From 5665d317db7763650e7827c20f6fe131bcce9ad3 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 23 Feb 2016 21:00:31 +0100 Subject: [PATCH 01/71] liste des cird --- server/Test/DisplayListCidr.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 server/Test/DisplayListCidr.php diff --git a/server/Test/DisplayListCidr.php b/server/Test/DisplayListCidr.php new file mode 100644 index 0000000..119b218 --- /dev/null +++ b/server/Test/DisplayListCidr.php @@ -0,0 +1,26 @@ +"admin", "password"=>"ae5or6cn", "domain"=>["id"=>"Default"]); + $options["scope"] = Array("project"=>Array("name"=>"admin", "domain"=>["id"=>"Default"])); + $options["authUrl"] = "http://148.60.11.31:5000/v3"; + $openstack = new OpenStack\OpenStack($options); + $networking = $openstack->networkingV2(["region"=>"RegionOne"]); + $ls = $networking->listSubnets(); + + foreach ($ls as $subnet) { + echo $subnet->cidr."
"; +} + + + + + + + + + From 154d49d1089d34ada6744556cca8028d1ec11430 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 23 Feb 2016 21:36:07 +0100 Subject: [PATCH 02/71] la premiere version de la classe netork --- server/core/Network.php | 104 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 103 insertions(+), 1 deletion(-) diff --git a/server/core/Network.php b/server/core/Network.php index 8d1c8b6..38e20be 100644 --- a/server/core/Network.php +++ b/server/core/Network.php @@ -1 +1,103 @@ - +] + * + * @return Image + */ + public function __construct($app, $openstack){ + $this->app = $app; + $this->libClass = $app->getLibClass("networkingV2"); + $this->networking = $openstack->networkingV2(["region"=>"RegionOne"]); + } + + + + + + public function create_network(array $options) + { + + $network = $networking->createNetworks($options); + + + return $network; + } + + public function create_subnet(array $options) + { + + $subnet = $networking->createSubnet($options); + + + return $subnet; + } + + public function list_network_ids() + { + + $ln = $networking->listNetworks(); + + $list_ids = array(); + + + foreach($ln as $n) + { + + $list_ids[] = $n->id; + + + } + + return $list_ids; + } + + public function list_network_names() + { + + $ln = $networking->listNetworks(); + + $list_names = array(); + + + foreach($ln as $n) + { + + $list_names[] = $n->name; + + + } + + return $list_names; + } + + public function list_cidr() + { + + $ls = $networking->listSubnets(); + $list_cidr = array(); + foreach ($ls as $subnet) + { + + $list_cidr[] = $subnet->cidr; + } + + return $list_names; + } + + From 38ba61c6eebadb79a23044b06671fd7c73975516 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 24 Feb 2016 19:42:01 +0100 Subject: [PATCH 03/71] modification dans network --- server/core/Network.php | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/server/core/Network.php b/server/core/Network.php index 38e20be..2e09508 100644 --- a/server/core/Network.php +++ b/server/core/Network.php @@ -6,34 +6,29 @@ class network{ protected $libClass; - protected $networking; - - protected $actions = array(); + - /** - * Image constructor - * - * @param App $app the main app object - * - * @throws [Type] [] - * - * @return Image - */ - public function __construct($app, $openstack){ + + + public function __construct($app){ $this->app = $app; - $this->libClass = $app->getLibClass("networkingV2"); - $this->networking = $openstack->networkingV2(["region"=>"RegionOne"]); + $this->libClass = $app->getLibClass("network"); + } - + public function action($action){ + + $this->{$action.""}(); + + } public function create_network(array $options) { - $network = $networking->createNetworks($options); + $network = $this->libClass->createNetworks($options); return $network; @@ -42,7 +37,7 @@ class network{ public function create_subnet(array $options) { - $subnet = $networking->createSubnet($options); + $subnet = $this->libClass->createSubnet($options); return $subnet; @@ -51,7 +46,7 @@ class network{ public function list_network_ids() { - $ln = $networking->listNetworks(); + $ln = $this->libClass->listNetworks(); $list_ids = array(); @@ -70,7 +65,7 @@ class network{ public function list_network_names() { - $ln = $networking->listNetworks(); + $ln = $this->libClass->listNetworks(); $list_names = array(); @@ -89,7 +84,7 @@ class network{ public function list_cidr() { - $ls = $networking->listSubnets(); + $ls = $this->libClass->listSubnets(); $list_cidr = array(); foreach ($ls as $subnet) { From 70fcf3553abb4a25672ee198dafb89e430e2bd79 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 2 Mar 2016 01:34:10 +0100 Subject: [PATCH 04/71] ajout des fonctions --- server/Test/getIdNetwork.php | 34 +++++++++++++ server/Test/getNetwork.php | 26 ++++++++++ server/core/Network.php | 98 +++++++++++++++++++++++++++++++++++- 3 files changed, 157 insertions(+), 1 deletion(-) create mode 100644 server/Test/getIdNetwork.php create mode 100644 server/Test/getNetwork.php diff --git a/server/Test/getIdNetwork.php b/server/Test/getIdNetwork.php new file mode 100644 index 0000000..1e38627 --- /dev/null +++ b/server/Test/getIdNetwork.php @@ -0,0 +1,34 @@ +"admin", "password"=>"ae5or6cn", "domain"=>["id"=>"Default"]); + $options["scope"] = Array("project"=>Array("name"=>"admin", "domain"=>["id"=>"Default"])); + $options["authUrl"] = "http://148.60.11.31:5000/v3"; + $openstack = new OpenStack\OpenStack($options); + $networking = $openstack->networkingV2(["region"=>"RegionOne"]); + + $ls = $networking->getNetwork('5f78d3c1-1f53-4be7-897b-cf3c797961e0'); +try{ +$ls->retrieve(); + + + +echo "oui";} + + catch (OpenStack\Common\Error\BadResponseError $e){ +echo "non"; } + + + + + + + + + + + diff --git a/server/Test/getNetwork.php b/server/Test/getNetwork.php new file mode 100644 index 0000000..4c76480 --- /dev/null +++ b/server/Test/getNetwork.php @@ -0,0 +1,26 @@ +"admin", "password"=>"ae5or6cn", "domain"=>["id"=>"Default"]); + $options["scope"] = Array("project"=>Array("name"=>"admin", "domain"=>["id"=>"Default"])); + $options["authUrl"] = "http://148.60.11.31:5000/v3"; + $openstack = new OpenStack\OpenStack($options); + $networking = $openstack->networkingV2(["region"=>"RegionOne"]); + $ls = $networking->listNetworks(); + + foreach ($ls as $subnet) { + echo $subnet->id."
"; +} + + + + + + + + + diff --git a/server/core/Network.php b/server/core/Network.php index 2e09508..6363fdb 100644 --- a/server/core/Network.php +++ b/server/core/Network.php @@ -94,5 +94,101 @@ class network{ return $list_names; } + //option array() + public function getNetwork($idNet) + { + $network=""; + + try + { $newtork = $networking->getNetwork($idNet); + $network->retrieve(); + + + } + + catch (OpenStack\Common\Error\BadResponseError $e) + { + $network = "Id non existant "; + } + catch (Exception $e) + { + $network = 'Exception reçue : ', $e->getMessage(), "\n"; + } + + return $network; + } + + public function getSubnet($idSub) + { + $sbnet=""; + + try + { $subnet = $networking->getSubnet($idSub); + $subnet->retrieve(); + + + } + + catch (OpenStack\Common\Error\BadResponseError $e) + { + $sbnet = "Id non existant "; + } + catch (Exception $e) + { + $sbnet = 'Exception reçue : ', $e->getMessage(), "\n"; + } + + return $sbnet; + } + + public function updateNetwork($idNet,$name,$shared,$adminStateUp) + { + $network = getNetwork($idNet); + if(!is_null($name)) + { + $network->name = $name; + } + if(!is_null($shared)) + { + $network->shared = $shared; + } + if(!is_null($adminStateUp)) + { + $network->adminStateUp = $shared; + } + $network->update(); + } - + public function updateSubnet($idSub,$name,$networkId,$ipVersion,$cidr) + { + $subnet = getNetwork($idSub); + if(!is_null($name)) + { + $subnet->name = $name; + } + if(!is_null($networkId)) + { + $subnet->networkId = $networkId; + } + if(!is_null($ipVersion)) + { + $subnet->ipVersion = $ipVersion; + } + if(!is_null($cidr)) + { + $subnet->cidr = $cidr; + } + $subnet->update(); + } + + public function deleteNetwork($idNet) + { + $network = getNetwork($idNet); + $network->delete(); + } + + public function deleteSubnet($idSub) + { + $subnet = getNetwork($idSub); + $subnet->delete(); + } From a51bcad21a526b5077f52bb8e12417e4b921f06b Mon Sep 17 00:00:00 2001 From: root Date: Tue, 8 Mar 2016 00:26:20 +0100 Subject: [PATCH 05/71] terminaison des fonctions --- server/core/Network.php | 276 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 265 insertions(+), 11 deletions(-) diff --git a/server/core/Network.php b/server/core/Network.php index 6363fdb..75ba2fd 100644 --- a/server/core/Network.php +++ b/server/core/Network.php @@ -25,18 +25,77 @@ class network{ } - public function create_network(array $options) + public function create_network($name,$adminStateUp,$shared,$tenantId) { - + $options = array(); + if (!is_null($name)) + { + $options['name'] = $name; + } + if (!is_null($adminStateUp)) + { + $options['adminStateUp'] = $adminStateUp; + } + if (!is_null($shared)) + { + $options['shared'] = $shared; + } + if (!is_null($tenantId)) + { + $options['tenantId'] = $tenantId; + } $network = $this->libClass->createNetworks($options); return $network; } - public function create_subnet(array $options) - { - + public function create_subnet($networkId,$ipVersion,$cidr,$name,$gatewayIp,$dnsNameservers,$allocationPools,$hostRoutes,$enableDhcp,$tenantId) + { $options = array(); + if (!is_null($networkId)) + { + $options['networkId'] = $networkId; + } + if (!is_null($ipVersion)) + { + $options['ipVersion'] = $ipVersion; + } + if (!is_null($cidr)) + { + $options['cidr'] = $cidr; + } + if (!is_null($tenantId)) + { + $options['tenantId'] = $tenantId; + } + if (!is_null($name)) + { + $options['name'] = $name; + } + if (!is_null($gatewayIp)) + { + $options['gatewayIp'] = $gatewayIp; + } + if (!is_null($dnsNameservers)) + { + $options['dnsNameservers'] = $dnsNameservers; + } + if (!is_null($allocationPools)) + { + $options['allocationPools'] = $allocationPools; + } + if (!is_null($hostRoutes)) + { + $options['hostRoutes'] = $hostRoutes; + } + if (!is_null($enableDhcp)) + { + $options['enableDhcp'] = $enableDhcp; + } + if (!is_null($tenantId)) + { + $options['tenantId'] = $tenantId; + } $subnet = $this->libClass->createSubnet($options); @@ -100,7 +159,7 @@ class network{ $network=""; try - { $newtork = $networking->getNetwork($idNet); + { $newtork = $this->libClass->getNetwork($idNet); $network->retrieve(); @@ -123,22 +182,22 @@ class network{ $sbnet=""; try - { $subnet = $networking->getSubnet($idSub); + { $subnet = $this->libClass->getSubnet($idSub); $subnet->retrieve(); - + return $sbnet; } catch (OpenStack\Common\Error\BadResponseError $e) { - $sbnet = "Id non existant "; + echo "Id non existant "; } catch (Exception $e) { - $sbnet = 'Exception reçue : ', $e->getMessage(), "\n"; + echo 'Exception reçue : ', $e->getMessage(), "\n"; } - return $sbnet; + } public function updateNetwork($idNet,$name,$shared,$adminStateUp) @@ -192,3 +251,198 @@ class network{ $subnet = getNetwork($idSub); $subnet->delete(); } + + public function createPort($networkId,$name,$adminStateUp,$macAddress,$fixedIps,$deviceId,$deviceOwner,$securityGroups,$tenantId) + { + $options = array(); + if (!is_null($networkId)) + { + $options['networkId'] = $networkId; + } + if (!is_null($name)) + { + $options['name'] = $name; + } + if (!is_null($adminStateUp)) + { + $options['adminStateUp'] = $adminStateUp; + } + if (!is_null($macAddress)) + { + $options['macAddress'] = $macAddress; + } + if (!is_null($fixedIps)) + { + $options['fixedIps'] = $fixedIps; + } + if (!is_null($deviceId)) + { + $options['deviceId'] = $deviceId; + } + if (!is_null($deviceOwner)) + { + $options['deviceOwner'] = $deviceOwner; + } + if (!is_null($securityGroups)) + { + $options['securityGroups'] = $securityGroups; + } + if (!is_null($tenantId)) + { + $options['tenantId'] = $tenantId; + } + + $this->libClass->createPort($options); + } + + public function listPorts() + { + return $this->libClass->listPorts(); + } + + public function getPort($portId) + { + try + { + $port = $this->libClass->getport($portId); + return $port; + } + catch (Exception $e) + { + echo 'id fourni non disponible'; + } + + } + + public function updatePort($networkId,$name,$adminStateUp,$macAddress,$fixedIps,$deviceId,$deviceOwner,$securityGroups,$tenantId) + { + $options = array(); + if (!is_null($networkId)) + { + $options['networkId'] = $networkId; + } + if (!is_null($name)) + { + $options['name'] = $name; + } + if (!is_null($adminStateUp)) + { + $options['adminStateUp'] = $adminStateUp; + } + if (!is_null($macAddress)) + { + $options['macAddress'] = $macAddress; + } + if (!is_null($fixedIps)) + { + $options['fixedIps'] = $fixedIps; + } + if (!is_null($deviceId)) + { + $options['deviceId'] = $deviceId; + } + if (!is_null($deviceOwner)) + { + $options['deviceOwner'] = $deviceOwner; + } + if (!is_null($securityGroups)) + { + $options['securityGroups'] = $securityGroups; + } + if (!is_null($tenantId)) + { + $options['tenantId'] = $tenantId; + } + + $this->libClass->update($options); + } + + public function deletePort($portId) + { + $port = getPort($portId); + $port->delete(); + } + + public function createSecurityGroup($name,$description) + { + $options = array(); + if (!is_null($name)) + { + $options['name'] = $name; + } + if (!is_null($description)) + { + $options['description'] = $description; + } + + $this->libClass->createSecurityGroup($options); + } + + public function createSecurityGroupRule($securityGroupId,$direction,$ethertype,$portRangeMin,$portRangeMax,$protocol,$remoteGroupId,$remoteIpPrefix) + { + $options = array(); + if (!is_null($securityGroupId)) + { + $options['securityGroupId'] = $securityGroupId; + } + if (!is_null($direction)) + { + $options['direction'] = $direction; + } + if (!is_null($ethertype)) + { + $options['ethertype'] = $ethertype; + } + if (!is_null($portRangeMin)) + { + $options['portRangeMin'] = $portRangeMin; + } + if (!is_null($portRangeMax)) + { + $options['portRangeMax'] = $portRangeMax; + } + if (!is_null($protocol)) + { + $options['protocol'] = $protocol; + } + if (!is_null($remoteGroupId)) + { + $options['remoteGroupId'] = $remoteGroupId; + } + if (!is_null($remoteIpPrefix)) + { + $options['remoteIpPrefix'] = $remoteIpPrefix; + } + $this->libClass->createSecurityGroupRule($options); + } + + + public function listSecurityGroupe() + { + return $this->libClass->listSecurityGroups(); + } + + public function listSecurityGroupeRule() + { + return $this->libClass->listSecurityGroupRules(); + } + + public function getSecurityGroupe($securityGroupeId) + { + try + { + $securityGroupe = $this->libClass->getSecurityGroupe($securityGroupeId); + return $securityGroupe; + } + catch (Exception $e) + { + echo 'id fourni non disponible'; + } + + } + + public function deleteSecurityGroupe($securityGroupeId) + { + $securityGroupe = getSecurityGroupe($securityGroupeId); + $securityGroupe->delete(); + } From 8ad216dedf017f3d6de047a25d08db3b98e16361 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Wed, 9 Mar 2016 15:33:52 +0100 Subject: [PATCH 06/71] test --- client/index.html | 2 +- client/js/controllers/image/image.js | 6 +++++- client/js/services/Image.js | 20 +++++++++++++++++++- client/partials/image/image.html | 7 +++++++ 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/client/index.html b/client/index.html index a06994c..7ff859d 100644 --- a/client/index.html +++ b/client/index.html @@ -66,7 +66,7 @@ - + diff --git a/client/js/controllers/image/image.js b/client/js/controllers/image/image.js index e298fcc..d499acb 100644 --- a/client/js/controllers/image/image.js +++ b/client/js/controllers/image/image.js @@ -3,7 +3,7 @@ * * @param {$scope} $scope The $scope service from angular */ -mainApp.controller('imageCtrl', ['$scope', 'Image', 'Loading', function ($scope, Image, Loading) +mainApp.controller('imageCtrl', ['$scope', 'Image', 'Loading',function ($scope, Image, Loading) { var callbackTest=function(){ $scope.images=Image.getData().images; @@ -17,5 +17,9 @@ mainApp.controller('imageCtrl', ['$scope', 'Image', 'Loading', function ($scope, else{ callbackTest(); } + + $scope.doUpload = function () { + Image.uploadImage($scope.myFile,function(){}); + }; }]); diff --git a/client/js/services/Image.js b/client/js/services/Image.js index 2e8c56f..decb5b2 100644 --- a/client/js/services/Image.js +++ b/client/js/services/Image.js @@ -44,6 +44,23 @@ mainApp.factory('Image',[ '$http', 'Identity', function($http, Identity){ }; + var uploadImage=function(fileToUpload, callback) { + + + var result=$http.post('../server/index.php', + $.param({"token" : Identity.getToken(), "task" : "image", 'action':'uploadImage', 'filename':fileToUpload, 'id':'6564'})); + + // Wait and handle the response + result.then(function (response){ + callback(parseUploadImageAnswer(response, false)); + },function(response){ + callback(parseUploadImageAnswer(response, true)); + }); + + + + } + var getData=function(response){ return data; @@ -52,7 +69,8 @@ mainApp.factory('Image',[ '$http', 'Identity', function($http, Identity){ // Return services objects return { getImages:getImages, - getData:getData + getData:getData, + uploadImage:uploadImage }; diff --git a/client/partials/image/image.html b/client/partials/image/image.html index 8af8af5..3f597fb 100644 --- a/client/partials/image/image.html +++ b/client/partials/image/image.html @@ -6,5 +6,12 @@
{{image.name}}
+
+ + +
+ + + From 20f8eb41d3ae5e53fd4bb53e55f0627ff7b7f15c Mon Sep 17 00:00:00 2001 From: Othmane Kabir <16008902@e003m10.istic.univ-rennes1.fr> Date: Wed, 9 Mar 2016 16:13:20 +0100 Subject: [PATCH 07/71] commit finale --- server/core/Network.php | 928 +++++++++++++++++++++++++++++--------- server/core/Network.php~ | 952 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 1668 insertions(+), 212 deletions(-) create mode 100644 server/core/Network.php~ diff --git a/server/core/Network.php b/server/core/Network.php index 75ba2fd..65de962 100644 --- a/server/core/Network.php +++ b/server/core/Network.php @@ -25,279 +25,595 @@ class network{ } - public function create_network($name,$adminStateUp,$shared,$tenantId) + public function create_network() { $options = array(); - if (!is_null($name)) + if (isset($this->app->getPostParam("name"))) { - $options['name'] = $name; + $options['name'] = $this->app->getPostParam("name"); } - if (!is_null($adminStateUp)) + if (isset($this->app->getPostParam("adminStateUp"))) { - $options['adminStateUp'] = $adminStateUp; + $options['adminStateUp'] = $this->app->getPostParam("adminStateUp"); } - if (!is_null($shared)) + if (isset($this->app->getPostParam("shared"))) { - $options['shared'] = $shared; + $options['shared'] = $this->app->getPostParam("shared"); } - if (!is_null($tenantId)) + if (isset($this->app->getPostParam("tenantId"))) { - $options['tenantId'] = $tenantId; + $options['tenantId'] = $this->app->getPostParam("tenantId"); } + try + { $network = $this->libClass->createNetworks($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); + } - return $network; + } - public function create_subnet($networkId,$ipVersion,$cidr,$name,$gatewayIp,$dnsNameservers,$allocationPools,$hostRoutes,$enableDhcp,$tenantId) + public function create_subnet() { $options = array(); - if (!is_null($networkId)) + if (isset($this->app->getPostParam("networkId"))) { $options['networkId'] = $networkId; } - if (!is_null($ipVersion)) + if (isset($this->app->getPostParam("ipVersion"))) { - $options['ipVersion'] = $ipVersion; + $options['ipVersion'] = $this->app->getPostParam("ipVersion"); } - if (!is_null($cidr)) + if (isset($this->app->getPostParam("cidr"))) { - $options['cidr'] = $cidr; + $options['cidr'] = $this->app->getPostParam("cidr"); } - if (!is_null($tenantId)) + if (isset($this->app->getPostParam("tenantId"))) { - $options['tenantId'] = $tenantId; + $options['tenantId'] = $this->app->getPostParam("tenantId"); } - if (!is_null($name)) + if (isset($this->app->getPostParam("name"))) { - $options['name'] = $name; + $options['name'] = $$this->app->getPostParam("name"); } - if (!is_null($gatewayIp)) + if (isset($this->app->getPostParam("gatewayIp"))) { - $options['gatewayIp'] = $gatewayIp; + $options['gatewayIp'] = $this->app->getPostParam("gatewayIp"); } - if (!is_null($dnsNameservers)) + if (isset($this->app->getPostParam("dnsNameservers"))) { - $options['dnsNameservers'] = $dnsNameservers; + $options['dnsNameservers'] = $this->app->getPostParam("dnsNameservers"); } - if (!is_null($allocationPools)) + if (isset($this->app->getPostParam("allocationPools"))) { - $options['allocationPools'] = $allocationPools; + $options['allocationPools'] = $this->app->getPostParam("allocationPools"); } - if (!is_null($hostRoutes)) + if (isset($this->app->getPostParam("hostRoutes"))) { - $options['hostRoutes'] = $hostRoutes; + $options['hostRoutes'] = $this->app->getPostParam("hostRoutes"); } - if (!is_null($enableDhcp)) + if (isset($this->app->getPostParam("enableDhcp"))) { - $options['enableDhcp'] = $enableDhcp; + $options['enableDhcp'] = $this->app->getPostParam("enableDhcp"); } - if (!is_null($tenantId)) + if (isset($this->app->getPostParam("tenantId"))) { - $options['tenantId'] = $tenantId; + $options['tenantId'] = $this->app->getPostParam("tenantId"); } - $subnet = $this->libClass->createSubnet($options); + try + { + $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); + } - return $subnet; + } public function list_network_ids() { - - $ln = $this->libClass->listNetworks(); - - $list_ids = array(); - - - foreach($ln as $n) + try { + $ln = $this->libClass->listNetworks(); + + $list_ids = array(); + + + foreach($ln as $n) + { - $list_ids[] = $n->id; + $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); + } - return $list_ids; + $this->app->setOutput("ListNetworkIds", $list_ids); } public function list_network_names() { - - $ln = $this->libClass->listNetworks(); - - $list_names = array(); - - - foreach($ln as $n) + try { + $ln = $this->libClass->listNetworks(); + + $list_names = array(); + + + foreach($ln as $n) + { - $list_names[] = $n->name; + $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); + } - return $list_names; + $this->app->setOutput("ListNetworkNames", $list_names); } public function list_cidr() { - - $ls = $this->libClass->listSubnets(); - $list_cidr = array(); - foreach ($ls as $subnet) - { - - $list_cidr[] = $subnet->cidr; - } + try + { + $ls = $this->libClass->listSubnets(); + $list_cidr = array(); + foreach ($ls as $subnet) + { + + $list_cidr[] = $subnet->cidr; + } - return $list_names; + $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); + } } - //option array() - public function getNetwork($idNet) + + public function getNetwork() { $network=""; try - { $newtork = $this->libClass->getNetwork($idNet); + { $newtork = $this->libClass->getNetwork($this->app->getPostParam("networkId")); $network->retrieve(); } - catch (OpenStack\Common\Error\BadResponseError $e) + + catch(BadResponseError $e) { - $network = "Id non existant "; - } - catch (Exception $e) + $this->app->getErrorInstance->BadResponseHandler($e); + } + catch(UserInputError $e) { - $network = 'Exception reçue : ', $e->getMessage(), "\n"; + $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); + } + + public function getNetwork($netId) + { + $network=""; + + try + { $newtork = $this->libClass->getNetwork($netId); + $network->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); + } + return $network; } - public function getSubnet($idSub) + public function getSubnet() { $sbnet=""; try - { $subnet = $this->libClass->getSubnet($idSub); + { $subnet = $this->libClass->getSubnet($this->app->getPostParam("subnetId")); $subnet->retrieve(); - return $sbnet; + } - catch (OpenStack\Common\Error\BadResponseError $e) + catch(BadResponseError $e) { - echo "Id non existant "; - } - catch (Exception $e) + $this->app->getErrorInstance->BadResponseHandler($e); + } + catch(UserInputError $e) { - echo 'Exception reçue : ', $e->getMessage(), "\n"; - } - + $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); - } + } - public function updateNetwork($idNet,$name,$shared,$adminStateUp) - { - $network = getNetwork($idNet); - if(!is_null($name)) - { - $network->name = $name; + public function getSubnet($subnetId) + { + $subnet=""; + + try + { $subnet = $this->libClass->getSubnet($subnetId); + $subnet->retrieve(); + + } - if(!is_null($shared)) + + catch(BadResponseError $e) { - $network->shared = $shared; - } - if(!is_null($adminStateUp)) + $this->app->getErrorInstance->BadResponseHandler($e); + } + catch(UserInputError $e) { - $network->adminStateUp = $shared; + $this->app->getErrorInstance->UserInputHandler($e); + } + catch(BaseError $e) + { + $this->app->getErrorInstance->BaseErrorHandler($e); + } + catch(NotImplementedError $e) + { + $this->app->getErrorInstance->NotImplementedHandler($e); + } + return $subnet; + + } + + public function updateNetwork() + { + $options = array(); + if(isset($this->app->getPostParam("name"))) + { + $options['name'] = $this->app->getPostParam("name"); } - $network->update(); + if(isset($this->app->getPostParam("shared"))) + { + $options['shared'] = $this->app->getPostParam("shared"); + } + if(isset($this->app->getPostParam("adminStateUp"))) + { + $options['adminStateUp'] = $this->app->getPostParam("adminStateUp"); + } + try + { + $network = getNetwork($this->app->getPostParam("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); + } } - public function updateSubnet($idSub,$name,$networkId,$ipVersion,$cidr) - { - $subnet = getNetwork($idSub); - if(!is_null($name)) + public function updateSubnet() + { + $options = array(); + if(isset($this->app->getPostParam("name"))) { - $subnet->name = $name; + $options['name'] = $this->app->getPostParam("name"); } - if(!is_null($networkId)) + if(isset($this->app->getPostParam("networkId"))) { - $subnet->networkId = $networkId; + $options['networkId'] = $this->app->getPostParam("networkId"); } - if(!is_null($ipVersion)) + if(isset($this->app->getPostParam("ipVersion"))) { - $subnet->ipVersion = $ipVersion; + $options['ipVersion'] = $this->app->getPostParam("ipVersion"); } - if(!is_null($cidr)) + if(isset($this->app->getPostParam("cidr"))) { - $subnet->cidr = $cidr; + $options['cidr'] = $this->app->getPostParam("cidr"); } - $subnet->update(); + try + { + $subnet = getSubnet($this->app->getPostParam("networkId")); + + $subnet->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); + } } - public function deleteNetwork($idNet) + public function deleteNetwork() { - $network = getNetwork($idNet); - $network->delete(); + try + { + + $network = getNetwork($this->app->getPostParam("networkId")); + $network->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); + } } - public function deleteSubnet($idSub) + public function deleteSubnet() { - $subnet = getNetwork($idSub); - $subnet->delete(); + try + { + $subnet = getNetwork($this->app->getPostParam("subnetId")); + $subnet->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); + } } - public function createPort($networkId,$name,$adminStateUp,$macAddress,$fixedIps,$deviceId,$deviceOwner,$securityGroups,$tenantId) + public function createPort() { $options = array(); - if (!is_null($networkId)) + if (isset($this->app->getPostParam("networkId"))) { - $options['networkId'] = $networkId; + $options['networkId'] = $this->app->getPostParam("networkId"); } - if (!is_null($name)) + if (isset($this->app->getPostParam("name"))) { - $options['name'] = $name; + $options['name'] = $this->app->getPostParam("name"); } - if (!is_null($adminStateUp)) + if (isset($this->app->getPostParam("adminStateUp"))) { - $options['adminStateUp'] = $adminStateUp; + $options['adminStateUp'] = $this->app->getPostParam("adminStateUp"); } - if (!is_null($macAddress)) + if (isset($this->app->getPostParam("macAddress"))) { - $options['macAddress'] = $macAddress; + $options['macAddress'] = $this->app->getPostParam("macAddress"); } - if (!is_null($fixedIps)) + if (isset($this->app->getPostParam("fixedIps"))) { - $options['fixedIps'] = $fixedIps; + $options['fixedIps'] = $this->app->getPostParam("fixedIps"); } - if (!is_null($deviceId)) + if (isset($this->app->getPostParam("deviceId"))) { - $options['deviceId'] = $deviceId; + $options['deviceId'] = $this->app->getPostParam("deviceId"); } - if (!is_null($deviceOwner)) + if (isset($this->app->getPostParam("deviceOwner"))) { - $options['deviceOwner'] = $deviceOwner; + $options['deviceOwner'] = $this->app->getPostParam("deviceOwner"); } - if (!is_null($securityGroups)) + if (isset($this->app->getPostParam("securityGroups"))) { - $options['securityGroups'] = $securityGroups; + $options['securityGroups'] = $this->app->getPostParam("securityGroups"); } - if (!is_null($tenantId)) + if (isset($this->app->getPostParam("tenantId"))) { - $options['tenantId'] = $tenantId; + $options['tenantId'] = $this->app->getPostParam("tenantId"); } - - $this->libClass->createPort($options); + try + { + $this->libClass->createPort($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); + } } public function listPorts() { - return $this->libClass->listPorts(); + try + { + $this->app->setOutput("listPorts", $this->libClass->listPorts()); + } + 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); + } + } + + public function getPort() + { + try + { + $port = $this->libClass->getport($this->app->getPostParam("portId")); + $this->app->setOutput("Port", $port); + } + 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); + } + } public function getPort($portId) @@ -307,124 +623,280 @@ class network{ $port = $this->libClass->getport($portId); return $port; } - catch (Exception $e) + catch(BadResponseError $e) { - echo 'id fourni non disponible'; - } + $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); + } - } + } - public function updatePort($networkId,$name,$adminStateUp,$macAddress,$fixedIps,$deviceId,$deviceOwner,$securityGroups,$tenantId) + public function updatePort() { $options = array(); - if (!is_null($networkId)) - { - $options['networkId'] = $networkId; - } - if (!is_null($name)) - { - $options['name'] = $name; - } - if (!is_null($adminStateUp)) - { - $options['adminStateUp'] = $adminStateUp; - } - if (!is_null($macAddress)) - { - $options['macAddress'] = $macAddress; - } - if (!is_null($fixedIps)) - { - $options['fixedIps'] = $fixedIps; - } - if (!is_null($deviceId)) - { - $options['deviceId'] = $deviceId; - } - if (!is_null($deviceOwner)) - { - $options['deviceOwner'] = $deviceOwner; - } - if (!is_null($securityGroups)) - { - $options['securityGroups'] = $securityGroups; - } - if (!is_null($tenantId)) - { - $options['tenantId'] = $tenantId; - } - $this->libClass->update($options); + if (isset($this->app->getPostParam("networkId"))) + { + $options['networkId'] = $this->app->getPostParam("networkId"); + } + if (isset($this->app->getPostParam("name"))) + { + $options['name'] =$this->app->getPostParam("name"); + } + if (isset($this->app->getPostParam("adminStateUp"))) + { + $options['adminStateUp'] =$this->app->getPostParam("adminStateUp"); + } + if (isset($this->app->getPostParam("macAddress"))) + { + $options['macAddress'] = $this->app->getPostParam("macAddress"); + } + if (isset($this->app->getPostParam("fixedIps"))) + { + $options['fixedIps'] = $this->app->getPostParam("fixedIps"); + } + if (isset($this->app->getPostParam("deviceId"))) + { + $options['deviceId'] = $this->app->getPostParam("deviceId"); + } + if (isset($this->app->getPostParam("deviceOwner"))) + { + $options['deviceOwner'] = $this->app->getPostParam("deviceOwner"); + } + if (isset($this->app->getPostParam("networkId"))) + { + $options['securityGroups'] = $this->app->getPostParam("securityGroups"); + } + if (isset($this->app->getPostParam("tenantId"))) + { + $options['tenantId'] = $this->app->getPostParam("tenantId"); + } + try + { + $port = getPort($this->app->getPostParam("networkId")); + $port->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); + } } - public function deletePort($portId) + public function deletePort() { - $port = getPort($portId); - $port->delete(); + + try + { + $port = getPort($this->app->getPostParam("portId")); + $port->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); + } } - public function createSecurityGroup($name,$description) + public function createSecurityGroup() { $options = array(); - if (!is_null($name)) + if (isset($this->app->getPostParam("name"))) { - $options['name'] = $name; + $options['name'] = $this->app->getPostParam("name"); } - if (!is_null($description)) + if (isset($this->app->getPostParam("description"))) { - $options['description'] = $description; + $options['description'] = $this->app->getPostParam("description"); } - - $this->libClass->createSecurityGroup($options); + try + { + $this->libClass->createSecurityGroup($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); + } + } - public function createSecurityGroupRule($securityGroupId,$direction,$ethertype,$portRangeMin,$portRangeMax,$protocol,$remoteGroupId,$remoteIpPrefix) + public function createSecurityGroupRule() { $options = array(); - if (!is_null($securityGroupId)) + if (isset($this->app->getPostParam("securityGroupId"))) { - $options['securityGroupId'] = $securityGroupId; + $options['securityGroupId'] = $this->app->getPostParam("securityGroupId"); } - if (!is_null($direction)) + if (isset($this->app->getPostParam("direction"))) { - $options['direction'] = $direction; + $options['direction'] = $this->app->getPostParam("direction"); } - if (!is_null($ethertype)) + if (isset($this->app->getPostParam("ethertype"))) { - $options['ethertype'] = $ethertype; + $options['ethertype'] = $this->app->getPostParam("ethertype"); } - if (!is_null($portRangeMin)) + if (isset($this->app->getPostParam("portRangeMin"))) { - $options['portRangeMin'] = $portRangeMin; + $options['portRangeMin'] = $this->app->getPostParam("portRangeMin"); } - if (!is_null($portRangeMax)) + if (isset($this->app->getPostParam("portRangeMax"))) { - $options['portRangeMax'] = $portRangeMax; + $options['portRangeMax'] = $this->app->getPostParam("portRangeMax"); } - if (!is_null($protocol)) + if (isset($this->app->getPostParam("protocol"))) { - $options['protocol'] = $protocol; + $options['protocol'] = $this->app->getPostParam("protocol"); } - if (!is_null($remoteGroupId)) + if (isset($this->app->getPostParam("remoteGroupId"))) { - $options['remoteGroupId'] = $remoteGroupId; + $options['remoteGroupId'] = $this->app->getPostParam("remoteGroupId"); } - if (!is_null($remoteIpPrefix)) + if (isset($this->app->getPostParam("remoteIpPrefix"))) { - $options['remoteIpPrefix'] = $remoteIpPrefix; + $options['remoteIpPrefix'] = $this->app->getPostParam("remoteIpPrefix"); } - $this->libClass->createSecurityGroupRule($options); + try + { + $this->libClass->createSecurityGroupRule($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); + } } public function listSecurityGroupe() { - return $this->libClass->listSecurityGroups(); + try + { + $this->app->setOutput("listSecurityGroups", $this->libClass->listSecurityGroups()); + } + 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); + } } public function listSecurityGroupeRule() { - return $this->libClass->listSecurityGroupRules(); + try + { + + $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); + } + } + + public function getSecurityGroupe() + { + try + { + $securityGroupe = $this->libClass->getSecurityGroupe($this->app->getPostParam("securityGroupeId")); + $this->app->setOutput("securityGroupe", $securityGroupe); + } + 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); + } + } public function getSecurityGroupe($securityGroupeId) @@ -434,15 +906,47 @@ class network{ $securityGroupe = $this->libClass->getSecurityGroupe($securityGroupeId); return $securityGroupe; } - catch (Exception $e) + catch(BadResponseError $e) { - echo 'id fourni non disponible'; - } + $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); + } } - public function deleteSecurityGroupe($securityGroupeId) - { - $securityGroupe = getSecurityGroupe($securityGroupeId); - $securityGroupe->delete(); + public function deleteSecurityGroupe() + { + try + { + + $securityGroupe = getSecurityGroupe($this->app->getPostParam("securityGroupeId")); + $securityGroupe->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); + } } diff --git a/server/core/Network.php~ b/server/core/Network.php~ new file mode 100644 index 0000000..65de962 --- /dev/null +++ b/server/core/Network.php~ @@ -0,0 +1,952 @@ +app = $app; + $this->libClass = $app->getLibClass("network"); + + } + + + public function action($action){ + + $this->{$action.""}(); + + } + + + public function create_network() + { + $options = array(); + if (isset($this->app->getPostParam("name"))) + { + $options['name'] = $this->app->getPostParam("name"); + } + if (isset($this->app->getPostParam("adminStateUp"))) + { + $options['adminStateUp'] = $this->app->getPostParam("adminStateUp"); + } + if (isset($this->app->getPostParam("shared"))) + { + $options['shared'] = $this->app->getPostParam("shared"); + } + if (isset($this->app->getPostParam("tenantId"))) + { + $options['tenantId'] = $this->app->getPostParam("tenantId"); + } + try + { + $network = $this->libClass->createNetworks($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); + } + + + } + + public function create_subnet() + { $options = array(); + if (isset($this->app->getPostParam("networkId"))) + { + $options['networkId'] = $networkId; + } + if (isset($this->app->getPostParam("ipVersion"))) + { + $options['ipVersion'] = $this->app->getPostParam("ipVersion"); + } + if (isset($this->app->getPostParam("cidr"))) + { + $options['cidr'] = $this->app->getPostParam("cidr"); + } + if (isset($this->app->getPostParam("tenantId"))) + { + $options['tenantId'] = $this->app->getPostParam("tenantId"); + } + if (isset($this->app->getPostParam("name"))) + { + $options['name'] = $$this->app->getPostParam("name"); + } + if (isset($this->app->getPostParam("gatewayIp"))) + { + $options['gatewayIp'] = $this->app->getPostParam("gatewayIp"); + } + if (isset($this->app->getPostParam("dnsNameservers"))) + { + $options['dnsNameservers'] = $this->app->getPostParam("dnsNameservers"); + } + if (isset($this->app->getPostParam("allocationPools"))) + { + $options['allocationPools'] = $this->app->getPostParam("allocationPools"); + } + if (isset($this->app->getPostParam("hostRoutes"))) + { + $options['hostRoutes'] = $this->app->getPostParam("hostRoutes"); + } + if (isset($this->app->getPostParam("enableDhcp"))) + { + $options['enableDhcp'] = $this->app->getPostParam("enableDhcp"); + } + if (isset($this->app->getPostParam("tenantId"))) + { + $options['tenantId'] = $this->app->getPostParam("tenantId"); + } + + try + { + $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); + } + + + } + + public function list_network_ids() + { + 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); + } + + public function list_network_names() + { + 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); + } + + public function list_cidr() + { + try + { + $ls = $this->libClass->listSubnets(); + $list_cidr = array(); + foreach ($ls as $subnet) + { + + $list_cidr[] = $subnet->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); + } + } + + public function getNetwork() + { + $network=""; + + try + { $newtork = $this->libClass->getNetwork($this->app->getPostParam("networkId")); + $network->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); + } + + $this->app->setOutput("Network", $network); + } + + public function getNetwork($netId) + { + $network=""; + + try + { $newtork = $this->libClass->getNetwork($netId); + $network->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); + } + + return $network; + } + + public function getSubnet() + { + $sbnet=""; + + try + { $subnet = $this->libClass->getSubnet($this->app->getPostParam("subnetId")); + $subnet->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); + } + $this->app->setOutput("Subnet", subnet); + + } + + public function getSubnet($subnetId) + { + $subnet=""; + + try + { $subnet = $this->libClass->getSubnet($subnetId); + $subnet->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); + } + return $subnet; + + } + + public function updateNetwork() + { + $options = array(); + if(isset($this->app->getPostParam("name"))) + { + $options['name'] = $this->app->getPostParam("name"); + } + if(isset($this->app->getPostParam("shared"))) + { + $options['shared'] = $this->app->getPostParam("shared"); + } + if(isset($this->app->getPostParam("adminStateUp"))) + { + $options['adminStateUp'] = $this->app->getPostParam("adminStateUp"); + } + try + { + $network = getNetwork($this->app->getPostParam("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); + } + } + + public function updateSubnet() + { + $options = array(); + if(isset($this->app->getPostParam("name"))) + { + $options['name'] = $this->app->getPostParam("name"); + } + if(isset($this->app->getPostParam("networkId"))) + { + $options['networkId'] = $this->app->getPostParam("networkId"); + } + if(isset($this->app->getPostParam("ipVersion"))) + { + $options['ipVersion'] = $this->app->getPostParam("ipVersion"); + } + if(isset($this->app->getPostParam("cidr"))) + { + $options['cidr'] = $this->app->getPostParam("cidr"); + } + try + { + $subnet = getSubnet($this->app->getPostParam("networkId")); + + $subnet->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); + } + } + + public function deleteNetwork() + { + try + { + + $network = getNetwork($this->app->getPostParam("networkId")); + $network->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); + } + } + + public function deleteSubnet() + { + try + { + $subnet = getNetwork($this->app->getPostParam("subnetId")); + $subnet->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); + } + } + + public function createPort() + { + $options = array(); + if (isset($this->app->getPostParam("networkId"))) + { + $options['networkId'] = $this->app->getPostParam("networkId"); + } + if (isset($this->app->getPostParam("name"))) + { + $options['name'] = $this->app->getPostParam("name"); + } + if (isset($this->app->getPostParam("adminStateUp"))) + { + $options['adminStateUp'] = $this->app->getPostParam("adminStateUp"); + } + if (isset($this->app->getPostParam("macAddress"))) + { + $options['macAddress'] = $this->app->getPostParam("macAddress"); + } + if (isset($this->app->getPostParam("fixedIps"))) + { + $options['fixedIps'] = $this->app->getPostParam("fixedIps"); + } + if (isset($this->app->getPostParam("deviceId"))) + { + $options['deviceId'] = $this->app->getPostParam("deviceId"); + } + if (isset($this->app->getPostParam("deviceOwner"))) + { + $options['deviceOwner'] = $this->app->getPostParam("deviceOwner"); + } + if (isset($this->app->getPostParam("securityGroups"))) + { + $options['securityGroups'] = $this->app->getPostParam("securityGroups"); + } + if (isset($this->app->getPostParam("tenantId"))) + { + $options['tenantId'] = $this->app->getPostParam("tenantId"); + } + try + { + $this->libClass->createPort($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); + } + } + + public function listPorts() + { + try + { + $this->app->setOutput("listPorts", $this->libClass->listPorts()); + } + 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); + } + } + + public function getPort() + { + try + { + $port = $this->libClass->getport($this->app->getPostParam("portId")); + $this->app->setOutput("Port", $port); + } + 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); + } + + } + + public function getPort($portId) + { + try + { + $port = $this->libClass->getport($portId); + return $port; + } + 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); + } + + } + + public function updatePort() + { + $options = array(); + + if (isset($this->app->getPostParam("networkId"))) + { + $options['networkId'] = $this->app->getPostParam("networkId"); + } + if (isset($this->app->getPostParam("name"))) + { + $options['name'] =$this->app->getPostParam("name"); + } + if (isset($this->app->getPostParam("adminStateUp"))) + { + $options['adminStateUp'] =$this->app->getPostParam("adminStateUp"); + } + if (isset($this->app->getPostParam("macAddress"))) + { + $options['macAddress'] = $this->app->getPostParam("macAddress"); + } + if (isset($this->app->getPostParam("fixedIps"))) + { + $options['fixedIps'] = $this->app->getPostParam("fixedIps"); + } + if (isset($this->app->getPostParam("deviceId"))) + { + $options['deviceId'] = $this->app->getPostParam("deviceId"); + } + if (isset($this->app->getPostParam("deviceOwner"))) + { + $options['deviceOwner'] = $this->app->getPostParam("deviceOwner"); + } + if (isset($this->app->getPostParam("networkId"))) + { + $options['securityGroups'] = $this->app->getPostParam("securityGroups"); + } + if (isset($this->app->getPostParam("tenantId"))) + { + $options['tenantId'] = $this->app->getPostParam("tenantId"); + } + try + { + $port = getPort($this->app->getPostParam("networkId")); + $port->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); + } + } + + public function deletePort() + { + + try + { + $port = getPort($this->app->getPostParam("portId")); + $port->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); + } + } + + public function createSecurityGroup() + { + $options = array(); + if (isset($this->app->getPostParam("name"))) + { + $options['name'] = $this->app->getPostParam("name"); + } + if (isset($this->app->getPostParam("description"))) + { + $options['description'] = $this->app->getPostParam("description"); + } + try + { + $this->libClass->createSecurityGroup($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); + } + + } + + public function createSecurityGroupRule() + { + $options = array(); + if (isset($this->app->getPostParam("securityGroupId"))) + { + $options['securityGroupId'] = $this->app->getPostParam("securityGroupId"); + } + if (isset($this->app->getPostParam("direction"))) + { + $options['direction'] = $this->app->getPostParam("direction"); + } + if (isset($this->app->getPostParam("ethertype"))) + { + $options['ethertype'] = $this->app->getPostParam("ethertype"); + } + if (isset($this->app->getPostParam("portRangeMin"))) + { + $options['portRangeMin'] = $this->app->getPostParam("portRangeMin"); + } + if (isset($this->app->getPostParam("portRangeMax"))) + { + $options['portRangeMax'] = $this->app->getPostParam("portRangeMax"); + } + if (isset($this->app->getPostParam("protocol"))) + { + $options['protocol'] = $this->app->getPostParam("protocol"); + } + if (isset($this->app->getPostParam("remoteGroupId"))) + { + $options['remoteGroupId'] = $this->app->getPostParam("remoteGroupId"); + } + if (isset($this->app->getPostParam("remoteIpPrefix"))) + { + $options['remoteIpPrefix'] = $this->app->getPostParam("remoteIpPrefix"); + } + try + { + $this->libClass->createSecurityGroupRule($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); + } + } + + + public function listSecurityGroupe() + { + try + { + $this->app->setOutput("listSecurityGroups", $this->libClass->listSecurityGroups()); + } + 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); + } + } + + public function listSecurityGroupeRule() + { + try + { + + $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); + } + } + + public function getSecurityGroupe() + { + try + { + $securityGroupe = $this->libClass->getSecurityGroupe($this->app->getPostParam("securityGroupeId")); + $this->app->setOutput("securityGroupe", $securityGroupe); + } + 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); + } + + } + + public function getSecurityGroupe($securityGroupeId) + { + try + { + $securityGroupe = $this->libClass->getSecurityGroupe($securityGroupeId); + return $securityGroupe; + } + 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); + } + + } + + public function deleteSecurityGroupe() + { + try + { + + $securityGroupe = getSecurityGroupe($this->app->getPostParam("securityGroupeId")); + $securityGroupe->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); + } + } From 1061d8c85e5b5ce7c1bf3e79685e9e19f92f7353 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Wed, 16 Mar 2016 13:07:04 +0100 Subject: [PATCH 08/71] Test --- server/vendor/php-opencloud/openstack | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/vendor/php-opencloud/openstack b/server/vendor/php-opencloud/openstack index f2ee770..4ba218f 160000 --- a/server/vendor/php-opencloud/openstack +++ b/server/vendor/php-opencloud/openstack @@ -1 +1 @@ -Subproject commit f2ee77024843659d970817a9e7055bb40a3724f9 +Subproject commit 4ba218fc7ed0e618fd83eaf690b2e4e3bf22cde5 From 004dc2acdd2dea2dff8af670f855c40b54f38f4b Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Wed, 16 Mar 2016 15:36:12 +0100 Subject: [PATCH 09/71] Test --- client/partials/image/image.html | 23 +++++++++++++++++++---- index.php | 3 +++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/client/partials/image/image.html b/client/partials/image/image.html index 8af8af5..620eda8 100644 --- a/client/partials/image/image.html +++ b/client/partials/image/image.html @@ -1,10 +1,25 @@
- Images disponibles + Image Manager
-
- {{image.name}} -
+ + + + + + + + + + + + + + + + + +
NameSizeAction
{{ image.name }}000actions
diff --git a/index.php b/index.php index e69de29..cf60860 100644 --- a/index.php +++ b/index.php @@ -0,0 +1,3 @@ + From f01cfa2ec71672e2b178c06f87037d8b793ddd67 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Wed, 16 Mar 2016 16:05:24 +0100 Subject: [PATCH 10/71] Make image manager --- client/partials/image/image.html | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/client/partials/image/image.html b/client/partials/image/image.html index 471ce3c..c90cbe0 100644 --- a/client/partials/image/image.html +++ b/client/partials/image/image.html @@ -4,6 +4,14 @@
+ + + +
+ + +
+

