From dcf0d8b2ba2547720215f7de55a747bf7ec47a0b Mon Sep 17 00:00:00 2001 From: Yoggzo Date: Wed, 23 Mar 2016 15:46:57 +0100 Subject: begining of automating tasks --- server/core/Automating.php | 95 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 server/core/Automating.php (limited to 'server/core/Automating.php') diff --git a/server/core/Automating.php b/server/core/Automating.php new file mode 100644 index 0000000..2665541 --- /dev/null +++ b/server/core/Automating.php @@ -0,0 +1,95 @@ +app->setOutput("Error", "Incorrect parameter app"); + } + $this->app = $app; + $this->libClass = $app->getLibClass("Automating"); + } + + /** + * Execute an action + * + * @param String $action name of another function of this class + * + * @return void + */ + public function action($action){ + $this->{$action.""}(); + } + + + private function createImageOnNewServer(){ + try{ + $image = new Image($this->app); + $compute = new Compute($this->app); + + $name = $this->app->getPostParam("name"); + $falvor_id = $this->app->getPostParam("falvor_id"); // Compris entre 1 et 5 (1=petit serveur, 5=gros serveur) + + $opt = Array(); + $opt['name'] = $name; + $opt['visibility'] = 'public'; + $opt['minDisk'] = 100; // A VOIR + $opt['minRam'] = 128; // A VOIR + $opt['protected'] = false; + + $this->app->setPostParam("opt", $opt); + + $image->action("createImage"); + $res = json_decode($this->app->show(), true)["Images"]; + + + $this->app->setPostParam("name", $name); + $this->app->setPostParam("imageId", $res['id']); + $this->app->setPostParam("flavorId", $falvor_id); + + $compute->action("createServer"); + + }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); + } + } + + +} + +?> \ No newline at end of file -- cgit v1.2.3 From 19d84e2ae4c6710aac2236df4f135409ef519fc8 Mon Sep 17 00:00:00 2001 From: Yoggzo Date: Sun, 27 Mar 2016 19:40:36 +0200 Subject: Update commentaries --- server/core/Automating.php | 15 +++++++---- server/core/ErrorManagement.php | 55 ++++++++++++++++++++++++++++++++++++++--- server/core/Image.php | 4 +-- 3 files changed, 64 insertions(+), 10 deletions(-) (limited to 'server/core/Automating.php') diff --git a/server/core/Automating.php b/server/core/Automating.php index 2665541..065cf5e 100644 --- a/server/core/Automating.php +++ b/server/core/Automating.php @@ -1,11 +1,11 @@ {$action.""}(); } - + /** + * Create a new image on a new server + * + * @param $error the error triggered + * + * @return Image the new image created + */ private function createImageOnNewServer(){ try{ $image = new Image($this->app); @@ -87,9 +93,8 @@ class automating implements Core{ }catch(Exception $e){ $this->app->getErrorInstance()->OtherException($e); } + $this->app->setOutput("Auto", $res); } - - } ?> \ No newline at end of file diff --git a/server/core/ErrorManagement.php b/server/core/ErrorManagement.php index e7cb83e..be7080b 100755 --- a/server/core/ErrorManagement.php +++ b/server/core/ErrorManagement.php @@ -1,4 +1,13 @@ app = $args; } + /** + * Put an error message corresponding to a base error in the output + * + * @param $error the error triggered + * + * @return String BaseError message + */ public function BaseErrorHandler($error){ $this->app->setOutput("Error", "BaseError"); } + /** + * Put an error message corresponding to a bad response in function of the status code in the output + * + * @param $error the error triggered + * + * @return String Error message + */ public function BadResponseHandler($error){ $statusCode = $error->getResponse()->getStatusCode(); switch ($statusCode) { @@ -54,19 +83,39 @@ Class errorManagement{ } } + /** + * Put an error message corresponding to a not implemented yet error in the output + * + * @param $error the error triggered + * + * @return String internal error message + */ public function NotImplementedHandler($error){ $this->app->setOutput("Error", "Internal error (not implemented yet), please contact an administrator"); } + /** + * Put an error message corresponding to a user input error in the output + * + * @param $error the error triggered + * + * @return String User input error message + */ public function UserInputHandler($error){ $this->app->setOutput("Error", "UserInputError"); } + /** + * Put an error message corresponding to an other error in the output + * + * @param $error the error triggered + * + * @return String error message + */ public function OtherException($error){ $this->app->setOutput("Error", $error->getMessage()); } - } ?> diff --git a/server/core/Image.php b/server/core/Image.php index e9736a2..c595135 100755 --- a/server/core/Image.php +++ b/server/core/Image.php @@ -5,7 +5,7 @@ * @version 1.0 Initialisation of this file * @since 1.0 Core application's file * -* @author Yogg 'yogg at epsina . com' +* @author Evan Pisani 'yogg at epsina . com' * * @todo Complete the functions with errors detection and finish the descriptions */ @@ -19,7 +19,7 @@ include("CoreInterface.php"); /** * Image Class of the back-end application * -* ADD CLASS DESCRIPTION +* Management of images * */ class image implements Core{ -- cgit v1.2.3 From 804fa322d841d73ee7592885ec500dc94e91b9e6 Mon Sep 17 00:00:00 2001 From: Yoggzo Date: Sun, 27 Mar 2016 19:54:38 +0200 Subject: difficulties with automating --- server/core/Automating.php | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'server/core/Automating.php') diff --git a/server/core/Automating.php b/server/core/Automating.php index 065cf5e..7f2c654 100644 --- a/server/core/Automating.php +++ b/server/core/Automating.php @@ -51,12 +51,14 @@ class automating implements Core{ /** * Create a new image on a new server * - * @param $error the error triggered + * @param $name the name of the new image + * @param $falvor_id the id of the flavor it will be used to create the new server * * @return Image the new image created */ private function createImageOnNewServer(){ try{ + /* POURRI $image = new Image($this->app); $compute = new Compute($this->app); @@ -81,6 +83,32 @@ class automating implements Core{ $this->app->setPostParam("flavorId", $falvor_id); $compute->action("createServer"); + */ + }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); + } + //$this->app->setOutput("Auto", $res); + } + + + /** + * Create a new image on an existing server + * + * @param $name the name of the new image + * @param $server_id the id of the server + * + * @return Image the new image created + */ + private function createImageOnServer(){ + try{ }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); @@ -93,7 +121,6 @@ class automating implements Core{ }catch(Exception $e){ $this->app->getErrorInstance()->OtherException($e); } - $this->app->setOutput("Auto", $res); } } -- cgit v1.2.3 From f4da4f285a4689e1d4eb8bb7d800d6570dfba6d0 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Mon, 28 Mar 2016 19:01:32 +0200 Subject: test --- client/js/services/Image.js | 4 ++-- server/Test/DisplayListCidr.php | 0 server/Test/getIdNetwork.php | 0 server/Test/getNetwork.php | 0 server/core/Automating.php | 0 server/core/Network.php~ | 0 server/vendor/php-opencloud/common/.travis.yml | 0 7 files changed, 2 insertions(+), 2 deletions(-) mode change 100644 => 100755 server/Test/DisplayListCidr.php mode change 100644 => 100755 server/Test/getIdNetwork.php mode change 100644 => 100755 server/Test/getNetwork.php mode change 100644 => 100755 server/core/Automating.php mode change 100644 => 100755 server/core/Network.php~ mode change 100644 => 100755 server/vendor/php-opencloud/common/.travis.yml (limited to 'server/core/Automating.php') diff --git a/client/js/services/Image.js b/client/js/services/Image.js index d427e51..d6c9fed 100644 --- a/client/js/services/Image.js +++ b/client/js/services/Image.js @@ -52,13 +52,13 @@ mainApp.factory('Image',[ '$http', 'Identity', function($http, Identity){ form_data.append("token" , Identity.getToken()) form_data.append('action',"uploadImage") form_data.append('id','6564') - form_data.append('file_name', fileToUpload.name); + form_data.append('file_name', fileToUpload); $.ajax({ url: "../server/index.php", // Url to which the request is send type: "POST", // Type of request to be send, called as method data: form_data, // Data sent to server, a set of key/value pairs (i.e. form fields and values) - file_name:fileToUpload.name, + file_name:fileToUpload, token : Identity.getToken(), task : "image", action:'uploadImage', diff --git a/server/Test/DisplayListCidr.php b/server/Test/DisplayListCidr.php old mode 100644 new mode 100755 diff --git a/server/Test/getIdNetwork.php b/server/Test/getIdNetwork.php old mode 100644 new mode 100755 diff --git a/server/Test/getNetwork.php b/server/Test/getNetwork.php old mode 100644 new mode 100755 diff --git a/server/core/Automating.php b/server/core/Automating.php old mode 100644 new mode 100755 diff --git a/server/core/Network.php~ b/server/core/Network.php~ old mode 100644 new mode 100755 diff --git a/server/vendor/php-opencloud/common/.travis.yml b/server/vendor/php-opencloud/common/.travis.yml old mode 100644 new mode 100755 -- cgit v1.2.3 From cb2e0a46dff0349400e02410f4cdecad2fc87db4 Mon Sep 17 00:00:00 2001 From: stupidon Date: Tue, 29 Mar 2016 08:07:35 +0200 Subject: added script function and put in a layout of module-specific functions for automation to be called from objects of various classes of our app --- server/core/Automating.php | 38 ++++++++++++++++++++++++++------------ server/core/Compute.php | 12 ++++++------ 2 files changed, 32 insertions(+), 18 deletions(-) (limited to 'server/core/Automating.php') diff --git a/server/core/Automating.php b/server/core/Automating.php index 7f2c654..adad348 100644 --- a/server/core/Automating.php +++ b/server/core/Automating.php @@ -5,7 +5,7 @@ * @version 1.0 Initialisation of this file * @since 1.0 Core application's file * -* @author Evan Pisani 'yogg at epsina . com' +* @author Evan Pisani 'yogg at epsina . com' et bhupi * * @todo Complete the functions with errors detection and finish the descriptions */ @@ -16,25 +16,28 @@ include("Network.php"); include("Compute.php"); class automating implements Core{ + /** @var App $app protected, contains the main app object */ - protected $app; - - /** @var OpenStack\Identity $libClass protected, contains the library Identity object */ - protected $libClass; + protected $appCompute; + protected $appImage; + protected $appNetwork; + protected $appIdentity; /** - * Image constructor + * Our library's app constructor for all server app objects * - * @param App $app the main app object + * @param App $app the main app object, e.g. compute, image, network, etc. * - * @return Image + * @return */ public function __construct($app){ if(!isset($app)){ - $this->app->setOutput("Error", "Incorrect parameter app"); + $this->app->setOutput("Error", "Parameter app missing."); } - $this->app = $app; - $this->libClass = $app->getLibClass("Automating"); + $this->appCompute = $appCompute; + $this->appImage = $appImage; + $this->appNetwork = $appNetwork; + $this->appIdentity = $appIdentity; } /** @@ -48,6 +51,17 @@ class automating implements Core{ $this->{$action.""}(); } + public function script() + { + appImage->createImage(); + appImage->create_network(); + appImage->list_network_ids(); + appImage->create_subnet(); + appCompute->listFlavors(); + appCompute->listImages(); + appCompute->createServer(); + + } /** * Create a new image on a new server * @@ -124,4 +138,4 @@ class automating implements Core{ } } -?> \ No newline at end of file +?> diff --git a/server/core/Compute.php b/server/core/Compute.php index e72abf9..4a7fe6c 100755 --- a/server/core/Compute.php +++ b/server/core/Compute.php @@ -170,7 +170,7 @@ class compute try{ $serverId = $this->app->getPostParam("serverId"); if(!isset($serverId)){ - $this->app->setOutput("Error", "Server ID is missing, son!"); + $this->app->setOutput("Error", "Server ID is missing!"); return; } $opt = array('id' => $serverId); @@ -204,7 +204,7 @@ class compute try{ $flavorId = $this->app->getPostParam("flavorId"); if(!isset($serverId)){ - $this->app->setOutput("Error", "Flavor ID is missing, son!"); + $this->app->setOutput("Error", "Flavor ID is missing!"); return; } $opt = array('id' => $flavorId); @@ -238,7 +238,7 @@ class compute try{ $imageId = $this->app->getPostParam("imageId"); if(!isset($serverId)){ - $this->app->setOutput("Error", "Image ID is missing, son!"); + $this->app->setOutput("Error", "Image ID is missing!"); return; } $opt = array('id' => $imageId); @@ -274,7 +274,7 @@ class compute $imageId = $this->app->getPostParam("imageId"); $flavorId = $this->app->getPostParam("flavorId"); if(!isset($name) || !isset($imageId) || !isset($flavorId)){ - $this->app->setOutput("Error", "No, we don't let you create a server without a name OR image ID OR flavor ID."); + $this->app->setOutput("Error", "Server name OR image ID OR flavor ID is missing."); return; } $opt = array('name' => $name, 'imageId' => $imageId, 'flavorId' => $flavorId); @@ -353,7 +353,7 @@ class compute try{ $serverId = $this->app->getPostParam("serverId"); if(!isset($serverId)){ - $this->app->setOutput("Error", "Server ID is missing, son!"); + $this->app->setOutput("Error", "Server ID is missing!"); return; } $opt = array('id' => $serverId); @@ -422,7 +422,7 @@ class compute try{ $serverId = $this->app->getPostParam("serverId"); if(!isset($serverId)){ - $this->app->setOutput("Error", "Server ID is missing, son!"); + $this->app->setOutput("Error", "Server ID is missing!"); return; } $opt = array('id' => $serverId); -- cgit v1.2.3 From d27f9248b2b8ef2829f14ba1331a9ba6dfbe8ed0 Mon Sep 17 00:00:00 2001 From: stupidon Date: Wed, 30 Mar 2016 11:06:03 +0200 Subject: added passage of parameters to the create functions in the script --- server/core/.Image.php.swp | Bin 0 -> 16384 bytes server/core/Automating.php | 8 ++++++-- 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 server/core/.Image.php.swp (limited to 'server/core/Automating.php') diff --git a/server/core/.Image.php.swp b/server/core/.Image.php.swp new file mode 100644 index 0000000..68e866c Binary files /dev/null and b/server/core/.Image.php.swp differ diff --git a/server/core/Automating.php b/server/core/Automating.php index adad348..df6e829 100644 --- a/server/core/Automating.php +++ b/server/core/Automating.php @@ -53,12 +53,16 @@ class automating implements Core{ public function script() { + appImage->setPostParam("A_REMPLIR_PAR_Evan","VALEUR"); appImage->createImage(); appImage->create_network(); appImage->list_network_ids(); appImage->create_subnet(); - appCompute->listFlavors(); - appCompute->listImages(); + appCompute->listFlavors(); //to show all flavors with detail. + appCompute->listImages(); //to show all images with detail and to verify that the image was created successfully by the call above. + appCompute->setPostParam("name","Test"); + appCompute->setPostParam("imageId","CREATED_ABOVE"); + appCompute->setPostParam("flavorId","1"); appCompute->createServer(); } -- cgit v1.2.3 From ba8b5feb07a7a19ca4a694313fa16d03a2fb2508 Mon Sep 17 00:00:00 2001 From: Yoggzo Date: Wed, 30 Mar 2016 11:56:26 +0200 Subject: ajout parametres dans Automating --- server/core/Automating.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'server/core/Automating.php') diff --git a/server/core/Automating.php b/server/core/Automating.php index df6e829..1eef72c 100644 --- a/server/core/Automating.php +++ b/server/core/Automating.php @@ -53,13 +53,19 @@ class automating implements Core{ public function script() { - appImage->setPostParam("A_REMPLIR_PAR_Evan","VALEUR"); + $opt = Array(); + $opt['name'] = getPostParam('name'); + + appImage->setPostParam('opt' $opt); appImage->createImage(); - appImage->create_network(); - appImage->list_network_ids(); - appImage->create_subnet(); + + appNetwork->create_network(); + appnetwork->list_network_ids(); + appNetwork->create_subnet(); + appCompute->listFlavors(); //to show all flavors with detail. appCompute->listImages(); //to show all images with detail and to verify that the image was created successfully by the call above. + appCompute->setPostParam("name","Test"); appCompute->setPostParam("imageId","CREATED_ABOVE"); appCompute->setPostParam("flavorId","1"); -- cgit v1.2.3 From c32933b362874d99207a4305d09b203dcbf20585 Mon Sep 17 00:00:00 2001 From: Yoggzo Date: Wed, 30 Mar 2016 18:30:44 +0200 Subject: debut automatisation --- server/core/Automating.php | 89 +++++++++++----------------------------------- 1 file changed, 20 insertions(+), 69 deletions(-) (limited to 'server/core/Automating.php') diff --git a/server/core/Automating.php b/server/core/Automating.php index 1eef72c..4a6a0b4 100644 --- a/server/core/Automating.php +++ b/server/core/Automating.php @@ -22,6 +22,7 @@ class automating implements Core{ protected $appImage; protected $appNetwork; protected $appIdentity; + protected $app; /** * Our library's app constructor for all server app objects @@ -38,6 +39,7 @@ class automating implements Core{ $this->appImage = $appImage; $this->appNetwork = $appNetwork; $this->appIdentity = $appIdentity; + $this->app = $app; } /** @@ -72,79 +74,28 @@ class automating implements Core{ appCompute->createServer(); } - /** - * Create a new image on a new server - * - * @param $name the name of the new image - * @param $falvor_id the id of the flavor it will be used to create the new server - * - * @return Image the new image created - */ - private function createImageOnNewServer(){ - try{ - /* POURRI - $image = new Image($this->app); - $compute = new Compute($this->app); - - $name = $this->app->getPostParam("name"); - $falvor_id = $this->app->getPostParam("falvor_id"); // Compris entre 1 et 5 (1=petit serveur, 5=gros serveur) - - $opt = Array(); - $opt['name'] = $name; - $opt['visibility'] = 'public'; - $opt['minDisk'] = 100; // A VOIR - $opt['minRam'] = 128; // A VOIR - $opt['protected'] = false; - - $this->app->setPostParam("opt", $opt); - - $image->action("createImage"); - $res = json_decode($this->app->show(), true)["Images"]; - + + private function createServer() + { + $imageName = $this->app->getPostParam('imageName'); + $serverName = $this->app->getPostParam('serverName'); + $flavor = $this->app->getPostParam('flavor'); - $this->app->setPostParam("name", $name); - $this->app->setPostParam("imageId", $res['id']); - $this->app->setPostParam("flavorId", $falvor_id); + // Création image + $opt = Array(); + $opt['name'] = $imageName; + $this->app->setPostParam('opt' $opt); + $this->appImage->createImage(); + $image = json_decode($this->app->show(), true)["Images"]; - $compute->action("createServer"); - */ - }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); - } - //$this->app->setOutput("Auto", $res); - } + // Création server + $this->app->setPostParam('name', $serverName); + $this->app->setPostParam('imageId', $image['id']); + $this->app->setPostParam('flavorId', $flavor); + $this->appNetwork->createServer(); + // Ajout adresse IP public - /** - * Create a new image on an existing server - * - * @param $name the name of the new image - * @param $server_id the id of the server - * - * @return Image the new image created - */ - private function createImageOnServer(){ - try{ - - }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 e1b15c38d7f3bd158d477537bb26256baa7565a8 Mon Sep 17 00:00:00 2001 From: Yoggzo Date: Mon, 18 Apr 2016 17:38:25 +0200 Subject: begining of automating --- server/Test/AppTestClass.php | 6 ---- server/core/Automating.php | 75 ++++++++++++++++++++++++-------------------- 2 files changed, 41 insertions(+), 40 deletions(-) (limited to 'server/core/Automating.php') diff --git a/server/Test/AppTestClass.php b/server/Test/AppTestClass.php index d2f71e7..a663514 100755 --- a/server/Test/AppTestClass.php +++ b/server/Test/AppTestClass.php @@ -118,12 +118,6 @@ class AppTest{ return $this->errorClass; } - - public function getOutput($key){ - - return $this->output[$key]; - - } } diff --git a/server/core/Automating.php b/server/core/Automating.php index 4a6a0b4..69a2773 100755 --- a/server/core/Automating.php +++ b/server/core/Automating.php @@ -22,6 +22,7 @@ class automating implements Core{ protected $appImage; protected $appNetwork; protected $appIdentity; + protected $appFloatingIp; protected $app; /** @@ -39,6 +40,7 @@ class automating implements Core{ $this->appImage = $appImage; $this->appNetwork = $appNetwork; $this->appIdentity = $appIdentity; + $this->appFloatingIp = $appFloatingIp; $this->app = $app; } @@ -52,51 +54,56 @@ class automating implements Core{ public function action($action){ $this->{$action.""}(); } - - public function script() - { - $opt = Array(); - $opt['name'] = getPostParam('name'); - - appImage->setPostParam('opt' $opt); - appImage->createImage(); - - appNetwork->create_network(); - appnetwork->list_network_ids(); - appNetwork->create_subnet(); - - appCompute->listFlavors(); //to show all flavors with detail. - appCompute->listImages(); //to show all images with detail and to verify that the image was created successfully by the call above. - - appCompute->setPostParam("name","Test"); - appCompute->setPostParam("imageId","CREATED_ABOVE"); - appCompute->setPostParam("flavorId","1"); - appCompute->createServer(); - - } + /** + * 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'); - // Création image - $opt = Array(); - $opt['name'] = $imageName; - $this->app->setPostParam('opt' $opt); - $this->appImage->createImage(); - $image = json_decode($this->app->show(), true)["Images"]; + 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->app->setPostParam('name', $serverName); - $this->app->setPostParam('imageId', $image['id']); - $this->app->setPostParam('flavorId', $flavor); - $this->appNetwork->createServer(); + // 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 + // 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(); + } } + } ?> -- cgit v1.2.3 From 3f6af0b6446725462362de94f09daf9a723b130d Mon Sep 17 00:00:00 2001 From: Yoggzo Date: Thu, 21 Apr 2016 21:51:46 +0200 Subject: modification in structure for ip and routers --- server/Test/AppTestClass.php | 2 +- server/Test/NetworkLayer3Tests.php | 88 ++++++++++ server/Test/automatingTests.php | 40 +---- server/Test/floatingIpTests.php | 88 ---------- server/core/App.php | 2 +- server/core/Automating.php | 5 +- server/core/FloatingIp.php | 326 ------------------------------------- server/core/NetworkLayer3.php | 326 +++++++++++++++++++++++++++++++++++++ server/index.php | 6 +- 9 files changed, 427 insertions(+), 456 deletions(-) create mode 100644 server/Test/NetworkLayer3Tests.php delete mode 100644 server/Test/floatingIpTests.php delete mode 100755 server/core/FloatingIp.php create mode 100755 server/core/NetworkLayer3.php (limited to 'server/core/Automating.php') diff --git a/server/Test/AppTestClass.php b/server/Test/AppTestClass.php index d8a02ca..972d9b4 100755 --- a/server/Test/AppTestClass.php +++ b/server/Test/AppTestClass.php @@ -63,7 +63,7 @@ class AppTest{ $opt = $this->tokenClass->getOptions($service); return $this->openstack->networkingV2($opt); break; - case "FloatingIp": + case "NetworkLayer3": if($this->tokenPost == NULL) $this->tokenClass->genNetworkToken(); $opt = $this->tokenClass->getOptions('Network'); return $this->openstack->networkingV2ExtLayer3($opt); diff --git a/server/Test/NetworkLayer3Tests.php b/server/Test/NetworkLayer3Tests.php new file mode 100644 index 0000000..b827a51 --- /dev/null +++ b/server/Test/NetworkLayer3Tests.php @@ -0,0 +1,88 @@ +"; +$compute->action("listServers"); +$servers = json_decode($App->show(), true)["Servers"]; +$id = null; +foreach($servers as $server){ + echo $server['name']." ".$server['id']." ".$server['ipv4']."
"; + if(strcmp($server['name'], "bob")){ + $id = $server['id']; + } +} +echo "
"; + + +// Liste des networks +echo "Liste des network :
"; +$network->action("list_network_ids"); +$servers = json_decode($App->show(), true)["ListNetworkIds"]; +$id = null; +foreach($servers as $server){ + echo $server."
"; +} +echo "
"; + + +// Liste des floatingip +echo "Liste des floatingip :
"; +$networkLayer3->action("listFloatingIp"); +$listFloatingIp = json_decode($App->show(), true)["NetworkLayer3"]; +$id = null; +foreach ($listFloatingIp as $floatIp){ + echo $floatIp['floatingIpAddress']." ".$floatIp['id']." ".$floatIp["status"]."
"; + $id = $floatIp['id']; +} +echo "
"; + + +// Liste des floatingip +echo "Get floatingip :
"; +$App->setPostParam('id', $id); +$networkLayer3->action("getFloatingIp"); +$getFloatingIp = json_decode($App->show(), true)["NetworkLayer3"]; +echo $getFloatingIp['id']."
"; +echo "
"; + + +/* +// Création d'une ip flotante +$opt = array(); +$opt['floatingNetworkId'] = "251b4641-20ff-4a72-8549-1758788b51ce"; + +$App->setPostParam('opt', $opt); +$networkLayer3->action("createFloatingIp"); +$float = json_decode($App->show(), true)["NetworkLayer3"]; +if(!isset($float)){ + echo "Erreur pendant la création
"; +} +echo "
"; +*/ + +/* +// Suppression d'une ip flotante +$App->setPostParam('id', $id); +$networkLayer3->action("deleteFloatingIp"); +*/ + +// Liste des floatingip +echo "Liste des floatingip :
"; +$networkLayer3->action("listFloatingIp"); +$listFloatingIp = json_decode($App->show(), true)["NetworkLayer3"]; +foreach ($listFloatingIp as $floatIp){ + echo $floatIp['floatingIpAddress']." ".$floatIp['id']." ".$floatIp["status"]."
"; +} + + +?> \ No newline at end of file diff --git a/server/Test/automatingTests.php b/server/Test/automatingTests.php index 3f32d02..e8e8475 100755 --- a/server/Test/automatingTests.php +++ b/server/Test/automatingTests.php @@ -4,12 +4,11 @@ include_once("../core/Image.php"); include_once("../core/Compute.php"); include_once("../core/Network.php"); //include_once("../core/Automating.php"); -include_once("../core/FloatingIp.php"); +include_once("../core/NetworkLayer3.php"); $image = new Image($App); $compute = new Compute($App); -$network = new Network($App); -$floatingIp = new FloatingIp($App); +$networkLayer3 = new NetworkLayer3($App); //$automating = new Automating($App); // Liste des serveurs @@ -25,15 +24,7 @@ foreach($servers as $server){ } echo "
"; -/* -// Liste des ports -echo "Liste des ports :
"; -$network->action("listPorts"); -$ports = json_decode($App->show(), true)["Network"]; -foreach ($ports as $p) { - echo $p["fixedIps"]."
"; -} -*/ + //Liste des networks echo "Liste des network :
"; $network->action("list_network_ids"); @@ -44,32 +35,11 @@ foreach($servers as $server){ } echo "
"; -/* -// Création d'une ip flotante -$opt = array(); -//$opt['floatingNetworkId'] = $id; !!!!! TOTALEMENT FAUX ici tu passe en parametre l id du serveur et non du network -//$opt['floatingip'] = $ip; !!!! il n y a pas d objet floatingip a passer en param, celui ci est compose, regarde bien les exemples de l api OpenStack -//$opt['tenantId'] = "fbf5f920a7954b61b352bc09ce5ae803 "; -//$opt['fixedIpAddress'] = "10.0.0.52"; -//$opt['floatingIpAddress'] = "148.60.11.116"; -//$opt['portId'] = "10.0.0.52"; -$opt['floatingNetworkId'] = "251b4641-20ff-4a72-8549-1758788b51ce"; - -$App->setPostParam('opt', $opt); -$floatingIp->action("createFloatingIp"); -$float = json_decode($App->show(), true)["FloatingIp"]; -if(!isset($float)){ - echo "Erreur pendant la création
"; -} -echo "
"; -*/ - - // liste des floatingip echo "Liste des floatingip :
"; -$floatingIp->action("listFloatingIp"); -$listFloatingIp = json_decode($App->show(), true)["FloatingIp"]; +$networkLayer3->action("listFloatingIp"); +$listFloatingIp = json_decode($App->show(), true)["NetworkLayer3"]; foreach ($listFloatingIp as $floatIp){ echo $floatIp['floatingIpAddress']." ".$floatIp['id']." ".$floatIp["status"]."
"; } diff --git a/server/Test/floatingIpTests.php b/server/Test/floatingIpTests.php deleted file mode 100644 index 191de46..0000000 --- a/server/Test/floatingIpTests.php +++ /dev/null @@ -1,88 +0,0 @@ -"; -$compute->action("listServers"); -$servers = json_decode($App->show(), true)["Servers"]; -$id = null; -foreach($servers as $server){ - echo $server['name']." ".$server['id']." ".$server['ipv4']."
"; - if(strcmp($server['name'], "bob")){ - $id = $server['id']; - } -} -echo "
"; - - -// Liste des networks -echo "Liste des network :
"; -$network->action("list_network_ids"); -$servers = json_decode($App->show(), true)["ListNetworkIds"]; -$id = null; -foreach($servers as $server){ - echo $server."
"; -} -echo "
"; - - -// Liste des floatingip -echo "Liste des floatingip :
"; -$floatingIp->action("listFloatingIp"); -$listFloatingIp = json_decode($App->show(), true)["FloatingIp"]; -$id = null; -foreach ($listFloatingIp as $floatIp){ - echo $floatIp['floatingIpAddress']." ".$floatIp['id']." ".$floatIp["status"]."
"; - $id = $floatIp['id']; -} -echo "
"; - - -// Liste des floatingip -echo "Get floatingip :
"; -$App->setPostParam('id', $id); -$floatingIp->action("getFloatingIp"); -$getFloatingIp = json_decode($App->show(), true)["FloatingIp"]; -echo $getFloatingIp['id']."
"; -echo "
"; - - -/* -// Création d'une ip flotante -$opt = array(); -$opt['floatingNetworkId'] = "251b4641-20ff-4a72-8549-1758788b51ce"; - -$App->setPostParam('opt', $opt); -$floatingIp->action("createFloatingIp"); -$float = json_decode($App->show(), true)["FloatingIp"]; -if(!isset($float)){ - echo "Erreur pendant la création
"; -} -echo "
"; -*/ - -/* -// Suppression d'une ip flotante -$App->setPostParam('id', $id); -$floatingIp->action("deleteFloatingIp"); -*/ - -// Liste des floatingip -echo "Liste des floatingip :
"; -$floatingIp->action("listFloatingIp"); -$listFloatingIp = json_decode($App->show(), true)["FloatingIp"]; -foreach ($listFloatingIp as $floatIp){ - echo $floatIp['floatingIpAddress']." ".$floatIp['id']." ".$floatIp["status"]."
"; -} - - -?> \ No newline at end of file diff --git a/server/core/App.php b/server/core/App.php index a4be6ec..32ad016 100755 --- a/server/core/App.php +++ b/server/core/App.php @@ -64,7 +64,7 @@ class App{ $opt = $this->tokenClass->getOptions($service); return $this->openstack->computeV2($opt); break; - case "FloatingIp": + case "NetworkLayer3": if($this->tokenPost == NULL) $this->tokenClass->genNetworkToken(); $opt = $this->tokenClass->getOptions('Network'); return $this->openstack->networkingV2ExtLayer3($opt); diff --git a/server/core/Automating.php b/server/core/Automating.php index 69a2773..4e212e7 100755 --- a/server/core/Automating.php +++ b/server/core/Automating.php @@ -14,6 +14,7 @@ include("CoreInterface.php"); include("Image.php"); include("Network.php"); include("Compute.php"); +include("NetworkLayer3"); class automating implements Core{ @@ -22,7 +23,7 @@ class automating implements Core{ protected $appImage; protected $appNetwork; protected $appIdentity; - protected $appFloatingIp; + protected $appNetworkLayer3; protected $app; /** @@ -40,7 +41,7 @@ class automating implements Core{ $this->appImage = $appImage; $this->appNetwork = $appNetwork; $this->appIdentity = $appIdentity; - $this->appFloatingIp = $appFloatingIp; + $this->appNetworkLayer3 = $appNetworkLayer3; $this->app = $app; } diff --git a/server/core/FloatingIp.php b/server/core/FloatingIp.php deleted file mode 100755 index cdbb64b..0000000 --- a/server/core/FloatingIp.php +++ /dev/null @@ -1,326 +0,0 @@ -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.""}(); - } - - - /** - * List floatingip - * - * @return list of the floatingip - */ - private function listFloatingIp(){ - try{ - $result = array(); - $l = $this->libClass->listFloatingIps(); - error_log(var_export($l, true), 0); - foreach ($l as $tmp) { - $result[] = $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 - * - * @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->createFloatingIp($opt); - - if(!isset($floatingip)){ - $this->app->setOutput("Error", "Unknowing error during floating ip creation"); - }else{ - $this->app->setOutput("FloatingIp", $floatingip); - } - }catch(BadResponseError $e){ - echo $e."
"; - $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ - echo $e."
"; - $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ - echo $e."
"; - $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ - echo $e."
"; - $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - echo $e->getMessage()."
"; - $this->app->getErrorInstance()->OtherException($e); - } - } - - - /** - * Show floatingip details - * - * @param String id the id of the floatingip - * - * @return floatingip details - */ - private function getFloatingIp(){ - $id = $this->app->getPostParam("id"); - if(!isset($id)){ - $this->app->setOutput("Error", "Incorrect parameter opt"); - } - - try{ - // 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($result)){ // If id doesn't exists - $this->app->setOutput("Error", "Unknow id"); - }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){ - $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{ - - // 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($result)){ // If id doesn't exists - $this->app->setOutput("Error", "Unknowing floatingip id"); - }else{ - $result->update(); - } - - - }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{ - // 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($result)){ // If id doesn't exists - $this->app->setOutput("Error", "Unknowing floatingip id"); - }else{ - $result->delete(); - } - }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{ - // 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($result)){ // If id doesn't exists - $this->app->setOutput("Error", "Unknowing floatingip id"); - }else{ - $result->retrieve(); - } - }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); - } - } -} diff --git a/server/core/NetworkLayer3.php b/server/core/NetworkLayer3.php new file mode 100755 index 0000000..28d27b4 --- /dev/null +++ b/server/core/NetworkLayer3.php @@ -0,0 +1,326 @@ +app->setOutput("Error", "Incorrect parameter app"); + } + $this->app = $app; + $this->libClass = $app->getLibClass("NetworkLayer3"); + } + + + /** + * Execute an action + * + * @param String $action name of another function of this class + * + * @return void + */ + public function action($action){ + $this->{$action.""}(); + } + + + /** + * List floatingip + * + * @return list of the floatingip + */ + private function listFloatingIp(){ + try{ + $result = array(); + $l = $this->libClass->listFloatingIps(); + error_log(var_export($l, true), 0); + foreach ($l as $tmp) { + $result[] = $tmp; + } + + $this->app->setOutput("NetworkLayer3", $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 + * + * @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->createFloatingIp($opt); + + if(!isset($floatingip)){ + $this->app->setOutput("Error", "Unknowing error during floating ip creation"); + }else{ + $this->app->setOutput("NetworkLayer3", $floatingip); + } + }catch(BadResponseError $e){ + echo $e."
"; + $this->app->getErrorInstance()->BadResponseHandler($e); + }catch(UserInputError $e){ + echo $e."
"; + $this->app->getErrorInstance()->UserInputHandler($e); + }catch(BaseError $e){ + echo $e."
"; + $this->app->getErrorInstance()->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + echo $e."
"; + $this->app->getErrorInstance()->NotImplementedHandler($e); + }catch(Exception $e){ + echo $e->getMessage()."
"; + $this->app->getErrorInstance()->OtherException($e); + } + } + + + /** + * Show floatingip details + * + * @param String id the id of the floatingip + * + * @return floatingip details + */ + private function getFloatingIp(){ + $id = $this->app->getPostParam("id"); + if(!isset($id)){ + $this->app->setOutput("Error", "Incorrect parameter opt"); + } + + try{ + // 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($result)){ // If id doesn't exists + $this->app->setOutput("Error", "Unknow id"); + }else{ // If id exists + $res = $this->libClass->getFloatingIp($id); + $this->app->setOutput("NetworkLayer3", $res); + } + + }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{ + + // 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($result)){ // If id doesn't exists + $this->app->setOutput("Error", "Unknowing floatingip id"); + }else{ + $result->update(); + } + + + }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{ + // 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($result)){ // If id doesn't exists + $this->app->setOutput("Error", "Unknowing floatingip id"); + }else{ + $result->delete(); + } + }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{ + // 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($result)){ // If id doesn't exists + $this->app->setOutput("Error", "Unknowing floatingip id"); + }else{ + $result->retrieve(); + } + }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); + } + } +} diff --git a/server/index.php b/server/index.php index ac66c95..53a24c4 100755 --- a/server/index.php +++ b/server/index.php @@ -53,9 +53,9 @@ $App->show(); break; - case "floatingip": - include_once("core/FloatingIp.php"); - $computeObject = new floatingIp($App); + case "networkLayer3": + include_once("core/NetworkLayer3.php"); + $computeObject = new networkLayer3($App); $computeObject->action($action); $App->show(); break; -- cgit v1.2.3 From 0fc14b5761e558680aecc57e4d1ae8075121f01e Mon Sep 17 00:00:00 2001 From: Yoggzo Date: Thu, 21 Apr 2016 23:57:37 +0200 Subject: structure of Automating --- server/Test/automatingTests.php | 60 +++++++++------------------------ server/core/Automating.php | 73 ++++++++++++++++++++++++----------------- 2 files changed, 59 insertions(+), 74 deletions(-) (limited to 'server/core/Automating.php') diff --git a/server/Test/automatingTests.php b/server/Test/automatingTests.php index e8e8475..8088102 100755 --- a/server/Test/automatingTests.php +++ b/server/Test/automatingTests.php @@ -1,48 +1,20 @@ "; -$compute->action("listServers"); -$servers = json_decode($App->show(), true)["Servers"]; -$id = null; -foreach($servers as $server){ - echo $server['name']." ".$server['id']." ".$server['ipv4']."
"; - if(strcmp($server['name'], "bob")){ - $id = $server['id']; - } -} -echo "
"; - - -//Liste des networks -echo "Liste des network :
"; -$network->action("list_network_ids"); -$servers = json_decode($App->show(), true)["ListNetworkIds"]; -$id = null; -foreach($servers as $server){ - echo $server."
"; -} -echo "
"; - - -// liste des floatingip -echo "Liste des floatingip :
"; -$networkLayer3->action("listFloatingIp"); -$listFloatingIp = json_decode($App->show(), true)["NetworkLayer3"]; -foreach ($listFloatingIp as $floatIp){ - echo $floatIp['floatingIpAddress']." ".$floatIp['id']." ".$floatIp["status"]."
"; -} - +include_once("../core/Automating.php"); + +$automating = new Automating($App); + +//$id = // id du réseau + +/* +// Création serveur avec ip publique +echo "Test création serveur avec ip publique :
"; +$App->setPostParam('networkId', $id); +$App->setPostParam('imageName', "ImageTest"); +$App->setPostParam('serverName', "ServerTest"); +$App->setPostParam('flavor', 1); +$compute->action("createPublicServer"); +$servers = json_decode($App->show(), true)["Automating"]; +*/ ?> \ No newline at end of file diff --git a/server/core/Automating.php b/server/core/Automating.php index 4e212e7..fb42702 100755 --- a/server/core/Automating.php +++ b/server/core/Automating.php @@ -10,20 +10,18 @@ * @todo Complete the functions with errors detection and finish the descriptions */ -include("CoreInterface.php"); include("Image.php"); include("Network.php"); include("Compute.php"); -include("NetworkLayer3"); +include("NetworkLayer3.php"); -class automating implements Core{ +class automating{ /** @var App $app protected, contains the main app object */ - protected $appCompute; - protected $appImage; - protected $appNetwork; - protected $appIdentity; - protected $appNetworkLayer3; + protected $compute; + protected $image; + protected $network; + protected $networkLayer3; protected $app; /** @@ -34,15 +32,11 @@ class automating implements Core{ * @return */ public function __construct($app){ - if(!isset($app)){ - $this->app->setOutput("Error", "Parameter app missing."); - } - $this->appCompute = $appCompute; - $this->appImage = $appImage; - $this->appNetwork = $appNetwork; - $this->appIdentity = $appIdentity; - $this->appNetworkLayer3 = $appNetworkLayer3; $this->app = $app; + $compute = new Compute($app); + $image = new Image($app); + $network = new Network($app); + $networkLayer3 = new NetworkLayer3($app); } /** @@ -59,14 +53,16 @@ class automating implements Core{ /** * create a new server and associate a public ip * + * @param String $networkId the id of the network where the server will be created * @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() + private function createPublicServer() { + $networkId = $this->app->getPostParam('networkId'); $imageName = $this->app->getPostParam('imageName'); $serverName = $this->app->getPostParam('serverName'); $flavor = $this->app->getPostParam('flavor'); @@ -84,27 +80,44 @@ class automating implements Core{ // Création image $opt = array(); $opt['name'] = $imageName; - $this->appImage->setPostParam('opt' $opt); - $this->appImage->createImage(); + $image->setPostParam('opt', $opt); + $image->action("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(); + $compute->setPostParam('name', $serverName); + $compute->setPostParam('imageId', $image['id']); + $compute->setPostParam('flavorId', $flavor); + $compute->action("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(); + // liste des adresses ip publiques diponibles + $networkLayer3->action("listFloatingIp"); + $listFloatingIp = json_decode($App->show(), true)["NetworkLayer3"]; + $ip = null; + foreach ($listFloatingIp as $f) { + if(strcmp($f['status'], "DOWN")){ + $ip = $f; + } + } + + // Si pas d'ip publique disponible on en créé une + if(!isset($ip)){ + // Ajout adresse IP public + $optIp = array(); + $opt['floatingNetworkId'] = $networkId; + $floatingIp->setPostParam('opt', $optIp); + $networkLayer3->action("createFloatingIp"); + $ip = json_decode($App->show(), true)["NetworkLayer3"]; + } + + // Association de l'ip publique au serveur + /* + * API non diponible pour le moment + */ } } - } ?> -- cgit v1.2.3 From 5263cf00a253891396c442fe5be29762fb8be50d Mon Sep 17 00:00:00 2001 From: EoleDev Date: Tue, 26 Apr 2016 20:42:31 +0200 Subject: Refactoring of comments beginning --- server/config.inc.php | 22 +- server/core/App.php | 164 +++- server/core/Automating.php | 9 +- server/core/Compute.php | 550 +++++------ server/core/CoreInterface.php | 10 +- server/core/ErrorManagement.php | 66 +- server/core/Identity.php | 1413 ++++++++++----------------- server/core/Image.php | 222 ++--- server/core/LibOverride/genTokenOptions.php | 104 +- server/core/Network.php | 318 +++--- server/core/NetworkLayer3.php | 156 +-- server/index.php | 136 +-- server/init.php | 89 +- 13 files changed, 1525 insertions(+), 1734 deletions(-) (limited to 'server/core/Automating.php') diff --git a/server/config.inc.php b/server/config.inc.php index aa10504..4a4e494 100755 --- a/server/config.inc.php +++ b/server/config.inc.php @@ -1,11 +1,21 @@ diff --git a/server/core/App.php b/server/core/App.php index 114d945..3a027d7 100755 --- a/server/core/App.php +++ b/server/core/App.php @@ -1,21 +1,53 @@ tokenPost = NULL; @@ -27,6 +59,13 @@ class App{ } + /** + * Set the class var $tokenPost and load the token + * into the genTokenOptions Class + * + * @param String $token token to be set + * + */ public function setToken($token){ $this->tokenPost = $token; @@ -34,42 +73,59 @@ class App{ } + /** + * Check the expiration of the token + * + * @return Boolean if the token is not expired + */ public function checkToken(){ return $this->tokenClass->checkToken(); } + /** + * Get the service Class given the name in parameter + * + * @param String $service Name of the service + * + * @return Core object + */ public function getLibClass($service){ switch($service){ - case "Identity": - if($this->tokenPost == NULL) $this->tokenClass->genIdentityToken(); - $opt = $this->tokenClass->getOptions($service); - return $this->openstack->identityV3($opt); - break; - case "Image": - if($this->tokenPost == NULL) $this->tokenClass->genImageToken(); - $opt = $this->tokenClass->getOptions($service); - return $this->openstack->imagesV2($opt); - break; - case "Network": - if($this->tokenPost == NULL) $this->tokenClass->genNetworkToken(); - $opt = $this->tokenClass->getOptions($service); - return $this->openstack->networkingV2($opt); - break; - case "Compute": - if($this->tokenPost == NULL) $this->tokenClass->genComputeToken(); - $opt = $this->tokenClass->getOptions($service); - return $this->openstack->computeV2($opt); - break; - case "NetworkLayer3": - if($this->tokenPost == NULL) $this->tokenClass->genNetworkToken(); - $opt = $this->tokenClass->getOptions('Network'); - return $this->openstack->networkingV2ExtLayer3($opt); - break; + case "Identity": + if($this->tokenPost == NULL) $this->tokenClass->genIdentityToken(); + $opt = $this->tokenClass->getOptions($service); + return $this->openstack->identityV3($opt); + break; + case "Image": + if($this->tokenPost == NULL) $this->tokenClass->genImageToken(); + $opt = $this->tokenClass->getOptions($service); + return $this->openstack->imagesV2($opt); + break; + case "Network": + if($this->tokenPost == NULL) $this->tokenClass->genNetworkToken(); + $opt = $this->tokenClass->getOptions($service); + return $this->openstack->networkingV2($opt); + break; + case "Compute": + if($this->tokenPost == NULL) $this->tokenClass->genComputeToken(); + $opt = $this->tokenClass->getOptions($service); + return $this->openstack->computeV2($opt); + break; + case "NetworkLayer3": + if($this->tokenPost == NULL) $this->tokenClass->genNetworkToken(); + $opt = $this->tokenClass->getOptions('Network'); + return $this->openstack->networkingV2ExtLayer3($opt); + break; } } + /** + * Generate the token for the different services in OpenStack + * + * @return NULL + */ public function authenticate(){ try{ @@ -81,16 +137,21 @@ class App{ $this->setOutput("token", $this->tokenClass->getBackup()); }catch(BadResponseError $e){ $this->errorClass->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->errorClass->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->errorClass->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->errorClass->NotImplementedHandler($e); - } + } } + /** + * Revoke the openstack services' token + * + * @return NULL + */ public function deauthenticate(){ try{ @@ -103,16 +164,23 @@ class App{ $this->setOutput("deauthenticate", "Ok"); }catch(BadResponseError $e){ $this->errorClass->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->errorClass->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->errorClass->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->errorClass->NotImplementedHandler($e); - } + } } + /** + * Retrieve a post parameter given its name + * + * @param String $name Expected post parameter's name + * + * @return Object Post value + */ public function getPostParam($name){ if(isset($this->postParams[$name])){ @@ -123,28 +191,52 @@ class App{ } - + /** + * Set a post parameter for automating task + * + * @param String $param Name for the Post entry + * @param Object $value Value for the Post entry + * + * @return NULL + */ public function setPostParam($param, $value){ $this->postParams[$param] = $value; - + } + /** + * Set a new output message + * + * @param String $key Array key for the message + * @param Array $out Message's value + * + * @return NULL + */ public function setOutput($key, $out){ $this->output[$key] = $out; } + /** + * Retrieve the errorManagement instance Object + * + * @return errorManagement object + */ public function getErrorInstance(){ return $this->errorClass; } + /** + * Output the messages to be send to the client + * + * @return NULl + */ public function show(){ echo json_encode($this->output); - //error_log(var_dump(json_encode($this->output), true), 0); } } diff --git a/server/core/Automating.php b/server/core/Automating.php index fb42702..2d8db00 100755 --- a/server/core/Automating.php +++ b/server/core/Automating.php @@ -5,9 +5,8 @@ * @version 1.0 Initialisation of this file * @since 1.0 Core application's file * -* @author Evan Pisani 'yogg at epsina . com' et bhupi +* @author Evan Pisani 'yogg at epsina . com', bhupi * -* @todo Complete the functions with errors detection and finish the descriptions */ include("Image.php"); @@ -44,10 +43,10 @@ class automating{ * * @param String $action name of another function of this class * - * @return void + * @return NULL */ public function action($action){ - $this->{$action.""}(); + $this->{$action.""}(); } /** @@ -58,7 +57,7 @@ class automating{ * @param String $serverName name ofthe new server * @param String $flavor kind of server * - * @return void + * @return NULL */ private function createPublicServer() { diff --git a/server/core/Compute.php b/server/core/Compute.php index 4a7fe6c..e466b52 100755 --- a/server/core/Compute.php +++ b/server/core/Compute.php @@ -4,170 +4,170 @@ use OpenCloud\Common\Error; class compute { - /** @var App $app protected, contains the main app object */ - protected $app; + /** @var App $app protected, contains the main app object */ + protected $app; - /** @var OpenStack\Identity $libClass protected, contains the library Compute object */ - protected $libClass; + /** @var OpenStack\Identity $libClass protected, contains the library Compute object */ + protected $libClass; - public function __construct($app) - { - $this->app = $app; - $this->libClass = $app->getLibClass("Compute"); - } + public function __construct($app) + { + $this->app = $app; + $this->libClass = $app->getLibClass("Compute"); + } /** * Execute an action * * @param String $action name of another function of this class * - * @return void + * @return NULL */ public function action($action){ - $this->{$action.""}(); + $this->{$action.""}(); } - /** - * List servers. - * @return array - */ - public function listServers() - { + /** + * List servers. + * @return array + */ + public function listServers() + { try{ $serverList = $this->libClass->listServers(true); $servers = Array(); foreach($serverList as $server){ - $servers[$server->id] = Array(); - $server->flavor->retrieve(); - $server->image->retrieve(); - $server->retrieve(); - $servers[$server->id]["id"] = $server->id; - $servers[$server->id]["name"] = $server->name; - $servers[$server->id]["image"] = $server->image; - $servers[$server->id]["ram"] = $server->flavor->ram; - $servers[$server->id]["disk"] = $server->flavor->disk; - $servers[$server->id]["flavor"] = $server->flavor; - $servers[$server->id]["status"] = $server->status; - $servers[$server->id]["created"] = $server->created; - $servers[$server->id]["updated"] = $server->updated; - $servers[$server->id]["ipv4"] = $server->ipv4; - $servers[$server->id]["ipv6"] = $server->ipv6; - $servers[$server->id]["progress"] = $server->progress; - $servers[$server->id]["hostId"] = $server->hostId; - $servers[$server->id]["tenantId"] = $server->tenantId; - $servers[$server->id]["userId"] = $server->userId; - $servers[$server->id]["taskState"] = $server->taskState; - $servers[$server->id]["addresses"] = $server->addresses; - $servers[$server->id]["links"] = $server->links; - $servers[$server->id]["metadata"] = $server->metadata; + $servers[$server->id] = Array(); + $server->flavor->retrieve(); + $server->image->retrieve(); + $server->retrieve(); + $servers[$server->id]["id"] = $server->id; + $servers[$server->id]["name"] = $server->name; + $servers[$server->id]["image"] = $server->image; + $servers[$server->id]["ram"] = $server->flavor->ram; + $servers[$server->id]["disk"] = $server->flavor->disk; + $servers[$server->id]["flavor"] = $server->flavor; + $servers[$server->id]["status"] = $server->status; + $servers[$server->id]["created"] = $server->created; + $servers[$server->id]["updated"] = $server->updated; + $servers[$server->id]["ipv4"] = $server->ipv4; + $servers[$server->id]["ipv6"] = $server->ipv6; + $servers[$server->id]["progress"] = $server->progress; + $servers[$server->id]["hostId"] = $server->hostId; + $servers[$server->id]["tenantId"] = $server->tenantId; + $servers[$server->id]["userId"] = $server->userId; + $servers[$server->id]["taskState"] = $server->taskState; + $servers[$server->id]["addresses"] = $server->addresses; + $servers[$server->id]["links"] = $server->links; + $servers[$server->id]["metadata"] = $server->metadata; } $this->app->setOutput("Servers", $servers); } 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); - } - return; - } - /** - * List flavors. - * @return array - */ - public function listFlavors() - { + } + return; + } + /** + * List flavors. + * @return array + */ + public function listFlavors() + { try{ $flavorList = $this->libClass->listFlavors(); $flavors = Array(); foreach($flavorList as $flavor){ - $flavors[$flavor->id] = Array(); - $flavor->retrieve(); - $flavors[$flavor->id]["id"] = $flavor->id; - $flavors[$flavor->id]["name"] = $flavor->name; - $flavors[$flavor->id]["ram"] = $flavor->ram; - $flavors[$flavor->id]["disk"] = $flavor->disk; - $flavors[$flavor->id]["vcpus"] = $flavor->vcpus; - $flavors[$flavor->id]["links"] = $flavor->links; - } - $this->app->setOutput("Flavors", $flavors); + $flavors[$flavor->id] = Array(); + $flavor->retrieve(); + $flavors[$flavor->id]["id"] = $flavor->id; + $flavors[$flavor->id]["name"] = $flavor->name; + $flavors[$flavor->id]["ram"] = $flavor->ram; + $flavors[$flavor->id]["disk"] = $flavor->disk; + $flavors[$flavor->id]["vcpus"] = $flavor->vcpus; + $flavors[$flavor->id]["links"] = $flavor->links; + } + $this->app->setOutput("Flavors", $flavors); } 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); - } - return; - } - /** - * List images. - * @return array - */ - public function listImages() - { - try{ + } + return; + } + /** + * List images. + * @return array + */ + public function listImages() + { + try{ $imageList = $this->libClass->listImages(); $images = Array(); foreach($imageList as $image){ - $images[$image->id] = Array(); - $image->retrieve(); - $images[$image->id]["id"] = $image->id; - $images[$image->id]["name"] = $image->name; - $images[$image->id]["status"] = $image->status; - $images[$image->id]["created"] = $image->created; - $images[$image->id]["updated"] = $image->updated; - $images[$image->id]["minDisk"] = $image->minDisk; - $images[$image->id]["minRam"] = $image->minRam; - $images[$image->id]["progress"] = $image->progress; - $images[$image->id]["links"] = $image->links; - $images[$image->id]["metadata"] = $image->metadata; - } - $this->app->setOutput("Images", $images); + $images[$image->id] = Array(); + $image->retrieve(); + $images[$image->id]["id"] = $image->id; + $images[$image->id]["name"] = $image->name; + $images[$image->id]["status"] = $image->status; + $images[$image->id]["created"] = $image->created; + $images[$image->id]["updated"] = $image->updated; + $images[$image->id]["minDisk"] = $image->minDisk; + $images[$image->id]["minRam"] = $image->minRam; + $images[$image->id]["progress"] = $image->progress; + $images[$image->id]["links"] = $image->links; + $images[$image->id]["metadata"] = $image->metadata; + } + $this->app->setOutput("Images", $images); } 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); - } - return; - } - /** - * Get server details. - * @return array - */ - public function getServer() - { - try{ + } + return; + } + /** + * Get server details. + * @return array + */ + public function getServer() + { + try{ $serverId = $this->app->getPostParam("serverId"); if(!isset($serverId)){ $this->app->setOutput("Error", "Server ID is missing!"); @@ -180,27 +180,27 @@ class compute } 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); - } - return; - } - /** - * Get flavor details. - * @return array - */ - public function getFlavor() - { + } + return; + } + /** + * Get flavor details. + * @return array + */ + public function getFlavor() + { try{ $flavorId = $this->app->getPostParam("flavorId"); if(!isset($serverId)){ @@ -214,27 +214,27 @@ class compute } 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); - } - return; - } - /** - * Get image details. - * @return array - */ - public function getImage() - { + } + return; + } + /** + * Get image details. + * @return array + */ + public function getImage() + { try{ $imageId = $this->app->getPostParam("imageId"); if(!isset($serverId)){ @@ -248,27 +248,27 @@ class compute } 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); - } - return; - } - /** - * Create server. - * @return array - */ - public function createServer() - { + } + return; + } + /** + * Create server. + * @return array + */ + public function createServer() + { try{ $name = $this->app->getPostParam("name"); $imageId = $this->app->getPostParam("imageId"); @@ -282,28 +282,28 @@ class compute } 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); - } + } return; - } - + } + /** * update a server - * @return void + * @return NULL */ - public function updateServer() - { + public function updateServer() + { try{ $serverId = $this->app->getPostParam("serverId"); $newName = $this->app->getPostParam("newName"); @@ -329,27 +329,27 @@ class compute } 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); - } - return; - } + } + return; + } /** * Delete a server - * @return void + * @return NULL */ - public function deleteServer() - { + public function deleteServer() + { try{ $serverId = $this->app->getPostParam("serverId"); if(!isset($serverId)){ @@ -363,27 +363,27 @@ class compute } 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); - } - return; - } + } + return; + } /** * Change the password of a server - * @return void + * @return NULL */ - public function changePassword() - { + public function changePassword() + { try{ $serverId = $this->app->getPostParam("serverId"); $password = $this->app->getPostParam("newPassword"); @@ -398,27 +398,27 @@ class compute } 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); - } + } return; - } - /** + } + /** * Reboot a server - * @return void + * @return NULL */ - public function reboot() - { + public function reboot() + { try{ $serverId = $this->app->getPostParam("serverId"); if(!isset($serverId)){ @@ -432,74 +432,74 @@ class compute } 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); - } - return; - } - /** + } + return; + } + /** * Rebuild a server - * @return void + * @return NULL */ - public function rebuild() - { - $serverId = $this->app->getPostParam("serverId"); - $imageId = $this->app->getPostParam("imageId"); - $newName = $this->app->getPostParam("newName"); - $adminPass = $this->app->getPostParam("adminPass"); + public function rebuild() + { + $serverId = $this->app->getPostParam("serverId"); + $imageId = $this->app->getPostParam("imageId"); + $newName = $this->app->getPostParam("newName"); + $adminPass = $this->app->getPostParam("adminPass"); if(!isset($serverId)|| !isset($imageId) || isset($newName) || isset($adminPass)) { $this->app->setOutput("Error", "You'll have to provide server ID and the new image, name and admin password!"); return; - try{ - $serverId = $this->app->getPostParam("serverId"); - $imageId = $this->app->getPostParam("imageId"); - $newName = $this->app->getPostParam("newName"); - $adminPass = $this->app->getPostParam("adminPass"); - if(!isset($serverId)|| !isset($imageId) || isset($newName) || isset($adminPass)){ - $this->app->setOutput("Error", "You'll have to provide server ID and the new image, name and admin password!"); - return; + try{ + $serverId = $this->app->getPostParam("serverId"); + $imageId = $this->app->getPostParam("imageId"); + $newName = $this->app->getPostParam("newName"); + $adminPass = $this->app->getPostParam("adminPass"); + if(!isset($serverId)|| !isset($imageId) || isset($newName) || isset($adminPass)){ + $this->app->setOutput("Error", "You'll have to provide server ID and the new image, name and admin password!"); + return; + } + $opt = array('id' => $serverId); + $server = $this->libClass->getServer($opt); + $attr = array('imageId' => $imageId, 'name' => $newName, 'adminPass' => $adminPass); + $server->rebuild($attr); + $this->app->setOutput("Success", $serverId." has been rebuilt successfully with the new image."); } - $opt = array('id' => $serverId); - $server = $this->libClass->getServer($opt); - $attr = array('imageId' => $imageId, 'name' => $newName, 'adminPass' => $adminPass); - $server->rebuild($attr); - $this->app->setOutput("Success", $serverId." has been rebuilt successfully with the new image."); + 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); + } + return; } - 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); - } - return; - } - } - /** + } + /** * Resize a server * A call to this method has to be followed by either confirmResize or revertResize - * @return void + * @return NULL */ - public function resize() - { + public function resize() + { try{ $serverId = $this->app->getPostParam("serverId"); $newFlavorId = $this->app->getPostParam("newFlavorId"); @@ -513,27 +513,27 @@ class compute } 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); - } - return; - } - /** + } + return; + } + /** * Confirm resize operation on a server - * @return void + * @return NULL */ - public function confirmResize() - { + public function confirmResize() + { try{ $serverId = $this->app->getPostParam("serverId"); if(!isset($serverId)){ @@ -547,27 +547,27 @@ class compute } 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); - } - return; - } - /** + } + return; + } + /** * Revert resize operation on a server - * @return void + * @return NULL */ - public function revertResize() - { + public function revertResize() + { try{ $serverId = $this->app->getPostParam("serverId"); if(!isset($serverId)){ @@ -581,28 +581,28 @@ class compute } 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); - } - return; - } + } + return; + } /** * List private and public addresses of a server - * @return void + * @return NULL */ - - public function listAddresses(array $options = []) - { + + public function listAddresses(array $options = []) + { try{ $serverId = $this->app->getPostParam("serverId"); if(!isset($serverId)){ @@ -616,20 +616,20 @@ class compute } 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); - } - return; - } + } + return; + } } - + diff --git a/server/core/CoreInterface.php b/server/core/CoreInterface.php index ed0d959..6c2313b 100755 --- a/server/core/CoreInterface.php +++ b/server/core/CoreInterface.php @@ -1,5 +1,13 @@ app->setOutput("Error", "BaseError"); @@ -46,49 +46,49 @@ Class errorManagement{ /** * Put an error message corresponding to a bad response in function of the status code in the output * - * @param $error the error triggered + * @param Exception $error the exception triggered * - * @return String Error message + * @return NULL */ public function BadResponseHandler($error){ $statusCode = $error->getResponse()->getStatusCode(); switch ($statusCode) { - case 400: - $this->app->setOutput("Error", "Invalid input."); - break; + case 400: + $this->app->setOutput("Error", "Invalid input."); + break; - case 401: - $this->app->setOutput("Error", "Authentification failed."); - break; + case 401: + $this->app->setOutput("Error", "Authentification failed."); + break; - case 403: - $this->app->setOutput("Error", "Operation forbidden."); - break; + case 403: + $this->app->setOutput("Error", "Operation forbidden."); + break; - case 404: - $this->app->setOutput("Error", "Ressource not found."); - break; + case 404: + $this->app->setOutput("Error", "Ressource not found."); + break; - case 500: - $this->app->setOutput("Error", "Internal server error, please contact an administrator."); - break; + case 500: + $this->app->setOutput("Error", "Internal server error, please contact an administrator."); + break; - case 503: - $this->app->setOutput("Error", "Service unvailable for the moment."); - break; + case 503: + $this->app->setOutput("Error", "Service unvailable for the moment."); + break; - default: - $this->app->setOutput("Error", "Unknow error, please contact an administrator."); - break; + default: + $this->app->setOutput("Error", "Unknow error, please contact an administrator."); + break; } } /** * Put an error message corresponding to a not implemented yet error in the output * - * @param $error the error triggered + * @param Exception $error the exception triggered * - * @return String internal error message + * @return NULL */ public function NotImplementedHandler($error){ $this->app->setOutput("Error", "Internal error (not implemented yet), please contact an administrator"); @@ -97,9 +97,9 @@ Class errorManagement{ /** * Put an error message corresponding to a user input error in the output * - * @param $error the error triggered + * @param Exception $error the exception triggered * - * @return String User input error message + * @return NULL */ public function UserInputHandler($error){ $this->app->setOutput("Error", "UserInputError"); @@ -108,9 +108,9 @@ Class errorManagement{ /** * Put an error message corresponding to an other error in the output * - * @param $error the error triggered + * @param Exception $error the exception triggered * - * @return String error message + * @return NULL */ public function OtherException($error){ $this->app->setOutput("Error", $error->getMessage()); diff --git a/server/core/Identity.php b/server/core/Identity.php index 464522a..f6179b0 100755 --- a/server/core/Identity.php +++ b/server/core/Identity.php @@ -7,15 +7,13 @@ * * @author Eole 'eoledev at outlook . fr' * -* @todo Complete the functions and finish the descriptions */ use OpenCloud\Common\Error; - + /** * Identity Class of the back-end application * -* This class allow the communication between the front-end application and -* the library which allow to send requests to an Openstack instance. +* This class implements the management for the identity request * */ class identity implements Core{ @@ -31,8 +29,6 @@ class identity implements Core{ * * @param App $app the main app object * - * @throws [Type] [] - * * @return identity */ public function __construct($app){ @@ -47,11 +43,11 @@ class identity implements Core{ * * @param String $action name of another function of this class * - * @return void + * @return NULL */ public function action($action){ - $this->{$action.""}(); + $this->{$action.""}(); } /** @@ -65,7 +61,7 @@ class identity implements Core{ * @param String $type Required Type of credential : ec2, cert... * @param String $userId Required Id of the user which own the credential * - * @return void + * @return NULL */ private function addCredential(){ @@ -88,22 +84,22 @@ class identity implements Core{ }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** * List the credentials for a given user. * - * @return void + * @return NULL */ private function listCredentials(){ try{ @@ -114,15 +110,15 @@ class identity implements Core{ }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } @@ -131,7 +127,7 @@ class identity implements Core{ * * @param String $credentialId Required credential id for which it retrieve the details * - * @return void + * @return NULL */ private function showCredential(){ $credentId = $this->app->getPostParam("credentialId"); @@ -149,15 +145,15 @@ class identity implements Core{ }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } @@ -168,7 +164,7 @@ class identity implements Core{ * @param JsonString $blob Required credentials information with this structure for ec2: "{\"access\":\"181920\",\"secret\":\"secretKey\"}" * @param String $type Required Type of credential : ec2, cert... * - * @return void + * @return NULL */ private function updateCredential(){ @@ -194,15 +190,15 @@ class identity implements Core{ }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** @@ -210,7 +206,7 @@ class identity implements Core{ * * @param String $credentialId Required credential id to delete * - * @return void + * @return NULL */ private function deleteCredential(){ @@ -229,16 +225,16 @@ class identity implements Core{ }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } - + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } + }- /** @@ -248,7 +244,7 @@ class identity implements Core{ * @param String $enabled Optional Domain enabled or not : value true or false * @param String $name Required Domain Name * - * @return void + * @return NULL */ private function addDomain(){ @@ -262,13 +258,13 @@ class identity implements Core{ } if(isset($enabled) && isset($description)) - $opt = array('description' => $description, 'enabled' => $enabled, 'name' => $name); + $opt = array('description' => $description, 'enabled' => $enabled, 'name' => $name); elseif(isset($enabled)) - $opt = array('enabled' => $enabled, 'name' => $name); + $opt = array('enabled' => $enabled, 'name' => $name); elseif(isset($description)) - $opt = array('description' => $description, 'name' => $name); + $opt = array('description' => $description, 'name' => $name); else - $opt = array('name' => $name); + $opt = array('name' => $name); try{ @@ -278,22 +274,22 @@ class identity implements Core{ }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** * Retrieve the different domain's list. * - * @return void + * @return NULL */ private function listDomains(){ @@ -305,15 +301,15 @@ class identity implements Core{ }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } @@ -322,7 +318,7 @@ class identity implements Core{ * * @param String $domainId Required Domain id for which it retrieve the details * - * @return void + * @return NULL */ private function showDomain(){ @@ -341,15 +337,15 @@ class identity implements Core{ }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** @@ -360,7 +356,7 @@ class identity implements Core{ * @param String $enabled Optional Domain enabled or not : value true or false * @param String $name Required Domain Name * - * @return void + * @return NULL */ private function updateDomain(){ @@ -374,17 +370,17 @@ class identity implements Core{ return; } - + try{ $domain = $this->libClass->getDomain($domId); if(isset($name)) - $domain->name = $name; + $domain->name = $name; if(isset($enabled)) - $domain->enabled = $enabled; + $domain->enabled = $enabled; if(isset($description)) - $domain->description = $description; + $domain->description = $description; $domain->update(); @@ -392,15 +388,15 @@ class identity implements Core{ }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** @@ -408,7 +404,7 @@ class identity implements Core{ * * @param String $domainId Required Domain id to delete * - * @return void + * @return NULL */ private function deleteDomain(){ @@ -427,23 +423,21 @@ class identity implements Core{ }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** * Retrieve the different roles of a given user in a domain. * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function listRolesDomainUser(){ @@ -464,23 +458,21 @@ class identity implements Core{ }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** * Grant a role to a given user in a domain. * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function grantRoleDomainUser(){ $domId = $this->app->getPostParam("domainId"); @@ -496,31 +488,29 @@ class identity implements Core{ $domain = $this->libClass->getDomain($domId); $domain->grantUserRole([ - 'userId' => $userId, - 'roleId' => $roleId, + 'userId' => $userId, + 'roleId' => $roleId, ]); //TODO parse answer }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** * Verify that a user has a given role in a domain. * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function checkRoleDomainUser(){ $domId = $this->app->getPostParam("domainId"); @@ -545,23 +535,21 @@ class identity implements Core{ }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** * Delete a role for a given user in a domain. * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function revokeRoleDomainUser(){ $domId = $this->app->getPostParam("domainId"); @@ -577,31 +565,29 @@ class identity implements Core{ $domain = $this->libClass->getDomain($domId); $domain->revokeUserRole([ - 'userId' => $userId, - 'roleId' => $roleId, + 'userId' => $userId, + 'roleId' => $roleId, ]); //TODO parse answer }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** * Retrieve the roles of a given group in a domain. * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function listRolesDomainGroup(){ $domId = $this->app->getPostParam("domainId"); @@ -622,23 +608,21 @@ class identity implements Core{ }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** * Add a role to a given group in a domain. * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function grantRoleDomainGroup(){ $domId = $this->app->getPostParam("domainId"); @@ -654,31 +638,29 @@ class identity implements Core{ $domain = $this->libClass->getDomain($domId); $domain->grantGroupRole([ - 'groupId' => $groupId, - 'roleId' => $roleId, + 'groupId' => $groupId, + 'roleId' => $roleId, ]); //TODO parse answer }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** * Verify that a role is associated with a given group in a domain. * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function checkRoleDomainGroup(){ $domId = $this->app->getPostParam("domainId"); @@ -703,29 +685,21 @@ class identity implements Core{ }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** * Delete a role for a given group in a domain. * - * A *description*, that can span multiple lines, to go _in-depth_ into the details of this element - * and to provide some background information or textual references. - * - * @param string $myArgument With a *description* of this argument, these may also - * span multiple lines. - * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function revokeRoleDomainGroup(){ $domId = $this->app->getPostParam("domainId"); @@ -741,8 +715,8 @@ class identity implements Core{ $domain = $this->libClass->getDomain($roleId); $domain->revokeGroupRole([ - 'groupId' => $groupId, - 'roleId' => $roleId, + 'groupId' => $groupId, + 'roleId' => $roleId, ]); @@ -750,23 +724,21 @@ class identity implements Core{ }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** * Add an endpoint to the Openstack instance * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function addEndpoint(){ $servId = $this->app->getPostParam("serviceId"); @@ -781,34 +753,32 @@ class identity implements Core{ try{ $endpoint = $this->libClass->createEndpoint([ - 'interface' => \OpenStack\Identity\v3\Enum::INTERFACE_INTERNAL, - 'name' => $name, - 'region' => $region, - 'url' => $url, - 'serviceId' => $servId + 'interface' => \OpenStack\Identity\v3\Enum::INTERFACE_INTERNAL, + 'name' => $name, + 'region' => $region, + 'url' => $url, + 'serviceId' => $servId ]); //TODO parse answer }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** * Retrieve the endpoint for the given id * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function getEndpoint(){ @@ -826,24 +796,24 @@ class identity implements Core{ }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** * Retrieve the list of the different endpoints * - * @return void + * @return NULL */ private function listEndpoints(){ - + try{ $res = $this->libClass->listEndpoints(); @@ -852,64 +822,30 @@ class identity implements Core{ }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** * Update a given endpoint * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function updateEndpoint(){ //Not Implemented Yet - - /*$domId = $this->app->getPostParam("domainId"); - $groupId = $this->app->getPostParam("groupId"); - - if(!isset($domId) || !isset($groupId)){ - - } - - //TODO PARAMETERS - try{ - - $endpoint = $this->libClass->getEndpoint('{endpointId}'); - - $endpoint->interface = \OpenStack\Identity\v3\Enum::INTERFACE_PUBLIC; - - $endpoint->update(); - - //TODO parse answer - - }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 given endpoint * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function deleteEndpoint(){ $endId = $this->app->getPostParam("endpointId"); @@ -927,129 +863,48 @@ class identity implements Core{ }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** * Add a group. * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function addGroup(){ //Not Implemented Yet - - /*$domId = $this->app->getPostParam("domainId"); - $groupId = $this->app->getPostParam("groupId"); - - if(!isset($domId) || !isset($groupId)){ - - } - try{ - - $this->libClass->listCredentials() - - //TODO parse answer - - }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 the group's list. * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function listGroups(){ //Not Implemented Yet - /* - $domId = $this->app->getPostParam("domainId"); - $groupId = $this->app->getPostParam("groupId"); - - if(!isset($domId) || !isset($groupId)){ - - } - try{ - - $this->libClass->listCredentials() - - //TODO parse answer - - }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 the details of a given group. * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function showGroup(){ //Not Implemented Yet - - /* - $domId = $this->app->getPostParam("domainId"); - $groupId = $this->app->getPostParam("groupId"); - - if(!isset($domId) || !isset($groupId)){ - - } - try{ - - $this->libClass->listCredentials() - - //TODO parse answer - - }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 a given group. * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function updateGroup(){ //Todo Argument Optional @@ -1066,9 +921,9 @@ class identity implements Core{ $group = $this->libClass->getGroup($groupId); if(isset($description)) - $group->description = 'foo'; + $group->description = 'foo'; if(isset($name)) - $group->name = 'bar'; + $group->name = 'bar'; $group->update(); @@ -1076,23 +931,21 @@ class identity implements Core{ }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** * Delete the given group. * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function deleteGroup(){ @@ -1112,23 +965,21 @@ class identity implements Core{ }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** * Retrieve the users of a given group. * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function listGroupUsers(){ @@ -1148,23 +999,21 @@ class identity implements Core{ }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** * Add a user to a group. * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function addGroupUser(){ @@ -1185,23 +1034,21 @@ class identity implements Core{ }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** * Remove a user from a given group. * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function removeGroupUser(){ @@ -1222,23 +1069,21 @@ class identity implements Core{ }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** * Check if a group contains a given user. * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function checkGroupUser(){ @@ -1259,199 +1104,67 @@ class identity implements Core{ }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** * @todo * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function addPolicies(){ //Not Implemented Yet - /* - $domId = $this->app->getPostParam("domainId"); - $groupId = $this->app->getPostParam("groupId"); - - if(!isset($domId) || !isset($groupId)){ - - } - try{ - - $this->libClass->listCredentials() - - //TODO parse answer - - }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); - }*/ } /** * @todo * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function listPolicies(){ //Not Implemented Yet - /* - $domId = $this->app->getPostParam("domainId"); - $groupId = $this->app->getPostParam("groupId"); - - if(!isset($domId) || !isset($groupId)){ - - } - try{ - - $this->libClass->listCredentials() - - //TODO parse answer - - }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); - }*/ } /** * @todo * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function showPolicie(){ //Not Implemented Yet - /* - $domId = $this->app->getPostParam("domainId"); - $groupId = $this->app->getPostParam("groupId"); - - if(!isset($domId) || !isset($groupId)){ - - } - try{ - - $this->libClass->listCredentials() - - //TODO parse answer - - }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); - }*/ } /** * @todo * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function updatePolicies(){ //Not Implemented Yet - /* - $domId = $this->app->getPostParam("domainId"); - $groupId = $this->app->getPostParam("groupId"); - - if(!isset($domId) || !isset($groupId)){ - - } - try{ - - $this->libClass->listCredentials() - - //TODO parse answer - - }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); - }*/ } /** * @todo * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function deletePolicies(){ //Not Implemented Yet - /* - $domId = $this->app->getPostParam("domainId"); - $groupId = $this->app->getPostParam("groupId"); - - if(!isset($domId) || !isset($groupId)){ - - } - try{ - - $this->libClass->listCredentials() - - //TODO parse answer - - }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); - }*/ } /** * Add a project. * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function addProject(){ //Todo Parameters Optional @@ -1465,30 +1178,30 @@ class identity implements Core{ try{ $project = $this->libClass->createProject([ - 'description' => $description, - 'enabled' => true, - 'name' => $name + 'description' => $description, + 'enabled' => true, + 'name' => $name ]); //TODO parse answer }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** * Retrieve the different projects. * - * @return void + * @return NULL */ private function listProjects(){ @@ -1500,23 +1213,21 @@ class identity implements Core{ }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** * Retrieve the details of a given project. * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function showProject(){ @@ -1535,23 +1246,21 @@ class identity implements Core{ }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** * Update a given project. * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function updateProject(){ //Todo Parameters Optionnal @@ -1577,23 +1286,21 @@ class identity implements Core{ }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** * Delete a given project. * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function deleteProject(){ $projId = $this->app->getPostParam("projId"); @@ -1612,23 +1319,21 @@ class identity implements Core{ }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** * List the roles of a given user in a project. * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function listRolesProjectUser(){ @@ -1649,25 +1354,23 @@ class identity implements Core{ }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** * Grant a role to an user in a project. * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function grantRoleProjectUser(){ @@ -1684,31 +1387,29 @@ class identity implements Core{ $project = $this->libClass->getProject($projId); $project->grantUserRole([ - 'userId' => $userId, - 'roleId' => $roleId, + 'userId' => $userId, + 'roleId' => $roleId, ]); //TODO parse answer }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** * Check if a given user has a role in a project. * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function checkRoleProjectUser(){ $projId = $this->app->getPostParam("projetId"); @@ -1724,8 +1425,8 @@ class identity implements Core{ $project = $this->libClass->getProject($projId); $result = $project->checkUserRole([ - 'userId' => $userId, - 'roleId' => $roleId, + 'userId' => $userId, + 'roleId' => $roleId, ]); /*if (true === $result) { @@ -1735,23 +1436,21 @@ class identity implements Core{ }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** * Delete a role for a given user in a project. * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function revokeRoleProjectUser(){ @@ -1768,31 +1467,29 @@ class identity implements Core{ $project = $this->libClass->getProject($projId); $project->revokeUserRole([ - 'userId' => $userId, - 'roleId' => $roleId, + 'userId' => $userId, + 'roleId' => $roleId, ]); //TODO parse answer }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** * List the roles of a group in a project. * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function listRolesProjectGroup(){ @@ -1803,7 +1500,7 @@ class identity implements Core{ if(!isset($projId) || !isset($groupId)){ } - + try{ $project = $this->libClass->getProject($projId); @@ -1814,23 +1511,21 @@ class identity implements Core{ }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** * Add a role to a group in a project. * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function grantRoleProjectGroup(){ @@ -1841,37 +1536,35 @@ class identity implements Core{ if(!isset($projId) || !isset($userId) || !isset($roleId)){ } - + try{ $project = $this->libClass->getProject($projId); $project->grantUserRole([ - 'userId' => $userId, - 'roleId' => $roleId, + 'userId' => $userId, + 'roleId' => $roleId, ]); //TODO parse answer }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** * Check if a group has a given role in a project. * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function checkRoleProjectGroup(){ @@ -1888,8 +1581,8 @@ class identity implements Core{ $project = $this->libClass->getProject($projId); $result = $project->checkGroupRole([ - 'groupId' => $groupId, - 'roleId' => $roleId, + 'groupId' => $groupId, + 'roleId' => $roleId, ]); /*if (true === $result) { @@ -1898,23 +1591,21 @@ class identity implements Core{ }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** * Delete a role for a group in a project. * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function revokeRoleProjectGroup(){ @@ -1931,31 +1622,29 @@ class identity implements Core{ $project = $this->libClass->getProject($projId); $project->revokeGroupRole([ - 'groupId' => $groupId, - 'roleId' => $roleId, + 'groupId' => $groupId, + 'roleId' => $roleId, ]); //TODO parse answer }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** * Add a role. * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function addRole(){ @@ -1968,28 +1657,28 @@ class identity implements Core{ try{ $role = $this->libClass->createRole([ - 'name' => $name, + 'name' => $name, ]); //TODO parse answer }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** * List the different roles * - * @return void + * @return NULL */ private function listRoles(){ @@ -2001,21 +1690,21 @@ class identity implements Core{ }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** - * @todo + * List the different assignments for a given role * - * @return void + * @return NULL */ private function listRoleAssignements(){ @@ -2027,23 +1716,21 @@ class identity implements Core{ }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** * Add a service. * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function addService(){ $name = $this->app->getPostParam("name"); @@ -2056,29 +1743,29 @@ class identity implements Core{ try{ $service = $this->libClass->createService([ - 'name' => $name, - 'type' => $type, + 'name' => $name, + 'type' => $type, ]); //TODO parse answer }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** * Retrieve the different services. * - * @return void + * @return NULL */ private function listServices(){ @@ -2090,23 +1777,21 @@ class identity implements Core{ }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** * Retrieve the details for a given service. * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function showService(){ $servId = $this->app->getPostParam("serviceId"); @@ -2123,23 +1808,21 @@ class identity implements Core{ }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** * Delete a given service. * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function deleteService(){ @@ -2159,23 +1842,21 @@ class identity implements Core{ }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** * Generate a new token for a given user id. * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function genTokenUserID(){ @@ -2189,33 +1870,31 @@ class identity implements Core{ try{ $token = $this->libClass->generateToken([ - 'user' => [ - 'id' => $userId, - 'password' => $userPass - ] + 'user' => [ + 'id' => $userId, + 'password' => $userPass + ] ]); //TODO parse answer }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** * Generate a new token for a given user name. * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function genTokenUserName(){ $username = $this->app->getPostParam("username"); @@ -2230,36 +1909,34 @@ class identity implements Core{ try{ $token = $this->libClass->generateToken([ - 'user' => [ - 'name' => $username, - 'password' => $userPass, - 'domain' => [ - 'id' => $domId - ] - ] + 'user' => [ + 'name' => $username, + 'password' => $userPass, + 'domain' => [ + 'id' => $domId + ] + ] ]); //TODO parse answer }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** * Generate a new token from another token ID. * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function genTokenID(){ @@ -2273,31 +1950,29 @@ class identity implements Core{ try{ $token = $this->libClass->generateToken([ - 'tokenId' => $tokenId, - 'scope' => ['project' => ['id' => $projectId]] + 'tokenId' => $tokenId, + 'scope' => ['project' => ['id' => $projectId]] ]); //TODO parse answer }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** * Generate a new token scoped by a project ID. * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function genTokenScopedProjectID(){ @@ -2312,36 +1987,34 @@ class identity implements Core{ try{ $token = $this->libClass->generateToken([ - 'user' => [ - 'id' => $userId, - 'password' => $userPass - ], - 'scope' => [ - 'project' => ['id' => $projId] - ] + 'user' => [ + 'id' => $userId, + 'password' => $userPass + ], + 'scope' => [ + 'project' => ['id' => $projId] + ] ]); //TODO parse answer }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** * Generate a new token scoped by a project name. * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function genTokenScopedProjectName(){ @@ -2357,41 +2030,39 @@ class identity implements Core{ try{ $token = $this->libClass->generateToken([ - 'user' => [ - 'id' => $userId, - 'password' => $userPass - ], - 'scope' => [ - 'project' => [ - 'name' => $projName, - 'domain' => [ - 'id' => $domId - ] - ] - ] + 'user' => [ + 'id' => $userId, + 'password' => $userPass + ], + 'scope' => [ + 'project' => [ + 'name' => $projName, + 'domain' => [ + 'id' => $domId + ] + ] + ] ]); //TODO parse answer }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** * Check if a token is validate. * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function validateToken(){ @@ -2413,23 +2084,21 @@ class identity implements Core{ }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** * Delete a given token. * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function revokeToken(){ @@ -2447,23 +2116,21 @@ class identity implements Core{ }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** * Add a new user. * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function addUser(){ //Todo Optionnal Parameter @@ -2475,40 +2142,40 @@ class identity implements Core{ $domId = $this->app->getPostParam("domId"); if(!isset($domId) || !isset($groupId)){ - + } try{ $user = $this->libClass->createUser([ - 'defaultProjectId' => $projId, - 'description' => $desc, - 'domainId' => $domId, - 'email' => $email, - 'enabled' => true, - 'name' => $name, - 'password' => $pass + 'defaultProjectId' => $projId, + 'description' => $desc, + 'domainId' => $domId, + 'email' => $email, + 'enabled' => true, + 'name' => $name, + 'password' => $pass ]); //TODO parse answer }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** * Retrieve the different users. * - * @return void + * @return NULL */ private function listUsers(){ @@ -2520,23 +2187,21 @@ class identity implements Core{ }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** * Retrieve the details of a given user. * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function showUser(){ @@ -2555,23 +2220,21 @@ class identity implements Core{ }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** * Update a given user. * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function updateUser(){ @@ -2596,23 +2259,21 @@ class identity implements Core{ }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** * Delete a given user. * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function deleteUser(){ @@ -2631,23 +2292,21 @@ class identity implements Core{ }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** * Retrieve the groups which contains a given user. * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function listUserGroups(){ @@ -2667,23 +2326,21 @@ class identity implements Core{ }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** * Retrieve the projects which contains a given user. * - * @throws [Type] [] - * - * @return void + * @return NULL */ private function listUserProjects(){ @@ -2703,14 +2360,14 @@ class identity implements Core{ }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } } diff --git a/server/core/Image.php b/server/core/Image.php index 334fce4..d930962 100755 --- a/server/core/Image.php +++ b/server/core/Image.php @@ -51,10 +51,10 @@ class image implements Core{ * * @param String $action name of another function of this class * - * @return void + * @return NULL */ public function action($action){ - $this->{$action.""}(); + $this->{$action.""}(); } /** @@ -78,13 +78,13 @@ class image implements Core{ if(isset($opt['name'])){ $imagesList = $this->listImage(); if(isset($imagesList)){ - foreach($imagesList as $image){ - if(strcmp($image->name, $opt['name']) == 0){ // if the image name already exists -> error - $this->app->setOutput("Error", "Image name already exists"); - } - } - } - $options['name'] = $opt['name']; + foreach($imagesList as $image){ + if(strcmp($image->name, $opt['name']) == 0){ // if the image name already exists -> error + $this->app->setOutput("Error", "Image name already exists"); + } + } + } + $options['name'] = $opt['name']; } else{ $this->app->setOutput("Error", "Missing parameter 'name' for the new image"); @@ -125,15 +125,15 @@ class image implements Core{ $image = $this->libClass->createImage($options); }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } $this->app->setOutput("Images", $image); } @@ -152,15 +152,15 @@ class image implements Core{ } }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } $this->app->setOutput("Images", $result); @@ -191,16 +191,16 @@ class image implements Core{ } }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } + } } /** @@ -254,15 +254,15 @@ class image implements Core{ $image->update($options); }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } $this->app->setOutput("Images", $image); } } @@ -272,7 +272,7 @@ class image implements Core{ * * @param String $id Identifier of the image * - * @return void + * @return NULL */ private function deleteImage(){ $id = $this->app->getPostParam("id"); @@ -289,16 +289,16 @@ class image implements Core{ $image->delete(); }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } + } } /** @@ -306,7 +306,7 @@ class image implements Core{ * * @param String $id Identifier of the image * - * @return void + * @return NULL */ private function reactivateImage(){ $id = $this->app->getPostParam("id"); @@ -326,16 +326,16 @@ class image implements Core{ $image->reactivate(); }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } + } } /** @@ -343,7 +343,7 @@ class image implements Core{ * * @param String $id Identifier of the image * - * @return void + * @return NULL */ private function desactivateImage(){ $id = $this->app->getPostParam("id"); @@ -362,16 +362,16 @@ class image implements Core{ $image->deactivate(); }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } + } } /** @@ -380,14 +380,14 @@ class image implements Core{ * @param String $id Identifier of the image * @param String $file_name Path of the image * - * @return void + * @return NULL */ private function uploadImage(){ $id = $this->app->getPostParam("id"); $file_name = $this->app->getPostParam("file_name"); - $file = $this->app->getPostParam("file"); + $file = $this->app->getPostParam("file"); error_log(print_r($file, true), 0); - + if(!isset($id)){ $this->app->setOutput("Error", "Incorrect id parameter"); } @@ -405,16 +405,16 @@ class image implements Core{ $image->uploadData($stream); }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } + } } /** @@ -440,17 +440,17 @@ class image implements Core{ $stream = $image->downloadData(); }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } - $this->app->setOutput("Images", $stream); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } + $this->app->setOutput("Images", $stream); + } } /** @@ -483,16 +483,16 @@ class image implements Core{ $this->app->setOutput("Images", $member_id); }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } + } } @@ -526,15 +526,15 @@ class image implements Core{ } }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } $this->app->setOutput("Images", $members); } } @@ -572,15 +572,15 @@ class image implements Core{ } }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } $this->app->setOutput("Images", $member); } } @@ -591,7 +591,7 @@ class image implements Core{ * @param String $image_id Identifier of the image * @param String $member_id Identifier of the member * - * @return void + * @return NULL */ private function removeMemberImage(){ $image_id = $this->app->getPostParam("image_id"); @@ -618,16 +618,16 @@ class image implements Core{ $member->delete(); }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } + } } /** @@ -637,7 +637,7 @@ class image implements Core{ * @param String $member_id Identifier of the member * @param String $status New status for the member * - * @return void + * @return NULL **/ private function updateMemberImage(){ $image_id = $this->app->getPostParam("image_id"); @@ -665,16 +665,16 @@ class image implements Core{ $member->updateStatus($status); }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } + } } } diff --git a/server/core/LibOverride/genTokenOptions.php b/server/core/LibOverride/genTokenOptions.php index 394db31..68a7dbd 100755 --- a/server/core/LibOverride/genTokenOptions.php +++ b/server/core/LibOverride/genTokenOptions.php @@ -22,33 +22,33 @@ class genTokenOptions $this->stack = HandlerStack::create(); $httpClient = new Client([ - 'base_uri' => Utils::normalizeUrl($options['authUrl']), - 'handler' => $this->stack, - ]); + 'base_uri' => Utils::normalizeUrl($options['authUrl']), + 'handler' => $this->stack, + ]); $this->httpClient = $httpClient; - $options['identityService'] = Service::factory($httpClient); + $options['identityService'] = Service::factory($httpClient); $options['authHandler'] = function () use ($options) { return $options['identityService']->generateToken($options); - }; + }; $this->optionsGlobal['Common'] = $options; } - - /** - * @codeCoverageIgnore - */ - private function addDebugMiddleware(array $options, HandlerStack &$stack) - { - if (!empty($options['debugLog']) - && !empty($options['logger']) - && !empty($options['messageFormatter']) - ) { - $stack->push(GuzzleMiddleware::log($options['logger'], $options['messageFormatter'])); - } - } + + /** + * @codeCoverageIgnore + */ + private function addDebugMiddleware(array $options, HandlerStack &$stack) + { + if (!empty($options['debugLog']) + && !empty($options['logger']) + && !empty($options['messageFormatter']) + ) { + $stack->push(GuzzleMiddleware::log($options['logger'], $options['messageFormatter'])); + } + } public function checkToken(){ //error_log(print_r($this->backup['time'], true), 0); @@ -73,9 +73,9 @@ class genTokenOptions $this->addDebugMiddleware($options, $stack); $options['httpClient'] = new Client([ - 'base_uri' => Utils::normalizeUrl($baseUrl), - 'handler' => $stack, - ]); + 'base_uri' => Utils::normalizeUrl($baseUrl), + 'handler' => $stack, + ]); $this->saveBackup('Identity', array('token' => $token, 'baseUrl' => $baseUrl )); $this->optionsGlobal['Identity'] = $options; @@ -98,15 +98,15 @@ class genTokenOptions $baseUrl = $this->backup['Identity']['baseUrl']; $stack = HandlerStack::create(); - + $stack->push(Middleware::authHandler($options['authHandler'], $token)); $this->addDebugMiddleware($options, $stack); $options['httpClient'] = new Client([ - 'base_uri' => Utils::normalizeUrl($baseUrl), - 'handler' => $stack, - ]); + 'base_uri' => Utils::normalizeUrl($baseUrl), + 'handler' => $stack, + ]); $this->saveBackup('Identity', array('token' => $token, 'baseUrl' => $baseUrl )); $this->optionsGlobal['Identity'] = $options; @@ -122,14 +122,14 @@ class genTokenOptions $stack = HandlerStack::create(); - $stack->push(Middleware::authHandler($options['authHandler'], $token)); + $stack->push(Middleware::authHandler($options['authHandler'], $token)); $this->addDebugMiddleware($options, $stack); $options['httpClient'] = new Client([ - 'base_uri' => Utils::normalizeUrl($baseUrl), - 'handler' => $stack, - ]); + 'base_uri' => Utils::normalizeUrl($baseUrl), + 'handler' => $stack, + ]); $this->saveBackup('Image', array('token' => $token, 'baseUrl' => $baseUrl )); $this->optionsGlobal['Image'] = $options; @@ -150,7 +150,7 @@ class genTokenOptions $this->backup['Image'] = $opt; $token = $this->unserializeToken($this->backup['Image']['token']); $baseUrl = $this->backup['Image']['baseUrl']; - + $stack = HandlerStack::create(); $stack->push(Middleware::authHandler($options['authHandler'], $token)); @@ -158,9 +158,9 @@ class genTokenOptions $this->addDebugMiddleware($options, $stack); $options['httpClient'] = new Client([ - 'base_uri' => Utils::normalizeUrl($baseUrl), - 'handler' => $stack, - ]); + 'base_uri' => Utils::normalizeUrl($baseUrl), + 'handler' => $stack, + ]); $this->saveBackup('Image', array('token' => $token, 'baseUrl' => $baseUrl )); $this->optionsGlobal['Image'] = $options; } @@ -175,14 +175,14 @@ class genTokenOptions $stack = HandlerStack::create(); - $stack->push(Middleware::authHandler($options['authHandler'], $token)); + $stack->push(Middleware::authHandler($options['authHandler'], $token)); $this->addDebugMiddleware($options, $stack); $options['httpClient'] = new Client([ - 'base_uri' => Utils::normalizeUrl($baseUrl), - 'handler' => $stack, - ]); + 'base_uri' => Utils::normalizeUrl($baseUrl), + 'handler' => $stack, + ]); $this->saveBackup('Network', array('token' => $token, 'baseUrl' => $baseUrl )); $this->optionsGlobal['Network'] = $options; @@ -203,17 +203,17 @@ class genTokenOptions $this->backup['Network'] = $opt; $token = $this->unserializeToken($this->backup['Network']['token']); $baseUrl = $this->backup['Network']['baseUrl']; - + $stack = HandlerStack::create(); - + $stack->push(Middleware::authHandler($options['authHandler'], $token)); $this->addDebugMiddleware($options, $stack); $options['httpClient'] = new Client([ - 'base_uri' => Utils::normalizeUrl($baseUrl), - 'handler' => $stack, - ]); + 'base_uri' => Utils::normalizeUrl($baseUrl), + 'handler' => $stack, + ]); $this->saveBackup('Network', array('token' => $token, 'baseUrl' => $baseUrl )); $this->optionsGlobal['Network'] = $options; } @@ -228,14 +228,14 @@ class genTokenOptions $stack = HandlerStack::create(); - $stack->push(Middleware::authHandler($options['authHandler'], $token)); + $stack->push(Middleware::authHandler($options['authHandler'], $token)); $this->addDebugMiddleware($options, $stack); $options['httpClient'] = new Client([ - 'base_uri' => Utils::normalizeUrl($baseUrl), - 'handler' => $stack, - ]); + 'base_uri' => Utils::normalizeUrl($baseUrl), + 'handler' => $stack, + ]); $this->saveBackup('Compute', array('token' => $token, 'baseUrl' => $baseUrl )); $this->optionsGlobal['Compute'] = $options; @@ -257,17 +257,17 @@ class genTokenOptions $this->backup['Compute'] = $opt; $token = $this->unserializeToken($this->backup['Compute']['token']); $baseUrl = $this->backup['Compute']['baseUrl']; - + $stack = HandlerStack::create(); - + $stack->push(Middleware::authHandler($options['authHandler'], $token)); $this->addDebugMiddleware($options, $stack); $options['httpClient'] = new Client([ - 'base_uri' => Utils::normalizeUrl($baseUrl), - 'handler' => $stack, - ]); + 'base_uri' => Utils::normalizeUrl($baseUrl), + 'handler' => $stack, + ]); $this->saveBackup('Compute', array('token' => $token, 'baseUrl' => $baseUrl )); $this->optionsGlobal['Compute'] = $options; } @@ -426,7 +426,7 @@ class genTokenOptions $token->user->description = unserialize($this->backup["user"]["description"]); $token->issued = unserialize($tokenSerialized["issued"]); $token->id = unserialize($tokenSerialized["id"]); - + return $token; } } diff --git a/server/core/Network.php b/server/core/Network.php index e93c2c5..54b5d60 100755 --- a/server/core/Network.php +++ b/server/core/Network.php @@ -22,9 +22,9 @@ use OpenCloud\Common\Error\UserInputError; */ class network{ -/** @var App $app protected, contains the main app object */ + /** @var App $app protected, contains the main app object */ protected $app; -/** @var OpenStack\Network $libClass protected, contains the library Network object */ + /** @var OpenStack\Network $libClass protected, contains the library Network object */ protected $libClass; @@ -49,11 +49,11 @@ class network{ * * @param String $action name of another function of this class * - * @return void + * @return NULL */ public function action($action){ - $this->{$action.""}(); + $this->{$action.""}(); } @@ -65,7 +65,7 @@ class network{ * @param String shared Specifies whether the network resource can be accessed by any tenant * @param String tenantId Owner of network. Only admin users can specify a tenant ID other than their own * - * @return void + * @return NULL */ private function create_network() { @@ -102,19 +102,19 @@ class network{ 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); - } + } } @@ -136,7 +136,7 @@ class network{ * * * - * @return void + * @return NULL */ private function create_subnet() @@ -200,24 +200,24 @@ class network{ try { - $subnet = $this->libClass->createSubnet($options); + $subnet = $this->libClass->createSubnet($options); } 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); - } + } } @@ -233,36 +233,36 @@ class network{ try { $ln = $this->libClass->listNetworks(); - + $list_ids = array(); - + foreach($ln as $n) { - + $list_ids[] = $n->id; - + } } 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); - } + } - $this->app->setOutput("ListNetworkIds", $list_ids); + $this->app->setOutput("ListNetworkIds", $list_ids); } /** @@ -276,37 +276,37 @@ class network{ try { $ln = $this->libClass->listNetworks(); - + $list_names = array(); - + foreach($ln as $n) { - + $list_names[] = $n->name; - + } - + } 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); - } + } - $this->app->setOutput("ListNetworkNames", $list_names); + $this->app->setOutput("ListNetworkNames", $list_names); } /** * List the CIDR of the SUBNETS @@ -317,32 +317,32 @@ class network{ { try { - $ls = $this->libClass->listSubnets(); - $list_cidr = array(); - foreach ($ls as $subnet) - { - - $list_cidr[] = $subnet->cidr; - } + $ls = $this->libClass->listSubnets(); + $list_cidr = array(); + foreach ($ls as $subnet) + { + + $list_cidr[] = $subnet->cidr; + } - $this->app->setOutput("ListCidr", $list_cidr); + $this->app->setOutput("ListCidr", $list_cidr); } 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); - } + } } /** * retrieve a specific network @@ -364,21 +364,21 @@ class network{ 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); - } + } - $this->app->setOutput("Network", $network); + $this->app->setOutput("Network", $network); } /** @@ -401,21 +401,21 @@ class network{ 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); - } + } - return $network; + return $network; } /** @@ -437,21 +437,21 @@ class network{ 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); - } + } $this->app->setOutput("Subnet", subnet); - + } /** * internal function @@ -472,21 +472,21 @@ class network{ 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); - } + } return $subnet; - + } /** @@ -498,11 +498,11 @@ class network{ * @param String tenantId Owner of network. Only admin users can specify a tenant ID other than their own * * - * @return void + * @return NULL **/ - private function updateNetwork() - { + private function updateNetwork() + { $options = array(); $name = $this->app->getPostParam("name"); $shared = $this->app->getPostParam("shared"); @@ -524,25 +524,25 @@ class network{ { $networkId = $this->app->getPostParam("networkId"); $network = getNetworkP($networkId); - + $network->update($options); } 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); - } + } } /** @@ -561,11 +561,11 @@ class network{ * @param String allocationPools Subranges of the CIDR available for dynamic allocation to ports * * - * @return void + * @return NULL **/ private function updateSubnet() - { + { $options = array(); $name = $this->app->getPostParam("name"); $networkId = $this->app->getPostParam("networkId"); @@ -596,19 +596,19 @@ class network{ 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); - } + } } /** @@ -617,10 +617,10 @@ class network{ * @param String networkId ID if network which we want to delete * * - * @return void + * @return NULL **/ private function deleteNetwork() - { + { try { $networkId = $this->app->getPostParam("networkId"); @@ -630,19 +630,19 @@ class network{ 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); - } + } } /** @@ -651,10 +651,10 @@ class network{ * @param String subnetId ID if network which we want to delete * * - * @return void + * @return NULL **/ private function deleteSubnet() - { + { try { $subnetId = $this->app->getPostParam("subnetId"); @@ -664,19 +664,19 @@ class network{ 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); - } + } } /** @@ -692,7 +692,7 @@ class network{ * @param String securityGroups Specifies the IDs of any security groups associated with this port * @param String tenantId Owner of the port. Only admin users can specify a tenant ID other than their own. * - * @return void + * @return NULL */ private function createPort() @@ -751,19 +751,19 @@ class network{ 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); - } + } } /** @@ -781,19 +781,19 @@ class network{ 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); - } + } } /** @@ -813,20 +813,20 @@ class network{ 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); - } - + } + } /** @@ -846,20 +846,20 @@ class network{ 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); - } - + } + } @@ -876,7 +876,7 @@ class network{ * @param String securityGroups Specifies the IDs of any security groups associated with this port * @param String tenantId Owner of the port. Only admin users can specify a tenant ID other than their own. * - * @return void + * @return NULL */ private function updatePort() { @@ -935,28 +935,28 @@ class network{ 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); - } + } } /** * Delete a port given * * @param String portId id of port which we wante to delete - * @return void + * @return NULL */ private function deletePort() - { + { try { @@ -967,19 +967,19 @@ class network{ 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); - } + } } /** @@ -988,7 +988,7 @@ class network{ * @param String name A human-readable name for the security group. This name might not be unique * @param String description Description of the security group * - * @return void + * @return NULL */ private function createSecurityGroup() @@ -1012,20 +1012,20 @@ class network{ 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); - } - + } + } /** @@ -1040,7 +1040,7 @@ class network{ *@param String remoteGroupId The remote group ID to be associated with this security group rule. You can specify either remoteGroupId or remoteGroupPrefix *@param String remoteIpPrefix The remote IP prefix to be associated with this security group rule. You can specify either remoteGroupId or remoteGroupPrefix * - * @return void + * @return NULL */ private function createSecurityGroupRule() { @@ -1093,19 +1093,19 @@ class network{ 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); - } + } } @@ -1124,19 +1124,19 @@ class network{ 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); - } + } } @@ -1150,26 +1150,26 @@ class network{ { try { - - $this->app->setOutput("listSecurityGroupeRule", $this->libClass->listSecurityGroupRules()); + + $this->app->setOutput("listSecurityGroupeRule", $this->libClass->listSecurityGroupRules()); } 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); - } + } } /** @@ -1189,20 +1189,20 @@ class network{ 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); - } - + } + } /** @@ -1221,28 +1221,28 @@ class network{ 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); - } - + } + } /** * Delete a specific Security Groupe given * @param securityGroupeId ID of security Groupe which we want to get - * @return void + * @return NULL */ private function deleteSecurityGroupe() - { + { try { $securityGroupId = $this->app->getPostParam("securityGroupeId"); @@ -1252,18 +1252,18 @@ class network{ 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); - } + } } } diff --git a/server/core/NetworkLayer3.php b/server/core/NetworkLayer3.php index 30e8a78..c0b773a 100755 --- a/server/core/NetworkLayer3.php +++ b/server/core/NetworkLayer3.php @@ -51,10 +51,10 @@ class networkLayer3 { * * @param String $action name of another function of this class * - * @return void + * @return NULL */ public function action($action){ - $this->{$action.""}(); + $this->{$action.""}(); } @@ -75,15 +75,15 @@ class networkLayer3 { $this->app->setOutput("NetworkLayer3", $result); }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** @@ -109,15 +109,15 @@ class networkLayer3 { } }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } @@ -147,7 +147,7 @@ class networkLayer3 { foreach ($res as $f) { if(strcmp($f->id, $id)){ $result = $f; - + } } @@ -159,15 +159,15 @@ class networkLayer3 { } }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** @@ -175,7 +175,7 @@ class networkLayer3 { * * @param id the id of the floatingip to update * - * @return void + * @return NULL */ private function updateFloatingIp(){ $id = $this->app->getPostParam("id"); @@ -197,7 +197,7 @@ class networkLayer3 { foreach ($res as $f) { if(strcmp($f->id, $id)){ $result = $f; - + } } @@ -208,15 +208,15 @@ class networkLayer3 { } }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } /** @@ -224,7 +224,7 @@ class networkLayer3 { * * @param string floatingip_id the floating-ip id to delete * - * @return void + * @return NULL */ private function deleteFloatingIp(){ $id = $this->app->getPostParam("id"); @@ -245,7 +245,7 @@ class networkLayer3 { foreach ($res as $f) { if(strcmp($f->id, $id)){ $result = $f; - + } } @@ -256,15 +256,15 @@ class networkLayer3 { } }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } @@ -273,7 +273,7 @@ class networkLayer3 { * * @param string floatingip_id the floating-ip id to retrieve * - * @return void + * @return NULL */ private function retrieveFloatingIp(){ $id = $this->app->getPostParam("id"); @@ -294,7 +294,7 @@ class networkLayer3 { foreach ($res as $f) { if(strcmp($f->id, $id)){ $result = $f; - + } } @@ -305,15 +305,15 @@ class networkLayer3 { } }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } @@ -344,15 +344,15 @@ class networkLayer3 { } }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } @@ -372,15 +372,15 @@ class networkLayer3 { $this->app->setOutput("NetworkLayer3", $result); }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } @@ -420,15 +420,15 @@ class networkLayer3 { } }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } @@ -437,7 +437,7 @@ class networkLayer3 { * * @param string router the router to delete * - * @return void + * @return NULL */ private function deleteRouter(){ $id = $this->app->getPostParam("id"); @@ -468,15 +468,15 @@ class networkLayer3 { } }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } @@ -485,7 +485,7 @@ class networkLayer3 { * * @param id the id of the floatingip to update * - * @return void + * @return NULL */ private function updateRouter(){ $id = $this->app->getPostParam("id"); @@ -507,7 +507,7 @@ class networkLayer3 { foreach ($res as $f) { if(strcmp($f->id, $id)){ $result = $f; - + } } @@ -518,14 +518,14 @@ class networkLayer3 { } }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); - }catch(UserInputError $e){ + }catch(UserInputError $e){ $this->app->getErrorInstance()->UserInputHandler($e); - }catch(BaseError $e){ + }catch(BaseError $e){ $this->app->getErrorInstance()->BaseErrorHandler($e); - }catch(NotImplementedError $e){ + }catch(NotImplementedError $e){ $this->app->getErrorInstance()->NotImplementedHandler($e); - }catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); - } + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } } } diff --git a/server/index.php b/server/index.php index 53a24c4..01203de 100755 --- a/server/index.php +++ b/server/index.php @@ -1,70 +1,88 @@ setOutput("Error", "Invalid Request!"); + $App->show(); + exit(); +} + +//Authentification and deauthentification request +if($task == "Authenticate"){ - if(isset($_POST["task"]) && isset($_POST["action"])){ - $task = $_POST["task"]; - $action = $_POST["action"]; - }else if(isset($_POST["task"]) && $_POST["task"] == "Authenticate" || $_POST["task"] == "Deauthenticate"){ - $task = $_POST["task"]; - }else{ - //Gestion Erreur - } + $App->authenticate(); + $App->show(); - if($task == "Authenticate"){ - - $App->authenticate(); +}else if($task == "Deauthenticate"){ + + $App->deauthenticate(); + $App->show(); + +}else if($App->checkToken()){ + //Task switcher and task's file loader + switch($task) + { + case "identity": + include_once("core/Identity.php"); + $identityObject = new identity($App); + $identityObject->action($action); $App->show(); + break; - }else if($task == "Deauthenticate"){ - - $App->deauthenticate(); + case "network": + include_once("core/Network.php"); + $networkObject = new network($App); + $networkObject->action($action); $App->show(); + break; - }else if($App->checkToken()){ - switch($task) - { - case "identity": - include_once("core/Identity.php"); - $identityObject = new identity($App); - $identityObject->action($action); - $App->show(); - break; - - case "network": - include_once("core/Network.php"); - $networkObject = new network($App); - $networkObject->action($action); - $App->show(); - break; - - case "image": - include_once("core/Image.php"); - $imageObject = new image($App); - $imageObject->action($action); - $App->show(); - break; - - case "compute": - include_once("core/Compute.php"); - $computeObject = new compute($App); - $computeObject->action($action); - $App->show(); - break; - - case "networkLayer3": - include_once("core/NetworkLayer3.php"); - $computeObject = new networkLayer3($App); - $computeObject->action($action); - $App->show(); - break; - } + case "image": + include_once("core/Image.php"); + $imageObject = new image($App); + $imageObject->action($action); + $App->show(); + break; + + case "compute": + include_once("core/Compute.php"); + $computeObject = new compute($App); + $computeObject->action($action); + $App->show(); + break; - }else{ - $App->setOutput("Error", "Token Invalide"); + case "networkLayer3": + include_once("core/NetworkLayer3.php"); + $computeObject = new networkLayer3($App); + $computeObject->action($action); $App->show(); + break; } - - +}else{ + //Request without authentication + $App->setOutput("Error", "Token Invalide"); + $App->show(); +} + + + diff --git a/server/init.php b/server/init.php index a00927d..767224a 100755 --- a/server/init.php +++ b/server/init.php @@ -1,48 +1,55 @@ Array( - "name" => $user, - "password" => $password, - "domain" => Array( - "name" => "Default") - ), - "scope" => Array( - "project" => Array( - "name" => $project, - "domain" => Array( - "name" => "Default") - ) - ), - "authUrl" => $config["urlAuth"] - ); +}else if(isset($_POST["user"]) && isset($_POST["password"]) && isset($_POST["project"]) ){ - $App = new App($Args); + $user = $_POST["user"]; + $password = $_POST["password"]; + $project = $_POST["project"]; + +} + +//Library args +$Args = Array( + "user" => Array( + "name" => $user, + "password" => $password, + "domain" => Array( + "name" => "Default") + ), + "scope" => Array( + "project" => Array( + "name" => $project, + "domain" => Array( + "name" => "Default") + ) + ), + "authUrl" => $config["urlAuth"] +); + +//Init core Api +$App = new App($Args); - if(isset($token)) - $App->setToken($token); +if(isset($token)) + $App->setToken($token); ?> -- cgit v1.2.3 From 1d42345e07b2ef557de3c5049864e6885632b9e9 Mon Sep 17 00:00:00 2001 From: EoleDev Date: Wed, 27 Apr 2016 14:22:59 +0200 Subject: End of comments --- server/config.inc.php | 4 +- server/core/App.php | 16 +-- server/core/Automating.php | 24 ++-- server/core/Compute.php | 141 +++++++++++++++--------- server/core/CoreInterface.php | 15 ++- server/core/ErrorManagement.php | 20 ++-- server/core/Identity.php | 160 ++++++++++++++------------- server/core/Image.php | 40 +++---- server/core/LibOverride/genTokenOptions.php | 164 ++++++++++++++++++++++++++-- server/core/Network.php | 108 +++++++++--------- server/core/NetworkLayer3.php | 42 +++---- server/index.php | 2 + server/init.php | 19 ++-- 13 files changed, 491 insertions(+), 264 deletions(-) (limited to 'server/core/Automating.php') diff --git a/server/config.inc.php b/server/config.inc.php index 4a4e494..71f0bb4 100755 --- a/server/config.inc.php +++ b/server/config.inc.php @@ -1,6 +1,6 @@ diff --git a/server/core/App.php b/server/core/App.php index 3a027d7..fb49b95 100755 --- a/server/core/App.php +++ b/server/core/App.php @@ -9,7 +9,9 @@ * */ -//Library token management override +/* +* Library token management override +*/ include_once("core/LibOverride/genTokenOptions.php"); include_once("core/ErrorManagement.php"); @@ -28,7 +30,7 @@ use OpenCloud\Common\Error\UserInputError; */ class App{ - /** @var Openstack $openstack protected, contains the main library object */ + /** @var OpenStack\OpenStack $openstack protected, contains the main library object */ protected $openstack; /** @var Array $postParams protected, contains the post parameters */ protected $postParams; @@ -124,7 +126,7 @@ class App{ /** * Generate the token for the different services in OpenStack * - * @return NULL + * @return void */ public function authenticate(){ @@ -150,7 +152,7 @@ class App{ /** * Revoke the openstack services' token * - * @return NULL + * @return void */ public function deauthenticate(){ @@ -197,7 +199,7 @@ class App{ * @param String $param Name for the Post entry * @param Object $value Value for the Post entry * - * @return NULL + * @return void */ public function setPostParam($param, $value){ @@ -211,7 +213,7 @@ class App{ * @param String $key Array key for the message * @param Array $out Message's value * - * @return NULL + * @return void */ public function setOutput($key, $out){ @@ -233,7 +235,7 @@ class App{ /** * Output the messages to be send to the client * - * @return NULl + * @return void */ public function show(){ echo json_encode($this->output); diff --git a/server/core/Automating.php b/server/core/Automating.php index 2d8db00..697b666 100755 --- a/server/core/Automating.php +++ b/server/core/Automating.php @@ -14,21 +14,31 @@ include("Network.php"); include("Compute.php"); include("NetworkLayer3.php"); -class automating{ +/** +* automating Class of the back-end application +* +* Contains the different function to automate some action +* +*/ +class automating implements Core{ - /** @var App $app protected, contains the main app object */ + /** @var App $compute protected, contains a Core compute object */ protected $compute; + /** @var App $image protected, contains a Core image object */ protected $image; + /** @var App $network protected, contains a Core network object */ protected $network; + /** @var App $networkLayer3 protected, contains a Core networkLayer3 object */ protected $networkLayer3; + /** @var App $app protected, contains the main app object */ protected $app; /** - * Our library's app constructor for all server app objects + * automating class constructor * - * @param App $app the main app object, e.g. compute, image, network, etc. + * @param App $app the main app object * - * @return + * @return automating Object */ public function __construct($app){ $this->app = $app; @@ -43,7 +53,7 @@ class automating{ * * @param String $action name of another function of this class * - * @return NULL + * @return void */ public function action($action){ $this->{$action.""}(); @@ -57,7 +67,7 @@ class automating{ * @param String $serverName name ofthe new server * @param String $flavor kind of server * - * @return NULL + * @return void */ private function createPublicServer() { diff --git a/server/core/Compute.php b/server/core/Compute.php index e466b52..7e27d00 100755 --- a/server/core/Compute.php +++ b/server/core/Compute.php @@ -1,37 +1,62 @@ app = $app; $this->libClass = $app->getLibClass("Compute"); } + /** * Execute an action * * @param String $action name of another function of this class * - * @return NULL + * @return void */ public function action($action){ $this->{$action.""}(); } + /** - * List servers. - * @return array - */ + * List servers. + * + * @return void + */ public function listServers() { try{ @@ -79,12 +104,13 @@ class compute catch(Exception $e){ $this->app->getErrorInstance()->OtherException($e); } - return; } + /** - * List flavors. - * @return array - */ + * List flavors. + * + * @return void + */ public function listFlavors() { try{ @@ -117,12 +143,13 @@ class compute catch(Exception $e){ $this->app->getErrorInstance()->OtherException($e); } - return; } + /** - * List images. - * @return array - */ + * List images. + * + * @return void + */ public function listImages() { try{ @@ -159,12 +186,13 @@ class compute catch(Exception $e){ $this->app->getErrorInstance()->OtherException($e); } - return; } + /** - * Get server details. - * @return array - */ + * Get server details. + * + * @return void + */ public function getServer() { try{ @@ -193,12 +221,13 @@ class compute catch(Exception $e){ $this->app->getErrorInstance()->OtherException($e); } - return; } + /** - * Get flavor details. - * @return array - */ + * Get flavor details. + * + * @return void + */ public function getFlavor() { try{ @@ -227,12 +256,12 @@ class compute catch(Exception $e){ $this->app->getErrorInstance()->OtherException($e); } - return; } + /** - * Get image details. - * @return array - */ + * Get image details. + * @return array + */ public function getImage() { try{ @@ -261,12 +290,13 @@ class compute catch(Exception $e){ $this->app->getErrorInstance()->OtherException($e); } - return; } + /** - * Create server. - * @return array - */ + * Create server. + * + * @return void + */ public function createServer() { try{ @@ -295,12 +325,12 @@ class compute catch(Exception $e){ $this->app->getErrorInstance()->OtherException($e); } - return; } /** * update a server - * @return NULL + * + * @return void */ public function updateServer() { @@ -342,11 +372,12 @@ class compute catch(Exception $e){ $this->app->getErrorInstance()->OtherException($e); } - return; } + /** * Delete a server - * @return NULL + * + * @return void */ public function deleteServer() { @@ -376,11 +407,12 @@ class compute catch(Exception $e){ $this->app->getErrorInstance()->OtherException($e); } - return; } + /** * Change the password of a server - * @return NULL + * + * @return void */ public function changePassword() { @@ -411,11 +443,12 @@ class compute catch(Exception $e){ $this->app->getErrorInstance()->OtherException($e); } - return; } + /** * Reboot a server - * @return NULL + * + * @return void */ public function reboot() { @@ -445,11 +478,12 @@ class compute catch(Exception $e){ $this->app->getErrorInstance()->OtherException($e); } - return; } + /** * Rebuild a server - * @return NULL + * + * @return void */ public function rebuild() { @@ -490,13 +524,15 @@ class compute catch(Exception $e){ $this->app->getErrorInstance()->OtherException($e); } - return; } } + /** * Resize a server + * * A call to this method has to be followed by either confirmResize or revertResize - * @return NULL + * + * @return void */ public function resize() { @@ -526,11 +562,12 @@ class compute catch(Exception $e){ $this->app->getErrorInstance()->OtherException($e); } - return; } + /** * Confirm resize operation on a server - * @return NULL + * + * @return void */ public function confirmResize() { @@ -560,11 +597,12 @@ class compute catch(Exception $e){ $this->app->getErrorInstance()->OtherException($e); } - return; } + /** * Revert resize operation on a server - * @return NULL + * + * @return void */ public function revertResize() { @@ -594,14 +632,14 @@ class compute catch(Exception $e){ $this->app->getErrorInstance()->OtherException($e); } - return; } + /** * List private and public addresses of a server - * @return NULL + * + * @return void */ - - public function listAddresses(array $options = []) + public function listAddresses() { try{ $serverId = $this->app->getPostParam("serverId"); @@ -629,7 +667,6 @@ class compute catch(Exception $e){ $this->app->getErrorInstance()->OtherException($e); } - return; } } diff --git a/server/core/CoreInterface.php b/server/core/CoreInterface.php index 6c2313b..8bcfad4 100755 --- a/server/core/CoreInterface.php +++ b/server/core/CoreInterface.php @@ -1,15 +1,26 @@ app->setOutput("Error", "BaseError"); @@ -48,7 +54,7 @@ Class errorManagement{ * * @param Exception $error the exception triggered * - * @return NULL + * @return void */ public function BadResponseHandler($error){ $statusCode = $error->getResponse()->getStatusCode(); @@ -88,7 +94,7 @@ Class errorManagement{ * * @param Exception $error the exception triggered * - * @return NULL + * @return void */ public function NotImplementedHandler($error){ $this->app->setOutput("Error", "Internal error (not implemented yet), please contact an administrator"); @@ -99,7 +105,7 @@ Class errorManagement{ * * @param Exception $error the exception triggered * - * @return NULL + * @return void */ public function UserInputHandler($error){ $this->app->setOutput("Error", "UserInputError"); @@ -110,7 +116,7 @@ Class errorManagement{ * * @param Exception $error the exception triggered * - * @return NULL + * @return void */ public function OtherException($error){ $this->app->setOutput("Error", $error->getMessage()); diff --git a/server/core/Identity.php b/server/core/Identity.php index f6179b0..a30dad2 100755 --- a/server/core/Identity.php +++ b/server/core/Identity.php @@ -2,11 +2,10 @@ /** * File containing the identity Class. * -* @version 1.0 Initialisation of this file -* @since 1.0 Core application's file -* -* @author Eole 'eoledev at outlook . fr' -* +*/ + +/** +* Import the Error of the Library */ use OpenCloud\Common\Error; @@ -15,6 +14,11 @@ use OpenCloud\Common\Error; * * This class implements the management for the identity request * +* @version 1.0 Initialisation of this file +* @since 1.0 Core application's file +* +* @author Eole 'eoledev at outlook . fr' +* */ class identity implements Core{ @@ -29,7 +33,7 @@ class identity implements Core{ * * @param App $app the main app object * - * @return identity + * @return identity Object */ public function __construct($app){ @@ -43,7 +47,7 @@ class identity implements Core{ * * @param String $action name of another function of this class * - * @return NULL + * @return void */ public function action($action){ @@ -61,7 +65,7 @@ class identity implements Core{ * @param String $type Required Type of credential : ec2, cert... * @param String $userId Required Id of the user which own the credential * - * @return NULL + * @return void */ private function addCredential(){ @@ -99,7 +103,7 @@ class identity implements Core{ /** * List the credentials for a given user. * - * @return NULL + * @return void */ private function listCredentials(){ try{ @@ -127,7 +131,7 @@ class identity implements Core{ * * @param String $credentialId Required credential id for which it retrieve the details * - * @return NULL + * @return void */ private function showCredential(){ $credentId = $this->app->getPostParam("credentialId"); @@ -164,7 +168,7 @@ class identity implements Core{ * @param JsonString $blob Required credentials information with this structure for ec2: "{\"access\":\"181920\",\"secret\":\"secretKey\"}" * @param String $type Required Type of credential : ec2, cert... * - * @return NULL + * @return void */ private function updateCredential(){ @@ -206,7 +210,7 @@ class identity implements Core{ * * @param String $credentialId Required credential id to delete * - * @return NULL + * @return void */ private function deleteCredential(){ @@ -244,7 +248,7 @@ class identity implements Core{ * @param String $enabled Optional Domain enabled or not : value true or false * @param String $name Required Domain Name * - * @return NULL + * @return void */ private function addDomain(){ @@ -289,7 +293,7 @@ class identity implements Core{ /** * Retrieve the different domain's list. * - * @return NULL + * @return void */ private function listDomains(){ @@ -318,7 +322,7 @@ class identity implements Core{ * * @param String $domainId Required Domain id for which it retrieve the details * - * @return NULL + * @return void */ private function showDomain(){ @@ -356,7 +360,7 @@ class identity implements Core{ * @param String $enabled Optional Domain enabled or not : value true or false * @param String $name Required Domain Name * - * @return NULL + * @return void */ private function updateDomain(){ @@ -404,7 +408,7 @@ class identity implements Core{ * * @param String $domainId Required Domain id to delete * - * @return NULL + * @return void */ private function deleteDomain(){ @@ -437,7 +441,7 @@ class identity implements Core{ /** * Retrieve the different roles of a given user in a domain. * - * @return NULL + * @return void */ private function listRolesDomainUser(){ @@ -472,7 +476,7 @@ class identity implements Core{ /** * Grant a role to a given user in a domain. * - * @return NULL + * @return void */ private function grantRoleDomainUser(){ $domId = $this->app->getPostParam("domainId"); @@ -510,7 +514,7 @@ class identity implements Core{ /** * Verify that a user has a given role in a domain. * - * @return NULL + * @return void */ private function checkRoleDomainUser(){ $domId = $this->app->getPostParam("domainId"); @@ -549,7 +553,7 @@ class identity implements Core{ /** * Delete a role for a given user in a domain. * - * @return NULL + * @return void */ private function revokeRoleDomainUser(){ $domId = $this->app->getPostParam("domainId"); @@ -587,7 +591,7 @@ class identity implements Core{ /** * Retrieve the roles of a given group in a domain. * - * @return NULL + * @return void */ private function listRolesDomainGroup(){ $domId = $this->app->getPostParam("domainId"); @@ -622,7 +626,7 @@ class identity implements Core{ /** * Add a role to a given group in a domain. * - * @return NULL + * @return void */ private function grantRoleDomainGroup(){ $domId = $this->app->getPostParam("domainId"); @@ -660,7 +664,7 @@ class identity implements Core{ /** * Verify that a role is associated with a given group in a domain. * - * @return NULL + * @return void */ private function checkRoleDomainGroup(){ $domId = $this->app->getPostParam("domainId"); @@ -699,7 +703,7 @@ class identity implements Core{ /** * Delete a role for a given group in a domain. * - * @return NULL + * @return void */ private function revokeRoleDomainGroup(){ $domId = $this->app->getPostParam("domainId"); @@ -738,7 +742,7 @@ class identity implements Core{ /** * Add an endpoint to the Openstack instance * - * @return NULL + * @return void */ private function addEndpoint(){ $servId = $this->app->getPostParam("serviceId"); @@ -778,7 +782,7 @@ class identity implements Core{ /** * Retrieve the endpoint for the given id * - * @return NULL + * @return void */ private function getEndpoint(){ @@ -810,7 +814,7 @@ class identity implements Core{ /** * Retrieve the list of the different endpoints * - * @return NULL + * @return void */ private function listEndpoints(){ @@ -836,7 +840,7 @@ class identity implements Core{ /** * Update a given endpoint * - * @return NULL + * @return void */ private function updateEndpoint(){ //Not Implemented Yet @@ -845,7 +849,7 @@ class identity implements Core{ /** * Delete a given endpoint * - * @return NULL + * @return void */ private function deleteEndpoint(){ $endId = $this->app->getPostParam("endpointId"); @@ -877,7 +881,7 @@ class identity implements Core{ /** * Add a group. * - * @return NULL + * @return void */ private function addGroup(){ //Not Implemented Yet @@ -886,7 +890,7 @@ class identity implements Core{ /** * Retrieve the group's list. * - * @return NULL + * @return void */ private function listGroups(){ //Not Implemented Yet @@ -895,7 +899,7 @@ class identity implements Core{ /** * Retrieve the details of a given group. * - * @return NULL + * @return void */ private function showGroup(){ //Not Implemented Yet @@ -904,7 +908,7 @@ class identity implements Core{ /** * Update a given group. * - * @return NULL + * @return void */ private function updateGroup(){ //Todo Argument Optional @@ -945,7 +949,7 @@ class identity implements Core{ /** * Delete the given group. * - * @return NULL + * @return void */ private function deleteGroup(){ @@ -979,7 +983,7 @@ class identity implements Core{ /** * Retrieve the users of a given group. * - * @return NULL + * @return void */ private function listGroupUsers(){ @@ -1013,7 +1017,7 @@ class identity implements Core{ /** * Add a user to a group. * - * @return NULL + * @return void */ private function addGroupUser(){ @@ -1048,7 +1052,7 @@ class identity implements Core{ /** * Remove a user from a given group. * - * @return NULL + * @return void */ private function removeGroupUser(){ @@ -1083,7 +1087,7 @@ class identity implements Core{ /** * Check if a group contains a given user. * - * @return NULL + * @return void */ private function checkGroupUser(){ @@ -1118,7 +1122,7 @@ class identity implements Core{ /** * @todo * - * @return NULL + * @return void */ private function addPolicies(){ //Not Implemented Yet @@ -1127,7 +1131,7 @@ class identity implements Core{ /** * @todo * - * @return NULL + * @return void */ private function listPolicies(){ //Not Implemented Yet @@ -1136,7 +1140,7 @@ class identity implements Core{ /** * @todo * - * @return NULL + * @return void */ private function showPolicie(){ //Not Implemented Yet @@ -1146,7 +1150,7 @@ class identity implements Core{ /** * @todo * - * @return NULL + * @return void */ private function updatePolicies(){ //Not Implemented Yet @@ -1155,7 +1159,7 @@ class identity implements Core{ /** * @todo * - * @return NULL + * @return void */ private function deletePolicies(){ //Not Implemented Yet @@ -1164,7 +1168,7 @@ class identity implements Core{ /** * Add a project. * - * @return NULL + * @return void */ private function addProject(){ //Todo Parameters Optional @@ -1201,7 +1205,7 @@ class identity implements Core{ /** * Retrieve the different projects. * - * @return NULL + * @return void */ private function listProjects(){ @@ -1227,7 +1231,7 @@ class identity implements Core{ /** * Retrieve the details of a given project. * - * @return NULL + * @return void */ private function showProject(){ @@ -1260,7 +1264,7 @@ class identity implements Core{ /** * Update a given project. * - * @return NULL + * @return void */ private function updateProject(){ //Todo Parameters Optionnal @@ -1300,7 +1304,7 @@ class identity implements Core{ /** * Delete a given project. * - * @return NULL + * @return void */ private function deleteProject(){ $projId = $this->app->getPostParam("projId"); @@ -1333,7 +1337,7 @@ class identity implements Core{ /** * List the roles of a given user in a project. * - * @return NULL + * @return void */ private function listRolesProjectUser(){ @@ -1370,7 +1374,7 @@ class identity implements Core{ /** * Grant a role to an user in a project. * - * @return NULL + * @return void */ private function grantRoleProjectUser(){ @@ -1409,7 +1413,7 @@ class identity implements Core{ /** * Check if a given user has a role in a project. * - * @return NULL + * @return void */ private function checkRoleProjectUser(){ $projId = $this->app->getPostParam("projetId"); @@ -1450,7 +1454,7 @@ class identity implements Core{ /** * Delete a role for a given user in a project. * - * @return NULL + * @return void */ private function revokeRoleProjectUser(){ @@ -1489,7 +1493,7 @@ class identity implements Core{ /** * List the roles of a group in a project. * - * @return NULL + * @return void */ private function listRolesProjectGroup(){ @@ -1525,7 +1529,7 @@ class identity implements Core{ /** * Add a role to a group in a project. * - * @return NULL + * @return void */ private function grantRoleProjectGroup(){ @@ -1564,7 +1568,7 @@ class identity implements Core{ /** * Check if a group has a given role in a project. * - * @return NULL + * @return void */ private function checkRoleProjectGroup(){ @@ -1605,7 +1609,7 @@ class identity implements Core{ /** * Delete a role for a group in a project. * - * @return NULL + * @return void */ private function revokeRoleProjectGroup(){ @@ -1644,7 +1648,7 @@ class identity implements Core{ /** * Add a role. * - * @return NULL + * @return void */ private function addRole(){ @@ -1678,7 +1682,7 @@ class identity implements Core{ /** * List the different roles * - * @return NULL + * @return void */ private function listRoles(){ @@ -1704,7 +1708,7 @@ class identity implements Core{ /** * List the different assignments for a given role * - * @return NULL + * @return void */ private function listRoleAssignements(){ @@ -1730,7 +1734,7 @@ class identity implements Core{ /** * Add a service. * - * @return NULL + * @return void */ private function addService(){ $name = $this->app->getPostParam("name"); @@ -1765,7 +1769,7 @@ class identity implements Core{ /** * Retrieve the different services. * - * @return NULL + * @return void */ private function listServices(){ @@ -1791,7 +1795,7 @@ class identity implements Core{ /** * Retrieve the details for a given service. * - * @return NULL + * @return void */ private function showService(){ $servId = $this->app->getPostParam("serviceId"); @@ -1822,7 +1826,7 @@ class identity implements Core{ /** * Delete a given service. * - * @return NULL + * @return void */ private function deleteService(){ @@ -1856,7 +1860,7 @@ class identity implements Core{ /** * Generate a new token for a given user id. * - * @return NULL + * @return void */ private function genTokenUserID(){ @@ -1894,7 +1898,7 @@ class identity implements Core{ /** * Generate a new token for a given user name. * - * @return NULL + * @return void */ private function genTokenUserName(){ $username = $this->app->getPostParam("username"); @@ -1936,7 +1940,7 @@ class identity implements Core{ /** * Generate a new token from another token ID. * - * @return NULL + * @return void */ private function genTokenID(){ @@ -1972,7 +1976,7 @@ class identity implements Core{ /** * Generate a new token scoped by a project ID. * - * @return NULL + * @return void */ private function genTokenScopedProjectID(){ @@ -2014,7 +2018,7 @@ class identity implements Core{ /** * Generate a new token scoped by a project name. * - * @return NULL + * @return void */ private function genTokenScopedProjectName(){ @@ -2062,7 +2066,7 @@ class identity implements Core{ /** * Check if a token is validate. * - * @return NULL + * @return void */ private function validateToken(){ @@ -2098,7 +2102,7 @@ class identity implements Core{ /** * Delete a given token. * - * @return NULL + * @return void */ private function revokeToken(){ @@ -2130,7 +2134,7 @@ class identity implements Core{ /** * Add a new user. * - * @return NULL + * @return void */ private function addUser(){ //Todo Optionnal Parameter @@ -2175,7 +2179,7 @@ class identity implements Core{ /** * Retrieve the different users. * - * @return NULL + * @return void */ private function listUsers(){ @@ -2201,7 +2205,7 @@ class identity implements Core{ /** * Retrieve the details of a given user. * - * @return NULL + * @return void */ private function showUser(){ @@ -2234,7 +2238,7 @@ class identity implements Core{ /** * Update a given user. * - * @return NULL + * @return void */ private function updateUser(){ @@ -2273,7 +2277,7 @@ class identity implements Core{ /** * Delete a given user. * - * @return NULL + * @return void */ private function deleteUser(){ @@ -2306,7 +2310,7 @@ class identity implements Core{ /** * Retrieve the groups which contains a given user. * - * @return NULL + * @return void */ private function listUserGroups(){ @@ -2340,7 +2344,7 @@ class identity implements Core{ /** * Retrieve the projects which contains a given user. * - * @return NULL + * @return void */ private function listUserProjects(){ diff --git a/server/core/Image.php b/server/core/Image.php index d930962..b256d4c 100755 --- a/server/core/Image.php +++ b/server/core/Image.php @@ -7,8 +7,8 @@ * * @author Evan Pisani 'yogg at epsina . com' * -* @todo Complete the functions with errors detection and finish the descriptions */ + use OpenCloud\Common\Error\BadResponseError; use OpenCloud\Common\Error\BaseError; use OpenCloud\Common\Error\NotImplementedError; @@ -27,7 +27,7 @@ class image implements Core{ /** @var App $app protected, contains the main app object */ protected $app; - /** @var OpenStack\Identity $libClass protected, contains the library Identity object */ + /** @var OpenStack\Image $libClass protected, contains the library Image object */ protected $libClass; /** @@ -35,7 +35,7 @@ class image implements Core{ * * @param App $app the main app object * - * @return Image + * @return image Object */ public function __construct($app){ if(!isset($app)){ @@ -51,7 +51,7 @@ class image implements Core{ * * @param String $action name of another function of this class * - * @return NULL + * @return void */ public function action($action){ $this->{$action.""}(); @@ -62,7 +62,7 @@ class image implements Core{ * * @param array $opt Options for the image creation (name is required, others are optionals) * - * @return Image + * @return void */ private function createImage(){ $opt = $this->app->getPostParam("opt"); @@ -141,7 +141,7 @@ class image implements Core{ /** * List the images of the server * - * @return List of Image + * @return void */ private function listImage(){ try{ @@ -171,7 +171,7 @@ class image implements Core{ * * @param String $id Identifier of the image * - * @return Image + * @return void */ private function detailsImage(){ $id = $this->app->getPostParam("id"); @@ -209,7 +209,7 @@ class image implements Core{ * @param String $id id of the image * @param array $opt Options for the image creation * - * @return Image + * @return void */ private function updateImage(){ @@ -272,7 +272,7 @@ class image implements Core{ * * @param String $id Identifier of the image * - * @return NULL + * @return void */ private function deleteImage(){ $id = $this->app->getPostParam("id"); @@ -302,11 +302,11 @@ class image implements Core{ } /** - * Resactive an image + * Reactive an image * * @param String $id Identifier of the image * - * @return NULL + * @return void */ private function reactivateImage(){ $id = $this->app->getPostParam("id"); @@ -339,11 +339,11 @@ class image implements Core{ } /** - * Desactive an image + * Desactivaate an image * * @param String $id Identifier of the image * - * @return NULL + * @return void */ private function desactivateImage(){ $id = $this->app->getPostParam("id"); @@ -380,7 +380,7 @@ class image implements Core{ * @param String $id Identifier of the image * @param String $file_name Path of the image * - * @return NULL + * @return void */ private function uploadImage(){ $id = $this->app->getPostParam("id"); @@ -422,7 +422,7 @@ class image implements Core{ * * @param String $id Identifier of the image * - * @return Stream + * @return void */ private function downloadImage(){ $id = $this->app->getPostParam("id"); @@ -459,7 +459,7 @@ class image implements Core{ * @param String $image_id Identifier of the image * @param String $member_id Identifier of the member * - * @return Member + * @return void */ private function addMemberImage(){ $image_id = $this->app->getPostParam("image_id"); @@ -501,7 +501,7 @@ class image implements Core{ * * @param String $image_id identifier of the image * - * @return List of Member + * @return void */ private function listMemberImage(){ $image_id = $this->app->getPostParam("image_id"); @@ -545,7 +545,7 @@ class image implements Core{ * @param String $image_id Identifier of the image * @param String $member_id Identifier of the member * - * @return Member + * @return void */ private function detailMemberImage(){ $image_id = $this->app->getPostParam("image_id"); @@ -591,7 +591,7 @@ class image implements Core{ * @param String $image_id Identifier of the image * @param String $member_id Identifier of the member * - * @return NULL + * @return void */ private function removeMemberImage(){ $image_id = $this->app->getPostParam("image_id"); @@ -637,7 +637,7 @@ class image implements Core{ * @param String $member_id Identifier of the member * @param String $status New status for the member * - * @return NULL + * @return void **/ private function updateMemberImage(){ $image_id = $this->app->getPostParam("image_id"); diff --git a/server/core/LibOverride/genTokenOptions.php b/server/core/LibOverride/genTokenOptions.php index 68a7dbd..f0b3b88 100755 --- a/server/core/LibOverride/genTokenOptions.php +++ b/server/core/LibOverride/genTokenOptions.php @@ -1,4 +1,14 @@ stack = HandlerStack::create(); + $stack = HandlerStack::create(); $httpClient = new Client([ 'base_uri' => Utils::normalizeUrl($options['authUrl']), - 'handler' => $this->stack, + 'handler' => $stack, ]); $this->httpClient = $httpClient; @@ -38,8 +65,13 @@ class genTokenOptions } /** - * @codeCoverageIgnore - */ + * Add a debug for the library + * + * @param array $options Debug options, cf library + * @param HandlerStack $stack pointer to a HandlerStack object + * + * @return void + */ private function addDebugMiddleware(array $options, HandlerStack &$stack) { if (!empty($options['debugLog']) @@ -50,12 +82,20 @@ class genTokenOptions } } + /** + * Check the expiration time of a token + * + * @return boolean if the token is not expired + */ public function checkToken(){ - //error_log(print_r($this->backup['time'], true), 0); return $this->backup['time'] > time(); - //return true; } + /** + * Generate a new token for the Identity service + * + * @return void + */ public function genIdentityToken(){ $options = $this->optionsGlobal['Common']; $options['catalogName'] = 'false'; @@ -81,12 +121,24 @@ class genTokenOptions $this->optionsGlobal['Identity'] = $options; } + /** + * Revoke the token for the Identity Service + * + * @return void + */ public function revokeIdentityToken(){ $token = $this->unserializeToken($this->backup['Identity']['token']); $this->optionsGlobal['Common']['identityService']->revokeToken($token->id); } + /** + * Load a token for the Identity Service + * + * @param String $opt serialized token + * + * @return void + */ public function loadIdentityBackup($opt){ $options = $this->optionsGlobal['Common']; $options['catalogName'] = 'false'; @@ -112,6 +164,11 @@ class genTokenOptions } + /** + * Generate a new token for the Image service + * + * @return void + */ public function genImageToken(){ $options = $this->optionsGlobal['Common']; $options['catalogName'] = 'glance'; @@ -135,12 +192,24 @@ class genTokenOptions $this->optionsGlobal['Image'] = $options; } + /** + * Revoke the token for the Image Service + * + * @return void + */ public function revokeImageToken(){ $token = $this->unserializeToken($this->backup['Image']['token']); $this->optionsGlobal['Common']['identityService']->revokeToken($token->id); } + /** + * Load a token for the Image Service + * + * @param String $opt serialized token + * + * @return void + */ public function loadImageBackup($opt){ $options = $this->optionsGlobal['Common']; $options['catalogName'] = 'glance'; @@ -165,6 +234,11 @@ class genTokenOptions $this->optionsGlobal['Image'] = $options; } + /** + * Generate a new token for the Metwork service + * + * @return void + */ public function genNetworkToken(){ $options = $this->optionsGlobal['Common']; $options['catalogName'] = 'neutron'; @@ -188,12 +262,24 @@ class genTokenOptions $this->optionsGlobal['Network'] = $options; } + /** + * Revoke the token for the Network Service + * + * @return void + */ public function revokeNetworkToken(){ $token = $this->unserializeToken($this->backup['Network']['token']); $this->optionsGlobal['Common']['identityService']->revokeToken($token->id); } + /** + * Load a token for the Network Service + * + * @param String $opt serialized token + * + * @return void + */ public function loadNetworkBackup($opt){ $options = $this->optionsGlobal['Common']; $options['catalogName'] = 'neutron'; @@ -218,6 +304,11 @@ class genTokenOptions $this->optionsGlobal['Network'] = $options; } + /** + * Generate a new token for the Compute service + * + * @return void + */ public function genComputeToken(){ $options = $this->optionsGlobal['Common']; $options['catalogName'] = 'nova'; @@ -241,12 +332,24 @@ class genTokenOptions $this->optionsGlobal['Compute'] = $options; } + /** + * Revoke the token for the Compute Service + * + * @return void + */ public function revokeComputeToken(){ $token = $this->unserializeToken($this->backup['Compute']['token']); $this->optionsGlobal['Common']['identityService']->revokeToken($token->id); } + /** + * Load a token for the Compute Service + * + * @param String $opt serialized token + * + * @return void + */ public function loadComputeBackup($opt){ $options = $this->optionsGlobal['Common']; @@ -272,10 +375,16 @@ class genTokenOptions $this->optionsGlobal['Compute'] = $options; } + /** + * Save the token given a service name + * + * @param String $name name of the service to save + * @param Array $data token and baseUrl for the service + * + * @return void + */ private function saveBackup($name, $data){ $token = $this->serializeToken($data["token"]); - //$path = "core/LibOverride/projectTokenData/".$token['saved']["project"]["name"]; - //error_log("Path a ecrire ".print_r($path, true), 0); file_put_contents("core/LibOverride/projectTokenData/".$token['saved']["project"]["name"], serialize($token['saved'])); $this->backup['time'] = $token['time']; $this->backup["roles"] = $token["roles"]; @@ -284,10 +393,22 @@ class genTokenOptions $this->backup[$name] = array('token' => $token["token"], 'baseUrl' => $data["baseUrl"] ); } + /** + * Retrieve the tokens saved + * + * @return String tokens serialized + */ public function getBackup(){ return serialize($this->backup); } + /** + * Load tokens into the library + * + * @param String $back tokens serialized + * + * @return void + */ public function loadBackup($back){ $backup = unserialize($back); @@ -302,10 +423,24 @@ class genTokenOptions } + /** + * Retrieve the common options for a service + * + * @param String $service name of the service + * + * @return array Options to create the library class corresponding to this service + */ public function getOptions($service){ return $this->optionsGlobal[$service]; } + /** + * Serialize a given token + * + * @param Array $token token to be serialized + * + * @return String token serialized + */ private function serializeToken($token){ global $config; $tokenSerialized = []; @@ -358,6 +493,15 @@ class genTokenOptions return $tokenSerialized; } + /** + * Unserialize a token + * + * Unserialize a token and recreate the architecture of the library token + * + * @param String $tokenSerialized the token to be unserialized + * + * @return OpenCloud\Common\Auth\Token the token unserialized + */ private function unserializeToken($tokenSerialized){ $Saved = file_get_contents("core/LibOverride/projectTokenData/".$this->backup["project"]); $Saved = unserialize($Saved); diff --git a/server/core/Network.php b/server/core/Network.php index 54b5d60..ee66eaa 100755 --- a/server/core/Network.php +++ b/server/core/Network.php @@ -7,7 +7,6 @@ * * @author KABIR Othmane * -* @todo Complete the functions with errors detection and finish the descriptions */ use OpenCloud\Common\Error\BadResponseError; use OpenCloud\Common\Error\BaseError; @@ -17,11 +16,10 @@ use OpenCloud\Common\Error\UserInputError; /** * Network Class of the back-end application * -* ADD CLASS DESCRIPTION +* Management of Networks * */ - -class network{ +class network implements Core{ /** @var App $app protected, contains the main app object */ protected $app; /** @var OpenStack\Network $libClass protected, contains the library Network object */ @@ -29,15 +27,12 @@ class network{ /** - * Image constructor + * Network constructor * * @param App $app the main app object * - * @return Network + * @return network Object */ - - - public function __construct($app){ $this->app = $app; $this->libClass = $app->getLibClass("Network"); @@ -49,7 +44,7 @@ class network{ * * @param String $action name of another function of this class * - * @return NULL + * @return void */ public function action($action){ @@ -65,7 +60,7 @@ class network{ * @param String shared Specifies whether the network resource can be accessed by any tenant * @param String tenantId Owner of network. Only admin users can specify a tenant ID other than their own * - * @return NULL + * @return void */ private function create_network() { @@ -134,9 +129,7 @@ class network{ * @param BOOLEAN enableDhcp Specifies whether DHCP is enabled for this subnet * @param String allocationPools Subranges of the CIDR available for dynamic allocation to ports * - * - * - * @return NULL + * @return void */ private function create_subnet() @@ -225,7 +218,7 @@ class network{ /** * List the ID of the NETWORKS * - * @return List of Networks ID + * @return void */ private function list_network_ids() @@ -276,18 +269,12 @@ class network{ try { $ln = $this->libClass->listNetworks(); - $list_names = array(); - foreach($ln as $n) { - $list_names[] = $n->name; - - } - } catch(BadResponseError $e) { @@ -308,10 +295,11 @@ class network{ $this->app->setOutput("ListNetworkNames", $list_names); } + /** * List the CIDR of the SUBNETS * - * @return List of SUBNETS CIDR + * @return void */ private function list_cidr() { @@ -344,10 +332,13 @@ class network{ $this->app->getErrorInstance->NotImplementedHandler($e); } } + /** * retrieve a specific network + * * @param networkId ID of network which we want to get - * @return Network + * + * @return void */ private function getNetwork() { @@ -383,8 +374,10 @@ class network{ /** * internal function + * * @param String netId ID of network which we want to get - * @return Network + * + * @return OpenStack\Network */ private function getNetworkP($netId) { @@ -420,8 +413,10 @@ class network{ /** * retrieve a specific subnet + * * @param subnetId ID of subnet which we want to get - * @return subnet + * + * @return void */ private function getSubnet() { @@ -455,8 +450,10 @@ class network{ } /** * internal function + * * @param String subnetId ID of subnet which we want to get - * @return subnet + * + * @return OpenStack\Subnet */ private function getSubnetP($subnetId) { @@ -498,7 +495,7 @@ class network{ * @param String tenantId Owner of network. Only admin users can specify a tenant ID other than their own * * - * @return NULL + * @return void **/ private function updateNetwork() @@ -561,7 +558,7 @@ class network{ * @param String allocationPools Subranges of the CIDR available for dynamic allocation to ports * * - * @return NULL + * @return void **/ private function updateSubnet() @@ -616,8 +613,7 @@ class network{ * * @param String networkId ID if network which we want to delete * - * - * @return NULL + * @return void **/ private function deleteNetwork() { @@ -650,8 +646,7 @@ class network{ * * @param String subnetId ID if network which we want to delete * - * - * @return NULL + * @return void **/ private function deleteSubnet() { @@ -692,7 +687,7 @@ class network{ * @param String securityGroups Specifies the IDs of any security groups associated with this port * @param String tenantId Owner of the port. Only admin users can specify a tenant ID other than their own. * - * @return NULL + * @return void */ private function createPort() @@ -769,7 +764,7 @@ class network{ /** * List the of ports * - * @return List of ports + * @return void */ private function listPorts() @@ -798,8 +793,10 @@ class network{ /** * retrieve a specific port given + * * @param portId ID of port which we want to get - * @return port + * + * @return void */ private function getPort() @@ -831,8 +828,11 @@ class network{ /** * internal function + * * retrieve a specific port given + * * @param portId ID of port which we want to get + * * @return port */ @@ -876,7 +876,7 @@ class network{ * @param String securityGroups Specifies the IDs of any security groups associated with this port * @param String tenantId Owner of the port. Only admin users can specify a tenant ID other than their own. * - * @return NULL + * @return void */ private function updatePort() { @@ -953,7 +953,8 @@ class network{ * Delete a port given * * @param String portId id of port which we wante to delete - * @return NULL + * + * @return void */ private function deletePort() { @@ -988,7 +989,7 @@ class network{ * @param String name A human-readable name for the security group. This name might not be unique * @param String description Description of the security group * - * @return NULL + * @return void */ private function createSecurityGroup() @@ -1032,15 +1033,15 @@ class network{ * Create a new security groupe * * @param String securityGroupId The security group ID to associate with this security group rule. - * @param String direction The direction in which the security group rule is applied. For a compute instance, an ingress security group * rule is applied to incoming (ingress) traffic for that instance. An egress rule is applied to traffic leaving the instance. + * @param String direction The direction in which the security group rule is applied. For a compute instance, an ingress security group rule is applied to incoming (ingress) traffic for that instance. An egress rule is applied to traffic leaving the instance. * @param String ethertype Must be IPv4 or IPv6, and addresses represented in CIDR must match the ingress or egress rules. - * @param String portRangeMin The minimum port number in the range that is matched by the security group rule. If the protocol is TCP or UDP, this value must be less than or equal to the value of the portRangeMax attribute. If the protocol is ICMP, this value must be an ICMP type - *@param String portRangeMax The maximum port number in the range that is matched by the security group rule. If the protocol is TCP or UDP, this value must be less than or equal to the value of the portRangeMax attribute. If the protocol is ICMP, this value must be an ICMP type. - *@param String protocol The protocol that is matched by the security group rule - *@param String remoteGroupId The remote group ID to be associated with this security group rule. You can specify either remoteGroupId or remoteGroupPrefix - *@param String remoteIpPrefix The remote IP prefix to be associated with this security group rule. You can specify either remoteGroupId or remoteGroupPrefix + * @param String portRangeMin The minimum port number in the range that is matched by the security group rule. If the protocol is TCP or UDP, this value must be less than or equal to the value of the portRangeMax attribute. If the protocol is ICMP, this value must be an ICMP type + * @param String portRangeMax The maximum port number in the range that is matched by the security group rule. If the protocol is TCP or UDP, this value must be less than or equal to the value of the portRangeMax attribute. If the protocol is ICMP, this value must be an ICMP type. + * @param String protocol The protocol that is matched by the security group rule + * @param String remoteGroupId The remote group ID to be associated with this security group rule. You can specify either remoteGroupId or remoteGroupPrefix + * @param String remoteIpPrefix The remote IP prefix to be associated with this security group rule. You can specify either remoteGroupId or remoteGroupPrefix * - * @return NULL + * @return void */ private function createSecurityGroupRule() { @@ -1112,7 +1113,7 @@ class network{ /** * List of Security Groupes * - * @return List of Security Groupes + * @return void */ private function listSecurityGroupe() @@ -1143,7 +1144,7 @@ class network{ /** * List of Security Groupe Rules * - * @return List of Security Groupe Rules + * @return void */ private function listSecurityGroupeRule() @@ -1174,8 +1175,10 @@ class network{ /** * retrieve a specific Security Groupe given + * * @param securityGroupeId ID of security Groupe which we want to get - * @return securityGroupe + * + * @return void */ private function getSecurityGroupe() @@ -1207,9 +1210,12 @@ class network{ /** * internal function + * * retrieve a specific Security Groupe given + * * @param securityGroupeId ID of security Groupe which we want to get - * @return securityGroupe + * + * @return securityGroup */ private function getSecurityGroupeP($securityGroupeId) { @@ -1238,8 +1244,10 @@ class network{ } /** * Delete a specific Security Groupe given + * * @param securityGroupeId ID of security Groupe which we want to get - * @return NULL + * + * @return void */ private function deleteSecurityGroupe() { diff --git a/server/core/NetworkLayer3.php b/server/core/NetworkLayer3.php index c0b773a..35bf707 100755 --- a/server/core/NetworkLayer3.php +++ b/server/core/NetworkLayer3.php @@ -1,41 +1,41 @@ {$action.""}(); @@ -61,7 +61,7 @@ class networkLayer3 { /** * List floatingip * - * @return list of the floatingip + * @return void */ private function listFloatingIp(){ try{ @@ -91,7 +91,7 @@ class networkLayer3 { * * @param array $opt Options for the floating ip creation (floatingNetworkId is required) * - * @return floatingip + * @return void */ private function createFloatingIp(){ $opt = $this->app->getPostParam("opt"); @@ -126,7 +126,7 @@ class networkLayer3 { * * @param String id the id of the floatingip * - * @return floatingip details + * @return void */ private function getFloatingIp(){ $id = $this->app->getPostParam("id"); @@ -175,7 +175,7 @@ class networkLayer3 { * * @param id the id of the floatingip to update * - * @return NULL + * @return void */ private function updateFloatingIp(){ $id = $this->app->getPostParam("id"); @@ -224,7 +224,7 @@ class networkLayer3 { * * @param string floatingip_id the floating-ip id to delete * - * @return NULL + * @return void */ private function deleteFloatingIp(){ $id = $this->app->getPostParam("id"); @@ -273,7 +273,7 @@ class networkLayer3 { * * @param string floatingip_id the floating-ip id to retrieve * - * @return NULL + * @return void */ private function retrieveFloatingIp(){ $id = $this->app->getPostParam("id"); @@ -326,7 +326,7 @@ class networkLayer3 { * adminStateUp (optionnal) * name (optionnal) * - * @return router + * @return void */ private function createRouter(){ $opt = $this->app->getPostParam("opt"); @@ -359,7 +359,7 @@ class networkLayer3 { /** * List routers * - * @return list of the routers + * @return void */ private function listRouters(){ try{ @@ -389,7 +389,7 @@ class networkLayer3 { * * @param String id the id of the router * - * @return router details + * @return void */ private function getRouter(){ $id = $this->app->getPostParam("id"); @@ -437,7 +437,7 @@ class networkLayer3 { * * @param string router the router to delete * - * @return NULL + * @return void */ private function deleteRouter(){ $id = $this->app->getPostParam("id"); @@ -485,7 +485,7 @@ class networkLayer3 { * * @param id the id of the floatingip to update * - * @return NULL + * @return void */ private function updateRouter(){ $id = $this->app->getPostParam("id"); diff --git a/server/index.php b/server/index.php index 01203de..25c7c2e 100755 --- a/server/index.php +++ b/server/index.php @@ -9,6 +9,8 @@ * */ +/* +*/ //loading dependencies require "vendor/autoload.php"; //Include general config file diff --git a/server/init.php b/server/init.php index 767224a..e6a90fb 100755 --- a/server/init.php +++ b/server/init.php @@ -1,14 +1,17 @@ Date: Wed, 27 Apr 2016 15:51:38 +0200 Subject: Error correction --- server/core/Automating.php | 1 + server/core/Compute.php | 1 + server/core/Identity.php | 1 + server/core/LibOverride/genTokenOptions.php | 6 +++++- server/core/Network.php | 2 ++ 5 files changed, 10 insertions(+), 1 deletion(-) (limited to 'server/core/Automating.php') diff --git a/server/core/Automating.php b/server/core/Automating.php index 697b666..27dd018 100755 --- a/server/core/Automating.php +++ b/server/core/Automating.php @@ -13,6 +13,7 @@ include("Image.php"); include("Network.php"); include("Compute.php"); include("NetworkLayer3.php"); +include("CoreInterface.php"); /** * automating Class of the back-end application diff --git a/server/core/Compute.php b/server/core/Compute.php index 7e27d00..1db21bf 100755 --- a/server/core/Compute.php +++ b/server/core/Compute.php @@ -11,6 +11,7 @@ use OpenCloud\Common\Error; +include("CoreInterface.php"); /** * Compute Class of the back-end application * diff --git a/server/core/Identity.php b/server/core/Identity.php index a30dad2..112c9e3 100755 --- a/server/core/Identity.php +++ b/server/core/Identity.php @@ -9,6 +9,7 @@ */ use OpenCloud\Common\Error; +include("CoreInterface.php"); /** * Identity Class of the back-end application * diff --git a/server/core/LibOverride/genTokenOptions.php b/server/core/LibOverride/genTokenOptions.php index f0b3b88..7134887 100755 --- a/server/core/LibOverride/genTokenOptions.php +++ b/server/core/LibOverride/genTokenOptions.php @@ -385,7 +385,9 @@ class genTokenOptions */ private function saveBackup($name, $data){ $token = $this->serializeToken($data["token"]); - file_put_contents("core/LibOverride/projectTokenData/".$token['saved']["project"]["name"], serialize($token['saved'])); + $ret = file_put_contents("core/LibOverride/projectTokenData/".$token['saved']["project"]["name"], serialize($token['saved'])); + if($ret === FALSE) + die("Internal Server Error : File Rights"); $this->backup['time'] = $token['time']; $this->backup["roles"] = $token["roles"]; $this->backup["project"] = $token['saved']["project"]["name"]; @@ -504,6 +506,8 @@ class genTokenOptions */ private function unserializeToken($tokenSerialized){ $Saved = file_get_contents("core/LibOverride/projectTokenData/".$this->backup["project"]); + if($Saved === FALSE) + die("Internal Server Error : File Access"); $Saved = unserialize($Saved); $api = new Api(); diff --git a/server/core/Network.php b/server/core/Network.php index ee66eaa..b244e4e 100755 --- a/server/core/Network.php +++ b/server/core/Network.php @@ -13,6 +13,8 @@ use OpenCloud\Common\Error\BaseError; use OpenCloud\Common\Error\NotImplementedError; use OpenCloud\Common\Error\UserInputError; +include("CoreInterface.php"); + /** * Network Class of the back-end application * -- cgit v1.2.3