app->setOutput("Error", "Parameter app missing."); } $this->appCompute = $appCompute; $this->appImage = $appImage; $this->appNetwork = $appNetwork; $this->appIdentity = $appIdentity; $this->appFloatingIp = $appFloatingIp; $this->app = $app; } /** * Execute an action * * @param String $action name of another function of this class * * @return void */ public function action($action){ $this->{$action.""}(); } /** * 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'); 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->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 $optIp = array(); $opt['floatingip'] = null; //new floatingip(); ??? $opt['floating_network_id'] = $server['id']; $this->appFloatingIp->setPostParam('opt', $optIp); $this->appFloatingIp->create(); } } } ?>