@@ -15,13 +23,16 @@ - - + + - - +
{{ image.name }}000actions{{ (image.size / 1048576).toFixed(2) }} MB
+ + + +
From 0ce2b2fa301dde1c5b9c50c826d3ed44b00a5c44 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Wed, 16 Mar 2016 18:01:03 +0100 Subject: [PATCH 11/71] Add overlay upload --- client/index.html | 2 +- client/partials/image/image.html | 8 ++++---- client/partials/image/upload.html | 25 +++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 client/partials/image/upload.html diff --git a/client/index.html b/client/index.html index 7ff859d..08be038 100644 --- a/client/index.html +++ b/client/index.html @@ -23,7 +23,7 @@
- +
diff --git a/client/partials/image/image.html b/client/partials/image/image.html index c90cbe0..886a11d 100644 --- a/client/partials/image/image.html +++ b/client/partials/image/image.html @@ -1,14 +1,14 @@ -
+ + +
Image Manager
- -
- +

diff --git a/client/partials/image/upload.html b/client/partials/image/upload.html new file mode 100644 index 0000000..9049abf --- /dev/null +++ b/client/partials/image/upload.html @@ -0,0 +1,25 @@ +
- - + + - + - + - + - + - + - - + + + + - - diff --git a/client/js/controllers/login.js b/client/js/controllers/login.js index fed358d..93a373e 100644 --- a/client/js/controllers/login.js +++ b/client/js/controllers/login.js @@ -5,62 +5,61 @@ * @param {$sce} $sce The $sce angular service * @param {$http} $http The $http angular service * @param {Identity} The Identity service - + */ -mainApp.controller('loginCtrl', ['$scope','$sce','Identity', function ($scope,$sce, Identity) -{ - // Check for login and define default states - if(!Identity.isAlreadyLogin()){ - $('#loginModal').modal({backdrop: 'static', keyboard: false}); - } +mainApp.controller('loginCtrl', ['$scope', '$sce', 'Identity', function ($scope, $sce, Identity) + { + // Check for login and define default states + if (!Identity.isAlreadyLogin()) { + $('#loginModal').modal({backdrop: 'static', keyboard: false}); + } - // Manager logout event - $scope.$on('logoutEvent', function(){ - $('#loginModal').modal({backdrop: 'static', keyboard: false}); - }); + // Manager logout event + $scope.$on('logoutEvent', function () { + $('#loginModal').modal({backdrop: 'static', keyboard: false}); + }); - - // Hide loading button and message alert - $('#loadingLoginButton').hide(); - $('#failedToLoginAlert').hide(); - - // Defined function for login - $scope.loginAction=function(){ - - // Begin login state for template - $('#loginButton').hide(); - $('#loadingLoginButton').show(); + // Hide loading button and message alert + $('#loadingLoginButton').hide(); $('#failedToLoginAlert').hide(); - // Get data from templates - var username=$("#loginFormUsername").val(); - var password=$("#loginFormPassword").val(); - var projectname=$("#loginFormProjectname").val(); - // Function to call to handle result - var responseCallback=function(response){ + // Defined function for login + $scope.loginAction = function () { - if(response.status!==0){ - // Set reason of fail - $scope.failReason=response.failReason; + // Begin login state for template + $('#loginButton').hide(); + $('#loadingLoginButton').show(); + $('#failedToLoginAlert').hide(); - // Display the error - $('#failedToLoginAlert').show(); - } - else { - // Else the user is online ! - $('#loginModal').modal('hide'); + // Get data from templates + var username = $("#loginFormUsername").val(); + var password = $("#loginFormPassword").val(); + var projectname = $("#loginFormProjectname").val(); + + // Function to call to handle result + var responseCallback = function (response) { + + if (response.status !== 0) { + // Set reason of fail + $scope.failReason = response.failReason; + + // Display the error + $('#failedToLoginAlert').show(); + } else { + // Else the user is online ! + $('#loginModal').modal('hide'); + } + + // Reset button state + $('#loginButton').show(); + $('#loadingLoginButton').hide(); } - // Reset button state - $('#loginButton').show(); - $('#loadingLoginButton').hide(); - } - - // Try to login - Identity.login(username, password, projectname, responseCallback); - }; - -}]); + // Try to login + Identity.login(username, password, projectname, responseCallback); + }; + + }]); From aa26e5f959b0b38fa43035a700cc72b5ac85e7a3 Mon Sep 17 00:00:00 2001 From: Yoggzo Date: Sun, 17 Apr 2016 11:44:32 +0200 Subject: [PATCH 48/71] modif upload --- server/core/Image.php | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/server/core/Image.php b/server/core/Image.php index c595135..fdf4e3a 100755 --- a/server/core/Image.php +++ b/server/core/Image.php @@ -224,7 +224,6 @@ class image implements Core{ } else{ try{ - //vérifier existence image $service = $this->libClass; $image = $service->getImage($id); if($image == null){ // if the image don't exists -> error @@ -276,8 +275,6 @@ class image implements Core{ * @return void */ private function deleteImage(){ - // si protected = true, demander de le mettre a false - // vérifier existence image $id = $this->app->getPostParam("id"); if(!isset($id)){ $this->app->setOutput("Error", "Image doesn't exist"); @@ -357,7 +354,6 @@ class image implements Core{ else { try{ - // vérifier existence image $service = $this->libClass; $image = $service->getImage($id); if($image == null){ // if the image don't exists -> error @@ -389,8 +385,9 @@ class image implements Core{ private function uploadImage(){ $id = $this->app->getPostParam("id"); $file_name = $this->app->getPostParam("file_name"); - - + $file = $this->app->getPostParam("file"); + error_log(print_r($file, true), 0); + if(!isset($id)){ $this->app->setOutput("Error", "Incorrect id parameter"); } @@ -399,13 +396,12 @@ class image implements Core{ } else{ try{ - // vérifier existence image $service = $this->libClass; $image = $service->getImage($id); if($image == null){ // if the image don't exists -> error $this->app->setOutput("Error", "Image doesn't exist"); } - $stream = \GuzzleHttp\Psr7\stream_for(fopen($file_name, 'r')); + $stream = \GuzzleHttp\Psr7\stream_for($file); $image->uploadData($stream); }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); @@ -436,7 +432,6 @@ class image implements Core{ } else{ try{ - // vérifier existence image $service = $this->libClass; $image = $service->getImage($id); if($image == null){ // if the image don't exists -> error @@ -520,7 +515,6 @@ class image implements Core{ } else{ try{ - // vérifier existence image $service = $this->libClass; $image = $service->getImage($image_id); if($image == null){ // if the image don't exists -> error From 8e700c2b7de7a2bc095ea8edf3204f160f8a8941 Mon Sep 17 00:00:00 2001 From: Loic GUEGAN Date: Sun, 17 Apr 2016 18:42:15 +0200 Subject: [PATCH 49/71] Add comments and correct some bugs --- client/js/app.js | 2 +- client/js/controllers/home/home.js | 86 ++++++++++++++---------------- client/js/controllers/login.js | 6 ++- client/js/controllers/status.js | 20 ++++--- client/js/services/Compute.js | 2 - client/partials/home/home.html | 11 ++-- 6 files changed, 59 insertions(+), 68 deletions(-) diff --git a/client/js/app.js b/client/js/app.js index e911050..4ef35b5 100644 --- a/client/js/app.js +++ b/client/js/app.js @@ -25,7 +25,7 @@ mainApp.config(['$routeProvider', function($routeProvider){ controller: 'imageCtrl' }) .otherwise({ - redirectTo: '/' + redirectTo: '/home' }); }]); diff --git a/client/js/controllers/home/home.js b/client/js/controllers/home/home.js index 10142c9..7880e12 100755 --- a/client/js/controllers/home/home.js +++ b/client/js/controllers/home/home.js @@ -3,58 +3,52 @@ * * @param {$scope} $scope The $scope service from angular */ -mainApp.controller('homeCtrl', [ '$scope', 'Compute', '$rootScope', 'Loading','Identity', 'Image', function ($scope, Compute, $rootScope, Loading, Identity, Image) -{ +mainApp.controller('homeCtrl', ['$scope', 'Compute', '$rootScope', 'Loading', 'Identity', 'Image', function ($scope, Compute, $rootScope, Loading, Identity, Image) + { - var callMeAfterPullData=function(data){ - console.log(data); - $scope.machines=Compute.getData().machines; - Loading.stop(); - } + // Function to call after pull all data about machines + var callMeAfterPullData = function (data) { + $scope.machines = Compute.getData().machines; + Loading.stop(); + }; - ; - if(Compute.getData().machines == null && Identity.isAlreadyLogin()){ - Loading.start(); - Compute.pullData(callMeAfterPullData); - } - else{ - if(Identity.isAlreadyLogin()){ - callMeAfterPullData(); - } - } + // Function to call to try to retrieve data and update the view + var tryToRetrieveData = function () { + // If no data retrieve about machine and user is logged + if (Compute.getData().machines == null && Identity.isAlreadyLogin()) { + Loading.start(); // Show loading gif + Compute.pullData(callMeAfterPullData); // Retrieve data and call the callback + } else { + // Else if user is logged and data is already retrieve + // simply display data + if (Identity.isAlreadyLogin()) { + callMeAfterPullData(); // Display data + } + } + }; - Image.getImages(function(){}); + // On user login + $scope.$on('loginEvent', function () { + tryToRetrieveData(); + }); - $scope.raiseShowMachineDetailsEvent=function(id){ + // Function to call from view to display the details of a machine + $scope.raiseShowMachineDetailsEvent = function (id) { - var callback=function(){ - Loading.stop(); - var data=Compute.getData(); - $rootScope.$broadcast("showMachineDetailsEvent", data.machines[id], data.axioms); + // Stop loading gif and display overlay + var callback = function () { + Loading.stop(); + var data = Compute.getData(); + $rootScope.$broadcast("showMachineDetailsEvent", data.machines[id], data.axioms); - } - Loading.start(); - Compute.pullMachines(callback); - } - - - - - - if(Identity.isAlreadyLogin()){ - if(Compute.getData().machines == null){ - Loading.start(); - Compute.pullData(callMeAfterPullData); - } - else{ - if(Identity.isAlreadyLogin()){ - callMeAfterPullData(); - } - } - Image.getImages(function(){}); - } - -}]); + }; + Loading.start(); // Show loading gif + Compute.pullMachines(callback); // Retrieve machine info and display overlay + }; + + // Try to retrieve data for the first time + tryToRetrieveData(); + }]); diff --git a/client/js/controllers/login.js b/client/js/controllers/login.js index 93a373e..4a0de42 100644 --- a/client/js/controllers/login.js +++ b/client/js/controllers/login.js @@ -7,7 +7,7 @@ * @param {Identity} The Identity service */ -mainApp.controller('loginCtrl', ['$scope', '$sce', 'Identity', function ($scope, $sce, Identity) +mainApp.controller('loginCtrl', ['$scope', '$sce', 'Identity', '$rootScope', function ($scope, $sce, Identity, $rootScope) { // Check for login and define default states if (!Identity.isAlreadyLogin()) { @@ -51,12 +51,14 @@ mainApp.controller('loginCtrl', ['$scope', '$sce', 'Identity', function ($scope, } else { // Else the user is online ! $('#loginModal').modal('hide'); + // Send login event + $rootScope.$broadcast("loginEvent"); } // Reset button state $('#loginButton').show(); $('#loadingLoginButton').hide(); - } + }; // Try to login Identity.login(username, password, projectname, responseCallback); diff --git a/client/js/controllers/status.js b/client/js/controllers/status.js index 15850f4..c3e634b 100644 --- a/client/js/controllers/status.js +++ b/client/js/controllers/status.js @@ -6,16 +6,14 @@ * @param {$scope} $scope The $scope service from angular * @param {Identity} The Identity service */ -mainApp.controller('statusCtrl', ['$scope','Identity', '$rootScope', function ($scope, Identity, $rootScope) -{ +mainApp.controller('statusCtrl', ['$scope', 'Identity', '$rootScope', function ($scope, Identity, $rootScope) + { + // Give profile to model + $scope.profile = Identity.getProfile(); - - // Give profile to model - $scope.profile=Identity.getProfile(); - - // Function to logout - $scope.logout=function(){ - Identity.logout(); - }; + // Function to logout + $scope.logout = function () { + Identity.logout(); + }; -}]); + }]); diff --git a/client/js/services/Compute.js b/client/js/services/Compute.js index 2bf28d8..032b402 100644 --- a/client/js/services/Compute.js +++ b/client/js/services/Compute.js @@ -101,8 +101,6 @@ mainApp.factory('Compute',[ '$http', 'Identity', function($http, Identity){ // Wait and handle the response result.then(function (response){ - alert(Identity.getToken()); - callback(parsePullImagesAnswer(response, false)); },function(response){ diff --git a/client/partials/home/home.html b/client/partials/home/home.html index f9f8878..11958d2 100644 --- a/client/partials/home/home.html +++ b/client/partials/home/home.html @@ -1,12 +1,11 @@ -
+
Home
- - Pour charger les machines, recharger la page (temporaire)
- Selectionner une machine: - - + + Selectionner une machine: + +
From fdfdd27a35ebc22222361ed273b6889fec4cf51e Mon Sep 17 00:00:00 2001 From: Loic GUEGAN Date: Sun, 17 Apr 2016 18:43:49 +0200 Subject: [PATCH 50/71] Add ';' --- client/js/services/Compute.js | 245 +++++++++++++++++----------------- 1 file changed, 120 insertions(+), 125 deletions(-) diff --git a/client/js/services/Compute.js b/client/js/services/Compute.js index 032b402..5e95f22 100644 --- a/client/js/services/Compute.js +++ b/client/js/services/Compute.js @@ -1,145 +1,140 @@ -mainApp.factory('Compute',[ '$http', 'Identity', function($http, Identity){ +mainApp.factory('Compute', ['$http', 'Identity', function ($http, Identity) { - // Init data - var data={}; - data.machines=null; - data.axioms={} // Contain static data - data.axioms.ram=[128,512,1024,2048,4096]; - data.axioms.disk=[1,2,5,10,25,50,100,150,200] - data.axioms.images={}; // Retrieve after - - - /** - * Parse pullMachines answer - * @param {response} the server response - * @param {boolean} false if the request as been send true else - * @return {requestParserResult} the result of parsing - */ - var parsePullMachinesAnswer=function(response, failedToSendRequest){ - - // Defined return object - var requestParserResult={}; - requestParserResult.status=1; - requestParserResult.failReason=null; - - - if (typeof response.data.Servers !== 'undefined') { - // Set status code - requestParserResult.status=0; - data.machines=response.data.Servers; - - } - else if(failedToSendRequest){ - requestParserResult.failReason="Failed to send PullMachine request"; - } - else{ - requestParserResult.failReason="Error"; - } - return requestParserResult; - }; + // Init data + var data = {}; + data.machines = null; + data.axioms = {} // Contain static data + data.axioms.ram = [128, 512, 1024, 2048, 4096]; + data.axioms.disk = [1, 2, 5, 10, 25, 50, 100, 150, 200] + data.axioms.images = {}; // Retrieve after - /** - * Retrieve machine list - * @param {callback} function to call after request complete - */ - var pullMachines=function(callback){ - // Send listServers request - var result=$http.post('../server/index.php', - $.param({"token" : Identity.getToken(), "task" : "compute", "action":"listServers"})); + /** + * Parse pullMachines answer + * @param {response} the server response + * @param {boolean} false if the request as been send true else + * @return {requestParserResult} the result of parsing + */ + var parsePullMachinesAnswer = function (response, failedToSendRequest) { - // Wait and handle the response - result.then(function (response){ - callback(parsePullMachinesAnswer(response, false)); - },function(response){ - callback(parsePullMachinesAnswer(response, true)); - }); - }; + // Defined return object + var requestParserResult = {}; + requestParserResult.status = 1; + requestParserResult.failReason = null; - /** - * Parse pullImages answer - * @param {response} the server response - * @param {boolean} false if the request as been send true else - * @return {requestParserResult} the result of parsing - */ - var parsePullImagesAnswer=function(response, failedToSendRequest){ + if (typeof response.data.Servers !== 'undefined') { + // Set status code + requestParserResult.status = 0; + data.machines = response.data.Servers; - // Defined return object - var requestParserResult={}; - requestParserResult.status=1; - requestParserResult.failReason=null; + } else if (failedToSendRequest) { + requestParserResult.failReason = "Failed to send PullMachine request"; + } else { + requestParserResult.failReason = "Error"; + } + return requestParserResult; + }; - - if (typeof response.data.Images !== 'undefined') { - // Set status code - requestParserResult.status=0; - data.axioms.images=response.data.Images; - } - else if(failedToSendRequest){ - requestParserResult.failReason="Failed to send PullImage request"; - } - else{ - requestParserResult.failReason="Error"; - } - return requestParserResult; - }; + + /** + * Retrieve machine list + * @param {callback} function to call after request complete + */ + var pullMachines = function (callback) { + // Send listServers request + var result = $http.post('../server/index.php', + $.param({"token": Identity.getToken(), "task": "compute", "action": "listServers"})); + + // Wait and handle the response + result.then(function (response) { + callback(parsePullMachinesAnswer(response, false)); + }, function (response) { + callback(parsePullMachinesAnswer(response, true)); + }); + }; + + + /** + * Parse pullImages answer + * @param {response} the server response + * @param {boolean} false if the request as been send true else + * @return {requestParserResult} the result of parsing + */ + var parsePullImagesAnswer = function (response, failedToSendRequest) { + + // Defined return object + var requestParserResult = {}; + requestParserResult.status = 1; + requestParserResult.failReason = null; + + + if (typeof response.data.Images !== 'undefined') { + // Set status code + requestParserResult.status = 0; + data.axioms.images = response.data.Images; + } else if (failedToSendRequest) { + requestParserResult.failReason = "Failed to send PullImage request"; + } else { + requestParserResult.failReason = "Error"; + } + return requestParserResult; + }; - - /** - * Retrieve machine list - * @param {callback} function to call after request complete - */ - var pullImages=function(callback){ - // Send listServers request - var result=$http.post('../server/index.php', - $.param({"token" : Identity.getToken(), "task" : "compute", "action":"listImages"})); - // Wait and handle the response - result.then(function (response){ - callback(parsePullImagesAnswer(response, false)); - },function(response){ + /** + * Retrieve machine list + * @param {callback} function to call after request complete + */ + var pullImages = function (callback) { + // Send listServers request + var result = $http.post('../server/index.php', + $.param({"token": Identity.getToken(), "task": "compute", "action": "listImages"})); - callback(parsePullImagesAnswer(response, true)); - }); - }; + // Wait and handle the response + result.then(function (response) { + callback(parsePullImagesAnswer(response, false)); + }, function (response) { + + callback(parsePullImagesAnswer(response, true)); + }); + }; - /** - * Retrieve all data - * @param {callback} function to call after request complete - */ - var pullData=function(callback){ - var nextFunction=function(response){ - if(response.status==0){ - pullMachines(callback); - } - else{ - callback(response); - } - } - pullImages(nextFunction); - } + /** + * Retrieve all data + * @param {callback} function to call after request complete + */ + var pullData = function (callback) { + var nextFunction = function (response) { + if (response.status == 0) { + pullMachines(callback); + } else { + callback(response); + } + }; + pullImages(nextFunction); + }; - /** - * Get Data - * @return {data} return the data object - */ - var getData=function(){ - return data; - } - - // Return services objects - return { - pullMachines: pullMachines, - pullData: pullData, - getData: getData - }; + /** + * Get Data + * @return {data} return the data object + */ + var getData = function () { + return data; + }; - -}]); + // Return services objects + return { + pullMachines: pullMachines, + pullData: pullData, + getData: getData + }; + + + }]); From 968eda48cc8f3af2214e347e83937086c5e93ad4 Mon Sep 17 00:00:00 2001 From: Loic GUEGAN Date: Sun, 17 Apr 2016 18:44:29 +0200 Subject: [PATCH 51/71] Add ';' and correct indent --- client/js/services/Identity.js | 294 ++++++++++++++++----------------- 1 file changed, 146 insertions(+), 148 deletions(-) diff --git a/client/js/services/Identity.js b/client/js/services/Identity.js index 73e5d86..17678ed 100644 --- a/client/js/services/Identity.js +++ b/client/js/services/Identity.js @@ -1,170 +1,168 @@ -mainApp.factory('Identity',[ '$http', '$cookies', '$rootScope', function($http, $cookies, $rootScope){ +mainApp.factory('Identity', ['$http', '$cookies', '$rootScope', function ($http, $cookies, $rootScope) { - /* Create profile structure to store informations - * about current session - */ - var profile={}; - profile.username=null; - profile.projectname=null; - var token=null; - - - /* - * @returns {boolean} Return true if a cookie is found (and load it in profile) false else - */ - var isAlreadyLogin=function(){ - - // Load cookies - var profileInCookie=$cookies.getObject('profile'); - var tokenPart_0InCookie=$cookies.getObject('token.part_0'); - var tokenPart_1InCookie=$cookies.getObject('token.part_1'); - - - // Check if cookie is defined - if(typeof profileInCookie !== 'undefined' - && typeof tokenPart_0InCookie !== 'undefined' - && typeof tokenPart_1InCookie !== 'undefined' - ){ - - //if(token!==null){ - // If yes, put it into variables - angular.extend(profile, profileInCookie); - token=tokenPart_0InCookie+tokenPart_1InCookie; - //} - - // Return I'm Login - return true; - } - - // Show the login overlay - $rootScope.$broadcast("logoutEvent"); - - // Return I'm not Login - return false; - } + /* Create profile structure to store informations + * about current session + */ + var profile = {}; + profile.username = null; + profile.projectname = null; + var token = null; - - /* - * Destroy profile cookies - */ - var logout=function(){ - $cookies.remove('profile'); - $cookies.remove('token.part_0'); - $cookies.remove('token.part_1'); - token=null; - profile.username=null; - profile.projectname=null; + /* + * @returns {boolean} Return true if a cookie is found (and load it in profile) false else + */ + var isAlreadyLogin = function () { - // Reload Page - //location.reload(); - $rootScope.$broadcast("logoutEvent"); + // Load cookies + var profileInCookie = $cookies.getObject('profile'); + var tokenPart_0InCookie = $cookies.getObject('token.part_0'); + var tokenPart_1InCookie = $cookies.getObject('token.part_1'); - } - - /** - * - * @param {string} response The response to parse - * @param {boolean} to check if the request is send or not - * @returns {requestParserResult} Formated data - */ - var parseLoginAnswer=function(response, failedToSendRequest){ - - // Defined return object - var requestParserResult={}; - requestParserResult.status=1; - requestParserResult.failReason=null; + // Check if cookie is defined + if (typeof profileInCookie !== 'undefined' + && typeof tokenPart_0InCookie !== 'undefined' + && typeof tokenPart_1InCookie !== 'undefined' + ) { - if (typeof response.data.token !== 'undefined') { - // Set status code - requestParserResult.status=0; + //if(token!==null){ + // If yes, put it into variables + angular.extend(profile, profileInCookie); + token = tokenPart_0InCookie + tokenPart_1InCookie; + //} - // Find the middle of the token to split it - var middle=parseInt(response.data.token.length/2); + // Return I'm Login + return true; + } - // Create expire date (cookie expire in 55 mins) - var expireDate=new Date(); - expireDate.setMinutes(expireDate.getMinutes()+55); - - // Save profile - $cookies.putObject('profile', profile, {'expires': expireDate}); - // Save first part of token - $cookies.putObject('token.part_0', response.data.token.substring(0, middle), {'expires': expireDate}); - // Save second part of token - $cookies.putObject('token.part_1', response.data.token.substring(middle, response.data.token.length), {'expires': expireDate}); + // Show the login overlay + $rootScope.$broadcast("logoutEvent"); - // Put token in var - token=response.data.token; - - } - else if(failedToSendRequest){ - requestParserResult.failReason="Failed to send request"; - } - else{ - requestParserResult.failReason="Please check your username, password and project name !"; - } + // Return I'm not Login + return false; + }; - - return requestParserResult; - }; - - /** - * Function to connect to OpenStack - * - * @param {object} $http Angular $http service - * @param {string} username The user name - * @param {string} password The user password - * @param {string} projectname The user project name - * @param {function} function to call when data is avalaible - */ - var login=function(username, password,projectname,callback){ - - // Set profile information (early) - profile.username=username; - profile.projectname=projectname; - - var result=$http.post('../server/index.php', - $.param({"task" : "Authenticate", "user" : username, "password" : password, "project" : projectname})); - // Wait and handle the response - result.then(function (response){ - callback(parseLoginAnswer(response, false)); - },function(response){ - callback(parseLoginAnswer(response, true)); - }); - }; + /* + * Destroy profile cookies + */ + var logout = function () { + $cookies.remove('profile'); + $cookies.remove('token.part_0'); + $cookies.remove('token.part_1'); + token = null; + profile.username = null; + profile.projectname = null; + + // Reload Page + //location.reload(); + $rootScope.$broadcast("logoutEvent"); + + }; + + + /** + * + * @param {string} response The response to parse + * @param {boolean} to check if the request is send or not + * @returns {requestParserResult} Formated data + */ + var parseLoginAnswer = function (response, failedToSendRequest) { + + // Defined return object + var requestParserResult = {}; + requestParserResult.status = 1; + requestParserResult.failReason = null; + + if (typeof response.data.token !== 'undefined') { + // Set status code + requestParserResult.status = 0; + + // Find the middle of the token to split it + var middle = parseInt(response.data.token.length / 2); + + // Create expire date (cookie expire in 55 mins) + var expireDate = new Date(); + expireDate.setMinutes(expireDate.getMinutes() + 55); + + // Save profile + $cookies.putObject('profile', profile, {'expires': expireDate}); + // Save first part of token + $cookies.putObject('token.part_0', response.data.token.substring(0, middle), {'expires': expireDate}); + // Save second part of token + $cookies.putObject('token.part_1', response.data.token.substring(middle, response.data.token.length), {'expires': expireDate}); + + // Put token in var + token = response.data.token; + + } else if (failedToSendRequest) { + requestParserResult.failReason = "Failed to send request"; + } else { + requestParserResult.failReason = "Please check your username, password and project name !"; + } + + + return requestParserResult; + }; + + + /** + * Function to connect to OpenStack + * + * @param {object} $http Angular $http service + * @param {string} username The user name + * @param {string} password The user password + * @param {string} projectname The user project name + * @param {function} function to call when data is avalaible + */ + var login = function (username, password, projectname, callback) { + + // Set profile information (early) + profile.username = username; + profile.projectname = projectname; + + var result = $http.post('../server/index.php', + $.param({"task": "Authenticate", "user": username, "password": password, "project": projectname})); + + // Wait and handle the response + result.then(function (response) { + callback(parseLoginAnswer(response, false)); + }, function (response) { + callback(parseLoginAnswer(response, true)); + }); + }; - - /* - * Get the profile - */ - var getProfile=function(){ - return profile; - } - /* - * Get the token - */ - var getToken=function(){ - return token; - } + /* + * Get the profile + */ + var getProfile = function () { + return profile; + }; - + /* + * Get the token + */ + var getToken = function () { + return token; + }; - // Return services objects - return { - login: login, - getProfile: getProfile, - isAlreadyLogin: isAlreadyLogin, - logout:logout, - getToken:getToken - }; - -}]); + + // Return services objects + return { + login: login, + getProfile: getProfile, + isAlreadyLogin: isAlreadyLogin, + logout: logout, + getToken: getToken + }; + + + }]); From bb1598713c0b6bbe39209c14681c759ab9907edc Mon Sep 17 00:00:00 2001 From: Loic GUEGAN Date: Sun, 17 Apr 2016 18:50:05 +0200 Subject: [PATCH 52/71] Clean code, add comment etc.. --- client/js/controllers/home/machineDetails.js | 65 +++---- client/js/controllers/image/image.js | 34 ++-- client/js/controllers/image/upload.js | 108 +++++------ client/js/controllers/network/network.js | 1 + client/js/services/Image.js | 188 ++++++++++--------- client/js/services/Loading.js | 45 ++--- client/js/services/Network.js | 42 +++-- 7 files changed, 251 insertions(+), 232 deletions(-) diff --git a/client/js/controllers/home/machineDetails.js b/client/js/controllers/home/machineDetails.js index 371310b..9c8c602 100644 --- a/client/js/controllers/home/machineDetails.js +++ b/client/js/controllers/home/machineDetails.js @@ -3,42 +3,43 @@ * * @param {$scope} $scope The $scope service from angular */ -mainApp.controller('machineDetailsCtrl', [ '$scope', 'Compute', '$rootScope', '$timeout', 'Identity', function ($scope, Compute, $rootScope, $timeout, Identity) -{ +mainApp.controller('machineDetailsCtrl', ['$scope', 'Compute', '$rootScope', '$timeout', 'Identity', function ($scope, Compute, $rootScope, $timeout, Identity) + { - // Init scope - $scope.machine={}; - $scope.machineIsStarting=false; // For loading icon + // Init scope + $scope.machine = {}; + $scope.machineIsStarting = false; // For loading icon + + // When we need to show details of machine + $scope.$on('showMachineDetailsEvent', function (eventName, machine, axioms) { + $scope.machine = machine; + $scope.axioms = axioms; + $('#machineDetailsModal').modal({backdrop: false, keyboard: true}); + }); + + // Try to stop or start a machine + $scope.toggleMachineState = function () { + // Display gif + $scope.machineIsStarting = true; + + // Fake timeout + $timeout(function () { + $scope.machineIsStarting = false; + }, 3000); + $timeout(function () { + $scope.machine.online = !$scope.machine.online; + + }, 3000); - $scope.$on('showMachineDetailsEvent', function(eventName ,machine, axioms){ - $scope.machine=machine; - $scope.axioms=axioms; - $('#machineDetailsModal').modal({backdrop: false, keyboard: true}); - }); + }; + + // Apply modifications + $scope.applyModifications = function () { + //Todo + }; - $scope.toggleMachineState=function(){ - // Display gif - $scope.machineIsStarting=true; - // Fake timeout - $timeout(function(){ - $scope.machineIsStarting=false; - }, 3000); - $timeout(function(){ - $scope.machine.online=!$scope.machine.online; - - }, 3000); - - - }; - - $scope.applyModifications=function(){ - //Todo - } - - - -}]); + }]); diff --git a/client/js/controllers/image/image.js b/client/js/controllers/image/image.js index d9a9c06..d0578d7 100644 --- a/client/js/controllers/image/image.js +++ b/client/js/controllers/image/image.js @@ -4,23 +4,21 @@ * @param {$scope} $scope The $scope service from angular */ mainApp.controller('imageCtrl', ['$scope', 'Image', 'Loading', 'Identity', function ($scope, Image, Loading, Identity) -{ + { - var callbackTest=function(){ - $scope.images=Image.getData().images; - Loading.stop(); - }; + // Update view + var callMeAfterGetImage = function () { + $scope.images = Image.getData().images; + Loading.stop(); + }; - - if(Identity.isAlreadyLogin()){ - - if(Image.getData().images==null){ - Loading.start(); - Image.getImages(callbackTest); - } - else{ - callbackTest(); - } - - } -}]); + // If user is login try to retrieve data + if (Identity.isAlreadyLogin()) { + if (Image.getData().images == null) { + Loading.start(); + Image.getImages(callMeAfterGetImage); + } else { + callMeAfterGetImage(); + } + } + }]); diff --git a/client/js/controllers/image/upload.js b/client/js/controllers/image/upload.js index d9587d0..6737269 100644 --- a/client/js/controllers/image/upload.js +++ b/client/js/controllers/image/upload.js @@ -3,58 +3,60 @@ * * @param {$scope} $scope The $scope service from angular */ -mainApp.controller('uploadImageCtrl', ['$scope', 'Image', 'Loading', 'Identity', 'upload', function ($scope, Image, Loading, Identity,upload) -{ +mainApp.controller('uploadImageCtrl', ['$scope', 'Image', 'Loading', 'Identity', 'upload', function ($scope, Image, Loading, Identity, upload) + { /*$scope.uploader = new FileUploader({ - "token" : Identity.getToken(), - "task" : "image", - 'action':'uploadImage', - 'id':'6564' - }); - $scope.uploader.url='../server/index.php' - $scope.uploader.alias='file_name' - $scope.uploader.formData={ - "token" : Identity.getToken(), - "task" : "image", - 'action':'uploadImage', - 'id':'6564' - } - */ + "token" : Identity.getToken(), + "task" : "image", + 'action':'uploadImage', + 'id':'6564' + }); + $scope.uploader.url='../server/index.php' + $scope.uploader.alias='file_name' + $scope.uploader.formData={ + "token" : Identity.getToken(), + "task" : "image", + 'action':'uploadImage', + 'id':'6564' + } + */ - $scope.doUpload = function () { - console.log($('#imageToUpload').prop('files')[0]); - Image.uploadImage($('#imageToUpload').prop('files')[0], function(){alert("done")}) - /*$("#drop-area-div").dmUploader({ - extraData: { - "token" : Identity.getToken(), - "task" : "image", - 'action':'uploadImage', - 'id':'6564'}, - url:"../server/index.php" - }); - */ - - /*upload({ - url: '../server/index.php', - method: 'POST', - data: { - "token" : Identity.getToken(), - "task" : "image", - 'action':'uploadImage', - 'id':'6564', - "file_name": $scope.myFile, // a jqLite type="file" element, upload() will extract all the files from the input and put them into the FormData object before sending. - } - }).then( - function (response) { - console.log(response.data); // will output whatever you choose to return from the server on a successful upload - }, - function (response) { - console.error(response); // Will return if status code is above 200 and lower than 300, same as $http - } - );*/ - - - }; - - $scope.token=Identity.getToken(); -}]); + $scope.doUpload = function () { + console.log($('#imageToUpload').prop('files')[0]); + Image.uploadImage($('#imageToUpload').prop('files')[0], function () { + alert("done") + }) + /*$("#drop-area-div").dmUploader({ + extraData: { + "token" : Identity.getToken(), + "task" : "image", + 'action':'uploadImage', + 'id':'6564'}, + url:"../server/index.php" + }); + */ + + /*upload({ + url: '../server/index.php', + method: 'POST', + data: { + "token" : Identity.getToken(), + "task" : "image", + 'action':'uploadImage', + 'id':'6564', + "file_name": $scope.myFile, // a jqLite type="file" element, upload() will extract all the files from the input and put them into the FormData object before sending. + } + }).then( + function (response) { + console.log(response.data); // will output whatever you choose to return from the server on a successful upload + }, + function (response) { + console.error(response); // Will return if status code is above 200 and lower than 300, same as $http + } + );*/ + + + }; + + $scope.token = Identity.getToken(); + }]); diff --git a/client/js/controllers/network/network.js b/client/js/controllers/network/network.js index 7264aec..f600f83 100644 --- a/client/js/controllers/network/network.js +++ b/client/js/controllers/network/network.js @@ -5,4 +5,5 @@ */ mainApp.controller('networkCtrl', function ($scope) { + }); \ No newline at end of file diff --git a/client/js/services/Image.js b/client/js/services/Image.js index 4947a1d..795f85e 100644 --- a/client/js/services/Image.js +++ b/client/js/services/Image.js @@ -1,102 +1,114 @@ -mainApp.factory('Image',[ '$http', 'Identity', function($http, Identity){ +mainApp.factory('Image', ['$http', 'Identity', function ($http, Identity) { - var data={}; - data.images=null; + // Data object + var data = {}; + data.images = null; // Images + + /** + * Parse uploadImage anwser + * @param {type} response + * @param {type} failedToSendRequest + * @returns {Image_L2.parseUploadImageAnswer.requestParserResult} + */ + var parseUploadImageAnswer = function (response, failedToSendRequest) { + + // Defined return object + var requestParserResult = {}; + requestParserResult.status = 1; + requestParserResult.failReason = null; - var parseUploadImageAnswer=function(response, failedToSendRequest){ + if (typeof response.data.Images !== 'undefined') { + // Set status code + requestParserResult.status = 0; + data.images = response.data.Images; - // Defined return object - var requestParserResult={}; - requestParserResult.status=1; - requestParserResult.failReason=null; - - - if (typeof response.data.Images !== 'undefined') { - // Set status code - requestParserResult.status=0; - data.images=response.data.Images; - - } - else if(failedToSendRequest){ - requestParserResult.failReason="Failed to send request"; - } - else{ - requestParserResult.failReason="Error"; - } - return requestParserResult; - }; + } else if (failedToSendRequest) { + requestParserResult.failReason = "Failed to send request"; + } else { + requestParserResult.failReason = "Error"; + } + return requestParserResult; + }; - var getImages=function(callback){ + /** + * Get images + * @param {type} callback + * @returns {undefined} + */ + var getImages = function (callback) { - var result=$http.post('../server/index.php', - $.param({"token" : Identity.getToken(), "task" : "image", 'action':'listImage'})); + var result = $http.post('../server/index.php', + $.param({"token": Identity.getToken(), "task": "image", 'action': 'listImage'})); - // Wait and handle the response - result.then(function (response){ - callback(parseUploadImageAnswer(response, false)); - },function(response){ - callback(parseUploadImageAnswer(response, true)); - }); - - - }; - - var uploadImage=function(fileToUpload, callback) { - var form_data = new FormData(); - form_data.append('file', fileToUpload); - console.log(fileToUpload); - form_data.append("task" , "image"); - form_data.append("token" , Identity.getToken()); - form_data.append('action',"uploadImage"); - form_data.append('id','6564'); - 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, - token : Identity.getToken(), - task : "image", - action:'uploadImage', - id:'6564', - contentType: false, // The content type used when sending data to the server. - cache: false, // To unable request pages to be cached - processData:false, // To send DOMDocument or non processed data file it is set to false - success: function(data) // A function to be called if request succeeds - { - alert("success"); - } - }); - - //var result=$http.post('../server/index.php', - // $.param({"token" : Identity.getToken(), "task" : "image", 'action':'uploadImage', 'file_name':form_data, 'id':'6564'})); - - // Wait and handle the response - /* result.then(function (response){ - callback(parseUploadImageAnswer(response, false)); - },function(response){ - callback(parseUploadImageAnswer(response, true)); - });*/ + // Wait and handle the response + result.then(function (response) { + callback(parseUploadImageAnswer(response, false)); + }, function (response) { + callback(parseUploadImageAnswer(response, true)); + }); - - } + }; + + /** + * Upload an image + * @param {type} fileToUpload + * @param {type} callback + * @returns {undefined} + */ + var uploadImage = function (fileToUpload, callback) { + var form_data = new FormData(); + form_data.append('file', fileToUpload); + console.log(fileToUpload); + form_data.append("task", "image"); + form_data.append("token", Identity.getToken()); + form_data.append('action', "uploadImage"); + form_data.append('id', '6564'); + 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, + token: Identity.getToken(), + task: "image", + action: 'uploadImage', + id: '6564', + contentType: false, // The content type used when sending data to the server. + cache: false, // To unable request pages to be cached + processData: false, // To send DOMDocument or non processed data file it is set to false + success: function (data) // A function to be called if request succeeds + { + alert("success"); + } + }); + + //var result=$http.post('../server/index.php', + // $.param({"token" : Identity.getToken(), "task" : "image", 'action':'uploadImage', 'file_name':form_data, 'id':'6564'})); + + // Wait and handle the response + /* result.then(function (response){ + callback(parseUploadImageAnswer(response, false)); + },function(response){ + callback(parseUploadImageAnswer(response, true)); + });*/ + }; - var getData=function(response){ - return data; - }; - - // Return services objects - return { - getImages:getImages, - getData:getData, - uploadImage:uploadImage - }; + var getData = function (response) { + return data; + }; - -}]); + // Return services objects + return { + getImages: getImages, + getData: getData, + uploadImage: uploadImage + }; + + + }]); diff --git a/client/js/services/Loading.js b/client/js/services/Loading.js index db06194..7ea2b42 100644 --- a/client/js/services/Loading.js +++ b/client/js/services/Loading.js @@ -1,23 +1,26 @@ +/** + * Loading service + * @param {type} param1 + * @param {type} param2 + */ +mainApp.factory('Loading', [function () { + /** + * Display Loading modal + */ + var start = function () { + $('#loadingModal').modal({backdrop: 'static', keyboard: false}); + }; -mainApp.factory('Loading',[ function(){ - /** - * Display Loading modal - */ - var start=function(){ - $('#loadingModal').modal({backdrop: 'static', keyboard: false}); - }; + /** + * Hide Loading modal + */ + var stop = function () { + $('#loadingModal').modal('hide'); + }; - /** - * Hide Loading modal - */ - var stop=function(){ - $('#loadingModal').modal('hide'); - } - - - // Service returns - return { - start:start, - stop:stop - }; -}]); + // Service returns + return { + start: start, + stop: stop + }; + }]); diff --git a/client/js/services/Network.js b/client/js/services/Network.js index bd2a24f..a0cd5a4 100644 --- a/client/js/services/Network.js +++ b/client/js/services/Network.js @@ -1,27 +1,29 @@ -mainApp.factory('Network',[ '$http', 'Identity', function($http, Identity){ +mainApp.factory('Network', ['$http', 'Identity', function ($http, Identity) { - var data={}; - data.networks=null; + // Data object + var data = {}; + data.networks = null; // Networks -var ListId=function(fileToUpload, callback) { + /** + * ListId + * @param {type} fileToUpload + * @param {type} callback + * @returns {undefined} + */ + var ListId = function (fileToUpload, callback) { + var result = $http.post('../server/index.php', + $.param({"token": Identity.getToken(), "task": "network", 'action': 'list_network_ids'})); + + // Wait and handle the response + result.then(function (response) { + callback(parseUploadImageAnswer(response, false)); + }, function (response) { + callback(parseUploadImageAnswer(response, true)); + }); + }; - var result=$http.post('../server/index.php', - $.param({"token" : Identity.getToken(), "task" : "network", 'action':'list_network_ids'})); - - // Wait and handle the response - result.then(function (response){ - callback(parseUploadImageAnswer(response, false)); - },function(response){ - callback(parseUploadImageAnswer(response, true)); - }); - - console.log(result) - - } - - -}]); + }]); From 9e7eb6774b823c1716ec14476ac8e53d758143ab Mon Sep 17 00:00:00 2001 From: Yoggzo Date: Mon, 18 Apr 2016 17:20:27 +0200 Subject: [PATCH 53/71] begining of floating ip --- server/Test/AppTestClass.php | 6 ++ server/core/FloatingIp.php | 195 +++++++++++++++++++++++++++++++++++ 2 files changed, 201 insertions(+) create mode 100644 server/core/FloatingIp.php diff --git a/server/Test/AppTestClass.php b/server/Test/AppTestClass.php index a663514..d2f71e7 100755 --- a/server/Test/AppTestClass.php +++ b/server/Test/AppTestClass.php @@ -118,6 +118,12 @@ class AppTest{ return $this->errorClass; } + + public function getOutput($key){ + + return $this->output[$key]; + + } } diff --git a/server/core/FloatingIp.php b/server/core/FloatingIp.php new file mode 100644 index 0000000..72ae836 --- /dev/null +++ b/server/core/FloatingIp.php @@ -0,0 +1,195 @@ +app->setOutput("Error", "Incorrect parameter app"); + } + $this->app = $app; + $this->libClass = $app->getLibClass("FloatingIp"); + } + + + /** + * Execute an action + * + * @param String $action name of another function of this class + * + * @return void + */ + public function action($action){ + $this->{$action.""}(); + } + + /** + * Create a new floating IP adress + * + * @param array $opt Options for the floating ip creation (floatingipo and floating network id are required, others are optionals) + * + * @return floatingip + */ + private function createFloatingIp(){ + $opt = $this->app->getPostParam("opt"); + + if(!isset($opt)){ + $this->app->setOutput("Error", "Incorrect parameter opt"); + } + try{ + $floatingip = $this->libClass->create($opt); + if(!isset){ + $this->app->setOutput("Error", "Unknowing error during floating ip creation"); + } + else{ + $this->app->setOutput("FloatingIp", $floatingip); + } + }catch(BadResponseError $e){ + $this->app->getErrorInstance()->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance()->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance()->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance()->NotImplementedHandler($e); + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } + } + + /** + * Update floating ip + * + * @param id the id of the floatingip to update + * + * @return Image + */ + private function updateFloatingIp(){ + $id = $this->app->getPostParam("id"); + + if(!isset($id)){ + $this->app->setOutput("Error", "Incorrect parameter opt"); + } + try{ + $floatingip = null; //obtenir ip + + $floatingip->update(); + + if(!isset){ + $this->app->setOutput("Error", "Unknowing error during floating ip creation"); + } + }catch(BadResponseError $e){ + $this->app->getErrorInstance()->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance()->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance()->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance()->NotImplementedHandler($e); + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } + } + + /** + * Delete a floating ip + * + * @param string floatingip_id the floating-ip id to delete + * + * @return void + */ + private function deleteFloatingIp(){ + $id = $this->app->getPostParam("id"); + + if(!isset($id)){ + $this->app->setOutput("Error", "Incorrect parameter opt"); + } + try{ + $floatingip = null; //obtenir ip + + $floatingip->delete(); + + if(!isset){ + $this->app->setOutput("Error", "Unknowing error during floating ip creation"); + } + }catch(BadResponseError $e){ + $this->app->getErrorInstance()->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance()->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance()->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance()->NotImplementedHandler($e); + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } + } + + /** + * Retrieve a floating ip + * + * @param string floatingip_id the floating-ip id to retrieve + * + * @return void + */ + private function retrieveFloatingIp(){ + $id = $this->app->getPostParam("id"); + + if(!isset($id)){ + $this->app->setOutput("Error", "Incorrect parameter opt"); + } + try{ + $floatingip = null; //obtenir ip + + $floatingip->retrieve(); + + if(!isset){ + $this->app->setOutput("Error", "Unknowing error during floating ip creation"); + } + }catch(BadResponseError $e){ + $this->app->getErrorInstance()->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance()->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance()->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance()->NotImplementedHandler($e); + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } + } +} From e1b15c38d7f3bd158d477537bb26256baa7565a8 Mon Sep 17 00:00:00 2001 From: Yoggzo Date: Mon, 18 Apr 2016 17:38:25 +0200 Subject: [PATCH 54/71] begining of automating --- server/Test/AppTestClass.php | 6 --- server/core/Automating.php | 75 ++++++++++++++++++++---------------- 2 files changed, 41 insertions(+), 40 deletions(-) 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(); + } } + } ?> From 71794b98c560fa7904a4b3550a21b64ec6cd9339 Mon Sep 17 00:00:00 2001 From: EoleDev Date: Mon, 18 Apr 2016 20:01:50 +0200 Subject: [PATCH 55/71] Add floating request --- server/core/FloatingIp.php | 2 +- server/index.php | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) mode change 100644 => 100755 server/core/FloatingIp.php diff --git a/server/core/FloatingIp.php b/server/core/FloatingIp.php old mode 100644 new mode 100755 index 72ae836..4271a84 --- a/server/core/FloatingIp.php +++ b/server/core/FloatingIp.php @@ -22,7 +22,7 @@ include("CoreInterface.php"); * Management of images * */ -class FloatingIp implements Core{ +class floatingIp implements Core{ /** @var App $app protected, contains the main app object */ protected $app; diff --git a/server/index.php b/server/index.php index d6b0329..ac66c95 100755 --- a/server/index.php +++ b/server/index.php @@ -52,6 +52,13 @@ $computeObject->action($action); $App->show(); break; + + case "floatingip": + include_once("core/FloatingIp.php"); + $computeObject = new floatingIp($App); + $computeObject->action($action); + $App->show(); + break; } }else{ From 2d260aa6f591030f869063ccdb1f6997d12c1294 Mon Sep 17 00:00:00 2001 From: Yoggzo Date: Tue, 19 Apr 2016 17:17:14 +0200 Subject: [PATCH 56/71] correct syntaxt on Network, add tests for automating --- server/Test/automatingTests.php | 24 ++++++++++++++++++++++++ server/core/FloatingIp.php | 33 ++++++++++++++++++++++++++++++--- server/core/Network.php | 10 ++++------ 3 files changed, 58 insertions(+), 9 deletions(-) create mode 100644 server/Test/automatingTests.php diff --git a/server/Test/automatingTests.php b/server/Test/automatingTests.php new file mode 100644 index 0000000..5cdee26 --- /dev/null +++ b/server/Test/automatingTests.php @@ -0,0 +1,24 @@ +listServers(); + +$servers = json_decode($App->show(), true)["Servers"]; + +foreach($servers as $server){ + echo $server->name." ".$server->id."
"; +} + +?> \ No newline at end of file diff --git a/server/core/FloatingIp.php b/server/core/FloatingIp.php index 4271a84..c5a947e 100755 --- a/server/core/FloatingIp.php +++ b/server/core/FloatingIp.php @@ -105,7 +105,16 @@ class floatingIp implements Core{ $this->app->setOutput("Error", "Incorrect parameter opt"); } try{ - $floatingip = null; //obtenir ip + $floatingips = listFloatingIps(); + $floatingIp = null; + foreach ($floatingips as $f) { + if($f['id'] == $id){ + $floatingIp = $f; + } + } + if(!isset($floatingIp)){ + $this->app->setOutput("Error", "Unknowing floatingip id"); + } $floatingip->update(); @@ -139,7 +148,16 @@ class floatingIp implements Core{ $this->app->setOutput("Error", "Incorrect parameter opt"); } try{ - $floatingip = null; //obtenir ip + $floatingips = listFloatingIps(); + $floatingIp = null; + foreach ($floatingips as $f) { + if($f['id'] == $id){ + $floatingIp = $f; + } + } + if(!isset($floatingIp)){ + $this->app->setOutput("Error", "Unknowing floatingip id"); + } $floatingip->delete(); @@ -173,7 +191,16 @@ class floatingIp implements Core{ $this->app->setOutput("Error", "Incorrect parameter opt"); } try{ - $floatingip = null; //obtenir ip + $floatingips = listFloatingIps(); + $floatingIp = null; + foreach ($floatingips as $f) { + if($f['id'] == $id){ + $floatingIp = $f; + } + } + if(!isset($floatingIp)){ + $this->app->setOutput("Error", "Unknowing floatingip id"); + } $floatingip->retrieve(); diff --git a/server/core/Network.php b/server/core/Network.php index ad0cbaf..fef3512 100755 --- a/server/core/Network.php +++ b/server/core/Network.php @@ -333,8 +333,7 @@ class network{ * retrieve a specific network * @param networkId ID of network which we want to get * @return Network - */ - retrieve a specific network + */ private function getNetwork() { $network=""; @@ -592,7 +591,6 @@ class network{ * Delete a network given * * @param String networkId ID if network which we want to delete - * * * @return void @@ -627,7 +625,6 @@ class network{ * Delete a subnet given * * @param String subnetId ID if network which we want to delete - * * * @return void @@ -1187,7 +1184,7 @@ class network{ * @return void */ private function deleteSecurityGroupe() - { + { try { @@ -1210,4 +1207,5 @@ class network{ { $this->app->getErrorInstance->NotImplementedHandler($e); } - } + } +} From 3795d05a97dd144073d466be1ed0fd144683d8df Mon Sep 17 00:00:00 2001 From: Yoggzo Date: Tue, 19 Apr 2016 18:00:37 +0200 Subject: [PATCH 57/71] trying test floatingip --- server/Test/AppTestClass.php | 5 ++++ server/Test/automatingTests.php | 22 +++++++++------ server/core/FloatingIp.php | 50 +++++++++++++++++++++++---------- 3 files changed, 53 insertions(+), 24 deletions(-) diff --git a/server/Test/AppTestClass.php b/server/Test/AppTestClass.php index a663514..eaea7f6 100755 --- a/server/Test/AppTestClass.php +++ b/server/Test/AppTestClass.php @@ -63,6 +63,11 @@ class AppTest{ $opt = $this->tokenClass->getOptions($service); return $this->openstack->networkingV2($opt); break; + case "FloatingIp": + if($this->tokenPost == NULL) $this->tokenClass->genNetworkToken(); + $opt = $this->tokenClass->getOptions($service); + return $this->openstack->networkingV2ExtLayer3($opt); + break; } } diff --git a/server/Test/automatingTests.php b/server/Test/automatingTests.php index 5cdee26..6de4de5 100644 --- a/server/Test/automatingTests.php +++ b/server/Test/automatingTests.php @@ -2,23 +2,27 @@ include('InitTest.php'); include_once("../core/Image.php"); include_once("../core/Compute.php"); -include_once("../core/Network.php"); +//include_once("../core/Network.php"); +//include_once("../core/Automating.php"); include_once("../core/FloatingIp.php"); -include_once("../core/Automating.php"); $image = new Image($App); $compute = new Compute($App); -$network = new Network($App); +//$network = new Network($App); $floatingIp = new FloatingIp($App); -$automating = new Automating($App); - - -$compute->listServers(); +//$automating = new Automating($App); +// Liste des serveurs +$compute->action("listServers"); $servers = json_decode($App->show(), true)["Servers"]; - foreach($servers as $server){ - echo $server->name." ".$server->id."
"; + echo $server['name']." ".$server['id']."
"; } +// liste des floatingip +$floatingIp->action("listFloatingIp"); +$listFloatingIp = json_decode($App->show(), true)["FloatingIp"]; +foreach ($listFloatingIp as $floatIp){ + echo $floatIp['floating_ip_address']." ".$floatIp['id']." ".$floatIp["status"]."
"; +} ?> \ No newline at end of file diff --git a/server/core/FloatingIp.php b/server/core/FloatingIp.php index c5a947e..bbcd888 100755 --- a/server/core/FloatingIp.php +++ b/server/core/FloatingIp.php @@ -14,7 +14,7 @@ use OpenCloud\Common\Error\BaseError; use OpenCloud\Common\Error\NotImplementedError; use OpenCloud\Common\Error\UserInputError; -include("CoreInterface.php"); +//include("CoreInterface.php"); /** * Image Class of the back-end application @@ -22,7 +22,7 @@ include("CoreInterface.php"); * Management of images * */ -class floatingIp implements Core{ +class floatingIp { /** @var App $app protected, contains the main app object */ protected $app; @@ -31,11 +31,11 @@ class floatingIp implements Core{ protected $libClass; /** - * Image constructor + * floatingip constructor * * @param App $app the main app object * - * @return Image + * @return floatingip */ public function __construct($app){ if(!isset($app)){ @@ -57,6 +57,36 @@ class floatingIp implements Core{ $this->{$action.""}(); } + + /** + * List floatingip + * + * @return list of the floatingip + */ + private function listFloatingIp(){ + try{ + $result = array(); + $l = $this->libClass->getFloatingIps(); + + + + foreach ($l as $tmp) { + $serult[] = $tmp; + } + $this->app->setOutput("FloatingIp", $result); + }catch(BadResponseError $e){ + $this->app->getErrorInstance()->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance()->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance()->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance()->NotImplementedHandler($e); + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } + } + /** * Create a new floating IP adress * @@ -72,7 +102,7 @@ class floatingIp implements Core{ } try{ $floatingip = $this->libClass->create($opt); - if(!isset){ + if(!isset($floatingip)){ $this->app->setOutput("Error", "Unknowing error during floating ip creation"); } else{ @@ -118,9 +148,6 @@ class floatingIp implements Core{ $floatingip->update(); - if(!isset){ - $this->app->setOutput("Error", "Unknowing error during floating ip creation"); - } }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); }catch(UserInputError $e){ @@ -161,9 +188,6 @@ class floatingIp implements Core{ $floatingip->delete(); - if(!isset){ - $this->app->setOutput("Error", "Unknowing error during floating ip creation"); - } }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); }catch(UserInputError $e){ @@ -203,10 +227,6 @@ class floatingIp implements Core{ } $floatingip->retrieve(); - - if(!isset){ - $this->app->setOutput("Error", "Unknowing error during floating ip creation"); - } }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); }catch(UserInputError $e){ From 6a3f770c762de4decfbb483bb8212ea44ffc44d1 Mon Sep 17 00:00:00 2001 From: Yoggzo Date: Tue, 19 Apr 2016 18:27:27 +0200 Subject: [PATCH 58/71] add init FloatingIp --- server/Test/AppTestClass.php | 2 +- server/core/App.php | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/server/Test/AppTestClass.php b/server/Test/AppTestClass.php index eaea7f6..d8a02ca 100755 --- a/server/Test/AppTestClass.php +++ b/server/Test/AppTestClass.php @@ -65,7 +65,7 @@ class AppTest{ break; case "FloatingIp": if($this->tokenPost == NULL) $this->tokenClass->genNetworkToken(); - $opt = $this->tokenClass->getOptions($service); + $opt = $this->tokenClass->getOptions('Network'); return $this->openstack->networkingV2ExtLayer3($opt); break; } diff --git a/server/core/App.php b/server/core/App.php index 48bb9ab..a4be6ec 100755 --- a/server/core/App.php +++ b/server/core/App.php @@ -64,6 +64,11 @@ class App{ $opt = $this->tokenClass->getOptions($service); return $this->openstack->computeV2($opt); break; + case "FloatingIp": + if($this->tokenPost == NULL) $this->tokenClass->genNetworkToken(); + $opt = $this->tokenClass->getOptions('Network'); + return $this->openstack->networkingV2ExtLayer3($opt); + break; } } From 00184e623ec6dd1b5757fd9b268bc2afe97c338b Mon Sep 17 00:00:00 2001 From: Yoggzo Date: Tue, 19 Apr 2016 18:33:21 +0200 Subject: [PATCH 59/71] trying floating ip --- server/core/FloatingIp.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server/core/FloatingIp.php b/server/core/FloatingIp.php index bbcd888..26f5ef1 100755 --- a/server/core/FloatingIp.php +++ b/server/core/FloatingIp.php @@ -66,13 +66,13 @@ class floatingIp { private function listFloatingIp(){ try{ $result = array(); + $l = $this->libClass->getFloatingIps(); - - - + echo 'toto'; foreach ($l as $tmp) { - $serult[] = $tmp; + $result[] = $tmp; } + $this->app->setOutput("FloatingIp", $result); }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); From 49ce03168ad0c71a1df3ff4f9f161cbbe61bb277 Mon Sep 17 00:00:00 2001 From: EoleDev Date: Tue, 19 Apr 2016 19:44:09 +0200 Subject: [PATCH 60/71] Error patch --- server/Test/automatingTests.php | 2 +- server/core/FloatingIp.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) mode change 100644 => 100755 server/Test/automatingTests.php diff --git a/server/Test/automatingTests.php b/server/Test/automatingTests.php old mode 100644 new mode 100755 index 6de4de5..8715464 --- a/server/Test/automatingTests.php +++ b/server/Test/automatingTests.php @@ -23,6 +23,6 @@ foreach($servers as $server){ $floatingIp->action("listFloatingIp"); $listFloatingIp = json_decode($App->show(), true)["FloatingIp"]; foreach ($listFloatingIp as $floatIp){ - echo $floatIp['floating_ip_address']." ".$floatIp['id']." ".$floatIp["status"]."
"; + echo "IP : ".$floatIp['floating_ip_address']." et ID: ".$floatIp['id']." ".$floatIp["status"]."
"; } ?> \ No newline at end of file diff --git a/server/core/FloatingIp.php b/server/core/FloatingIp.php index 26f5ef1..f26c3fb 100755 --- a/server/core/FloatingIp.php +++ b/server/core/FloatingIp.php @@ -66,8 +66,8 @@ class floatingIp { private function listFloatingIp(){ try{ $result = array(); - - $l = $this->libClass->getFloatingIps(); + $l = $this->libClass->listFloatingIps(); + error_log(var_export($l, true), 0); echo 'toto'; foreach ($l as $tmp) { $result[] = $tmp; From 438b9b4dcdee7e0c18c3477bb9592ac7efbebfec Mon Sep 17 00:00:00 2001 From: Yoggzo Date: Tue, 19 Apr 2016 23:16:37 +0200 Subject: [PATCH 61/71] Correction de cette putain de classe non testee par othmane --- server/core/Network.php | 310 ++++++++++++++++++++++++---------------- 1 file changed, 184 insertions(+), 126 deletions(-) diff --git a/server/core/Network.php b/server/core/Network.php index fef3512..9564f06 100755 --- a/server/core/Network.php +++ b/server/core/Network.php @@ -14,8 +14,6 @@ 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 * @@ -73,24 +71,29 @@ class network{ { $options = array(); // check the name if it is null - if (isset($this->app->getPostParam("name"))) + $name = $this->app->getPostParam("name"); + $adminStateUp = $this->app->getPostParam("adminStateUp"); + $shared = $this->app->getPostParam("shared"); + $tenantId = $this->app->getPostParam("tenantId"); + + if (isset($name)) { - $options['name'] = $this->app->getPostParam("name"); + $options['name'] = $name; } // check the adminStateUp if it is null - if (isset($this->app->getPostParam("adminStateUp"))) + if (isset($adminStateUp)) { - $options['adminStateUp'] = $this->app->getPostParam("adminStateUp"); + $options['adminStateUp'] = $adminStateUp; } // check the shared if it is null - if (isset($this->app->getPostParam("shared"))) + if (isset($shared)) { - $options['shared'] = $this->app->getPostParam("shared"); + $options['shared'] = $shared; } // check the tenantId if it is null - if (isset($this->app->getPostParam("tenantId"))) + if (isset($tenantId)) { - $options['tenantId'] = $this->app->getPostParam("tenantId"); + $options['tenantId'] =$tenantId; } try { @@ -138,49 +141,61 @@ class network{ private function create_subnet() { $options = array(); - if (isset($this->app->getPostParam("networkId"))) + $networkId = $this->app->getPostParam("networkId"); + $ipVersion = $this->app->getPostParam("ipVersion"); + $cidr = $this->app->getPostParam("cidr"); + $tenantId = $this->app->getPostParam("tenantId"); + $name = $this->app->getPostParam("name"); + $gatewayIp = $this->app->getPostParam("gatewayIp"); + $dnsNameservers = $this->app->getPostParam("dnsNameservers"); + $allocationPools = $this->app->getPostParam("allocationPools"); + $hostRoutes = $this->app->getPostParam("hostRoutes"); + $enableDhcp = $this->app->getPostParam("enableDhcp"); + $tenantId = $this->app->getPostParam("tenantId"); + + if (isset($networkId)) { $options['networkId'] = $networkId; } - if (isset($this->app->getPostParam("ipVersion"))) + if (isset($ipVersion)) { - $options['ipVersion'] = $this->app->getPostParam("ipVersion"); + $options['ipVersion'] = $ipVersion; } - if (isset($this->app->getPostParam("cidr"))) + if (isset($cidr)) { - $options['cidr'] = $this->app->getPostParam("cidr"); + $options['cidr'] = $cidr; } - if (isset($this->app->getPostParam("tenantId"))) + if (isset($tenantId)) { - $options['tenantId'] = $this->app->getPostParam("tenantId"); + $options['tenantId'] = $tenantId; } - if (isset($this->app->getPostParam("name"))) + if (isset($name)) { - $options['name'] = $$this->app->getPostParam("name"); + $options['name'] = $name; } - if (isset($this->app->getPostParam("gatewayIp"))) + if (isset($gatewayIp)) { - $options['gatewayIp'] = $this->app->getPostParam("gatewayIp"); + $options['gatewayIp'] = $gatewayIp; } - if (isset($this->app->getPostParam("dnsNameservers"))) + if (isset($dnsNameservers)) { - $options['dnsNameservers'] = $this->app->getPostParam("dnsNameservers"); + $options['dnsNameservers'] = $dnsNameservers; } - if (isset($this->app->getPostParam("allocationPools"))) + if (isset($allocationPools)) { - $options['allocationPools'] = $this->app->getPostParam("allocationPools"); + $options['allocationPools'] = $allocationPools; } - if (isset($this->app->getPostParam("hostRoutes"))) + if (isset($hostRoutes)) { - $options['hostRoutes'] = $this->app->getPostParam("hostRoutes"); + $options['hostRoutes'] = $hostRoutes; } - if (isset($this->app->getPostParam("enableDhcp"))) + if (isset($enableDhcp)) { - $options['enableDhcp'] = $this->app->getPostParam("enableDhcp"); + $options['enableDhcp'] = $enableDhcp; } - if (isset($this->app->getPostParam("tenantId"))) + if (isset($tenantId)) { - $options['tenantId'] = $this->app->getPostParam("tenantId"); + $options['tenantId'] = $tenantId; } try @@ -339,10 +354,10 @@ class network{ $network=""; try - { $newtork = $this->libClass->getNetwork($this->app->getPostParam("networkId")); - $network->retrieve(); - - + { + $networkId = $this->app->getPostParam("networkId"); + $newtork = $this->libClass->getNetworkP($networkId); + $network->retrieve(); } @@ -371,7 +386,7 @@ class network{ * @param String netId ID of network which we want to get * @return Network */ - private function getNetwork($netId) + private function getNetworkP($netId) { $network=""; @@ -413,10 +428,10 @@ class network{ $sbnet=""; try - { $subnet = $this->libClass->getSubnet($this->app->getPostParam("subnetId")); + { + $subnetId = $this->app->getPostParam("subnetId"); + $subnet = $this->libClass->getSubnet($subnetId); $subnet->retrieve(); - - } catch(BadResponseError $e) @@ -443,7 +458,7 @@ class network{ * @param String subnetId ID of subnet which we want to get * @return subnet */ - private function getSubnet($subnetId) + private function getSubnetP($subnetId) { $subnet=""; @@ -489,21 +504,26 @@ class network{ private function updateNetwork() { $options = array(); - if(isset($this->app->getPostParam("name"))) + $name = $this->app->getPostParam("name"); + $shared = $this->app->getPostParam("shared"); + $adminStateUp = $this->app->getPostParam("adminStateUp"); + + if(isset($name)) { - $options['name'] = $this->app->getPostParam("name"); + $options['name'] = $name; } - if(isset($this->app->getPostParam("shared"))) + if(isset($shared)) { - $options['shared'] = $this->app->getPostParam("shared"); + $options['shared'] = $shared; } - if(isset($this->app->getPostParam("adminStateUp"))) + if(isset($adminStateUp)) { - $options['adminStateUp'] = $this->app->getPostParam("adminStateUp"); + $options['adminStateUp'] = $adminStateUp; } try { - $network = getNetwork($this->app->getPostParam("networkId")); + $networkId = $this->app->getPostParam("networkId"); + $network = getNetworkP($networkId); $network->update($options); } @@ -547,26 +567,30 @@ class network{ private function updateSubnet() { $options = array(); - if(isset($this->app->getPostParam("name"))) + $name = $this->app->getPostParam("name"); + $networkId = $this->app->getPostParam("networkId"); + $ipVersion = $this->app->getPostParam("ipVersion"); + $cidr = $this->app->getPostParam("cidr"); + if(isset($name)) { - $options['name'] = $this->app->getPostParam("name"); + $options['name'] = $name; } - if(isset($this->app->getPostParam("networkId"))) + if(isset($networkId)) { - $options['networkId'] = $this->app->getPostParam("networkId"); + $options['networkId'] = $networkId; } - if(isset($this->app->getPostParam("ipVersion"))) + if(isset($ipVersion)) { - $options['ipVersion'] = $this->app->getPostParam("ipVersion"); + $options['ipVersion'] = $ipVersion; } - if(isset($this->app->getPostParam("cidr"))) + if(isset($cidr)) { - $options['cidr'] = $this->app->getPostParam("cidr"); + $options['cidr'] = $cidr; } try { - $subnet = getSubnet($this->app->getPostParam("networkId")); - + $networkId = $this->app->getPostParam("networkId"); + $subnet = getSubnetP($networkId); $subnet->update($options); } catch(BadResponseError $e) @@ -599,8 +623,8 @@ class network{ { try { - - $network = getNetwork($this->app->getPostParam("networkId")); + $networkId = $this->app->getPostParam("networkId"); + $network = getNetworkP($networkId); $network->delete(); } catch(BadResponseError $e) @@ -633,7 +657,8 @@ class network{ { try { - $subnet = getNetwork($this->app->getPostParam("subnetId")); + $subnetId = $this->app->getPostParam("subnetId"); + $subnet = getNetworkP($subnetId); $subnet->delete(); } catch(BadResponseError $e) @@ -673,41 +698,51 @@ class network{ private function createPort() { $options = array(); - if (isset($this->app->getPostParam("networkId"))) + $networkId = $this->app->getPostParam("networkId"); + $name = $this->app->getPostParam("name"); + $adminStateUp = $this->app->getPostParam("adminStateUp"); + $macAddress = $this->app->getPostParam("macAddress"); + $fixedIps = $this->app->getPostParam("fixedIps"); + $deviceId = $this->app->getPostParam("deviceId"); + $deviceOwner = $this->app->getPostParam("deviceOwner"); + $securityGroups = $this->app->getPostParam("securityGroups"); + $tenantId = $this->app->getPostParam("tenantId"); + + if (isset($networkId)) { - $options['networkId'] = $this->app->getPostParam("networkId"); + $options['networkId'] = $networkId; } - if (isset($this->app->getPostParam("name"))) + if (isset($name)) { - $options['name'] = $this->app->getPostParam("name"); + $options['name'] = $name; } - if (isset($this->app->getPostParam("adminStateUp"))) + if (isset($adminStateUp)) { - $options['adminStateUp'] = $this->app->getPostParam("adminStateUp"); + $options['adminStateUp'] = $adminStateUp; } - if (isset($this->app->getPostParam("macAddress"))) + if (isset($macAddress)) { - $options['macAddress'] = $this->app->getPostParam("macAddress"); + $options['macAddress'] = $macAddress; } - if (isset($this->app->getPostParam("fixedIps"))) + if (isset($fixedIps)) { - $options['fixedIps'] = $this->app->getPostParam("fixedIps"); + $options['fixedIps'] = $fixedIps; } - if (isset($this->app->getPostParam("deviceId"))) + if (isset($deviceId)) { - $options['deviceId'] = $this->app->getPostParam("deviceId"); + $options['deviceId'] = $deviceId; } - if (isset($this->app->getPostParam("deviceOwner"))) + if (isset($deviceOwner)) { - $options['deviceOwner'] = $this->app->getPostParam("deviceOwner"); + $options['deviceOwner'] = $deviceOwner; } - if (isset($this->app->getPostParam("securityGroups"))) + if (isset($securityGroups)) { - $options['securityGroups'] = $this->app->getPostParam("securityGroups"); + $options['securityGroups'] = $securityGroups; } - if (isset($this->app->getPostParam("tenantId"))) + if (isset($tenantId)) { - $options['tenantId'] = $this->app->getPostParam("tenantId"); + $options['tenantId'] = $tenantId; } try { @@ -771,7 +806,8 @@ class network{ { try { - $port = $this->libClass->getport($this->app->getPostParam("portId")); + $portId = $this->app->getPostParam("portId"); + $port = $this->libClass->getport($portId); $this->app->setOutput("Port", $port); } catch(BadResponseError $e) @@ -800,7 +836,7 @@ class network{ * @return port */ - private function getPort($portId) + private function getPortP($portId) { try { @@ -845,46 +881,55 @@ class network{ private function updatePort() { $options = array(); - - if (isset($this->app->getPostParam("networkId"))) + $networkId = $this->app->getPostParam("networkId"); + $name = $this->app->getPostParam("name"); + $adminStateUp = $this->app->getPostParam("adminStateUp"); + $macAddress = $this->app->getPostParam("macAddress"); + $fixedIps = $this->app->getPostParam("fixedIps"); + $deviceId = $this->app->getPostParam("deviceId"); + $deviceOwner = $this->app->getPostParam("deviceOwner"); + $securityGroups = $this->app->getPostParam("securityGroups"); + $tenantId = $this->app->getPostParam("tenantId"); + + if (isset($networkId)) { - $options['networkId'] = $this->app->getPostParam("networkId"); + $options['networkId'] = $networkId; } - if (isset($this->app->getPostParam("name"))) + if (isset($name)) { - $options['name'] =$this->app->getPostParam("name"); + $options['name'] = $name; } - if (isset($this->app->getPostParam("adminStateUp"))) + if (isset($adminStateUp)) { - $options['adminStateUp'] =$this->app->getPostParam("adminStateUp"); + $options['adminStateUp'] = $adminStateUp; } - if (isset($this->app->getPostParam("macAddress"))) + if (isset($macAddress)) { - $options['macAddress'] = $this->app->getPostParam("macAddress"); + $options['macAddress'] = $macAddress; } - if (isset($this->app->getPostParam("fixedIps"))) + if (isset($fixedIps)) { - $options['fixedIps'] = $this->app->getPostParam("fixedIps"); + $options['fixedIps'] = $fixedIps; } - if (isset($this->app->getPostParam("deviceId"))) + if (isset($deviceId)) { - $options['deviceId'] = $this->app->getPostParam("deviceId"); + $options['deviceId'] = $deviceId; } - if (isset($this->app->getPostParam("deviceOwner"))) + if (isset($deviceOwner)) { - $options['deviceOwner'] = $this->app->getPostParam("deviceOwner"); + $options['deviceOwner'] = $deviceOwner; } - if (isset($this->app->getPostParam("networkId"))) + if (isset($securityGroups)) { - $options['securityGroups'] = $this->app->getPostParam("securityGroups"); + $options['securityGroups'] = $securityGroups; } - if (isset($this->app->getPostParam("tenantId"))) + if (isset($tenantId)) { - $options['tenantId'] = $this->app->getPostParam("tenantId"); + $options['tenantId'] = $tenantId; } try { - $port = getPort($this->app->getPostParam("networkId")); + $port = getPortP($networkId); $port->update($options); } catch(BadResponseError $e) @@ -908,7 +953,6 @@ class network{ * Delete a port given * * @param String portId id of port which we wante to delete - * @return void */ private function deletePort() @@ -916,7 +960,8 @@ class network{ try { - $port = getPort($this->app->getPostParam("portId")); + $portId = $this->app->getPostParam("portId"); + $port = getPortP($portId); $port->delete(); } catch(BadResponseError $e) @@ -949,13 +994,16 @@ class network{ private function createSecurityGroup() { $options = array(); - if (isset($this->app->getPostParam("name"))) + $name = $this->app->getPostParam("name"); + $description = $this->app->getPostParam("description"); + + if (isset($name)) { - $options['name'] = $this->app->getPostParam("name"); + $options['name'] = $name; } - if (isset($this->app->getPostParam("description"))) + if (isset($description)) { - $options['description'] = $this->app->getPostParam("description"); + $options['description'] = $description; } try { @@ -997,37 +1045,46 @@ class network{ private function createSecurityGroupRule() { $options = array(); - if (isset($this->app->getPostParam("securityGroupId"))) + $securityGroupId = $this->app->getPostParam("securityGroupId"); + $direction = $this->app->getPostParam("direction"); + $ethertype = $this->app->getPostParam("ethertype"); + $portRangeMin = $this->app->getPostParam("portRangeMin"); + $portRangeMax = $this->app->getPostParam("portRangeMax"); + $protocol = $this->app->getPostParam("protocol"); + $remoteGroupId = $this->app->getPostParam("remoteGroupId"); + $remoteIpPrefix = $this->app->getPostParam("remoteIpPrefix"); + + if (isset($securityGroupId)) { - $options['securityGroupId'] = $this->app->getPostParam("securityGroupId"); + $options['securityGroupId'] = $securityGroupId; } - if (isset($this->app->getPostParam("direction"))) + if (isset($direction)) { - $options['direction'] = $this->app->getPostParam("direction"); + $options['direction'] = $direction; } - if (isset($this->app->getPostParam("ethertype"))) + if (isset($ethertype)) { - $options['ethertype'] = $this->app->getPostParam("ethertype"); + $options['ethertype'] = $ethertype; } - if (isset($this->app->getPostParam("portRangeMin"))) + if (isset($portRangeMin)) { - $options['portRangeMin'] = $this->app->getPostParam("portRangeMin"); + $options['portRangeMin'] = $portRangeMin; } - if (isset($this->app->getPostParam("portRangeMax"))) + if (isset($portRangeMax)) { - $options['portRangeMax'] = $this->app->getPostParam("portRangeMax"); + $options['portRangeMax'] = $portRangeMax; } - if (isset($this->app->getPostParam("protocol"))) + if (isset($protocol)) { - $options['protocol'] = $this->app->getPostParam("protocol"); + $options['protocol'] = $protocol; } - if (isset($this->app->getPostParam("remoteGroupId"))) + if (isset($remoteGroupId)) { - $options['remoteGroupId'] = $this->app->getPostParam("remoteGroupId"); + $options['remoteGroupId'] = $remoteGroupId; } - if (isset($this->app->getPostParam("remoteIpPrefix"))) + if (isset($remoteIpPrefix)) { - $options['remoteIpPrefix'] = $this->app->getPostParam("remoteIpPrefix"); + $options['remoteIpPrefix'] = $remoteIpPrefix; } try { @@ -1125,7 +1182,8 @@ class network{ { try { - $securityGroupe = $this->libClass->getSecurityGroupe($this->app->getPostParam("securityGroupeId")); + $securityGroupId = $this->app->getPostParam("securityGroupeId"); + $securityGroupe = $this->libClass->getSecurityGroupe($securityGroupId); $this->app->setOutput("securityGroupe", $securityGroupe); } catch(BadResponseError $e) @@ -1153,7 +1211,7 @@ class network{ * @param securityGroupeId ID of security Groupe which we want to get * @return securityGroupe */ - private function getSecurityGroupe($securityGroupeId) + private function getSecurityGroupeP($securityGroupeId) { try { @@ -1187,8 +1245,8 @@ class network{ { try { - - $securityGroupe = getSecurityGroupe($this->app->getPostParam("securityGroupeId")); + $securityGroupId = $this->app->getPostParam("securityGroupeId"); + $securityGroupe = getSecurityGroupeP($securityGroupId); $securityGroupe->delete(); } catch(BadResponseError $e) From 94629aeaf523f391f09ef18c1b2ca639e0b02d08 Mon Sep 17 00:00:00 2001 From: Yoggzo Date: Tue, 19 Apr 2016 23:57:03 +0200 Subject: [PATCH 62/71] tentative ip publique --- server/Test/automatingTests.php | 65 +++++++++++++++++++++++++++++++-- server/core/FloatingIp.php | 51 +++++++++++++++++++++++++- server/core/Network.php | 2 +- 3 files changed, 111 insertions(+), 7 deletions(-) diff --git a/server/Test/automatingTests.php b/server/Test/automatingTests.php index 8715464..078f86b 100755 --- a/server/Test/automatingTests.php +++ b/server/Test/automatingTests.php @@ -2,27 +2,84 @@ include('InitTest.php'); include_once("../core/Image.php"); include_once("../core/Compute.php"); -//include_once("../core/Network.php"); +include_once("../core/Network.php"); //include_once("../core/Automating.php"); include_once("../core/FloatingIp.php"); $image = new Image($App); $compute = new Compute($App); -//$network = new Network($App); +$network = new Network($App); $floatingIp = new FloatingIp($App); //$automating = new Automating($App); // Liste des serveurs +echo "Liste des serveurs :
"; $compute->action("listServers"); $servers = json_decode($App->show(), true)["Servers"]; +$id = null; foreach($servers as $server){ - echo $server['name']." ".$server['id']."
"; + echo $server['name']." ".$server['id']." ".$server['ipv4']."
"; + if(strcmp($server['name'], "bob")){ + $id = $server['id']; + } } +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 floatingip +echo "Liste des floatingip :
"; +$floatingIp->action("listFloatingIp"); +$listFloatingIp = json_decode($App->show(), true)["FloatingIp"]; +$ip = null; +foreach ($listFloatingIp as $floatIp){ + echo $floatIp['floatingIpAddress']." ".$floatIp['id']." ".$floatIp["status"]."
"; + $ip = $floatIp; +} + +echo "
"; + +// Création d'une ip flotante +$opt = array(); +$opt['floatingNetworkId'] = $id; +$opt['floatingip'] = $ip; +//$opt['tenantId'] = "fbf5f920a7954b61b352bc09ce5ae803 "; +//$opt['fixedIpAddress'] = "10.0.0.52"; +//$opt['floatingIpAddress'] = "148.60.11.116"; +//$opt['portId'] = "10.0.0.52"; + +$App->setPostParam('opt', $opt); +$floatingIp->action("createFloatingIp"); +$float = json_decode($App->show(), true)["FloatingIp"]; +if(!isset($float)){ + echo "Erreur pendant la création
"; +} +else{ + foreach ($float as $f) { + echo $f." "; + } + echo "
"; +} + + +echo "
"; + +// liste des floatingip +echo "Liste des floatingip :
"; $floatingIp->action("listFloatingIp"); $listFloatingIp = json_decode($App->show(), true)["FloatingIp"]; foreach ($listFloatingIp as $floatIp){ - echo "IP : ".$floatIp['floating_ip_address']." et ID: ".$floatIp['id']." ".$floatIp["status"]."
"; + echo $floatIp['floatingIpAddress']." ".$floatIp['id']." ".$floatIp["status"]."
"; } + + ?> \ No newline at end of file diff --git a/server/core/FloatingIp.php b/server/core/FloatingIp.php index f26c3fb..528ab4f 100755 --- a/server/core/FloatingIp.php +++ b/server/core/FloatingIp.php @@ -68,7 +68,6 @@ class floatingIp { $result = array(); $l = $this->libClass->listFloatingIps(); error_log(var_export($l, true), 0); - echo 'toto'; foreach ($l as $tmp) { $result[] = $tmp; } @@ -101,13 +100,61 @@ class floatingIp { $this->app->setOutput("Error", "Incorrect parameter opt"); } try{ - $floatingip = $this->libClass->create($opt); + $floatingip = $this->libClass->createFloatingIp($opt); + echo 'YOLO'; 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{ + /*$l = $this->listFloatingIp(); + $res = null; + foreach ($l as $f) { + if($f['id']==$id){ + $res = $f; + } + } + if(!isset($f)){ + $this->app->setOutput("Error", "Unknow id"); + } + else{*/ + $res = $this->libClass->getFloatingIp($id); + $this->app->setOutput("FloatingIp", $res); + //} }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); }catch(UserInputError $e){ diff --git a/server/core/Network.php b/server/core/Network.php index 9564f06..3e5e2ca 100755 --- a/server/core/Network.php +++ b/server/core/Network.php @@ -40,7 +40,7 @@ class network{ public function __construct($app){ $this->app = $app; - $this->libClass = $app->getLibClass("network"); + $this->libClass = $app->getLibClass("Network"); } From 20dc35d9ab6ce3b9aafeeca14be52b70a30aaf1e Mon Sep 17 00:00:00 2001 From: EoleDev Date: Wed, 20 Apr 2016 09:45:24 +0200 Subject: [PATCH 63/71] Error correction automating --- server/Test/automatingTests.php | 15 ++++++++++++--- server/core/Network.php | 4 ++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/server/Test/automatingTests.php b/server/Test/automatingTests.php index 078f86b..6b0e9d6 100755 --- a/server/Test/automatingTests.php +++ b/server/Test/automatingTests.php @@ -34,7 +34,15 @@ foreach ($ports as $p) { echo $p["fixedIps"]."
"; } */ - +//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 :
"; @@ -50,12 +58,13 @@ echo "
"; // Création d'une ip flotante $opt = array(); -$opt['floatingNetworkId'] = $id; -$opt['floatingip'] = $ip; +//$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"); diff --git a/server/core/Network.php b/server/core/Network.php index 3e5e2ca..e93c2c5 100755 --- a/server/core/Network.php +++ b/server/core/Network.php @@ -118,7 +118,7 @@ class network{ } - + /** * Create a new subnet * @@ -356,7 +356,7 @@ class network{ try { $networkId = $this->app->getPostParam("networkId"); - $newtork = $this->libClass->getNetworkP($networkId); + $newtork = $this->libClass->getNetwork($networkId); $network->retrieve(); } From 94ce37f5175eb6f528d5ad29a446c04d981628f1 Mon Sep 17 00:00:00 2001 From: Yoggzo Date: Thu, 21 Apr 2016 21:31:25 +0200 Subject: [PATCH 64/71] end of floatingip --- server/Test/automatingTests.php | 24 ++----- server/Test/floatingIpTests.php | 88 +++++++++++++++++++++++ server/core/FloatingIp.php | 123 +++++++++++++++++++++----------- 3 files changed, 172 insertions(+), 63 deletions(-) create mode 100644 server/Test/floatingIpTests.php diff --git a/server/Test/automatingTests.php b/server/Test/automatingTests.php index 6b0e9d6..3f32d02 100755 --- a/server/Test/automatingTests.php +++ b/server/Test/automatingTests.php @@ -44,18 +44,7 @@ foreach($servers as $server){ } echo "
"; -// liste des floatingip -echo "Liste des floatingip :
"; -$floatingIp->action("listFloatingIp"); -$listFloatingIp = json_decode($App->show(), true)["FloatingIp"]; -$ip = null; -foreach ($listFloatingIp as $floatIp){ - echo $floatIp['floatingIpAddress']." ".$floatIp['id']." ".$floatIp["status"]."
"; - $ip = $floatIp; -} - -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 @@ -72,15 +61,10 @@ $float = json_decode($App->show(), true)["FloatingIp"]; if(!isset($float)){ echo "Erreur pendant la création
"; } -else{ - foreach ($float as $f) { - echo $f." "; - } - echo "
"; -} - - echo "
"; +*/ + + // liste des floatingip echo "Liste des floatingip :
"; diff --git a/server/Test/floatingIpTests.php b/server/Test/floatingIpTests.php new file mode 100644 index 0000000..191de46 --- /dev/null +++ b/server/Test/floatingIpTests.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 :
"; +$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/FloatingIp.php b/server/core/FloatingIp.php index 528ab4f..cdbb64b 100755 --- a/server/core/FloatingIp.php +++ b/server/core/FloatingIp.php @@ -101,11 +101,10 @@ class floatingIp { } try{ $floatingip = $this->libClass->createFloatingIp($opt); - echo 'YOLO'; + if(!isset($floatingip)){ $this->app->setOutput("Error", "Unknowing error during floating ip creation"); - } - else{ + }else{ $this->app->setOutput("FloatingIp", $floatingip); } }catch(BadResponseError $e){ @@ -141,20 +140,29 @@ class floatingIp { } try{ - /*$l = $this->listFloatingIp(); - $res = null; - foreach ($l as $f) { - if($f['id']==$id){ - $res = $f; + // List of floating IPs + $res = array(); + $l = $this->libClass->listFloatingIps(); + foreach ($l as $tmp) { + $res[] = $tmp; + } + + // Verification if id exists + $result = null; + foreach ($res as $f) { + if(strcmp($res['id'], $id)){ + $result = $f; + } } - if(!isset($f)){ + + if(!isset($result)){ // If id doesn't exists $this->app->setOutput("Error", "Unknow id"); - } - else{*/ + }else{ // If id exists $res = $this->libClass->getFloatingIp($id); $this->app->setOutput("FloatingIp", $res); - //} + } + }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); }catch(UserInputError $e){ @@ -182,18 +190,29 @@ class floatingIp { $this->app->setOutput("Error", "Incorrect parameter opt"); } try{ - $floatingips = listFloatingIps(); - $floatingIp = null; - foreach ($floatingips as $f) { - if($f['id'] == $id){ - $floatingIp = $f; - } - } - if(!isset($floatingIp)){ - $this->app->setOutput("Error", "Unknowing floatingip id"); + + // List of floating IPs + $res = array(); + $l = $this->libClass->listFloatingIps(); + foreach ($l as $tmp) { + $res[] = $tmp; } - $floatingip->update(); + // 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); @@ -222,19 +241,27 @@ class floatingIp { $this->app->setOutput("Error", "Incorrect parameter opt"); } try{ - $floatingips = listFloatingIps(); - $floatingIp = null; - foreach ($floatingips as $f) { - if($f['id'] == $id){ - $floatingIp = $f; - } - } - if(!isset($floatingIp)){ - $this->app->setOutput("Error", "Unknowing floatingip id"); + // List of floating IPs + $res = array(); + $l = $this->libClass->listFloatingIps(); + foreach ($l as $tmp) { + $res[] = $tmp; } - $floatingip->delete(); - + // 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){ @@ -248,6 +275,7 @@ class floatingIp { } } + /** * Retrieve a floating ip * @@ -262,18 +290,27 @@ class floatingIp { $this->app->setOutput("Error", "Incorrect parameter opt"); } try{ - $floatingips = listFloatingIps(); - $floatingIp = null; - foreach ($floatingips as $f) { - if($f['id'] == $id){ - $floatingIp = $f; - } - } - if(!isset($floatingIp)){ - $this->app->setOutput("Error", "Unknowing floatingip id"); + // List of floating IPs + $res = array(); + $l = $this->libClass->listFloatingIps(); + foreach ($l as $tmp) { + $res[] = $tmp; } - $floatingip->retrieve(); + // 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){ From 3f6af0b6446725462362de94f09daf9a723b130d Mon Sep 17 00:00:00 2001 From: Yoggzo Date: Thu, 21 Apr 2016 21:51:46 +0200 Subject: [PATCH 65/71] modification in structure for ip and routers --- server/Test/AppTestClass.php | 2 +- ...tingIpTests.php => NetworkLayer3Tests.php} | 22 +++++----- server/Test/automatingTests.php | 40 +++---------------- server/core/App.php | 2 +- server/core/Automating.php | 5 ++- .../{FloatingIp.php => NetworkLayer3.php} | 12 +++--- server/index.php | 6 +-- 7 files changed, 30 insertions(+), 59 deletions(-) rename server/Test/{floatingIpTests.php => NetworkLayer3Tests.php} (74%) rename server/core/{FloatingIp.php => NetworkLayer3.php} (96%) 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/floatingIpTests.php b/server/Test/NetworkLayer3Tests.php similarity index 74% rename from server/Test/floatingIpTests.php rename to server/Test/NetworkLayer3Tests.php index 191de46..b827a51 100644 --- a/server/Test/floatingIpTests.php +++ b/server/Test/NetworkLayer3Tests.php @@ -3,11 +3,11 @@ include('InitTest.php'); include_once("../core/Compute.php"); include_once("../core/Network.php"); -include_once("../core/FloatingIp.php"); +include_once("../core/NetworkLayer3.php"); $compute = new Compute($App); $network = new Network($App); -$floatingIp = new FloatingIp($App); +$networkLayer3 = new NetworkLayer3($App); // Liste des serveurs @@ -37,8 +37,8 @@ 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"]; $id = null; foreach ($listFloatingIp as $floatIp){ echo $floatIp['floatingIpAddress']." ".$floatIp['id']." ".$floatIp["status"]."
"; @@ -50,8 +50,8 @@ echo "
"; // Liste des floatingip echo "Get floatingip :
"; $App->setPostParam('id', $id); -$floatingIp->action("getFloatingIp"); -$getFloatingIp = json_decode($App->show(), true)["FloatingIp"]; +$networkLayer3->action("getFloatingIp"); +$getFloatingIp = json_decode($App->show(), true)["NetworkLayer3"]; echo $getFloatingIp['id']."
"; echo "
"; @@ -62,8 +62,8 @@ $opt = array(); $opt['floatingNetworkId'] = "251b4641-20ff-4a72-8549-1758788b51ce"; $App->setPostParam('opt', $opt); -$floatingIp->action("createFloatingIp"); -$float = json_decode($App->show(), true)["FloatingIp"]; +$networkLayer3->action("createFloatingIp"); +$float = json_decode($App->show(), true)["NetworkLayer3"]; if(!isset($float)){ echo "Erreur pendant la création
"; } @@ -73,13 +73,13 @@ echo "
"; /* // Suppression d'une ip flotante $App->setPostParam('id', $id); -$floatingIp->action("deleteFloatingIp"); +$networkLayer3->action("deleteFloatingIp"); */ // 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/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/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/NetworkLayer3.php similarity index 96% rename from server/core/FloatingIp.php rename to server/core/NetworkLayer3.php index cdbb64b..28d27b4 100755 --- a/server/core/FloatingIp.php +++ b/server/core/NetworkLayer3.php @@ -22,7 +22,7 @@ use OpenCloud\Common\Error\UserInputError; * Management of images * */ -class floatingIp { +class networkLayer3 { /** @var App $app protected, contains the main app object */ protected $app; @@ -35,14 +35,14 @@ class floatingIp { * * @param App $app the main app object * - * @return floatingip + * @return networkLayer3 */ public function __construct($app){ if(!isset($app)){ $this->app->setOutput("Error", "Incorrect parameter app"); } $this->app = $app; - $this->libClass = $app->getLibClass("FloatingIp"); + $this->libClass = $app->getLibClass("NetworkLayer3"); } @@ -72,7 +72,7 @@ class floatingIp { $result[] = $tmp; } - $this->app->setOutput("FloatingIp", $result); + $this->app->setOutput("NetworkLayer3", $result); }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); }catch(UserInputError $e){ @@ -105,7 +105,7 @@ class floatingIp { if(!isset($floatingip)){ $this->app->setOutput("Error", "Unknowing error during floating ip creation"); }else{ - $this->app->setOutput("FloatingIp", $floatingip); + $this->app->setOutput("NetworkLayer3", $floatingip); } }catch(BadResponseError $e){ echo $e."
"; @@ -160,7 +160,7 @@ class floatingIp { $this->app->setOutput("Error", "Unknow id"); }else{ // If id exists $res = $this->libClass->getFloatingIp($id); - $this->app->setOutput("FloatingIp", $res); + $this->app->setOutput("NetworkLayer3", $res); } }catch(BadResponseError $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; From 7e5b9f3a729b676c4efcf40769ed1631bf9fc0ba Mon Sep 17 00:00:00 2001 From: Yoggzo Date: Thu, 21 Apr 2016 22:52:00 +0200 Subject: [PATCH 66/71] add router functions --- server/Test/NetworkLayer3Tests.php | 60 +++++++- server/core/NetworkLayer3.php | 233 +++++++++++++++++++++++++++-- 2 files changed, 278 insertions(+), 15 deletions(-) diff --git a/server/Test/NetworkLayer3Tests.php b/server/Test/NetworkLayer3Tests.php index b827a51..cb14e3a 100644 --- a/server/Test/NetworkLayer3Tests.php +++ b/server/Test/NetworkLayer3Tests.php @@ -47,7 +47,7 @@ foreach ($listFloatingIp as $floatIp){ echo "
"; -// Liste des floatingip +// get floatingip echo "Get floatingip :
"; $App->setPostParam('id', $id); $networkLayer3->action("getFloatingIp"); @@ -70,12 +70,14 @@ if(!isset($float)){ echo "
"; */ + /* // Suppression d'une ip flotante $App->setPostParam('id', $id); $networkLayer3->action("deleteFloatingIp"); */ + // Liste des floatingip echo "Liste des floatingip :
"; $networkLayer3->action("listFloatingIp"); @@ -83,6 +85,62 @@ $listFloatingIp = json_decode($App->show(), true)["NetworkLayer3"]; foreach ($listFloatingIp as $floatIp){ echo $floatIp['floatingIpAddress']." ".$floatIp['id']." ".$floatIp["status"]."
"; } +echo "
"; +// Liste des routeurs +echo "Liste des routeurs :
"; +$networkLayer3->action("listRouters"); +$listRouters = json_decode($App->show(), true)["NetworkLayer3"]; +foreach ($listRouters as $router){ + echo $router['name']." ".$router['id']."
"; + if(strcmp($router['name'], "Test")){ + $id = $router['id']; + } +} +echo "
"; + + +// get floatingip +echo "Get router :
"; +$App->setPostParam('id', $id); +$networkLayer3->action("getRouter"); +$getRouter = json_decode($App->show(), true)["NetworkLayer3"]; +echo $getRouter['id']."
"; +echo "
"; + + +/* +// Création d'un routeur' +$opt = array(); +$optGate = array(); +$optGate['networkId'] = "251b4641-20ff-4a72-8549-1758788b51ce"; +$opt['externalGatewayInfo'] = $optGate; +$opt['name'] = "Test"; +$App->setPostParam('opt', $opt); +$networkLayer3->action("createRouter"); +$r = json_decode($App->show(), true)["NetworkLayer3"]; +if(!isset($r)){ + echo "Erreur pendant la création
"; +} +echo "
"; +*/ + + +/* +// Suppression d'un routeur +$App->setPostParam('id', $id); +$networkLayer3->action("deleteRouter"); +echo "
"; +*/ + + +// Liste des routeurs +echo "Liste des routeurs :
"; +$networkLayer3->action("listRouters"); +$listRouters = json_decode($App->show(), true)["NetworkLayer3"]; +foreach ($listRouters as $router){ + echo $router['name']." ".$router['id']."
"; +} + ?> \ No newline at end of file diff --git a/server/core/NetworkLayer3.php b/server/core/NetworkLayer3.php index 28d27b4..30e8a78 100755 --- a/server/core/NetworkLayer3.php +++ b/server/core/NetworkLayer3.php @@ -89,7 +89,7 @@ class networkLayer3 { /** * 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) + * @param array $opt Options for the floating ip creation (floatingNetworkId is required) * * @return floatingip */ @@ -108,19 +108,14 @@ class networkLayer3 { $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); } } @@ -150,7 +145,7 @@ class networkLayer3 { // Verification if id exists $result = null; foreach ($res as $f) { - if(strcmp($res['id'], $id)){ + if(strcmp($f->id, $id)){ $result = $f; } @@ -162,7 +157,6 @@ class networkLayer3 { $res = $this->libClass->getFloatingIp($id); $this->app->setOutput("NetworkLayer3", $res); } - }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); }catch(UserInputError $e){ @@ -181,7 +175,7 @@ class networkLayer3 { * * @param id the id of the floatingip to update * - * @return Image + * @return void */ private function updateFloatingIp(){ $id = $this->app->getPostParam("id"); @@ -201,7 +195,7 @@ class networkLayer3 { // Verification if id exists $result = null; foreach ($res as $f) { - if(strcmp($res['id'], $id)){ + if(strcmp($f->id, $id)){ $result = $f; } @@ -212,8 +206,6 @@ class networkLayer3 { }else{ $result->update(); } - - }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); }catch(UserInputError $e){ @@ -251,7 +243,7 @@ class networkLayer3 { // Verification if id exists $result = null; foreach ($res as $f) { - if(strcmp($res['id'], $id)){ + if(strcmp($f->id, $id)){ $result = $f; } @@ -300,7 +292,7 @@ class networkLayer3 { // Verification if id exists $result = null; foreach ($res as $f) { - if(strcmp($res['id'], $id)){ + if(strcmp($f->id, $id)){ $result = $f; } @@ -323,4 +315,217 @@ class networkLayer3 { $this->app->getErrorInstance()->OtherException($e); } } + + + + /** + * Create a new router + * + * @param array $opt Options for the new router + * externalGatewayInfo[] required (only the param networkId in the tab) + * adminStateUp (optionnal) + * name (optionnal) + * + * @return router + */ + private function createRouter(){ + $opt = $this->app->getPostParam("opt"); + + if(!isset($opt)){ + $this->app->setOutput("Error", "Incorrect parameter opt"); + } + try{ + $router = $this->libClass->createRouter($opt); + + if(!isset($router)){ + $this->app->setOutput("Error", "Unknowing error during floating ip creation"); + }else{ + $this->app->setOutput("NetworkLayer3", $router); + } + }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); + } + } + + + /** + * List routers + * + * @return list of the routers + */ + private function listRouters(){ + try{ + $result = array(); + $l = $this->libClass->listRouters(); + 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); + } + } + + + /** + * Show router details + * + * @param String id the id of the router + * + * @return router details + */ + private function getRouter(){ + $id = $this->app->getPostParam("id"); + if(!isset($id)){ + $this->app->setOutput("Error", "Incorrect parameter opt"); + } + try{ + // List of routers + $res = array(); + $l = $this->libClass->listRouters(); + foreach ($l as $tmp) { + $res[] = $tmp; + } + + // Verification if id exists + $result = null; + foreach ($res as $f) { + if(strcmp($f->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->getRouter($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); + } + } + + + /** + * Delete a router + * + * @param string router the router to delete + * + * @return void + */ + private function deleteRouter(){ + $id = $this->app->getPostParam("id"); + + if(!isset($id)){ + $this->app->setOutput("Error", "Incorrect parameter opt"); + } + try{ + // List of routers + $res = array(); + $l = $this->libClass->listRouters(); + foreach ($l as $tmp) { + $res[] = $tmp; + } + + // Verification if id exists + $result = null; + foreach ($res as $f) { + if(strcmp($f->id, $id)){ + $result = $f; + } + } + + if(!isset($result)){ // If id doesn't exists + $this->app->setOutput("Error", "Unknowing router 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); + } + } + + + /** + * Update router + * + * @param id the id of the floatingip to update + * + * @return void + */ + private function updateRouter(){ + $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->listRouters(); + foreach ($l as $tmp) { + $res[] = $tmp; + } + + // Verification if id exists + $result = null; + foreach ($res as $f) { + if(strcmp($f->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); + } + } } From 0fc14b5761e558680aecc57e4d1ae8075121f01e Mon Sep 17 00:00:00 2001 From: Yoggzo Date: Thu, 21 Apr 2016 23:57:37 +0200 Subject: [PATCH 67/71] structure of Automating --- server/Test/automatingTests.php | 54 ++++++------------------ server/core/Automating.php | 73 +++++++++++++++++++-------------- 2 files changed, 56 insertions(+), 71 deletions(-) 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"]."
"; -} +//$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 + */ } } - } ?> From 477dc821824b422c11d0d34b644de4b68a596510 Mon Sep 17 00:00:00 2001 From: EoleDev Date: Tue, 26 Apr 2016 17:35:32 +0200 Subject: [PATCH 68/71] Nettoyage --- server/config.inc.php | 2 +- server/core/App.php | 3 - server/core/Network.php~ | 952 ------------------------------------- server/core/Plugin.php | 13 - server/core/Plugin_Api.php | 24 - server/create_serv.php | 55 --- 6 files changed, 1 insertion(+), 1048 deletions(-) delete mode 100755 server/core/Network.php~ delete mode 100755 server/core/Plugin.php delete mode 100755 server/core/Plugin_Api.php delete mode 100755 server/create_serv.php diff --git a/server/config.inc.php b/server/config.inc.php index 636ee5e..aa10504 100755 --- a/server/config.inc.php +++ b/server/config.inc.php @@ -5,7 +5,7 @@ $config["modules_enabled"] = ""; $config["urlAuth"] = "http://148.60.11.31:5000/v3"; - $config["tokenTime"] = 60 //miunte = 60 //miuntess + $config["tokenTime"] = 60 //minute = 60 ?> diff --git a/server/core/App.php b/server/core/App.php index 32ad016..114d945 100755 --- a/server/core/App.php +++ b/server/core/App.php @@ -1,5 +1,4 @@ tokenPost = NULL; $this->tokenClass = new genTokenOptions($args); $this->openstack = new OpenStack\OpenStack(['authUrl' => $args["authUrl"]]); - $this->pluginsApi = plugin_api::getInstance(); $this->errorClass = new errorManagement($this); $this->output = array(); $this->postParams = $_POST; diff --git a/server/core/Network.php~ b/server/core/Network.php~ deleted file mode 100755 index 65de962..0000000 --- a/server/core/Network.php~ +++ /dev/null @@ -1,952 +0,0 @@ -app = $app; - $this->libClass = $app->getLibClass("network"); - - } - - - public function action($action){ - - $this->{$action.""}(); - - } - - - public function create_network() - { - $options = array(); - if (isset($this->app->getPostParam("name"))) - { - $options['name'] = $this->app->getPostParam("name"); - } - if (isset($this->app->getPostParam("adminStateUp"))) - { - $options['adminStateUp'] = $this->app->getPostParam("adminStateUp"); - } - if (isset($this->app->getPostParam("shared"))) - { - $options['shared'] = $this->app->getPostParam("shared"); - } - if (isset($this->app->getPostParam("tenantId"))) - { - $options['tenantId'] = $this->app->getPostParam("tenantId"); - } - try - { - $network = $this->libClass->createNetworks($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); - } - - - } - - public function create_subnet() - { $options = array(); - if (isset($this->app->getPostParam("networkId"))) - { - $options['networkId'] = $networkId; - } - if (isset($this->app->getPostParam("ipVersion"))) - { - $options['ipVersion'] = $this->app->getPostParam("ipVersion"); - } - if (isset($this->app->getPostParam("cidr"))) - { - $options['cidr'] = $this->app->getPostParam("cidr"); - } - if (isset($this->app->getPostParam("tenantId"))) - { - $options['tenantId'] = $this->app->getPostParam("tenantId"); - } - if (isset($this->app->getPostParam("name"))) - { - $options['name'] = $$this->app->getPostParam("name"); - } - if (isset($this->app->getPostParam("gatewayIp"))) - { - $options['gatewayIp'] = $this->app->getPostParam("gatewayIp"); - } - if (isset($this->app->getPostParam("dnsNameservers"))) - { - $options['dnsNameservers'] = $this->app->getPostParam("dnsNameservers"); - } - if (isset($this->app->getPostParam("allocationPools"))) - { - $options['allocationPools'] = $this->app->getPostParam("allocationPools"); - } - if (isset($this->app->getPostParam("hostRoutes"))) - { - $options['hostRoutes'] = $this->app->getPostParam("hostRoutes"); - } - if (isset($this->app->getPostParam("enableDhcp"))) - { - $options['enableDhcp'] = $this->app->getPostParam("enableDhcp"); - } - if (isset($this->app->getPostParam("tenantId"))) - { - $options['tenantId'] = $this->app->getPostParam("tenantId"); - } - - try - { - $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); - } - - - } - - public function list_network_ids() - { - 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); - } - - public function list_network_names() - { - 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); - } - - public function list_cidr() - { - try - { - $ls = $this->libClass->listSubnets(); - $list_cidr = array(); - foreach ($ls as $subnet) - { - - $list_cidr[] = $subnet->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); - } - } - - public function getNetwork() - { - $network=""; - - try - { $newtork = $this->libClass->getNetwork($this->app->getPostParam("networkId")); - $network->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); - } - - $this->app->setOutput("Network", $network); - } - - public function getNetwork($netId) - { - $network=""; - - try - { $newtork = $this->libClass->getNetwork($netId); - $network->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); - } - - return $network; - } - - public function getSubnet() - { - $sbnet=""; - - try - { $subnet = $this->libClass->getSubnet($this->app->getPostParam("subnetId")); - $subnet->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); - } - $this->app->setOutput("Subnet", subnet); - - } - - public function getSubnet($subnetId) - { - $subnet=""; - - try - { $subnet = $this->libClass->getSubnet($subnetId); - $subnet->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); - } - return $subnet; - - } - - public function updateNetwork() - { - $options = array(); - if(isset($this->app->getPostParam("name"))) - { - $options['name'] = $this->app->getPostParam("name"); - } - if(isset($this->app->getPostParam("shared"))) - { - $options['shared'] = $this->app->getPostParam("shared"); - } - if(isset($this->app->getPostParam("adminStateUp"))) - { - $options['adminStateUp'] = $this->app->getPostParam("adminStateUp"); - } - try - { - $network = getNetwork($this->app->getPostParam("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); - } - } - - public function updateSubnet() - { - $options = array(); - if(isset($this->app->getPostParam("name"))) - { - $options['name'] = $this->app->getPostParam("name"); - } - if(isset($this->app->getPostParam("networkId"))) - { - $options['networkId'] = $this->app->getPostParam("networkId"); - } - if(isset($this->app->getPostParam("ipVersion"))) - { - $options['ipVersion'] = $this->app->getPostParam("ipVersion"); - } - if(isset($this->app->getPostParam("cidr"))) - { - $options['cidr'] = $this->app->getPostParam("cidr"); - } - try - { - $subnet = getSubnet($this->app->getPostParam("networkId")); - - $subnet->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); - } - } - - public function deleteNetwork() - { - try - { - - $network = getNetwork($this->app->getPostParam("networkId")); - $network->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); - } - } - - public function deleteSubnet() - { - try - { - $subnet = getNetwork($this->app->getPostParam("subnetId")); - $subnet->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); - } - } - - public function createPort() - { - $options = array(); - if (isset($this->app->getPostParam("networkId"))) - { - $options['networkId'] = $this->app->getPostParam("networkId"); - } - if (isset($this->app->getPostParam("name"))) - { - $options['name'] = $this->app->getPostParam("name"); - } - if (isset($this->app->getPostParam("adminStateUp"))) - { - $options['adminStateUp'] = $this->app->getPostParam("adminStateUp"); - } - if (isset($this->app->getPostParam("macAddress"))) - { - $options['macAddress'] = $this->app->getPostParam("macAddress"); - } - if (isset($this->app->getPostParam("fixedIps"))) - { - $options['fixedIps'] = $this->app->getPostParam("fixedIps"); - } - if (isset($this->app->getPostParam("deviceId"))) - { - $options['deviceId'] = $this->app->getPostParam("deviceId"); - } - if (isset($this->app->getPostParam("deviceOwner"))) - { - $options['deviceOwner'] = $this->app->getPostParam("deviceOwner"); - } - if (isset($this->app->getPostParam("securityGroups"))) - { - $options['securityGroups'] = $this->app->getPostParam("securityGroups"); - } - if (isset($this->app->getPostParam("tenantId"))) - { - $options['tenantId'] = $this->app->getPostParam("tenantId"); - } - try - { - $this->libClass->createPort($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); - } - } - - public function listPorts() - { - try - { - $this->app->setOutput("listPorts", $this->libClass->listPorts()); - } - 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); - } - } - - public function getPort() - { - try - { - $port = $this->libClass->getport($this->app->getPostParam("portId")); - $this->app->setOutput("Port", $port); - } - 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); - } - - } - - public function getPort($portId) - { - try - { - $port = $this->libClass->getport($portId); - return $port; - } - 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); - } - - } - - public function updatePort() - { - $options = array(); - - if (isset($this->app->getPostParam("networkId"))) - { - $options['networkId'] = $this->app->getPostParam("networkId"); - } - if (isset($this->app->getPostParam("name"))) - { - $options['name'] =$this->app->getPostParam("name"); - } - if (isset($this->app->getPostParam("adminStateUp"))) - { - $options['adminStateUp'] =$this->app->getPostParam("adminStateUp"); - } - if (isset($this->app->getPostParam("macAddress"))) - { - $options['macAddress'] = $this->app->getPostParam("macAddress"); - } - if (isset($this->app->getPostParam("fixedIps"))) - { - $options['fixedIps'] = $this->app->getPostParam("fixedIps"); - } - if (isset($this->app->getPostParam("deviceId"))) - { - $options['deviceId'] = $this->app->getPostParam("deviceId"); - } - if (isset($this->app->getPostParam("deviceOwner"))) - { - $options['deviceOwner'] = $this->app->getPostParam("deviceOwner"); - } - if (isset($this->app->getPostParam("networkId"))) - { - $options['securityGroups'] = $this->app->getPostParam("securityGroups"); - } - if (isset($this->app->getPostParam("tenantId"))) - { - $options['tenantId'] = $this->app->getPostParam("tenantId"); - } - try - { - $port = getPort($this->app->getPostParam("networkId")); - $port->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); - } - } - - public function deletePort() - { - - try - { - $port = getPort($this->app->getPostParam("portId")); - $port->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); - } - } - - public function createSecurityGroup() - { - $options = array(); - if (isset($this->app->getPostParam("name"))) - { - $options['name'] = $this->app->getPostParam("name"); - } - if (isset($this->app->getPostParam("description"))) - { - $options['description'] = $this->app->getPostParam("description"); - } - try - { - $this->libClass->createSecurityGroup($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); - } - - } - - public function createSecurityGroupRule() - { - $options = array(); - if (isset($this->app->getPostParam("securityGroupId"))) - { - $options['securityGroupId'] = $this->app->getPostParam("securityGroupId"); - } - if (isset($this->app->getPostParam("direction"))) - { - $options['direction'] = $this->app->getPostParam("direction"); - } - if (isset($this->app->getPostParam("ethertype"))) - { - $options['ethertype'] = $this->app->getPostParam("ethertype"); - } - if (isset($this->app->getPostParam("portRangeMin"))) - { - $options['portRangeMin'] = $this->app->getPostParam("portRangeMin"); - } - if (isset($this->app->getPostParam("portRangeMax"))) - { - $options['portRangeMax'] = $this->app->getPostParam("portRangeMax"); - } - if (isset($this->app->getPostParam("protocol"))) - { - $options['protocol'] = $this->app->getPostParam("protocol"); - } - if (isset($this->app->getPostParam("remoteGroupId"))) - { - $options['remoteGroupId'] = $this->app->getPostParam("remoteGroupId"); - } - if (isset($this->app->getPostParam("remoteIpPrefix"))) - { - $options['remoteIpPrefix'] = $this->app->getPostParam("remoteIpPrefix"); - } - try - { - $this->libClass->createSecurityGroupRule($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); - } - } - - - public function listSecurityGroupe() - { - try - { - $this->app->setOutput("listSecurityGroups", $this->libClass->listSecurityGroups()); - } - 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); - } - } - - public function listSecurityGroupeRule() - { - try - { - - $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); - } - } - - public function getSecurityGroupe() - { - try - { - $securityGroupe = $this->libClass->getSecurityGroupe($this->app->getPostParam("securityGroupeId")); - $this->app->setOutput("securityGroupe", $securityGroupe); - } - 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); - } - - } - - public function getSecurityGroupe($securityGroupeId) - { - try - { - $securityGroupe = $this->libClass->getSecurityGroupe($securityGroupeId); - return $securityGroupe; - } - 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); - } - - } - - public function deleteSecurityGroupe() - { - try - { - - $securityGroupe = getSecurityGroupe($this->app->getPostParam("securityGroupeId")); - $securityGroupe->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); - } - } diff --git a/server/core/Plugin.php b/server/core/Plugin.php deleted file mode 100755 index e6fd8a7..0000000 --- a/server/core/Plugin.php +++ /dev/null @@ -1,13 +0,0 @@ -api = $api; - - } - -} diff --git a/server/core/Plugin_Api.php b/server/core/Plugin_Api.php deleted file mode 100755 index 20ffd0c..0000000 --- a/server/core/Plugin_Api.php +++ /dev/null @@ -1,24 +0,0 @@ -"admin", "password"=>"ae5or6cn", "domain"=>["id"=>"Default"]); - $options["scope"] = Array("project"=>Array("name"=>"admin", "domain"=>["id"=>"Default"])); - $options["authUrl"] = "http://148.60.11.31:5000/v3"; - $openstack = new OpenStack\OpenStack($options); - $compute=$openstack->computeV2(["region" => "RegionOne"]); - $servers = $compute->listServers(true); - foreach($servers as $server) - { - $monserv = $server; - echo $server->name."
"; - } - echo "

"; - - $images = $compute->ListImages(); - - $monim = ""; - foreach($images as $image) - { - - - $monim = $image; - echo $image->name."
"; - break; - - - - - } - - $flavors = $compute->ListFlavors(); - - echo "

"; - - $monflav = ""; - - foreach($flavors as $flavor) - { - - $monflav=$flavor; - echo $flavor->name."
"; - break; - } - - $response= $compute->createServer(array('name' => "TestOthmane2",'imageId' => $monim->id , 'flavorId'=>$monflav->id , "networks" => array - ( array("uuid"=> "251b4641-20ff-4a72-8549-1758788b51ce")))); - - - From 5263cf00a253891396c442fe5be29762fb8be50d Mon Sep 17 00:00:00 2001 From: EoleDev Date: Tue, 26 Apr 2016 20:42:31 +0200 Subject: [PATCH 69/71] Refactoring of comments beginning --- server/config.inc.php | 22 +- server/core/App.php | 164 ++- server/core/Automating.php | 9 +- server/core/Compute.php | 552 ++++---- 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 | 150 +- server/init.php | 93 +- 13 files changed, 1535 insertions(+), 1744 deletions(-) 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; - } - $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; - } + 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."); + } + 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(); + +}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; + + 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; } - if($task == "Authenticate"){ - - $App->authenticate(); - $App->show(); - - }else if($task == "Deauthenticate"){ - - $App->deauthenticate(); - $App->show(); - - }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; - } - - }else{ - $App->setOutput("Error", "Token Invalide"); - $App->show(); - } - - - +}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"] - ); - - $App = new App($Args); +$user = ""; +$password = ""; +$project = ""; - if(isset($token)) - $App->setToken($token); + +//token processing +if(isset($_POST["token"])){ + + $token = $_POST["token"]; + +}else if(isset($_POST["user"]) && isset($_POST["password"]) && isset($_POST["project"]) ){ + + $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); ?> From 1d42345e07b2ef557de3c5049864e6885632b9e9 Mon Sep 17 00:00:00 2001 From: EoleDev Date: Wed, 27 Apr 2016 14:22:59 +0200 Subject: [PATCH 70/71] 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(-) 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: [PATCH 71/71] 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(-) 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 *