summaryrefslogtreecommitdiff
path: root/server/core
diff options
context:
space:
mode:
authorEole <EoleDev@outlook.fr>2016-04-27 16:42:28 +0200
committerEole <EoleDev@outlook.fr>2016-04-27 16:42:28 +0200
commit49f416dc5061032e0514ea0cfeceaca37d13e432 (patch)
tree1202ac2a6fa860b8929afdc886c94fc50bd0a1de /server/core
parentc7edd70b5e5b0f5159c78ce3d924d4e7f60db816 (diff)
parentc9202d9113210981ae47df40511645da2ee140df (diff)
Merge branch 'develop' into Eole_Graph
Conflicts: client/index.html client/js/controllers/home/home.js client/partials/home/home.html
Diffstat (limited to 'server/core')
-rwxr-xr-xserver/core/App.php179
-rwxr-xr-xserver/core/Automating.php133
-rwxr-xr-xserver/core/Compute.php915
-rwxr-xr-x[-rw-r--r--]server/core/CoreInterface.php19
-rwxr-xr-xserver/core/ErrorManagement.php102
-rwxr-xr-xserver/core/Identity.php1637
-rwxr-xr-xserver/core/Image.php780
-rwxr-xr-xserver/core/LibOverride/genTokenOptions.php314
-rwxr-xr-x[-rw-r--r--]server/core/LibOverride/projectTokenData/demo0
-rwxr-xr-x[-rw-r--r--]server/core/Network.php1280
-rwxr-xr-xserver/core/NetworkLayer3.php531
-rw-r--r--server/core/Plugin.php13
-rw-r--r--server/core/Plugin_Api.php24
-rwxr-xr-x[-rw-r--r--]server/core/Readme.txt0
14 files changed, 4181 insertions, 1746 deletions
diff --git a/server/core/App.php b/server/core/App.php
index d35ccc0..fb49b95 100755
--- a/server/core/App.php
+++ b/server/core/App.php
@@ -1,35 +1,73 @@
<?php
-include_once("core/Plugin_Api.php");
+/**
+* File containing the identity Class.
+*
+* @version 1.0 Initialisation of this file
+* @since 1.0 Core application's file
+*
+* @author Eole 'eoledev at outlook . fr'
+*
+*/
+
+/*
+* Library token management override
+*/
include_once("core/LibOverride/genTokenOptions.php");
include_once("core/ErrorManagement.php");
+//Library loading
use OpenCloud\Common\Error\BadResponseError;
use OpenCloud\Common\Error\BaseError;
use OpenCloud\Common\Error\NotImplementedError;
use OpenCloud\Common\Error\UserInputError;
+/**
+* App Class of the back-end application
+*
+* This class allow the communication between the front-end application and
+* the library which allow to send requests to an Openstack instance.
+*
+*/
class App{
+ /** @var OpenStack\OpenStack $openstack protected, contains the main library object */
protected $openstack;
- protected $pluginsApi;
+ /** @var Array $postParams protected, contains the post parameters */
protected $postParams;
+ /** @var genTokenOptions $tokenClass protected, contains the class object for the authentication override of the library */
protected $tokenClass;
+ /** @var String $tokenPost protected, contains the token given in parameter */
protected $tokenPost;
+ /** @var errorManagement $errorClass protected, contains the errorManagement object */
protected $errorClass;
+ /** @var Array $output protected, contains the result for the API call */
protected $output;
+ /**
+ * App constructor
+ *
+ * @param Array $args Args for the OpenStack Library
+ *
+ * @return App object
+ */
public function __construct($args){
$this->tokenPost = NULL;
$this->tokenClass = new genTokenOptions($args);
- $this->openstack = new OpenStack\OpenStack([]);
- $this->pluginsApi = plugin_api::getInstance();
+ $this->openstack = new OpenStack\OpenStack(['authUrl' => $args["authUrl"]]);
$this->errorClass = new errorManagement($this);
$this->output = array();
$this->postParams = $_POST;
}
+ /**
+ * Set the class var $tokenPost and load the token
+ * into the genTokenOptions Class
+ *
+ * @param String $token token to be set
+ *
+ */
public function setToken($token){
$this->tokenPost = $token;
@@ -37,33 +75,59 @@ class App{
}
+ /**
+ * Check the expiration of the token
+ *
+ * @return Boolean if the token is not expired
+ */
+ public function checkToken(){
+ return $this->tokenClass->checkToken();
+ }
+
+ /**
+ * Get the service Class given the name in parameter
+ *
+ * @param String $service Name of the service
+ *
+ * @return Core object
+ */
public function getLibClass($service){
switch($service){
- case "Identity":
- if($this->tokenPost == NULL) $this->tokenClass->genIdentityToken();
- $opt = $this->tokenClass->getOptions($service);
- return $this->openstack->identityV3($opt);
- break;
- case "Image":
- if($this->tokenPost == NULL) $this->tokenClass->genImageToken();
- $opt = $this->tokenClass->getOptions($service);
- return $this->openstack->imagesV2($opt);
- break;
- case "Network":
- if($this->tokenPost == NULL) $this->tokenClass->genNetworkToken();
- $opt = $this->tokenClass->getOptions($service);
- return $this->openstack->networkingV2($opt);
- break;
- case "Compute":
- if($this->tokenPost == NULL) $this->tokenClass->genComputeToken();
- $opt = $this->tokenClass->getOptions($service);
- return $this->openstack->computeV2($opt);
- break;
+ case "Identity":
+ if($this->tokenPost == NULL) $this->tokenClass->genIdentityToken();
+ $opt = $this->tokenClass->getOptions($service);
+ return $this->openstack->identityV3($opt);
+ break;
+ case "Image":
+ if($this->tokenPost == NULL) $this->tokenClass->genImageToken();
+ $opt = $this->tokenClass->getOptions($service);
+ return $this->openstack->imagesV2($opt);
+ break;
+ case "Network":
+ if($this->tokenPost == NULL) $this->tokenClass->genNetworkToken();
+ $opt = $this->tokenClass->getOptions($service);
+ return $this->openstack->networkingV2($opt);
+ break;
+ case "Compute":
+ if($this->tokenPost == NULL) $this->tokenClass->genComputeToken();
+ $opt = $this->tokenClass->getOptions($service);
+ return $this->openstack->computeV2($opt);
+ break;
+ case "NetworkLayer3":
+ if($this->tokenPost == NULL) $this->tokenClass->genNetworkToken();
+ $opt = $this->tokenClass->getOptions('Network');
+ return $this->openstack->networkingV2ExtLayer3($opt);
+ break;
}
}
+ /**
+ * Generate the token for the different services in OpenStack
+ *
+ * @return void
+ */
public function authenticate(){
try{
@@ -75,16 +139,21 @@ class App{
$this->setOutput("token", $this->tokenClass->getBackup());
}catch(BadResponseError $e){
$this->errorClass->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->errorClass->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->errorClass->BaseErrorHandler($e);
- }catch(NotImplementedError $e){
+ }catch(NotImplementedError $e){
$this->errorClass->NotImplementedHandler($e);
- }
+ }
}
+ /**
+ * Revoke the openstack services' token
+ *
+ * @return void
+ */
public function deauthenticate(){
try{
@@ -97,37 +166,79 @@ class App{
$this->setOutput("deauthenticate", "Ok");
}catch(BadResponseError $e){
$this->errorClass->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->errorClass->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->errorClass->BaseErrorHandler($e);
- }catch(NotImplementedError $e){
+ }catch(NotImplementedError $e){
$this->errorClass->NotImplementedHandler($e);
- }
+ }
}
+ /**
+ * Retrieve a post parameter given its name
+ *
+ * @param String $name Expected post parameter's name
+ *
+ * @return Object Post value
+ */
public function getPostParam($name){
+
+ if(isset($this->postParams[$name])){
+ return $this->postParams[$name];
+ }else{
+ $this->setOutput("Error", "Missing parameter ".$name);
+ }
+
+ }
+
+ /**
+ * Set a post parameter for automating task
+ *
+ * @param String $param Name for the Post entry
+ * @param Object $value Value for the Post entry
+ *
+ * @return void
+ */
+ public function setPostParam($param, $value){
- return $this->postParams[$name];
+ $this->postParams[$param] = $value;
}
+ /**
+ * Set a new output message
+ *
+ * @param String $key Array key for the message
+ * @param Array $out Message's value
+ *
+ * @return void
+ */
public function setOutput($key, $out){
$this->output[$key] = $out;
}
+ /**
+ * Retrieve the errorManagement instance Object
+ *
+ * @return errorManagement object
+ */
public function getErrorInstance(){
return $this->errorClass;
}
+ /**
+ * Output the messages to be send to the client
+ *
+ * @return void
+ */
public function show(){
echo json_encode($this->output);
- //error_log(var_dump(json_encode($this->output), true), 0);
}
}
diff --git a/server/core/Automating.php b/server/core/Automating.php
new file mode 100755
index 0000000..27dd018
--- /dev/null
+++ b/server/core/Automating.php
@@ -0,0 +1,133 @@
+<?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', bhupi
+*
+*/
+
+include("Image.php");
+include("Network.php");
+include("Compute.php");
+include("NetworkLayer3.php");
+include("CoreInterface.php");
+
+/**
+* automating Class of the back-end application
+*
+* Contains the different function to automate some action
+*
+*/
+class automating implements Core{
+
+ /** @var App $compute protected, contains a Core compute object */
+ protected $compute;
+ /** @var App $image protected, contains a Core image object */
+ protected $image;
+ /** @var App $network protected, contains a Core network object */
+ protected $network;
+ /** @var App $networkLayer3 protected, contains a Core networkLayer3 object */
+ protected $networkLayer3;
+ /** @var App $app protected, contains the main app object */
+ protected $app;
+
+ /**
+ * automating class constructor
+ *
+ * @param App $app the main app object
+ *
+ * @return automating Object
+ */
+ public function __construct($app){
+ $this->app = $app;
+ $compute = new Compute($app);
+ $image = new Image($app);
+ $network = new Network($app);
+ $networkLayer3 = new NetworkLayer3($app);
+ }
+
+ /**
+ * Execute an action
+ *
+ * @param String $action name of another function of this class
+ *
+ * @return void
+ */
+ public function action($action){
+ $this->{$action.""}();
+ }
+
+ /**
+ * create a new server and associate a public ip
+ *
+ * @param String $networkId the id of the network where the server will be created
+ * @param String $imageName name of the new image
+ * @param String $serverName name ofthe new server
+ * @param String $flavor kind of server
+ *
+ * @return void
+ */
+ private function createPublicServer()
+ {
+ $networkId = $this->app->getPostParam('networkId');
+ $imageName = $this->app->getPostParam('imageName');
+ $serverName = $this->app->getPostParam('serverName');
+ $flavor = $this->app->getPostParam('flavor');
+
+ if(!isset($imageName)){
+ $this->app->setOutput("Error", "Incorrect imageName parameter");
+ }
+ else if(!isset($serverName)){
+ $this->app->setOutput("Error", "Incorrect serverName parameter");
+ }
+ else if(!isset($flavor)){
+ $this->app->setOutput("Error", "Incorrect flavor parameter");
+ }
+ else{
+ // Création image
+ $opt = array();
+ $opt['name'] = $imageName;
+ $image->setPostParam('opt', $opt);
+ $image->action("createImage");
+ $image = json_decode($this->app->show(), true)["Images"];
+
+ // Création server
+ $compute->setPostParam('name', $serverName);
+ $compute->setPostParam('imageId', $image['id']);
+ $compute->setPostParam('flavorId', $flavor);
+ $compute->action("createServer");
+ $server = json_decode($this->app->show(), true)["Compute"];
+
+ // liste des adresses ip publiques diponibles
+ $networkLayer3->action("listFloatingIp");
+ $listFloatingIp = json_decode($App->show(), true)["NetworkLayer3"];
+ $ip = null;
+ foreach ($listFloatingIp as $f) {
+ if(strcmp($f['status'], "DOWN")){
+ $ip = $f;
+ }
+ }
+
+ // Si pas d'ip publique disponible on en créé une
+ if(!isset($ip)){
+ // Ajout adresse IP public
+ $optIp = array();
+ $opt['floatingNetworkId'] = $networkId;
+ $floatingIp->setPostParam('opt', $optIp);
+ $networkLayer3->action("createFloatingIp");
+ $ip = json_decode($App->show(), true)["NetworkLayer3"];
+ }
+
+ // Association de l'ip publique au serveur
+ /*
+ * API non diponible pour le moment
+ */
+
+ }
+ }
+}
+
+?>
diff --git a/server/core/Compute.php b/server/core/Compute.php
index b658580..1db21bf 100755
--- a/server/core/Compute.php
+++ b/server/core/Compute.php
@@ -1,21 +1,45 @@
<?php
-//namespace istic-openstack\Server\core;
+/**
+* File containing the compute Class.
+*
+* @version 1.0 Initialisation of this file
+* @since 1.0 Core application's file
+*
+* @author bhupi
+*
+*/
+
use OpenCloud\Common\Error;
-class compute
+include("CoreInterface.php");
+/**
+* Compute Class of the back-end application
+*
+* Management of Servers
+*
+*/
+class compute implements Core
{
- /** @var App $app protected, contains the main app object */
- protected $app;
+ /** @var App $app protected, contains the main app object */
+ protected $app;
- /** @var OpenStack\Identity $libClass protected, contains the library Compute object */
- protected $libClass;
+ /** @var OpenStack\Compute $libClass protected, contains the library Compute object */
+ protected $libClass;
- public function __construct($app)
- {
- $this->app = $app;
- $this->libClass = $app->getLibClass("Compute");
- }
+ /**
+ * Compute constructor
+ *
+ * @param App $args the main app object
+ *
+ * @return compute Object
+ */
+ public function __construct($app)
+ {
+ $this->app = $app;
+ $this->libClass = $app->getLibClass("Compute");
+ }
+
/**
* Execute an action
*
@@ -25,342 +49,625 @@ class compute
*/
public function action($action){
- $this->{$action.""}();
+ $this->{$action.""}();
}
- /**
- * List servers.
- * @return array
- */
- 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;
- }
- $this->app->setOutput("Servers", $servers);
- return;
- }
- /**
- * List flavors.
- * @return array
- */
- 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;
- }
- $this->app->setOutput("Flavors", $flavors);
- return;
- }
- /**
- * List images.
- * @return array
- */
- 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;
- }
- $this->app->setOutput("Images", $images);
- return;
- }
- /**
- * Get server details.
- * @return array
- */
- public function getServer()
- {
- $serverId = $this->app->getPostParam("serverId");
- if(!isset($serverId)){
- $this->app->setOutput("Error", "Server ID is missing, son!");
- return;
+
+ /**
+ * List servers.
+ *
+ * @return void
+ */
+ public function listServers()
+ {
+ try{
+ $serverList = $this->libClass->listServers(true);
+ $servers = Array();
+ foreach($serverList as $server){
+ $servers[$server->id] = Array();
+ $server->flavor->retrieve();
+ $server->image->retrieve();
+ $server->retrieve();
+ $servers[$server->id]["id"] = $server->id;
+ $servers[$server->id]["name"] = $server->name;
+ $servers[$server->id]["image"] = $server->image;
+ $servers[$server->id]["ram"] = $server->flavor->ram;
+ $servers[$server->id]["disk"] = $server->flavor->disk;
+ $servers[$server->id]["flavor"] = $server->flavor;
+ $servers[$server->id]["status"] = $server->status;
+ $servers[$server->id]["created"] = $server->created;
+ $servers[$server->id]["updated"] = $server->updated;
+ $servers[$server->id]["ipv4"] = $server->ipv4;
+ $servers[$server->id]["ipv6"] = $server->ipv6;
+ $servers[$server->id]["progress"] = $server->progress;
+ $servers[$server->id]["hostId"] = $server->hostId;
+ $servers[$server->id]["tenantId"] = $server->tenantId;
+ $servers[$server->id]["userId"] = $server->userId;
+ $servers[$server->id]["taskState"] = $server->taskState;
+ $servers[$server->id]["addresses"] = $server->addresses;
+ $servers[$server->id]["links"] = $server->links;
+ $servers[$server->id]["metadata"] = $server->metadata;
+ }
+ $this->app->setOutput("Servers", $servers);
}
- $opt = array('id' => $serverId);
- $server = $this->libClass->getServer($opt);
- $server->retrieve();
- $this->app->setOutput("MyServer", $server);
- return;
- }
- /**
- * Get flavor details.
- * @return array
- */
- public function getFlavor()
- {
- $flavorId = $this->app->getPostParam("flavorId");
- if(!isset($serverId)){
- $this->app->setOutput("Error", "Flavor ID is missing, son!");
- return;
+ catch(BadResponseError $e){
+ $this->app->getErrorInstance()->BadResponseHandler($e);
}
- $opt = array('id' => $flavorId);
- $flavor = $this->libClass->getFlavor($opt);
- $flavor->retrieve();
- $this->app->setOutput("MyFlavor", $flavor);
- return;
- }
- /**
- * Get image details.
- * @return array
- */
- public function getImage()
- {
- $imageId = $this->app->getPostParam("imageId");
- if(!isset($serverId)){
- $this->app->setOutput("Error", "Image ID is missing, son!");
- return;
+ catch(UserInputError $e){
+ $this->app->getErrorInstance()->UserInputHandler($e);
}
- $opt = array('id' => $imageId);
- $image = $this->libClass->getImage($opt);
- $image->retrieve();
- $this->app->setOutput("MyImage", $image);
- return;
- }
- /**
- * Create server.
- * @return array
- */
- 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;
+ catch(BaseError $e){
+ $this->app->getErrorInstance()->BaseErrorHandler($e);
+ }
+ catch(NotImplementedError $e){
+ $this->app->getErrorInstance()->NotImplementedHandler($e);
}
- $opt = array('name' => $name, 'imageId' => $imageId, 'flavorId' => $flavorId);
- $server = $this->libClass->createServer($opt);
- }
-
+ catch(Exception $e){
+ $this->app->getErrorInstance()->OtherException($e);
+ }
+ }
+
/**
- * update a server
+ * List flavors.
+ *
* @return void
*/
- 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;
+ public function listFlavors()
+ {
+ try{
+ $flavorList = $this->libClass->listFlavors();
+ $flavors = Array();
+ foreach($flavorList as $flavor){
+ $flavors[$flavor->id] = Array();
+ $flavor->retrieve();
+ $flavors[$flavor->id]["id"] = $flavor->id;
+ $flavors[$flavor->id]["name"] = $flavor->name;
+ $flavors[$flavor->id]["ram"] = $flavor->ram;
+ $flavors[$flavor->id]["disk"] = $flavor->disk;
+ $flavors[$flavor->id]["vcpus"] = $flavor->vcpus;
+ $flavors[$flavor->id]["links"] = $flavor->links;
+ }
+ $this->app->setOutput("Flavors", $flavors);
}
- $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);
+ 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);
+ }
+ }
+
+ /**
+ * List images.
+ *
+ * @return void
+ */
+ public function listImages()
+ {
+ try{
+ $imageList = $this->libClass->listImages();
+ $images = Array();
+ foreach($imageList as $image){
+ $images[$image->id] = Array();
+ $image->retrieve();
+ $images[$image->id]["id"] = $image->id;
+ $images[$image->id]["name"] = $image->name;
+ $images[$image->id]["status"] = $image->status;
+ $images[$image->id]["created"] = $image->created;
+ $images[$image->id]["updated"] = $image->updated;
+ $images[$image->id]["minDisk"] = $image->minDisk;
+ $images[$image->id]["minRam"] = $image->minRam;
+ $images[$image->id]["progress"] = $image->progress;
+ $images[$image->id]["links"] = $image->links;
+ $images[$image->id]["metadata"] = $image->metadata;
+ }
+ $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);
+ }
+ }
+
+ /**
+ * Get server details.
+ *
+ * @return void
+ */
+ public function getServer()
+ {
+ 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->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);
+ }
+ }
+
+ /**
+ * Get flavor details.
+ *
+ * @return void
+ */
+ public function getFlavor()
+ {
+ try{
+ $flavorId = $this->app->getPostParam("flavorId");
+ if(!isset($serverId)){
+ $this->app->setOutput("Error", "Flavor ID is missing!");
+ return;
+ }
+ $opt = array('id' => $flavorId);
+ $flavor = $this->libClass->getFlavor($opt);
+ $flavor->retrieve();
+ $this->app->setOutput("MyFlavor", $flavor);
+ }
+ catch(BadResponseError $e){
+ $this->app->getErrorInstance()->BadResponseHandler($e);
+ }
+ 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);
+ }
+ }
+
+ /**
+ * Get image details.
+ * @return array
+ */
+ public function getImage()
+ {
+ try{
+ $imageId = $this->app->getPostParam("imageId");
+ if(!isset($serverId)){
+ $this->app->setOutput("Error", "Image ID is missing!");
+ return;
}
- else $attr = array('name' => $newName);
- }
- $server->update($attr);
- $this->app->setOutput("Success", $serverId." has been updated successfully.");
- return;
- }
+ $opt = array('id' => $imageId);
+ $image = $this->libClass->getImage($opt);
+ $image->retrieve();
+ $this->app->setOutput("MyImage", $image);
+ }
+ catch(BadResponseError $e){
+ $this->app->getErrorInstance()->BadResponseHandler($e);
+ }
+ 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);
+ }
+ }
+
+ /**
+ * Create server.
+ *
+ * @return void
+ */
+ public function createServer()
+ {
+ try{
+ $name = $this->app->getPostParam("name");
+ $imageId = $this->app->getPostParam("imageId");
+ $flavorId = $this->app->getPostParam("flavorId");
+ if(!isset($name) || !isset($imageId) || !isset($flavorId)){
+ $this->app->setOutput("Error", "Server name OR image ID OR flavor ID is missing.");
+ return;
+ }
+ $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);
+ }
+ }
+
+ /**
+ * update a server
+ *
+ * @return void
+ */
+ public function updateServer()
+ {
+ try{
+ $serverId = $this->app->getPostParam("serverId");
+ $newName = $this->app->getPostParam("newName");
+ $newIpv4 = $this->app->getPostParam("newIpv4");
+ $newIpv6 = $this->app->getPostParam("newIpv6");
+ if(!isset($serverId)|| !(isset($newName) || isset($newIpv4) || isset($newIpv6)) ){
+ $this->app->setOutput("Error", "You'll have to provide server ID and the new attribute(IP(v4/v6)/Name) you desire to update!");
+ return;
+ }
+ $opt = array('id' => $serverId);
+ $server = $this->libClass->getServer($opt);
+ if (isset($newName)){
+ if(isset($newIpv4)){
+ if(isset($newIpv6)){
+ $attr = array('name' => $newName, 'accessIPv4' => $newIPv4, 'accessIPv6' => $newIpv6);
+ }
+ else $attr = array('name' => $newName, 'accessIPv4' => $newIPv4);
+ }
+ 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);
+ }
+ }
+
/**
* Delete a server
+ *
* @return void
*/
- public function deleteServer()
- {
- $serverId = $this->app->getPostParam("serverId");
- if(!isset($serverId)){
- $this->app->setOutput("Error", "Server ID is missing, son!");
- return;
+ public function deleteServer()
+ {
+ 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->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.");
- return;
- }
+ 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);
+ }
+ }
+
/**
* Change the password of a server
+ *
* @return void
*/
- 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;
+ public function changePassword()
+ {
+ try{
+ $serverId = $this->app->getPostParam("serverId");
+ $password = $this->app->getPostParam("newPassword");
+ if(!isset($serverId) || !isset($password)){
+ $this->app->setOutput("Error", "Server ID or new password missing.");
+ return;
+ }
+ $opt = array('id' => $serverId);
+ $server = $this->libClass->getServer($opt);
+ $server->changePassword($password);
+ $this->app->setOutput("Success", "Password for ".$serverId." has been updated successfully.");
+ }
+ catch(BadResponseError $e){
+ $this->app->getErrorInstance()->BadResponseHandler($e);
+ }
+ catch(UserInputError $e){
+ $this->app->getErrorInstance()->UserInputHandler($e);
}
- $opt = array('id' => $serverId);
- $server = $this->libClass->getServer($opt);
- $server->changePassword($password);
- $this->app->setOutput("Success", "Password for ".$serverId." has been updated successfully.");
- return;
- }
- /**
+ catch(BaseError $e){
+ $this->app->getErrorInstance()->BaseErrorHandler($e);
+ }
+ catch(NotImplementedError $e){
+ $this->app->getErrorInstance()->NotImplementedHandler($e);
+ }
+ catch(Exception $e){
+ $this->app->getErrorInstance()->OtherException($e);
+ }
+ }
+
+ /**
* Reboot a server
+ *
* @return void
*/
- public function reboot()
- {
- $serverId = $this->app->getPostParam("serverId");
- if(!isset($serverId)){
- $this->app->setOutput("Error", "Server ID is missing, son!");
- return;
+ public function reboot()
+ {
+ 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->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);
}
- $opt = array('id' => $serverId);
- $server = $this->libClass->getServer($opt);
- $server->reboot();
- $this->app->setOutput("Success", $serverId." has been deleted successfully.");
- return;
- }
- /**
+ catch(Exception $e){
+ $this->app->getErrorInstance()->OtherException($e);
+ }
+ }
+
+ /**
* Rebuild a server
+ *
* @return void
*/
- public function rebuild()
- {
- $serverId = $this->app->getPostParam("serverId");
- $imageId = $this->app->getPostParam("imageId");
- $newName = $this->app->getPostParam("newName");
- $adminPass = $this->app->getPostParam("adminPass");
+ public function rebuild()
+ {
+ $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;
+ 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.");
+ }
+ 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);
+ }
}
- $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.");
- return;
- }
- /**
+ }
+
+ /**
* Resize a server
+ *
* A call to this method has to be followed by either confirmResize or revertResize
+ *
* @return void
*/
- 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;
+ public function resize()
+ {
+ try{
+ $serverId = $this->app->getPostParam("serverId");
+ $newFlavorId = $this->app->getPostParam("newFlavorId");
+ if(!isset($serverId)|| !isset($flavorId)){
+ $this->app->setOutput("Error", "You'll have to provide server ID and the new flavor ID!");
+ return;
+ }
+ $opt = array('id' => $serverId);
+ $server = $this->libClass->getServer($opt);
+ $server->resize($newFlavorId);
+ }
+ 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);
}
- $opt = array('id' => $serverId);
- $server = $this->libClass->getServer($opt);
- $server->resize($newFlavorId);
- return;
- }
- /**
+ }
+
+ /**
* Confirm resize operation on a server
+ *
* @return void
*/
- public function confirmResize()
- {
- $serverId = $this->app->getPostParam("serverId");
- if(!isset($serverId)){
- $this->app->setOutput("Error", "Server ID is missing!");
- return;
+ public function confirmResize()
+ {
+ try{
+ $serverId = $this->app->getPostParam("serverId");
+ if(!isset($serverId)){
+ $this->app->setOutput("Error", "Server ID is missing!");
+ return;
+ }
+ $opt = array('id' => $serverId);
+ $server = $this->libClass->getServer($opt);
+ $server->confirmResize();
+ $this->app->setOutput("Success", $serverId." has been resized successfully as the new flavor.");
+ }
+ catch(BadResponseError $e){
+ $this->app->getErrorInstance()->BadResponseHandler($e);
}
- $opt = array('id' => $serverId);
- $server = $this->libClass->getServer($opt);
- $server->confirmResize();
- $this->app->setOutput("Success", $serverId." has been resized successfully as the new flavor.");
- return;
- }
- /**
+ 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);
+ }
+ }
+
+ /**
* Revert resize operation on a server
+ *
* @return void
*/
- public function revertResize()
- {
- $serverId = $this->app->getPostParam("serverId");
- if(!isset($serverId)){
- $this->app->setOutput("Error", "Server ID is missing!");
- return;
+ public function revertResize()
+ {
+ try{
+ $serverId = $this->app->getPostParam("serverId");
+ if(!isset($serverId)){
+ $this->app->setOutput("Error", "Server ID is missing!");
+ return;
+ }
+ $opt = array('id' => $serverId);
+ $server = $this->libClass->getServer($opt);
+ $server->revertResize();
+ $this->app->setOutput("Success", $serverId." : resize operation has been reverted to the old flavor.");
}
- $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.");
- return;
- }
- /*
- public function createImage(array $options)
- {
- //TODO
- }
- 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
- }
-*/
+ 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);
+ }
+ }
+
+ /**
+ * List private and public addresses of a server
+ *
+ * @return void
+ */
+ public function listAddresses()
+ {
+ 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);
+ }
+ }
}
-
+
diff --git a/server/core/CoreInterface.php b/server/core/CoreInterface.php
index ed0d959..8bcfad4 100644..100755
--- a/server/core/CoreInterface.php
+++ b/server/core/CoreInterface.php
@@ -1,7 +1,26 @@
<?php
+/**
+* File containing Core Interface.
+*
+*/
+/**
+* Interface for the main classes of the API
+*
+* @version 1.0 Initialisation of this file
+* @since 1.0 Core application's file
+*
+* @author Eole 'eoledev at outlook . fr'
+*/
interface Core{
+ /**
+ * Execute an action in the class
+ *
+ * @param String $action Function to be called
+ *
+ * @return void
+ */
public function action($action);
} \ No newline at end of file
diff --git a/server/core/ErrorManagement.php b/server/core/ErrorManagement.php
index 4ba3493..130c488 100755
--- a/server/core/ErrorManagement.php
+++ b/server/core/ErrorManagement.php
@@ -1,38 +1,126 @@
<?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;
use OpenCloud\Common\Error\NotImplementedError;
use OpenCloud\Common\Error\UserInputError;
-
+/**
+* errorManagement Class of the back-end application
+*
+* Management of error
+*
+*/
Class errorManagement{
+ /** @var App $app protected, contains the main app object */
protected $app;
-
+ /**
+ * ErrorManagemement constructor
+ *
+ * @param App $args the main app object
+ *
+ * @return ErrorManagement Object
+ */
public function __construct($args){
$this->app = $args;
}
+ /**
+ * Put an error message corresponding to a base error in the output
+ *
+ * @param Exception $error the exception triggered
+ *
+ * @return void
+ */
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 Exception $error the exception triggered
+ *
+ * @return void
+ */
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 Exception $error the exception triggered
+ *
+ * @return void
+ */
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 Exception $error the exception triggered
+ *
+ * @return void
+ */
public function UserInputHandler($error){
-
+ $this->app->setOutput("Error", "UserInputError");
+ }
+
+ /**
+ * Put an error message corresponding to an other error in the output
+ *
+ * @param Exception $error the exception triggered
+ *
+ * @return void
+ */
+ public function OtherException($error){
+ $this->app->setOutput("Error", $error->getMessage());
}
-
}
diff --git a/server/core/Identity.php b/server/core/Identity.php
index 7100c9f..112c9e3 100755
--- a/server/core/Identity.php
+++ b/server/core/Identity.php
@@ -2,21 +2,24 @@
/**
* File containing the identity Class.
*
-* @version 1.0 Initialisation of this file
-* @since 1.0 Core application's file
-*
-* @author Eole 'eoledev at outlook . fr'
-*
-* @todo Complete the functions and finish the descriptions
+*/
+
+/**
+* Import the Error of the Library
*/
use OpenCloud\Common\Error;
-
+
+include("CoreInterface.php");
/**
* Identity Class of the back-end application
*
-* This class allow the communication between the front-end application and
-* the library which allow to send requests to an Openstack instance.
+* This class implements the management for the identity request
*
+* @version 1.0 Initialisation of this file
+* @since 1.0 Core application's file
+*
+* @author Eole 'eoledev at outlook . fr'
+*
*/
class identity implements Core{
@@ -31,9 +34,7 @@ class identity implements Core{
*
* @param App $app the main app object
*
- * @throws [Type] [<description>]
- *
- * @return identity
+ * @return identity Object
*/
public function __construct($app){
@@ -51,7 +52,7 @@ class identity implements Core{
*/
public function action($action){
- $this->{$action.""}();
+ $this->{$action.""}();
}
/**
@@ -87,14 +88,16 @@ class identity implements Core{
//TODO parse answer
}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->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);
+ }
}
@@ -111,14 +114,16 @@ class identity implements Core{
//TODO parse answer
}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->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);
+ }
}
@@ -144,14 +149,16 @@ class identity implements Core{
//TODO parse answer
}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->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);
+ }
}
@@ -187,14 +194,16 @@ class identity implements Core{
//TODO parse answer
}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->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);
+ }
}
/**
@@ -220,14 +229,17 @@ class identity implements Core{
//TODO parse answer
}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->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);
+ }
+
}-
/**
@@ -251,13 +263,13 @@ class identity implements Core{
}
if(isset($enabled) && isset($description))
- $opt = array('description' => $description, 'enabled' => $enabled, 'name' => $name);
+ $opt = array('description' => $description, 'enabled' => $enabled, 'name' => $name);
elseif(isset($enabled))
- $opt = array('enabled' => $enabled, 'name' => $name);
+ $opt = array('enabled' => $enabled, 'name' => $name);
elseif(isset($description))
- $opt = array('description' => $description, 'name' => $name);
+ $opt = array('description' => $description, 'name' => $name);
else
- $opt = array('name' => $name);
+ $opt = array('name' => $name);
try{
@@ -266,14 +278,16 @@ class identity implements Core{
//TODO parse answer
}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->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);
+ }
}
@@ -291,14 +305,16 @@ class identity implements Core{
//TODO parse answer
}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->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);
+ }
}
@@ -325,14 +341,16 @@ class identity implements Core{
//TODO parse answer
}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->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);
+ }
}
/**
@@ -357,31 +375,33 @@ class identity implements Core{
return;
}
-
+
try{
$domain = $this->libClass->getDomain($domId);
if(isset($name))
- $domain->name = $name;
+ $domain->name = $name;
if(isset($enabled))
- $domain->enabled = $enabled;
+ $domain->enabled = $enabled;
if(isset($description))
- $domain->description = $description;
+ $domain->description = $description;
$domain->update();
//TODO parse answer
}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->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);
+ }
}
/**
@@ -407,21 +427,21 @@ class identity implements Core{
//TODO parse answer
}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->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);
+ }
}
/**
* Retrieve the different roles of a given user in a domain.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function listRolesDomainUser(){
@@ -442,21 +462,21 @@ class identity implements Core{
//TODO parse answer
}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->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);
+ }
}
/**
* Grant a role to a given user in a domain.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function grantRoleDomainUser(){
@@ -473,28 +493,28 @@ class identity implements Core{
$domain = $this->libClass->getDomain($domId);
$domain->grantUserRole([
- 'userId' => $userId,
- 'roleId' => $roleId,
+ 'userId' => $userId,
+ 'roleId' => $roleId,
]);
//TODO parse answer
}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->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);
+ }
}
/**
* Verify that a user has a given role in a domain.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function checkRoleDomainUser(){
@@ -519,21 +539,21 @@ class identity implements Core{
//TODO parse answer
}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->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);
+ }
}
/**
* Delete a role for a given user in a domain.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function revokeRoleDomainUser(){
@@ -550,28 +570,28 @@ class identity implements Core{
$domain = $this->libClass->getDomain($domId);
$domain->revokeUserRole([
- 'userId' => $userId,
- 'roleId' => $roleId,
+ 'userId' => $userId,
+ 'roleId' => $roleId,
]);
//TODO parse answer
}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->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);
+ }
}
/**
* Retrieve the roles of a given group in a domain.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function listRolesDomainGroup(){
@@ -592,21 +612,21 @@ class identity implements Core{
//TODO parse answer
}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->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);
+ }
}
/**
* Add a role to a given group in a domain.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function grantRoleDomainGroup(){
@@ -623,28 +643,28 @@ class identity implements Core{
$domain = $this->libClass->getDomain($domId);
$domain->grantGroupRole([
- 'groupId' => $groupId,
- 'roleId' => $roleId,
+ 'groupId' => $groupId,
+ 'roleId' => $roleId,
]);
//TODO parse answer
}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->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);
+ }
}
/**
* Verify that a role is associated with a given group in a domain.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function checkRoleDomainGroup(){
@@ -669,27 +689,21 @@ class identity implements Core{
//TODO parse answer
}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->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);
+ }
}
/**
* Delete a role for a given group in a domain.
*
- * A *description*, that can span multiple lines, to go _in-depth_ into the details of this element
- * and to provide some background information or textual references.
- *
- * @param string $myArgument With a *description* of this argument, these may also
- * span multiple lines.
- *
- * @throws [Type] [<description>]
- *
* @return void
*/
private function revokeRoleDomainGroup(){
@@ -706,29 +720,29 @@ class identity implements Core{
$domain = $this->libClass->getDomain($roleId);
$domain->revokeGroupRole([
- 'groupId' => $groupId,
- 'roleId' => $roleId,
+ 'groupId' => $groupId,
+ 'roleId' => $roleId,
]);
//TODO parse answer
}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->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);
+ }
}
/**
* Add an endpoint to the Openstack instance
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function addEndpoint(){
@@ -744,31 +758,31 @@ class identity implements Core{
try{
$endpoint = $this->libClass->createEndpoint([
- 'interface' => \OpenStack\Identity\v3\Enum::INTERFACE_INTERNAL,
- 'name' => $name,
- 'region' => $region,
- 'url' => $url,
- 'serviceId' => $servId
+ 'interface' => \OpenStack\Identity\v3\Enum::INTERFACE_INTERNAL,
+ 'name' => $name,
+ 'region' => $region,
+ 'url' => $url,
+ 'serviceId' => $servId
]);
//TODO parse answer
}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->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);
+ }
}
/**
* Retrieve the endpoint for the given id
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function getEndpoint(){
@@ -786,14 +800,16 @@ class identity implements Core{
//TODO parse answer
}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->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);
+ }
}
/**
@@ -802,7 +818,7 @@ class identity implements Core{
* @return void
*/
private function listEndpoints(){
-
+
try{
$res = $this->libClass->listEndpoints();
@@ -810,60 +826,30 @@ class identity implements Core{
//TODO parse answer
}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->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);
+ }
}
/**
* Update a given endpoint
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function updateEndpoint(){
//Not Implemented Yet
-
- /*$domId = $this->app->getPostParam("domainId");
- $groupId = $this->app->getPostParam("groupId");
-
- if(!isset($domId) || !isset($groupId)){
-
- }
-
- //TODO PARAMETERS
- try{
-
- $endpoint = $this->libClass->getEndpoint('{endpointId}');
-
- $endpoint->interface = \OpenStack\Identity\v3\Enum::INTERFACE_PUBLIC;
-
- $endpoint->update();
-
- //TODO parse answer
-
- }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 given endpoint
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function deleteEndpoint(){
@@ -881,121 +867,48 @@ class identity implements Core{
//TODO parse answer
}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->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);
+ }
}
/**
* Add a group.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function addGroup(){
//Not Implemented Yet
-
- /*$domId = $this->app->getPostParam("domainId");
- $groupId = $this->app->getPostParam("groupId");
-
- if(!isset($domId) || !isset($groupId)){
-
- }
- try{
-
- $this->libClass->listCredentials()
-
- //TODO parse answer
-
- }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 the group's list.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function listGroups(){
//Not Implemented Yet
- /*
- $domId = $this->app->getPostParam("domainId");
- $groupId = $this->app->getPostParam("groupId");
-
- if(!isset($domId) || !isset($groupId)){
-
- }
- try{
-
- $this->libClass->listCredentials()
-
- //TODO parse answer
-
- }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 the details of a given group.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function showGroup(){
//Not Implemented Yet
-
- /*
- $domId = $this->app->getPostParam("domainId");
- $groupId = $this->app->getPostParam("groupId");
-
- if(!isset($domId) || !isset($groupId)){
-
- }
- try{
-
- $this->libClass->listCredentials()
-
- //TODO parse answer
-
- }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 given group.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function updateGroup(){
@@ -1013,30 +926,30 @@ class identity implements Core{
$group = $this->libClass->getGroup($groupId);
if(isset($description))
- $group->description = 'foo';
+ $group->description = 'foo';
if(isset($name))
- $group->name = 'bar';
+ $group->name = 'bar';
$group->update();
//TODO parse answer
}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->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);
+ }
}
/**
* Delete the given group.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function deleteGroup(){
@@ -1056,21 +969,21 @@ class identity implements Core{
//TODO parse answer
}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->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);
+ }
}
/**
* Retrieve the users of a given group.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function listGroupUsers(){
@@ -1090,21 +1003,21 @@ class identity implements Core{
//TODO parse answer
}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->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);
+ }
}
/**
* Add a user to a group.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function addGroupUser(){
@@ -1125,21 +1038,21 @@ class identity implements Core{
//TODO parse answer
}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->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);
+ }
}
/**
* Remove a user from a given group.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function removeGroupUser(){
@@ -1160,21 +1073,21 @@ class identity implements Core{
//TODO parse answer
}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->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);
+ }
}
/**
* Check if a group contains a given user.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function checkGroupUser(){
@@ -1195,187 +1108,67 @@ class identity implements Core{
//TODO parse answer
}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->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);
+ }
}
/**
* @todo
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function addPolicies(){
//Not Implemented Yet
- /*
- $domId = $this->app->getPostParam("domainId");
- $groupId = $this->app->getPostParam("groupId");
-
- if(!isset($domId) || !isset($groupId)){
-
- }
- try{
-
- $this->libClass->listCredentials()
-
- //TODO parse answer
-
- }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);
- }*/
}
/**
* @todo
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function listPolicies(){
//Not Implemented Yet
- /*
- $domId = $this->app->getPostParam("domainId");
- $groupId = $this->app->getPostParam("groupId");
-
- if(!isset($domId) || !isset($groupId)){
-
- }
- try{
-
- $this->libClass->listCredentials()
-
- //TODO parse answer
-
- }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);
- }*/
}
/**
* @todo
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function showPolicie(){
//Not Implemented Yet
- /*
- $domId = $this->app->getPostParam("domainId");
- $groupId = $this->app->getPostParam("groupId");
-
- if(!isset($domId) || !isset($groupId)){
-
- }
- try{
-
- $this->libClass->listCredentials()
-
- //TODO parse answer
-
- }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);
- }*/
}
/**
* @todo
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function updatePolicies(){
//Not Implemented Yet
- /*
- $domId = $this->app->getPostParam("domainId");
- $groupId = $this->app->getPostParam("groupId");
-
- if(!isset($domId) || !isset($groupId)){
-
- }
- try{
-
- $this->libClass->listCredentials()
-
- //TODO parse answer
-
- }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);
- }*/
}
/**
* @todo
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function deletePolicies(){
//Not Implemented Yet
- /*
- $domId = $this->app->getPostParam("domainId");
- $groupId = $this->app->getPostParam("groupId");
-
- if(!isset($domId) || !isset($groupId)){
-
- }
- try{
-
- $this->libClass->listCredentials()
-
- //TODO parse answer
-
- }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);
- }*/
}
/**
* Add a project.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function addProject(){
@@ -1390,22 +1183,24 @@ class identity implements Core{
try{
$project = $this->libClass->createProject([
- 'description' => $description,
- 'enabled' => true,
- 'name' => $name
+ 'description' => $description,
+ 'enabled' => true,
+ 'name' => $name
]);
//TODO parse answer
}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->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);
+ }
}
/**
@@ -1422,21 +1217,21 @@ class identity implements Core{
//TODO parse answer
}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->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);
+ }
}
/**
* Retrieve the details of a given project.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function showProject(){
@@ -1455,21 +1250,21 @@ class identity implements Core{
//TODO parse answer
}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->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);
+ }
}
/**
* Update a given project.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function updateProject(){
@@ -1495,21 +1290,21 @@ class identity implements Core{
//TODO parse answer
}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->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);
+ }
}
/**
* Delete a given project.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function deleteProject(){
@@ -1528,21 +1323,21 @@ class identity implements Core{
//TODO parse answer
}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->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);
+ }
}
/**
* List the roles of a given user in a project.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function listRolesProjectUser(){
@@ -1563,21 +1358,23 @@ class identity implements Core{
//TODO parse answer
}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->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);
+ }catch(Exception $e){
+ $this->app->getErrorInstance()->OtherException($e);
+ }
}
/**
* Grant a role to an user in a project.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function grantRoleProjectUser(){
@@ -1595,28 +1392,28 @@ class identity implements Core{
$project = $this->libClass->getProject($projId);
$project->grantUserRole([
- 'userId' => $userId,
- 'roleId' => $roleId,
+ 'userId' => $userId,
+ 'roleId' => $roleId,
]);
//TODO parse answer
}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->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);
+ }
}
/**
* Check if a given user has a role in a project.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function checkRoleProjectUser(){
@@ -1633,8 +1430,8 @@ class identity implements Core{
$project = $this->libClass->getProject($projId);
$result = $project->checkUserRole([
- 'userId' => $userId,
- 'roleId' => $roleId,
+ 'userId' => $userId,
+ 'roleId' => $roleId,
]);
/*if (true === $result) {
@@ -1643,21 +1440,21 @@ class identity implements Core{
//TODO parse answer
}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->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);
+ }
}
/**
* Delete a role for a given user in a project.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function revokeRoleProjectUser(){
@@ -1675,28 +1472,28 @@ class identity implements Core{
$project = $this->libClass->getProject($projId);
$project->revokeUserRole([
- 'userId' => $userId,
- 'roleId' => $roleId,
+ 'userId' => $userId,
+ 'roleId' => $roleId,
]);
//TODO parse answer
}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->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);
+ }
}
/**
* List the roles of a group in a project.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function listRolesProjectGroup(){
@@ -1708,7 +1505,7 @@ class identity implements Core{
if(!isset($projId) || !isset($groupId)){
}
-
+
try{
$project = $this->libClass->getProject($projId);
@@ -1718,21 +1515,21 @@ class identity implements Core{
//TODO parse answer
}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->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);
+ }
}
/**
* Add a role to a group in a project.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function grantRoleProjectGroup(){
@@ -1744,34 +1541,34 @@ class identity implements Core{
if(!isset($projId) || !isset($userId) || !isset($roleId)){
}
-
+
try{
$project = $this->libClass->getProject($projId);
$project->grantUserRole([
- 'userId' => $userId,
- 'roleId' => $roleId,
+ 'userId' => $userId,
+ 'roleId' => $roleId,
]);
//TODO parse answer
}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->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);
+ }
}
/**
* Check if a group has a given role in a project.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function checkRoleProjectGroup(){
@@ -1789,8 +1586,8 @@ class identity implements Core{
$project = $this->libClass->getProject($projId);
$result = $project->checkGroupRole([
- 'groupId' => $groupId,
- 'roleId' => $roleId,
+ 'groupId' => $groupId,
+ 'roleId' => $roleId,
]);
/*if (true === $result) {
@@ -1798,21 +1595,21 @@ class identity implements Core{
//TODO parse answer
}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->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);
+ }
}
/**
* Delete a role for a group in a project.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function revokeRoleProjectGroup(){
@@ -1830,28 +1627,28 @@ class identity implements Core{
$project = $this->libClass->getProject($projId);
$project->revokeGroupRole([
- 'groupId' => $groupId,
- 'roleId' => $roleId,
+ 'groupId' => $groupId,
+ 'roleId' => $roleId,
]);
//TODO parse answer
}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->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);
+ }
}
/**
* Add a role.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function addRole(){
@@ -1865,20 +1662,22 @@ class identity implements Core{
try{
$role = $this->libClass->createRole([
- 'name' => $name,
+ 'name' => $name,
]);
//TODO parse answer
}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->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);
+ }
}
/**
@@ -1895,18 +1694,20 @@ class identity implements Core{
//TODO parse answer
}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->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);
+ }
}
/**
- * @todo
+ * List the different assignments for a given role
*
* @return void
*/
@@ -1919,21 +1720,21 @@ class identity implements Core{
//TODO parse answer
}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->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);
+ }
}
/**
* Add a service.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function addService(){
@@ -1947,21 +1748,23 @@ class identity implements Core{
try{
$service = $this->libClass->createService([
- 'name' => $name,
- 'type' => $type,
+ 'name' => $name,
+ 'type' => $type,
]);
//TODO parse answer
}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->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);
+ }
}
/**
@@ -1978,21 +1781,21 @@ class identity implements Core{
//TODO parse answer
}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->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);
+ }
}
/**
* Retrieve the details for a given service.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function showService(){
@@ -2009,21 +1812,21 @@ class identity implements Core{
//TODO parse answer
}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->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);
+ }
}
/**
* Delete a given service.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function deleteService(){
@@ -2043,21 +1846,21 @@ class identity implements Core{
//TODO parse answer
}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->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);
+ }
}
/**
* Generate a new token for a given user id.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function genTokenUserID(){
@@ -2072,30 +1875,30 @@ class identity implements Core{
try{
$token = $this->libClass->generateToken([
- 'user' => [
- 'id' => $userId,
- 'password' => $userPass
- ]
+ 'user' => [
+ 'id' => $userId,
+ 'password' => $userPass
+ ]
]);
//TODO parse answer
}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->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);
+ }
}
/**
* Generate a new token for a given user name.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function genTokenUserName(){
@@ -2111,33 +1914,33 @@ class identity implements Core{
try{
$token = $this->libClass->generateToken([
- 'user' => [
- 'name' => $username,
- 'password' => $userPass,
- 'domain' => [
- 'id' => $domId
- ]
- ]
+ 'user' => [
+ 'name' => $username,
+ 'password' => $userPass,
+ 'domain' => [
+ 'id' => $domId
+ ]
+ ]
]);
//TODO parse answer
}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->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);
+ }
}
/**
* Generate a new token from another token ID.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function genTokenID(){
@@ -2152,28 +1955,28 @@ class identity implements Core{
try{
$token = $this->libClass->generateToken([
- 'tokenId' => $tokenId,
- 'scope' => ['project' => ['id' => $projectId]]
+ 'tokenId' => $tokenId,
+ 'scope' => ['project' => ['id' => $projectId]]
]);
//TODO parse answer
}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->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);
+ }
}
/**
* Generate a new token scoped by a project ID.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function genTokenScopedProjectID(){
@@ -2189,33 +1992,33 @@ class identity implements Core{
try{
$token = $this->libClass->generateToken([
- 'user' => [
- 'id' => $userId,
- 'password' => $userPass
- ],
- 'scope' => [
- 'project' => ['id' => $projId]
- ]
+ 'user' => [
+ 'id' => $userId,
+ 'password' => $userPass
+ ],
+ 'scope' => [
+ 'project' => ['id' => $projId]
+ ]
]);
//TODO parse answer
}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->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);
+ }
}
/**
* Generate a new token scoped by a project name.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function genTokenScopedProjectName(){
@@ -2232,38 +2035,38 @@ class identity implements Core{
try{
$token = $this->libClass->generateToken([
- 'user' => [
- 'id' => $userId,
- 'password' => $userPass
- ],
- 'scope' => [
- 'project' => [
- 'name' => $projName,
- 'domain' => [
- 'id' => $domId
- ]
- ]
- ]
+ 'user' => [
+ 'id' => $userId,
+ 'password' => $userPass
+ ],
+ 'scope' => [
+ 'project' => [
+ 'name' => $projName,
+ 'domain' => [
+ 'id' => $domId
+ ]
+ ]
+ ]
]);
//TODO parse answer
}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->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);
+ }
}
/**
* Check if a token is validate.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function validateToken(){
@@ -2285,21 +2088,21 @@ class identity implements Core{
//TODO parse answer
}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->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);
+ }
}
/**
* Delete a given token.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function revokeToken(){
@@ -2317,21 +2120,21 @@ class identity implements Core{
//TODO parse answer
}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->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);
+ }
}
/**
* Add a new user.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function addUser(){
@@ -2344,32 +2147,34 @@ class identity implements Core{
$domId = $this->app->getPostParam("domId");
if(!isset($domId) || !isset($groupId)){
-
+
}
try{
$user = $this->libClass->createUser([
- 'defaultProjectId' => $projId,
- 'description' => $desc,
- 'domainId' => $domId,
- 'email' => $email,
- 'enabled' => true,
- 'name' => $name,
- 'password' => $pass
+ 'defaultProjectId' => $projId,
+ 'description' => $desc,
+ 'domainId' => $domId,
+ 'email' => $email,
+ 'enabled' => true,
+ 'name' => $name,
+ 'password' => $pass
]);
//TODO parse answer
}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->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);
+ }
}
/**
@@ -2386,21 +2191,21 @@ class identity implements Core{
//TODO parse answer
}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->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);
+ }
}
/**
* Retrieve the details of a given user.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function showUser(){
@@ -2419,21 +2224,21 @@ class identity implements Core{
//TODO parse answer
}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->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);
+ }
}
/**
* Update a given user.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function updateUser(){
@@ -2458,21 +2263,21 @@ class identity implements Core{
//TODO parse answer
}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->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);
+ }
}
/**
* Delete a given user.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function deleteUser(){
@@ -2491,21 +2296,21 @@ class identity implements Core{
//TODO parse answer
}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->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);
+ }
}
/**
* Retrieve the groups which contains a given user.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function listUserGroups(){
@@ -2525,21 +2330,21 @@ class identity implements Core{
//TODO parse answer
}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->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);
+ }
}
/**
* Retrieve the projects which contains a given user.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function listUserProjects(){
@@ -2559,13 +2364,15 @@ class identity implements Core{
//TODO parse answer
}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->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);
+ }
}
}
diff --git a/server/core/Image.php b/server/core/Image.php
index d37c828..b256d4c 100755
--- a/server/core/Image.php
+++ b/server/core/Image.php
@@ -5,23 +5,21 @@
* @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
*/
-use OpenStack\Common\Error\BadResponseError;
-use OpenStack\Common\Error\BaseError;
-use OpenStack\Common\Error\NotImplementedError;
-use OpenStack\Common\Error\UserInputError;
+use OpenCloud\Common\Error\BadResponseError;
+use OpenCloud\Common\Error\BaseError;
+use OpenCloud\Common\Error\NotImplementedError;
+use OpenCloud\Common\Error\UserInputError;
include("CoreInterface.php");
-
/**
* Image Class of the back-end application
*
-* ADD CLASS DESCRIPTION
+* Management of images
*
*/
class image implements Core{
@@ -29,7 +27,7 @@ class image implements Core{
/** @var App $app protected, contains the main app object */
protected $app;
- /** @var OpenStack\Identity $libClass protected, contains the library Identity object */
+ /** @var OpenStack\Image $libClass protected, contains the library Image object */
protected $libClass;
/**
@@ -37,13 +35,11 @@ class image implements Core{
*
* @param App $app the main app object
*
- * @throws [Type] [<description>]
- *
- * @return Image
+ * @return image Object
*/
public function __construct($app){
if(!isset($app)){
- $this->app->setOutput("Error", "Incorrect parameter");
+ $this->app->setOutput("Error", "Incorrect parameter app");
}
$this->app = $app;
$this->libClass = $app->getLibClass("Image");
@@ -58,47 +54,46 @@ class image implements Core{
* @return void
*/
public function action($action){
-
- $this->{$action.""}();
-
+ $this->{$action.""}();
}
/**
- * Details about an image
+ * Create a new image
*
- * @param array $opt
- * options for the image creation
+ * @param array $opt Options for the image creation (name is required, others are optionals)
*
- **/
+ * @return void
+ */
private function createImage(){
$opt = $this->app->getPostParam("opt");
-
if(!isset($opt)){
- $this->app->setOutput("Error", "Incorrect parameter");
+ $this->app->setOutput("Error", "Incorrect parameter opt");
}
-
try{
- // VOIR SI MAUVAIS TYPE
$options = Array();
- if(isset($opt['name'])){ // if the image name already exists -> error
- $imagesList = listImage();
- if(isset($images)){
- foreach($imagesList as $image){
- if(strcmp($image->name, $opt['name']) == 0){
-
- }
- }
- }
+ // Check the image name
+ if(isset($opt['name'])){
+ $imagesList = $this->listImage();
+ if(isset($imagesList)){
+ foreach($imagesList as $image){
+ if(strcmp($image->name, $opt['name']) == 0){ // if the image name already exists -> error
+ $this->app->setOutput("Error", "Image name already exists");
+ }
+ }
+ }
+ $options['name'] = $opt['name'];
}
else{
- $this->app->setOutput("Error", "Image name already exists");
+ $this->app->setOutput("Error", "Missing parameter 'name' for the new image");
}
+
+ // Check optionals arguments
if(isset($opt['id'])){ // UUID : nnnnnnnn-nnnn-nnnn-nnnn-nnnnnnnnnnnn
if($this->libClass->getImage($opt['id']) != null){ // if the id already exists -> error
-
+ $this->app->setOutput("Error", "Image id already exists");
}
$options['id'] = $opt['id'];
}
@@ -123,20 +118,22 @@ 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'];
}
$image = $this->libClass->createImage($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);
- }
+ }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("Images", $image);
}
@@ -144,7 +141,7 @@ class image implements Core{
/**
* List the images of the server
*
- * @return the list with all images on the server
+ * @return void
*/
private function listImage(){
try{
@@ -155,13 +152,15 @@ class image implements Core{
}
}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(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("Images", $result);
@@ -170,45 +169,48 @@ class image implements Core{
/**
* Details about an image
*
- * @param string $id
- * identifier of the image
- *
- **/
+ * @param String $id Identifier of the image
+ *
+ * @return void
+ */
private function detailsImage(){
$id = $this->app->getPostParam("id");
+
if(!isset($id)){
$this->app->setOutput("Error", "Incorrect id parameter");
-
}
- try{
- $service = $this->libClass;
- $image = $service->getImage($id);
- if($image == null){ // if the image don't exists -> error
- $this->app->setOutput("Error", "Image doesn't exist");
+ else{
+ try{
+ $service = $this->libClass;
+ $image = $service->getImage($id);
+ if($image == null){ // if the image don't exists -> error
+ $this->app->setOutput("Error", "Image doesn't exist");
+ }
+ else{
+ $this->app->setOutput("Images", $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);
}
-
- $this->app->setOutput("Images", $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);
- }
+ }
}
/**
- * Details about an image
- *
- * @param string $id
- * id of the image
+ * Update informations about an image
*
- * @param array $opt
- * options for the image creation
- **/
+ * @param String $id id of the image
+ * @param array $opt Options for the image creation
+ *
+ * @return void
+ */
private function updateImage(){
$id = $this->app->getPostParam("id");
@@ -217,395 +219,425 @@ class image implements Core{
if(!isset($id)){
$this->app->setOutput("Error", "Incorrect id parameter");
}
- if(!isset($opt)){
+ else if(!isset($opt)){
$this->app->setOutput("Error", "Incorrect opt parameter");
}
+ else{
+ try{
+ $service = $this->libClass;
+ $image = $service->getImage($id);
+ if($image == null){ // if the image don't exists -> error
+ $this->app->setOutput("Error", "Image doesn't exist");
+ }
- try{
- //vérifier existence image
- $service = $this->libClass;
- $image = $service->getImage($id);
- if($image == null){ // if the image don't exists -> error
- $this->app->setOutput("Error", "Image doesn't exist");
- }
+ $options = Array();
- $options = Array();
-
- // Voir vérification des types
- if(isset($opt['name'])){ //string
- $options['name'] = $opt['name'];
- }
- if(isset($opt['minDisk'])){ //int
- $options['minDisk'] = $opt['minDisk'];
- }
- if(isset($opt['minRam'])){ // int
- $options['minRam'] = $opt['minRam'];
- }
- if(isset($opt['protected'])){ // boolean
- $options['protected'] = $opt['protected'];
- }
- if(isset($opt['visibility'])){ // public, private
- $options['visibility'] = $opt['visibility'];
- }
- if(isset($opt['tags'])){ // list
- $options['tags'] = $opt['tags'];
+ // Voir vérification des types
+ if(isset($opt['name'])){ //string
+ $options['name'] = $opt['name'];
+ }
+ if(isset($opt['minDisk'])){ //int
+ $options['minDisk'] = $opt['minDisk'];
+ }
+ if(isset($opt['minRam'])){ // int
+ $options['minRam'] = $opt['minRam'];
+ }
+ if(isset($opt['protected'])){ // boolean
+ $options['protected'] = $opt['protected'];
+ }
+ if(isset($opt['visibility'])){ // public, private
+ $options['visibility'] = $opt['visibility'];
+ }
+ if(isset($opt['tags'])){ // list
+ $options['tags'] = $opt['tags'];
+ }
+ $image->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);
+ }catch(Exception $e){
+ $this->app->getErrorInstance()->OtherException($e);
}
- $image->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);
- }
- $this->app->setOutput("Images", $image);
+ $this->app->setOutput("Images", $image);
+ }
}
/**
* Delete an image
*
- * @param string $id
- * identifier of the image
- **/
+ * @param String $id Identifier of the image
+ *
+ * @return void
+ */
private function deleteImage(){
- // si protected = true, demander de le mettre a false
- // vérifier existence image
$id = $this->app->getPostParam("id");
if(!isset($id)){
$this->app->setOutput("Error", "Image doesn't exist");
}
-
- try{
- $service = $this->libClass;
- $image = $this->libClass->getImage($id);
- if($image == null){ // if the image don't exists -> error
- $this->app->setOutput("Error", "Image doesn't exist");
- }
- $image->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);
- }
+ else{
+ try{
+ $service = $this->libClass;
+ $image = $this->libClass->getImage($id);
+ if($image == null){ // if the image doesn't exists -> error
+ $this->app->setOutput("Error", "Image doesn't exist");
+ }
+ $image->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);
+ }catch(Exception $e){
+ $this->app->getErrorInstance()->OtherException($e);
+ }
+ }
}
/**
- * Resactive an image
+ * Reactive an image
*
- * @param string $id
- * identifier of the image
- **/
+ * @param String $id Identifier of the image
+ *
+ * @return void
+ */
private function reactivateImage(){
$id = $this->app->getPostParam("id");
if(!isset($id)){
$this->app->setOutput("Error", "Incorrect parameter");
}
- try{
- // vérifier existence image
- $service = $this->libClass;
- $image = $service->getImage($id);
- if($image == null){ // if the image don't exists -> error
- $this->app->setOutput("Error", "Image doesn't exist");
+ else
+ {
+ try{
+ $service = $this->libClass;
+ $image = $service->getImage($id);
+ 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);
+ }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);
}
- $image->reactivate();
- }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);
- }
+ }
}
/**
- * Desactive an image
+ * Desactivaate an image
*
- * @param string $id
- * identifier of the image
- **/
+ * @param String $id Identifier of the image
+ *
+ * @return void
+ */
private function desactivateImage(){
$id = $this->app->getPostParam("id");
if(!isset($id)){
$this->app->setOutput("Error", "Incorrect parameter");
}
- try{
- // vérifier existence image
- $service = $this->libClass;
- $image = $service->getImage($id);
- if($image == null){ // if the image don't exists -> error
- $this->app->setOutput("Error", "Image doesn't exist");
+ else
+ {
+ try{
+ $service = $this->libClass;
+ $image = $service->getImage($id);
+ if($image == null){ // if the image don't exists -> error
+ $this->app->setOutput("Error", "Image doesn't exist");
+ }
+ $image->deactivate();
+ }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);
}
- $image->deactivate();
- }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);
- }
+ }
}
/**
* Upload an image
*
- * @param string $id
- * identifier of the image
- *
- * @param string $file_name
- * path of the image
- **/
+ * @param String $id Identifier of the image
+ * @param String $file_name Path of the image
+ *
+ * @return void
+ */
private function uploadImage(){
$id = $this->app->getPostParam("id");
$file_name = $this->app->getPostParam("file_name");
-
-
+ $file = $this->app->getPostParam("file");
+ error_log(print_r($file, true), 0);
+
if(!isset($id)){
$this->app->setOutput("Error", "Incorrect id parameter");
}
- if(!isset($file_name)){
- $this->app->setOutput("Error", "Incorrect file_name parameter");
+ else if(!isset($file_name)){
+ $this->app->setOutput("Error", "Incorrect file name parameter");
}
- try{
- // vérifier existence image
- $service = $this->libClass;
- $image = $service->getImage($id);
- if($image == null){ // if the image don't exists -> error
- $this->app->setOutput("Error", "Image doesn't exist");
+ else{
+ try{
+ $service = $this->libClass;
+ $image = $service->getImage($id);
+ if($image == null){ // if the image don't exists -> error
+ $this->app->setOutput("Error", "Image doesn't exist");
+ }
+ $stream = \GuzzleHttp\Psr7\stream_for($file);
+ $image->uploadData($stream);
+ }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);
}
- $stream = \GuzzleHttp\Psr7\stream_for(fopen($file_name, 'r'));
- $image->uploadData($stream);
- }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);
- }
+ }
}
/**
* Download an image
*
- * @param string $id
- * identifier of the image
- **/
+ * @param String $id Identifier of the image
+ *
+ * @return void
+ */
private function downloadImage(){
$id = $this->app->getPostParam("id");
if(!isset($id)){
- $this->app->setOutput("Error", "Incorrect parameter");
+ $this->app->setOutput("Error", "Incorrect id parameter");
+ }
+ else{
+ try{
+ $service = $this->libClass;
+ $image = $service->getImage($id);
+ if($image == null){ // if the image don't exists -> error
+ $this->app->setOutput("Error", "Image doesn't exist");
+ }
+ $stream = $image->downloadData();
+ }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("Images", $stream);
}
- try{
- // vérifier existence image
- $service = $this->libClass;
- $image = $service->getImage($id);
- if($image == null){ // if the image don't exists -> error
- $this->app->setOutput("Error", "Image doesn't exist");
- }
- $stream = $image->downloadData();
- }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("Images", $stream);
}
/**
* Add a member to image
*
- * @param string $image_id
- * identifier of the image
- *
- * @param string $member_id
- * identifier of the member
- **/
+ * @param String $image_id Identifier of the image
+ * @param String $member_id Identifier of the member
+ *
+ * @return void
+ */
private function addMemberImage(){
$image_id = $this->app->getPostParam("image_id");
$member_id = $this->app->getPostParam("member_id");
if(!isset($image_id)){
- $this->app->setOutput("Error", "Incorrect parameter image_id");
+ $this->app->setOutput("Error", "Incorrect image id parameter");
}
- if(!isset($member_id)){
- $this->app->setOutput("Error", "Incorrect parameter member_id");
+ else if(!isset($member_id)){
+ $this->app->setOutput("Error", "Incorrect member id parameter");
}
- try{
- $service = $this->libClass;
+ else{
+ try{
+ $service = $this->libClass;
- $image = $service->getImage($id);
- if($image == null){ // if the image don't exists -> error
- $this->app->setOutput("Error", "Image doesn't exist");
+ $image = $service->getImage($id);
+ if($image == null){ // if the image don't exists -> error
+ $this->app->setOutput("Error", "Image doesn't exist");
+ }
+ $member_id = $image->addMember($member_id);
+ $this->app->setOutput("Images", $member_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);
+ }catch(Exception $e){
+ $this->app->getErrorInstance()->OtherException($e);
}
- $member_id = $image->addMember($member_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);
- }
+ }
}
/**
* List members of an image
*
- * @param string $image_id
- * identifier of the image
- **/
+ * @param String $image_id identifier of the image
+ *
+ * @return void
+ */
private function listMemberImage(){
$image_id = $this->app->getPostParam("image_id");
$member_id = $this->app->getPostParam("member_id");
if(!isset($image_id)){
- $this->app->setOutput("Error", "Incorrect parameter image_id");
+ $this->app->setOutput("Error", "Incorrect image id parameter");
}
- if(!isset($member_id)){
- $this->app->setOutput("Error", "Incorrect parameter member_id");
+ else if(!isset($member_id)){
+ $this->app->setOutput("Error", "Incorrect member id parameter");
+ }
+ else{
+ try{
+ $service = $this->libClass;
+ $image = $service->getImage($image_id);
+ if($image == null){ // if the image don't exists -> error
+ $this->app->setOutput("Error", "Image doesn't exist");
+ }
+ $members = $image->listMembers();
+ if($members == null){ // if the image don't exists -> error
+ $this->app->setOutput("Error", "No member");
+ }
+ }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("Images", $members);
}
- try{
- // vérifier existence image
- $service = $this->libClass;
- $image = $service->getImage($image_id);
- if($image == null){ // if the image don't exists -> error
- $this->app->setOutput("Error", "Image doesn't exist");
- }
- $members = $image->listMembers();
- if($member == null){ // if the image don't exists -> error
- $this->app->setOutput("Error", "No member");
- }
- }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("Images", $member);
}
/**
* Show details of a member of an image
*
- * @param string $image_id
- * identifier of the image
+ * @param String $image_id Identifier of the image
+ * @param String $member_id Identifier of the member
*
- * @param string $member_id
- * identifier of the member
- **/
+ * @return void
+ */
private function detailMemberImage(){
$image_id = $this->app->getPostParam("image_id");
$member_id = $this->app->getPostParam("member_id");
if(!isset($image_id)){
- $this->app->setOutput("Error", "Incorrect parameter image_id");
+ $this->app->setOutput("Error", "Incorrect image id parameter");
}
- if(!isset($member_id)){
- $this->app->setOutput("Error", "Incorrect parameter member_id");
+ else if(!isset($member_id)){
+ $this->app->setOutput("Error", "Incorrect member id parameter");
}
- try{
- // vérifier existence image
- // on doit être le proprio de l'image
- // vérifier membre existe
- $service = $this->libClass;
-
- $image = $service->getImage($id);
- if($image == null){ // if the image don't exists -> error
- $this->app->setOutput("Error", "Image doesn't exist");
- }
+ else{
+ try{
+ $service = $this->libClass;
- $member = $image->getMember($member_id);
- if($member == null){ // if the member don't exists -> error
- $this->app->setOutput("Error", "Member doesn't exist");
- }
- }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("Images", $member);
+ $image = $service->getImage($id);
+ if($image == null){ // if the image don't exists -> error
+ $this->app->setOutput("Error", "Image doesn't exist");
+ }
+
+ $member = $image->getMember($member_id);
+ if($member == null){ // if the member don't exists -> error
+ $this->app->setOutput("Error", "Member doesn't exist");
+ }
+ }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("Images", $member);
+ }
}
/**
* Remove a member of an image
*
- * @param string $image_id
- * identifier of the image
- *
- * @param string $member_id
- * identifier of the member
- **/
+ * @param String $image_id Identifier of the image
+ * @param String $member_id Identifier of the member
+ *
+ * @return void
+ */
private function removeMemberImage(){
$image_id = $this->app->getPostParam("image_id");
$member_id = $this->app->getPostParam("member_id");
if(!isset($image_id)){
- $this->app->setOutput("Error", "Incorrect parameter image_id");
+ $this->app->setOutput("Error", "Incorrect image id parameter");
}
- if(!isset($member_id)){
- $this->app->setOutput("Error", "Incorrect parameter member_id");
+ else if(!isset($member_id)){
+ $this->app->setOutput("Error", "Incorrect member id parameter");
}
- try{
- $service = $this->libClass;
-
- $image = $service->getImage($id);
- if($image == null){ // if the image don't exists -> error
- $this->app->setOutput("Error", "Image doesn't exist");
- }
- $member = $image->getMember($member_id);
- if($member == null){ // if the image don't exists -> error
- $this->app->setOutput("Error", "Member doesn't exist");
+ else{
+ try{
+ $service = $this->libClass;
+
+ $image = $service->getImage($id);
+ if($image == null){ // if the image don't exists -> error
+ $this->app->setOutput("Error", "Image doesn't exist");
+ }
+ $member = $image->getMember($member_id);
+ if($member == null){ // if the image don't exists -> error
+ $this->app->setOutput("Error", "Member doesn't exist");
+ }
+ $member->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);
+ }catch(Exception $e){
+ $this->app->getErrorInstance()->OtherException($e);
}
- $member->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);
- }
+ }
}
/**
* Update a member of an image
*
- * @param string $image_id
- * identifier of the image
- *
- * @param string $member_id
- * identifier of the member
+ * @param String $image_id Identifier of the image
+ * @param String $member_id Identifier of the member
+ * @param String $status New status for the member
*
- * @param string $status
- * new status for the member
+ * @return void
**/
private function updateMemberImage(){
$image_id = $this->app->getPostParam("image_id");
@@ -613,33 +645,37 @@ class image implements Core{
$status = $this->app->getPostParam("status");
if(!isset($image_id)){
- $this->app->setOutput("Error", "Incorrect parameter image_id");
+ $this->app->setOutput("Error", "Incorrect image id parameter");
}
- if(!isset($member_id)){
- $this->app->setOutput("Error", "Incorrect parameter member_id");
+ else if(!isset($member_id)){
+ $this->app->setOutput("Error", "Incorrect member id parameter");
}
- try{
- $service = $this->libClass;
+ else{
+ try{
+ $service = $this->libClass;
- $image = $service->getImage($id);
- if($image == null){ // if the image don't exists -> error
- $this->app->setOutput("Error", "Image doesn't exist");
- }
- $member = $image->getMember($member_id);
- if($member == null){ // if the member don't exists -> error
- $this->app->setOutput("Error", "Member doesn't exist");
+ $image = $service->getImage($id);
+ if($image == null){ // if the image don't exists -> error
+ $this->app->setOutput("Error", "Image doesn't exist");
+ }
+ $member = $image->getMember($member_id);
+ if($member == null){ // if the member don't exists -> error
+ $this->app->setOutput("Error", "Member doesn't exist");
+ }
+ $member->updateStatus($status);
+ }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);
}
- $member->updateStatus($status);
- }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);
- }
+ }
}
}
-?> \ No newline at end of file
+?>
diff --git a/server/core/LibOverride/genTokenOptions.php b/server/core/LibOverride/genTokenOptions.php
index bdae8a6..7134887 100755
--- a/server/core/LibOverride/genTokenOptions.php
+++ b/server/core/LibOverride/genTokenOptions.php
@@ -1,4 +1,14 @@
<?php
+/**
+* File containing the override of the authentication for the Library.
+*
+* @version 1.0 Initialisation of this file
+* @since 1.0 Core application's file
+*
+* @author Eole 'eoledev at outlook . fr'
+*
+* @todo Check with the API, the condition and test the revoke token implementation
+*/
use GuzzleHttp\Client;
use OpenCloud\Common\Transport\HandlerStack;
@@ -9,47 +19,83 @@ use OpenCloud\Common\Auth\Token;
use OpenCloud\Common\Transport\Utils;
use OpenStack\Identity\v3\Models;
+/**
+* genTokenOptions Class
+*
+* This class allow the generation of tokens for openstack, and to inject
+* those tokens into the library. Which allow to do a proper login only once
+* and not for each request
+*
+*/
class genTokenOptions
{
+ /** @var Array $optionsGlobal private, contains the options common for the different tokens */
private $optionsGlobal;
-
- private $stack;
+ /** @var Array $backup private, contains all the informations about the different tokens. It contains the information send to the clients */
private $backup = [];
+ /** @var GuzzleHttp\Client $httpClient private, contains a default Client to construct some OpenStack library object */
private $httpClient;
+ /**
+ * genTokenOptions constructor
+ *
+ * @param Array $options Options to create the objects in the library
+ * AuthUrl is the main options required
+ *
+ * @return genTokenOptions Object
+ */
public function __construct($options){
- $this->stack = HandlerStack::create();
+ $stack = HandlerStack::create();
$httpClient = new Client([
- 'base_uri' => Utils::normalizeUrl($options['authUrl']),
- 'handler' => $this->stack,
- ]);
+ 'base_uri' => Utils::normalizeUrl($options['authUrl']),
+ 'handler' => $stack,
+ ]);
$this->httpClient = $httpClient;
- $options['identityService'] = Service::factory($httpClient);
+ $options['identityService'] = Service::factory($httpClient);
$options['authHandler'] = function () use ($options) {
return $options['identityService']->generateToken($options);
- };
+ };
$this->optionsGlobal['Common'] = $options;
}
-
- /**
- * @codeCoverageIgnore
- */
- private function addDebugMiddleware(array $options, HandlerStack &$stack)
- {
- if (!empty($options['debugLog'])
- && !empty($options['logger'])
- && !empty($options['messageFormatter'])
- ) {
- $stack->push(GuzzleMiddleware::log($options['logger'], $options['messageFormatter']));
- }
- }
+
+ /**
+ * Add a debug for the library
+ *
+ * @param array $options Debug options, cf library
+ * @param HandlerStack $stack pointer to a HandlerStack object
+ *
+ * @return void
+ */
+ private function addDebugMiddleware(array $options, HandlerStack &$stack)
+ {
+ if (!empty($options['debugLog'])
+ && !empty($options['logger'])
+ && !empty($options['messageFormatter'])
+ ) {
+ $stack->push(GuzzleMiddleware::log($options['logger'], $options['messageFormatter']));
+ }
+ }
+
+ /**
+ * Check the expiration time of a token
+ *
+ * @return boolean if the token is not expired
+ */
+ public function checkToken(){
+ return $this->backup['time'] > time();
+ }
+ /**
+ * Generate a new token for the Identity service
+ *
+ * @return void
+ */
public function genIdentityToken(){
$options = $this->optionsGlobal['Common'];
$options['catalogName'] = 'false';
@@ -67,20 +113,32 @@ class genTokenOptions
$this->addDebugMiddleware($options, $stack);
$options['httpClient'] = new Client([
- 'base_uri' => Utils::normalizeUrl($baseUrl),
- 'handler' => $stack,
- ]);
+ 'base_uri' => Utils::normalizeUrl($baseUrl),
+ 'handler' => $stack,
+ ]);
$this->saveBackup('Identity', array('token' => $token, 'baseUrl' => $baseUrl ));
$this->optionsGlobal['Identity'] = $options;
}
+ /**
+ * Revoke the token for the Identity Service
+ *
+ * @return void
+ */
public function revokeIdentityToken(){
$token = $this->unserializeToken($this->backup['Identity']['token']);
$this->optionsGlobal['Common']['identityService']->revokeToken($token->id);
}
+ /**
+ * Load a token for the Identity Service
+ *
+ * @param String $opt serialized token
+ *
+ * @return void
+ */
public function loadIdentityBackup($opt){
$options = $this->optionsGlobal['Common'];
$options['catalogName'] = 'false';
@@ -92,20 +150,25 @@ class genTokenOptions
$baseUrl = $this->backup['Identity']['baseUrl'];
$stack = HandlerStack::create();
-
+
$stack->push(Middleware::authHandler($options['authHandler'], $token));
$this->addDebugMiddleware($options, $stack);
$options['httpClient'] = new Client([
- 'base_uri' => Utils::normalizeUrl($baseUrl),
- 'handler' => $stack,
- ]);
+ 'base_uri' => Utils::normalizeUrl($baseUrl),
+ 'handler' => $stack,
+ ]);
$this->saveBackup('Identity', array('token' => $token, 'baseUrl' => $baseUrl ));
$this->optionsGlobal['Identity'] = $options;
}
+ /**
+ * Generate a new token for the Image service
+ *
+ * @return void
+ */
public function genImageToken(){
$options = $this->optionsGlobal['Common'];
$options['catalogName'] = 'glance';
@@ -116,25 +179,37 @@ class genTokenOptions
$stack = HandlerStack::create();
- $stack->push(Middleware::authHandler($options['authHandler'], $token));
+ $stack->push(Middleware::authHandler($options['authHandler'], $token));
$this->addDebugMiddleware($options, $stack);
$options['httpClient'] = new Client([
- 'base_uri' => Utils::normalizeUrl($baseUrl),
- 'handler' => $stack,
- ]);
+ 'base_uri' => Utils::normalizeUrl($baseUrl),
+ 'handler' => $stack,
+ ]);
$this->saveBackup('Image', array('token' => $token, 'baseUrl' => $baseUrl ));
$this->optionsGlobal['Image'] = $options;
}
+ /**
+ * Revoke the token for the Image Service
+ *
+ * @return void
+ */
public function revokeImageToken(){
$token = $this->unserializeToken($this->backup['Image']['token']);
$this->optionsGlobal['Common']['identityService']->revokeToken($token->id);
}
+ /**
+ * Load a token for the Image Service
+ *
+ * @param String $opt serialized token
+ *
+ * @return void
+ */
public function loadImageBackup($opt){
$options = $this->optionsGlobal['Common'];
$options['catalogName'] = 'glance';
@@ -144,7 +219,7 @@ class genTokenOptions
$this->backup['Image'] = $opt;
$token = $this->unserializeToken($this->backup['Image']['token']);
$baseUrl = $this->backup['Image']['baseUrl'];
-
+
$stack = HandlerStack::create();
$stack->push(Middleware::authHandler($options['authHandler'], $token));
@@ -152,13 +227,18 @@ class genTokenOptions
$this->addDebugMiddleware($options, $stack);
$options['httpClient'] = new Client([
- 'base_uri' => Utils::normalizeUrl($baseUrl),
- 'handler' => $stack,
- ]);
+ 'base_uri' => Utils::normalizeUrl($baseUrl),
+ 'handler' => $stack,
+ ]);
$this->saveBackup('Image', array('token' => $token, 'baseUrl' => $baseUrl ));
$this->optionsGlobal['Image'] = $options;
}
+ /**
+ * Generate a new token for the Metwork service
+ *
+ * @return void
+ */
public function genNetworkToken(){
$options = $this->optionsGlobal['Common'];
$options['catalogName'] = 'neutron';
@@ -169,25 +249,37 @@ class genTokenOptions
$stack = HandlerStack::create();
- $stack->push(Middleware::authHandler($options['authHandler'], $token));
+ $stack->push(Middleware::authHandler($options['authHandler'], $token));
$this->addDebugMiddleware($options, $stack);
$options['httpClient'] = new Client([
- 'base_uri' => Utils::normalizeUrl($baseUrl),
- 'handler' => $stack,
- ]);
+ 'base_uri' => Utils::normalizeUrl($baseUrl),
+ 'handler' => $stack,
+ ]);
$this->saveBackup('Network', array('token' => $token, 'baseUrl' => $baseUrl ));
$this->optionsGlobal['Network'] = $options;
}
+ /**
+ * Revoke the token for the Network Service
+ *
+ * @return void
+ */
public function revokeNetworkToken(){
$token = $this->unserializeToken($this->backup['Network']['token']);
$this->optionsGlobal['Common']['identityService']->revokeToken($token->id);
}
+ /**
+ * Load a token for the Network Service
+ *
+ * @param String $opt serialized token
+ *
+ * @return void
+ */
public function loadNetworkBackup($opt){
$options = $this->optionsGlobal['Common'];
$options['catalogName'] = 'neutron';
@@ -197,21 +289,26 @@ class genTokenOptions
$this->backup['Network'] = $opt;
$token = $this->unserializeToken($this->backup['Network']['token']);
$baseUrl = $this->backup['Network']['baseUrl'];
-
+
$stack = HandlerStack::create();
-
+
$stack->push(Middleware::authHandler($options['authHandler'], $token));
$this->addDebugMiddleware($options, $stack);
$options['httpClient'] = new Client([
- 'base_uri' => Utils::normalizeUrl($baseUrl),
- 'handler' => $stack,
- ]);
+ 'base_uri' => Utils::normalizeUrl($baseUrl),
+ 'handler' => $stack,
+ ]);
$this->saveBackup('Network', array('token' => $token, 'baseUrl' => $baseUrl ));
$this->optionsGlobal['Network'] = $options;
}
+ /**
+ * Generate a new token for the Compute service
+ *
+ * @return void
+ */
public function genComputeToken(){
$options = $this->optionsGlobal['Common'];
$options['catalogName'] = 'nova';
@@ -222,25 +319,37 @@ class genTokenOptions
$stack = HandlerStack::create();
- $stack->push(Middleware::authHandler($options['authHandler'], $token));
+ $stack->push(Middleware::authHandler($options['authHandler'], $token));
$this->addDebugMiddleware($options, $stack);
$options['httpClient'] = new Client([
- 'base_uri' => Utils::normalizeUrl($baseUrl),
- 'handler' => $stack,
- ]);
+ 'base_uri' => Utils::normalizeUrl($baseUrl),
+ 'handler' => $stack,
+ ]);
$this->saveBackup('Compute', array('token' => $token, 'baseUrl' => $baseUrl ));
$this->optionsGlobal['Compute'] = $options;
}
+ /**
+ * Revoke the token for the Compute Service
+ *
+ * @return void
+ */
public function revokeComputeToken(){
$token = $this->unserializeToken($this->backup['Compute']['token']);
$this->optionsGlobal['Common']['identityService']->revokeToken($token->id);
}
+ /**
+ * Load a token for the Compute Service
+ *
+ * @param String $opt serialized token
+ *
+ * @return void
+ */
public function loadComputeBackup($opt){
$options = $this->optionsGlobal['Common'];
@@ -251,40 +360,61 @@ class genTokenOptions
$this->backup['Compute'] = $opt;
$token = $this->unserializeToken($this->backup['Compute']['token']);
$baseUrl = $this->backup['Compute']['baseUrl'];
-
+
$stack = HandlerStack::create();
-
+
$stack->push(Middleware::authHandler($options['authHandler'], $token));
$this->addDebugMiddleware($options, $stack);
$options['httpClient'] = new Client([
- 'base_uri' => Utils::normalizeUrl($baseUrl),
- 'handler' => $stack,
- ]);
+ 'base_uri' => Utils::normalizeUrl($baseUrl),
+ 'handler' => $stack,
+ ]);
$this->saveBackup('Compute', array('token' => $token, 'baseUrl' => $baseUrl ));
$this->optionsGlobal['Compute'] = $options;
}
+ /**
+ * Save the token given a service name
+ *
+ * @param String $name name of the service to save
+ * @param Array $data token and baseUrl for the service
+ *
+ * @return void
+ */
private function saveBackup($name, $data){
$token = $this->serializeToken($data["token"]);
- $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']));
+ $ret = file_put_contents("core/LibOverride/projectTokenData/".$token['saved']["project"]["name"], serialize($token['saved']));
+ if($ret === FALSE)
+ die("Internal Server Error : File Rights");
+ $this->backup['time'] = $token['time'];
$this->backup["roles"] = $token["roles"];
$this->backup["project"] = $token['saved']["project"]["name"];
$this->backup["user"] = $token["user"];
$this->backup[$name] = array('token' => $token["token"], 'baseUrl' => $data["baseUrl"] );
}
+ /**
+ * Retrieve the tokens saved
+ *
+ * @return String tokens serialized
+ */
public function getBackup(){
return serialize($this->backup);
}
+ /**
+ * Load tokens into the library
+ *
+ * @param String $back tokens serialized
+ *
+ * @return void
+ */
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"];
@@ -295,18 +425,33 @@ class genTokenOptions
}
+ /**
+ * Retrieve the common options for a service
+ *
+ * @param String $service name of the service
+ *
+ * @return array Options to create the library class corresponding to this service
+ */
public function getOptions($service){
return $this->optionsGlobal[$service];
}
+ /**
+ * Serialize a given token
+ *
+ * @param Array $token token to be serialized
+ *
+ * @return String token serialized
+ */
private function serializeToken($token){
+ global $config;
$tokenSerialized = [];
$tokenSerialized["token"]["methods"] = serialize($token->methods);
$tokenSerialized["roles"] = [];
-
+
foreach($token->roles as $role){
- $tokenSerialized["roles"][serialize($role->id)]["links"] = serialize($role->links);
- $tokenSerialized["roles"][serialize($role->id)]["name"] = serialize($role->name);
+ $tokenSerialized["roles"][$role->id]["links"] = serialize($role->links);
+ $tokenSerialized["roles"][$role->id]["name"] = serialize($role->name);
}
$tokenSerialized["token"]["expires"] = serialize($token->expires);
@@ -318,19 +463,21 @@ class genTokenOptions
$tokenSerialized['saved']["project"]["links"] = serialize($token->project->links);
$tokenSerialized['saved']["project"]["name"] = $token->project->name;
+ $tokenSerialized['saved']["catalog"] = array();
foreach($token->catalog->services as $service){
- $tokenSerialized['saved']["catalog"][serialize($service->id)]["name"] = serialize($service->name);
- $tokenSerialized['saved']["catalog"][serialize($service->id)]["description"] = serialize($service->description);
- $tokenSerialized['saved']["catalog"][serialize($service->id)]["type"] = serialize($service->type);
+ $tokenSerialized['saved']["catalog"][$service->id]["name"] = serialize($service->name);
+ $tokenSerialized['saved']["catalog"][$service->id]["description"] = serialize($service->description);
+ $tokenSerialized['saved']["catalog"][$service->id]["type"] = serialize($service->type);
+
foreach($service->endpoints as $end){
- $tokenSerialized['saved']["catalog"][serialize($service->id)]["endpoints"][serialize($end->id)]["interface"] = serialize($end->interface);
- $tokenSerialized['saved']["catalog"][serialize($service->id)]["endpoints"][serialize($end->id)]["name"] = serialize($end->name);
- $tokenSerialized['saved']["catalog"][serialize($service->id)]["endpoints"][serialize($end->id)]["serviceId"] = serialize($end->serviceId);
- $tokenSerialized['saved']["catalog"][serialize($service->id)]["endpoints"][serialize($end->id)]["region"] = serialize($end->region);
- $tokenSerialized['saved']["catalog"][serialize($service->id)]["endpoints"][serialize($end->id)]["links"] = serialize($end->links);
- $tokenSerialized['saved']["catalog"][serialize($service->id)]["endpoints"][serialize($end->id)]["url"] = serialize($end->url);
+ $tokenSerialized['saved']["catalog"][$service->id]["endpoints"][$end->id]["interface"] = serialize($end->interface);
+ $tokenSerialized['saved']["catalog"][$service->id]["endpoints"][$end->id]["name"] = serialize($end->name);
+ $tokenSerialized['saved']["catalog"][$service->id]["endpoints"][$end->id]["serviceId"] = serialize($end->serviceId);
+ $tokenSerialized['saved']["catalog"][$service->id]["endpoints"][$end->id]["region"] = serialize($end->region);
+ $tokenSerialized['saved']["catalog"][$service->id]["endpoints"][$end->id]["links"] = serialize($end->links);
+ $tokenSerialized['saved']["catalog"][$service->id]["endpoints"][$end->id]["url"] = serialize($end->url);
}
- $tokenSerialized['saved']["catalog"][serialize($service->id)]["links"] = serialize($service->links);
+ $tokenSerialized['saved']["catalog"][$service->id]["links"] = serialize($service->links);
}
$tokenSerialized["token"]["extras"] = serialize($token->extras);
$tokenSerialized["user"]["domainId"] = serialize($token->user->domainId);
@@ -343,22 +490,35 @@ 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;
}
+ /**
+ * Unserialize a token
+ *
+ * Unserialize a token and recreate the architecture of the library token
+ *
+ * @param String $tokenSerialized the token to be unserialized
+ *
+ * @return OpenCloud\Common\Auth\Token the token unserialized
+ */
private function unserializeToken($tokenSerialized){
$Saved = file_get_contents("core/LibOverride/projectTokenData/".$this->backup["project"]);
+ if($Saved === FALSE)
+ die("Internal Server Error : File Access");
$Saved = unserialize($Saved);
+
$api = new Api();
$token = new Models\Token($this->httpClient, $api);
$token->methods = unserialize($tokenSerialized["methods"]);
$token->roles = [];
-
+
foreach($this->backup["roles"] as $key => $role){
$tmp = new Models\Role($this->httpClient, $api);
- $tmp->id = unserialize($key);
+ $tmp->id = $key;
$tmp->links = unserialize($role["links"]);
$tmp->name = unserialize($role["name"]);
@@ -377,17 +537,19 @@ class genTokenOptions
$token->catalog = new Models\Catalog($this->httpClient, $api);
$token->catalog->services = [];
+
foreach($Saved["catalog"] as $key => $service){
$tmp = new Models\Service($this->httpClient, $api);
- $tmp->id = unserialize($key);
+ $tmp->id = $key;
$tmp->name = unserialize($service["name"]);
$tmp->description = unserialize($service["description"]);
$tmp->type = unserialize($service["type"]);
$tmp->endpoints = [];
+
foreach($service["endpoints"] as $key => $end){
$tmpEnd = new Models\Endpoint($this->httpClient, $api);
- $tmpEnd->id = unserialize($key);
+ $tmpEnd->id = $key;
$tmpEnd->interface = unserialize($end["interface"]);
$tmpEnd->name = unserialize($end["name"]);
$tmpEnd->serviceId = unserialize($end["serviceId"]);
@@ -412,7 +574,7 @@ class genTokenOptions
$token->user->description = unserialize($this->backup["user"]["description"]);
$token->issued = unserialize($tokenSerialized["issued"]);
$token->id = unserialize($tokenSerialized["id"]);
-
+
return $token;
}
}
diff --git a/server/core/LibOverride/projectTokenData/demo b/server/core/LibOverride/projectTokenData/demo
index 95d1e10..95d1e10 100644..100755
--- a/server/core/LibOverride/projectTokenData/demo
+++ b/server/core/LibOverride/projectTokenData/demo
diff --git a/server/core/Network.php b/server/core/Network.php
index 8d1c8b6..b244e4e 100644..100755
--- a/server/core/Network.php
+++ b/server/core/Network.php
@@ -1 +1,1279 @@
-
+<?php
+/**
+* File containing the Image Class.
+*
+* @version 1.0 Initialisation of this file
+* @since 1.0 Core application's file
+*
+* @author KABIR Othmane
+*
+*/
+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
+*
+* Management of Networks
+*
+*/
+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 */
+ protected $libClass;
+
+
+ /**
+ * Network constructor
+ *
+ * @param App $app the main app object
+ *
+ * @return network Object
+ */
+ 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
+ */
+ private function create_network()
+ {
+ $options = array();
+ // check the name if it is null
+ $name = $this->app->getPostParam("name");
+ $adminStateUp = $this->app->getPostParam("adminStateUp");
+ $shared = $this->app->getPostParam("shared");
+ $tenantId = $this->app->getPostParam("tenantId");
+
+ if (isset($name))
+ {
+ $options['name'] = $name;
+ }
+ // check the adminStateUp if it is null
+ if (isset($adminStateUp))
+ {
+ $options['adminStateUp'] = $adminStateUp;
+ }
+ // check the shared if it is null
+ if (isset($shared))
+ {
+ $options['shared'] = $shared;
+ }
+ // check the tenantId if it is null
+ if (isset($tenantId))
+ {
+ $options['tenantId'] =$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
+ */
+
+ private function create_subnet()
+ { $options = array();
+ $networkId = $this->app->getPostParam("networkId");
+ $ipVersion = $this->app->getPostParam("ipVersion");
+ $cidr = $this->app->getPostParam("cidr");
+ $tenantId = $this->app->getPostParam("tenantId");
+ $name = $this->app->getPostParam("name");
+ $gatewayIp = $this->app->getPostParam("gatewayIp");
+ $dnsNameservers = $this->app->getPostParam("dnsNameservers");
+ $allocationPools = $this->app->getPostParam("allocationPools");
+ $hostRoutes = $this->app->getPostParam("hostRoutes");
+ $enableDhcp = $this->app->getPostParam("enableDhcp");
+ $tenantId = $this->app->getPostParam("tenantId");
+
+ if (isset($networkId))
+ {
+ $options['networkId'] = $networkId;
+ }
+ if (isset($ipVersion))
+ {
+ $options['ipVersion'] = $ipVersion;
+ }
+ if (isset($cidr))
+ {
+ $options['cidr'] = $cidr;
+ }
+ if (isset($tenantId))
+ {
+ $options['tenantId'] = $tenantId;
+ }
+ if (isset($name))
+ {
+ $options['name'] = $name;
+ }
+ if (isset($gatewayIp))
+ {
+ $options['gatewayIp'] = $gatewayIp;
+ }
+ if (isset($dnsNameservers))
+ {
+ $options['dnsNameservers'] = $dnsNameservers;
+ }
+ if (isset($allocationPools))
+ {
+ $options['allocationPools'] = $allocationPools;
+ }
+ if (isset($hostRoutes))
+ {
+ $options['hostRoutes'] = $hostRoutes;
+ }
+ if (isset($enableDhcp))
+ {
+ $options['enableDhcp'] = $enableDhcp;
+ }
+ if (isset($tenantId))
+ {
+ $options['tenantId'] = $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 void
+ */
+
+ private 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
+ */
+
+ private 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 void
+ */
+ private 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 void
+ */
+ private function getNetwork()
+ {
+ $network="";
+
+ try
+ {
+ $networkId = $this->app->getPostParam("networkId");
+ $newtork = $this->libClass->getNetwork($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 OpenStack\Network
+ */
+ private function getNetworkP($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 void
+ */
+ private function getSubnet()
+ {
+ $sbnet="";
+
+ try
+ {
+ $subnetId = $this->app->getPostParam("subnetId");
+ $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);
+ }
+ $this->app->setOutput("Subnet", subnet);
+
+ }
+ /**
+ * internal function
+ *
+ * @param String subnetId ID of subnet which we want to get
+ *
+ * @return OpenStack\Subnet
+ */
+ private function getSubnetP($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
+ **/
+
+ private function updateNetwork()
+ {
+ $options = array();
+ $name = $this->app->getPostParam("name");
+ $shared = $this->app->getPostParam("shared");
+ $adminStateUp = $this->app->getPostParam("adminStateUp");
+
+ if(isset($name))
+ {
+ $options['name'] = $name;
+ }
+ if(isset($shared))
+ {
+ $options['shared'] = $shared;
+ }
+ if(isset($adminStateUp))
+ {
+ $options['adminStateUp'] = $adminStateUp;
+ }
+ try
+ {
+ $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);
+ }
+ }
+
+ /**
+ * 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
+ **/
+
+ private function updateSubnet()
+ {
+ $options = array();
+ $name = $this->app->getPostParam("name");
+ $networkId = $this->app->getPostParam("networkId");
+ $ipVersion = $this->app->getPostParam("ipVersion");
+ $cidr = $this->app->getPostParam("cidr");
+ if(isset($name))
+ {
+ $options['name'] = $name;
+ }
+ if(isset($networkId))
+ {
+ $options['networkId'] = $networkId;
+ }
+ if(isset($ipVersion))
+ {
+ $options['ipVersion'] = $ipVersion;
+ }
+ if(isset($cidr))
+ {
+ $options['cidr'] = $cidr;
+ }
+ try
+ {
+ $networkId = $this->app->getPostParam("networkId");
+ $subnet = getSubnetP($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
+ **/
+ private function deleteNetwork()
+ {
+ try
+ {
+ $networkId = $this->app->getPostParam("networkId");
+ $network = getNetworkP($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
+ **/
+ private function deleteSubnet()
+ {
+ try
+ {
+ $subnetId = $this->app->getPostParam("subnetId");
+ $subnet = getNetworkP($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
+ */
+
+ private function createPort()
+ {
+ $options = array();
+ $networkId = $this->app->getPostParam("networkId");
+ $name = $this->app->getPostParam("name");
+ $adminStateUp = $this->app->getPostParam("adminStateUp");
+ $macAddress = $this->app->getPostParam("macAddress");
+ $fixedIps = $this->app->getPostParam("fixedIps");
+ $deviceId = $this->app->getPostParam("deviceId");
+ $deviceOwner = $this->app->getPostParam("deviceOwner");
+ $securityGroups = $this->app->getPostParam("securityGroups");
+ $tenantId = $this->app->getPostParam("tenantId");
+
+ if (isset($networkId))
+ {
+ $options['networkId'] = $networkId;
+ }
+ if (isset($name))
+ {
+ $options['name'] = $name;
+ }
+ if (isset($adminStateUp))
+ {
+ $options['adminStateUp'] = $adminStateUp;
+ }
+ if (isset($macAddress))
+ {
+ $options['macAddress'] = $macAddress;
+ }
+ if (isset($fixedIps))
+ {
+ $options['fixedIps'] = $fixedIps;
+ }
+ if (isset($deviceId))
+ {
+ $options['deviceId'] = $deviceId;
+ }
+ if (isset($deviceOwner))
+ {
+ $options['deviceOwner'] = $deviceOwner;
+ }
+ if (isset($securityGroups))
+ {
+ $options['securityGroups'] = $securityGroups;
+ }
+ if (isset($tenantId))
+ {
+ $options['tenantId'] = $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 void
+ */
+
+ private 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 void
+ */
+
+ private function getPort()
+ {
+ try
+ {
+ $portId = $this->app->getPostParam("portId");
+ $port = $this->libClass->getport($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 getPortP($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
+ */
+ private function updatePort()
+ {
+ $options = array();
+ $networkId = $this->app->getPostParam("networkId");
+ $name = $this->app->getPostParam("name");
+ $adminStateUp = $this->app->getPostParam("adminStateUp");
+ $macAddress = $this->app->getPostParam("macAddress");
+ $fixedIps = $this->app->getPostParam("fixedIps");
+ $deviceId = $this->app->getPostParam("deviceId");
+ $deviceOwner = $this->app->getPostParam("deviceOwner");
+ $securityGroups = $this->app->getPostParam("securityGroups");
+ $tenantId = $this->app->getPostParam("tenantId");
+
+ if (isset($networkId))
+ {
+ $options['networkId'] = $networkId;
+ }
+ if (isset($name))
+ {
+ $options['name'] = $name;
+ }
+ if (isset($adminStateUp))
+ {
+ $options['adminStateUp'] = $adminStateUp;
+ }
+ if (isset($macAddress))
+ {
+ $options['macAddress'] = $macAddress;
+ }
+ if (isset($fixedIps))
+ {
+ $options['fixedIps'] = $fixedIps;
+ }
+ if (isset($deviceId))
+ {
+ $options['deviceId'] = $deviceId;
+ }
+ if (isset($deviceOwner))
+ {
+ $options['deviceOwner'] = $deviceOwner;
+ }
+ if (isset($securityGroups))
+ {
+ $options['securityGroups'] = $securityGroups;
+ }
+ if (isset($tenantId))
+ {
+ $options['tenantId'] = $tenantId;
+ }
+ try
+ {
+ $port = getPortP($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
+ */
+ private function deletePort()
+ {
+
+ try
+ {
+ $portId = $this->app->getPostParam("portId");
+ $port = getPortP($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
+ */
+
+ private function createSecurityGroup()
+ {
+ $options = array();
+ $name = $this->app->getPostParam("name");
+ $description = $this->app->getPostParam("description");
+
+ if (isset($name))
+ {
+ $options['name'] = $name;
+ }
+ if (isset($description))
+ {
+ $options['description'] = $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
+ */
+ private function createSecurityGroupRule()
+ {
+ $options = array();
+ $securityGroupId = $this->app->getPostParam("securityGroupId");
+ $direction = $this->app->getPostParam("direction");
+ $ethertype = $this->app->getPostParam("ethertype");
+ $portRangeMin = $this->app->getPostParam("portRangeMin");
+ $portRangeMax = $this->app->getPostParam("portRangeMax");
+ $protocol = $this->app->getPostParam("protocol");
+ $remoteGroupId = $this->app->getPostParam("remoteGroupId");
+ $remoteIpPrefix = $this->app->getPostParam("remoteIpPrefix");
+
+ if (isset($securityGroupId))
+ {
+ $options['securityGroupId'] = $securityGroupId;
+ }
+ if (isset($direction))
+ {
+ $options['direction'] = $direction;
+ }
+ if (isset($ethertype))
+ {
+ $options['ethertype'] = $ethertype;
+ }
+ if (isset($portRangeMin))
+ {
+ $options['portRangeMin'] = $portRangeMin;
+ }
+ if (isset($portRangeMax))
+ {
+ $options['portRangeMax'] = $portRangeMax;
+ }
+ if (isset($protocol))
+ {
+ $options['protocol'] = $protocol;
+ }
+ if (isset($remoteGroupId))
+ {
+ $options['remoteGroupId'] = $remoteGroupId;
+ }
+ if (isset($remoteIpPrefix))
+ {
+ $options['remoteIpPrefix'] = $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 void
+ */
+
+ private 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 void
+ */
+
+ private 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 void
+ */
+
+ private function getSecurityGroupe()
+ {
+ try
+ {
+ $securityGroupId = $this->app->getPostParam("securityGroupeId");
+ $securityGroupe = $this->libClass->getSecurityGroupe($securityGroupId);
+ $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 securityGroup
+ */
+ private function getSecurityGroupeP($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
+ */
+ private function deleteSecurityGroupe()
+ {
+ try
+ {
+ $securityGroupId = $this->app->getPostParam("securityGroupeId");
+ $securityGroupe = getSecurityGroupeP($securityGroupId);
+ $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/NetworkLayer3.php b/server/core/NetworkLayer3.php
new file mode 100755
index 0000000..35bf707
--- /dev/null
+++ b/server/core/NetworkLayer3.php
@@ -0,0 +1,531 @@
+<?php
+/**
+* File containing the networkLayer3 Class.
+*
+* @version 1.0 Initialisation of this file
+* @since 1.0 Core application's file
+*
+* @author Evan Pisani 'yogg at epsina . com'
+*
+*/
+
+use OpenCloud\Common\Error\BadResponseError;
+use OpenCloud\Common\Error\BaseError;
+use OpenCloud\Common\Error\NotImplementedError;
+use OpenCloud\Common\Error\UserInputError;
+
+include("CoreInterface.php");
+
+/**
+* networkLayer3 Class of the back-end application
+*
+* Management of networkLayer3
+*
+*/
+class networkLayer3 implements Core{
+
+ /** @var App $app protected, contains the main app object */
+ protected $app;
+
+ /** @var OpenStack\NetworkLayer3 $libClass protected, contains the library NetworkLayer3 object */
+ protected $libClass;
+
+ /**
+ * networkLayer3 constructor
+ *
+ * @param App $app the main app object
+ *
+ * @return networkLayer3 Object
+ */
+ public function __construct($app){
+ if(!isset($app)){
+ $this->app->setOutput("Error", "Incorrect parameter app");
+ }
+ $this->app = $app;
+ $this->libClass = $app->getLibClass("NetworkLayer3");
+ }
+
+
+ /**
+ * Execute an action
+ *
+ * @param String $action name of another function of this class
+ *
+ * @return void
+ */
+ public function action($action){
+ $this->{$action.""}();
+ }
+
+
+ /**
+ * List floatingip
+ *
+ * @return void
+ */
+ private function listFloatingIp(){
+ try{
+ $result = array();
+ $l = $this->libClass->listFloatingIps();
+ error_log(var_export($l, true), 0);
+ foreach ($l as $tmp) {
+ $result[] = $tmp;
+ }
+
+ $this->app->setOutput("NetworkLayer3", $result);
+ }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);
+ }
+ }
+
+ /**
+ * Create a new floating IP adress
+ *
+ * @param array $opt Options for the floating ip creation (floatingNetworkId is required)
+ *
+ * @return void
+ */
+ private function createFloatingIp(){
+ $opt = $this->app->getPostParam("opt");
+
+ if(!isset($opt)){
+ $this->app->setOutput("Error", "Incorrect parameter opt");
+ }
+ try{
+ $floatingip = $this->libClass->createFloatingIp($opt);
+
+ if(!isset($floatingip)){
+ $this->app->setOutput("Error", "Unknowing error during floating ip creation");
+ }else{
+ $this->app->setOutput("NetworkLayer3", $floatingip);
+ }
+ }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);
+ }
+ }
+
+
+ /**
+ * Show floatingip details
+ *
+ * @param String id the id of the floatingip
+ *
+ * @return void
+ */
+ private function getFloatingIp(){
+ $id = $this->app->getPostParam("id");
+ if(!isset($id)){
+ $this->app->setOutput("Error", "Incorrect parameter opt");
+ }
+
+ try{
+ // List of floating IPs
+ $res = array();
+ $l = $this->libClass->listFloatingIps();
+ foreach ($l as $tmp) {
+ $res[] = $tmp;
+ }
+
+ // Verification if id exists
+ $result = null;
+ foreach ($res as $f) {
+ if(strcmp($f->id, $id)){
+ $result = $f;
+
+ }
+ }
+
+ if(!isset($result)){ // If id doesn't exists
+ $this->app->setOutput("Error", "Unknow id");
+ }else{ // If id exists
+ $res = $this->libClass->getFloatingIp($id);
+ $this->app->setOutput("NetworkLayer3", $res);
+ }
+ }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);
+ }
+ }
+
+ /**
+ * Update floating ip
+ *
+ * @param id the id of the floatingip to update
+ *
+ * @return void
+ */
+ private function updateFloatingIp(){
+ $id = $this->app->getPostParam("id");
+
+ if(!isset($id)){
+ $this->app->setOutput("Error", "Incorrect parameter opt");
+ }
+ try{
+
+ // List of floating IPs
+ $res = array();
+ $l = $this->libClass->listFloatingIps();
+ foreach ($l as $tmp) {
+ $res[] = $tmp;
+ }
+
+ // Verification if id exists
+ $result = null;
+ foreach ($res as $f) {
+ if(strcmp($f->id, $id)){
+ $result = $f;
+
+ }
+ }
+
+ if(!isset($result)){ // If id doesn't exists
+ $this->app->setOutput("Error", "Unknowing floatingip id");
+ }else{
+ $result->update();
+ }
+ }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);
+ }
+ }
+
+ /**
+ * Delete a floating ip
+ *
+ * @param string floatingip_id the floating-ip id to delete
+ *
+ * @return void
+ */
+ private function deleteFloatingIp(){
+ $id = $this->app->getPostParam("id");
+
+ if(!isset($id)){
+ $this->app->setOutput("Error", "Incorrect parameter opt");
+ }
+ try{
+ // List of floating IPs
+ $res = array();
+ $l = $this->libClass->listFloatingIps();
+ foreach ($l as $tmp) {
+ $res[] = $tmp;
+ }
+
+ // Verification if id exists
+ $result = null;
+ foreach ($res as $f) {
+ if(strcmp($f->id, $id)){
+ $result = $f;
+
+ }
+ }
+
+ if(!isset($result)){ // If id doesn't exists
+ $this->app->setOutput("Error", "Unknowing floatingip id");
+ }else{
+ $result->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);
+ }catch(Exception $e){
+ $this->app->getErrorInstance()->OtherException($e);
+ }
+ }
+
+
+ /**
+ * Retrieve a floating ip
+ *
+ * @param string floatingip_id the floating-ip id to retrieve
+ *
+ * @return void
+ */
+ private function retrieveFloatingIp(){
+ $id = $this->app->getPostParam("id");
+
+ if(!isset($id)){
+ $this->app->setOutput("Error", "Incorrect parameter opt");
+ }
+ try{
+ // List of floating IPs
+ $res = array();
+ $l = $this->libClass->listFloatingIps();
+ foreach ($l as $tmp) {
+ $res[] = $tmp;
+ }
+
+ // Verification if id exists
+ $result = null;
+ foreach ($res as $f) {
+ if(strcmp($f->id, $id)){
+ $result = $f;
+
+ }
+ }
+
+ if(!isset($result)){ // If id doesn't exists
+ $this->app->setOutput("Error", "Unknowing floatingip id");
+ }else{
+ $result->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);
+ }catch(Exception $e){
+ $this->app->getErrorInstance()->OtherException($e);
+ }
+ }
+
+
+
+ /**
+ * Create a new router
+ *
+ * @param array $opt Options for the new router
+ * externalGatewayInfo[] required (only the param networkId in the tab)
+ * adminStateUp (optionnal)
+ * name (optionnal)
+ *
+ * @return void
+ */
+ private function createRouter(){
+ $opt = $this->app->getPostParam("opt");
+
+ if(!isset($opt)){
+ $this->app->setOutput("Error", "Incorrect parameter opt");
+ }
+ try{
+ $router = $this->libClass->createRouter($opt);
+
+ if(!isset($router)){
+ $this->app->setOutput("Error", "Unknowing error during floating ip creation");
+ }else{
+ $this->app->setOutput("NetworkLayer3", $router);
+ }
+ }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);
+ }
+ }
+
+
+ /**
+ * List routers
+ *
+ * @return void
+ */
+ private function listRouters(){
+ try{
+ $result = array();
+ $l = $this->libClass->listRouters();
+ foreach ($l as $tmp) {
+ $result[] = $tmp;
+ }
+
+ $this->app->setOutput("NetworkLayer3", $result);
+ }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);
+ }
+ }
+
+
+ /**
+ * Show router details
+ *
+ * @param String id the id of the router
+ *
+ * @return void
+ */
+ private function getRouter(){
+ $id = $this->app->getPostParam("id");
+ if(!isset($id)){
+ $this->app->setOutput("Error", "Incorrect parameter opt");
+ }
+ try{
+ // List of routers
+ $res = array();
+ $l = $this->libClass->listRouters();
+ foreach ($l as $tmp) {
+ $res[] = $tmp;
+ }
+
+ // Verification if id exists
+ $result = null;
+ foreach ($res as $f) {
+ if(strcmp($f->id, $id)){
+ $result = $f;
+ }
+ }
+
+ if(!isset($result)){ // If id doesn't exists
+ $this->app->setOutput("Error", "Unknow id");
+ }else{ // If id exists
+ $res = $this->libClass->getRouter($id);
+ $this->app->setOutput("NetworkLayer3", $res);
+ }
+ }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);
+ }
+ }
+
+
+ /**
+ * Delete a router
+ *
+ * @param string router the router to delete
+ *
+ * @return void
+ */
+ private function deleteRouter(){
+ $id = $this->app->getPostParam("id");
+
+ if(!isset($id)){
+ $this->app->setOutput("Error", "Incorrect parameter opt");
+ }
+ try{
+ // List of routers
+ $res = array();
+ $l = $this->libClass->listRouters();
+ foreach ($l as $tmp) {
+ $res[] = $tmp;
+ }
+
+ // Verification if id exists
+ $result = null;
+ foreach ($res as $f) {
+ if(strcmp($f->id, $id)){
+ $result = $f;
+ }
+ }
+
+ if(!isset($result)){ // If id doesn't exists
+ $this->app->setOutput("Error", "Unknowing router id");
+ }else{
+ $result->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);
+ }catch(Exception $e){
+ $this->app->getErrorInstance()->OtherException($e);
+ }
+ }
+
+
+ /**
+ * Update router
+ *
+ * @param id the id of the floatingip to update
+ *
+ * @return void
+ */
+ private function updateRouter(){
+ $id = $this->app->getPostParam("id");
+
+ if(!isset($id)){
+ $this->app->setOutput("Error", "Incorrect parameter opt");
+ }
+ try{
+
+ // List of floating IPs
+ $res = array();
+ $l = $this->libClass->listRouters();
+ foreach ($l as $tmp) {
+ $res[] = $tmp;
+ }
+
+ // Verification if id exists
+ $result = null;
+ foreach ($res as $f) {
+ if(strcmp($f->id, $id)){
+ $result = $f;
+
+ }
+ }
+
+ if(!isset($result)){ // If id doesn't exists
+ $this->app->setOutput("Error", "Unknowing floatingip id");
+ }else{
+ $result->update();
+ }
+ }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);
+ }
+ }
+}
diff --git a/server/core/Plugin.php b/server/core/Plugin.php
deleted file mode 100644
index e6fd8a7..0000000
--- a/server/core/Plugin.php
+++ /dev/null
@@ -1,13 +0,0 @@
-<?php
-
-abstract class plugin{
-
- public $api;
-
- public function __construct($api){
-
- $this->api = $api;
-
- }
-
-}
diff --git a/server/core/Plugin_Api.php b/server/core/Plugin_Api.php
deleted file mode 100644
index 20ffd0c..0000000
--- a/server/core/Plugin_Api.php
+++ /dev/null
@@ -1,24 +0,0 @@
-<?php
-
-//Init plugin directory
-/*if (!defined('PLUGINS_DIR')) {
- define('PLUGINS_DIR', INSTALL_PATH . 'plugins/');
-}*/
-
-class plugin_api{
-
- static protected $instance;
-
- protected function __construct(){
-
- }
-
- static function getInstance(){
-
- if(!self::$instance){
- self::$instance = new plugin_api();
- }
-
- return self::$instance;
- }
-}
diff --git a/server/core/Readme.txt b/server/core/Readme.txt
index 8d1c8b6..8d1c8b6 100644..100755
--- a/server/core/Readme.txt
+++ b/server/core/Readme.txt