diff options
Diffstat (limited to 'server/core/Automating.php')
| -rwxr-xr-x[-rw-r--r--] | server/core/Automating.php | 103 |
1 files changed, 30 insertions, 73 deletions
diff --git a/server/core/Automating.php b/server/core/Automating.php index df6e829..4a6a0b4 100644..100755 --- a/server/core/Automating.php +++ b/server/core/Automating.php @@ -22,6 +22,7 @@ class automating implements Core{ protected $appImage; protected $appNetwork; protected $appIdentity; + protected $app; /** * Our library's app constructor for all server app objects @@ -38,6 +39,7 @@ class automating implements Core{ $this->appImage = $appImage; $this->appNetwork = $appNetwork; $this->appIdentity = $appIdentity; + $this->app = $app; } /** @@ -53,92 +55,47 @@ 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"); appCompute->createServer(); } - /** - * Create a new image on a new server - * - * @param $name the name of the new image - * @param $falvor_id the id of the flavor it will be used to create the new server - * - * @return Image the new image created - */ - private function createImageOnNewServer(){ - try{ - /* POURRI - $image = new Image($this->app); - $compute = new Compute($this->app); - - $name = $this->app->getPostParam("name"); - $falvor_id = $this->app->getPostParam("falvor_id"); // Compris entre 1 et 5 (1=petit serveur, 5=gros serveur) - - $opt = Array(); - $opt['name'] = $name; - $opt['visibility'] = 'public'; - $opt['minDisk'] = 100; // A VOIR - $opt['minRam'] = 128; // A VOIR - $opt['protected'] = false; - - $this->app->setPostParam("opt", $opt); - - $image->action("createImage"); - $res = json_decode($this->app->show(), true)["Images"]; - + + private function createServer() + { + $imageName = $this->app->getPostParam('imageName'); + $serverName = $this->app->getPostParam('serverName'); + $flavor = $this->app->getPostParam('flavor'); - $this->app->setPostParam("name", $name); - $this->app->setPostParam("imageId", $res['id']); - $this->app->setPostParam("flavorId", $falvor_id); + // Création image + $opt = Array(); + $opt['name'] = $imageName; + $this->app->setPostParam('opt' $opt); + $this->appImage->createImage(); + $image = json_decode($this->app->show(), true)["Images"]; - $compute->action("createServer"); - */ - }catch(BadResponseError $e){ - $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ - $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ - $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ - $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } - //$this->app->setOutput("Auto", $res); - } + // Création server + $this->app->setPostParam('name', $serverName); + $this->app->setPostParam('imageId', $image['id']); + $this->app->setPostParam('flavorId', $flavor); + $this->appNetwork->createServer(); + // Ajout adresse IP public - /** - * Create a new image on an existing server - * - * @param $name the name of the new image - * @param $server_id the id of the server - * - * @return Image the new image created - */ - private function createImageOnServer(){ - try{ - - }catch(BadResponseError $e){ - $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ - $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ - $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ - $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } } } |
