From 2d260aa6f591030f869063ccdb1f6997d12c1294 Mon Sep 17 00:00:00 2001 From: Yoggzo Date: Tue, 19 Apr 2016 17:17:14 +0200 Subject: [PATCH] correct syntaxt on Network, add tests for automating --- server/Test/automatingTests.php | 24 ++++++++++++++++++++++++ server/core/FloatingIp.php | 33 ++++++++++++++++++++++++++++++--- server/core/Network.php | 10 ++++------ 3 files changed, 58 insertions(+), 9 deletions(-) create mode 100644 server/Test/automatingTests.php diff --git a/server/Test/automatingTests.php b/server/Test/automatingTests.php new file mode 100644 index 0000000..5cdee26 --- /dev/null +++ b/server/Test/automatingTests.php @@ -0,0 +1,24 @@ +listServers(); + +$servers = json_decode($App->show(), true)["Servers"]; + +foreach($servers as $server){ + echo $server->name." ".$server->id."
"; +} + +?> \ No newline at end of file diff --git a/server/core/FloatingIp.php b/server/core/FloatingIp.php index 4271a84..c5a947e 100755 --- a/server/core/FloatingIp.php +++ b/server/core/FloatingIp.php @@ -105,7 +105,16 @@ class floatingIp implements Core{ $this->app->setOutput("Error", "Incorrect parameter opt"); } try{ - $floatingip = null; //obtenir ip + $floatingips = listFloatingIps(); + $floatingIp = null; + foreach ($floatingips as $f) { + if($f['id'] == $id){ + $floatingIp = $f; + } + } + if(!isset($floatingIp)){ + $this->app->setOutput("Error", "Unknowing floatingip id"); + } $floatingip->update(); @@ -139,7 +148,16 @@ class floatingIp implements Core{ $this->app->setOutput("Error", "Incorrect parameter opt"); } try{ - $floatingip = null; //obtenir ip + $floatingips = listFloatingIps(); + $floatingIp = null; + foreach ($floatingips as $f) { + if($f['id'] == $id){ + $floatingIp = $f; + } + } + if(!isset($floatingIp)){ + $this->app->setOutput("Error", "Unknowing floatingip id"); + } $floatingip->delete(); @@ -173,7 +191,16 @@ class floatingIp implements Core{ $this->app->setOutput("Error", "Incorrect parameter opt"); } try{ - $floatingip = null; //obtenir ip + $floatingips = listFloatingIps(); + $floatingIp = null; + foreach ($floatingips as $f) { + if($f['id'] == $id){ + $floatingIp = $f; + } + } + if(!isset($floatingIp)){ + $this->app->setOutput("Error", "Unknowing floatingip id"); + } $floatingip->retrieve(); diff --git a/server/core/Network.php b/server/core/Network.php index ad0cbaf..fef3512 100755 --- a/server/core/Network.php +++ b/server/core/Network.php @@ -333,8 +333,7 @@ class network{ * retrieve a specific network * @param networkId ID of network which we want to get * @return Network - */ - retrieve a specific network + */ private function getNetwork() { $network=""; @@ -592,7 +591,6 @@ class network{ * Delete a network given * * @param String networkId ID if network which we want to delete - * * * @return void @@ -627,7 +625,6 @@ class network{ * Delete a subnet given * * @param String subnetId ID if network which we want to delete - * * * @return void @@ -1187,7 +1184,7 @@ class network{ * @return void */ private function deleteSecurityGroupe() - { + { try { @@ -1210,4 +1207,5 @@ class network{ { $this->app->getErrorInstance->NotImplementedHandler($e); } - } + } +}