From 2d260aa6f591030f869063ccdb1f6997d12c1294 Mon Sep 17 00:00:00 2001 From: Yoggzo Date: Tue, 19 Apr 2016 17:17:14 +0200 Subject: correct syntaxt on Network, add tests for automating --- server/core/Network.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'server/core/Network.php') diff --git a/server/core/Network.php b/server/core/Network.php index ad0cbaf..fef3512 100755 --- a/server/core/Network.php +++ b/server/core/Network.php @@ -333,8 +333,7 @@ class network{ * retrieve a specific network * @param networkId ID of network which we want to get * @return Network - */ - retrieve a specific network + */ private function getNetwork() { $network=""; @@ -592,7 +591,6 @@ class network{ * Delete a network given * * @param String networkId ID if network which we want to delete - * * * @return void @@ -627,7 +625,6 @@ class network{ * Delete a subnet given * * @param String subnetId ID if network which we want to delete - * * * @return void @@ -1187,7 +1184,7 @@ class network{ * @return void */ private function deleteSecurityGroupe() - { + { try { @@ -1210,4 +1207,5 @@ class network{ { $this->app->getErrorInstance->NotImplementedHandler($e); } - } + } +} -- cgit v1.2.3 From 438b9b4dcdee7e0c18c3477bb9592ac7efbebfec Mon Sep 17 00:00:00 2001 From: Yoggzo Date: Tue, 19 Apr 2016 23:16:37 +0200 Subject: Correction de cette putain de classe non testee par othmane --- server/core/Network.php | 310 ++++++++++++++++++++++++++++-------------------- 1 file changed, 184 insertions(+), 126 deletions(-) (limited to 'server/core/Network.php') diff --git a/server/core/Network.php b/server/core/Network.php index fef3512..9564f06 100755 --- a/server/core/Network.php +++ b/server/core/Network.php @@ -14,8 +14,6 @@ use OpenCloud\Common\Error\BaseError; use OpenCloud\Common\Error\NotImplementedError; use OpenCloud\Common\Error\UserInputError; -include("CoreInterface.php"); - /** * Network Class of the back-end application * @@ -73,24 +71,29 @@ class network{ { $options = array(); // check the name if it is null - if (isset($this->app->getPostParam("name"))) + $name = $this->app->getPostParam("name"); + $adminStateUp = $this->app->getPostParam("adminStateUp"); + $shared = $this->app->getPostParam("shared"); + $tenantId = $this->app->getPostParam("tenantId"); + + if (isset($name)) { - $options['name'] = $this->app->getPostParam("name"); + $options['name'] = $name; } // check the adminStateUp if it is null - if (isset($this->app->getPostParam("adminStateUp"))) + if (isset($adminStateUp)) { - $options['adminStateUp'] = $this->app->getPostParam("adminStateUp"); + $options['adminStateUp'] = $adminStateUp; } // check the shared if it is null - if (isset($this->app->getPostParam("shared"))) + if (isset($shared)) { - $options['shared'] = $this->app->getPostParam("shared"); + $options['shared'] = $shared; } // check the tenantId if it is null - if (isset($this->app->getPostParam("tenantId"))) + if (isset($tenantId)) { - $options['tenantId'] = $this->app->getPostParam("tenantId"); + $options['tenantId'] =$tenantId; } try { @@ -138,49 +141,61 @@ class network{ private function create_subnet() { $options = array(); - if (isset($this->app->getPostParam("networkId"))) + $networkId = $this->app->getPostParam("networkId"); + $ipVersion = $this->app->getPostParam("ipVersion"); + $cidr = $this->app->getPostParam("cidr"); + $tenantId = $this->app->getPostParam("tenantId"); + $name = $this->app->getPostParam("name"); + $gatewayIp = $this->app->getPostParam("gatewayIp"); + $dnsNameservers = $this->app->getPostParam("dnsNameservers"); + $allocationPools = $this->app->getPostParam("allocationPools"); + $hostRoutes = $this->app->getPostParam("hostRoutes"); + $enableDhcp = $this->app->getPostParam("enableDhcp"); + $tenantId = $this->app->getPostParam("tenantId"); + + if (isset($networkId)) { $options['networkId'] = $networkId; } - if (isset($this->app->getPostParam("ipVersion"))) + if (isset($ipVersion)) { - $options['ipVersion'] = $this->app->getPostParam("ipVersion"); + $options['ipVersion'] = $ipVersion; } - if (isset($this->app->getPostParam("cidr"))) + if (isset($cidr)) { - $options['cidr'] = $this->app->getPostParam("cidr"); + $options['cidr'] = $cidr; } - if (isset($this->app->getPostParam("tenantId"))) + if (isset($tenantId)) { - $options['tenantId'] = $this->app->getPostParam("tenantId"); + $options['tenantId'] = $tenantId; } - if (isset($this->app->getPostParam("name"))) + if (isset($name)) { - $options['name'] = $$this->app->getPostParam("name"); + $options['name'] = $name; } - if (isset($this->app->getPostParam("gatewayIp"))) + if (isset($gatewayIp)) { - $options['gatewayIp'] = $this->app->getPostParam("gatewayIp"); + $options['gatewayIp'] = $gatewayIp; } - if (isset($this->app->getPostParam("dnsNameservers"))) + if (isset($dnsNameservers)) { - $options['dnsNameservers'] = $this->app->getPostParam("dnsNameservers"); + $options['dnsNameservers'] = $dnsNameservers; } - if (isset($this->app->getPostParam("allocationPools"))) + if (isset($allocationPools)) { - $options['allocationPools'] = $this->app->getPostParam("allocationPools"); + $options['allocationPools'] = $allocationPools; } - if (isset($this->app->getPostParam("hostRoutes"))) + if (isset($hostRoutes)) { - $options['hostRoutes'] = $this->app->getPostParam("hostRoutes"); + $options['hostRoutes'] = $hostRoutes; } - if (isset($this->app->getPostParam("enableDhcp"))) + if (isset($enableDhcp)) { - $options['enableDhcp'] = $this->app->getPostParam("enableDhcp"); + $options['enableDhcp'] = $enableDhcp; } - if (isset($this->app->getPostParam("tenantId"))) + if (isset($tenantId)) { - $options['tenantId'] = $this->app->getPostParam("tenantId"); + $options['tenantId'] = $tenantId; } try @@ -339,10 +354,10 @@ class network{ $network=""; try - { $newtork = $this->libClass->getNetwork($this->app->getPostParam("networkId")); - $network->retrieve(); - - + { + $networkId = $this->app->getPostParam("networkId"); + $newtork = $this->libClass->getNetworkP($networkId); + $network->retrieve(); } @@ -371,7 +386,7 @@ class network{ * @param String netId ID of network which we want to get * @return Network */ - private function getNetwork($netId) + private function getNetworkP($netId) { $network=""; @@ -413,10 +428,10 @@ class network{ $sbnet=""; try - { $subnet = $this->libClass->getSubnet($this->app->getPostParam("subnetId")); + { + $subnetId = $this->app->getPostParam("subnetId"); + $subnet = $this->libClass->getSubnet($subnetId); $subnet->retrieve(); - - } catch(BadResponseError $e) @@ -443,7 +458,7 @@ class network{ * @param String subnetId ID of subnet which we want to get * @return subnet */ - private function getSubnet($subnetId) + private function getSubnetP($subnetId) { $subnet=""; @@ -489,21 +504,26 @@ class network{ private function updateNetwork() { $options = array(); - if(isset($this->app->getPostParam("name"))) + $name = $this->app->getPostParam("name"); + $shared = $this->app->getPostParam("shared"); + $adminStateUp = $this->app->getPostParam("adminStateUp"); + + if(isset($name)) { - $options['name'] = $this->app->getPostParam("name"); + $options['name'] = $name; } - if(isset($this->app->getPostParam("shared"))) + if(isset($shared)) { - $options['shared'] = $this->app->getPostParam("shared"); + $options['shared'] = $shared; } - if(isset($this->app->getPostParam("adminStateUp"))) + if(isset($adminStateUp)) { - $options['adminStateUp'] = $this->app->getPostParam("adminStateUp"); + $options['adminStateUp'] = $adminStateUp; } try { - $network = getNetwork($this->app->getPostParam("networkId")); + $networkId = $this->app->getPostParam("networkId"); + $network = getNetworkP($networkId); $network->update($options); } @@ -547,26 +567,30 @@ class network{ private function updateSubnet() { $options = array(); - if(isset($this->app->getPostParam("name"))) + $name = $this->app->getPostParam("name"); + $networkId = $this->app->getPostParam("networkId"); + $ipVersion = $this->app->getPostParam("ipVersion"); + $cidr = $this->app->getPostParam("cidr"); + if(isset($name)) { - $options['name'] = $this->app->getPostParam("name"); + $options['name'] = $name; } - if(isset($this->app->getPostParam("networkId"))) + if(isset($networkId)) { - $options['networkId'] = $this->app->getPostParam("networkId"); + $options['networkId'] = $networkId; } - if(isset($this->app->getPostParam("ipVersion"))) + if(isset($ipVersion)) { - $options['ipVersion'] = $this->app->getPostParam("ipVersion"); + $options['ipVersion'] = $ipVersion; } - if(isset($this->app->getPostParam("cidr"))) + if(isset($cidr)) { - $options['cidr'] = $this->app->getPostParam("cidr"); + $options['cidr'] = $cidr; } try { - $subnet = getSubnet($this->app->getPostParam("networkId")); - + $networkId = $this->app->getPostParam("networkId"); + $subnet = getSubnetP($networkId); $subnet->update($options); } catch(BadResponseError $e) @@ -599,8 +623,8 @@ class network{ { try { - - $network = getNetwork($this->app->getPostParam("networkId")); + $networkId = $this->app->getPostParam("networkId"); + $network = getNetworkP($networkId); $network->delete(); } catch(BadResponseError $e) @@ -633,7 +657,8 @@ class network{ { try { - $subnet = getNetwork($this->app->getPostParam("subnetId")); + $subnetId = $this->app->getPostParam("subnetId"); + $subnet = getNetworkP($subnetId); $subnet->delete(); } catch(BadResponseError $e) @@ -673,41 +698,51 @@ class network{ private function createPort() { $options = array(); - if (isset($this->app->getPostParam("networkId"))) + $networkId = $this->app->getPostParam("networkId"); + $name = $this->app->getPostParam("name"); + $adminStateUp = $this->app->getPostParam("adminStateUp"); + $macAddress = $this->app->getPostParam("macAddress"); + $fixedIps = $this->app->getPostParam("fixedIps"); + $deviceId = $this->app->getPostParam("deviceId"); + $deviceOwner = $this->app->getPostParam("deviceOwner"); + $securityGroups = $this->app->getPostParam("securityGroups"); + $tenantId = $this->app->getPostParam("tenantId"); + + if (isset($networkId)) { - $options['networkId'] = $this->app->getPostParam("networkId"); + $options['networkId'] = $networkId; } - if (isset($this->app->getPostParam("name"))) + if (isset($name)) { - $options['name'] = $this->app->getPostParam("name"); + $options['name'] = $name; } - if (isset($this->app->getPostParam("adminStateUp"))) + if (isset($adminStateUp)) { - $options['adminStateUp'] = $this->app->getPostParam("adminStateUp"); + $options['adminStateUp'] = $adminStateUp; } - if (isset($this->app->getPostParam("macAddress"))) + if (isset($macAddress)) { - $options['macAddress'] = $this->app->getPostParam("macAddress"); + $options['macAddress'] = $macAddress; } - if (isset($this->app->getPostParam("fixedIps"))) + if (isset($fixedIps)) { - $options['fixedIps'] = $this->app->getPostParam("fixedIps"); + $options['fixedIps'] = $fixedIps; } - if (isset($this->app->getPostParam("deviceId"))) + if (isset($deviceId)) { - $options['deviceId'] = $this->app->getPostParam("deviceId"); + $options['deviceId'] = $deviceId; } - if (isset($this->app->getPostParam("deviceOwner"))) + if (isset($deviceOwner)) { - $options['deviceOwner'] = $this->app->getPostParam("deviceOwner"); + $options['deviceOwner'] = $deviceOwner; } - if (isset($this->app->getPostParam("securityGroups"))) + if (isset($securityGroups)) { - $options['securityGroups'] = $this->app->getPostParam("securityGroups"); + $options['securityGroups'] = $securityGroups; } - if (isset($this->app->getPostParam("tenantId"))) + if (isset($tenantId)) { - $options['tenantId'] = $this->app->getPostParam("tenantId"); + $options['tenantId'] = $tenantId; } try { @@ -771,7 +806,8 @@ class network{ { try { - $port = $this->libClass->getport($this->app->getPostParam("portId")); + $portId = $this->app->getPostParam("portId"); + $port = $this->libClass->getport($portId); $this->app->setOutput("Port", $port); } catch(BadResponseError $e) @@ -800,7 +836,7 @@ class network{ * @return port */ - private function getPort($portId) + private function getPortP($portId) { try { @@ -845,46 +881,55 @@ class network{ private function updatePort() { $options = array(); - - if (isset($this->app->getPostParam("networkId"))) + $networkId = $this->app->getPostParam("networkId"); + $name = $this->app->getPostParam("name"); + $adminStateUp = $this->app->getPostParam("adminStateUp"); + $macAddress = $this->app->getPostParam("macAddress"); + $fixedIps = $this->app->getPostParam("fixedIps"); + $deviceId = $this->app->getPostParam("deviceId"); + $deviceOwner = $this->app->getPostParam("deviceOwner"); + $securityGroups = $this->app->getPostParam("securityGroups"); + $tenantId = $this->app->getPostParam("tenantId"); + + if (isset($networkId)) { - $options['networkId'] = $this->app->getPostParam("networkId"); + $options['networkId'] = $networkId; } - if (isset($this->app->getPostParam("name"))) + if (isset($name)) { - $options['name'] =$this->app->getPostParam("name"); + $options['name'] = $name; } - if (isset($this->app->getPostParam("adminStateUp"))) + if (isset($adminStateUp)) { - $options['adminStateUp'] =$this->app->getPostParam("adminStateUp"); + $options['adminStateUp'] = $adminStateUp; } - if (isset($this->app->getPostParam("macAddress"))) + if (isset($macAddress)) { - $options['macAddress'] = $this->app->getPostParam("macAddress"); + $options['macAddress'] = $macAddress; } - if (isset($this->app->getPostParam("fixedIps"))) + if (isset($fixedIps)) { - $options['fixedIps'] = $this->app->getPostParam("fixedIps"); + $options['fixedIps'] = $fixedIps; } - if (isset($this->app->getPostParam("deviceId"))) + if (isset($deviceId)) { - $options['deviceId'] = $this->app->getPostParam("deviceId"); + $options['deviceId'] = $deviceId; } - if (isset($this->app->getPostParam("deviceOwner"))) + if (isset($deviceOwner)) { - $options['deviceOwner'] = $this->app->getPostParam("deviceOwner"); + $options['deviceOwner'] = $deviceOwner; } - if (isset($this->app->getPostParam("networkId"))) + if (isset($securityGroups)) { - $options['securityGroups'] = $this->app->getPostParam("securityGroups"); + $options['securityGroups'] = $securityGroups; } - if (isset($this->app->getPostParam("tenantId"))) + if (isset($tenantId)) { - $options['tenantId'] = $this->app->getPostParam("tenantId"); + $options['tenantId'] = $tenantId; } try { - $port = getPort($this->app->getPostParam("networkId")); + $port = getPortP($networkId); $port->update($options); } catch(BadResponseError $e) @@ -908,7 +953,6 @@ class network{ * Delete a port given * * @param String portId id of port which we wante to delete - * @return void */ private function deletePort() @@ -916,7 +960,8 @@ class network{ try { - $port = getPort($this->app->getPostParam("portId")); + $portId = $this->app->getPostParam("portId"); + $port = getPortP($portId); $port->delete(); } catch(BadResponseError $e) @@ -949,13 +994,16 @@ class network{ private function createSecurityGroup() { $options = array(); - if (isset($this->app->getPostParam("name"))) + $name = $this->app->getPostParam("name"); + $description = $this->app->getPostParam("description"); + + if (isset($name)) { - $options['name'] = $this->app->getPostParam("name"); + $options['name'] = $name; } - if (isset($this->app->getPostParam("description"))) + if (isset($description)) { - $options['description'] = $this->app->getPostParam("description"); + $options['description'] = $description; } try { @@ -997,37 +1045,46 @@ class network{ private function createSecurityGroupRule() { $options = array(); - if (isset($this->app->getPostParam("securityGroupId"))) + $securityGroupId = $this->app->getPostParam("securityGroupId"); + $direction = $this->app->getPostParam("direction"); + $ethertype = $this->app->getPostParam("ethertype"); + $portRangeMin = $this->app->getPostParam("portRangeMin"); + $portRangeMax = $this->app->getPostParam("portRangeMax"); + $protocol = $this->app->getPostParam("protocol"); + $remoteGroupId = $this->app->getPostParam("remoteGroupId"); + $remoteIpPrefix = $this->app->getPostParam("remoteIpPrefix"); + + if (isset($securityGroupId)) { - $options['securityGroupId'] = $this->app->getPostParam("securityGroupId"); + $options['securityGroupId'] = $securityGroupId; } - if (isset($this->app->getPostParam("direction"))) + if (isset($direction)) { - $options['direction'] = $this->app->getPostParam("direction"); + $options['direction'] = $direction; } - if (isset($this->app->getPostParam("ethertype"))) + if (isset($ethertype)) { - $options['ethertype'] = $this->app->getPostParam("ethertype"); + $options['ethertype'] = $ethertype; } - if (isset($this->app->getPostParam("portRangeMin"))) + if (isset($portRangeMin)) { - $options['portRangeMin'] = $this->app->getPostParam("portRangeMin"); + $options['portRangeMin'] = $portRangeMin; } - if (isset($this->app->getPostParam("portRangeMax"))) + if (isset($portRangeMax)) { - $options['portRangeMax'] = $this->app->getPostParam("portRangeMax"); + $options['portRangeMax'] = $portRangeMax; } - if (isset($this->app->getPostParam("protocol"))) + if (isset($protocol)) { - $options['protocol'] = $this->app->getPostParam("protocol"); + $options['protocol'] = $protocol; } - if (isset($this->app->getPostParam("remoteGroupId"))) + if (isset($remoteGroupId)) { - $options['remoteGroupId'] = $this->app->getPostParam("remoteGroupId"); + $options['remoteGroupId'] = $remoteGroupId; } - if (isset($this->app->getPostParam("remoteIpPrefix"))) + if (isset($remoteIpPrefix)) { - $options['remoteIpPrefix'] = $this->app->getPostParam("remoteIpPrefix"); + $options['remoteIpPrefix'] = $remoteIpPrefix; } try { @@ -1125,7 +1182,8 @@ class network{ { try { - $securityGroupe = $this->libClass->getSecurityGroupe($this->app->getPostParam("securityGroupeId")); + $securityGroupId = $this->app->getPostParam("securityGroupeId"); + $securityGroupe = $this->libClass->getSecurityGroupe($securityGroupId); $this->app->setOutput("securityGroupe", $securityGroupe); } catch(BadResponseError $e) @@ -1153,7 +1211,7 @@ class network{ * @param securityGroupeId ID of security Groupe which we want to get * @return securityGroupe */ - private function getSecurityGroupe($securityGroupeId) + private function getSecurityGroupeP($securityGroupeId) { try { @@ -1187,8 +1245,8 @@ class network{ { try { - - $securityGroupe = getSecurityGroupe($this->app->getPostParam("securityGroupeId")); + $securityGroupId = $this->app->getPostParam("securityGroupeId"); + $securityGroupe = getSecurityGroupeP($securityGroupId); $securityGroupe->delete(); } catch(BadResponseError $e) -- cgit v1.2.3 From 94629aeaf523f391f09ef18c1b2ca639e0b02d08 Mon Sep 17 00:00:00 2001 From: Yoggzo Date: Tue, 19 Apr 2016 23:57:03 +0200 Subject: tentative ip publique --- server/Test/automatingTests.php | 65 ++++++++++++++++++++++++++++++++++++++--- server/core/FloatingIp.php | 51 ++++++++++++++++++++++++++++++-- server/core/Network.php | 2 +- 3 files changed, 111 insertions(+), 7 deletions(-) (limited to 'server/core/Network.php') diff --git a/server/Test/automatingTests.php b/server/Test/automatingTests.php index 8715464..078f86b 100755 --- a/server/Test/automatingTests.php +++ b/server/Test/automatingTests.php @@ -2,27 +2,84 @@ include('InitTest.php'); include_once("../core/Image.php"); include_once("../core/Compute.php"); -//include_once("../core/Network.php"); +include_once("../core/Network.php"); //include_once("../core/Automating.php"); include_once("../core/FloatingIp.php"); $image = new Image($App); $compute = new Compute($App); -//$network = new Network($App); +$network = new Network($App); $floatingIp = new FloatingIp($App); //$automating = new Automating($App); // Liste des serveurs +echo "Liste des serveurs :
"; $compute->action("listServers"); $servers = json_decode($App->show(), true)["Servers"]; +$id = null; foreach($servers as $server){ - echo $server['name']." ".$server['id']."
"; + echo $server['name']." ".$server['id']." ".$server['ipv4']."
"; + if(strcmp($server['name'], "bob")){ + $id = $server['id']; + } } +echo "
"; + +/* +// Liste des ports +echo "Liste des ports :
"; +$network->action("listPorts"); +$ports = json_decode($App->show(), true)["Network"]; +foreach ($ports as $p) { + echo $p["fixedIps"]."
"; +} +*/ + + +// liste des floatingip +echo "Liste des floatingip :
"; +$floatingIp->action("listFloatingIp"); +$listFloatingIp = json_decode($App->show(), true)["FloatingIp"]; +$ip = null; +foreach ($listFloatingIp as $floatIp){ + echo $floatIp['floatingIpAddress']." ".$floatIp['id']." ".$floatIp["status"]."
"; + $ip = $floatIp; +} + +echo "
"; + +// Création d'une ip flotante +$opt = array(); +$opt['floatingNetworkId'] = $id; +$opt['floatingip'] = $ip; +//$opt['tenantId'] = "fbf5f920a7954b61b352bc09ce5ae803 "; +//$opt['fixedIpAddress'] = "10.0.0.52"; +//$opt['floatingIpAddress'] = "148.60.11.116"; +//$opt['portId'] = "10.0.0.52"; + +$App->setPostParam('opt', $opt); +$floatingIp->action("createFloatingIp"); +$float = json_decode($App->show(), true)["FloatingIp"]; +if(!isset($float)){ + echo "Erreur pendant la création
"; +} +else{ + foreach ($float as $f) { + echo $f." "; + } + echo "
"; +} + + +echo "
"; // liste des floatingip +echo "Liste des floatingip :
"; $floatingIp->action("listFloatingIp"); $listFloatingIp = json_decode($App->show(), true)["FloatingIp"]; foreach ($listFloatingIp as $floatIp){ - echo "IP : ".$floatIp['floating_ip_address']." et ID: ".$floatIp['id']." ".$floatIp["status"]."
"; + echo $floatIp['floatingIpAddress']." ".$floatIp['id']." ".$floatIp["status"]."
"; } + + ?> \ No newline at end of file diff --git a/server/core/FloatingIp.php b/server/core/FloatingIp.php index f26c3fb..528ab4f 100755 --- a/server/core/FloatingIp.php +++ b/server/core/FloatingIp.php @@ -68,7 +68,6 @@ class floatingIp { $result = array(); $l = $this->libClass->listFloatingIps(); error_log(var_export($l, true), 0); - echo 'toto'; foreach ($l as $tmp) { $result[] = $tmp; } @@ -101,13 +100,61 @@ class floatingIp { $this->app->setOutput("Error", "Incorrect parameter opt"); } try{ - $floatingip = $this->libClass->create($opt); + $floatingip = $this->libClass->createFloatingIp($opt); + echo 'YOLO'; if(!isset($floatingip)){ $this->app->setOutput("Error", "Unknowing error during floating ip creation"); } else{ $this->app->setOutput("FloatingIp", $floatingip); } + }catch(BadResponseError $e){ + echo $e."
"; + $this->app->getErrorInstance()->BadResponseHandler($e); + }catch(UserInputError $e){ + echo $e."
"; + $this->app->getErrorInstance()->UserInputHandler($e); + }catch(BaseError $e){ + echo $e."
"; + $this->app->getErrorInstance()->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + echo $e."
"; + $this->app->getErrorInstance()->NotImplementedHandler($e); + }catch(Exception $e){ + echo $e->getMessage()."
"; + $this->app->getErrorInstance()->OtherException($e); + } + } + + + /** + * Show floatingip details + * + * @param String id the id of the floatingip + * + * @return floatingip details + */ + private function getFloatingIp(){ + $id = $this->app->getPostParam("id"); + if(!isset($id)){ + $this->app->setOutput("Error", "Incorrect parameter opt"); + } + + try{ + /*$l = $this->listFloatingIp(); + $res = null; + foreach ($l as $f) { + if($f['id']==$id){ + $res = $f; + } + } + if(!isset($f)){ + $this->app->setOutput("Error", "Unknow id"); + } + else{*/ + $res = $this->libClass->getFloatingIp($id); + $this->app->setOutput("FloatingIp", $res); + //} }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); }catch(UserInputError $e){ diff --git a/server/core/Network.php b/server/core/Network.php index 9564f06..3e5e2ca 100755 --- a/server/core/Network.php +++ b/server/core/Network.php @@ -40,7 +40,7 @@ class network{ public function __construct($app){ $this->app = $app; - $this->libClass = $app->getLibClass("network"); + $this->libClass = $app->getLibClass("Network"); } -- cgit v1.2.3 From 20dc35d9ab6ce3b9aafeeca14be52b70a30aaf1e Mon Sep 17 00:00:00 2001 From: EoleDev Date: Wed, 20 Apr 2016 09:45:24 +0200 Subject: Error correction automating --- server/Test/automatingTests.php | 15 ++++++++++++--- server/core/Network.php | 4 ++-- 2 files changed, 14 insertions(+), 5 deletions(-) (limited to 'server/core/Network.php') diff --git a/server/Test/automatingTests.php b/server/Test/automatingTests.php index 078f86b..6b0e9d6 100755 --- a/server/Test/automatingTests.php +++ b/server/Test/automatingTests.php @@ -34,7 +34,15 @@ foreach ($ports as $p) { echo $p["fixedIps"]."
"; } */ - +//Liste des networks +echo "Liste des network :
"; +$network->action("list_network_ids"); +$servers = json_decode($App->show(), true)["ListNetworkIds"]; +$id = null; +foreach($servers as $server){ + echo $server."
"; +} +echo "
"; // liste des floatingip echo "Liste des floatingip :
"; @@ -50,12 +58,13 @@ echo "
"; // Création d'une ip flotante $opt = array(); -$opt['floatingNetworkId'] = $id; -$opt['floatingip'] = $ip; +//$opt['floatingNetworkId'] = $id; !!!!! TOTALEMENT FAUX ici tu passe en parametre l id du serveur et non du network +//$opt['floatingip'] = $ip; !!!! il n y a pas d objet floatingip a passer en param, celui ci est compose, regarde bien les exemples de l api OpenStack //$opt['tenantId'] = "fbf5f920a7954b61b352bc09ce5ae803 "; //$opt['fixedIpAddress'] = "10.0.0.52"; //$opt['floatingIpAddress'] = "148.60.11.116"; //$opt['portId'] = "10.0.0.52"; +$opt['floatingNetworkId'] = "251b4641-20ff-4a72-8549-1758788b51ce"; $App->setPostParam('opt', $opt); $floatingIp->action("createFloatingIp"); diff --git a/server/core/Network.php b/server/core/Network.php index 3e5e2ca..e93c2c5 100755 --- a/server/core/Network.php +++ b/server/core/Network.php @@ -118,7 +118,7 @@ class network{ } - + /** * Create a new subnet * @@ -356,7 +356,7 @@ class network{ try { $networkId = $this->app->getPostParam("networkId"); - $newtork = $this->libClass->getNetworkP($networkId); + $newtork = $this->libClass->getNetwork($networkId); $network->retrieve(); } -- cgit v1.2.3