diff options
Diffstat (limited to 'server/core')
| -rwxr-xr-x | server/core/FloatingIp.php | 111 |
1 files changed, 74 insertions, 37 deletions
diff --git a/server/core/FloatingIp.php b/server/core/FloatingIp.php index 528ab4f..cdbb64b 100755 --- a/server/core/FloatingIp.php +++ b/server/core/FloatingIp.php @@ -101,11 +101,10 @@ class floatingIp { } try{ $floatingip = $this->libClass->createFloatingIp($opt); - echo 'YOLO'; + if(!isset($floatingip)){ $this->app->setOutput("Error", "Unknowing error during floating ip creation"); - } - else{ + }else{ $this->app->setOutput("FloatingIp", $floatingip); } }catch(BadResponseError $e){ @@ -141,20 +140,29 @@ class floatingIp { } try{ - /*$l = $this->listFloatingIp(); - $res = null; - foreach ($l as $f) { - if($f['id']==$id){ - $res = $f; + // List of floating IPs + $res = array(); + $l = $this->libClass->listFloatingIps(); + foreach ($l as $tmp) { + $res[] = $tmp; + } + + // Verification if id exists + $result = null; + foreach ($res as $f) { + if(strcmp($res['id'], $id)){ + $result = $f; + } } - if(!isset($f)){ + + if(!isset($result)){ // If id doesn't exists $this->app->setOutput("Error", "Unknow id"); - } - else{*/ + }else{ // If id exists $res = $this->libClass->getFloatingIp($id); $this->app->setOutput("FloatingIp", $res); - //} + } + }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); }catch(UserInputError $e){ @@ -182,18 +190,29 @@ class floatingIp { $this->app->setOutput("Error", "Incorrect parameter opt"); } try{ - $floatingips = listFloatingIps(); - $floatingIp = null; - foreach ($floatingips as $f) { - if($f['id'] == $id){ - $floatingIp = $f; + + // List of floating IPs + $res = array(); + $l = $this->libClass->listFloatingIps(); + foreach ($l as $tmp) { + $res[] = $tmp; + } + + // Verification if id exists + $result = null; + foreach ($res as $f) { + if(strcmp($res['id'], $id)){ + $result = $f; + } } - if(!isset($floatingIp)){ + + if(!isset($result)){ // If id doesn't exists $this->app->setOutput("Error", "Unknowing floatingip id"); + }else{ + $result->update(); } - - $floatingip->update(); + }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); @@ -222,19 +241,27 @@ class floatingIp { $this->app->setOutput("Error", "Incorrect parameter opt"); } try{ - $floatingips = listFloatingIps(); - $floatingIp = null; - foreach ($floatingips as $f) { - if($f['id'] == $id){ - $floatingIp = $f; + // List of floating IPs + $res = array(); + $l = $this->libClass->listFloatingIps(); + foreach ($l as $tmp) { + $res[] = $tmp; + } + + // Verification if id exists + $result = null; + foreach ($res as $f) { + if(strcmp($res['id'], $id)){ + $result = $f; + } } - if(!isset($floatingIp)){ + + if(!isset($result)){ // If id doesn't exists $this->app->setOutput("Error", "Unknowing floatingip id"); + }else{ + $result->delete(); } - - $floatingip->delete(); - }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); }catch(UserInputError $e){ @@ -248,6 +275,7 @@ class floatingIp { } } + /** * Retrieve a floating ip * @@ -262,18 +290,27 @@ class floatingIp { $this->app->setOutput("Error", "Incorrect parameter opt"); } try{ - $floatingips = listFloatingIps(); - $floatingIp = null; - foreach ($floatingips as $f) { - if($f['id'] == $id){ - $floatingIp = $f; + // List of floating IPs + $res = array(); + $l = $this->libClass->listFloatingIps(); + foreach ($l as $tmp) { + $res[] = $tmp; + } + + // Verification if id exists + $result = null; + foreach ($res as $f) { + if(strcmp($res['id'], $id)){ + $result = $f; + } } - if(!isset($floatingIp)){ + + if(!isset($result)){ // If id doesn't exists $this->app->setOutput("Error", "Unknowing floatingip id"); + }else{ + $result->retrieve(); } - - $floatingip->retrieve(); }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); }catch(UserInputError $e){ |
