begining of automating
This commit is contained in:
parent
9e7eb6774b
commit
e1b15c38d7
2 changed files with 41 additions and 40 deletions
|
@ -118,12 +118,6 @@ class AppTest{
|
|||
return $this->errorClass;
|
||||
|
||||
}
|
||||
|
||||
public function getOutput($key){
|
||||
|
||||
return $this->output[$key];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ class automating implements Core{
|
|||
protected $appImage;
|
||||
protected $appNetwork;
|
||||
protected $appIdentity;
|
||||
protected $appFloatingIp;
|
||||
protected $app;
|
||||
|
||||
/**
|
||||
|
@ -39,6 +40,7 @@ class automating implements Core{
|
|||
$this->appImage = $appImage;
|
||||
$this->appNetwork = $appNetwork;
|
||||
$this->appIdentity = $appIdentity;
|
||||
$this->appFloatingIp = $appFloatingIp;
|
||||
$this->app = $app;
|
||||
}
|
||||
|
||||
|
@ -53,50 +55,55 @@ class automating implements Core{
|
|||
$this->{$action.""}();
|
||||
}
|
||||
|
||||
public function script()
|
||||
{
|
||||
$opt = Array();
|
||||
$opt['name'] = getPostParam('name');
|
||||
|
||||
appImage->setPostParam('opt' $opt);
|
||||
appImage->createImage();
|
||||
|
||||
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 server and associate a public ip
|
||||
*
|
||||
* @param String $imageName name of the new image
|
||||
* @param String $serverName name ofthe new server
|
||||
* @param String $flavor kind of server
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function createServer()
|
||||
{
|
||||
$imageName = $this->app->getPostParam('imageName');
|
||||
$serverName = $this->app->getPostParam('serverName');
|
||||
$flavor = $this->app->getPostParam('flavor');
|
||||
|
||||
// Création image
|
||||
$opt = Array();
|
||||
$opt['name'] = $imageName;
|
||||
$this->app->setPostParam('opt' $opt);
|
||||
$this->appImage->createImage();
|
||||
$image = json_decode($this->app->show(), true)["Images"];
|
||||
if(!isset($imageName)){
|
||||
$this->app->setOutput("Error", "Incorrect imageName parameter");
|
||||
}
|
||||
else if(!isset($serverName)){
|
||||
$this->app->setOutput("Error", "Incorrect serverName parameter");
|
||||
}
|
||||
else if(!isset($flavor)){
|
||||
$this->app->setOutput("Error", "Incorrect flavor parameter");
|
||||
}
|
||||
else{
|
||||
// Création image
|
||||
$opt = array();
|
||||
$opt['name'] = $imageName;
|
||||
$this->appImage->setPostParam('opt' $opt);
|
||||
$this->appImage->createImage();
|
||||
$image = json_decode($this->app->show(), true)["Images"];
|
||||
|
||||
// Création server
|
||||
$this->app->setPostParam('name', $serverName);
|
||||
$this->app->setPostParam('imageId', $image['id']);
|
||||
$this->app->setPostParam('flavorId', $flavor);
|
||||
$this->appNetwork->createServer();
|
||||
// Création server
|
||||
$this->appCompute->setPostParam('name', $serverName);
|
||||
$this->appCompute->setPostParam('imageId', $image['id']);
|
||||
$this->appCompute->setPostParam('flavorId', $flavor);
|
||||
$this->appCompute->createServer();
|
||||
$server = json_decode($this->app->show(), true)["Compute"];
|
||||
|
||||
// Ajout adresse IP public
|
||||
// Ajout adresse IP public
|
||||
$optIp = array();
|
||||
$opt['floatingip'] = null; //new floatingip(); ???
|
||||
$opt['floating_network_id'] = $server['id'];
|
||||
$this->appFloatingIp->setPostParam('opt', $optIp);
|
||||
$this->appFloatingIp->create();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
Loading…
Add table
Reference in a new issue