From cb2e0a46dff0349400e02410f4cdecad2fc87db4 Mon Sep 17 00:00:00 2001 From: stupidon Date: Tue, 29 Mar 2016 08:07:35 +0200 Subject: 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 --- server/core/Automating.php | 38 ++++++++++++++++++++++++++------------ server/core/Compute.php | 12 ++++++------ 2 files changed, 32 insertions(+), 18 deletions(-) (limited to 'server/core') diff --git a/server/core/Automating.php b/server/core/Automating.php index 7f2c654..adad348 100644 --- a/server/core/Automating.php +++ b/server/core/Automating.php @@ -5,7 +5,7 @@ * @version 1.0 Initialisation of this 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 */ @@ -16,25 +16,28 @@ include("Network.php"); include("Compute.php"); 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 */ - 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){ if(!isset($app)){ - $this->app->setOutput("Error", "Incorrect parameter app"); + $this->app->setOutput("Error", "Parameter app missing."); } - $this->app = $app; - $this->libClass = $app->getLibClass("Automating"); + $this->appCompute = $appCompute; + $this->appImage = $appImage; + $this->appNetwork = $appNetwork; + $this->appIdentity = $appIdentity; } /** @@ -48,6 +51,17 @@ class automating implements Core{ $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 * @@ -124,4 +138,4 @@ class automating implements Core{ } } -?> \ No newline at end of file +?> diff --git a/server/core/Compute.php b/server/core/Compute.php index e72abf9..4a7fe6c 100755 --- a/server/core/Compute.php +++ b/server/core/Compute.php @@ -170,7 +170,7 @@ class compute try{ $serverId = $this->app->getPostParam("serverId"); if(!isset($serverId)){ - $this->app->setOutput("Error", "Server ID is missing, son!"); + $this->app->setOutput("Error", "Server ID is missing!"); return; } $opt = array('id' => $serverId); @@ -204,7 +204,7 @@ class compute try{ $flavorId = $this->app->getPostParam("flavorId"); if(!isset($serverId)){ - $this->app->setOutput("Error", "Flavor ID is missing, son!"); + $this->app->setOutput("Error", "Flavor ID is missing!"); return; } $opt = array('id' => $flavorId); @@ -238,7 +238,7 @@ class compute try{ $imageId = $this->app->getPostParam("imageId"); if(!isset($serverId)){ - $this->app->setOutput("Error", "Image ID is missing, son!"); + $this->app->setOutput("Error", "Image ID is missing!"); return; } $opt = array('id' => $imageId); @@ -274,7 +274,7 @@ class compute $imageId = $this->app->getPostParam("imageId"); $flavorId = $this->app->getPostParam("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; } $opt = array('name' => $name, 'imageId' => $imageId, 'flavorId' => $flavorId); @@ -353,7 +353,7 @@ class compute try{ $serverId = $this->app->getPostParam("serverId"); if(!isset($serverId)){ - $this->app->setOutput("Error", "Server ID is missing, son!"); + $this->app->setOutput("Error", "Server ID is missing!"); return; } $opt = array('id' => $serverId); @@ -422,7 +422,7 @@ class compute try{ $serverId = $this->app->getPostParam("serverId"); if(!isset($serverId)){ - $this->app->setOutput("Error", "Server ID is missing, son!"); + $this->app->setOutput("Error", "Server ID is missing!"); return; } $opt = array('id' => $serverId); -- cgit v1.2.3 From d27f9248b2b8ef2829f14ba1331a9ba6dfbe8ed0 Mon Sep 17 00:00:00 2001 From: stupidon Date: Wed, 30 Mar 2016 11:06:03 +0200 Subject: added passage of parameters to the create functions in the script --- server/core/.Image.php.swp | Bin 0 -> 16384 bytes server/core/Automating.php | 8 ++++++-- 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 server/core/.Image.php.swp (limited to 'server/core') diff --git a/server/core/.Image.php.swp b/server/core/.Image.php.swp new file mode 100644 index 0000000..68e866c Binary files /dev/null and b/server/core/.Image.php.swp differ diff --git a/server/core/Automating.php b/server/core/Automating.php index adad348..df6e829 100644 --- a/server/core/Automating.php +++ b/server/core/Automating.php @@ -53,12 +53,16 @@ class automating implements Core{ public function script() { + appImage->setPostParam("A_REMPLIR_PAR_Evan","VALEUR"); appImage->createImage(); appImage->create_network(); appImage->list_network_ids(); appImage->create_subnet(); - appCompute->listFlavors(); - appCompute->listImages(); + appCompute->listFlavors(); //to show all flavors with detail. + appCompute->listImages(); //to show all images with detail and to verify that the image was created successfully by the call above. + appCompute->setPostParam("name","Test"); + appCompute->setPostParam("imageId","CREATED_ABOVE"); + appCompute->setPostParam("flavorId","1"); appCompute->createServer(); } -- cgit v1.2.3 From 646af6fd4d14c5b5edb1372e5f68ed9bdc35b3d2 Mon Sep 17 00:00:00 2001 From: stupidon Date: Wed, 30 Mar 2016 11:07:35 +0200 Subject: removed swap file for image --- server/core/.Image.php.swp | Bin 16384 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 server/core/.Image.php.swp (limited to 'server/core') diff --git a/server/core/.Image.php.swp b/server/core/.Image.php.swp deleted file mode 100644 index 68e866c..0000000 Binary files a/server/core/.Image.php.swp and /dev/null differ -- cgit v1.2.3 From ba8b5feb07a7a19ca4a694313fa16d03a2fb2508 Mon Sep 17 00:00:00 2001 From: Yoggzo Date: Wed, 30 Mar 2016 11:56:26 +0200 Subject: ajout parametres dans Automating --- server/core/Automating.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'server/core') diff --git a/server/core/Automating.php b/server/core/Automating.php index df6e829..1eef72c 100644 --- a/server/core/Automating.php +++ b/server/core/Automating.php @@ -53,13 +53,19 @@ class automating implements Core{ public function script() { - appImage->setPostParam("A_REMPLIR_PAR_Evan","VALEUR"); + $opt = Array(); + $opt['name'] = getPostParam('name'); + + appImage->setPostParam('opt' $opt); appImage->createImage(); - appImage->create_network(); - appImage->list_network_ids(); - appImage->create_subnet(); + + appNetwork->create_network(); + appnetwork->list_network_ids(); + appNetwork->create_subnet(); + appCompute->listFlavors(); //to show all flavors with detail. appCompute->listImages(); //to show all images with detail and to verify that the image was created successfully by the call above. + appCompute->setPostParam("name","Test"); appCompute->setPostParam("imageId","CREATED_ABOVE"); appCompute->setPostParam("flavorId","1"); -- cgit v1.2.3 From 1fdc1a19ce180e4db111354cbedc436a15dd803c Mon Sep 17 00:00:00 2001 From: Apache Date: Wed, 30 Mar 2016 12:40:30 +0200 Subject: Reactivation Token time management --- server/core/LibOverride/genTokenOptions.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'server/core') diff --git a/server/core/LibOverride/genTokenOptions.php b/server/core/LibOverride/genTokenOptions.php index 4733c5a..1fbee06 100755 --- a/server/core/LibOverride/genTokenOptions.php +++ b/server/core/LibOverride/genTokenOptions.php @@ -51,9 +51,9 @@ class genTokenOptions } public function checkToken(){ - //error_log($this->backup['time'], 0); - //return $this->backup['time'] > time(); - return true; + //error_log(print_r($this->backup['time'], true), 0); + return $this->backup['time'] > time(); + //return true; } public function genIdentityToken(){ @@ -386,7 +386,7 @@ class genTokenOptions $token->catalog = new Models\Catalog($this->httpClient, $api); $token->catalog->services = []; - error_log(print_r($Saved["catalog"], true), 0); + //error_log(print_r($Saved["catalog"], true), 0); foreach($Saved["catalog"] as $key => $service){ $tmp = new Models\Service($this->httpClient, $api); -- cgit v1.2.3