From 9e7eb6774b823c1716ec14476ac8e53d758143ab Mon Sep 17 00:00:00 2001 From: Yoggzo Date: Mon, 18 Apr 2016 17:20:27 +0200 Subject: begining of floating ip --- server/core/FloatingIp.php | 195 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 195 insertions(+) create mode 100644 server/core/FloatingIp.php (limited to 'server/core/FloatingIp.php') diff --git a/server/core/FloatingIp.php b/server/core/FloatingIp.php new file mode 100644 index 0000000..72ae836 --- /dev/null +++ b/server/core/FloatingIp.php @@ -0,0 +1,195 @@ +app->setOutput("Error", "Incorrect parameter app"); + } + $this->app = $app; + $this->libClass = $app->getLibClass("FloatingIp"); + } + + + /** + * Execute an action + * + * @param String $action name of another function of this class + * + * @return void + */ + public function action($action){ + $this->{$action.""}(); + } + + /** + * Create a new floating IP adress + * + * @param array $opt Options for the floating ip creation (floatingipo and floating network id are required, others are optionals) + * + * @return floatingip + */ + private function createFloatingIp(){ + $opt = $this->app->getPostParam("opt"); + + if(!isset($opt)){ + $this->app->setOutput("Error", "Incorrect parameter opt"); + } + try{ + $floatingip = $this->libClass->create($opt); + if(!isset){ + $this->app->setOutput("Error", "Unknowing error during floating ip creation"); + } + else{ + $this->app->setOutput("FloatingIp", $floatingip); + } + }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); + } + } + + /** + * Update floating ip + * + * @param id the id of the floatingip to update + * + * @return Image + */ + private function updateFloatingIp(){ + $id = $this->app->getPostParam("id"); + + if(!isset($id)){ + $this->app->setOutput("Error", "Incorrect parameter opt"); + } + try{ + $floatingip = null; //obtenir ip + + $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){ + $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); + } + } + + /** + * Delete a floating ip + * + * @param string floatingip_id the floating-ip id to delete + * + * @return void + */ + private function deleteFloatingIp(){ + $id = $this->app->getPostParam("id"); + + if(!isset($id)){ + $this->app->setOutput("Error", "Incorrect parameter opt"); + } + try{ + $floatingip = null; //obtenir ip + + $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){ + $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); + } + } + + /** + * Retrieve a floating ip + * + * @param string floatingip_id the floating-ip id to retrieve + * + * @return void + */ + private function retrieveFloatingIp(){ + $id = $this->app->getPostParam("id"); + + if(!isset($id)){ + $this->app->setOutput("Error", "Incorrect parameter opt"); + } + try{ + $floatingip = null; //obtenir ip + + $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){ + $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); + } + } +} -- cgit v1.2.3 From 71794b98c560fa7904a4b3550a21b64ec6cd9339 Mon Sep 17 00:00:00 2001 From: EoleDev Date: Mon, 18 Apr 2016 20:01:50 +0200 Subject: Add floating request --- server/core/FloatingIp.php | 2 +- server/index.php | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) mode change 100644 => 100755 server/core/FloatingIp.php (limited to 'server/core/FloatingIp.php') diff --git a/server/core/FloatingIp.php b/server/core/FloatingIp.php old mode 100644 new mode 100755 index 72ae836..4271a84 --- a/server/core/FloatingIp.php +++ b/server/core/FloatingIp.php @@ -22,7 +22,7 @@ include("CoreInterface.php"); * Management of images * */ -class FloatingIp implements Core{ +class floatingIp implements Core{ /** @var App $app protected, contains the main app object */ protected $app; diff --git a/server/index.php b/server/index.php index d6b0329..ac66c95 100755 --- a/server/index.php +++ b/server/index.php @@ -52,6 +52,13 @@ $computeObject->action($action); $App->show(); break; + + case "floatingip": + include_once("core/FloatingIp.php"); + $computeObject = new floatingIp($App); + $computeObject->action($action); + $App->show(); + break; } }else{ -- cgit v1.2.3