added script function and put in a layout of module-specific functions for automation to be called from objects of various classes of our app
This commit is contained in:
parent
804fa322d8
commit
cb2e0a46df
2 changed files with 32 additions and 18 deletions
|
@ -5,7 +5,7 @@
|
||||||
* @version 1.0 Initialisation of this file
|
* @version 1.0 Initialisation of this file
|
||||||
* @since 1.0 Core application's file
|
* @since 1.0 Core application's file
|
||||||
*
|
*
|
||||||
* @author Evan Pisani 'yogg at epsina . com'
|
* @author Evan Pisani 'yogg at epsina . com' et bhupi
|
||||||
*
|
*
|
||||||
* @todo Complete the functions with errors detection and finish the descriptions
|
* @todo Complete the functions with errors detection and finish the descriptions
|
||||||
*/
|
*/
|
||||||
|
@ -16,25 +16,28 @@ include("Network.php");
|
||||||
include("Compute.php");
|
include("Compute.php");
|
||||||
|
|
||||||
class automating implements Core{
|
class automating implements Core{
|
||||||
/** @var App $app protected, contains the main app object */
|
|
||||||
protected $app;
|
|
||||||
|
|
||||||
/** @var OpenStack\Identity $libClass protected, contains the library Identity object */
|
/** @var App $app protected, contains the main app object */
|
||||||
protected $libClass;
|
protected $appCompute;
|
||||||
|
protected $appImage;
|
||||||
|
protected $appNetwork;
|
||||||
|
protected $appIdentity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Image constructor
|
* Our library's app constructor for all server app objects
|
||||||
*
|
*
|
||||||
* @param App $app the main app object
|
* @param App $app the main app object, e.g. compute, image, network, etc.
|
||||||
*
|
*
|
||||||
* @return Image
|
* @return
|
||||||
*/
|
*/
|
||||||
public function __construct($app){
|
public function __construct($app){
|
||||||
if(!isset($app)){
|
if(!isset($app)){
|
||||||
$this->app->setOutput("Error", "Incorrect parameter app");
|
$this->app->setOutput("Error", "Parameter app missing.");
|
||||||
}
|
}
|
||||||
$this->app = $app;
|
$this->appCompute = $appCompute;
|
||||||
$this->libClass = $app->getLibClass("Automating");
|
$this->appImage = $appImage;
|
||||||
|
$this->appNetwork = $appNetwork;
|
||||||
|
$this->appIdentity = $appIdentity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -48,6 +51,17 @@ class automating implements Core{
|
||||||
$this->{$action.""}();
|
$this->{$action.""}();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function script()
|
||||||
|
{
|
||||||
|
appImage->createImage();
|
||||||
|
appImage->create_network();
|
||||||
|
appImage->list_network_ids();
|
||||||
|
appImage->create_subnet();
|
||||||
|
appCompute->listFlavors();
|
||||||
|
appCompute->listImages();
|
||||||
|
appCompute->createServer();
|
||||||
|
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Create a new image on a new server
|
* Create a new image on a new server
|
||||||
*
|
*
|
||||||
|
|
|
@ -170,7 +170,7 @@ class compute
|
||||||
try{
|
try{
|
||||||
$serverId = $this->app->getPostParam("serverId");
|
$serverId = $this->app->getPostParam("serverId");
|
||||||
if(!isset($serverId)){
|
if(!isset($serverId)){
|
||||||
$this->app->setOutput("Error", "Server ID is missing, son!");
|
$this->app->setOutput("Error", "Server ID is missing!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$opt = array('id' => $serverId);
|
$opt = array('id' => $serverId);
|
||||||
|
@ -204,7 +204,7 @@ class compute
|
||||||
try{
|
try{
|
||||||
$flavorId = $this->app->getPostParam("flavorId");
|
$flavorId = $this->app->getPostParam("flavorId");
|
||||||
if(!isset($serverId)){
|
if(!isset($serverId)){
|
||||||
$this->app->setOutput("Error", "Flavor ID is missing, son!");
|
$this->app->setOutput("Error", "Flavor ID is missing!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$opt = array('id' => $flavorId);
|
$opt = array('id' => $flavorId);
|
||||||
|
@ -238,7 +238,7 @@ class compute
|
||||||
try{
|
try{
|
||||||
$imageId = $this->app->getPostParam("imageId");
|
$imageId = $this->app->getPostParam("imageId");
|
||||||
if(!isset($serverId)){
|
if(!isset($serverId)){
|
||||||
$this->app->setOutput("Error", "Image ID is missing, son!");
|
$this->app->setOutput("Error", "Image ID is missing!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$opt = array('id' => $imageId);
|
$opt = array('id' => $imageId);
|
||||||
|
@ -274,7 +274,7 @@ class compute
|
||||||
$imageId = $this->app->getPostParam("imageId");
|
$imageId = $this->app->getPostParam("imageId");
|
||||||
$flavorId = $this->app->getPostParam("flavorId");
|
$flavorId = $this->app->getPostParam("flavorId");
|
||||||
if(!isset($name) || !isset($imageId) || !isset($flavorId)){
|
if(!isset($name) || !isset($imageId) || !isset($flavorId)){
|
||||||
$this->app->setOutput("Error", "No, we don't let you create a server without a name OR image ID OR flavor ID.");
|
$this->app->setOutput("Error", "Server name OR image ID OR flavor ID is missing.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$opt = array('name' => $name, 'imageId' => $imageId, 'flavorId' => $flavorId);
|
$opt = array('name' => $name, 'imageId' => $imageId, 'flavorId' => $flavorId);
|
||||||
|
@ -353,7 +353,7 @@ class compute
|
||||||
try{
|
try{
|
||||||
$serverId = $this->app->getPostParam("serverId");
|
$serverId = $this->app->getPostParam("serverId");
|
||||||
if(!isset($serverId)){
|
if(!isset($serverId)){
|
||||||
$this->app->setOutput("Error", "Server ID is missing, son!");
|
$this->app->setOutput("Error", "Server ID is missing!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$opt = array('id' => $serverId);
|
$opt = array('id' => $serverId);
|
||||||
|
@ -422,7 +422,7 @@ class compute
|
||||||
try{
|
try{
|
||||||
$serverId = $this->app->getPostParam("serverId");
|
$serverId = $this->app->getPostParam("serverId");
|
||||||
if(!isset($serverId)){
|
if(!isset($serverId)){
|
||||||
$this->app->setOutput("Error", "Server ID is missing, son!");
|
$this->app->setOutput("Error", "Server ID is missing!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$opt = array('id' => $serverId);
|
$opt = array('id' => $serverId);
|
||||||
|
|
Loading…
Add table
Reference in a new issue