debut automatisation
This commit is contained in:
parent
b6ffc16d78
commit
c32933b362
1 changed files with 20 additions and 69 deletions
|
@ -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)
|
||||
|
||||
private function createServer()
|
||||
{
|
||||
$imageName = $this->app->getPostParam('imageName');
|
||||
$serverName = $this->app->getPostParam('serverName');
|
||||
$flavor = $this->app->getPostParam('flavor');
|
||||
|
||||
$opt = Array();
|
||||
$opt['name'] = $name;
|
||||
$opt['visibility'] = 'public';
|
||||
$opt['minDisk'] = 100; // A VOIR
|
||||
$opt['minRam'] = 128; // A VOIR
|
||||
$opt['protected'] = false;
|
||||
// Création image
|
||||
$opt = Array();
|
||||
$opt['name'] = $imageName;
|
||||
$this->app->setPostParam('opt' $opt);
|
||||
$this->appImage->createImage();
|
||||
$image = json_decode($this->app->show(), true)["Images"];
|
||||
|
||||
$this->app->setPostParam("opt", $opt);
|
||||
// Création server
|
||||
$this->app->setPostParam('name', $serverName);
|
||||
$this->app->setPostParam('imageId', $image['id']);
|
||||
$this->app->setPostParam('flavorId', $flavor);
|
||||
$this->appNetwork->createServer();
|
||||
|
||||
$image->action("createImage");
|
||||
$res = json_decode($this->app->show(), true)["Images"];
|
||||
// Ajout adresse IP public
|
||||
|
||||
|
||||
$this->app->setPostParam("name", $name);
|
||||
$this->app->setPostParam("imageId", $res['id']);
|
||||
$this->app->setPostParam("flavorId", $falvor_id);
|
||||
|
||||
$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);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue