summaryrefslogtreecommitdiff
path: root/server/core
diff options
context:
space:
mode:
authormanzerbredes <loic.guegan_secondary@yahoo.fr>2016-03-28 12:17:43 +0200
committermanzerbredes <loic.guegan_secondary@yahoo.fr>2016-03-28 12:17:43 +0200
commit53f65de9d4163c9c095f2b8e87baca648c3645bd (patch)
tree37f167f38b25aa50bd7dd1429438c0245a280a28 /server/core
parent60cfe3ebc039df8d6a468a43a59e7fd8c2a16956 (diff)
parent804fa322d841d73ee7592885ec500dc94e91b9e6 (diff)
Test
Diffstat (limited to 'server/core')
-rwxr-xr-xserver/core/App.php19
-rw-r--r--server/core/Automating.php127
-rwxr-xr-xserver/core/Compute.php641
-rwxr-xr-xserver/core/ErrorManagement.php94
-rwxr-xr-xserver/core/Image.php12
-rwxr-xr-xserver/core/LibOverride/genTokenOptions.php12
-rwxr-xr-xserver/core/Network.php1214
-rw-r--r--server/core/Network.php~952
8 files changed, 2867 insertions, 204 deletions
diff --git a/server/core/App.php b/server/core/App.php
index d35ccc0..48bb9ab 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();
@@ -37,6 +37,10 @@ class App{
}
+ public function checkToken(){
+ return $this->tokenClass->checkToken();
+ }
+
public function getLibClass($service){
switch($service){
@@ -108,9 +112,20 @@ class App{
}
public function getPostParam($name){
+
+ if(isset($this->postParams[$name])){
+ return $this->postParams[$name];
+ }else{
+ $this->setOutput("Error", "Missing parameter ".$name);
+ }
- return $this->postParams[$name];
+ }
+
+
+ public function setPostParam($param, $value){
+ $this->postParams[$param] = $value;
+
}
public function setOutput($key, $out){
diff --git a/server/core/Automating.php b/server/core/Automating.php
new file mode 100644
index 0000000..7f2c654
--- /dev/null
+++ b/server/core/Automating.php
@@ -0,0 +1,127 @@
+<?php
+/**
+* File containing the Automating Class.
+*
+* @version 1.0 Initialisation of this file
+* @since 1.0 Core application's file
+*
+* @author Evan Pisani 'yogg at epsina . com'
+*
+* @todo Complete the functions with errors detection and finish the descriptions
+*/
+
+include("CoreInterface.php");
+include("Image.php");
+include("Network.php");
+include("Compute.php");
+
+class automating implements Core{
+ /** @var App $app protected, contains the main app object */
+ protected $app;
+
+ /** @var OpenStack\Identity $libClass protected, contains the library Identity object */
+ protected $libClass;
+
+ /**
+ * Image constructor
+ *
+ * @param App $app the main app object
+ *
+ * @return Image
+ */
+ public function __construct($app){
+ if(!isset($app)){
+ $this->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.""}();
+ }
+
+ /**
+ * Create a new image on a new server
+ *
+ * @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);
+
+ $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);
+ }
+ //$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);
+ }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
diff --git a/server/core/Compute.php b/server/core/Compute.php
index b658580..e72abf9 100755
--- a/server/core/Compute.php
+++ b/server/core/Compute.php
@@ -34,34 +34,51 @@ class compute
*/
public function listServers()
{
- $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;
+ 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);
}
- $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,19 +87,36 @@ class compute
*/
public function listFlavors()
{
- $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;
+ try{
+ $flavorList = $this->libClass->listFlavors();
+ $flavors = Array();
+ foreach($flavorList as $flavor){
+ $flavors[$flavor->id] = Array();
+ $flavor->retrieve();
+ $flavors[$flavor->id]["id"] = $flavor->id;
+ $flavors[$flavor->id]["name"] = $flavor->name;
+ $flavors[$flavor->id]["ram"] = $flavor->ram;
+ $flavors[$flavor->id]["disk"] = $flavor->disk;
+ $flavors[$flavor->id]["vcpus"] = $flavor->vcpus;
+ $flavors[$flavor->id]["links"] = $flavor->links;
}
$this->app->setOutput("Flavors", $flavors);
+ }
+ 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,23 +125,40 @@ class compute
*/
public function listImages()
{
- $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;
+ try{
+ $imageList = $this->libClass->listImages();
+ $images = Array();
+ foreach($imageList as $image){
+ $images[$image->id] = Array();
+ $image->retrieve();
+ $images[$image->id]["id"] = $image->id;
+ $images[$image->id]["name"] = $image->name;
+ $images[$image->id]["status"] = $image->status;
+ $images[$image->id]["created"] = $image->created;
+ $images[$image->id]["updated"] = $image->updated;
+ $images[$image->id]["minDisk"] = $image->minDisk;
+ $images[$image->id]["minRam"] = $image->minRam;
+ $images[$image->id]["progress"] = $image->progress;
+ $images[$image->id]["links"] = $image->links;
+ $images[$image->id]["metadata"] = $image->metadata;
}
$this->app->setOutput("Images", $images);
+ }
+ 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,15 +167,32 @@ class compute
*/
public function getServer()
{
- $serverId = $this->app->getPostParam("serverId");
- if(!isset($serverId)){
- $this->app->setOutput("Error", "Server ID is missing, son!");
- return;
+ 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);
}
- $opt = array('id' => $serverId);
- $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,15 +201,32 @@ class compute
*/
public function getFlavor()
{
- $flavorId = $this->app->getPostParam("flavorId");
- if(!isset($serverId)){
- $this->app->setOutput("Error", "Flavor ID is missing, son!");
- return;
+ 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);
}
- $opt = array('id' => $flavorId);
- $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,15 +235,32 @@ class compute
*/
public function getImage()
{
- $imageId = $this->app->getPostParam("imageId");
- if(!isset($serverId)){
- $this->app->setOutput("Error", "Image ID is missing, son!");
- return;
+ 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);
}
- $opt = array('id' => $imageId);
- $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,15 +269,33 @@ class compute
*/
public function createServer()
{
- $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;
+ 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);
}
- $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,27 +304,44 @@ class compute
*/
public function updateServer()
{
- $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);
+ 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;
}
- 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);
+ }
+ 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,15 +350,32 @@ class compute
*/
public function deleteServer()
{
- $serverId = $this->app->getPostParam("serverId");
- if(!isset($serverId)){
- $this->app->setOutput("Error", "Server ID is missing, son!");
- return;
+ 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.");
}
- $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);
+ }
+ 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,16 +384,33 @@ class compute
*/
public function changePassword()
{
- $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;
+ 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.");
}
- $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);
+ }
+ 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,15 +419,32 @@ class compute
*/
public function reboot()
{
- $serverId = $this->app->getPostParam("serverId");
- if(!isset($serverId)){
- $this->app->setOutput("Error", "Server ID is missing, son!");
- return;
+ 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.");
}
- $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);
+ }
+ 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;
}
/**
@@ -272,14 +460,39 @@ class compute
if(!isset($serverId)|| !isset($imageId) || isset($newName) || isset($adminPass)) {
$this->app->setOutput("Error", "You'll have to provide server ID and the new image, name and admin password!");
return;
+ try{
+ $serverId = $this->app->getPostParam("serverId");
+ $imageId = $this->app->getPostParam("imageId");
+ $newName = $this->app->getPostParam("newName");
+ $adminPass = $this->app->getPostParam("adminPass");
+ if(!isset($serverId)|| !isset($imageId) || isset($newName) || isset($adminPass)){
+ $this->app->setOutput("Error", "You'll have to provide server ID and the new image, name and admin password!");
+ return;
+ }
+ $opt = array('id' => $serverId);
+ $server = $this->libClass->getServer($opt);
+ $attr = array('imageId' => $imageId, 'name' => $newName, 'adminPass' => $adminPass);
+ $server->rebuild($attr);
+ $this->app->setOutput("Success", $serverId." has been rebuilt successfully with the new image.");
}
- $opt = array('id' => $serverId);
- $server = $this->libClass->getServer($opt);
- $attr = array('imageId' => $imageId, 'name' => $newName, 'adminPass' => $adminPass);
- $server->rebuild($attr);
- $this->app->setOutput("Success", $serverId." has been rebuilt successfully with the new image.");
+ catch(BadResponseError $e){
+ $this->app->getErrorInstance()->BadResponseHandler($e);
+ }
+ catch(UserInputError $e){
+ $this->app->getErrorInstance()->UserInputHandler($e);
+ }
+ catch(BaseError $e){
+ $this->app->getErrorInstance()->BaseErrorHandler($e);
+ }
+ catch(NotImplementedError $e){
+ $this->app->getErrorInstance()->NotImplementedHandler($e);
+ }
+ catch(Exception $e){
+ $this->app->getErrorInstance()->OtherException($e);
+ }
return;
}
+ }
/**
* Resize a server
* A call to this method has to be followed by either confirmResize or revertResize
@@ -287,15 +500,32 @@ class compute
*/
public function resize()
{
- $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;
+ 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);
}
- $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,15 +534,32 @@ class compute
*/
public function confirmResize()
{
- $serverId = $this->app->getPostParam("serverId");
- if(!isset($serverId)){
- $this->app->setOutput("Error", "Server ID is missing!");
- return;
+ 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.");
}
- $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);
+ }
+ 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,46 +568,68 @@ class compute
*/
public function revertResize()
{
- $serverId = $this->app->getPostParam("serverId");
- if(!isset($serverId)){
- $this->app->setOutput("Error", "Server ID is missing!");
- return;
+ 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.");
}
- $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);
+ }
+ 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
- }
+ /**
+ * List private and public addresses of a server
+ * @return void
+ */
+
public function listAddresses(array $options = [])
{
- //TODO
- }
- 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
+ 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;
}
-*/
}
diff --git a/server/core/ErrorManagement.php b/server/core/ErrorManagement.php
index ff66339..be7080b 100755
--- a/server/core/ErrorManagement.php
+++ b/server/core/ErrorManagement.php
@@ -1,4 +1,13 @@
<?php
+/**
+* File containing the Errormanagement Class.
+*
+* @version 1.0 Initialisation of this file
+* @since 1.0 Core application's file
+*
+* @author Eole 'eoledev at outlook . fr', Evan Pisani 'yogg at epsina . com'
+*
+*/
use OpenCloud\Common\Error\BadResponseError;
use OpenCloud\Common\Error\BaseError;
@@ -7,37 +16,106 @@ use OpenCloud\Common\Error\UserInputError;
Class errorManagement{
-
+ /** @var App $app protected, contains the main app object */
protected $app;
-
+ /**
+ * ErrorManagemement constructor
+ *
+ * @param App $app the main app object
+ *
+ * @return ErrorManagement
+ */
public function __construct($args){
$this->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){
- $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;
+ }
}
+ /**
+ * 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", "Erreur Interne, Merci de contacter un administrateur!");
+ $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);
+ $this->app->setOutput("Error", $error->getMessage());
}
-
}
?>
diff --git a/server/core/Image.php b/server/core/Image.php
index 71e19ce..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{
@@ -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);
diff --git a/server/core/LibOverride/genTokenOptions.php b/server/core/LibOverride/genTokenOptions.php
index bdae8a6..4733c5a 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(){
+ //error_log($this->backup['time'], 0);
+ //return $this->backup['time'] > time();
+ return true;
+ }
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"];
@@ -300,6 +307,7 @@ class genTokenOptions
}
private function serializeToken($token){
+ global $config;
$tokenSerialized = [];
$tokenSerialized["token"]["methods"] = serialize($token->methods);
$tokenSerialized["roles"] = [];
@@ -343,6 +351,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;
}
@@ -377,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/core/Network.php b/server/core/Network.php
index 8d1c8b6..a4e0939 100755
--- a/server/core/Network.php
+++ b/server/core/Network.php
@@ -1 +1,1213 @@
-
+<?php
+/**
+* File containing the Image Class.
+*
+* @version 1.0 Initialisation of this file
+* @since 1.0 Core application's file
+*
+* @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
+*
+*/
+
+class network{
+/** @var App $app protected, contains the main app object */
+ protected $app;
+/** @var OpenStack\Network $libClass protected, contains the library Network object */
+ protected $libClass;
+
+
+ /**
+ * Image constructor
+ *
+ * @param App $app the main app object
+ *
+ * @return Network
+ */
+
+
+
+ public function __construct($app){
+ $this->app = $app;
+ $this->libClass = $app->getLibClass("network");
+
+ }
+
+ /**
+ * Execute an action
+ *
+ * @param String $action name of another function of this class
+ *
+ * @return void
+ */
+ public function action($action){
+
+ $this->{$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);
+ }
+ 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 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")))
+ {
+ $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);
+ }
+
+
+ }
+
+ /**
+ * List the ID of the NETWORKS
+ *
+ * @return List of Networks ID
+ */
+
+ 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);
+ }
+
+ /**
+ * List the name of the NETWORKS
+ *
+ * @return List of Networks name
+ */
+
+ 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);
+ }
+ /**
+ * List the CIDR of the SUBNETS
+ *
+ * @return List of SUBNETS CIDR
+ */
+ 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);
+ }
+ }
+ /**
+ * retrieve a specific network
+ * @param networkId ID of network which we want to get
+ * @return Network
+ */
+ retrieve a specific network
+ 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);
+ }
+
+ /**
+ * internal function
+ * @param String netId ID of network which we want to get
+ * @return Network
+ */
+ private 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;
+ }
+
+ /**
+ * retrieve a specific subnet
+ * @param subnetId ID of subnet which we want to get
+ * @return subnet
+ */
+ 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);
+
+ }
+ /**
+ * internal function
+ * @param String subnetId ID of subnet which we want to get
+ * @return subnet
+ */
+ private 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;
+
+ }
+
+ /**
+ * 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()
+ {
+ $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);
+ }
+ }
+
+ /**
+ * 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();
+ 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);
+ }
+ }
+
+ /**
+ * Delete a network given
+ *
+ * @param String networkId ID if network which we want to delete
+
+ *
+ *
+ * @return void
+ **/
+ 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);
+ }
+ }
+
+ /**
+ * Delete a subnet given
+ *
+ * @param String subnetId ID if network which we want to delete
+
+ *
+ *
+ * @return void
+ **/
+ 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);
+ }
+ }
+
+ /**
+ * 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();
+ 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);
+ }
+ }
+
+ /**
+ * List the of ports
+ *
+ * @return List of ports
+ */
+
+ 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);
+ }
+ }
+
+ /**
+ * retrieve a specific port given
+ * @param portId ID of port which we want to get
+ * @return port
+ */
+
+ 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);
+ }
+
+ }
+
+ /**
+ * internal function
+ * retrieve a specific port given
+ * @param portId ID of port which we want to get
+ * @return port
+ */
+
+ private 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);
+ }
+
+ }
+
+
+ /**
+ * 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();
+
+ 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);
+ }
+ }
+ /**
+ * Delete a port given
+ *
+ * @param String portId id of port which we wante to delete
+
+ * @return void
+ */
+ 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);
+ }
+ }
+
+ /**
+ * 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();
+ 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);
+ }
+
+ }
+
+ /**
+ * 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();
+ 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);
+ }
+ }
+
+
+ /**
+ * List of Security Groupes
+ *
+ * @return List of Security Groupes
+ */
+
+ 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);
+ }
+ }
+
+
+ /**
+ * List of Security Groupe Rules
+ *
+ * @return List of Security Groupe Rules
+ */
+
+ 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);
+ }
+ }
+
+ /**
+ * retrieve a specific Security Groupe given
+ * @param securityGroupeId ID of security Groupe which we want to get
+ * @return securityGroupe
+ */
+
+ 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);
+ }
+
+ }
+
+ /**
+ * 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
+ {
+ $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);
+ }
+
+ }
+ /**
+ * Delete a specific Security Groupe given
+ * @param securityGroupeId ID of security Groupe which we want to get
+ * @return void
+ */
+ 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 @@
+<?php
+
+class network{
+
+ protected $app;
+
+ protected $libClass;
+
+
+
+
+
+
+ public function __construct($app){
+ $this->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);
+ }
+ }