Correction de cette putain de classe non testee par othmane

This commit is contained in:
Yoggzo 2016-04-19 23:16:37 +02:00
parent 49ce03168a
commit 438b9b4dcd

View file

@ -14,8 +14,6 @@ use OpenCloud\Common\Error\BaseError;
use OpenCloud\Common\Error\NotImplementedError; use OpenCloud\Common\Error\NotImplementedError;
use OpenCloud\Common\Error\UserInputError; use OpenCloud\Common\Error\UserInputError;
include("CoreInterface.php");
/** /**
* Network Class of the back-end application * Network Class of the back-end application
* *
@ -73,24 +71,29 @@ class network{
{ {
$options = array(); $options = array();
// check the name if it is null // 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 // 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 // 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 // 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 try
{ {
@ -138,49 +141,61 @@ class network{
private function create_subnet() private function create_subnet()
{ $options = array(); { $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; $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 try
@ -339,10 +354,10 @@ class network{
$network=""; $network="";
try 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 * @param String netId ID of network which we want to get
* @return Network * @return Network
*/ */
private function getNetwork($netId) private function getNetworkP($netId)
{ {
$network=""; $network="";
@ -413,10 +428,10 @@ class network{
$sbnet=""; $sbnet="";
try try
{ $subnet = $this->libClass->getSubnet($this->app->getPostParam("subnetId")); {
$subnetId = $this->app->getPostParam("subnetId");
$subnet = $this->libClass->getSubnet($subnetId);
$subnet->retrieve(); $subnet->retrieve();
} }
catch(BadResponseError $e) catch(BadResponseError $e)
@ -443,7 +458,7 @@ class network{
* @param String subnetId ID of subnet which we want to get * @param String subnetId ID of subnet which we want to get
* @return subnet * @return subnet
*/ */
private function getSubnet($subnetId) private function getSubnetP($subnetId)
{ {
$subnet=""; $subnet="";
@ -489,21 +504,26 @@ class network{
private function updateNetwork() private function updateNetwork()
{ {
$options = array(); $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 try
{ {
$network = getNetwork($this->app->getPostParam("networkId")); $networkId = $this->app->getPostParam("networkId");
$network = getNetworkP($networkId);
$network->update($options); $network->update($options);
} }
@ -547,26 +567,30 @@ class network{
private function updateSubnet() private function updateSubnet()
{ {
$options = array(); $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 try
{ {
$subnet = getSubnet($this->app->getPostParam("networkId")); $networkId = $this->app->getPostParam("networkId");
$subnet = getSubnetP($networkId);
$subnet->update($options); $subnet->update($options);
} }
catch(BadResponseError $e) catch(BadResponseError $e)
@ -599,8 +623,8 @@ class network{
{ {
try try
{ {
$networkId = $this->app->getPostParam("networkId");
$network = getNetwork($this->app->getPostParam("networkId")); $network = getNetworkP($networkId);
$network->delete(); $network->delete();
} }
catch(BadResponseError $e) catch(BadResponseError $e)
@ -633,7 +657,8 @@ class network{
{ {
try try
{ {
$subnet = getNetwork($this->app->getPostParam("subnetId")); $subnetId = $this->app->getPostParam("subnetId");
$subnet = getNetworkP($subnetId);
$subnet->delete(); $subnet->delete();
} }
catch(BadResponseError $e) catch(BadResponseError $e)
@ -673,41 +698,51 @@ class network{
private function createPort() private function createPort()
{ {
$options = array(); $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 try
{ {
@ -771,7 +806,8 @@ class network{
{ {
try try
{ {
$port = $this->libClass->getport($this->app->getPostParam("portId")); $portId = $this->app->getPostParam("portId");
$port = $this->libClass->getport($portId);
$this->app->setOutput("Port", $port); $this->app->setOutput("Port", $port);
} }
catch(BadResponseError $e) catch(BadResponseError $e)
@ -800,7 +836,7 @@ class network{
* @return port * @return port
*/ */
private function getPort($portId) private function getPortP($portId)
{ {
try try
{ {
@ -845,46 +881,55 @@ class network{
private function updatePort() private function updatePort()
{ {
$options = array(); $options = array();
$networkId = $this->app->getPostParam("networkId");
if (isset($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 try
{ {
$port = getPort($this->app->getPostParam("networkId")); $port = getPortP($networkId);
$port->update($options); $port->update($options);
} }
catch(BadResponseError $e) catch(BadResponseError $e)
@ -908,7 +953,6 @@ class network{
* Delete a port given * Delete a port given
* *
* @param String portId id of port which we wante to delete * @param String portId id of port which we wante to delete
* @return void * @return void
*/ */
private function deletePort() private function deletePort()
@ -916,7 +960,8 @@ class network{
try try
{ {
$port = getPort($this->app->getPostParam("portId")); $portId = $this->app->getPostParam("portId");
$port = getPortP($portId);
$port->delete(); $port->delete();
} }
catch(BadResponseError $e) catch(BadResponseError $e)
@ -949,13 +994,16 @@ class network{
private function createSecurityGroup() private function createSecurityGroup()
{ {
$options = array(); $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 try
{ {
@ -997,37 +1045,46 @@ class network{
private function createSecurityGroupRule() private function createSecurityGroupRule()
{ {
$options = array(); $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 try
{ {
@ -1125,7 +1182,8 @@ class network{
{ {
try try
{ {
$securityGroupe = $this->libClass->getSecurityGroupe($this->app->getPostParam("securityGroupeId")); $securityGroupId = $this->app->getPostParam("securityGroupeId");
$securityGroupe = $this->libClass->getSecurityGroupe($securityGroupId);
$this->app->setOutput("securityGroupe", $securityGroupe); $this->app->setOutput("securityGroupe", $securityGroupe);
} }
catch(BadResponseError $e) catch(BadResponseError $e)
@ -1153,7 +1211,7 @@ class network{
* @param securityGroupeId ID of security Groupe which we want to get * @param securityGroupeId ID of security Groupe which we want to get
* @return securityGroupe * @return securityGroupe
*/ */
private function getSecurityGroupe($securityGroupeId) private function getSecurityGroupeP($securityGroupeId)
{ {
try try
{ {
@ -1187,8 +1245,8 @@ class network{
{ {
try try
{ {
$securityGroupId = $this->app->getPostParam("securityGroupeId");
$securityGroupe = getSecurityGroupe($this->app->getPostParam("securityGroupeId")); $securityGroupe = getSecurityGroupeP($securityGroupId);
$securityGroupe->delete(); $securityGroupe->delete();
} }
catch(BadResponseError $e) catch(BadResponseError $e)