summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYoggzo <yogg@epsina.com>2016-04-18 17:38:25 +0200
committerYoggzo <yogg@epsina.com>2016-04-18 17:38:25 +0200
commite1b15c38d7f3bd158d477537bb26256baa7565a8 (patch)
tree5fe2f85a439b74c54ffbccce6db94af086e55461
parent9e7eb6774b823c1716ec14476ac8e53d758143ab (diff)
begining of automating
-rwxr-xr-xserver/Test/AppTestClass.php6
-rwxr-xr-xserver/core/Automating.php75
2 files changed, 41 insertions, 40 deletions
diff --git a/server/Test/AppTestClass.php b/server/Test/AppTestClass.php
index d2f71e7..a663514 100755
--- a/server/Test/AppTestClass.php
+++ b/server/Test/AppTestClass.php
@@ -118,12 +118,6 @@ class AppTest{
return $this->errorClass;
}
-
- public function getOutput($key){
-
- return $this->output[$key];
-
- }
}
diff --git a/server/core/Automating.php b/server/core/Automating.php
index 4a6a0b4..69a2773 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 $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;
}
@@ -52,51 +54,56 @@ class automating implements Core{
public function action($action){
$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();
+ }
}
+
}
?>