diff --git a/server/Test/AppTestClass.php b/server/Test/AppTestClass.php index a663514..eaea7f6 100755 --- a/server/Test/AppTestClass.php +++ b/server/Test/AppTestClass.php @@ -63,6 +63,11 @@ class AppTest{ $opt = $this->tokenClass->getOptions($service); return $this->openstack->networkingV2($opt); break; + case "FloatingIp": + if($this->tokenPost == NULL) $this->tokenClass->genNetworkToken(); + $opt = $this->tokenClass->getOptions($service); + return $this->openstack->networkingV2ExtLayer3($opt); + break; } } diff --git a/server/Test/automatingTests.php b/server/Test/automatingTests.php index 5cdee26..6de4de5 100644 --- a/server/Test/automatingTests.php +++ b/server/Test/automatingTests.php @@ -2,23 +2,27 @@ include('InitTest.php'); include_once("../core/Image.php"); include_once("../core/Compute.php"); -include_once("../core/Network.php"); +//include_once("../core/Network.php"); +//include_once("../core/Automating.php"); include_once("../core/FloatingIp.php"); -include_once("../core/Automating.php"); $image = new Image($App); $compute = new Compute($App); -$network = new Network($App); +//$network = new Network($App); $floatingIp = new FloatingIp($App); -$automating = new Automating($App); - - -$compute->listServers(); +//$automating = new Automating($App); +// Liste des serveurs +$compute->action("listServers"); $servers = json_decode($App->show(), true)["Servers"]; - foreach($servers as $server){ - echo $server->name." ".$server->id."
"; + echo $server['name']." ".$server['id']."
"; } +// liste des floatingip +$floatingIp->action("listFloatingIp"); +$listFloatingIp = json_decode($App->show(), true)["FloatingIp"]; +foreach ($listFloatingIp as $floatIp){ + echo $floatIp['floating_ip_address']." ".$floatIp['id']." ".$floatIp["status"]."
"; +} ?> \ No newline at end of file diff --git a/server/core/FloatingIp.php b/server/core/FloatingIp.php index c5a947e..bbcd888 100755 --- a/server/core/FloatingIp.php +++ b/server/core/FloatingIp.php @@ -14,7 +14,7 @@ use OpenCloud\Common\Error\BaseError; use OpenCloud\Common\Error\NotImplementedError; use OpenCloud\Common\Error\UserInputError; -include("CoreInterface.php"); +//include("CoreInterface.php"); /** * Image Class of the back-end application @@ -22,7 +22,7 @@ include("CoreInterface.php"); * Management of images * */ -class floatingIp implements Core{ +class floatingIp { /** @var App $app protected, contains the main app object */ protected $app; @@ -31,11 +31,11 @@ class floatingIp implements Core{ protected $libClass; /** - * Image constructor + * floatingip constructor * * @param App $app the main app object * - * @return Image + * @return floatingip */ public function __construct($app){ if(!isset($app)){ @@ -57,6 +57,36 @@ class floatingIp implements Core{ $this->{$action.""}(); } + + /** + * List floatingip + * + * @return list of the floatingip + */ + private function listFloatingIp(){ + try{ + $result = array(); + $l = $this->libClass->getFloatingIps(); + + + + foreach ($l as $tmp) { + $serult[] = $tmp; + } + $this->app->setOutput("FloatingIp", $result); + }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); + } + } + /** * Create a new floating IP adress * @@ -72,7 +102,7 @@ class floatingIp implements Core{ } try{ $floatingip = $this->libClass->create($opt); - if(!isset){ + if(!isset($floatingip)){ $this->app->setOutput("Error", "Unknowing error during floating ip creation"); } else{ @@ -118,9 +148,6 @@ class floatingIp implements Core{ $floatingip->update(); - if(!isset){ - $this->app->setOutput("Error", "Unknowing error during floating ip creation"); - } }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); }catch(UserInputError $e){ @@ -161,9 +188,6 @@ class floatingIp implements Core{ $floatingip->delete(); - if(!isset){ - $this->app->setOutput("Error", "Unknowing error during floating ip creation"); - } }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); }catch(UserInputError $e){ @@ -203,10 +227,6 @@ class floatingIp implements Core{ } $floatingip->retrieve(); - - if(!isset){ - $this->app->setOutput("Error", "Unknowing error during floating ip creation"); - } }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); }catch(UserInputError $e){