summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rwxr-xr-xserver/config.inc.php22
-rwxr-xr-xserver/core/App.php166
-rwxr-xr-xserver/core/Automating.php26
-rwxr-xr-xserver/core/Compute.php576
-rwxr-xr-xserver/core/CoreInterface.php19
-rwxr-xr-xserver/core/ErrorManagement.php76
-rwxr-xr-xserver/core/Identity.php1286
-rwxr-xr-xserver/core/Image.php236
-rwxr-xr-xserver/core/LibOverride/genTokenOptions.php268
-rwxr-xr-xserver/core/Network.php368
-rwxr-xr-xserver/core/NetworkLayer3.php174
-rwxr-xr-xserver/index.php138
-rwxr-xr-xserver/init.php92
13 files changed, 1737 insertions, 1710 deletions
diff --git a/server/config.inc.php b/server/config.inc.php
index aa10504..71f0bb4 100755
--- a/server/config.inc.php
+++ b/server/config.inc.php
@@ -1,11 +1,21 @@
<?php
- date_default_timezone_set('Europe/Paris');
+/**
+* File containing global config options for the API.
+*
+* @version 1.0 Initialisation of this file
+* @since 1.0 Core application's file
+*
+* @author Eole 'eoledev at outlook . fr'
+*
+*/
- $config = Array();
-
- $config["modules_enabled"] = "";
- $config["urlAuth"] = "http://148.60.11.31:5000/v3";
- $config["tokenTime"] = 60 //minute = 60
+date_default_timezone_set('Europe/Paris');
+
+$config = Array();
+
+$config["modules_enabled"] = "";
+$config["urlAuth"] = "http://148.60.11.31:5000/v3";
+$config["tokenTime"] = 60; //minutes
?>
diff --git a/server/core/App.php b/server/core/App.php
index 114d945..fb49b95 100755
--- a/server/core/App.php
+++ b/server/core/App.php
@@ -1,21 +1,55 @@
<?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;
+ /** @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;
@@ -27,6 +61,13 @@ class App{
}
+ /**
+ * 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;
@@ -34,42 +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 "NetworkLayer3":
- if($this->tokenPost == NULL) $this->tokenClass->genNetworkToken();
- $opt = $this->tokenClass->getOptions('Network');
- return $this->openstack->networkingV2ExtLayer3($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{
@@ -81,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{
@@ -103,16 +166,23 @@ 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])){
@@ -123,28 +193,52 @@ class App{
}
-
+ /**
+ * 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){
$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
index fb42702..27dd018 100755
--- a/server/core/Automating.php
+++ b/server/core/Automating.php
@@ -5,31 +5,41 @@
* @version 1.0 Initialisation of this file
* @since 1.0 Core application's file
*
-* @author Evan Pisani 'yogg at epsina . com' et bhupi
+* @author Evan Pisani 'yogg at epsina . com', bhupi
*
-* @todo Complete the functions with errors detection and finish the descriptions
*/
include("Image.php");
include("Network.php");
include("Compute.php");
include("NetworkLayer3.php");
+include("CoreInterface.php");
-class automating{
+/**
+* automating Class of the back-end application
+*
+* Contains the different function to automate some action
+*
+*/
+class automating implements Core{
- /** @var App $app protected, contains the main app object */
+ /** @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;
/**
- * Our library's app constructor for all server app objects
+ * automating class constructor
*
- * @param App $app the main app object, e.g. compute, image, network, etc.
+ * @param App $app the main app object
*
- * @return
+ * @return automating Object
*/
public function __construct($app){
$this->app = $app;
@@ -47,7 +57,7 @@ class automating{
* @return void
*/
public function action($action){
- $this->{$action.""}();
+ $this->{$action.""}();
}
/**
diff --git a/server/core/Compute.php b/server/core/Compute.php
index 4a7fe6c..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,149 +49,154 @@ class compute
*/
public function action($action){
- $this->{$action.""}();
+ $this->{$action.""}();
}
- /**
- * List servers.
- * @return array
- */
- public function listServers()
- {
+
+ /**
+ * 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;
+ $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);
}
catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }
+ }
catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }
+ }
catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }
+ }
catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
- }
+ }
catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
- }
- return;
- }
- /**
- * List flavors.
- * @return array
- */
- public function listFlavors()
- {
+ }
+ }
+
+ /**
+ * List flavors.
+ *
+ * @return void
+ */
+ 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);
+ $flavors[$flavor->id] = Array();
+ $flavor->retrieve();
+ $flavors[$flavor->id]["id"] = $flavor->id;
+ $flavors[$flavor->id]["name"] = $flavor->name;
+ $flavors[$flavor->id]["ram"] = $flavor->ram;
+ $flavors[$flavor->id]["disk"] = $flavor->disk;
+ $flavors[$flavor->id]["vcpus"] = $flavor->vcpus;
+ $flavors[$flavor->id]["links"] = $flavor->links;
+ }
+ $this->app->setOutput("Flavors", $flavors);
}
catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }
+ }
catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }
+ }
catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }
+ }
catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
- }
+ }
catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
- }
- return;
- }
- /**
- * List images.
- * @return array
- */
- public function listImages()
- {
- try{
+ }
+ }
+
+ /**
+ * 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);
+ $images[$image->id] = Array();
+ $image->retrieve();
+ $images[$image->id]["id"] = $image->id;
+ $images[$image->id]["name"] = $image->name;
+ $images[$image->id]["status"] = $image->status;
+ $images[$image->id]["created"] = $image->created;
+ $images[$image->id]["updated"] = $image->updated;
+ $images[$image->id]["minDisk"] = $image->minDisk;
+ $images[$image->id]["minRam"] = $image->minRam;
+ $images[$image->id]["progress"] = $image->progress;
+ $images[$image->id]["links"] = $image->links;
+ $images[$image->id]["metadata"] = $image->metadata;
+ }
+ $this->app->setOutput("Images", $images);
}
catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }
+ }
catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }
+ }
catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }
+ }
catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
- }
+ }
catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
- }
- return;
- }
- /**
- * Get server details.
- * @return array
- */
- public function getServer()
- {
- try{
+ }
+ }
+
+ /**
+ * 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!");
@@ -180,27 +209,28 @@ class compute
}
catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }
+ }
catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }
+ }
catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }
+ }
catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
- }
+ }
catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
- }
- return;
- }
- /**
- * Get flavor details.
- * @return array
- */
- public function getFlavor()
- {
+ }
+ }
+
+ /**
+ * Get flavor details.
+ *
+ * @return void
+ */
+ public function getFlavor()
+ {
try{
$flavorId = $this->app->getPostParam("flavorId");
if(!isset($serverId)){
@@ -214,27 +244,27 @@ class compute
}
catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }
+ }
catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }
+ }
catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }
+ }
catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
- }
+ }
catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
- }
- return;
- }
- /**
- * Get image details.
- * @return array
- */
- public function getImage()
- {
+ }
+ }
+
+ /**
+ * Get image details.
+ * @return array
+ */
+ public function getImage()
+ {
try{
$imageId = $this->app->getPostParam("imageId");
if(!isset($serverId)){
@@ -248,27 +278,28 @@ class compute
}
catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }
+ }
catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }
+ }
catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }
+ }
catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
- }
+ }
catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
- }
- return;
- }
- /**
- * Create server.
- * @return array
- */
- public function createServer()
- {
+ }
+ }
+
+ /**
+ * Create server.
+ *
+ * @return void
+ */
+ public function createServer()
+ {
try{
$name = $this->app->getPostParam("name");
$imageId = $this->app->getPostParam("imageId");
@@ -282,28 +313,28 @@ class compute
}
catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }
+ }
catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }
+ }
catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }
+ }
catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
- }
+ }
catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
- }
- return;
- }
-
+ }
+ }
+
/**
* update a server
+ *
* @return void
*/
- public function updateServer()
- {
+ public function updateServer()
+ {
try{
$serverId = $this->app->getPostParam("serverId");
$newName = $this->app->getPostParam("newName");
@@ -329,27 +360,28 @@ class compute
}
catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }
+ }
catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }
+ }
catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }
+ }
catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
- }
+ }
catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
- }
- return;
- }
+ }
+ }
+
/**
* Delete a server
+ *
* @return void
*/
- public function deleteServer()
- {
+ public function deleteServer()
+ {
try{
$serverId = $this->app->getPostParam("serverId");
if(!isset($serverId)){
@@ -363,27 +395,28 @@ class compute
}
catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }
+ }
catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }
+ }
catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }
+ }
catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
- }
+ }
catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
- }
- return;
- }
+ }
+ }
+
/**
* Change the password of a server
+ *
* @return void
*/
- public function changePassword()
- {
+ public function changePassword()
+ {
try{
$serverId = $this->app->getPostParam("serverId");
$password = $this->app->getPostParam("newPassword");
@@ -398,27 +431,28 @@ class compute
}
catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }
+ }
catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }
+ }
catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }
+ }
catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
- }
+ }
catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
- }
- return;
- }
- /**
+ }
+ }
+
+ /**
* Reboot a server
+ *
* @return void
*/
- public function reboot()
- {
+ public function reboot()
+ {
try{
$serverId = $this->app->getPostParam("serverId");
if(!isset($serverId)){
@@ -432,74 +466,77 @@ class compute
}
catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }
+ }
catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }
+ }
catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }
+ }
catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
- }
+ }
catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
- }
- return;
- }
- /**
+ }
+ }
+
+ /**
* 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;
+ 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.");
}
- catch(BadResponseError $e){
- $this->app->getErrorInstance()->BadResponseHandler($e);
- }
- catch(UserInputError $e){
- $this->app->getErrorInstance()->UserInputHandler($e);
- }
- catch(BaseError $e){
- $this->app->getErrorInstance()->BaseErrorHandler($e);
- }
- catch(NotImplementedError $e){
- $this->app->getErrorInstance()->NotImplementedHandler($e);
- }
- catch(Exception $e){
- $this->app->getErrorInstance()->OtherException($e);
- }
- return;
- }
- }
- /**
+ }
+
+ /**
* Resize a server
+ *
* A call to this method has to be followed by either confirmResize or revertResize
+ *
* @return void
*/
- public function resize()
- {
+ public function resize()
+ {
try{
$serverId = $this->app->getPostParam("serverId");
$newFlavorId = $this->app->getPostParam("newFlavorId");
@@ -513,27 +550,28 @@ class compute
}
catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }
+ }
catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }
+ }
catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }
+ }
catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
- }
+ }
catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
- }
- return;
- }
- /**
+ }
+ }
+
+ /**
* Confirm resize operation on a server
+ *
* @return void
*/
- public function confirmResize()
- {
+ public function confirmResize()
+ {
try{
$serverId = $this->app->getPostParam("serverId");
if(!isset($serverId)){
@@ -547,27 +585,28 @@ class compute
}
catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }
+ }
catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }
+ }
catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }
+ }
catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
- }
+ }
catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
- }
- return;
- }
- /**
+ }
+ }
+
+ /**
* Revert resize operation on a server
+ *
* @return void
*/
- public function revertResize()
- {
+ public function revertResize()
+ {
try{
$serverId = $this->app->getPostParam("serverId");
if(!isset($serverId)){
@@ -581,28 +620,28 @@ class compute
}
catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }
+ }
catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }
+ }
catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }
+ }
catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
- }
+ }
catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
- }
- return;
- }
+ }
+ }
+
/**
* List private and public addresses of a server
+ *
* @return void
*/
-
- public function listAddresses(array $options = [])
- {
+ public function listAddresses()
+ {
try{
$serverId = $this->app->getPostParam("serverId");
if(!isset($serverId)){
@@ -616,20 +655,19 @@ class compute
}
catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }
+ }
catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }
+ }
catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }
+ }
catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
- }
+ }
catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
- }
- return;
- }
+ }
+ }
}
-
+
diff --git a/server/core/CoreInterface.php b/server/core/CoreInterface.php
index ed0d959..8bcfad4 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 be7080b..130c488 100755
--- a/server/core/ErrorManagement.php
+++ b/server/core/ErrorManagement.php
@@ -1,6 +1,6 @@
<?php
/**
-* File containing the Errormanagement Class.
+* File containing the errorManagement Class.
*
* @version 1.0 Initialisation of this file
* @since 1.0 Core application's file
@@ -14,17 +14,23 @@ 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 $app the main app object
+ * @param App $args the main app object
*
- * @return ErrorManagement
+ * @return ErrorManagement Object
*/
public function __construct($args){
@@ -35,9 +41,9 @@ Class errorManagement{
/**
* Put an error message corresponding to a base error in the output
*
- * @param $error the error triggered
+ * @param Exception $error the exception triggered
*
- * @return String BaseError message
+ * @return void
*/
public function BaseErrorHandler($error){
$this->app->setOutput("Error", "BaseError");
@@ -46,49 +52,49 @@ Class errorManagement{
/**
* Put an error message corresponding to a bad response in function of the status code in the output
*
- * @param $error the error triggered
+ * @param Exception $error the exception triggered
*
- * @return String Error message
+ * @return void
*/
public function BadResponseHandler($error){
$statusCode = $error->getResponse()->getStatusCode();
switch ($statusCode) {
- case 400:
- $this->app->setOutput("Error", "Invalid input.");
- break;
+ case 400:
+ $this->app->setOutput("Error", "Invalid input.");
+ break;
- case 401:
- $this->app->setOutput("Error", "Authentification failed.");
- break;
+ case 401:
+ $this->app->setOutput("Error", "Authentification failed.");
+ break;
- case 403:
- $this->app->setOutput("Error", "Operation forbidden.");
- break;
+ case 403:
+ $this->app->setOutput("Error", "Operation forbidden.");
+ break;
- case 404:
- $this->app->setOutput("Error", "Ressource not found.");
- 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 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;
+ case 503:
+ $this->app->setOutput("Error", "Service unvailable for the moment.");
+ break;
- default:
- $this->app->setOutput("Error", "Unknow error, please contact an administrator.");
- break;
+ default:
+ $this->app->setOutput("Error", "Unknow error, please contact an administrator.");
+ break;
}
}
/**
* Put an error message corresponding to a not implemented yet error in the output
*
- * @param $error the error triggered
+ * @param Exception $error the exception triggered
*
- * @return String internal error message
+ * @return void
*/
public function NotImplementedHandler($error){
$this->app->setOutput("Error", "Internal error (not implemented yet), please contact an administrator");
@@ -97,9 +103,9 @@ Class errorManagement{
/**
* Put an error message corresponding to a user input error in the output
*
- * @param $error the error triggered
+ * @param Exception $error the exception triggered
*
- * @return String User input error message
+ * @return void
*/
public function UserInputHandler($error){
$this->app->setOutput("Error", "UserInputError");
@@ -108,9 +114,9 @@ Class errorManagement{
/**
* Put an error message corresponding to an other error in the output
*
- * @param $error the error triggered
+ * @param Exception $error the exception triggered
*
- * @return String error message
+ * @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 464522a..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.""}();
}
/**
@@ -88,15 +89,15 @@ class identity implements Core{
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
@@ -114,15 +115,15 @@ class identity implements Core{
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
@@ -149,15 +150,15 @@ class identity implements Core{
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
@@ -194,15 +195,15 @@ class identity implements Core{
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
@@ -229,16 +230,16 @@ class identity implements Core{
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
+
}-
/**
@@ -262,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{
@@ -278,15 +279,15 @@ class identity implements Core{
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
@@ -305,15 +306,15 @@ class identity implements Core{
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
@@ -341,15 +342,15 @@ class identity implements Core{
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
@@ -374,17 +375,17 @@ 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();
@@ -392,15 +393,15 @@ class identity implements Core{
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
@@ -427,22 +428,20 @@ class identity implements Core{
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
* Retrieve the different roles of a given user in a domain.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function listRolesDomainUser(){
@@ -464,22 +463,20 @@ class identity implements Core{
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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 a given user in a domain.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function grantRoleDomainUser(){
@@ -496,30 +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){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
* Verify that a user has a given role in a domain.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function checkRoleDomainUser(){
@@ -545,22 +540,20 @@ class identity implements Core{
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
* Delete a role for a given user in a domain.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function revokeRoleDomainUser(){
@@ -577,30 +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){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
* Retrieve the roles of a given group in a domain.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function listRolesDomainGroup(){
@@ -622,22 +613,20 @@ class identity implements Core{
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
* Add a role to a given group in a domain.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function grantRoleDomainGroup(){
@@ -654,30 +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){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
* Verify that a role is associated with a given group in a domain.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function checkRoleDomainGroup(){
@@ -703,28 +690,20 @@ class identity implements Core{
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
* 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(){
@@ -741,8 +720,8 @@ class identity implements Core{
$domain = $this->libClass->getDomain($roleId);
$domain->revokeGroupRole([
- 'groupId' => $groupId,
- 'roleId' => $roleId,
+ 'groupId' => $groupId,
+ 'roleId' => $roleId,
]);
@@ -750,22 +729,20 @@ class identity implements Core{
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
* Add an endpoint to the Openstack instance
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function addEndpoint(){
@@ -781,33 +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){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
* Retrieve the endpoint for the given id
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function getEndpoint(){
@@ -826,15 +801,15 @@ class identity implements Core{
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
@@ -843,7 +818,7 @@ class identity implements Core{
* @return void
*/
private function listEndpoints(){
-
+
try{
$res = $this->libClass->listEndpoints();
@@ -852,63 +827,29 @@ class identity implements Core{
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
* 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);
- }catch(Exception $e){
- $this->app->getErrorInstance()->OtherException($e);
- }*/
}
/**
* Delete a given endpoint
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function deleteEndpoint(){
@@ -927,128 +868,47 @@ class identity implements Core{
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
* 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);
- }catch(Exception $e){
- $this->app->getErrorInstance()->OtherException($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);
- }catch(Exception $e){
- $this->app->getErrorInstance()->OtherException($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);
- }catch(Exception $e){
- $this->app->getErrorInstance()->OtherException($e);
- }*/
}
/**
* Update a given group.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function updateGroup(){
@@ -1066,9 +926,9 @@ 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();
@@ -1076,22 +936,20 @@ class identity implements Core{
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
* Delete the given group.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function deleteGroup(){
@@ -1112,22 +970,20 @@ class identity implements Core{
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
* Retrieve the users of a given group.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function listGroupUsers(){
@@ -1148,22 +1004,20 @@ class identity implements Core{
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
* Add a user to a group.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function addGroupUser(){
@@ -1185,22 +1039,20 @@ class identity implements Core{
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
* Remove a user from a given group.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function removeGroupUser(){
@@ -1222,22 +1074,20 @@ class identity implements Core{
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
* Check if a group contains a given user.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function checkGroupUser(){
@@ -1259,198 +1109,66 @@ class identity implements Core{
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
* @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);
- }catch(Exception $e){
- $this->app->getErrorInstance()->OtherException($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);
- }catch(Exception $e){
- $this->app->getErrorInstance()->OtherException($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);
- }catch(Exception $e){
- $this->app->getErrorInstance()->OtherException($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);
- }catch(Exception $e){
- $this->app->getErrorInstance()->OtherException($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);
- }catch(Exception $e){
- $this->app->getErrorInstance()->OtherException($e);
- }*/
}
/**
* Add a project.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function addProject(){
@@ -1465,24 +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){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
@@ -1500,22 +1218,20 @@ class identity implements Core{
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
* Retrieve the details of a given project.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function showProject(){
@@ -1535,22 +1251,20 @@ class identity implements Core{
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
* Update a given project.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function updateProject(){
@@ -1577,22 +1291,20 @@ class identity implements Core{
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
* Delete a given project.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function deleteProject(){
@@ -1612,22 +1324,20 @@ class identity implements Core{
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
* List the roles of a given user in a project.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function listRolesProjectUser(){
@@ -1649,24 +1359,22 @@ class identity implements Core{
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
- }
+ }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(){
@@ -1684,30 +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){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
* Check if a given user has a role in a project.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function checkRoleProjectUser(){
@@ -1724,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) {
@@ -1735,22 +1441,20 @@ class identity implements Core{
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
* Delete a role for a given user in a project.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function revokeRoleProjectUser(){
@@ -1768,30 +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){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
* List the roles of a group in a project.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function listRolesProjectGroup(){
@@ -1803,7 +1505,7 @@ class identity implements Core{
if(!isset($projId) || !isset($groupId)){
}
-
+
try{
$project = $this->libClass->getProject($projId);
@@ -1814,22 +1516,20 @@ class identity implements Core{
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
* Add a role to a group in a project.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function grantRoleProjectGroup(){
@@ -1841,36 +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){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
* Check if a group has a given role in a project.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function checkRoleProjectGroup(){
@@ -1888,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) {
@@ -1898,22 +1596,20 @@ class identity implements Core{
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
* Delete a role for a group in a project.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function revokeRoleProjectGroup(){
@@ -1931,30 +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){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
* Add a role.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function addRole(){
@@ -1968,22 +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){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
@@ -2001,19 +1695,19 @@ class identity implements Core{
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
- * @todo
+ * List the different assignments for a given role
*
* @return void
*/
@@ -2027,22 +1721,20 @@ class identity implements Core{
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
* Add a service.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function addService(){
@@ -2056,23 +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){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
@@ -2090,22 +1782,20 @@ class identity implements Core{
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
* Retrieve the details for a given service.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function showService(){
@@ -2123,22 +1813,20 @@ class identity implements Core{
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
* Delete a given service.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function deleteService(){
@@ -2159,22 +1847,20 @@ class identity implements Core{
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
* Generate a new token for a given user id.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function genTokenUserID(){
@@ -2189,32 +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){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
* Generate a new token for a given user name.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function genTokenUserName(){
@@ -2230,35 +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){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
* Generate a new token from another token ID.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function genTokenID(){
@@ -2273,30 +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){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
* Generate a new token scoped by a project ID.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function genTokenScopedProjectID(){
@@ -2312,35 +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){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
* Generate a new token scoped by a project name.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function genTokenScopedProjectName(){
@@ -2357,40 +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){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
* Check if a token is validate.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function validateToken(){
@@ -2413,22 +2089,20 @@ class identity implements Core{
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
* Delete a given token.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function revokeToken(){
@@ -2447,22 +2121,20 @@ class identity implements Core{
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
* Add a new user.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function addUser(){
@@ -2475,34 +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){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
@@ -2520,22 +2192,20 @@ class identity implements Core{
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
* Retrieve the details of a given user.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function showUser(){
@@ -2555,22 +2225,20 @@ class identity implements Core{
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
* Update a given user.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function updateUser(){
@@ -2596,22 +2264,20 @@ class identity implements Core{
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
* Delete a given user.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function deleteUser(){
@@ -2631,22 +2297,20 @@ class identity implements Core{
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
* Retrieve the groups which contains a given user.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function listUserGroups(){
@@ -2667,22 +2331,20 @@ class identity implements Core{
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
* Retrieve the projects which contains a given user.
*
- * @throws [Type] [<description>]
- *
* @return void
*/
private function listUserProjects(){
@@ -2703,14 +2365,14 @@ class identity implements Core{
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
}
diff --git a/server/core/Image.php b/server/core/Image.php
index 334fce4..b256d4c 100755
--- a/server/core/Image.php
+++ b/server/core/Image.php
@@ -7,8 +7,8 @@
*
* @author Evan Pisani 'yogg at epsina . com'
*
-* @todo Complete the functions with errors detection and finish the descriptions
*/
+
use OpenCloud\Common\Error\BadResponseError;
use OpenCloud\Common\Error\BaseError;
use OpenCloud\Common\Error\NotImplementedError;
@@ -27,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;
/**
@@ -35,7 +35,7 @@ class image implements Core{
*
* @param App $app the main app object
*
- * @return Image
+ * @return image Object
*/
public function __construct($app){
if(!isset($app)){
@@ -54,7 +54,7 @@ class image implements Core{
* @return void
*/
public function action($action){
- $this->{$action.""}();
+ $this->{$action.""}();
}
/**
@@ -62,7 +62,7 @@ class image implements Core{
*
* @param array $opt Options for the image creation (name is required, others are optionals)
*
- * @return Image
+ * @return void
*/
private function createImage(){
$opt = $this->app->getPostParam("opt");
@@ -78,13 +78,13 @@ class image implements Core{
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'];
+ 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", "Missing parameter 'name' for the new image");
@@ -125,15 +125,15 @@ class image implements Core{
$image = $this->libClass->createImage($options);
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
$this->app->setOutput("Images", $image);
}
@@ -141,7 +141,7 @@ class image implements Core{
/**
* List the images of the server
*
- * @return List of Image
+ * @return void
*/
private function listImage(){
try{
@@ -152,15 +152,15 @@ class image implements Core{
}
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
$this->app->setOutput("Images", $result);
@@ -171,7 +171,7 @@ class image implements Core{
*
* @param String $id Identifier of the image
*
- * @return Image
+ * @return void
*/
private function detailsImage(){
$id = $this->app->getPostParam("id");
@@ -191,16 +191,16 @@ class image implements Core{
}
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
+ }
}
/**
@@ -209,7 +209,7 @@ class image implements Core{
* @param String $id id of the image
* @param array $opt Options for the image creation
*
- * @return Image
+ * @return void
*/
private function updateImage(){
@@ -254,15 +254,15 @@ class image implements Core{
$image->update($options);
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
$this->app->setOutput("Images", $image);
}
}
@@ -289,20 +289,20 @@ class image implements Core{
$image->delete();
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
+ }
}
/**
- * Resactive an image
+ * Reactive an image
*
* @param String $id Identifier of the image
*
@@ -326,20 +326,20 @@ class image implements Core{
$image->reactivate();
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
+ }
}
/**
- * Desactive an image
+ * Desactivaate an image
*
* @param String $id Identifier of the image
*
@@ -362,16 +362,16 @@ class image implements Core{
$image->deactivate();
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
+ }
}
/**
@@ -385,9 +385,9 @@ class image implements Core{
private function uploadImage(){
$id = $this->app->getPostParam("id");
$file_name = $this->app->getPostParam("file_name");
- $file = $this->app->getPostParam("file");
+ $file = $this->app->getPostParam("file");
error_log(print_r($file, true), 0);
-
+
if(!isset($id)){
$this->app->setOutput("Error", "Incorrect id parameter");
}
@@ -405,16 +405,16 @@ class image implements Core{
$image->uploadData($stream);
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
+ }
}
/**
@@ -422,7 +422,7 @@ class image implements Core{
*
* @param String $id Identifier of the image
*
- * @return Stream
+ * @return void
*/
private function downloadImage(){
$id = $this->app->getPostParam("id");
@@ -440,17 +440,17 @@ class image implements Core{
$stream = $image->downloadData();
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $e){
+ }catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
- }catch(Exception $e){
- $this->app->getErrorInstance()->OtherException($e);
- }
- $this->app->setOutput("Images", $stream);
- }
+ }catch(Exception $e){
+ $this->app->getErrorInstance()->OtherException($e);
+ }
+ $this->app->setOutput("Images", $stream);
+ }
}
/**
@@ -459,7 +459,7 @@ class image implements Core{
* @param String $image_id Identifier of the image
* @param String $member_id Identifier of the member
*
- * @return Member
+ * @return void
*/
private function addMemberImage(){
$image_id = $this->app->getPostParam("image_id");
@@ -483,16 +483,16 @@ class image implements Core{
$this->app->setOutput("Images", $member_id);
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
+ }
}
@@ -501,7 +501,7 @@ class image implements Core{
*
* @param String $image_id identifier of the image
*
- * @return List of Member
+ * @return void
*/
private function listMemberImage(){
$image_id = $this->app->getPostParam("image_id");
@@ -526,15 +526,15 @@ class image implements Core{
}
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
$this->app->setOutput("Images", $members);
}
}
@@ -545,7 +545,7 @@ class image implements Core{
* @param String $image_id Identifier of the image
* @param String $member_id Identifier of the member
*
- * @return Member
+ * @return void
*/
private function detailMemberImage(){
$image_id = $this->app->getPostParam("image_id");
@@ -572,15 +572,15 @@ class image implements Core{
}
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
$this->app->setOutput("Images", $member);
}
}
@@ -618,16 +618,16 @@ class image implements Core{
$member->delete();
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
+ }
}
/**
@@ -637,7 +637,7 @@ class image implements Core{
* @param String $member_id Identifier of the member
* @param String $status New status for the member
*
- * @return void
+ * @return void
**/
private function updateMemberImage(){
$image_id = $this->app->getPostParam("image_id");
@@ -665,16 +665,16 @@ class image implements Core{
$member->updateStatus($status);
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
+ }
}
}
diff --git a/server/core/LibOverride/genTokenOptions.php b/server/core/LibOverride/genTokenOptions.php
index 394db31..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,53 +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(){
- //error_log(print_r($this->backup['time'], true), 0);
return $this->backup['time'] > time();
- //return true;
}
+ /**
+ * Generate a new token for the Identity service
+ *
+ * @return void
+ */
public function genIdentityToken(){
$options = $this->optionsGlobal['Common'];
$options['catalogName'] = 'false';
@@ -73,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';
@@ -98,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';
@@ -122,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';
@@ -150,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));
@@ -158,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';
@@ -175,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';
@@ -203,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';
@@ -228,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'];
@@ -257,26 +360,34 @@ 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("Path a ecrire ".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"];
@@ -284,10 +395,22 @@ class genTokenOptions
$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);
@@ -302,10 +425,24 @@ 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 = [];
@@ -358,8 +495,19 @@ class genTokenOptions
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();
@@ -426,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/Network.php b/server/core/Network.php
index e93c2c5..b244e4e 100755
--- a/server/core/Network.php
+++ b/server/core/Network.php
@@ -7,37 +7,34 @@
*
* @author KABIR Othmane
*
-* @todo Complete the functions with errors detection and finish the descriptions
*/
use OpenCloud\Common\Error\BadResponseError;
use OpenCloud\Common\Error\BaseError;
use OpenCloud\Common\Error\NotImplementedError;
use OpenCloud\Common\Error\UserInputError;
+include("CoreInterface.php");
+
/**
* Network Class of the back-end application
*
-* ADD CLASS DESCRIPTION
+* Management of Networks
*
*/
-
-class network{
-/** @var App $app protected, contains the main app object */
+class network implements Core{
+ /** @var App $app protected, contains the main app object */
protected $app;
-/** @var OpenStack\Network $libClass protected, contains the library Network object */
+ /** @var OpenStack\Network $libClass protected, contains the library Network object */
protected $libClass;
/**
- * Image constructor
+ * Network constructor
*
* @param App $app the main app object
*
- * @return Network
+ * @return network Object
*/
-
-
-
public function __construct($app){
$this->app = $app;
$this->libClass = $app->getLibClass("Network");
@@ -53,7 +50,7 @@ class network{
*/
public function action($action){
- $this->{$action.""}();
+ $this->{$action.""}();
}
@@ -102,19 +99,19 @@ class network{
catch(BadResponseError $e)
{
$this->app->getErrorInstance->BadResponseHandler($e);
- }
+ }
catch(UserInputError $e)
{
$this->app->getErrorInstance->UserInputHandler($e);
- }
+ }
catch(BaseError $e)
{
$this->app->getErrorInstance->BaseErrorHandler($e);
- }
+ }
catch(NotImplementedError $e)
{
$this->app->getErrorInstance->NotImplementedHandler($e);
- }
+ }
}
@@ -134,8 +131,6 @@ class network{
* @param BOOLEAN enableDhcp Specifies whether DHCP is enabled for this subnet
* @param String allocationPools Subranges of the CIDR available for dynamic allocation to ports
*
- *
- *
* @return void
*/
@@ -200,24 +195,24 @@ class network{
try
{
- $subnet = $this->libClass->createSubnet($options);
+ $subnet = $this->libClass->createSubnet($options);
}
catch(BadResponseError $e)
{
$this->app->getErrorInstance->BadResponseHandler($e);
- }
+ }
catch(UserInputError $e)
{
$this->app->getErrorInstance->UserInputHandler($e);
- }
+ }
catch(BaseError $e)
{
$this->app->getErrorInstance->BaseErrorHandler($e);
- }
+ }
catch(NotImplementedError $e)
{
$this->app->getErrorInstance->NotImplementedHandler($e);
- }
+ }
}
@@ -225,7 +220,7 @@ class network{
/**
* List the ID of the NETWORKS
*
- * @return List of Networks ID
+ * @return void
*/
private function list_network_ids()
@@ -233,36 +228,36 @@ class network{
try
{
$ln = $this->libClass->listNetworks();
-
+
$list_ids = array();
-
+
foreach($ln as $n)
{
-
+
$list_ids[] = $n->id;
-
+
}
}
catch(BadResponseError $e)
{
$this->app->getErrorInstance->BadResponseHandler($e);
- }
+ }
catch(UserInputError $e)
{
$this->app->getErrorInstance->UserInputHandler($e);
- }
+ }
catch(BaseError $e)
{
$this->app->getErrorInstance->BaseErrorHandler($e);
- }
+ }
catch(NotImplementedError $e)
{
$this->app->getErrorInstance->NotImplementedHandler($e);
- }
+ }
- $this->app->setOutput("ListNetworkIds", $list_ids);
+ $this->app->setOutput("ListNetworkIds", $list_ids);
}
/**
@@ -276,78 +271,76 @@ class network{
try
{
$ln = $this->libClass->listNetworks();
-
$list_names = array();
-
-
+
foreach($ln as $n)
{
-
$list_names[] = $n->name;
-
-
}
-
}
catch(BadResponseError $e)
{
$this->app->getErrorInstance->BadResponseHandler($e);
- }
+ }
catch(UserInputError $e)
{
$this->app->getErrorInstance->UserInputHandler($e);
- }
+ }
catch(BaseError $e)
{
$this->app->getErrorInstance->BaseErrorHandler($e);
- }
+ }
catch(NotImplementedError $e)
{
$this->app->getErrorInstance->NotImplementedHandler($e);
- }
+ }
- $this->app->setOutput("ListNetworkNames", $list_names);
+ $this->app->setOutput("ListNetworkNames", $list_names);
}
+
/**
* List the CIDR of the SUBNETS
*
- * @return List of SUBNETS CIDR
+ * @return void
*/
private function list_cidr()
{
try
{
- $ls = $this->libClass->listSubnets();
- $list_cidr = array();
- foreach ($ls as $subnet)
- {
-
- $list_cidr[] = $subnet->cidr;
- }
+ $ls = $this->libClass->listSubnets();
+ $list_cidr = array();
+ foreach ($ls as $subnet)
+ {
+
+ $list_cidr[] = $subnet->cidr;
+ }
- $this->app->setOutput("ListCidr", $list_cidr);
+ $this->app->setOutput("ListCidr", $list_cidr);
}
catch(BadResponseError $e)
{
$this->app->getErrorInstance->BadResponseHandler($e);
- }
+ }
catch(UserInputError $e)
{
$this->app->getErrorInstance->UserInputHandler($e);
- }
+ }
catch(BaseError $e)
{
$this->app->getErrorInstance->BaseErrorHandler($e);
- }
+ }
catch(NotImplementedError $e)
{
$this->app->getErrorInstance->NotImplementedHandler($e);
- }
+ }
}
+
/**
* retrieve a specific network
+ *
* @param networkId ID of network which we want to get
- * @return Network
+ *
+ * @return void
*/
private function getNetwork()
{
@@ -364,27 +357,29 @@ class network{
catch(BadResponseError $e)
{
$this->app->getErrorInstance->BadResponseHandler($e);
- }
+ }
catch(UserInputError $e)
{
$this->app->getErrorInstance->UserInputHandler($e);
- }
+ }
catch(BaseError $e)
{
$this->app->getErrorInstance->BaseErrorHandler($e);
- }
+ }
catch(NotImplementedError $e)
{
$this->app->getErrorInstance->NotImplementedHandler($e);
- }
+ }
- $this->app->setOutput("Network", $network);
+ $this->app->setOutput("Network", $network);
}
/**
* internal function
+ *
* @param String netId ID of network which we want to get
- * @return Network
+ *
+ * @return OpenStack\Network
*/
private function getNetworkP($netId)
{
@@ -401,27 +396,29 @@ class network{
catch(BadResponseError $e)
{
$this->app->getErrorInstance->BadResponseHandler($e);
- }
+ }
catch(UserInputError $e)
{
$this->app->getErrorInstance->UserInputHandler($e);
- }
+ }
catch(BaseError $e)
{
$this->app->getErrorInstance->BaseErrorHandler($e);
- }
+ }
catch(NotImplementedError $e)
{
$this->app->getErrorInstance->NotImplementedHandler($e);
- }
+ }
- return $network;
+ return $network;
}
/**
* retrieve a specific subnet
+ *
* @param subnetId ID of subnet which we want to get
- * @return subnet
+ *
+ * @return void
*/
private function getSubnet()
{
@@ -437,26 +434,28 @@ class network{
catch(BadResponseError $e)
{
$this->app->getErrorInstance->BadResponseHandler($e);
- }
+ }
catch(UserInputError $e)
{
$this->app->getErrorInstance->UserInputHandler($e);
- }
+ }
catch(BaseError $e)
{
$this->app->getErrorInstance->BaseErrorHandler($e);
- }
+ }
catch(NotImplementedError $e)
{
$this->app->getErrorInstance->NotImplementedHandler($e);
- }
+ }
$this->app->setOutput("Subnet", subnet);
-
+
}
/**
* internal function
+ *
* @param String subnetId ID of subnet which we want to get
- * @return subnet
+ *
+ * @return OpenStack\Subnet
*/
private function getSubnetP($subnetId)
{
@@ -472,21 +471,21 @@ class network{
catch(BadResponseError $e)
{
$this->app->getErrorInstance->BadResponseHandler($e);
- }
+ }
catch(UserInputError $e)
{
$this->app->getErrorInstance->UserInputHandler($e);
- }
+ }
catch(BaseError $e)
{
$this->app->getErrorInstance->BaseErrorHandler($e);
- }
+ }
catch(NotImplementedError $e)
{
$this->app->getErrorInstance->NotImplementedHandler($e);
- }
+ }
return $subnet;
-
+
}
/**
@@ -501,8 +500,8 @@ class network{
* @return void
**/
- private function updateNetwork()
- {
+ private function updateNetwork()
+ {
$options = array();
$name = $this->app->getPostParam("name");
$shared = $this->app->getPostParam("shared");
@@ -524,25 +523,25 @@ class network{
{
$networkId = $this->app->getPostParam("networkId");
$network = getNetworkP($networkId);
-
+
$network->update($options);
}
catch(BadResponseError $e)
{
$this->app->getErrorInstance->BadResponseHandler($e);
- }
+ }
catch(UserInputError $e)
{
$this->app->getErrorInstance->UserInputHandler($e);
- }
+ }
catch(BaseError $e)
{
$this->app->getErrorInstance->BaseErrorHandler($e);
- }
+ }
catch(NotImplementedError $e)
{
$this->app->getErrorInstance->NotImplementedHandler($e);
- }
+ }
}
/**
@@ -565,7 +564,7 @@ class network{
**/
private function updateSubnet()
- {
+ {
$options = array();
$name = $this->app->getPostParam("name");
$networkId = $this->app->getPostParam("networkId");
@@ -596,19 +595,19 @@ class network{
catch(BadResponseError $e)
{
$this->app->getErrorInstance->BadResponseHandler($e);
- }
+ }
catch(UserInputError $e)
{
$this->app->getErrorInstance->UserInputHandler($e);
- }
+ }
catch(BaseError $e)
{
$this->app->getErrorInstance->BaseErrorHandler($e);
- }
+ }
catch(NotImplementedError $e)
{
$this->app->getErrorInstance->NotImplementedHandler($e);
- }
+ }
}
/**
@@ -616,11 +615,10 @@ class network{
*
* @param String networkId ID if network which we want to delete
*
- *
* @return void
**/
private function deleteNetwork()
- {
+ {
try
{
$networkId = $this->app->getPostParam("networkId");
@@ -630,19 +628,19 @@ class network{
catch(BadResponseError $e)
{
$this->app->getErrorInstance->BadResponseHandler($e);
- }
+ }
catch(UserInputError $e)
{
$this->app->getErrorInstance->UserInputHandler($e);
- }
+ }
catch(BaseError $e)
{
$this->app->getErrorInstance->BaseErrorHandler($e);
- }
+ }
catch(NotImplementedError $e)
{
$this->app->getErrorInstance->NotImplementedHandler($e);
- }
+ }
}
/**
@@ -650,11 +648,10 @@ class network{
*
* @param String subnetId ID if network which we want to delete
*
- *
* @return void
**/
private function deleteSubnet()
- {
+ {
try
{
$subnetId = $this->app->getPostParam("subnetId");
@@ -664,19 +661,19 @@ class network{
catch(BadResponseError $e)
{
$this->app->getErrorInstance->BadResponseHandler($e);
- }
+ }
catch(UserInputError $e)
{
$this->app->getErrorInstance->UserInputHandler($e);
- }
+ }
catch(BaseError $e)
{
$this->app->getErrorInstance->BaseErrorHandler($e);
- }
+ }
catch(NotImplementedError $e)
{
$this->app->getErrorInstance->NotImplementedHandler($e);
- }
+ }
}
/**
@@ -751,25 +748,25 @@ class network{
catch(BadResponseError $e)
{
$this->app->getErrorInstance->BadResponseHandler($e);
- }
+ }
catch(UserInputError $e)
{
$this->app->getErrorInstance->UserInputHandler($e);
- }
+ }
catch(BaseError $e)
{
$this->app->getErrorInstance->BaseErrorHandler($e);
- }
+ }
catch(NotImplementedError $e)
{
$this->app->getErrorInstance->NotImplementedHandler($e);
- }
+ }
}
/**
* List the of ports
*
- * @return List of ports
+ * @return void
*/
private function listPorts()
@@ -781,25 +778,27 @@ class network{
catch(BadResponseError $e)
{
$this->app->getErrorInstance->BadResponseHandler($e);
- }
+ }
catch(UserInputError $e)
{
$this->app->getErrorInstance->UserInputHandler($e);
- }
+ }
catch(BaseError $e)
{
$this->app->getErrorInstance->BaseErrorHandler($e);
- }
+ }
catch(NotImplementedError $e)
{
$this->app->getErrorInstance->NotImplementedHandler($e);
- }
+ }
}
/**
* retrieve a specific port given
+ *
* @param portId ID of port which we want to get
- * @return port
+ *
+ * @return void
*/
private function getPort()
@@ -813,26 +812,29 @@ class network{
catch(BadResponseError $e)
{
$this->app->getErrorInstance->BadResponseHandler($e);
- }
+ }
catch(UserInputError $e)
{
$this->app->getErrorInstance->UserInputHandler($e);
- }
+ }
catch(BaseError $e)
{
$this->app->getErrorInstance->BaseErrorHandler($e);
- }
+ }
catch(NotImplementedError $e)
{
$this->app->getErrorInstance->NotImplementedHandler($e);
- }
-
+ }
+
}
/**
* internal function
+ *
* retrieve a specific port given
+ *
* @param portId ID of port which we want to get
+ *
* @return port
*/
@@ -846,20 +848,20 @@ class network{
catch(BadResponseError $e)
{
$this->app->getErrorInstance->BadResponseHandler($e);
- }
+ }
catch(UserInputError $e)
{
$this->app->getErrorInstance->UserInputHandler($e);
- }
+ }
catch(BaseError $e)
{
$this->app->getErrorInstance->BaseErrorHandler($e);
- }
+ }
catch(NotImplementedError $e)
{
$this->app->getErrorInstance->NotImplementedHandler($e);
- }
-
+ }
+
}
@@ -935,28 +937,29 @@ class network{
catch(BadResponseError $e)
{
$this->app->getErrorInstance->BadResponseHandler($e);
- }
+ }
catch(UserInputError $e)
{
$this->app->getErrorInstance->UserInputHandler($e);
- }
+ }
catch(BaseError $e)
{
$this->app->getErrorInstance->BaseErrorHandler($e);
- }
+ }
catch(NotImplementedError $e)
{
$this->app->getErrorInstance->NotImplementedHandler($e);
- }
+ }
}
/**
* Delete a port given
*
* @param String portId id of port which we wante to delete
+ *
* @return void
*/
private function deletePort()
- {
+ {
try
{
@@ -967,19 +970,19 @@ class network{
catch(BadResponseError $e)
{
$this->app->getErrorInstance->BadResponseHandler($e);
- }
+ }
catch(UserInputError $e)
{
$this->app->getErrorInstance->UserInputHandler($e);
- }
+ }
catch(BaseError $e)
{
$this->app->getErrorInstance->BaseErrorHandler($e);
- }
+ }
catch(NotImplementedError $e)
{
$this->app->getErrorInstance->NotImplementedHandler($e);
- }
+ }
}
/**
@@ -1012,33 +1015,33 @@ class network{
catch(BadResponseError $e)
{
$this->app->getErrorInstance->BadResponseHandler($e);
- }
+ }
catch(UserInputError $e)
{
$this->app->getErrorInstance->UserInputHandler($e);
- }
+ }
catch(BaseError $e)
{
$this->app->getErrorInstance->BaseErrorHandler($e);
- }
+ }
catch(NotImplementedError $e)
{
$this->app->getErrorInstance->NotImplementedHandler($e);
- }
-
+ }
+
}
/**
* Create a new security groupe
*
* @param String securityGroupId The security group ID to associate with this security group rule.
- * @param String direction The direction in which the security group rule is applied. For a compute instance, an ingress security group * rule is applied to incoming (ingress) traffic for that instance. An egress rule is applied to traffic leaving the instance.
+ * @param String direction The direction in which the security group rule is applied. For a compute instance, an ingress security group rule is applied to incoming (ingress) traffic for that instance. An egress rule is applied to traffic leaving the instance.
* @param String ethertype Must be IPv4 or IPv6, and addresses represented in CIDR must match the ingress or egress rules.
- * @param String portRangeMin The minimum port number in the range that is matched by the security group rule. If the protocol is TCP or UDP, this value must be less than or equal to the value of the portRangeMax attribute. If the protocol is ICMP, this value must be an ICMP type
- *@param String portRangeMax The maximum port number in the range that is matched by the security group rule. If the protocol is TCP or UDP, this value must be less than or equal to the value of the portRangeMax attribute. If the protocol is ICMP, this value must be an ICMP type.
- *@param String protocol The protocol that is matched by the security group rule
- *@param String remoteGroupId The remote group ID to be associated with this security group rule. You can specify either remoteGroupId or remoteGroupPrefix
- *@param String remoteIpPrefix The remote IP prefix to be associated with this security group rule. You can specify either remoteGroupId or remoteGroupPrefix
+ * @param String portRangeMin The minimum port number in the range that is matched by the security group rule. If the protocol is TCP or UDP, this value must be less than or equal to the value of the portRangeMax attribute. If the protocol is ICMP, this value must be an ICMP type
+ * @param String portRangeMax The maximum port number in the range that is matched by the security group rule. If the protocol is TCP or UDP, this value must be less than or equal to the value of the portRangeMax attribute. If the protocol is ICMP, this value must be an ICMP type.
+ * @param String protocol The protocol that is matched by the security group rule
+ * @param String remoteGroupId The remote group ID to be associated with this security group rule. You can specify either remoteGroupId or remoteGroupPrefix
+ * @param String remoteIpPrefix The remote IP prefix to be associated with this security group rule. You can specify either remoteGroupId or remoteGroupPrefix
*
* @return void
*/
@@ -1093,26 +1096,26 @@ class network{
catch(BadResponseError $e)
{
$this->app->getErrorInstance->BadResponseHandler($e);
- }
+ }
catch(UserInputError $e)
{
$this->app->getErrorInstance->UserInputHandler($e);
- }
+ }
catch(BaseError $e)
{
$this->app->getErrorInstance->BaseErrorHandler($e);
- }
+ }
catch(NotImplementedError $e)
{
$this->app->getErrorInstance->NotImplementedHandler($e);
- }
+ }
}
/**
* List of Security Groupes
*
- * @return List of Security Groupes
+ * @return void
*/
private function listSecurityGroupe()
@@ -1124,58 +1127,60 @@ class network{
catch(BadResponseError $e)
{
$this->app->getErrorInstance->BadResponseHandler($e);
- }
+ }
catch(UserInputError $e)
{
$this->app->getErrorInstance->UserInputHandler($e);
- }
+ }
catch(BaseError $e)
{
$this->app->getErrorInstance->BaseErrorHandler($e);
- }
+ }
catch(NotImplementedError $e)
{
$this->app->getErrorInstance->NotImplementedHandler($e);
- }
+ }
}
/**
* List of Security Groupe Rules
*
- * @return List of Security Groupe Rules
+ * @return void
*/
private function listSecurityGroupeRule()
{
try
{
-
- $this->app->setOutput("listSecurityGroupeRule", $this->libClass->listSecurityGroupRules());
+
+ $this->app->setOutput("listSecurityGroupeRule", $this->libClass->listSecurityGroupRules());
}
catch(BadResponseError $e)
{
$this->app->getErrorInstance->BadResponseHandler($e);
- }
+ }
catch(UserInputError $e)
{
$this->app->getErrorInstance->UserInputHandler($e);
- }
+ }
catch(BaseError $e)
{
$this->app->getErrorInstance->BaseErrorHandler($e);
- }
+ }
catch(NotImplementedError $e)
{
$this->app->getErrorInstance->NotImplementedHandler($e);
- }
+ }
}
/**
* retrieve a specific Security Groupe given
+ *
* @param securityGroupeId ID of security Groupe which we want to get
- * @return securityGroupe
+ *
+ * @return void
*/
private function getSecurityGroupe()
@@ -1189,27 +1194,30 @@ class network{
catch(BadResponseError $e)
{
$this->app->getErrorInstance->BadResponseHandler($e);
- }
+ }
catch(UserInputError $e)
{
$this->app->getErrorInstance->UserInputHandler($e);
- }
+ }
catch(BaseError $e)
{
$this->app->getErrorInstance->BaseErrorHandler($e);
- }
+ }
catch(NotImplementedError $e)
{
$this->app->getErrorInstance->NotImplementedHandler($e);
- }
-
+ }
+
}
/**
* internal function
+ *
* retrieve a specific Security Groupe given
+ *
* @param securityGroupeId ID of security Groupe which we want to get
- * @return securityGroupe
+ *
+ * @return securityGroup
*/
private function getSecurityGroupeP($securityGroupeId)
{
@@ -1221,28 +1229,30 @@ class network{
catch(BadResponseError $e)
{
$this->app->getErrorInstance->BadResponseHandler($e);
- }
+ }
catch(UserInputError $e)
{
$this->app->getErrorInstance->UserInputHandler($e);
- }
+ }
catch(BaseError $e)
{
$this->app->getErrorInstance->BaseErrorHandler($e);
- }
+ }
catch(NotImplementedError $e)
{
$this->app->getErrorInstance->NotImplementedHandler($e);
- }
-
+ }
+
}
/**
* Delete a specific Security Groupe given
+ *
* @param securityGroupeId ID of security Groupe which we want to get
+ *
* @return void
*/
private function deleteSecurityGroupe()
- {
+ {
try
{
$securityGroupId = $this->app->getPostParam("securityGroupeId");
@@ -1252,18 +1262,18 @@ class network{
catch(BadResponseError $e)
{
$this->app->getErrorInstance->BadResponseHandler($e);
- }
+ }
catch(UserInputError $e)
{
$this->app->getErrorInstance->UserInputHandler($e);
- }
+ }
catch(BaseError $e)
{
$this->app->getErrorInstance->BaseErrorHandler($e);
- }
+ }
catch(NotImplementedError $e)
{
$this->app->getErrorInstance->NotImplementedHandler($e);
- }
+ }
}
}
diff --git a/server/core/NetworkLayer3.php b/server/core/NetworkLayer3.php
index 30e8a78..35bf707 100755
--- a/server/core/NetworkLayer3.php
+++ b/server/core/NetworkLayer3.php
@@ -1,41 +1,41 @@
<?php
/**
-* File containing the FloatingIp Class.
+* 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'
*
-* @todo Complete the functions with errors detection and finish the descriptions
*/
+
use OpenCloud\Common\Error\BadResponseError;
use OpenCloud\Common\Error\BaseError;
use OpenCloud\Common\Error\NotImplementedError;
use OpenCloud\Common\Error\UserInputError;
-//include("CoreInterface.php");
+include("CoreInterface.php");
/**
-* Image Class of the back-end application
+* networkLayer3 Class of the back-end application
*
-* Management of images
+* Management of networkLayer3
*
*/
-class networkLayer3 {
+class networkLayer3 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\NetworkLayer3 $libClass protected, contains the library NetworkLayer3 object */
protected $libClass;
/**
- * floatingip constructor
+ * networkLayer3 constructor
*
* @param App $app the main app object
*
- * @return networkLayer3
+ * @return networkLayer3 Object
*/
public function __construct($app){
if(!isset($app)){
@@ -54,14 +54,14 @@ class networkLayer3 {
* @return void
*/
public function action($action){
- $this->{$action.""}();
+ $this->{$action.""}();
}
/**
* List floatingip
*
- * @return list of the floatingip
+ * @return void
*/
private function listFloatingIp(){
try{
@@ -75,15 +75,15 @@ class networkLayer3 {
$this->app->setOutput("NetworkLayer3", $result);
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
@@ -91,7 +91,7 @@ class networkLayer3 {
*
* @param array $opt Options for the floating ip creation (floatingNetworkId is required)
*
- * @return floatingip
+ * @return void
*/
private function createFloatingIp(){
$opt = $this->app->getPostParam("opt");
@@ -109,15 +109,15 @@ class networkLayer3 {
}
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
@@ -126,7 +126,7 @@ class networkLayer3 {
*
* @param String id the id of the floatingip
*
- * @return floatingip details
+ * @return void
*/
private function getFloatingIp(){
$id = $this->app->getPostParam("id");
@@ -147,7 +147,7 @@ class networkLayer3 {
foreach ($res as $f) {
if(strcmp($f->id, $id)){
$result = $f;
-
+
}
}
@@ -159,15 +159,15 @@ class networkLayer3 {
}
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
@@ -197,7 +197,7 @@ class networkLayer3 {
foreach ($res as $f) {
if(strcmp($f->id, $id)){
$result = $f;
-
+
}
}
@@ -208,15 +208,15 @@ class networkLayer3 {
}
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
@@ -245,7 +245,7 @@ class networkLayer3 {
foreach ($res as $f) {
if(strcmp($f->id, $id)){
$result = $f;
-
+
}
}
@@ -256,15 +256,15 @@ class networkLayer3 {
}
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
@@ -294,7 +294,7 @@ class networkLayer3 {
foreach ($res as $f) {
if(strcmp($f->id, $id)){
$result = $f;
-
+
}
}
@@ -305,15 +305,15 @@ class networkLayer3 {
}
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
@@ -326,7 +326,7 @@ class networkLayer3 {
* adminStateUp (optionnal)
* name (optionnal)
*
- * @return router
+ * @return void
*/
private function createRouter(){
$opt = $this->app->getPostParam("opt");
@@ -344,22 +344,22 @@ class networkLayer3 {
}
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
/**
* List routers
*
- * @return list of the routers
+ * @return void
*/
private function listRouters(){
try{
@@ -372,15 +372,15 @@ class networkLayer3 {
$this->app->setOutput("NetworkLayer3", $result);
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
@@ -389,7 +389,7 @@ class networkLayer3 {
*
* @param String id the id of the router
*
- * @return router details
+ * @return void
*/
private function getRouter(){
$id = $this->app->getPostParam("id");
@@ -420,15 +420,15 @@ class networkLayer3 {
}
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
@@ -468,15 +468,15 @@ class networkLayer3 {
}
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
@@ -507,7 +507,7 @@ class networkLayer3 {
foreach ($res as $f) {
if(strcmp($f->id, $id)){
$result = $f;
-
+
}
}
@@ -518,14 +518,14 @@ class networkLayer3 {
}
}catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
- }catch(UserInputError $e){
+ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
- }catch(BaseError $e){
+ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
- }catch(NotImplementedError $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);
+ }
}
}
diff --git a/server/index.php b/server/index.php
index 53a24c4..25c7c2e 100755
--- a/server/index.php
+++ b/server/index.php
@@ -1,70 +1,90 @@
<?php
- require "vendor/autoload.php";
- include_once("config.inc.php");
- include_once("init.php");
+/**
+* File containing the code for the API door.
+*
+* @version 1.0 Initialisation of this file
+* @since 1.0 Core application's file
+*
+* @author Eole 'eoledev at outlook . fr'
+*
+*/
+
+/*
+*/
+//loading dependencies
+require "vendor/autoload.php";
+//Include general config file
+include_once("config.inc.php");
+//Include API initialisation
+include_once("init.php");
+
+if(isset($_POST["task"]) && isset($_POST["action"])){
+ $task = $_POST["task"];
+ $action = $_POST["action"];
+}else if(isset($_POST["task"]) && $_POST["task"] == "Authenticate" || $_POST["task"] == "Deauthenticate"){
+ $task = $_POST["task"];
+}else{
+ $App->setOutput("Error", "Invalid Request!");
+ $App->show();
+ exit();
+}
+
+//Authentification and deauthentification request
+if($task == "Authenticate"){
- if(isset($_POST["task"]) && isset($_POST["action"])){
- $task = $_POST["task"];
- $action = $_POST["action"];
- }else if(isset($_POST["task"]) && $_POST["task"] == "Authenticate" || $_POST["task"] == "Deauthenticate"){
- $task = $_POST["task"];
- }else{
- //Gestion Erreur
- }
+ $App->authenticate();
+ $App->show();
- if($task == "Authenticate"){
-
- $App->authenticate();
+}else if($task == "Deauthenticate"){
+
+ $App->deauthenticate();
+ $App->show();
+
+}else if($App->checkToken()){
+ //Task switcher and task's file loader
+ switch($task)
+ {
+ case "identity":
+ include_once("core/Identity.php");
+ $identityObject = new identity($App);
+ $identityObject->action($action);
$App->show();
+ break;
- }else if($task == "Deauthenticate"){
-
- $App->deauthenticate();
+ case "network":
+ include_once("core/Network.php");
+ $networkObject = new network($App);
+ $networkObject->action($action);
$App->show();
+ break;
- }else if($App->checkToken()){
- switch($task)
- {
- case "identity":
- include_once("core/Identity.php");
- $identityObject = new identity($App);
- $identityObject->action($action);
- $App->show();
- break;
-
- case "network":
- include_once("core/Network.php");
- $networkObject = new network($App);
- $networkObject->action($action);
- $App->show();
- break;
-
- case "image":
- include_once("core/Image.php");
- $imageObject = new image($App);
- $imageObject->action($action);
- $App->show();
- break;
-
- case "compute":
- include_once("core/Compute.php");
- $computeObject = new compute($App);
- $computeObject->action($action);
- $App->show();
- break;
-
- case "networkLayer3":
- include_once("core/NetworkLayer3.php");
- $computeObject = new networkLayer3($App);
- $computeObject->action($action);
- $App->show();
- break;
- }
+ case "image":
+ include_once("core/Image.php");
+ $imageObject = new image($App);
+ $imageObject->action($action);
+ $App->show();
+ break;
+
+ case "compute":
+ include_once("core/Compute.php");
+ $computeObject = new compute($App);
+ $computeObject->action($action);
+ $App->show();
+ break;
- }else{
- $App->setOutput("Error", "Token Invalide");
+ case "networkLayer3":
+ include_once("core/NetworkLayer3.php");
+ $computeObject = new networkLayer3($App);
+ $computeObject->action($action);
$App->show();
+ break;
}
-
-
+}else{
+ //Request without authentication
+ $App->setOutput("Error", "Token Invalide");
+ $App->show();
+}
+
+
+
diff --git a/server/init.php b/server/init.php
index a00927d..e6a90fb 100755
--- a/server/init.php
+++ b/server/init.php
@@ -1,48 +1,58 @@
<?php
- include_once("core/App.php");
+/**
+ * File containing the initialisation of the API.
+ *
+ * @version 1.0 Initialisation of this file
+ * @since 1.0 Core application's file
+ *
+ * @author Eole 'eoledev at outlook . fr'
+ *
+ */
- $user = "";
- $password = "";
- $project = "";
+/*
+* Include Main Api Class
+*/
+include_once("core/App.php");
+
+$user = "";
+$password = "";
+$project = "";
+
+
+//token processing
+if(isset($_POST["token"])){
+ $token = $_POST["token"];
- //traitement requete, recuperation data
- if(isset($_POST["token"])){
-
- $token = $_POST["token"];
-
- }else if(isset($_POST["user"]) && isset($_POST["password"]) && isset($_POST["project"]) ){
-
- $user = $_POST["user"];
- $password = $_POST["password"];
- $project = $_POST["project"];
-
- } /*else { // Test Backend
- $user = "admin";
- $password = "ae5or6cn";
- $project = "admin";
-
- }*/
-
- $Args = Array(
- "user" => Array(
- "name" => $user,
- "password" => $password,
- "domain" => Array(
- "name" => "Default")
- ),
- "scope" => Array(
- "project" => Array(
- "name" => $project,
- "domain" => Array(
- "name" => "Default")
- )
- ),
- "authUrl" => $config["urlAuth"]
- );
+}else if(isset($_POST["user"]) && isset($_POST["password"]) && isset($_POST["project"]) ){
- $App = new App($Args);
+ $user = $_POST["user"];
+ $password = $_POST["password"];
+ $project = $_POST["project"];
+
+}
+
+//Library args
+$Args = Array(
+ "user" => Array(
+ "name" => $user,
+ "password" => $password,
+ "domain" => Array(
+ "name" => "Default")
+ ),
+ "scope" => Array(
+ "project" => Array(
+ "name" => $project,
+ "domain" => Array(
+ "name" => "Default")
+ )
+ ),
+ "authUrl" => $config["urlAuth"]
+);
+
+//Init core Api
+$App = new App($Args);
- if(isset($token))
- $App->setToken($token);
+if(isset($token))
+ $App->setToken($token);
?>