diff options
Diffstat (limited to 'server/core/Network.php')
| -rwxr-xr-x | server/core/Network.php | 368 |
1 files changed, 189 insertions, 179 deletions
diff --git a/server/core/Network.php b/server/core/Network.php index e93c2c5..b244e4e 100755 --- a/server/core/Network.php +++ b/server/core/Network.php @@ -7,37 +7,34 @@ * * @author KABIR Othmane * -* @todo Complete the functions with errors detection and finish the descriptions */ use OpenCloud\Common\Error\BadResponseError; use OpenCloud\Common\Error\BaseError; use OpenCloud\Common\Error\NotImplementedError; use OpenCloud\Common\Error\UserInputError; +include("CoreInterface.php"); + /** * Network Class of the back-end application * -* ADD CLASS DESCRIPTION +* Management of Networks * */ - -class network{ -/** @var App $app protected, contains the main app object */ +class network implements Core{ + /** @var App $app protected, contains the main app object */ protected $app; -/** @var OpenStack\Network $libClass protected, contains the library Network object */ + /** @var OpenStack\Network $libClass protected, contains the library Network object */ protected $libClass; /** - * Image constructor + * Network constructor * * @param App $app the main app object * - * @return Network + * @return network Object */ - - - public function __construct($app){ $this->app = $app; $this->libClass = $app->getLibClass("Network"); @@ -53,7 +50,7 @@ class network{ */ public function action($action){ - $this->{$action.""}(); + $this->{$action.""}(); } @@ -102,19 +99,19 @@ class network{ catch(BadResponseError $e) { $this->app->getErrorInstance->BadResponseHandler($e); - } + } catch(UserInputError $e) { $this->app->getErrorInstance->UserInputHandler($e); - } + } catch(BaseError $e) { $this->app->getErrorInstance->BaseErrorHandler($e); - } + } catch(NotImplementedError $e) { $this->app->getErrorInstance->NotImplementedHandler($e); - } + } } @@ -134,8 +131,6 @@ class network{ * @param BOOLEAN enableDhcp Specifies whether DHCP is enabled for this subnet * @param String allocationPools Subranges of the CIDR available for dynamic allocation to ports * - * - * * @return void */ @@ -200,24 +195,24 @@ class network{ try { - $subnet = $this->libClass->createSubnet($options); + $subnet = $this->libClass->createSubnet($options); } catch(BadResponseError $e) { $this->app->getErrorInstance->BadResponseHandler($e); - } + } catch(UserInputError $e) { $this->app->getErrorInstance->UserInputHandler($e); - } + } catch(BaseError $e) { $this->app->getErrorInstance->BaseErrorHandler($e); - } + } catch(NotImplementedError $e) { $this->app->getErrorInstance->NotImplementedHandler($e); - } + } } @@ -225,7 +220,7 @@ class network{ /** * List the ID of the NETWORKS * - * @return List of Networks ID + * @return void */ private function list_network_ids() @@ -233,36 +228,36 @@ class network{ try { $ln = $this->libClass->listNetworks(); - + $list_ids = array(); - + foreach($ln as $n) { - + $list_ids[] = $n->id; - + } } catch(BadResponseError $e) { $this->app->getErrorInstance->BadResponseHandler($e); - } + } catch(UserInputError $e) { $this->app->getErrorInstance->UserInputHandler($e); - } + } catch(BaseError $e) { $this->app->getErrorInstance->BaseErrorHandler($e); - } + } catch(NotImplementedError $e) { $this->app->getErrorInstance->NotImplementedHandler($e); - } + } - $this->app->setOutput("ListNetworkIds", $list_ids); + $this->app->setOutput("ListNetworkIds", $list_ids); } /** @@ -276,78 +271,76 @@ class network{ try { $ln = $this->libClass->listNetworks(); - $list_names = array(); - - + foreach($ln as $n) { - $list_names[] = $n->name; - - } - } catch(BadResponseError $e) { $this->app->getErrorInstance->BadResponseHandler($e); - } + } catch(UserInputError $e) { $this->app->getErrorInstance->UserInputHandler($e); - } + } catch(BaseError $e) { $this->app->getErrorInstance->BaseErrorHandler($e); - } + } catch(NotImplementedError $e) { $this->app->getErrorInstance->NotImplementedHandler($e); - } + } - $this->app->setOutput("ListNetworkNames", $list_names); + $this->app->setOutput("ListNetworkNames", $list_names); } + /** * List the CIDR of the SUBNETS * - * @return List of SUBNETS CIDR + * @return void */ private function list_cidr() { try { - $ls = $this->libClass->listSubnets(); - $list_cidr = array(); - foreach ($ls as $subnet) - { - - $list_cidr[] = $subnet->cidr; - } + $ls = $this->libClass->listSubnets(); + $list_cidr = array(); + foreach ($ls as $subnet) + { + + $list_cidr[] = $subnet->cidr; + } - $this->app->setOutput("ListCidr", $list_cidr); + $this->app->setOutput("ListCidr", $list_cidr); } catch(BadResponseError $e) { $this->app->getErrorInstance->BadResponseHandler($e); - } + } catch(UserInputError $e) { $this->app->getErrorInstance->UserInputHandler($e); - } + } catch(BaseError $e) { $this->app->getErrorInstance->BaseErrorHandler($e); - } + } catch(NotImplementedError $e) { $this->app->getErrorInstance->NotImplementedHandler($e); - } + } } + /** * retrieve a specific network + * * @param networkId ID of network which we want to get - * @return Network + * + * @return void */ private function getNetwork() { @@ -364,27 +357,29 @@ class network{ catch(BadResponseError $e) { $this->app->getErrorInstance->BadResponseHandler($e); - } + } catch(UserInputError $e) { $this->app->getErrorInstance->UserInputHandler($e); - } + } catch(BaseError $e) { $this->app->getErrorInstance->BaseErrorHandler($e); - } + } catch(NotImplementedError $e) { $this->app->getErrorInstance->NotImplementedHandler($e); - } + } - $this->app->setOutput("Network", $network); + $this->app->setOutput("Network", $network); } /** * internal function + * * @param String netId ID of network which we want to get - * @return Network + * + * @return OpenStack\Network */ private function getNetworkP($netId) { @@ -401,27 +396,29 @@ class network{ catch(BadResponseError $e) { $this->app->getErrorInstance->BadResponseHandler($e); - } + } catch(UserInputError $e) { $this->app->getErrorInstance->UserInputHandler($e); - } + } catch(BaseError $e) { $this->app->getErrorInstance->BaseErrorHandler($e); - } + } catch(NotImplementedError $e) { $this->app->getErrorInstance->NotImplementedHandler($e); - } + } - return $network; + return $network; } /** * retrieve a specific subnet + * * @param subnetId ID of subnet which we want to get - * @return subnet + * + * @return void */ private function getSubnet() { @@ -437,26 +434,28 @@ class network{ catch(BadResponseError $e) { $this->app->getErrorInstance->BadResponseHandler($e); - } + } catch(UserInputError $e) { $this->app->getErrorInstance->UserInputHandler($e); - } + } catch(BaseError $e) { $this->app->getErrorInstance->BaseErrorHandler($e); - } + } catch(NotImplementedError $e) { $this->app->getErrorInstance->NotImplementedHandler($e); - } + } $this->app->setOutput("Subnet", subnet); - + } /** * internal function + * * @param String subnetId ID of subnet which we want to get - * @return subnet + * + * @return OpenStack\Subnet */ private function getSubnetP($subnetId) { @@ -472,21 +471,21 @@ class network{ catch(BadResponseError $e) { $this->app->getErrorInstance->BadResponseHandler($e); - } + } catch(UserInputError $e) { $this->app->getErrorInstance->UserInputHandler($e); - } + } catch(BaseError $e) { $this->app->getErrorInstance->BaseErrorHandler($e); - } + } catch(NotImplementedError $e) { $this->app->getErrorInstance->NotImplementedHandler($e); - } + } return $subnet; - + } /** @@ -501,8 +500,8 @@ class network{ * @return void **/ - private function updateNetwork() - { + private function updateNetwork() + { $options = array(); $name = $this->app->getPostParam("name"); $shared = $this->app->getPostParam("shared"); @@ -524,25 +523,25 @@ class network{ { $networkId = $this->app->getPostParam("networkId"); $network = getNetworkP($networkId); - + $network->update($options); } catch(BadResponseError $e) { $this->app->getErrorInstance->BadResponseHandler($e); - } + } catch(UserInputError $e) { $this->app->getErrorInstance->UserInputHandler($e); - } + } catch(BaseError $e) { $this->app->getErrorInstance->BaseErrorHandler($e); - } + } catch(NotImplementedError $e) { $this->app->getErrorInstance->NotImplementedHandler($e); - } + } } /** @@ -565,7 +564,7 @@ class network{ **/ private function updateSubnet() - { + { $options = array(); $name = $this->app->getPostParam("name"); $networkId = $this->app->getPostParam("networkId"); @@ -596,19 +595,19 @@ class network{ catch(BadResponseError $e) { $this->app->getErrorInstance->BadResponseHandler($e); - } + } catch(UserInputError $e) { $this->app->getErrorInstance->UserInputHandler($e); - } + } catch(BaseError $e) { $this->app->getErrorInstance->BaseErrorHandler($e); - } + } catch(NotImplementedError $e) { $this->app->getErrorInstance->NotImplementedHandler($e); - } + } } /** @@ -616,11 +615,10 @@ class network{ * * @param String networkId ID if network which we want to delete * - * * @return void **/ private function deleteNetwork() - { + { try { $networkId = $this->app->getPostParam("networkId"); @@ -630,19 +628,19 @@ class network{ catch(BadResponseError $e) { $this->app->getErrorInstance->BadResponseHandler($e); - } + } catch(UserInputError $e) { $this->app->getErrorInstance->UserInputHandler($e); - } + } catch(BaseError $e) { $this->app->getErrorInstance->BaseErrorHandler($e); - } + } catch(NotImplementedError $e) { $this->app->getErrorInstance->NotImplementedHandler($e); - } + } } /** @@ -650,11 +648,10 @@ class network{ * * @param String subnetId ID if network which we want to delete * - * * @return void **/ private function deleteSubnet() - { + { try { $subnetId = $this->app->getPostParam("subnetId"); @@ -664,19 +661,19 @@ class network{ catch(BadResponseError $e) { $this->app->getErrorInstance->BadResponseHandler($e); - } + } catch(UserInputError $e) { $this->app->getErrorInstance->UserInputHandler($e); - } + } catch(BaseError $e) { $this->app->getErrorInstance->BaseErrorHandler($e); - } + } catch(NotImplementedError $e) { $this->app->getErrorInstance->NotImplementedHandler($e); - } + } } /** @@ -751,25 +748,25 @@ class network{ catch(BadResponseError $e) { $this->app->getErrorInstance->BadResponseHandler($e); - } + } catch(UserInputError $e) { $this->app->getErrorInstance->UserInputHandler($e); - } + } catch(BaseError $e) { $this->app->getErrorInstance->BaseErrorHandler($e); - } + } catch(NotImplementedError $e) { $this->app->getErrorInstance->NotImplementedHandler($e); - } + } } /** * List the of ports * - * @return List of ports + * @return void */ private function listPorts() @@ -781,25 +778,27 @@ class network{ catch(BadResponseError $e) { $this->app->getErrorInstance->BadResponseHandler($e); - } + } catch(UserInputError $e) { $this->app->getErrorInstance->UserInputHandler($e); - } + } catch(BaseError $e) { $this->app->getErrorInstance->BaseErrorHandler($e); - } + } catch(NotImplementedError $e) { $this->app->getErrorInstance->NotImplementedHandler($e); - } + } } /** * retrieve a specific port given + * * @param portId ID of port which we want to get - * @return port + * + * @return void */ private function getPort() @@ -813,26 +812,29 @@ class network{ catch(BadResponseError $e) { $this->app->getErrorInstance->BadResponseHandler($e); - } + } catch(UserInputError $e) { $this->app->getErrorInstance->UserInputHandler($e); - } + } catch(BaseError $e) { $this->app->getErrorInstance->BaseErrorHandler($e); - } + } catch(NotImplementedError $e) { $this->app->getErrorInstance->NotImplementedHandler($e); - } - + } + } /** * internal function + * * retrieve a specific port given + * * @param portId ID of port which we want to get + * * @return port */ @@ -846,20 +848,20 @@ class network{ catch(BadResponseError $e) { $this->app->getErrorInstance->BadResponseHandler($e); - } + } catch(UserInputError $e) { $this->app->getErrorInstance->UserInputHandler($e); - } + } catch(BaseError $e) { $this->app->getErrorInstance->BaseErrorHandler($e); - } + } catch(NotImplementedError $e) { $this->app->getErrorInstance->NotImplementedHandler($e); - } - + } + } @@ -935,28 +937,29 @@ class network{ catch(BadResponseError $e) { $this->app->getErrorInstance->BadResponseHandler($e); - } + } catch(UserInputError $e) { $this->app->getErrorInstance->UserInputHandler($e); - } + } catch(BaseError $e) { $this->app->getErrorInstance->BaseErrorHandler($e); - } + } catch(NotImplementedError $e) { $this->app->getErrorInstance->NotImplementedHandler($e); - } + } } /** * Delete a port given * * @param String portId id of port which we wante to delete + * * @return void */ private function deletePort() - { + { try { @@ -967,19 +970,19 @@ class network{ catch(BadResponseError $e) { $this->app->getErrorInstance->BadResponseHandler($e); - } + } catch(UserInputError $e) { $this->app->getErrorInstance->UserInputHandler($e); - } + } catch(BaseError $e) { $this->app->getErrorInstance->BaseErrorHandler($e); - } + } catch(NotImplementedError $e) { $this->app->getErrorInstance->NotImplementedHandler($e); - } + } } /** @@ -1012,33 +1015,33 @@ class network{ catch(BadResponseError $e) { $this->app->getErrorInstance->BadResponseHandler($e); - } + } catch(UserInputError $e) { $this->app->getErrorInstance->UserInputHandler($e); - } + } catch(BaseError $e) { $this->app->getErrorInstance->BaseErrorHandler($e); - } + } catch(NotImplementedError $e) { $this->app->getErrorInstance->NotImplementedHandler($e); - } - + } + } /** * Create a new security groupe * * @param String securityGroupId The security group ID to associate with this security group rule. - * @param String direction The direction in which the security group rule is applied. For a compute instance, an ingress security group * rule is applied to incoming (ingress) traffic for that instance. An egress rule is applied to traffic leaving the instance. + * @param String direction The direction in which the security group rule is applied. For a compute instance, an ingress security group rule is applied to incoming (ingress) traffic for that instance. An egress rule is applied to traffic leaving the instance. * @param String ethertype Must be IPv4 or IPv6, and addresses represented in CIDR must match the ingress or egress rules. - * @param String portRangeMin The minimum port number in the range that is matched by the security group rule. If the protocol is TCP or UDP, this value must be less than or equal to the value of the portRangeMax attribute. If the protocol is ICMP, this value must be an ICMP type - *@param String portRangeMax The maximum port number in the range that is matched by the security group rule. If the protocol is TCP or UDP, this value must be less than or equal to the value of the portRangeMax attribute. If the protocol is ICMP, this value must be an ICMP type. - *@param String protocol The protocol that is matched by the security group rule - *@param String remoteGroupId The remote group ID to be associated with this security group rule. You can specify either remoteGroupId or remoteGroupPrefix - *@param String remoteIpPrefix The remote IP prefix to be associated with this security group rule. You can specify either remoteGroupId or remoteGroupPrefix + * @param String portRangeMin The minimum port number in the range that is matched by the security group rule. If the protocol is TCP or UDP, this value must be less than or equal to the value of the portRangeMax attribute. If the protocol is ICMP, this value must be an ICMP type + * @param String portRangeMax The maximum port number in the range that is matched by the security group rule. If the protocol is TCP or UDP, this value must be less than or equal to the value of the portRangeMax attribute. If the protocol is ICMP, this value must be an ICMP type. + * @param String protocol The protocol that is matched by the security group rule + * @param String remoteGroupId The remote group ID to be associated with this security group rule. You can specify either remoteGroupId or remoteGroupPrefix + * @param String remoteIpPrefix The remote IP prefix to be associated with this security group rule. You can specify either remoteGroupId or remoteGroupPrefix * * @return void */ @@ -1093,26 +1096,26 @@ class network{ catch(BadResponseError $e) { $this->app->getErrorInstance->BadResponseHandler($e); - } + } catch(UserInputError $e) { $this->app->getErrorInstance->UserInputHandler($e); - } + } catch(BaseError $e) { $this->app->getErrorInstance->BaseErrorHandler($e); - } + } catch(NotImplementedError $e) { $this->app->getErrorInstance->NotImplementedHandler($e); - } + } } /** * List of Security Groupes * - * @return List of Security Groupes + * @return void */ private function listSecurityGroupe() @@ -1124,58 +1127,60 @@ class network{ catch(BadResponseError $e) { $this->app->getErrorInstance->BadResponseHandler($e); - } + } catch(UserInputError $e) { $this->app->getErrorInstance->UserInputHandler($e); - } + } catch(BaseError $e) { $this->app->getErrorInstance->BaseErrorHandler($e); - } + } catch(NotImplementedError $e) { $this->app->getErrorInstance->NotImplementedHandler($e); - } + } } /** * List of Security Groupe Rules * - * @return List of Security Groupe Rules + * @return void */ private function listSecurityGroupeRule() { try { - - $this->app->setOutput("listSecurityGroupeRule", $this->libClass->listSecurityGroupRules()); + + $this->app->setOutput("listSecurityGroupeRule", $this->libClass->listSecurityGroupRules()); } catch(BadResponseError $e) { $this->app->getErrorInstance->BadResponseHandler($e); - } + } catch(UserInputError $e) { $this->app->getErrorInstance->UserInputHandler($e); - } + } catch(BaseError $e) { $this->app->getErrorInstance->BaseErrorHandler($e); - } + } catch(NotImplementedError $e) { $this->app->getErrorInstance->NotImplementedHandler($e); - } + } } /** * retrieve a specific Security Groupe given + * * @param securityGroupeId ID of security Groupe which we want to get - * @return securityGroupe + * + * @return void */ private function getSecurityGroupe() @@ -1189,27 +1194,30 @@ class network{ catch(BadResponseError $e) { $this->app->getErrorInstance->BadResponseHandler($e); - } + } catch(UserInputError $e) { $this->app->getErrorInstance->UserInputHandler($e); - } + } catch(BaseError $e) { $this->app->getErrorInstance->BaseErrorHandler($e); - } + } catch(NotImplementedError $e) { $this->app->getErrorInstance->NotImplementedHandler($e); - } - + } + } /** * internal function + * * retrieve a specific Security Groupe given + * * @param securityGroupeId ID of security Groupe which we want to get - * @return securityGroupe + * + * @return securityGroup */ private function getSecurityGroupeP($securityGroupeId) { @@ -1221,28 +1229,30 @@ class network{ catch(BadResponseError $e) { $this->app->getErrorInstance->BadResponseHandler($e); - } + } catch(UserInputError $e) { $this->app->getErrorInstance->UserInputHandler($e); - } + } catch(BaseError $e) { $this->app->getErrorInstance->BaseErrorHandler($e); - } + } catch(NotImplementedError $e) { $this->app->getErrorInstance->NotImplementedHandler($e); - } - + } + } /** * Delete a specific Security Groupe given + * * @param securityGroupeId ID of security Groupe which we want to get + * * @return void */ private function deleteSecurityGroupe() - { + { try { $securityGroupId = $this->app->getPostParam("securityGroupeId"); @@ -1252,18 +1262,18 @@ class network{ catch(BadResponseError $e) { $this->app->getErrorInstance->BadResponseHandler($e); - } + } catch(UserInputError $e) { $this->app->getErrorInstance->UserInputHandler($e); - } + } catch(BaseError $e) { $this->app->getErrorInstance->BaseErrorHandler($e); - } + } catch(NotImplementedError $e) { $this->app->getErrorInstance->NotImplementedHandler($e); - } + } } } |
