From 5665d317db7763650e7827c20f6fe131bcce9ad3 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 23 Feb 2016 21:00:31 +0100 Subject: [PATCH 01/20] 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/20] 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/20] 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/20] 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/20] 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 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 06/20] 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 a2f120aa7350e9417e80db26abf36b7e53c3196b Mon Sep 17 00:00:00 2001 From: Apache Date: Wed, 16 Mar 2016 11:11:25 +0100 Subject: [PATCH 07/20] Front-end path redefinition --- client/js/app.js | 2 +- client/js/controllers/home/home.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/client/js/app.js b/client/js/app.js index 1602e65..a26e0ec 100644 --- a/client/js/app.js +++ b/client/js/app.js @@ -24,7 +24,7 @@ mainApp.config(['$routeProvider', function($routeProvider){ templateUrl: 'partials/image/image.html', controller: 'imageCtrl' }).otherwise({ - redirectTo: '/home' + redirectTo: '/' }); }]); diff --git a/client/js/controllers/home/home.js b/client/js/controllers/home/home.js index 4402e62..d20779b 100644 --- a/client/js/controllers/home/home.js +++ b/client/js/controllers/home/home.js @@ -22,17 +22,17 @@ mainApp.controller('homeCtrl', [ '$scope', 'Compute', '$rootScope', 'Loading','I } } - + Image.getImages(function(){}); - + $scope.raiseShowMachineDetailsEvent=function(id){ var callback=function(){ Loading.stop(); var data=Compute.getData(); $rootScope.$broadcast("showMachineDetailsEvent", data.machines[id], data.axioms); - + } Loading.start(); Compute.pullMachines(callback); From f9643dd9ffeec5eda4f563dd695135ac3a681d60 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 19 Mar 2016 12:49:07 +0100 Subject: [PATCH 08/20] Time maagement on token --- server/config.inc.php | 1 + server/core/App.php | 4 ++++ server/core/LibOverride/genTokenOptions.php | 10 +++++++++- server/index.php | 5 ++++- 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/server/config.inc.php b/server/config.inc.php index 9767c72..636ee5e 100644 --- a/server/config.inc.php +++ b/server/config.inc.php @@ -5,6 +5,7 @@ $config["modules_enabled"] = ""; $config["urlAuth"] = "http://148.60.11.31:5000/v3"; + $config["tokenTime"] = 60 //miunte = 60 //miuntess ?> diff --git a/server/core/App.php b/server/core/App.php index d35ccc0..e3c9c22 100755 --- a/server/core/App.php +++ b/server/core/App.php @@ -37,6 +37,10 @@ class App{ } + public function checkToken(){ + $this->tokenClass->checkToken(); + } + public function getLibClass($service){ switch($service){ diff --git a/server/core/LibOverride/genTokenOptions.php b/server/core/LibOverride/genTokenOptions.php index bdae8a6..028226a 100755 --- a/server/core/LibOverride/genTokenOptions.php +++ b/server/core/LibOverride/genTokenOptions.php @@ -49,6 +49,12 @@ class genTokenOptions $stack->push(GuzzleMiddleware::log($options['logger'], $options['messageFormatter'])); } } + + public function checkToken(){ + + return $this->backup['time'] > time(); + + } public function genIdentityToken(){ $options = $this->optionsGlobal['Common']; @@ -271,6 +277,7 @@ class genTokenOptions $path = "core/LibOverride/projectTokenData/".$token['saved']["project"]["name"]; //error_log(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"]; $this->backup["project"] = $token['saved']["project"]["name"]; $this->backup["user"] = $token["user"]; @@ -284,7 +291,7 @@ class genTokenOptions public function loadBackup($back){ $backup = unserialize($back); - + $this->backup['time'] = $backup['time']; $this->backup["roles"] = $backup["roles"]; $this->backup["project"] = $backup["project"]; $this->backup["user"] = $backup["user"]; @@ -343,6 +350,7 @@ class genTokenOptions $tokenSerialized["user"]["name"] = serialize($token->user->name); $tokenSerialized["token"]["issued"] = serialize($token->issued); $tokenSerialized["token"]["id"] = serialize($token->id); + $tokenSerialized['time'] = time()+$config['tokenTime']*60; return $tokenSerialized; } diff --git a/server/index.php b/server/index.php index 31feb08..4e9c82b 100755 --- a/server/index.php +++ b/server/index.php @@ -22,7 +22,7 @@ $App->deauthenticate(); $App->show(); - }else{ + }else if($App->checkToken()){ switch($task) { case "identity": @@ -54,6 +54,9 @@ break; } + }else{ + $App->setOuptut("Error", "Token Invalide"); + $App->show(); } From 1fa4dcbab660a7185165b106b178a12de0917f59 Mon Sep 17 00:00:00 2001 From: Yoggzo Date: Mon, 21 Mar 2016 10:19:26 +0100 Subject: [PATCH 09/20] correct error in error management ! --- server/Test/imageTests.php | 21 ++++++++++----------- server/core/ErrorManagement.php | 2 +- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/server/Test/imageTests.php b/server/Test/imageTests.php index 883387d..d184d44 100644 --- a/server/Test/imageTests.php +++ b/server/Test/imageTests.php @@ -15,7 +15,7 @@ $opt['protected'] = false; $opt['minRam'] = 10; //$App->setPostParam('id', 'sdfihlus154dfhj'); -$err = $image->action("createImage"); +//$err = $image->action("createImage"); //Liste des images @@ -35,16 +35,15 @@ foreach($images as $i){ echo "
"; echo "Erreur capturée: "; echo "
"; - - /* - //$App->setPostParam('id', $recup['id']); - $App->setPostParam('id', 'sdfihlus154dfhj'); - $err = $image->action("detailsImage"); - $temp = $App->show(); - $ret = json_decode($temp, true)["Images"]; - echo $ret['id']; - */ - //$App->getPostParam("id"); + +/* +$App->setPostParam('id', 354); +$err = $image->action("deleteImage"); +$temp = $App->show(); +$ret = json_decode($temp, true)["Images"]; +echo $ret['id']; +*/ + diff --git a/server/core/ErrorManagement.php b/server/core/ErrorManagement.php index ff66339..3257dd3 100755 --- a/server/core/ErrorManagement.php +++ b/server/core/ErrorManagement.php @@ -34,7 +34,7 @@ Class errorManagement{ } public function OtherException($error){ - $this->app->setOutput("Error", $error->getMessage); + $this->app->setOutput("Error", $error->getMessage()); } From 3372268aa1fc8ecca9e9a82e50ca59c6865c015d Mon Sep 17 00:00:00 2001 From: stupidon Date: Tue, 22 Mar 2016 16:55:59 +0100 Subject: [PATCH 10/20] completed error management and all functions of Compute module --- server/core/Compute.php | 314 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 285 insertions(+), 29 deletions(-) diff --git a/server/core/Compute.php b/server/core/Compute.php index 37fc8ad..370f5a0 100644 --- a/server/core/Compute.php +++ b/server/core/Compute.php @@ -34,6 +34,7 @@ class compute */ public function listServers() { + try{ $serverList = $this->libClass->listServers(true); $servers = Array(); foreach($serverList as $server){ @@ -62,6 +63,22 @@ class compute $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; } /** @@ -70,6 +87,7 @@ class compute */ public function listFlavors() { + try{ $flavorList = $this->libClass->listFlavors(); $flavors = Array(); foreach($flavorList as $flavor){ @@ -83,6 +101,22 @@ class compute $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; } /** @@ -91,7 +125,8 @@ class compute */ public function listImages() { - $imageList = $this->libClass->listImages(); + try{ + $imageList = $this->libClass->listImages(); $images = Array(); foreach($imageList as $image){ $images[$image->id] = Array(); @@ -108,6 +143,22 @@ class compute $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; } /** @@ -116,7 +167,8 @@ class compute */ public function getServer() { - $serverId = $this->app->getPostParam("serverId"); + try{ + $serverId = $this->app->getPostParam("serverId"); if(!isset($serverId)){ $this->app->setOutput("Error", "Server ID is missing, son!"); return; @@ -125,6 +177,22 @@ class compute $server = $this->libClass->getServer($opt); $server->retrieve(); $this->app->setOutput("MyServer", $server); + } + 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; } /** @@ -133,6 +201,7 @@ class compute */ public function getFlavor() { + try{ $flavorId = $this->app->getPostParam("flavorId"); if(!isset($serverId)){ $this->app->setOutput("Error", "Flavor ID is missing, son!"); @@ -142,6 +211,22 @@ class compute $flavor = $this->libClass->getFlavor($opt); $flavor->retrieve(); $this->app->setOutput("MyFlavor", $flavor); + } + 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; } /** @@ -150,6 +235,7 @@ class compute */ public function getImage() { + try{ $imageId = $this->app->getPostParam("imageId"); if(!isset($serverId)){ $this->app->setOutput("Error", "Image ID is missing, son!"); @@ -159,6 +245,22 @@ class compute $image = $this->libClass->getImage($opt); $image->retrieve(); $this->app->setOutput("MyImage", $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; } /** @@ -167,6 +269,7 @@ class compute */ public function createServer() { + try{ $name = $this->app->getPostParam("name"); $imageId = $this->app->getPostParam("imageId"); $flavorId = $this->app->getPostParam("flavorId"); @@ -176,6 +279,23 @@ class compute } $opt = array('name' => $name, 'imageId' => $imageId, 'flavorId' => $flavorId); $server = $this->libClass->createServer($opt); + } + 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; } /** @@ -184,6 +304,7 @@ class compute */ public function updateServer() { + try{ $serverId = $this->app->getPostParam("serverId"); $newName = $this->app->getPostParam("newName"); $newIpv4 = $this->app->getPostParam("newIpv4"); @@ -205,6 +326,22 @@ class compute } $server->update($attr); $this->app->setOutput("Success", $serverId." has been updated successfully."); + } + 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; } /** @@ -213,6 +350,7 @@ class compute */ public function deleteServer() { + try{ $serverId = $this->app->getPostParam("serverId"); if(!isset($serverId)){ $this->app->setOutput("Error", "Server ID is missing, son!"); @@ -222,6 +360,22 @@ class compute $server = $this->libClass->getServer($opt); $server->delete(); $this->app->setOutput("Success", $serverId." has been deleted successfully."); + } + 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; } /** @@ -230,6 +384,7 @@ class compute */ public function changePassword() { + try{ $serverId = $this->app->getPostParam("serverId"); $password = $this->app->getPostParam("newPassword"); if(!isset($serverId) || !isset($password)){ @@ -240,6 +395,22 @@ class compute $server = $this->libClass->getServer($opt); $server->changePassword($password); $this->app->setOutput("Success", "Password for ".$serverId." has been updated successfully."); + } + 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; } /** @@ -248,6 +419,7 @@ class compute */ public function reboot() { + try{ $serverId = $this->app->getPostParam("serverId"); if(!isset($serverId)){ $this->app->setOutput("Error", "Server ID is missing, son!"); @@ -257,6 +429,22 @@ class compute $server = $this->libClass->getServer($opt); $server->reboot(); $this->app->setOutput("Success", $serverId." has been deleted successfully."); + } + 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; } /** @@ -265,6 +453,7 @@ class compute */ public function rebuild() { + try{ $serverId = $this->app->getPostParam("serverId"); $imageId = $this->app->getPostParam("imageId"); $newName = $this->app->getPostParam("newName"); @@ -278,6 +467,22 @@ class compute $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; } /** @@ -287,6 +492,7 @@ class compute */ public function resize() { + try{ $serverId = $this->app->getPostParam("serverId"); $newFlavorId = $this->app->getPostParam("newFlavorId"); if(!isset($serverId)|| !isset($flavorId)){ @@ -296,6 +502,22 @@ class compute $opt = array('id' => $serverId); $server = $this->libClass->getServer($opt); $server->resize($newFlavorId); + } + 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; } /** @@ -304,6 +526,7 @@ class compute */ public function confirmResize() { + try{ $serverId = $this->app->getPostParam("serverId"); if(!isset($serverId)){ $this->app->setOutput("Error", "Server ID is missing!"); @@ -313,6 +536,22 @@ class compute $server = $this->libClass->getServer($opt); $server->confirmResize(); $this->app->setOutput("Success", $serverId." has been resized successfully as the new flavor."); + } + 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; } /** @@ -321,6 +560,7 @@ class compute */ public function revertResize() { + try{ $serverId = $this->app->getPostParam("serverId"); if(!isset($serverId)){ $this->app->setOutput("Error", "Server ID is missing!"); @@ -330,37 +570,53 @@ class compute $server = $this->libClass->getServer($opt); $server->revertResize(); $this->app->setOutput("Success", $serverId." : resize operation has been reverted to the old flavor."); + } + 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; } - /* - public function createImage(array $options) - { - //TODO - } public function listAddresses(array $options = []) { - //TODO + try{ + $serverId = $this->app->getPostParam("serverId"); + if(!isset($serverId)){ + $this->app->setOutput("Error", "Server ID is missing!"); + return; + } + $opt = array('id' => $serverId); + $server = $this->libClass->getServer($opt); + $addresses = $server->listAddresses(); + $this->app->setOutput("Addresses", $addresses); + } + 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; } - public function getMetadata() - { - //TODO - } - public function resetMetadata(array $metadata) - { - //TODO - } - public function mergeMetadata(array $metadata) - { - //TODO - } - public function getMetadataItem($key) - { - //TODO - } - public function deleteMetadataItem($key) - { - //TODO - } -*/ } From 7a61955d8566ec14fbabcfa5b3eab13d3631352f Mon Sep 17 00:00:00 2001 From: stupidon Date: Tue, 22 Mar 2016 17:05:39 +0100 Subject: [PATCH 11/20] indentation and comments --- server/core/Compute.php | 411 ++++++++++++++++++++-------------------- 1 file changed, 208 insertions(+), 203 deletions(-) diff --git a/server/core/Compute.php b/server/core/Compute.php index 370f5a0..4d94705 100644 --- a/server/core/Compute.php +++ b/server/core/Compute.php @@ -35,34 +35,34 @@ class compute 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; - } - $this->app->setOutput("Servers", $servers); + $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; + } + $this->app->setOutput("Servers", $servers); } catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); @@ -77,7 +77,7 @@ class compute $this->app->getErrorInstance()->NotImplementedHandler($e); } catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); + $this->app->getErrorInstance()->OtherException($e); } return; } @@ -88,17 +88,17 @@ class compute 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; + $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); } @@ -115,7 +115,7 @@ class compute $this->app->getErrorInstance()->NotImplementedHandler($e); } catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); + $this->app->getErrorInstance()->OtherException($e); } return; } @@ -126,21 +126,21 @@ class compute 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; + $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); } @@ -157,7 +157,7 @@ class compute $this->app->getErrorInstance()->NotImplementedHandler($e); } catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); + $this->app->getErrorInstance()->OtherException($e); } return; } @@ -168,15 +168,15 @@ class compute public function getServer() { try{ - $serverId = $this->app->getPostParam("serverId"); - if(!isset($serverId)){ - $this->app->setOutput("Error", "Server ID is missing, son!"); - return; - } - $opt = array('id' => $serverId); - $server = $this->libClass->getServer($opt); - $server->retrieve(); - $this->app->setOutput("MyServer", $server); + $serverId = $this->app->getPostParam("serverId"); + if(!isset($serverId)){ + $this->app->setOutput("Error", "Server ID is missing, son!"); + return; + } + $opt = array('id' => $serverId); + $server = $this->libClass->getServer($opt); + $server->retrieve(); + $this->app->setOutput("MyServer", $server); } catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); @@ -191,7 +191,7 @@ class compute $this->app->getErrorInstance()->NotImplementedHandler($e); } catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); + $this->app->getErrorInstance()->OtherException($e); } return; } @@ -202,15 +202,15 @@ class compute public function getFlavor() { try{ - $flavorId = $this->app->getPostParam("flavorId"); - if(!isset($serverId)){ - $this->app->setOutput("Error", "Flavor ID is missing, son!"); - return; - } - $opt = array('id' => $flavorId); - $flavor = $this->libClass->getFlavor($opt); - $flavor->retrieve(); - $this->app->setOutput("MyFlavor", $flavor); + $flavorId = $this->app->getPostParam("flavorId"); + if(!isset($serverId)){ + $this->app->setOutput("Error", "Flavor ID is missing, son!"); + return; + } + $opt = array('id' => $flavorId); + $flavor = $this->libClass->getFlavor($opt); + $flavor->retrieve(); + $this->app->setOutput("MyFlavor", $flavor); } catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); @@ -225,7 +225,7 @@ class compute $this->app->getErrorInstance()->NotImplementedHandler($e); } catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); + $this->app->getErrorInstance()->OtherException($e); } return; } @@ -236,15 +236,15 @@ class compute public function getImage() { try{ - $imageId = $this->app->getPostParam("imageId"); - if(!isset($serverId)){ - $this->app->setOutput("Error", "Image ID is missing, son!"); - return; - } - $opt = array('id' => $imageId); - $image = $this->libClass->getImage($opt); - $image->retrieve(); - $this->app->setOutput("MyImage", $image); + $imageId = $this->app->getPostParam("imageId"); + if(!isset($serverId)){ + $this->app->setOutput("Error", "Image ID is missing, son!"); + return; + } + $opt = array('id' => $imageId); + $image = $this->libClass->getImage($opt); + $image->retrieve(); + $this->app->setOutput("MyImage", $image); } catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); @@ -259,7 +259,7 @@ class compute $this->app->getErrorInstance()->NotImplementedHandler($e); } catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); + $this->app->getErrorInstance()->OtherException($e); } return; } @@ -270,15 +270,15 @@ class compute public function createServer() { try{ - $name = $this->app->getPostParam("name"); - $imageId = $this->app->getPostParam("imageId"); - $flavorId = $this->app->getPostParam("flavorId"); - if(!isset($name) || !isset($imageId) || !isset($flavorId)){ - $this->app->setOutput("Error", "No, we don't let you create a server without a name OR image ID OR flavor ID."); - return; - } - $opt = array('name' => $name, 'imageId' => $imageId, 'flavorId' => $flavorId); - $server = $this->libClass->createServer($opt); + $name = $this->app->getPostParam("name"); + $imageId = $this->app->getPostParam("imageId"); + $flavorId = $this->app->getPostParam("flavorId"); + if(!isset($name) || !isset($imageId) || !isset($flavorId)){ + $this->app->setOutput("Error", "No, we don't let you create a server without a name OR image ID OR flavor ID."); + return; + } + $opt = array('name' => $name, 'imageId' => $imageId, 'flavorId' => $flavorId); + $server = $this->libClass->createServer($opt); } catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); @@ -293,7 +293,7 @@ class compute $this->app->getErrorInstance()->NotImplementedHandler($e); } catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); + $this->app->getErrorInstance()->OtherException($e); } return; } @@ -305,27 +305,27 @@ class compute public function updateServer() { try{ - $serverId = $this->app->getPostParam("serverId"); - $newName = $this->app->getPostParam("newName"); - $newIpv4 = $this->app->getPostParam("newIpv4"); - $newIpv6 = $this->app->getPostParam("newIpv6"); - if(!isset($serverId)|| !(isset($newName) || isset($newIpv4) || isset($newIpv6)) ){ - $this->app->setOutput("Error", "You'll have to provide server ID and the new attribute(IP(v4/v6)/Name) you desire to update!"); - return; - } - $opt = array('id' => $serverId); - $server = $this->libClass->getServer($opt); - if (isset($newName)){ - if(isset($newIpv4)){ - if(isset($newIpv6)){ - $attr = array('name' => $newName, 'accessIPv4' => $newIPv4, 'accessIPv6' => $newIpv6); - } - else $attr = array('name' => $newName, 'accessIPv4' => $newIPv4); + $serverId = $this->app->getPostParam("serverId"); + $newName = $this->app->getPostParam("newName"); + $newIpv4 = $this->app->getPostParam("newIpv4"); + $newIpv6 = $this->app->getPostParam("newIpv6"); + if(!isset($serverId)|| !(isset($newName) || isset($newIpv4) || isset($newIpv6)) ){ + $this->app->setOutput("Error", "You'll have to provide server ID and the new attribute(IP(v4/v6)/Name) you desire to update!"); + return; } - else $attr = array('name' => $newName); - } - $server->update($attr); - $this->app->setOutput("Success", $serverId." has been updated successfully."); + $opt = array('id' => $serverId); + $server = $this->libClass->getServer($opt); + if (isset($newName)){ + if(isset($newIpv4)){ + if(isset($newIpv6)){ + $attr = array('name' => $newName, 'accessIPv4' => $newIPv4, 'accessIPv6' => $newIpv6); + } + else $attr = array('name' => $newName, 'accessIPv4' => $newIPv4); + } + else $attr = array('name' => $newName); + } + $server->update($attr); + $this->app->setOutput("Success", $serverId." has been updated successfully."); } catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); @@ -340,7 +340,7 @@ class compute $this->app->getErrorInstance()->NotImplementedHandler($e); } catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); + $this->app->getErrorInstance()->OtherException($e); } return; } @@ -351,15 +351,15 @@ class compute public function deleteServer() { try{ - $serverId = $this->app->getPostParam("serverId"); - if(!isset($serverId)){ - $this->app->setOutput("Error", "Server ID is missing, son!"); - return; - } - $opt = array('id' => $serverId); - $server = $this->libClass->getServer($opt); - $server->delete(); - $this->app->setOutput("Success", $serverId." has been deleted successfully."); + $serverId = $this->app->getPostParam("serverId"); + if(!isset($serverId)){ + $this->app->setOutput("Error", "Server ID is missing, son!"); + return; + } + $opt = array('id' => $serverId); + $server = $this->libClass->getServer($opt); + $server->delete(); + $this->app->setOutput("Success", $serverId." has been deleted successfully."); } catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); @@ -374,7 +374,7 @@ class compute $this->app->getErrorInstance()->NotImplementedHandler($e); } catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); + $this->app->getErrorInstance()->OtherException($e); } return; } @@ -385,16 +385,16 @@ class compute public function changePassword() { try{ - $serverId = $this->app->getPostParam("serverId"); - $password = $this->app->getPostParam("newPassword"); - if(!isset($serverId) || !isset($password)){ - $this->app->setOutput("Error", "Server ID or new password missing."); - return; - } - $opt = array('id' => $serverId); - $server = $this->libClass->getServer($opt); - $server->changePassword($password); - $this->app->setOutput("Success", "Password for ".$serverId." has been updated successfully."); + $serverId = $this->app->getPostParam("serverId"); + $password = $this->app->getPostParam("newPassword"); + if(!isset($serverId) || !isset($password)){ + $this->app->setOutput("Error", "Server ID or new password missing."); + return; + } + $opt = array('id' => $serverId); + $server = $this->libClass->getServer($opt); + $server->changePassword($password); + $this->app->setOutput("Success", "Password for ".$serverId." has been updated successfully."); } catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); @@ -409,7 +409,7 @@ class compute $this->app->getErrorInstance()->NotImplementedHandler($e); } catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); + $this->app->getErrorInstance()->OtherException($e); } return; } @@ -420,15 +420,15 @@ class compute public function reboot() { try{ - $serverId = $this->app->getPostParam("serverId"); - if(!isset($serverId)){ - $this->app->setOutput("Error", "Server ID is missing, son!"); - return; - } - $opt = array('id' => $serverId); - $server = $this->libClass->getServer($opt); - $server->reboot(); - $this->app->setOutput("Success", $serverId." has been deleted successfully."); + $serverId = $this->app->getPostParam("serverId"); + if(!isset($serverId)){ + $this->app->setOutput("Error", "Server ID is missing, son!"); + return; + } + $opt = array('id' => $serverId); + $server = $this->libClass->getServer($opt); + $server->reboot(); + $this->app->setOutput("Success", $serverId." has been deleted successfully."); } catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); @@ -443,7 +443,7 @@ class compute $this->app->getErrorInstance()->NotImplementedHandler($e); } catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); + $this->app->getErrorInstance()->OtherException($e); } return; } @@ -454,19 +454,19 @@ class compute public function rebuild() { 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."); + $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); @@ -481,7 +481,7 @@ class compute $this->app->getErrorInstance()->NotImplementedHandler($e); } catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); + $this->app->getErrorInstance()->OtherException($e); } return; } @@ -493,15 +493,15 @@ class compute public function resize() { try{ - $serverId = $this->app->getPostParam("serverId"); - $newFlavorId = $this->app->getPostParam("newFlavorId"); - if(!isset($serverId)|| !isset($flavorId)){ - $this->app->setOutput("Error", "You'll have to provide server ID and the new flavor ID!"); - return; - } - $opt = array('id' => $serverId); - $server = $this->libClass->getServer($opt); - $server->resize($newFlavorId); + $serverId = $this->app->getPostParam("serverId"); + $newFlavorId = $this->app->getPostParam("newFlavorId"); + if(!isset($serverId)|| !isset($flavorId)){ + $this->app->setOutput("Error", "You'll have to provide server ID and the new flavor ID!"); + return; + } + $opt = array('id' => $serverId); + $server = $this->libClass->getServer($opt); + $server->resize($newFlavorId); } catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); @@ -516,7 +516,7 @@ class compute $this->app->getErrorInstance()->NotImplementedHandler($e); } catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); + $this->app->getErrorInstance()->OtherException($e); } return; } @@ -527,15 +527,15 @@ class compute public function confirmResize() { try{ - $serverId = $this->app->getPostParam("serverId"); - if(!isset($serverId)){ - $this->app->setOutput("Error", "Server ID is missing!"); - return; - } - $opt = array('id' => $serverId); - $server = $this->libClass->getServer($opt); - $server->confirmResize(); - $this->app->setOutput("Success", $serverId." has been resized successfully as the new flavor."); + $serverId = $this->app->getPostParam("serverId"); + if(!isset($serverId)){ + $this->app->setOutput("Error", "Server ID is missing!"); + return; + } + $opt = array('id' => $serverId); + $server = $this->libClass->getServer($opt); + $server->confirmResize(); + $this->app->setOutput("Success", $serverId." has been resized successfully as the new flavor."); } catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); @@ -550,7 +550,7 @@ class compute $this->app->getErrorInstance()->NotImplementedHandler($e); } catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); + $this->app->getErrorInstance()->OtherException($e); } return; } @@ -561,15 +561,15 @@ class compute public function revertResize() { try{ - $serverId = $this->app->getPostParam("serverId"); - if(!isset($serverId)){ - $this->app->setOutput("Error", "Server ID is missing!"); - return; - } - $opt = array('id' => $serverId); - $server = $this->libClass->getServer($opt); - $server->revertResize(); - $this->app->setOutput("Success", $serverId." : resize operation has been reverted to the old flavor."); + $serverId = $this->app->getPostParam("serverId"); + if(!isset($serverId)){ + $this->app->setOutput("Error", "Server ID is missing!"); + return; + } + $opt = array('id' => $serverId); + $server = $this->libClass->getServer($opt); + $server->revertResize(); + $this->app->setOutput("Success", $serverId." : resize operation has been reverted to the old flavor."); } catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); @@ -584,22 +584,27 @@ class compute $this->app->getErrorInstance()->NotImplementedHandler($e); } catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); + $this->app->getErrorInstance()->OtherException($e); } return; } + /** + * List private and public addresses of a server + * @return void + */ + public function listAddresses(array $options = []) { try{ - $serverId = $this->app->getPostParam("serverId"); - if(!isset($serverId)){ - $this->app->setOutput("Error", "Server ID is missing!"); - return; - } - $opt = array('id' => $serverId); - $server = $this->libClass->getServer($opt); - $addresses = $server->listAddresses(); - $this->app->setOutput("Addresses", $addresses); + $serverId = $this->app->getPostParam("serverId"); + if(!isset($serverId)){ + $this->app->setOutput("Error", "Server ID is missing!"); + return; + } + $opt = array('id' => $serverId); + $server = $this->libClass->getServer($opt); + $addresses = $server->listAddresses(); + $this->app->setOutput("Addresses", $addresses); } catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); @@ -614,7 +619,7 @@ class compute $this->app->getErrorInstance()->NotImplementedHandler($e); } catch(Exception $e){ - $this->app->getErrorInstance()->OtherException($e); + $this->app->getErrorInstance()->OtherException($e); } return; } From c37b891909f10172aa2e355868395c18b6d3efaa Mon Sep 17 00:00:00 2001 From: stupidon Date: Tue, 22 Mar 2016 17:14:40 +0100 Subject: [PATCH 12/20] syntax correction --- server/core/Compute.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/core/Compute.php b/server/core/Compute.php index 4d94705..df43c7c 100644 --- a/server/core/Compute.php +++ b/server/core/Compute.php @@ -458,7 +458,7 @@ class compute $imageId = $this->app->getPostParam("imageId"); $newName = $this->app->getPostParam("newName"); $adminPass = $this->app->getPostParam("adminPass"); - if(!isset($serverId)|| !isset($imageId) || isset($newName) || isset($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; } From 1342db60283cb61a1c3810993575d35b9fb33ac0 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 23 Mar 2016 11:22:12 +0100 Subject: [PATCH 13/20] insertion des commentaires --- server/core/Network.php | 301 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 281 insertions(+), 20 deletions(-) diff --git a/server/core/Network.php b/server/core/Network.php index 65de962..a4e0939 100644 --- a/server/core/Network.php +++ b/server/core/Network.php @@ -1,13 +1,42 @@ {$action.""}(); } - + /** + * Create a new network + * + * @param String name A human-readable name for the network. This name might not be unique + * @param String adminStateUp The administrative state of network. If false (down), the network does not forward packets + * @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 + */ public function create_network() { $options = array(); + // check the name if it is null if (isset($this->app->getPostParam("name"))) { $options['name'] = $this->app->getPostParam("name"); } + // check the adminStateUp if it is null if (isset($this->app->getPostParam("adminStateUp"))) { $options['adminStateUp'] = $this->app->getPostParam("adminStateUp"); } + // check the shared if it is null if (isset($this->app->getPostParam("shared"))) { $options['shared'] = $this->app->getPostParam("shared"); } + // check the tenantId if it is null if (isset($this->app->getPostParam("tenantId"))) { $options['tenantId'] = $this->app->getPostParam("tenantId"); } try { - $network = $this->libClass->createNetworks($options); + $network = $this->libClass->createNetworks($options); } catch(BadResponseError $e) { @@ -68,6 +116,26 @@ class network{ } + /** + * Create a new subnet + * + * @param String networkId A Network this subnet is associated with + * @param String ipVersion IP version (4 or 6) + * @param String cidr CIDR representing the IP address range for this subnet Exmple X.Y.W.Z/12 + * @param String tenantId Owner of network. Only admin users can specify a tenant ID other than their own + * @param String name A human-readable name for the subnet. This name might not be unique + * @param String gatewayIp IP address of the default gateway used by devices on this subnet + * @param String dnsNameservers DNS nameservers used by hosts in this subnet + * @param String enableDhcp Specifies whether DHCP is enabled for this subnet + * @param String hostRoutes Routes that should be used by devices with IP addresses from this subnet (not including the local subnet route) + * @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 void + */ + public function create_subnet() { $options = array(); if (isset($this->app->getPostParam("networkId"))) @@ -139,6 +207,12 @@ class network{ } + /** + * List the ID of the NETWORKS + * + * @return List of Networks ID + */ + public function list_network_ids() { try @@ -176,6 +250,12 @@ class network{ $this->app->setOutput("ListNetworkIds", $list_ids); } + /** + * List the name of the NETWORKS + * + * @return List of Networks name + */ + public function list_network_names() { try @@ -213,7 +293,11 @@ class network{ $this->app->setOutput("ListNetworkNames", $list_names); } - + /** + * List the CIDR of the SUBNETS + * + * @return List of SUBNETS CIDR + */ public function list_cidr() { try @@ -245,7 +329,12 @@ class network{ $this->app->getErrorInstance->NotImplementedHandler($e); } } - + /** + * retrieve a specific network + * @param networkId ID of network which we want to get + * @return Network + */ + retrieve a specific network public function getNetwork() { $network=""; @@ -277,8 +366,13 @@ class network{ $this->app->setOutput("Network", $network); } - - public function getNetwork($netId) + + /** + * internal function + * @param String netId ID of network which we want to get + * @return Network + */ + private function getNetwork($netId) { $network=""; @@ -310,6 +404,11 @@ class network{ return $network; } + /** + * retrieve a specific subnet + * @param subnetId ID of subnet which we want to get + * @return subnet + */ public function getSubnet() { $sbnet=""; @@ -340,8 +439,12 @@ class network{ $this->app->setOutput("Subnet", subnet); } - - public function getSubnet($subnetId) + /** + * internal function + * @param String subnetId ID of subnet which we want to get + * @return subnet + */ + private function getSubnet($subnetId) { $subnet=""; @@ -371,6 +474,18 @@ class network{ return $subnet; } + + /** + * Update a network given + * + * @param String name A human-readable name for the network. This name might not be unique + * @param String adminStateUp The administrative state of network. If false (down), the network does not forward packets + * @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 + **/ public function updateNetwork() { @@ -411,6 +526,25 @@ class network{ } } + /** + * Update a subnet given + * + * @param String networkId A Network this subnet is associated with + * @param String ipVersion IP version (4 or 6) + * @param String cidr CIDR representing the IP address range for this subnet Exmple X.Y.W.Z/12 + * @param String tenantId Owner of network. Only admin users can specify a tenant ID other than their own + * @param String name A human-readable name for the subnet. This name might not be unique + * @param String gatewayIp IP address of the default gateway used by devices on this subnet + * @param String dnsNameservers DNS nameservers used by hosts in this subnet + * @param String enableDhcp Specifies whether DHCP is enabled for this subnet + * @param String hostRoutes Routes that should be used by devices with IP addresses from this subnet (not including the local subnet route) + * @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 void + **/ + public function updateSubnet() { $options = array(); @@ -453,7 +587,16 @@ class network{ $this->app->getErrorInstance->NotImplementedHandler($e); } } - + + /** + * Delete a network given + * + * @param String networkId ID if network which we want to delete + + * + * + * @return void + **/ public function deleteNetwork() { try @@ -479,7 +622,16 @@ class network{ $this->app->getErrorInstance->NotImplementedHandler($e); } } - + + /** + * Delete a subnet given + * + * @param String subnetId ID if network which we want to delete + + * + * + * @return void + **/ public function deleteSubnet() { try @@ -505,6 +657,22 @@ class network{ } } + /** + * Create a new port + * + * @param String networkId Network this port is associated with + * @param String name A human-readable name for the port. This name might not be unique + * @param String adminStateUp The administrative state of port. If false (down), the port does not forward packets + * @param String macAddress MAC address to use on this port + * @param String fixedIps IP addresses for this port + * @param String deviceId Identifies the device (for example, virtual server) using this port + * @param String deviceOwner Identifies the entity (for example, DHCP agent) using this port + * @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 + */ + public function createPort() { $options = array(); @@ -565,6 +733,12 @@ class network{ $this->app->getErrorInstance->NotImplementedHandler($e); } } + + /** + * List the of ports + * + * @return List of ports + */ public function listPorts() { @@ -590,6 +764,12 @@ class network{ } } + /** + * retrieve a specific port given + * @param portId ID of port which we want to get + * @return port + */ + public function getPort() { try @@ -616,7 +796,14 @@ class network{ } - public function getPort($portId) + /** + * internal function + * retrieve a specific port given + * @param portId ID of port which we want to get + * @return port + */ + + private function getPort($portId) { try { @@ -642,6 +829,22 @@ class network{ } + + /** + * Update port given + * + * @param String networkId Network this port is associated with + * @param String name A human-readable name for the port. This name might not be unique + * @param String adminStateUp The administrative state of port. If false (down), the port does not forward packets + * @param String macAddress MAC address to use on this port + * @param String fixedIps IP addresses for this port + * @param String deviceId Identifies the device (for example, virtual server) using this port + * @param String deviceOwner Identifies the entity (for example, DHCP agent) using this port + * @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 + */ public function updatePort() { $options = array(); @@ -704,7 +907,13 @@ class network{ $this->app->getErrorInstance->NotImplementedHandler($e); } } - + /** + * Delete a port given + * + * @param String portId id of port which we wante to delete + + * @return void + */ public function deletePort() { @@ -731,6 +940,15 @@ class network{ } } + /** + * Create a new security groupe + * + * @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 + */ + public function createSecurityGroup() { $options = array(); @@ -764,7 +982,21 @@ 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 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 + * + * @return void + */ public function createSecurityGroupRule() { $options = array(); @@ -822,6 +1054,12 @@ class network{ } } + + /** + * List of Security Groupes + * + * @return List of Security Groupes + */ public function listSecurityGroupe() { @@ -846,6 +1084,13 @@ class network{ $this->app->getErrorInstance->NotImplementedHandler($e); } } + + + /** + * List of Security Groupe Rules + * + * @return List of Security Groupe Rules + */ public function listSecurityGroupeRule() { @@ -872,6 +1117,12 @@ class network{ $this->app->getErrorInstance->NotImplementedHandler($e); } } + + /** + * retrieve a specific Security Groupe given + * @param securityGroupeId ID of security Groupe which we want to get + * @return securityGroupe + */ public function getSecurityGroupe() { @@ -898,8 +1149,14 @@ class network{ } } - - public function getSecurityGroupe($securityGroupeId) + + /** + * internal function + * retrieve a specific Security Groupe given + * @param securityGroupeId ID of security Groupe which we want to get + * @return securityGroupe + */ + private function getSecurityGroupe($securityGroupeId) { try { @@ -924,7 +1181,11 @@ class network{ } } - + /** + * Delete a specific Security Groupe given + * @param securityGroupeId ID of security Groupe which we want to get + * @return void + */ public function deleteSecurityGroupe() { try From 0dc17aa9efb987dcdf6f864f4110450bcc0c9003 Mon Sep 17 00:00:00 2001 From: EoleDev Date: Wed, 23 Mar 2016 15:13:42 +0100 Subject: [PATCH 14/20] Correction Erreur --- client/js/controllers/home/home.js | 2 +- server/core/App.php | 4 ++-- server/core/Compute.php | 1 + server/core/LibOverride/genTokenOptions.php | 8 +++++--- server/index.php | 2 +- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/client/js/controllers/home/home.js b/client/js/controllers/home/home.js index 3332a10..ec6fb6e 100755 --- a/client/js/controllers/home/home.js +++ b/client/js/controllers/home/home.js @@ -44,7 +44,7 @@ mainApp.controller('homeCtrl', [ '$scope', 'Compute', '$rootScope', 'Loading','I if(Identity.isAlreadyLogin()){ - if(Compute.getData().machines == null{ + if(Compute.getData().machines == null){ Loading.start(); Compute.pullData(callMeAfterPullData); } diff --git a/server/core/App.php b/server/core/App.php index e3c9c22..6970e5f 100755 --- a/server/core/App.php +++ b/server/core/App.php @@ -22,7 +22,7 @@ class App{ $this->tokenPost = NULL; $this->tokenClass = new genTokenOptions($args); - $this->openstack = new OpenStack\OpenStack([]); + $this->openstack = new OpenStack\OpenStack(['authUrl' => $args["authUrl"]]); $this->pluginsApi = plugin_api::getInstance(); $this->errorClass = new errorManagement($this); $this->output = array(); @@ -38,7 +38,7 @@ class App{ } public function checkToken(){ - $this->tokenClass->checkToken(); + return $this->tokenClass->checkToken(); } public function getLibClass($service){ diff --git a/server/core/Compute.php b/server/core/Compute.php index 9b01d49..e72abf9 100755 --- a/server/core/Compute.php +++ b/server/core/Compute.php @@ -492,6 +492,7 @@ class compute } return; } + } /** * Resize a server * A call to this method has to be followed by either confirmResize or revertResize diff --git a/server/core/LibOverride/genTokenOptions.php b/server/core/LibOverride/genTokenOptions.php index 028226a..4733c5a 100755 --- a/server/core/LibOverride/genTokenOptions.php +++ b/server/core/LibOverride/genTokenOptions.php @@ -51,9 +51,9 @@ class genTokenOptions } public function checkToken(){ - - return $this->backup['time'] > time(); - + //error_log($this->backup['time'], 0); + //return $this->backup['time'] > time(); + return true; } public function genIdentityToken(){ @@ -307,6 +307,7 @@ class genTokenOptions } private function serializeToken($token){ + global $config; $tokenSerialized = []; $tokenSerialized["token"]["methods"] = serialize($token->methods); $tokenSerialized["roles"] = []; @@ -385,6 +386,7 @@ class genTokenOptions $token->catalog = new Models\Catalog($this->httpClient, $api); $token->catalog->services = []; + error_log(print_r($Saved["catalog"], true), 0); foreach($Saved["catalog"] as $key => $service){ $tmp = new Models\Service($this->httpClient, $api); diff --git a/server/index.php b/server/index.php index 4e9c82b..d6b0329 100755 --- a/server/index.php +++ b/server/index.php @@ -55,7 +55,7 @@ } }else{ - $App->setOuptut("Error", "Token Invalide"); + $App->setOutput("Error", "Token Invalide"); $App->show(); } From 54ec6723deb44e325782afd366eeec01ee29ac55 Mon Sep 17 00:00:00 2001 From: EoleDev Date: Wed, 23 Mar 2016 15:30:47 +0100 Subject: [PATCH 15/20] Maj Library --- server/composer.json | 3 +- server/composer.lock | 48 ++-- server/vendor/composer/installed.json | 240 +++++++++--------- server/vendor/guzzlehttp/guzzle/.travis.yml | 3 +- server/vendor/guzzlehttp/guzzle/CHANGELOG.md | 19 ++ server/vendor/guzzlehttp/guzzle/LICENSE | 2 +- server/vendor/guzzlehttp/guzzle/README.md | 2 +- server/vendor/guzzlehttp/guzzle/composer.json | 2 +- .../vendor/guzzlehttp/guzzle/src/Client.php | 9 +- .../guzzlehttp/guzzle/src/ClientInterface.php | 10 +- .../guzzle/src/Cookie/CookieJar.php | 18 +- .../guzzle/src/Cookie/FileCookieJar.php | 9 +- .../guzzle/src/Handler/CurlFactory.php | 3 + .../guzzle/src/Handler/CurlMultiHandler.php | 2 +- .../guzzle/src/Handler/EasyHandle.php | 5 + .../guzzle/src/Handler/MockHandler.php | 2 +- .../guzzle/src/Handler/StreamHandler.php | 7 +- .../guzzlehttp/guzzle/src/Middleware.php | 7 +- .../guzzlehttp/guzzle/src/functions.php | 46 ++++ .../vendor/php-opencloud/common/.travis.yml | 30 +++ .../common/src/Common/Api/AbstractApi.php | 12 +- .../common/src/Common/Api/AbstractParams.php | 20 +- .../common/src/Common/Api/ApiInterface.php | 2 +- .../common/src/Common/Api/Operation.php | 22 +- .../common/src/Common/Api/Operator.php | 18 +- .../src/Common/Api/OperatorInterface.php | 11 +- .../common/src/Common/Api/Parameter.php | 48 ++-- .../common/src/Common/ArrayAccessTrait.php | 8 +- .../common/src/Common/Auth/AuthHandler.php | 7 +- .../common/src/Common/Auth/Catalog.php | 4 +- .../src/Common/Auth/IdentityService.php | 4 +- .../common/src/Common/Auth/Token.php | 6 +- .../src/Common/Error/BadResponseError.php | 6 +- .../common/src/Common/Error/BaseError.php | 2 +- .../common/src/Common/Error/Builder.php | 14 +- .../src/Common/Error/NotImplementedError.php | 2 +- .../src/Common/Error/UserInputError.php | 2 +- .../src/Common/HydratorStrategyTrait.php | 4 +- .../common/src/Common/JsonPath.php | 13 +- .../src/Common/JsonSchema/JsonPatch.php | 18 +- .../common/src/Common/JsonSchema/Schema.php | 15 +- .../src/Common/Resource/AbstractResource.php | 24 +- .../common/src/Common/Resource/Creatable.php | 4 +- .../common/src/Common/Resource/Deletable.php | 2 +- .../src/Common/Resource/HasMetadata.php | 10 +- .../src/Common/Resource/HasWaiterTrait.php | 10 +- .../common/src/Common/Resource/Iterator.php | 2 +- .../common/src/Common/Resource/Listable.php | 2 +- .../src/Common/Resource/ResourceInterface.php | 2 +- .../src/Common/Resource/Retrievable.php | 2 +- .../common/src/Common/Resource/Updateable.php | 2 +- .../src/Common/Service/AbstractService.php | 2 +- .../common/src/Common/Service/Builder.php | 40 ++- .../src/Common/Service/ServiceInterface.php | 2 +- .../src/Common/Transport/HandlerStack.php | 4 +- .../src/Common/Transport/JsonSerializer.php | 12 +- .../src/Common/Transport/Middleware.php | 20 +- .../Common/Transport/RequestSerializer.php | 4 +- .../common/src/Common/Transport/Utils.php | 14 +- .../tests/integration/DefaultLogger.php | 2 +- .../common/tests/integration/Runner.php | 12 +- .../integration/SampleManagerInterface.php | 2 +- .../common/tests/integration/TestCase.php | 2 +- .../tests/integration/TestInterface.php | 2 +- .../common/tests/integration/Utils.php | 48 +--- .../common/tests/integration/run.php | 10 - .../tests/unit/Common/Api/OperatorTest.php | 3 +- .../unit/Common/Auth/AuthHandlerTest.php | 10 +- .../unit/Common/JsonSchema/SchemaTest.php | 4 +- .../Common/Transport/JsonSerializerTest.php | 8 +- .../tests/unit/Fixtures/ComputeV2Api.php | 12 +- server/vendor/php-opencloud/openstack | 2 +- 72 files changed, 525 insertions(+), 455 deletions(-) mode change 100644 => 100755 server/composer.json create mode 100644 server/vendor/php-opencloud/common/.travis.yml delete mode 100644 server/vendor/php-opencloud/common/tests/integration/run.php diff --git a/server/composer.json b/server/composer.json old mode 100644 new mode 100755 index 9d44d6e..d5e2dbc --- a/server/composer.json +++ b/server/composer.json @@ -1,6 +1,5 @@ { "require": { - "php-opencloud/openstack": "dev-master", - "php-opencloud/common": "dev-master" + "php-opencloud/openstack": "dev-master" } } diff --git a/server/composer.lock b/server/composer.lock index 6ab8a7f..7d11e49 100644 --- a/server/composer.lock +++ b/server/composer.lock @@ -4,21 +4,21 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "7647ed348aee68f2db6b71e4d2fb1fe7", - "content-hash": "82731500d050a65f09e92b70c1f96ea9", + "hash": "e7cbd5d3df36fb1a3f3378b837068196", + "content-hash": "125e4702f7a417475a4150c889ac6c3d", "packages": [ { "name": "guzzlehttp/guzzle", - "version": "6.1.1", + "version": "6.2.0", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "c6851d6e48f63b69357cbfa55bca116448140e0c" + "reference": "d094e337976dff9d8e2424e8485872194e768662" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/c6851d6e48f63b69357cbfa55bca116448140e0c", - "reference": "c6851d6e48f63b69357cbfa55bca116448140e0c", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/d094e337976dff9d8e2424e8485872194e768662", + "reference": "d094e337976dff9d8e2424e8485872194e768662", "shasum": "" }, "require": { @@ -34,7 +34,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "6.1-dev" + "dev-master": "6.2-dev" } }, "autoload": { @@ -67,7 +67,7 @@ "rest", "web service" ], - "time": "2015-11-23 00:47:50" + "time": "2016-03-21 20:02:09" }, { "name": "guzzlehttp/promises", @@ -246,16 +246,16 @@ }, { "name": "php-opencloud/common", - "version": "dev-master", + "version": "v1.0.2", "source": { "type": "git", "url": "https://github.com/php-opencloud/common.git", - "reference": "fd027b817c3dd8f83b0c8d9fb1df34ebf25f8c62" + "reference": "4a4aec0a4f35b471570271dd1a2e52667dee62b8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-opencloud/common/zipball/fd027b817c3dd8f83b0c8d9fb1df34ebf25f8c62", - "reference": "fd027b817c3dd8f83b0c8d9fb1df34ebf25f8c62", + "url": "https://api.github.com/repos/php-opencloud/common/zipball/4a4aec0a4f35b471570271dd1a2e52667dee62b8", + "reference": "4a4aec0a4f35b471570271dd1a2e52667dee62b8", "shasum": "" }, "require": { @@ -287,7 +287,7 @@ "homepage": "https://github.com/jamiehannaford" } ], - "time": "2016-03-08 12:56:34" + "time": "2016-03-18 13:45:42" }, { "name": "php-opencloud/openstack", @@ -295,25 +295,16 @@ "source": { "type": "git", "url": "https://github.com/php-opencloud/openstack.git", - "reference": "f2ee77024843659d970817a9e7055bb40a3724f9" + "reference": "61626420361a1dab3ed6f9455e1057bda18cc335" }, "dist": { "type": "zip", -<<<<<<< HEAD -<<<<<<< Updated upstream - "url": "https://api.github.com/repos/php-opencloud/openstack/zipball/15aca73f423166c7ef8337ba08615c103c66e931", -======= - "url": "https://api.github.com/repos/php-opencloud/openstack/zipball/f2ee77024843659d970817a9e7055bb40a3724f9", ->>>>>>> develop - "reference": "15aca73f423166c7ef8337ba08615c103c66e931", -======= - "url": "https://api.github.com/repos/php-opencloud/openstack/zipball/f2ee77024843659d970817a9e7055bb40a3724f9", - "reference": "f2ee77024843659d970817a9e7055bb40a3724f9", ->>>>>>> Stashed changes + "url": "https://api.github.com/repos/php-opencloud/openstack/zipball/61626420361a1dab3ed6f9455e1057bda18cc335", + "reference": "61626420361a1dab3ed6f9455e1057bda18cc335", "shasum": "" }, "require": { - "php-opencloud/common": "dev-master" + "php-opencloud/common": "~1.0" }, "require-dev": { "fabpot/php-cs-fixer": "~1.0", @@ -337,7 +328,7 @@ "homepage": "https://github.com/jamiehannaford" } ], - "time": "2016-03-08 14:37:14" + "time": "2016-03-20 10:57:06" }, { "name": "psr/http-message", @@ -393,8 +384,7 @@ "aliases": [], "minimum-stability": "stable", "stability-flags": { - "php-opencloud/openstack": 20, - "php-opencloud/common": 20 + "php-opencloud/openstack": 20 }, "prefer-stable": false, "prefer-lowest": false, diff --git a/server/vendor/composer/installed.json b/server/vendor/composer/installed.json index 8f06408..450bbfb 100644 --- a/server/vendor/composer/installed.json +++ b/server/vendor/composer/installed.json @@ -50,70 +50,6 @@ "response" ] }, - { - "name": "guzzlehttp/guzzle", - "version": "6.1.1", - "version_normalized": "6.1.1.0", - "source": { - "type": "git", - "url": "https://github.com/guzzle/guzzle.git", - "reference": "c6851d6e48f63b69357cbfa55bca116448140e0c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/c6851d6e48f63b69357cbfa55bca116448140e0c", - "reference": "c6851d6e48f63b69357cbfa55bca116448140e0c", - "shasum": "" - }, - "require": { - "guzzlehttp/promises": "~1.0", - "guzzlehttp/psr7": "~1.1", - "php": ">=5.5.0" - }, - "require-dev": { - "ext-curl": "*", - "phpunit/phpunit": "~4.0", - "psr/log": "~1.0" - }, - "time": "2015-11-23 00:47:50", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "6.1-dev" - } - }, - "installation-source": "dist", - "autoload": { - "files": [ - "src/functions_include.php" - ], - "psr-4": { - "GuzzleHttp\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - } - ], - "description": "Guzzle is a PHP HTTP client library", - "homepage": "http://guzzlephp.org/", - "keywords": [ - "client", - "curl", - "framework", - "http", - "http client", - "rest", - "web service" - ] - }, { "name": "justinrainbow/json-schema", "version": "1.6.1", @@ -182,53 +118,6 @@ "schema" ] }, - { - "name": "php-opencloud/common", - "version": "dev-master", - "version_normalized": "9999999-dev", - "source": { - "type": "git", - "url": "https://github.com/php-opencloud/common.git", - "reference": "fd027b817c3dd8f83b0c8d9fb1df34ebf25f8c62" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-opencloud/common/zipball/fd027b817c3dd8f83b0c8d9fb1df34ebf25f8c62", - "reference": "fd027b817c3dd8f83b0c8d9fb1df34ebf25f8c62", - "shasum": "" - }, - "require": { - "guzzlehttp/guzzle": "~6.1", - "justinrainbow/json-schema": "~1.3", - "php": "~7.0" - }, - "require-dev": { - "fabpot/php-cs-fixer": "~1.0", - "jakub-onderka/php-parallel-lint": "0.*", - "phpunit/phpunit": "~4.0", - "psr/log": "~1.0", - "sami/sami": "dev-master", - "satooshi/php-coveralls": "~1.0" - }, - "time": "2016-03-08 12:56:34", - "type": "library", - "installation-source": "source", - "autoload": { - "psr-4": { - "OpenCloud\\": "src/", - "OpenCloud\\Test\\": "tests/unit/", - "OpenCloud\\Integration\\": "tests/integration/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "authors": [ - { - "name": "Jamie Hannaford", - "email": "jamie.hannaford@rackspace.com", - "homepage": "https://github.com/jamiehannaford" - } - ] - }, { "name": "guzzlehttp/promises", "version": "1.1.0", @@ -343,22 +232,88 @@ ] }, { - "name": "php-opencloud/openstack", - "version": "dev-master", - "version_normalized": "9999999-dev", + "name": "guzzlehttp/guzzle", + "version": "6.2.0", + "version_normalized": "6.2.0.0", "source": { "type": "git", - "url": "https://github.com/php-opencloud/openstack.git", - "reference": "f2ee77024843659d970817a9e7055bb40a3724f9" + "url": "https://github.com/guzzle/guzzle.git", + "reference": "d094e337976dff9d8e2424e8485872194e768662" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-opencloud/openstack/zipball/f2ee77024843659d970817a9e7055bb40a3724f9", - "reference": "f2ee77024843659d970817a9e7055bb40a3724f9", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/d094e337976dff9d8e2424e8485872194e768662", + "reference": "d094e337976dff9d8e2424e8485872194e768662", "shasum": "" }, "require": { - "php-opencloud/common": "dev-master" + "guzzlehttp/promises": "~1.0", + "guzzlehttp/psr7": "~1.1", + "php": ">=5.5.0" + }, + "require-dev": { + "ext-curl": "*", + "phpunit/phpunit": "~4.0", + "psr/log": "~1.0" + }, + "time": "2016-03-21 20:02:09", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "6.2-dev" + } + }, + "installation-source": "dist", + "autoload": { + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "GuzzleHttp\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "Guzzle is a PHP HTTP client library", + "homepage": "http://guzzlephp.org/", + "keywords": [ + "client", + "curl", + "framework", + "http", + "http client", + "rest", + "web service" + ] + }, + { + "name": "php-opencloud/common", + "version": "v1.0.2", + "version_normalized": "1.0.2.0", + "source": { + "type": "git", + "url": "https://github.com/php-opencloud/common.git", + "reference": "4a4aec0a4f35b471570271dd1a2e52667dee62b8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-opencloud/common/zipball/4a4aec0a4f35b471570271dd1a2e52667dee62b8", + "reference": "4a4aec0a4f35b471570271dd1a2e52667dee62b8", + "shasum": "" + }, + "require": { + "guzzlehttp/guzzle": "~6.1", + "justinrainbow/json-schema": "~1.3", + "php": "~7.0" }, "require-dev": { "fabpot/php-cs-fixer": "~1.0", @@ -368,7 +323,52 @@ "sami/sami": "dev-master", "satooshi/php-coveralls": "~1.0" }, - "time": "2016-03-08 14:37:14", + "time": "2016-03-18 13:45:42", + "type": "library", + "installation-source": "source", + "autoload": { + "psr-4": { + "OpenCloud\\": "src/", + "OpenCloud\\Test\\": "tests/unit/", + "OpenCloud\\Integration\\": "tests/integration/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "authors": [ + { + "name": "Jamie Hannaford", + "email": "jamie.hannaford@rackspace.com", + "homepage": "https://github.com/jamiehannaford" + } + ] + }, + { + "name": "php-opencloud/openstack", + "version": "dev-master", + "version_normalized": "9999999-dev", + "source": { + "type": "git", + "url": "https://github.com/php-opencloud/openstack.git", + "reference": "61626420361a1dab3ed6f9455e1057bda18cc335" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-opencloud/openstack/zipball/61626420361a1dab3ed6f9455e1057bda18cc335", + "reference": "61626420361a1dab3ed6f9455e1057bda18cc335", + "shasum": "" + }, + "require": { + "php-opencloud/common": "~1.0" + }, + "require-dev": { + "fabpot/php-cs-fixer": "~1.0", + "jakub-onderka/php-parallel-lint": "0.*", + "phpunit/phpunit": "~4.0", + "psr/log": "~1.0", + "sami/sami": "dev-master", + "satooshi/php-coveralls": "~1.0" + }, + "time": "2016-03-20 10:57:06", "type": "library", "installation-source": "source", "autoload": { diff --git a/server/vendor/guzzlehttp/guzzle/.travis.yml b/server/vendor/guzzlehttp/guzzle/.travis.yml index d2060f4..a4cd64c 100644 --- a/server/vendor/guzzlehttp/guzzle/.travis.yml +++ b/server/vendor/guzzlehttp/guzzle/.travis.yml @@ -14,16 +14,17 @@ before_script: - composer install --no-interaction --prefer-source --dev - ~/.nvm/nvm.sh install v0.6.14 - ~/.nvm/nvm.sh run v0.6.14 + - '[ "$TRAVIS_PHP_VERSION" != "7.0" ] || echo "xdebug.overload_var_dump = 1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini' script: make test matrix: allow_failures: - php: hhvm - - php: 7.0 fast_finish: true before_deploy: + - rvm 1.9.3 do gem install mime-types -v 2.6.2 - make package deploy: diff --git a/server/vendor/guzzlehttp/guzzle/CHANGELOG.md b/server/vendor/guzzlehttp/guzzle/CHANGELOG.md index 5b7669b..5c35854 100644 --- a/server/vendor/guzzlehttp/guzzle/CHANGELOG.md +++ b/server/vendor/guzzlehttp/guzzle/CHANGELOG.md @@ -1,5 +1,24 @@ # CHANGELOG +## 6.2.0 - 2016-03-21 + +* Feature: added `GuzzleHttp\json_encode` and `GuzzleHttp\json_decode`. + https://github.com/guzzle/guzzle/pull/1389 +* Bug fix: Fix sleep calculation when waiting for delayed requests. + https://github.com/guzzle/guzzle/pull/1324 +* Feature: More flexible history containers. + https://github.com/guzzle/guzzle/pull/1373 +* Bug fix: defer sink stream opening in StreamHandler. + https://github.com/guzzle/guzzle/pull/1377 +* Bug fix: do not attempt to escape cookie values. + https://github.com/guzzle/guzzle/pull/1406 +* Feature: report original content encoding and length on decoded responses. + https://github.com/guzzle/guzzle/pull/1409 +* Bug fix: rewind seekable request bodies before dispatching to cURL. + https://github.com/guzzle/guzzle/pull/1422 +* Bug fix: provide an empty string to `http_build_query` for HHVM workaround. + https://github.com/guzzle/guzzle/pull/1367 + ## 6.1.1 - 2015-11-22 * Bug fix: Proxy::wrapSync() now correctly proxies to the appropriate handler diff --git a/server/vendor/guzzlehttp/guzzle/LICENSE b/server/vendor/guzzlehttp/guzzle/LICENSE index 9af9fba..ea7f07c 100644 --- a/server/vendor/guzzlehttp/guzzle/LICENSE +++ b/server/vendor/guzzlehttp/guzzle/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2011-2015 Michael Dowling, https://github.com/mtdowling +Copyright (c) 2011-2016 Michael Dowling, https://github.com/mtdowling Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/server/vendor/guzzlehttp/guzzle/README.md b/server/vendor/guzzlehttp/guzzle/README.md index 3af1cc3..06e9497 100644 --- a/server/vendor/guzzlehttp/guzzle/README.md +++ b/server/vendor/guzzlehttp/guzzle/README.md @@ -24,7 +24,7 @@ $res = $client->request('GET', 'https://api.github.com/user', [ ]); echo $res->getStatusCode(); // 200 -echo $res->getHeader('content-type'); +echo $res->getHeaderLine('content-type'); // 'application/json; charset=utf8' echo $res->getBody(); // {"type":"User"...' diff --git a/server/vendor/guzzlehttp/guzzle/composer.json b/server/vendor/guzzlehttp/guzzle/composer.json index 1f8b070..f543372 100644 --- a/server/vendor/guzzlehttp/guzzle/composer.json +++ b/server/vendor/guzzlehttp/guzzle/composer.json @@ -35,7 +35,7 @@ }, "extra": { "branch-alias": { - "dev-master": "6.1-dev" + "dev-master": "6.2-dev" } } } diff --git a/server/vendor/guzzlehttp/guzzle/src/Client.php b/server/vendor/guzzlehttp/guzzle/src/Client.php index 2e86ece..9f7b0cf 100644 --- a/server/vendor/guzzlehttp/guzzle/src/Client.php +++ b/server/vendor/guzzlehttp/guzzle/src/Client.php @@ -93,7 +93,7 @@ class Client implements ClientInterface $options = $this->prepareDefaults($options); return $this->transfer( - $request->withUri($this->buildUri($request->getUri(), $options)), + $request->withUri($this->buildUri($request->getUri(), $options), $request->hasHeader('Host')), $options ); } @@ -173,7 +173,7 @@ class Client implements ClientInterface $cleanedNoProxy = str_replace(' ', '', $noProxy); $defaults['proxy']['no'] = explode(',', $cleanedNoProxy); } - + $this->config = $config + $defaults; if (!empty($config['cookies']) && $config['cookies'] === true) { @@ -291,7 +291,7 @@ class Client implements ClientInterface . 'x-www-form-urlencoded requests, and the multipart ' . 'option to send multipart/form-data requests.'); } - $options['body'] = http_build_query($options['form_params'], null, '&'); + $options['body'] = http_build_query($options['form_params'], '', '&'); unset($options['form_params']); $options['_conditional']['Content-Type'] = 'application/x-www-form-urlencoded'; } @@ -357,7 +357,8 @@ class Client implements ClientInterface } if (isset($options['json'])) { - $modify['body'] = Psr7\stream_for(json_encode($options['json'])); + $jsonStr = \GuzzleHttp\json_encode($options['json']); + $modify['body'] = Psr7\stream_for($jsonStr); $options['_conditional']['Content-Type'] = 'application/json'; unset($options['json']); } diff --git a/server/vendor/guzzlehttp/guzzle/src/ClientInterface.php b/server/vendor/guzzlehttp/guzzle/src/ClientInterface.php index 19068e1..5222dab 100644 --- a/server/vendor/guzzlehttp/guzzle/src/ClientInterface.php +++ b/server/vendor/guzzlehttp/guzzle/src/ClientInterface.php @@ -12,7 +12,7 @@ use Psr\Http\Message\UriInterface; */ interface ClientInterface { - const VERSION = '6.1.1'; + const VERSION = '6.2.0'; /** * Send an HTTP request. @@ -44,14 +44,14 @@ interface ClientInterface * relative path to append to the base path of the client. The URL can * contain the query string as well. * - * @param string $method HTTP method - * @param string|UriInterface $uri URI object or string. - * @param array $options Request options to apply. + * @param string $method HTTP method. + * @param string|UriInterface|null $uri URI object or string (default null). + * @param array $options Request options to apply. * * @return ResponseInterface * @throws GuzzleException */ - public function request($method, $uri, array $options = []); + public function request($method, $uri = null, array $options = []); /** * Create and send an asynchronous HTTP request. diff --git a/server/vendor/guzzlehttp/guzzle/src/Cookie/CookieJar.php b/server/vendor/guzzlehttp/guzzle/src/Cookie/CookieJar.php index 11421fe..0b932ae 100644 --- a/server/vendor/guzzlehttp/guzzle/src/Cookie/CookieJar.php +++ b/server/vendor/guzzlehttp/guzzle/src/Cookie/CookieJar.php @@ -5,7 +5,7 @@ use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; /** - * Cookie jar that stores cookies an an array + * Cookie jar that stores cookies as an array */ class CookieJar implements CookieJarInterface { @@ -58,22 +58,10 @@ class CookieJar implements CookieJarInterface } /** - * Quote the cookie value if it is not already quoted and it contains - * problematic characters. - * - * @param string $value Value that may or may not need to be quoted - * - * @return string + * @deprecated */ public static function getCookieValue($value) { - if (substr($value, 0, 1) !== '"' && - substr($value, -1, 1) !== '"' && - strpbrk($value, ';,=') - ) { - $value = '"' . $value . '"'; - } - return $value; } @@ -248,7 +236,7 @@ class CookieJar implements CookieJarInterface (!$cookie->getSecure() || $scheme == 'https') ) { $values[] = $cookie->getName() . '=' - . self::getCookieValue($cookie->getValue()); + . $cookie->getValue(); } } diff --git a/server/vendor/guzzlehttp/guzzle/src/Cookie/FileCookieJar.php b/server/vendor/guzzlehttp/guzzle/src/Cookie/FileCookieJar.php index e4e6248..9887c1d 100644 --- a/server/vendor/guzzlehttp/guzzle/src/Cookie/FileCookieJar.php +++ b/server/vendor/guzzlehttp/guzzle/src/Cookie/FileCookieJar.php @@ -11,7 +11,7 @@ class FileCookieJar extends CookieJar /** @var bool Control whether to persist session cookies or not. */ private $storeSessionCookies; - + /** * Create a new FileCookieJar object * @@ -55,7 +55,8 @@ class FileCookieJar extends CookieJar } } - if (false === file_put_contents($filename, json_encode($json))) { + $jsonStr = \GuzzleHttp\json_encode($json); + if (false === file_put_contents($filename, $jsonStr)) { throw new \RuntimeException("Unable to save file {$filename}"); } } @@ -73,9 +74,11 @@ class FileCookieJar extends CookieJar $json = file_get_contents($filename); if (false === $json) { throw new \RuntimeException("Unable to load file {$filename}"); + } elseif ($json === '') { + return; } - $data = json_decode($json, true); + $data = \GuzzleHttp\json_decode($json, true); if (is_array($data)) { foreach (json_decode($json, true) as $cookie) { $this->setCookie(new SetCookie($cookie)); diff --git a/server/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php b/server/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php index e8d9388..1091899 100644 --- a/server/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php +++ b/server/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php @@ -265,6 +265,9 @@ class CurlFactory implements CurlFactoryInterface $this->removeHeader('Content-Length', $conf); } $body = $request->getBody(); + if ($body->isSeekable()) { + $body->rewind(); + } $conf[CURLOPT_READFUNCTION] = function ($ch, $fd, $length) use ($body) { return $body->read($length); }; diff --git a/server/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php b/server/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php index 417850b..945d06e 100644 --- a/server/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php +++ b/server/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php @@ -192,6 +192,6 @@ class CurlMultiHandler } } - return max(0, $currentTime - $nextTime); + return max(0, $nextTime - $currentTime) * 1000000; } } diff --git a/server/vendor/guzzlehttp/guzzle/src/Handler/EasyHandle.php b/server/vendor/guzzlehttp/guzzle/src/Handler/EasyHandle.php index c4b927e..7754e91 100644 --- a/server/vendor/guzzlehttp/guzzle/src/Handler/EasyHandle.php +++ b/server/vendor/guzzlehttp/guzzle/src/Handler/EasyHandle.php @@ -56,8 +56,13 @@ final class EasyHandle if (!empty($this->options['decode_content']) && isset($normalizedKeys['content-encoding']) ) { + $headers['x-encoded-content-encoding'] + = $headers[$normalizedKeys['content-encoding']]; unset($headers[$normalizedKeys['content-encoding']]); if (isset($normalizedKeys['content-length'])) { + $headers['x-encoded-content-length'] + = $headers[$normalizedKeys['content-length']]; + $bodyLength = (int) $this->sink->getSize(); if ($bodyLength) { $headers[$normalizedKeys['content-length']] = $bodyLength; diff --git a/server/vendor/guzzlehttp/guzzle/src/Handler/MockHandler.php b/server/vendor/guzzlehttp/guzzle/src/Handler/MockHandler.php index cd7898f..0658769 100644 --- a/server/vendor/guzzlehttp/guzzle/src/Handler/MockHandler.php +++ b/server/vendor/guzzlehttp/guzzle/src/Handler/MockHandler.php @@ -74,7 +74,7 @@ class MockHandler implements \Countable $response = array_shift($this->queue); if (is_callable($response)) { - $response = $response($request, $options); + $response = call_user_func($response, $request, $options); } $response = $response instanceof \Exception diff --git a/server/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php b/server/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php index c835dc7..9f9c05f 100644 --- a/server/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php +++ b/server/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php @@ -138,7 +138,7 @@ class StreamHandler : fopen('php://temp', 'r+'); return is_string($sink) - ? new Psr7\Stream(Psr7\try_fopen($sink, 'r+')) + ? new Psr7\LazyOpenStream($sink, 'w+') : Psr7\stream_for($sink); } @@ -153,10 +153,15 @@ class StreamHandler $stream = new Psr7\InflateStream( Psr7\stream_for($stream) ); + $headers['x-encoded-content-encoding'] + = $headers[$normalizedKeys['content-encoding']]; // Remove content-encoding header unset($headers[$normalizedKeys['content-encoding']]); // Fix content-length header if (isset($normalizedKeys['content-length'])) { + $headers['x-encoded-content-length'] + = $headers[$normalizedKeys['content-length']]; + $length = (int) $stream->getSize(); if ($length == 0) { unset($headers[$normalizedKeys['content-length']]); diff --git a/server/vendor/guzzlehttp/guzzle/src/Middleware.php b/server/vendor/guzzlehttp/guzzle/src/Middleware.php index 85d3165..449ab4b 100644 --- a/server/vendor/guzzlehttp/guzzle/src/Middleware.php +++ b/server/vendor/guzzlehttp/guzzle/src/Middleware.php @@ -75,9 +75,14 @@ final class Middleware * @param array $container Container to hold the history (by reference). * * @return callable Returns a function that accepts the next handler. + * @throws \InvalidArgumentException if container is not an array or ArrayAccess. */ - public static function history(array &$container) + public static function history(&$container) { + if (!is_array($container) && !$container instanceof \ArrayAccess) { + throw new \InvalidArgumentException('history container must be an array or object implementing ArrayAccess'); + } + return function (callable $handler) use (&$container) { return function ($request, array $options) use ($handler, &$container) { return $handler($request, $options)->then( diff --git a/server/vendor/guzzlehttp/guzzle/src/functions.php b/server/vendor/guzzlehttp/guzzle/src/functions.php index 5e93b22..5ab82af 100644 --- a/server/vendor/guzzlehttp/guzzle/src/functions.php +++ b/server/vendor/guzzlehttp/guzzle/src/functions.php @@ -282,3 +282,49 @@ function is_host_in_noproxy($host, array $noProxyArray) return false; } + +/** + * Wrapper for json_decode that throws when an error occurs. + * + * @param string $json JSON data to parse + * @param bool $assoc When true, returned objects will be converted + * into associative arrays. + * @param int $depth User specified recursion depth. + * @param int $options Bitmask of JSON decode options. + * + * @return mixed + * @throws \InvalidArgumentException if the JSON cannot be decoded. + * @link http://www.php.net/manual/en/function.json-decode.php + */ +function json_decode($json, $assoc = false, $depth = 512, $options = 0) +{ + $data = \json_decode($json, $assoc, $depth, $options); + if (JSON_ERROR_NONE !== json_last_error()) { + throw new \InvalidArgumentException( + 'json_decode error: ' . json_last_error_msg()); + } + + return $data; +} + +/** + * Wrapper for JSON encoding that throws when an error occurs. + * + * @param string $value The value being encoded + * @param int $options JSON encode option bitmask + * @param int $depth Set the maximum depth. Must be greater than zero. + * + * @return string + * @throws \InvalidArgumentException if the JSON cannot be encoded. + * @link http://www.php.net/manual/en/function.json-encode.php + */ +function json_encode($value, $options = 0, $depth = 512) +{ + $json = \json_encode($value, $options, $depth); + if (JSON_ERROR_NONE !== json_last_error()) { + throw new \InvalidArgumentException( + 'json_encode error: ' . json_last_error_msg()); + } + + return $json; +} diff --git a/server/vendor/php-opencloud/common/.travis.yml b/server/vendor/php-opencloud/common/.travis.yml new file mode 100644 index 0000000..f15d253 --- /dev/null +++ b/server/vendor/php-opencloud/common/.travis.yml @@ -0,0 +1,30 @@ +language: php + +sudo: false + +cache: + directories: + - $HOME/.composer/cache + +matrix: + include: + - php: 7.0 + - php: nightly + allow_failures: + - php: nightly + fast_finish: true + +before_install: + - composer self-update + +before_script: + - composer install --prefer-source + - vendor/bin/parallel-lint --exclude vendor . + - vendor/bin/php-cs-fixer fix --dry-run --diff --level psr2 . + +after_script: + - php vendor/bin/coveralls -v + +notifications: + email: + - jamie.hannaford@rackspace.com diff --git a/server/vendor/php-opencloud/common/src/Common/Api/AbstractApi.php b/server/vendor/php-opencloud/common/src/Common/Api/AbstractApi.php index beee5e8..09988fd 100644 --- a/server/vendor/php-opencloud/common/src/Common/Api/AbstractApi.php +++ b/server/vendor/php-opencloud/common/src/Common/Api/AbstractApi.php @@ -1,4 +1,4 @@ - true]); } - protected function notRequired(array $param) + protected function notRequired(array $param): array { return array_merge($param, ['required' => false]); } - protected function query(array $param) + protected function query(array $param): array { return array_merge($param, ['location' => AbstractParams::QUERY]); } - protected function url(array $param) + protected function url(array $param): array { return array_merge($param, ['location' => AbstractParams::URL]); } - public function documented(array $param) + public function documented(array $param): array { return array_merge($param, ['required' => true]); } diff --git a/server/vendor/php-opencloud/common/src/Common/Api/AbstractParams.php b/server/vendor/php-opencloud/common/src/Common/Api/AbstractParams.php index 225e025..b21b3dd 100644 --- a/server/vendor/php-opencloud/common/src/Common/Api/AbstractParams.php +++ b/server/vendor/php-opencloud/common/src/Common/Api/AbstractParams.php @@ -1,4 +1,4 @@ - self::INT_TYPE, @@ -38,7 +38,7 @@ DESC ]; } - public function marker() + public function marker(): array { return [ 'type' => 'string', @@ -51,7 +51,7 @@ DESC ]; } - public function id($type) + public function id(string $type): array { return [ 'description' => sprintf("The unique ID, or identifier, for the %s", $type), @@ -60,7 +60,7 @@ DESC ]; } - public function idPath() + public function idPath(): array { return [ 'type' => self::STRING_TYPE, @@ -69,7 +69,7 @@ DESC ]; } - public function name($resource) + public function name(string $resource): array { return [ 'description' => sprintf("The name of the %s", $resource), @@ -79,7 +79,7 @@ DESC } - public function sortDir() + public function sortDir(): array { return [ 'type' => self::STRING_TYPE, @@ -89,7 +89,7 @@ DESC ]; } - public function sortKey() + public function sortKey(): array { return [ 'type' => self::STRING_TYPE, @@ -97,4 +97,4 @@ DESC 'description' => "Sorts by one or more sets of attribute and sort direction combinations.", ]; } -} +} \ No newline at end of file diff --git a/server/vendor/php-opencloud/common/src/Common/Api/ApiInterface.php b/server/vendor/php-opencloud/common/src/Common/Api/ApiInterface.php index d5d26a0..d4629dc 100644 --- a/server/vendor/php-opencloud/common/src/Common/Api/ApiInterface.php +++ b/server/vendor/php-opencloud/common/src/Common/Api/ApiInterface.php @@ -1,4 +1,4 @@ -path; } @@ -57,7 +55,7 @@ class Operation /** * @return string */ - public function getMethod() + public function getMethod(): string { return $this->method; } @@ -69,7 +67,7 @@ class Operation * * @return bool */ - public function hasParam($key) + public function hasParam(string $key): bool { return isset($this->params[$key]); } @@ -79,7 +77,7 @@ class Operation * * @return Parameter */ - public function getParam($name) + public function getParam(string $name) { return isset($this->params[$name]) ? $this->params[$name] : null; } @@ -87,9 +85,9 @@ class Operation /** * @return string */ - public function getJsonKey() + public function getJsonKey(): string { - return $this->jsonKey; + return $this->jsonKey ?: ''; } /** @@ -100,7 +98,7 @@ class Operation * * @return array */ - public static function toParamArray(array $data) + public static function toParamArray(array $data): array { $params = []; @@ -121,7 +119,7 @@ class Operation * @return bool TRUE if validation passes * @throws \Exception If validate fails */ - public function validate(array $userValues) + public function validate(array $userValues): bool { foreach ($this->params as $paramName => $param) { if (array_key_exists($paramName, $userValues)) { @@ -133,4 +131,4 @@ class Operation return true; } -} +} \ No newline at end of file diff --git a/server/vendor/php-opencloud/common/src/Common/Api/Operator.php b/server/vendor/php-opencloud/common/src/Common/Api/Operator.php index 4325b69..5698779 100644 --- a/server/vendor/php-opencloud/common/src/Common/Api/Operator.php +++ b/server/vendor/php-opencloud/common/src/Common/Api/Operator.php @@ -1,7 +1,9 @@ -validate($userValues); @@ -79,7 +81,7 @@ abstract class Operator implements OperatorInterface /** * {@inheritDoc} */ - public function execute(array $definition, array $userValues = []) + public function execute(array $definition, array $userValues = []): ResponseInterface { return $this->sendRequest($this->getOperation($definition), $userValues); } @@ -87,7 +89,7 @@ abstract class Operator implements OperatorInterface /** * {@inheritDoc} */ - public function executeAsync(array $definition, array $userValues = []) + public function executeAsync(array $definition, array $userValues = []): PromiseInterface { return $this->sendRequest($this->getOperation($definition), $userValues, true); } @@ -95,7 +97,7 @@ abstract class Operator implements OperatorInterface /** * {@inheritDoc} */ - public function model($class, $data = null) + public function model(string $class, $data = null): ResourceInterface { $model = new $class($this->client, $this->api); @@ -121,13 +123,13 @@ abstract class Operator implements OperatorInterface * * @return static */ - public function newInstance() + public function newInstance(): self { return new static($this->client, $this->api); } /** - * @return \GuzzleHttp\Psr7\Uri + * @return \GuzzleHttp\Psr7\Uri:null */ protected function getHttpBaseUrl() { diff --git a/server/vendor/php-opencloud/common/src/Common/Api/OperatorInterface.php b/server/vendor/php-opencloud/common/src/Common/Api/OperatorInterface.php index 43c6ce2..168518b 100644 --- a/server/vendor/php-opencloud/common/src/Common/Api/OperatorInterface.php +++ b/server/vendor/php-opencloud/common/src/Common/Api/OperatorInterface.php @@ -1,8 +1,11 @@ -name, 'metadata') !== false) { + if ($this->name && stripos($this->name, 'metadata') !== false) { $this->properties = new Parameter($data['properties']); } else { foreach ($data['properties'] as $name => $property) { @@ -166,7 +166,7 @@ class Parameter * * @return string */ - public function getName() + public function getName(): string { return $this->sentAs ?: $this->name; } @@ -176,7 +176,7 @@ class Parameter * * @return bool */ - public function isRequired() + public function isRequired(): bool { return $this->required === true; } @@ -189,7 +189,7 @@ class Parameter * @return bool TRUE if the validation passes * @throws \Exception If validation fails */ - public function validate($userValues) + public function validate($userValues): bool { $this->validateEnums($userValues); $this->validateType($userValues); @@ -245,9 +245,9 @@ class Parameter * @returns Parameter * @throws \Exception */ - private function getNestedProperty($key) + private function getNestedProperty($key): Parameter { - if (stripos($this->name, 'metadata') !== false && $this->properties instanceof Parameter) { + if ($this->name && stripos($this->name, 'metadata') !== false && $this->properties instanceof Parameter) { return $this->properties; } elseif (isset($this->properties[$key])) { return $this->properties[$key]; @@ -264,7 +264,7 @@ class Parameter * * @return bool */ - private function hasCorrectType($userValue) + private function hasCorrectType($userValue): bool { // Helper fn to see whether an array is associative (i.e. a JSON object) $isAssociative = function ($value) { @@ -293,7 +293,7 @@ class Parameter * * @return bool */ - public function isArray() + public function isArray(): bool { return $this->type == 'array' && $this->itemSchema instanceof Parameter; } @@ -303,12 +303,12 @@ class Parameter * * @return bool */ - public function isObject() + public function isObject(): bool { return $this->type == 'object' && !empty($this->properties); } - public function getLocation() + public function getLocation(): string { return $this->location; } @@ -320,7 +320,7 @@ class Parameter * * @return bool */ - public function hasLocation($value) + public function hasLocation($value): bool { return $this->location == $value; } @@ -330,7 +330,7 @@ class Parameter * * @return string|null */ - public function getPath() + public function getPath(): string { return $this->path; } @@ -338,7 +338,7 @@ class Parameter /** * Retrieves the common schema that an array parameter applies to all its child elements. * - * @return Parameter + * @return Parameter|null */ public function getItemSchema() { @@ -350,7 +350,7 @@ class Parameter * * @param string $name */ - public function setName($name) + public function setName(string $name) { $this->name = $name; } @@ -362,7 +362,7 @@ class Parameter * * @return null|Parameter */ - public function getProperty($name) + public function getProperty(string $name) { if ($this->properties instanceof Parameter) { $this->properties->setName($name); @@ -377,12 +377,12 @@ class Parameter * * @return string|null */ - public function getPrefix() + public function getPrefix(): string { return $this->prefix; } - public function getPrefixedName() + public function getPrefixedName(): string { return $this->prefix . $this->getName(); } diff --git a/server/vendor/php-opencloud/common/src/Common/ArrayAccessTrait.php b/server/vendor/php-opencloud/common/src/Common/ArrayAccessTrait.php index 72bcfce..a9e3aba 100644 --- a/server/vendor/php-opencloud/common/src/Common/ArrayAccessTrait.php +++ b/server/vendor/php-opencloud/common/src/Common/ArrayAccessTrait.php @@ -1,4 +1,4 @@ -internalState[$offset]); } @@ -48,7 +48,7 @@ trait ArrayAccessTrait * * @param string $offset */ - public function offsetUnset($offset) + public function offsetUnset(string $offset) { unset($this->internalState[$offset]); } @@ -60,7 +60,7 @@ trait ArrayAccessTrait * * @return mixed|null */ - public function offsetGet($offset) + public function offsetGet(string $offset) { return $this->offsetExists($offset) ? $this->internalState[$offset] : null; } diff --git a/server/vendor/php-opencloud/common/src/Common/Auth/AuthHandler.php b/server/vendor/php-opencloud/common/src/Common/Auth/AuthHandler.php index 1a36cc0..61a07c9 100644 --- a/server/vendor/php-opencloud/common/src/Common/Auth/AuthHandler.php +++ b/server/vendor/php-opencloud/common/src/Common/Auth/AuthHandler.php @@ -1,4 +1,4 @@ -getUri(), 'tokens') !== false && $request->getMethod() == 'POST'; } diff --git a/server/vendor/php-opencloud/common/src/Common/Auth/Catalog.php b/server/vendor/php-opencloud/common/src/Common/Auth/Catalog.php index b4ab381..22ebc09 100644 --- a/server/vendor/php-opencloud/common/src/Common/Auth/Catalog.php +++ b/server/vendor/php-opencloud/common/src/Common/Auth/Catalog.php @@ -1,4 +1,4 @@ -response = $response; } - public function getRequest() + public function getRequest(): RequestInterface { return $this->request; } - public function getResponse() + public function getResponse(): ResponseInterface { return $this->response; } diff --git a/server/vendor/php-opencloud/common/src/Common/Error/BaseError.php b/server/vendor/php-opencloud/common/src/Common/Error/BaseError.php index a7cb26e..1776890 100644 --- a/server/vendor/php-opencloud/common/src/Common/Error/BaseError.php +++ b/server/vendor/php-opencloud/common/src/Common/Error/BaseError.php @@ -1,4 +1,4 @@ -docDomain . $link; @@ -78,7 +78,7 @@ class Builder * @codeCoverageIgnore * @return string */ - public function str(MessageInterface $message) + public function str(MessageInterface $message): string { if ($message instanceof RequestInterface) { $msg = trim($message->getMethod() . ' ' @@ -112,7 +112,7 @@ class Builder * * @return BadResponseError */ - public function httpError(RequestInterface $request, ResponseInterface $response) + public function httpError(RequestInterface $request, ResponseInterface $response): BadResponseError { $message = $this->header('HTTP Error'); @@ -138,7 +138,7 @@ class Builder return $e; } - private function getStatusCodeMessage($statusCode) + private function getStatusCodeMessage(int $statusCode): string { $errors = [ 400 => 'Please ensure that your input values are valid and well-formed. ', @@ -159,7 +159,7 @@ class Builder * * @return UserInputError */ - public function userInputError($expectedType, $userValue, $furtherLink = null) + public function userInputError(string $expectedType, $userValue, string $furtherLink = null): UserInputError { $message = $this->header('User Input Error'); diff --git a/server/vendor/php-opencloud/common/src/Common/Error/NotImplementedError.php b/server/vendor/php-opencloud/common/src/Common/Error/NotImplementedError.php index 3e01d74..db18f62 100644 --- a/server/vendor/php-opencloud/common/src/Common/Error/NotImplementedError.php +++ b/server/vendor/php-opencloud/common/src/Common/Error/NotImplementedError.php @@ -1,4 +1,4 @@ -jsonStructure = $this->setPath($path, $value, $this->jsonStructure); } @@ -53,9 +53,10 @@ class JsonPath * @param $path * @param $value * @param $json + * * @return mixed */ - private function setPath($path, $value, $json) + private function setPath(string $path, $value, array $json): array { $nodes = explode('.', $path); $point = array_shift($nodes); @@ -87,9 +88,10 @@ class JsonPath * Get a path's value. If no path can be matched, NULL is returned. * * @param $path + * * @return mixed|null */ - public function get($path) + public function get(string $path) { return $this->getPath($path, $this->jsonStructure); } @@ -99,9 +101,10 @@ class JsonPath * * @param $path * @param $json + * * @return null */ - private function getPath($path, $json) + private function getPath(string $path, $json) { $nodes = explode('.', $path); $point = array_shift($nodes); diff --git a/server/vendor/php-opencloud/common/src/Common/JsonSchema/JsonPatch.php b/server/vendor/php-opencloud/common/src/Common/JsonSchema/JsonPatch.php index 2c12ec0..74d2a78 100644 --- a/server/vendor/php-opencloud/common/src/Common/JsonSchema/JsonPatch.php +++ b/server/vendor/php-opencloud/common/src/Common/JsonSchema/JsonPatch.php @@ -1,4 +1,4 @@ -makeDiff($src, $dest); } - public function makeDiff($srcStruct, $desStruct, $path = '') + public function makeDiff($srcStruct, $desStruct, string $path = ''): array { $changes = []; @@ -28,7 +28,7 @@ class JsonPatch return $changes; } - protected function handleArray($srcStruct, $desStruct, $path) + protected function handleArray(array $srcStruct, array $desStruct, string $path): array { $changes = []; @@ -53,7 +53,7 @@ class JsonPatch return $changes; } - protected function handleObject($srcStruct, $desStruct, $path) + protected function handleObject(\stdClass $srcStruct, \stdClass $desStruct, string $path): array { $changes = []; @@ -76,12 +76,12 @@ class JsonPatch return $changes; } - protected function shouldPartiallyReplace($o1, $o2) + protected function shouldPartiallyReplace(\stdClass $o1, \stdClass $o2): bool { return count(array_diff_key((array) $o1, (array) $o2)) < count($o1); } - protected function arrayDiff(array $a1, array $a2) + protected function arrayDiff(array $a1, array $a2): array { $result = []; @@ -94,8 +94,10 @@ class JsonPatch return $result; } - protected function path($root, $path) + protected function path(string $root, $path): string { + $path = (string) $path; + if ($path === '_empty_') { $path = ''; } @@ -103,7 +105,7 @@ class JsonPatch return rtrim($root, '/') . '/' . ltrim($path, '/'); } - protected function makePatch($op, $path, $val = null) + protected function makePatch(string $op, string $path, $val = null): array { switch ($op) { default: diff --git a/server/vendor/php-opencloud/common/src/Common/JsonSchema/Schema.php b/server/vendor/php-opencloud/common/src/Common/JsonSchema/Schema.php index a1cd380..e1e3f65 100644 --- a/server/vendor/php-opencloud/common/src/Common/JsonSchema/Schema.php +++ b/server/vendor/php-opencloud/common/src/Common/JsonSchema/Schema.php @@ -1,4 +1,4 @@ -validator = $validator ?: new Validator(); } - public function getPropertyPaths() + public function getPropertyPaths(): array { $paths = []; @@ -26,7 +29,7 @@ class Schema return $paths; } - public function normalizeObject($subject, array $aliases) + public function normalizeObject($subject, array $aliases): \stdClass { $out = new \stdClass; @@ -49,17 +52,17 @@ class Schema $this->validator->check($data, $this->body); } - public function isValid() + public function isValid(): bool { return $this->validator->isValid(); } - public function getErrors() + public function getErrors(): array { return $this->validator->getErrors(); } - public function getErrorString() + public function getErrorString(): string { $msg = "Provided values do not validate. Errors:\n"; diff --git a/server/vendor/php-opencloud/common/src/Common/Resource/AbstractResource.php b/server/vendor/php-opencloud/common/src/Common/Resource/AbstractResource.php index 9f79b07..989fde7 100644 --- a/server/vendor/php-opencloud/common/src/Common/Resource/AbstractResource.php +++ b/server/vendor/php-opencloud/common/src/Common/Resource/AbstractResource.php @@ -1,4 +1,4 @@ -getHeaderLine('Content-Type'), 'application/json') === 0) { $json = Utils::jsonDecode($response); @@ -79,12 +79,12 @@ abstract class AbstractResource extends Operator implements ResourceInterface * * @return mixed|void */ - public function populateFromArray(array $array) + public function populateFromArray(array $array): self { $reflClass = new \ReflectionClass($this); foreach ($array as $key => $val) { - $propertyName = isset($this->aliases[$key]) ? $this->aliases[$key] : $key; + $propertyName = (string) (isset($this->aliases[$key]) ? $this->aliases[$key] : $key); if (property_exists($this, $propertyName)) { if ($type = $this->extractTypeFromDocBlock($reflClass, $propertyName)) { @@ -94,9 +94,11 @@ abstract class AbstractResource extends Operator implements ResourceInterface $this->$propertyName = $val; } } + + return $this; } - private function parseDocBlockValue($type, $val) + private function parseDocBlockValue(string $type, $val) { if (strpos($type, '[]') === 0 && is_array($val)) { $array = []; @@ -113,7 +115,7 @@ abstract class AbstractResource extends Operator implements ResourceInterface return $val; } - private function isNotNativeType($type) + private function isNotNativeType(string $type): bool { return !in_array($type, [ 'string', 'bool', 'boolean', 'double', 'null', 'array', 'object', 'int', 'integer', 'float', 'numeric', @@ -121,7 +123,7 @@ abstract class AbstractResource extends Operator implements ResourceInterface ]); } - private function normalizeModelClass($class) + private function normalizeModelClass(string $class): string { if (strpos($class, '\\') === false) { $currentNamespace = (new \ReflectionClass($this))->getNamespaceName(); @@ -131,7 +133,7 @@ abstract class AbstractResource extends Operator implements ResourceInterface return $class; } - private function extractTypeFromDocBlock(\ReflectionClass $reflClass, $propertyName) + private function extractTypeFromDocBlock(\ReflectionClass $reflClass, string $propertyName) { $docComment = $reflClass->getProperty($propertyName)->getDocComment(); @@ -174,7 +176,7 @@ abstract class AbstractResource extends Operator implements ResourceInterface return $this->execute($definition, $this->getAttrs(array_keys($definition['params']))); } - private function getResourcesKey() + private function getResourcesKey(): string { $resourcesKey = $this->resourcesKey; @@ -189,7 +191,7 @@ abstract class AbstractResource extends Operator implements ResourceInterface /** * {@inheritDoc} */ - public function enumerate(array $def, array $userVals = [], callable $mapFn = null) + public function enumerate(array $def, array $userVals = [], callable $mapFn = null): \Generator { $operation = $this->getOperation($def); @@ -217,7 +219,7 @@ abstract class AbstractResource extends Operator implements ResourceInterface return $iterator(); } - public function extractMultipleInstances(ResponseInterface $response, $key = null) + public function extractMultipleInstances(ResponseInterface $response, string $key = null): array { $key = $key ?: $this->getResourcesKey(); $resourcesData = Utils::jsonDecode($response)[$key]; diff --git a/server/vendor/php-opencloud/common/src/Common/Resource/Creatable.php b/server/vendor/php-opencloud/common/src/Common/Resource/Creatable.php index 19579c1..5f16bfa 100644 --- a/server/vendor/php-opencloud/common/src/Common/Resource/Creatable.php +++ b/server/vendor/php-opencloud/common/src/Common/Resource/Creatable.php @@ -1,4 +1,4 @@ -waitUntil('ACTIVE', $timeout); } - public function waitUntilDeleted($timeout = 60, $sleepPeriod = 1) + public function waitUntilDeleted($timeout = 60, int $sleepPeriod = 1) { $startTime = time(); diff --git a/server/vendor/php-opencloud/common/src/Common/Resource/Iterator.php b/server/vendor/php-opencloud/common/src/Common/Resource/Iterator.php index 63d4455..05507f0 100644 --- a/server/vendor/php-opencloud/common/src/Common/Resource/Iterator.php +++ b/server/vendor/php-opencloud/common/src/Common/Resource/Iterator.php @@ -1,4 +1,4 @@ -rootNamespace, $serviceName, $serviceVersion); @@ -70,19 +70,18 @@ class Builder * directly - this setup includes the configuration of the HTTP client's base URL, and the * attachment of an authentication handler. * - * @param $serviceName The name of the service as it appears in the OpenCloud\* namespace - * @param $serviceVersion The major version of the service - * @param array $serviceOptions The service-specific options to use + * @param string $serviceName The name of the service as it appears in the OpenCloud\* namespace + * @param int $serviceVersion The major version of the service + * @param array $serviceOptions The service-specific options to use * * @return \OpenCloud\Common\Service\ServiceInterface * * @throws \Exception */ - public function createService($serviceName, $serviceVersion, array $serviceOptions = []) + public function createService(string $serviceName, int $serviceVersion, array $serviceOptions = []): ServiceInterface { $options = $this->mergeOptions($serviceOptions); - $this->stockIdentityService($options); $this->stockAuthHandler($options); $this->stockHttpClient($options, $serviceName); @@ -91,7 +90,7 @@ class Builder return new $serviceClass($options['httpClient'], new $apiClass()); } - private function stockHttpClient(array &$options, $serviceName) + private function stockHttpClient(array &$options, string $serviceName) { if (!isset($options['httpClient']) || !($options['httpClient'] instanceof ClientInterface)) { if (strcasecmp($serviceName, 'identity') === 0) { @@ -121,16 +120,9 @@ class Builder } } - private function stockIdentityService(array &$options) - { - if (!isset($options['identityService'])) { - $httpClient = $this->httpClient($options['authUrl'], HandlerStack::create()); - $options['identityService'] = Service::factory($httpClient); - } - } - /** * @param array $options + * * @codeCoverageIgnore */ private function stockAuthHandler(array &$options) @@ -142,14 +134,14 @@ class Builder } } - private function getStack(callable $authHandler, Token $token = null) + private function getStack(callable $authHandler, Token $token = null): HandlerStack { $stack = HandlerStack::create(); $stack->push(Middleware::authHandler($authHandler, $token)); return $stack; } - private function httpClient($baseUrl, HandlerStack $stack) + private function httpClient(string $baseUrl, HandlerStack $stack): ClientInterface { return new Client([ 'base_uri' => Utils::normalizeUrl($baseUrl), @@ -157,7 +149,7 @@ class Builder ]); } - private function mergeOptions(array $serviceOptions) + private function mergeOptions(array $serviceOptions): array { $options = array_merge($this->defaults, $this->globalOptions, $serviceOptions); @@ -165,6 +157,12 @@ class Builder throw new \InvalidArgumentException('"authUrl" is a required option'); } + if (!isset($options['identityService']) || !($options['identityService'] instanceof IdentityService)) { + throw new \InvalidArgumentException(sprintf( + '"identityService" must be specified and implement %s', IdentityService::class + )); + } + return $options; } -} +} \ No newline at end of file diff --git a/server/vendor/php-opencloud/common/src/Common/Service/ServiceInterface.php b/server/vendor/php-opencloud/common/src/Common/Service/ServiceInterface.php index 6ad3089..0f2f23c 100644 --- a/server/vendor/php-opencloud/common/src/Common/Service/ServiceInterface.php +++ b/server/vendor/php-opencloud/common/src/Common/Service/ServiceInterface.php @@ -1,4 +1,4 @@ -getName(); if ($path = $param->getPath()) { @@ -46,7 +46,7 @@ class JsonSerializer * * @return array|mixed */ - private function stockArrayJson(Parameter $param, $userValue) + private function stockArrayJson(Parameter $param, array $userValue): array { $elems = []; foreach ($userValue as $item) { @@ -63,7 +63,7 @@ class JsonSerializer * * @return array */ - private function stockObjectJson(Parameter $param, $userValue) + private function stockObjectJson(Parameter $param, \stdClass $userValue): array { $object = []; foreach ($userValue as $key => $val) { @@ -82,12 +82,12 @@ class JsonSerializer * * @return array */ - public function stockJson(Parameter $param, $userValue, $json) + public function stockJson(Parameter $param, $userValue, array $json): array { if ($param->isArray()) { $userValue = $this->stockArrayJson($param, $userValue); } elseif ($param->isObject()) { - $userValue = $this->stockObjectJson($param, $userValue); + $userValue = $this->stockObjectJson($param, (object) $userValue); } // Populate the final value return $this->stockValue($param, $userValue, $json); diff --git a/server/vendor/php-opencloud/common/src/Common/Transport/Middleware.php b/server/vendor/php-opencloud/common/src/Common/Transport/Middleware.php index 916ff22..2b407a4 100644 --- a/server/vendor/php-opencloud/common/src/Common/Transport/Middleware.php +++ b/server/vendor/php-opencloud/common/src/Common/Transport/Middleware.php @@ -1,4 +1,4 @@ -jsonSerializer = $jsonSerializer ?: new JsonSerializer(); } - public function serializeOptions(Operation $operation, array $userValues = []) + public function serializeOptions(Operation $operation, array $userValues = []): array { $options = ['headers' => []]; diff --git a/server/vendor/php-opencloud/common/src/Common/Transport/Utils.php b/server/vendor/php-opencloud/common/src/Common/Transport/Utils.php index c2a2dc1..ffac9ce 100644 --- a/server/vendor/php-opencloud/common/src/Common/Transport/Utils.php +++ b/server/vendor/php-opencloud/common/src/Common/Transport/Utils.php @@ -1,4 +1,4 @@ - 'JSON_ERROR_DEPTH - Maximum stack depth exceeded', @@ -40,11 +40,11 @@ class Utils * Method for flattening a nested array. * * @param array $data The nested array - * @param null $key The key to extract + * @param string $key The key to extract * * @return array */ - public static function flattenJson($data, $key = null) + public static function flattenJson($data, string $key = null) { return (!empty($data) && $key && isset($data[$key])) ? $data[$key] : $data; } @@ -59,7 +59,7 @@ class Utils * * @return string */ - public static function normalizeUrl($url) + public static function normalizeUrl(string $url): string { if (strpos($url, 'http') === false) { $url = 'http://' . $url; @@ -76,12 +76,12 @@ class Utils * * @return UriInterface */ - public static function addPaths(UriInterface $uri, ...$paths) + public static function addPaths(UriInterface $uri, ...$paths): UriInterface { return uri_for(rtrim((string) $uri, '/') . '/' . implode('/', $paths)); } - public static function appendPath(UriInterface $uri, $path) + public static function appendPath(UriInterface $uri, $path): UriInterface { return uri_for(rtrim((string) $uri, '/') . '/' . $path); } diff --git a/server/vendor/php-opencloud/common/tests/integration/DefaultLogger.php b/server/vendor/php-opencloud/common/tests/integration/DefaultLogger.php index a546c70..d367600 100644 --- a/server/vendor/php-opencloud/common/tests/integration/DefaultLogger.php +++ b/server/vendor/php-opencloud/common/tests/integration/DefaultLogger.php @@ -1,6 +1,6 @@ basePath = $basePath; + $this->namespace = $testNamespace; + $this->logger = new DefaultLogger(); $this->assembleServicesFromSamples(); } @@ -73,15 +76,14 @@ class Runner */ private function getTest($serviceName, $version, $verbosity) { - $namespace = (new \ReflectionClass($this))->getNamespaceName(); - $className = sprintf("%s\\%s\\%sTest", $namespace, Utils::toCamelCase($serviceName), ucfirst($version)); + $className = sprintf("%s\\%s\\%sTest", $this->namespace, Utils::toCamelCase($serviceName), ucfirst($version)); if (!class_exists($className)) { throw new \RuntimeException(sprintf("%s does not exist", $className)); } $basePath = $this->basePath . DIRECTORY_SEPARATOR . $serviceName . DIRECTORY_SEPARATOR . $version; - $smClass = sprintf("%s\\SampleManager", $namespace); + $smClass = sprintf("%s\\SampleManager", $this->namespace); $class = new $className($this->logger, new $smClass($basePath, $verbosity)); if (!($class instanceof TestInterface)) { diff --git a/server/vendor/php-opencloud/common/tests/integration/SampleManagerInterface.php b/server/vendor/php-opencloud/common/tests/integration/SampleManagerInterface.php index f0fe848..c4293ba 100644 --- a/server/vendor/php-opencloud/common/tests/integration/SampleManagerInterface.php +++ b/server/vendor/php-opencloud/common/tests/integration/SampleManagerInterface.php @@ -1,6 +1,6 @@ getenv('OS_AUTH_URL'), - 'region' => getenv('OS_REGION_NAME'), - 'user' => [ - 'id' => getenv('OS_USER_ID'), - 'password' => getenv('OS_PASSWORD'), - ], - 'scope' => [ - 'project' => [ - 'id' => getenv('OS_PROJECT_ID'), - ] - ] - ]; - } - - public static function getAuthOptsV2() - { - $httpClient = new Client([ - 'base_uri' => CommonUtils::normalizeUrl(getenv('OS_AUTH_URL')), - 'handler' => HandlerStack::create(), - ]); - return [ - 'authUrl' => getenv('OS_AUTH_URL'), - 'region' => getenv('OS_REGION_NAME'), - 'username' => getenv('OS_USERNAME'), - 'password' => getenv('OS_PASSWORD'), - 'tenantName' => getenv('OS_TENANT_NAME'), - 'identityService' => new Service($httpClient, new Api), - ]; - } - - public static function getAuthOpts(array $options = []) - { - $authOptions = getenv('OS_IDENTITY_API_VERSION') == '2.0' - ? self::getAuthOptsV2() - : self::getAuthOptsV3(); - - return array_merge($authOptions, $options); - } - public static function toCamelCase($word, $separator = '_') { return str_replace($separator, '', ucwords($word, $separator)); diff --git a/server/vendor/php-opencloud/common/tests/integration/run.php b/server/vendor/php-opencloud/common/tests/integration/run.php deleted file mode 100644 index 5bc5548..0000000 --- a/server/vendor/php-opencloud/common/tests/integration/run.php +++ /dev/null @@ -1,10 +0,0 @@ -runServices(); diff --git a/server/vendor/php-opencloud/common/tests/unit/Common/Api/OperatorTest.php b/server/vendor/php-opencloud/common/tests/unit/Common/Api/OperatorTest.php index 43c5804..e22c25e 100644 --- a/server/vendor/php-opencloud/common/tests/unit/Common/Api/OperatorTest.php +++ b/server/vendor/php-opencloud/common/tests/unit/Common/Api/OperatorTest.php @@ -10,7 +10,6 @@ use GuzzleHttp\Psr7\Uri; use OpenCloud\Common\Api\Operator; use OpenCloud\Common\Resource\AbstractResource; use OpenCloud\Common\Resource\ResourceInterface; -use OpenCloud\Compute\v2\Models\Server; use OpenCloud\Test\Fixtures\ComputeV2Api; use OpenCloud\Test\TestCase; use Prophecy\Argument; @@ -45,7 +44,7 @@ class OperatorTest extends TestCase public function test_it_sends_a_request_when_operations_are_executed() { - $this->client->request('GET', 'test', ['headers' => []])->willReturn(new Request('GET', 'test')); + $this->client->request('GET', 'test', ['headers' => []])->willReturn(new Response()); $this->operator->execute($this->def, []); } diff --git a/server/vendor/php-opencloud/common/tests/unit/Common/Auth/AuthHandlerTest.php b/server/vendor/php-opencloud/common/tests/unit/Common/Auth/AuthHandlerTest.php index 3c77dde..d0d63cf 100644 --- a/server/vendor/php-opencloud/common/tests/unit/Common/Auth/AuthHandlerTest.php +++ b/server/vendor/php-opencloud/common/tests/unit/Common/Auth/AuthHandlerTest.php @@ -53,7 +53,11 @@ class AuthHandlerTest extends TestCase } } -class FakeToken implements Token { - public function getId() {} - public function hasExpired() {} +class FakeToken implements Token +{ + public function getId(): string + {} + + public function hasExpired(): bool + {} } \ No newline at end of file diff --git a/server/vendor/php-opencloud/common/tests/unit/Common/JsonSchema/SchemaTest.php b/server/vendor/php-opencloud/common/tests/unit/Common/JsonSchema/SchemaTest.php index 22663ef..4aae8e5 100644 --- a/server/vendor/php-opencloud/common/tests/unit/Common/JsonSchema/SchemaTest.php +++ b/server/vendor/php-opencloud/common/tests/unit/Common/JsonSchema/SchemaTest.php @@ -95,8 +95,8 @@ class SchemaTest extends TestCase public function test_it_checks_validity() { - $this->validator->isValid()->shouldBeCalled(); + $this->validator->isValid()->shouldBeCalled()->willReturn(true); $this->schema->isValid(); } -} +} \ No newline at end of file diff --git a/server/vendor/php-opencloud/common/tests/unit/Common/Transport/JsonSerializerTest.php b/server/vendor/php-opencloud/common/tests/unit/Common/Transport/JsonSerializerTest.php index 9075594..5e21833 100644 --- a/server/vendor/php-opencloud/common/tests/unit/Common/Transport/JsonSerializerTest.php +++ b/server/vendor/php-opencloud/common/tests/unit/Common/Transport/JsonSerializerTest.php @@ -47,8 +47,8 @@ class JsonSerializerTest extends \PHPUnit_Framework_TestCase $itemSchema = $this->prophesize(Parameter::class); $itemSchema->isArray()->shouldBeCalled()->willReturn(false); $itemSchema->isObject()->shouldBeCalled()->willReturn(false); - $itemSchema->getName()->shouldBeCalled()->willReturn(null); - $itemSchema->getPath()->shouldBeCalled()->willReturn(null); + $itemSchema->getName()->shouldBeCalled()->willReturn(''); + $itemSchema->getPath()->shouldBeCalled()->willReturn(''); $param->getItemSchema()->shouldBeCalled()->willReturn($itemSchema); @@ -67,7 +67,7 @@ class JsonSerializerTest extends \PHPUnit_Framework_TestCase $prop->isArray()->shouldBeCalled()->willReturn(false); $prop->isObject()->shouldBeCalled()->willReturn(false); $prop->getName()->shouldBeCalled()->willReturn('foo'); - $prop->getPath()->shouldBeCalled()->willReturn(null); + $prop->getPath()->shouldBeCalled()->willReturn(''); $param = $this->prophesize(Parameter::class); $param->isArray()->shouldBeCalled()->willReturn(false); @@ -78,7 +78,7 @@ class JsonSerializerTest extends \PHPUnit_Framework_TestCase $expected = ['topLevel' => ['foo' => true]]; - $json = $this->serializer->stockJson($param->reveal(), ['foo' => true], []); + $json = $this->serializer->stockJson($param->reveal(), (object) ['foo' => true], []); $this->assertEquals($expected, $json); } diff --git a/server/vendor/php-opencloud/common/tests/unit/Fixtures/ComputeV2Api.php b/server/vendor/php-opencloud/common/tests/unit/Fixtures/ComputeV2Api.php index d395d10..8c6858d 100644 --- a/server/vendor/php-opencloud/common/tests/unit/Fixtures/ComputeV2Api.php +++ b/server/vendor/php-opencloud/common/tests/unit/Fixtures/ComputeV2Api.php @@ -53,7 +53,17 @@ class ComputeV2Api implements ApiInterface ] ], 'name' => ['type' => 'string', 'required' => true], - 'metadata' => ['type' => 'object', 'location' => 'json'], + 'metadata' => [ + 'type' => 'object', + 'location' => 'json', + 'description' => 'An arbitrary key/value pairing that will be used for metadata.', + 'properties' => [ + 'type' => 'string', + 'description' => << ['type' => 'string'], 'blockDeviceMapping' => [ 'type' => 'array', diff --git a/server/vendor/php-opencloud/openstack b/server/vendor/php-opencloud/openstack index 4ba218f..6162642 160000 --- a/server/vendor/php-opencloud/openstack +++ b/server/vendor/php-opencloud/openstack @@ -1 +1 @@ -Subproject commit 4ba218fc7ed0e618fd83eaf690b2e4e3bf22cde5 +Subproject commit 61626420361a1dab3ed6f9455e1057bda18cc335 From db2c1490b3e7a9be5ce8cbee37f772a1bd4f2268 Mon Sep 17 00:00:00 2001 From: Yoggzo Date: Wed, 23 Mar 2016 15:44:06 +0100 Subject: [PATCH 16/20] auth correction in AppTestClass.php --- server/Test/AppTestClass.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/Test/AppTestClass.php b/server/Test/AppTestClass.php index e1631c5..3f8abbe 100755 --- a/server/Test/AppTestClass.php +++ b/server/Test/AppTestClass.php @@ -22,7 +22,7 @@ class AppTest{ $this->tokenPost = NULL; $this->tokenClass = new genTokenOptions($args); - $this->openstack = new OpenStack\OpenStack([]); + $this->openstack = new OpenStack\OpenStack(['authUrl' => $args["authUrl"]]); $this->pluginsApi = plugin_api::getInstance(); $this->errorClass = new errorManagement($this); $this->output = array(); From dcf0d8b2ba2547720215f7de55a747bf7ec47a0b Mon Sep 17 00:00:00 2001 From: Yoggzo Date: Wed, 23 Mar 2016 15:46:57 +0100 Subject: [PATCH 17/20] begining of automating tasks --- server/Test/imageTests.php | 18 +++++++- server/core/App.php | 6 +++ server/core/Automating.php | 95 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 117 insertions(+), 2 deletions(-) create mode 100644 server/core/Automating.php diff --git a/server/Test/imageTests.php b/server/Test/imageTests.php index d184d44..d86c664 100644 --- a/server/Test/imageTests.php +++ b/server/Test/imageTests.php @@ -1,8 +1,10 @@ action("listImage"); $im = $App->show(); $images = json_decode($im, true)["Images"]; -$recup; echo "Images présentes :"; echo "
"; @@ -33,9 +34,22 @@ foreach($images as $i){ //echo $recup['id']; } echo "
"; -echo "Erreur capturée: "; + +echo "Flavors: "; echo "
"; +$compute->action("listFlavors"); +$flavors = json_decode($App->show(), true)["Flavors"]; + +foreach($flavors as $f){ + echo "Id=".$f['id'].", "; + echo "name=".$f['name'].", "; + echo "ram=".$f['ram'].", "; + echo "disk=".$f['disk'].", "; + echo "vcpus=".$f['vcpus']; + echo "
"; + } + /* $App->setPostParam('id', 354); $err = $image->action("deleteImage"); diff --git a/server/core/App.php b/server/core/App.php index 6970e5f..10813bd 100755 --- a/server/core/App.php +++ b/server/core/App.php @@ -116,6 +116,12 @@ class App{ return $this->postParams[$name]; } + + public function setPostParam($name, $value){ + + $this->postParams[$name]= $value; + + } public function setOutput($key, $out){ diff --git a/server/core/Automating.php b/server/core/Automating.php new file mode 100644 index 0000000..2665541 --- /dev/null +++ b/server/core/Automating.php @@ -0,0 +1,95 @@ +app->setOutput("Error", "Incorrect parameter app"); + } + $this->app = $app; + $this->libClass = $app->getLibClass("Automating"); + } + + /** + * Execute an action + * + * @param String $action name of another function of this class + * + * @return void + */ + public function action($action){ + $this->{$action.""}(); + } + + + private function createImageOnNewServer(){ + try{ + $image = new Image($this->app); + $compute = new Compute($this->app); + + $name = $this->app->getPostParam("name"); + $falvor_id = $this->app->getPostParam("falvor_id"); // Compris entre 1 et 5 (1=petit serveur, 5=gros serveur) + + $opt = Array(); + $opt['name'] = $name; + $opt['visibility'] = 'public'; + $opt['minDisk'] = 100; // A VOIR + $opt['minRam'] = 128; // A VOIR + $opt['protected'] = false; + + $this->app->setPostParam("opt", $opt); + + $image->action("createImage"); + $res = json_decode($this->app->show(), true)["Images"]; + + + $this->app->setPostParam("name", $name); + $this->app->setPostParam("imageId", $res['id']); + $this->app->setPostParam("flavorId", $falvor_id); + + $compute->action("createServer"); + + }catch(BadResponseError $e){ + $this->app->getErrorInstance()->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance()->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance()->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance()->NotImplementedHandler($e); + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } + } + + +} + +?> \ No newline at end of file From e9c7477ff0acedf9b49e508e1543395bbcbf7533 Mon Sep 17 00:00:00 2001 From: Yoggzo Date: Sun, 27 Mar 2016 19:24:03 +0200 Subject: [PATCH 18/20] Modifications in error management and correct error in Image.php --- server/Test/AppTestClass.php | 8 +-- server/Test/imageTests.php | 95 +++++++++++++++++++++++++-------- server/core/App.php | 15 ++++-- server/core/ErrorManagement.php | 37 +++++++++++-- server/core/Image.php | 8 +-- 5 files changed, 124 insertions(+), 39 deletions(-) diff --git a/server/Test/AppTestClass.php b/server/Test/AppTestClass.php index 3f8abbe..a663514 100755 --- a/server/Test/AppTestClass.php +++ b/server/Test/AppTestClass.php @@ -89,9 +89,11 @@ class AppTest{ } public function getPostParam($name){ - - return $this->postParams[$name]; - + if(isset($this->postParams[$name])){ + return $this->postParams[$name]; + }else{ + $this->setOutput("Error", "Missing parameter ".$name); + } } public function setPostParam($name, $value){ diff --git a/server/Test/imageTests.php b/server/Test/imageTests.php index d86c664..4adec08 100644 --- a/server/Test/imageTests.php +++ b/server/Test/imageTests.php @@ -6,6 +6,9 @@ include_once("../core/Compute.php"); $image = new Image($App); $compute = new Compute($App); +// Création image +/* +echo "Création image :
"; $opt = Array(); $opt['name'] = "Test"; $opt['tags'] = ['test', 'openstack']; @@ -16,28 +19,86 @@ $opt['minDisk'] = 1; $opt['protected'] = false; $opt['minRam'] = 10; -//$App->setPostParam('id', 'sdfihlus154dfhj'); -//$err = $image->action("createImage"); +$App->setPostParam('opt', $opt); +$image->action("createImage"); +$retCreate = json_decode($App->show(), true)["Images"]; +$idNew = $retCreate['id']; +*/ +/* +// Delete Image +$App->setPostParam('id', $idNew); +$image->action("deleteImage"); +*/ -//Liste des images +// Liste images $image->action("listImage"); $im = $App->show(); $images = json_decode($im, true)["Images"]; -echo "Images présentes :"; -echo "
"; +echo "List images :
"; foreach($images as $i){ - $recup = $i; - echo $recup['name']; + echo $i['name']."
"; // Nom + echo $i['status']."
"; // Status + $id = $i['id']; // Id + echo $id."
"; + foreach ($i['tags'] as $tag) { // Tags + echo $tag."
"; + } echo "
"; - //echo $recup['id']; - } + } + + +// Details images +echo "Détail image :
"; +$App->setPostParam('id', $id); +$image->action("detailsImage"); +$retDetails = json_decode($App->show(), true)["Images"]; +echo $retDetails['id']."
"; echo "
"; + +/* +// Download image +$App->setPostParam('id', $id); +$image->action("downloadImage"); +*/ + + +// Desactivate Images +echo "Desactivate image :
"; +echo $id."
"; +$App->setPostParam('id', $id); +$err = $image->action("desactivateImage"); +echo "
"; + + +/* +// Resactivate Images +echo $id."
"; +$App->setPostParam('id', $id); +$err = $image->action("resactivateImage"); +*/ + + +/* +// Details images +echo "Update image :
"; +$optUpdate = Array(); +$optUpdate['tags'] = ['ciros', 'testUpdate']; +$App->setPostParam('id', $id); +$App->setPostParam('opt', $optUpdate); +$image->action("updateImage"); +$retDetails = json_decode($App->show(), true)["Images"]; +foreach ($retDetails['tags'] as $tag) { // Tags + echo $tag."
"; +} +*/ + + +/* echo "Flavors: "; echo "
"; - $compute->action("listFlavors"); $flavors = json_decode($App->show(), true)["Flavors"]; @@ -49,17 +110,5 @@ foreach($flavors as $f){ echo "vcpus=".$f['vcpus']; echo "
"; } - -/* -$App->setPostParam('id', 354); -$err = $image->action("deleteImage"); -$temp = $App->show(); -$ret = json_decode($temp, true)["Images"]; -echo $ret['id']; -*/ - - - - - +*/ ?> \ No newline at end of file diff --git a/server/core/App.php b/server/core/App.php index 10813bd..48bb9ab 100755 --- a/server/core/App.php +++ b/server/core/App.php @@ -112,15 +112,20 @@ class App{ } public function getPostParam($name){ - - return $this->postParams[$name]; + + if(isset($this->postParams[$name])){ + return $this->postParams[$name]; + }else{ + $this->setOutput("Error", "Missing parameter ".$name); + } } - public function setPostParam($name, $value){ - - $this->postParams[$name]= $value; + + public function setPostParam($param, $value){ + $this->postParams[$param] = $value; + } public function setOutput($key, $out){ diff --git a/server/core/ErrorManagement.php b/server/core/ErrorManagement.php index 3257dd3..e7cb83e 100755 --- a/server/core/ErrorManagement.php +++ b/server/core/ErrorManagement.php @@ -18,19 +18,48 @@ Class errorManagement{ } public function BaseErrorHandler($error){ - + $this->app->setOutput("Error", "BaseError"); } public function BadResponseHandler($error){ - $this->app->setOutput("Error", "Erreur Interne, Merci de contacter un administrateur!"); + $statusCode = $error->getResponse()->getStatusCode(); + switch ($statusCode) { + case 400: + $this->app->setOutput("Error", "Invalid input."); + break; + + case 401: + $this->app->setOutput("Error", "Authentification failed."); + break; + + case 403: + $this->app->setOutput("Error", "Operation forbidden."); + 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 503: + $this->app->setOutput("Error", "Service unvailable for the moment."); + break; + + default: + $this->app->setOutput("Error", "Unknow error, please contact an administrator."); + break; + } } public function NotImplementedHandler($error){ - $this->app->setOutput("Error", "Erreur Interne, Merci de contacter un administrateur!"); + $this->app->setOutput("Error", "Internal error (not implemented yet), please contact an administrator"); } public function UserInputHandler($error){ - + $this->app->setOutput("Error", "UserInputError"); } public function OtherException($error){ diff --git a/server/core/Image.php b/server/core/Image.php index 71e19ce..e9736a2 100755 --- a/server/core/Image.php +++ b/server/core/Image.php @@ -76,7 +76,7 @@ class image implements Core{ // Check the image name if(isset($opt['name'])){ - $imagesList = listImage(); + $imagesList = $this->listImage(); if(isset($imagesList)){ foreach($imagesList as $image){ if(strcmp($image->name, $opt['name']) == 0){ // if the image name already exists -> error @@ -84,7 +84,7 @@ class image implements Core{ } } } - + $options['name'] = $opt['name']; } else{ $this->app->setOutput("Error", "Missing parameter 'name' for the new image"); @@ -118,7 +118,7 @@ class image implements Core{ if(isset($opt['protected'])){ // boolean $options['protected'] = $opt['protected']; } - if(isset($opt['properties'])){ // type dict ? + if(isset($opt['properties'])){ // type dict $options['properties'] = $opt['properties']; } @@ -187,7 +187,6 @@ class image implements Core{ $this->app->setOutput("Error", "Image doesn't exist"); } else{ - echo 'toto'; $this->app->setOutput("Images", $image); } }catch(BadResponseError $e){ @@ -326,6 +325,7 @@ class image implements Core{ if($image == null){ // if the image don't exists -> error $this->app->setOutput("Error", "Image doesn't exist"); } + $image->reactivate(); }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); From 19d84e2ae4c6710aac2236df4f135409ef519fc8 Mon Sep 17 00:00:00 2001 From: Yoggzo Date: Sun, 27 Mar 2016 19:40:36 +0200 Subject: [PATCH 19/20] Update commentaries --- server/core/Automating.php | 15 ++++++--- server/core/ErrorManagement.php | 55 +++++++++++++++++++++++++++++++-- server/core/Image.php | 4 +-- 3 files changed, 64 insertions(+), 10 deletions(-) diff --git a/server/core/Automating.php b/server/core/Automating.php index 2665541..065cf5e 100644 --- a/server/core/Automating.php +++ b/server/core/Automating.php @@ -1,11 +1,11 @@ {$action.""}(); } - + /** + * Create a new image on a new server + * + * @param $error the error triggered + * + * @return Image the new image created + */ private function createImageOnNewServer(){ try{ $image = new Image($this->app); @@ -87,9 +93,8 @@ class automating implements Core{ }catch(Exception $e){ $this->app->getErrorInstance()->OtherException($e); } + $this->app->setOutput("Auto", $res); } - - } ?> \ No newline at end of file diff --git a/server/core/ErrorManagement.php b/server/core/ErrorManagement.php index e7cb83e..be7080b 100755 --- a/server/core/ErrorManagement.php +++ b/server/core/ErrorManagement.php @@ -1,4 +1,13 @@ app = $args; } + /** + * Put an error message corresponding to a base error in the output + * + * @param $error the error triggered + * + * @return String BaseError message + */ public function BaseErrorHandler($error){ $this->app->setOutput("Error", "BaseError"); } + /** + * Put an error message corresponding to a bad response in function of the status code in the output + * + * @param $error the error triggered + * + * @return String Error message + */ public function BadResponseHandler($error){ $statusCode = $error->getResponse()->getStatusCode(); switch ($statusCode) { @@ -54,19 +83,39 @@ Class errorManagement{ } } + /** + * Put an error message corresponding to a not implemented yet error in the output + * + * @param $error the error triggered + * + * @return String internal error message + */ public function NotImplementedHandler($error){ $this->app->setOutput("Error", "Internal error (not implemented yet), please contact an administrator"); } + /** + * Put an error message corresponding to a user input error in the output + * + * @param $error the error triggered + * + * @return String User input error message + */ public function UserInputHandler($error){ $this->app->setOutput("Error", "UserInputError"); } + /** + * Put an error message corresponding to an other error in the output + * + * @param $error the error triggered + * + * @return String error message + */ public function OtherException($error){ $this->app->setOutput("Error", $error->getMessage()); } - } ?> diff --git a/server/core/Image.php b/server/core/Image.php index e9736a2..c595135 100755 --- a/server/core/Image.php +++ b/server/core/Image.php @@ -5,7 +5,7 @@ * @version 1.0 Initialisation of this file * @since 1.0 Core application's file * -* @author Yogg 'yogg at epsina . com' +* @author Evan Pisani 'yogg at epsina . com' * * @todo Complete the functions with errors detection and finish the descriptions */ @@ -19,7 +19,7 @@ include("CoreInterface.php"); /** * Image Class of the back-end application * -* ADD CLASS DESCRIPTION +* Management of images * */ class image implements Core{ From 804fa322d841d73ee7592885ec500dc94e91b9e6 Mon Sep 17 00:00:00 2001 From: Yoggzo Date: Sun, 27 Mar 2016 19:54:38 +0200 Subject: [PATCH 20/20] difficulties with automating --- server/core/Automating.php | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/server/core/Automating.php b/server/core/Automating.php index 065cf5e..7f2c654 100644 --- a/server/core/Automating.php +++ b/server/core/Automating.php @@ -51,12 +51,14 @@ class automating implements Core{ /** * Create a new image on a new server * - * @param $error the error triggered + * @param $name the name of the new image + * @param $falvor_id the id of the flavor it will be used to create the new server * * @return Image the new image created */ private function createImageOnNewServer(){ try{ + /* POURRI $image = new Image($this->app); $compute = new Compute($this->app); @@ -81,6 +83,32 @@ class automating implements Core{ $this->app->setPostParam("flavorId", $falvor_id); $compute->action("createServer"); + */ + }catch(BadResponseError $e){ + $this->app->getErrorInstance()->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance()->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance()->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance()->NotImplementedHandler($e); + }catch(Exception $e){ + $this->app->getErrorInstance()->OtherException($e); + } + //$this->app->setOutput("Auto", $res); + } + + + /** + * Create a new image on an existing server + * + * @param $name the name of the new image + * @param $server_id the id of the server + * + * @return Image the new image created + */ + private function createImageOnServer(){ + try{ }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); @@ -93,7 +121,6 @@ class automating implements Core{ }catch(Exception $e){ $this->app->getErrorInstance()->OtherException($e); } - $this->app->setOutput("Auto", $res); } }