diff options
| author | Yoggzo <yogg@epsina.com> | 2016-03-30 18:30:44 +0200 |
|---|---|---|
| committer | Yoggzo <yogg@epsina.com> | 2016-03-30 18:30:44 +0200 |
| commit | c32933b362874d99207a4305d09b203dcbf20585 (patch) | |
| tree | 2920aec4b3aec75a0b32029d7b7c4c3143dc5941 | |
| parent | b6ffc16d78e3fd22f9d728d45cef1c78c182cc1f (diff) | |
debut automatisation
| -rw-r--r-- | server/core/Automating.php | 89 |
1 files changed, 20 insertions, 69 deletions
diff --git a/server/core/Automating.php b/server/core/Automating.php index 1eef72c..4a6a0b4 100644 --- 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; } /** @@ -72,79 +74,28 @@ class automating implements Core{ 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); - } } } |
