Refactoring of comments beginning

This commit is contained in:
EoleDev 2016-04-26 20:42:31 +02:00
parent 477dc82182
commit 5263cf00a2
13 changed files with 1535 additions and 1744 deletions

View file

@ -1,11 +1,21 @@
<?php <?php
date_default_timezone_set('Europe/Paris'); /**
* 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'
*
*/
$config = Array(); date_default_timezone_set('Europe/Paris');
$config["modules_enabled"] = ""; $config = Array();
$config["urlAuth"] = "http://148.60.11.31:5000/v3";
$config["tokenTime"] = 60 //minute = 60 $config["modules_enabled"] = "";
$config["urlAuth"] = "http://148.60.11.31:5000/v3";
$config["tokenTime"] = 60; //minute = 60
?> ?>

View file

@ -1,21 +1,53 @@
<?php <?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/LibOverride/genTokenOptions.php");
include_once("core/ErrorManagement.php"); include_once("core/ErrorManagement.php");
//Library loading
use OpenCloud\Common\Error\BadResponseError; use OpenCloud\Common\Error\BadResponseError;
use OpenCloud\Common\Error\BaseError; use OpenCloud\Common\Error\BaseError;
use OpenCloud\Common\Error\NotImplementedError; use OpenCloud\Common\Error\NotImplementedError;
use OpenCloud\Common\Error\UserInputError; use OpenCloud\Common\Error\UserInputError;
/**
* 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{ class App{
/** @var Openstack $openstack protected, contains the main library object */
protected $openstack; protected $openstack;
/** @var Array $postParams protected, contains the post parameters */
protected $postParams; protected $postParams;
/** @var genTokenOptions $tokenClass protected, contains the class object for the authentication override of the library */
protected $tokenClass; protected $tokenClass;
/** @var String $tokenPost protected, contains the token given in parameter */
protected $tokenPost; protected $tokenPost;
/** @var errorManagement $errorClass protected, contains the errorManagement object */
protected $errorClass; protected $errorClass;
/** @var Array $output protected, contains the result for the API call */
protected $output; protected $output;
/**
* App constructor
*
* @param Array $args Args for the OpenStack Library
*
* @return App object
*/
public function __construct($args){ public function __construct($args){
$this->tokenPost = NULL; $this->tokenPost = NULL;
@ -27,6 +59,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){ public function setToken($token){
$this->tokenPost = $token; $this->tokenPost = $token;
@ -34,42 +73,59 @@ class App{
} }
/**
* Check the expiration of the token
*
* @return Boolean if the token is not expired
*/
public function checkToken(){ public function checkToken(){
return $this->tokenClass->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){ public function getLibClass($service){
switch($service){ switch($service){
case "Identity": case "Identity":
if($this->tokenPost == NULL) $this->tokenClass->genIdentityToken(); if($this->tokenPost == NULL) $this->tokenClass->genIdentityToken();
$opt = $this->tokenClass->getOptions($service); $opt = $this->tokenClass->getOptions($service);
return $this->openstack->identityV3($opt); return $this->openstack->identityV3($opt);
break; break;
case "Image": case "Image":
if($this->tokenPost == NULL) $this->tokenClass->genImageToken(); if($this->tokenPost == NULL) $this->tokenClass->genImageToken();
$opt = $this->tokenClass->getOptions($service); $opt = $this->tokenClass->getOptions($service);
return $this->openstack->imagesV2($opt); return $this->openstack->imagesV2($opt);
break; break;
case "Network": case "Network":
if($this->tokenPost == NULL) $this->tokenClass->genNetworkToken(); if($this->tokenPost == NULL) $this->tokenClass->genNetworkToken();
$opt = $this->tokenClass->getOptions($service); $opt = $this->tokenClass->getOptions($service);
return $this->openstack->networkingV2($opt); return $this->openstack->networkingV2($opt);
break; break;
case "Compute": case "Compute":
if($this->tokenPost == NULL) $this->tokenClass->genComputeToken(); if($this->tokenPost == NULL) $this->tokenClass->genComputeToken();
$opt = $this->tokenClass->getOptions($service); $opt = $this->tokenClass->getOptions($service);
return $this->openstack->computeV2($opt); return $this->openstack->computeV2($opt);
break; break;
case "NetworkLayer3": case "NetworkLayer3":
if($this->tokenPost == NULL) $this->tokenClass->genNetworkToken(); if($this->tokenPost == NULL) $this->tokenClass->genNetworkToken();
$opt = $this->tokenClass->getOptions('Network'); $opt = $this->tokenClass->getOptions('Network');
return $this->openstack->networkingV2ExtLayer3($opt); return $this->openstack->networkingV2ExtLayer3($opt);
break; break;
} }
} }
/**
* Generate the token for the different services in OpenStack
*
* @return NULL
*/
public function authenticate(){ public function authenticate(){
try{ try{
@ -81,16 +137,21 @@ class App{
$this->setOutput("token", $this->tokenClass->getBackup()); $this->setOutput("token", $this->tokenClass->getBackup());
}catch(BadResponseError $e){ }catch(BadResponseError $e){
$this->errorClass->BadResponseHandler($e); $this->errorClass->BadResponseHandler($e);
}catch(UserInputError $e){ }catch(UserInputError $e){
$this->errorClass->UserInputHandler($e); $this->errorClass->UserInputHandler($e);
}catch(BaseError $e){ }catch(BaseError $e){
$this->errorClass->BaseErrorHandler($e); $this->errorClass->BaseErrorHandler($e);
}catch(NotImplementedError $e){ }catch(NotImplementedError $e){
$this->errorClass->NotImplementedHandler($e); $this->errorClass->NotImplementedHandler($e);
} }
} }
/**
* Revoke the openstack services' token
*
* @return NULL
*/
public function deauthenticate(){ public function deauthenticate(){
try{ try{
@ -103,16 +164,23 @@ class App{
$this->setOutput("deauthenticate", "Ok"); $this->setOutput("deauthenticate", "Ok");
}catch(BadResponseError $e){ }catch(BadResponseError $e){
$this->errorClass->BadResponseHandler($e); $this->errorClass->BadResponseHandler($e);
}catch(UserInputError $e){ }catch(UserInputError $e){
$this->errorClass->UserInputHandler($e); $this->errorClass->UserInputHandler($e);
}catch(BaseError $e){ }catch(BaseError $e){
$this->errorClass->BaseErrorHandler($e); $this->errorClass->BaseErrorHandler($e);
}catch(NotImplementedError $e){ }catch(NotImplementedError $e){
$this->errorClass->NotImplementedHandler($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){ public function getPostParam($name){
if(isset($this->postParams[$name])){ if(isset($this->postParams[$name])){
@ -123,28 +191,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 NULL
*/
public function setPostParam($param, $value){ public function setPostParam($param, $value){
$this->postParams[$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 NULL
*/
public function setOutput($key, $out){ public function setOutput($key, $out){
$this->output[$key] = $out; $this->output[$key] = $out;
} }
/**
* Retrieve the errorManagement instance Object
*
* @return errorManagement object
*/
public function getErrorInstance(){ public function getErrorInstance(){
return $this->errorClass; return $this->errorClass;
} }
/**
* Output the messages to be send to the client
*
* @return NULl
*/
public function show(){ public function show(){
echo json_encode($this->output); echo json_encode($this->output);
//error_log(var_dump(json_encode($this->output), true), 0);
} }
} }

View file

@ -5,9 +5,8 @@
* @version 1.0 Initialisation of this file * @version 1.0 Initialisation of this file
* @since 1.0 Core application's 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("Image.php");
@ -44,10 +43,10 @@ class automating{
* *
* @param String $action name of another function of this class * @param String $action name of another function of this class
* *
* @return void * @return NULL
*/ */
public function action($action){ public function action($action){
$this->{$action.""}(); $this->{$action.""}();
} }
/** /**
@ -58,7 +57,7 @@ class automating{
* @param String $serverName name ofthe new server * @param String $serverName name ofthe new server
* @param String $flavor kind of server * @param String $flavor kind of server
* *
* @return void * @return NULL
*/ */
private function createPublicServer() private function createPublicServer()
{ {

View file

@ -4,170 +4,170 @@ use OpenCloud\Common\Error;
class compute class compute
{ {
/** @var App $app protected, contains the main app object */ /** @var App $app protected, contains the main app object */
protected $app; protected $app;
/** @var OpenStack\Identity $libClass protected, contains the library Compute object */ /** @var OpenStack\Identity $libClass protected, contains the library Compute object */
protected $libClass; protected $libClass;
public function __construct($app) public function __construct($app)
{ {
$this->app = $app; $this->app = $app;
$this->libClass = $app->getLibClass("Compute"); $this->libClass = $app->getLibClass("Compute");
} }
/** /**
* Execute an action * Execute an action
* *
* @param String $action name of another function of this class * @param String $action name of another function of this class
* *
* @return void * @return NULL
*/ */
public function action($action){ public function action($action){
$this->{$action.""}(); $this->{$action.""}();
} }
/** /**
* List servers. * List servers.
* @return array * @return array
*/ */
public function listServers() public function listServers()
{ {
try{ try{
$serverList = $this->libClass->listServers(true); $serverList = $this->libClass->listServers(true);
$servers = Array(); $servers = Array();
foreach($serverList as $server){ foreach($serverList as $server){
$servers[$server->id] = Array(); $servers[$server->id] = Array();
$server->flavor->retrieve(); $server->flavor->retrieve();
$server->image->retrieve(); $server->image->retrieve();
$server->retrieve(); $server->retrieve();
$servers[$server->id]["id"] = $server->id; $servers[$server->id]["id"] = $server->id;
$servers[$server->id]["name"] = $server->name; $servers[$server->id]["name"] = $server->name;
$servers[$server->id]["image"] = $server->image; $servers[$server->id]["image"] = $server->image;
$servers[$server->id]["ram"] = $server->flavor->ram; $servers[$server->id]["ram"] = $server->flavor->ram;
$servers[$server->id]["disk"] = $server->flavor->disk; $servers[$server->id]["disk"] = $server->flavor->disk;
$servers[$server->id]["flavor"] = $server->flavor; $servers[$server->id]["flavor"] = $server->flavor;
$servers[$server->id]["status"] = $server->status; $servers[$server->id]["status"] = $server->status;
$servers[$server->id]["created"] = $server->created; $servers[$server->id]["created"] = $server->created;
$servers[$server->id]["updated"] = $server->updated; $servers[$server->id]["updated"] = $server->updated;
$servers[$server->id]["ipv4"] = $server->ipv4; $servers[$server->id]["ipv4"] = $server->ipv4;
$servers[$server->id]["ipv6"] = $server->ipv6; $servers[$server->id]["ipv6"] = $server->ipv6;
$servers[$server->id]["progress"] = $server->progress; $servers[$server->id]["progress"] = $server->progress;
$servers[$server->id]["hostId"] = $server->hostId; $servers[$server->id]["hostId"] = $server->hostId;
$servers[$server->id]["tenantId"] = $server->tenantId; $servers[$server->id]["tenantId"] = $server->tenantId;
$servers[$server->id]["userId"] = $server->userId; $servers[$server->id]["userId"] = $server->userId;
$servers[$server->id]["taskState"] = $server->taskState; $servers[$server->id]["taskState"] = $server->taskState;
$servers[$server->id]["addresses"] = $server->addresses; $servers[$server->id]["addresses"] = $server->addresses;
$servers[$server->id]["links"] = $server->links; $servers[$server->id]["links"] = $server->links;
$servers[$server->id]["metadata"] = $server->metadata; $servers[$server->id]["metadata"] = $server->metadata;
} }
$this->app->setOutput("Servers", $servers); $this->app->setOutput("Servers", $servers);
} }
catch(BadResponseError $e){ catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
} }
catch(UserInputError $e){ catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e); $this->app->getErrorInstance()->UserInputHandler($e);
} }
catch(BaseError $e){ catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e); $this->app->getErrorInstance()->BaseErrorHandler($e);
} }
catch(NotImplementedError $e){ catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
} }
catch(Exception $e){ catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
return; return;
} }
/** /**
* List flavors. * List flavors.
* @return array * @return array
*/ */
public function listFlavors() public function listFlavors()
{ {
try{ try{
$flavorList = $this->libClass->listFlavors(); $flavorList = $this->libClass->listFlavors();
$flavors = Array(); $flavors = Array();
foreach($flavorList as $flavor){ foreach($flavorList as $flavor){
$flavors[$flavor->id] = Array(); $flavors[$flavor->id] = Array();
$flavor->retrieve(); $flavor->retrieve();
$flavors[$flavor->id]["id"] = $flavor->id; $flavors[$flavor->id]["id"] = $flavor->id;
$flavors[$flavor->id]["name"] = $flavor->name; $flavors[$flavor->id]["name"] = $flavor->name;
$flavors[$flavor->id]["ram"] = $flavor->ram; $flavors[$flavor->id]["ram"] = $flavor->ram;
$flavors[$flavor->id]["disk"] = $flavor->disk; $flavors[$flavor->id]["disk"] = $flavor->disk;
$flavors[$flavor->id]["vcpus"] = $flavor->vcpus; $flavors[$flavor->id]["vcpus"] = $flavor->vcpus;
$flavors[$flavor->id]["links"] = $flavor->links; $flavors[$flavor->id]["links"] = $flavor->links;
} }
$this->app->setOutput("Flavors", $flavors); $this->app->setOutput("Flavors", $flavors);
} }
catch(BadResponseError $e){ catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
} }
catch(UserInputError $e){ catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e); $this->app->getErrorInstance()->UserInputHandler($e);
} }
catch(BaseError $e){ catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e); $this->app->getErrorInstance()->BaseErrorHandler($e);
} }
catch(NotImplementedError $e){ catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
} }
catch(Exception $e){ catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
return; return;
} }
/** /**
* List images. * List images.
* @return array * @return array
*/ */
public function listImages() public function listImages()
{ {
try{ try{
$imageList = $this->libClass->listImages(); $imageList = $this->libClass->listImages();
$images = Array(); $images = Array();
foreach($imageList as $image){ foreach($imageList as $image){
$images[$image->id] = Array(); $images[$image->id] = Array();
$image->retrieve(); $image->retrieve();
$images[$image->id]["id"] = $image->id; $images[$image->id]["id"] = $image->id;
$images[$image->id]["name"] = $image->name; $images[$image->id]["name"] = $image->name;
$images[$image->id]["status"] = $image->status; $images[$image->id]["status"] = $image->status;
$images[$image->id]["created"] = $image->created; $images[$image->id]["created"] = $image->created;
$images[$image->id]["updated"] = $image->updated; $images[$image->id]["updated"] = $image->updated;
$images[$image->id]["minDisk"] = $image->minDisk; $images[$image->id]["minDisk"] = $image->minDisk;
$images[$image->id]["minRam"] = $image->minRam; $images[$image->id]["minRam"] = $image->minRam;
$images[$image->id]["progress"] = $image->progress; $images[$image->id]["progress"] = $image->progress;
$images[$image->id]["links"] = $image->links; $images[$image->id]["links"] = $image->links;
$images[$image->id]["metadata"] = $image->metadata; $images[$image->id]["metadata"] = $image->metadata;
} }
$this->app->setOutput("Images", $images); $this->app->setOutput("Images", $images);
} }
catch(BadResponseError $e){ catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
} }
catch(UserInputError $e){ catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e); $this->app->getErrorInstance()->UserInputHandler($e);
} }
catch(BaseError $e){ catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e); $this->app->getErrorInstance()->BaseErrorHandler($e);
} }
catch(NotImplementedError $e){ catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
} }
catch(Exception $e){ catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
return; return;
} }
/** /**
* Get server details. * Get server details.
* @return array * @return array
*/ */
public function getServer() public function getServer()
{ {
try{ try{
$serverId = $this->app->getPostParam("serverId"); $serverId = $this->app->getPostParam("serverId");
if(!isset($serverId)){ if(!isset($serverId)){
$this->app->setOutput("Error", "Server ID is missing!"); $this->app->setOutput("Error", "Server ID is missing!");
@ -180,27 +180,27 @@ class compute
} }
catch(BadResponseError $e){ catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
} }
catch(UserInputError $e){ catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e); $this->app->getErrorInstance()->UserInputHandler($e);
} }
catch(BaseError $e){ catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e); $this->app->getErrorInstance()->BaseErrorHandler($e);
} }
catch(NotImplementedError $e){ catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
} }
catch(Exception $e){ catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
return; return;
} }
/** /**
* Get flavor details. * Get flavor details.
* @return array * @return array
*/ */
public function getFlavor() public function getFlavor()
{ {
try{ try{
$flavorId = $this->app->getPostParam("flavorId"); $flavorId = $this->app->getPostParam("flavorId");
if(!isset($serverId)){ if(!isset($serverId)){
@ -214,27 +214,27 @@ class compute
} }
catch(BadResponseError $e){ catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
} }
catch(UserInputError $e){ catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e); $this->app->getErrorInstance()->UserInputHandler($e);
} }
catch(BaseError $e){ catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e); $this->app->getErrorInstance()->BaseErrorHandler($e);
} }
catch(NotImplementedError $e){ catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
} }
catch(Exception $e){ catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
return; return;
} }
/** /**
* Get image details. * Get image details.
* @return array * @return array
*/ */
public function getImage() public function getImage()
{ {
try{ try{
$imageId = $this->app->getPostParam("imageId"); $imageId = $this->app->getPostParam("imageId");
if(!isset($serverId)){ if(!isset($serverId)){
@ -248,27 +248,27 @@ class compute
} }
catch(BadResponseError $e){ catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
} }
catch(UserInputError $e){ catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e); $this->app->getErrorInstance()->UserInputHandler($e);
} }
catch(BaseError $e){ catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e); $this->app->getErrorInstance()->BaseErrorHandler($e);
} }
catch(NotImplementedError $e){ catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
} }
catch(Exception $e){ catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
return; return;
} }
/** /**
* Create server. * Create server.
* @return array * @return array
*/ */
public function createServer() public function createServer()
{ {
try{ try{
$name = $this->app->getPostParam("name"); $name = $this->app->getPostParam("name");
$imageId = $this->app->getPostParam("imageId"); $imageId = $this->app->getPostParam("imageId");
@ -282,28 +282,28 @@ class compute
} }
catch(BadResponseError $e){ catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
} }
catch(UserInputError $e){ catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e); $this->app->getErrorInstance()->UserInputHandler($e);
} }
catch(BaseError $e){ catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e); $this->app->getErrorInstance()->BaseErrorHandler($e);
} }
catch(NotImplementedError $e){ catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
} }
catch(Exception $e){ catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
return; return;
} }
/** /**
* update a server * update a server
* @return void * @return NULL
*/ */
public function updateServer() public function updateServer()
{ {
try{ try{
$serverId = $this->app->getPostParam("serverId"); $serverId = $this->app->getPostParam("serverId");
$newName = $this->app->getPostParam("newName"); $newName = $this->app->getPostParam("newName");
@ -329,27 +329,27 @@ class compute
} }
catch(BadResponseError $e){ catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
} }
catch(UserInputError $e){ catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e); $this->app->getErrorInstance()->UserInputHandler($e);
} }
catch(BaseError $e){ catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e); $this->app->getErrorInstance()->BaseErrorHandler($e);
} }
catch(NotImplementedError $e){ catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
} }
catch(Exception $e){ catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
return; return;
} }
/** /**
* Delete a server * Delete a server
* @return void * @return NULL
*/ */
public function deleteServer() public function deleteServer()
{ {
try{ try{
$serverId = $this->app->getPostParam("serverId"); $serverId = $this->app->getPostParam("serverId");
if(!isset($serverId)){ if(!isset($serverId)){
@ -363,27 +363,27 @@ class compute
} }
catch(BadResponseError $e){ catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
} }
catch(UserInputError $e){ catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e); $this->app->getErrorInstance()->UserInputHandler($e);
} }
catch(BaseError $e){ catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e); $this->app->getErrorInstance()->BaseErrorHandler($e);
} }
catch(NotImplementedError $e){ catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
} }
catch(Exception $e){ catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
return; return;
} }
/** /**
* Change the password of a server * Change the password of a server
* @return void * @return NULL
*/ */
public function changePassword() public function changePassword()
{ {
try{ try{
$serverId = $this->app->getPostParam("serverId"); $serverId = $this->app->getPostParam("serverId");
$password = $this->app->getPostParam("newPassword"); $password = $this->app->getPostParam("newPassword");
@ -398,27 +398,27 @@ class compute
} }
catch(BadResponseError $e){ catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
} }
catch(UserInputError $e){ catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e); $this->app->getErrorInstance()->UserInputHandler($e);
} }
catch(BaseError $e){ catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e); $this->app->getErrorInstance()->BaseErrorHandler($e);
} }
catch(NotImplementedError $e){ catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
} }
catch(Exception $e){ catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
return; return;
} }
/** /**
* Reboot a server * Reboot a server
* @return void * @return NULL
*/ */
public function reboot() public function reboot()
{ {
try{ try{
$serverId = $this->app->getPostParam("serverId"); $serverId = $this->app->getPostParam("serverId");
if(!isset($serverId)){ if(!isset($serverId)){
@ -432,74 +432,74 @@ class compute
} }
catch(BadResponseError $e){ catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
} }
catch(UserInputError $e){ catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e); $this->app->getErrorInstance()->UserInputHandler($e);
} }
catch(BaseError $e){ catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e); $this->app->getErrorInstance()->BaseErrorHandler($e);
} }
catch(NotImplementedError $e){ catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
} }
catch(Exception $e){ catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
return; return;
} }
/** /**
* Rebuild a server * Rebuild a server
* @return void * @return NULL
*/ */
public function rebuild() public function rebuild()
{ {
$serverId = $this->app->getPostParam("serverId"); $serverId = $this->app->getPostParam("serverId");
$imageId = $this->app->getPostParam("imageId"); $imageId = $this->app->getPostParam("imageId");
$newName = $this->app->getPostParam("newName"); $newName = $this->app->getPostParam("newName");
$adminPass = $this->app->getPostParam("adminPass"); $adminPass = $this->app->getPostParam("adminPass");
if(!isset($serverId)|| !isset($imageId) || isset($newName) || isset($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!"); $this->app->setOutput("Error", "You'll have to provide server ID and the new image, name and admin password!");
return; return;
try{ try{
$serverId = $this->app->getPostParam("serverId"); $serverId = $this->app->getPostParam("serverId");
$imageId = $this->app->getPostParam("imageId"); $imageId = $this->app->getPostParam("imageId");
$newName = $this->app->getPostParam("newName"); $newName = $this->app->getPostParam("newName");
$adminPass = $this->app->getPostParam("adminPass"); $adminPass = $this->app->getPostParam("adminPass");
if(!isset($serverId)|| !isset($imageId) || isset($newName) || isset($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!"); $this->app->setOutput("Error", "You'll have to provide server ID and the new image, name and admin password!");
return; 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);
}
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);
}
return;
}
}
/**
* Resize a server * Resize a server
* A call to this method has to be followed by either confirmResize or revertResize * A call to this method has to be followed by either confirmResize or revertResize
* @return void * @return NULL
*/ */
public function resize() public function resize()
{ {
try{ try{
$serverId = $this->app->getPostParam("serverId"); $serverId = $this->app->getPostParam("serverId");
$newFlavorId = $this->app->getPostParam("newFlavorId"); $newFlavorId = $this->app->getPostParam("newFlavorId");
@ -513,27 +513,27 @@ class compute
} }
catch(BadResponseError $e){ catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
} }
catch(UserInputError $e){ catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e); $this->app->getErrorInstance()->UserInputHandler($e);
} }
catch(BaseError $e){ catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e); $this->app->getErrorInstance()->BaseErrorHandler($e);
} }
catch(NotImplementedError $e){ catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
} }
catch(Exception $e){ catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
return; return;
} }
/** /**
* Confirm resize operation on a server * Confirm resize operation on a server
* @return void * @return NULL
*/ */
public function confirmResize() public function confirmResize()
{ {
try{ try{
$serverId = $this->app->getPostParam("serverId"); $serverId = $this->app->getPostParam("serverId");
if(!isset($serverId)){ if(!isset($serverId)){
@ -547,27 +547,27 @@ class compute
} }
catch(BadResponseError $e){ catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
} }
catch(UserInputError $e){ catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e); $this->app->getErrorInstance()->UserInputHandler($e);
} }
catch(BaseError $e){ catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e); $this->app->getErrorInstance()->BaseErrorHandler($e);
} }
catch(NotImplementedError $e){ catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
} }
catch(Exception $e){ catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
return; return;
} }
/** /**
* Revert resize operation on a server * Revert resize operation on a server
* @return void * @return NULL
*/ */
public function revertResize() public function revertResize()
{ {
try{ try{
$serverId = $this->app->getPostParam("serverId"); $serverId = $this->app->getPostParam("serverId");
if(!isset($serverId)){ if(!isset($serverId)){
@ -581,28 +581,28 @@ class compute
} }
catch(BadResponseError $e){ catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
} }
catch(UserInputError $e){ catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e); $this->app->getErrorInstance()->UserInputHandler($e);
} }
catch(BaseError $e){ catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e); $this->app->getErrorInstance()->BaseErrorHandler($e);
} }
catch(NotImplementedError $e){ catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
} }
catch(Exception $e){ catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
return; return;
} }
/** /**
* List private and public addresses of a server * List private and public addresses of a server
* @return void * @return NULL
*/ */
public function listAddresses(array $options = []) public function listAddresses(array $options = [])
{ {
try{ try{
$serverId = $this->app->getPostParam("serverId"); $serverId = $this->app->getPostParam("serverId");
if(!isset($serverId)){ if(!isset($serverId)){
@ -616,20 +616,20 @@ class compute
} }
catch(BadResponseError $e){ catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
} }
catch(UserInputError $e){ catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e); $this->app->getErrorInstance()->UserInputHandler($e);
} }
catch(BaseError $e){ catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e); $this->app->getErrorInstance()->BaseErrorHandler($e);
} }
catch(NotImplementedError $e){ catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
} }
catch(Exception $e){ catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
return; return;
} }
} }

View file

@ -1,5 +1,13 @@
<?php <?php
/**
* File containing Core Interface
*
* @version 1.0 Initialisation of this file
* @since 1.0 Core application's file
*
* @author Eole 'eoledev at outlook . fr'
*
*/
interface Core{ interface Core{
public function action($action); public function action($action);

View file

@ -22,9 +22,9 @@ Class errorManagement{
/** /**
* ErrorManagemement constructor * 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){ public function __construct($args){
@ -35,9 +35,9 @@ Class errorManagement{
/** /**
* Put an error message corresponding to a base error in the output * 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 NULL
*/ */
public function BaseErrorHandler($error){ public function BaseErrorHandler($error){
$this->app->setOutput("Error", "BaseError"); $this->app->setOutput("Error", "BaseError");
@ -46,49 +46,49 @@ Class errorManagement{
/** /**
* Put an error message corresponding to a bad response in function of the status code in the output * 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 NULL
*/ */
public function BadResponseHandler($error){ public function BadResponseHandler($error){
$statusCode = $error->getResponse()->getStatusCode(); $statusCode = $error->getResponse()->getStatusCode();
switch ($statusCode) { switch ($statusCode) {
case 400: case 400:
$this->app->setOutput("Error", "Invalid input."); $this->app->setOutput("Error", "Invalid input.");
break; break;
case 401: case 401:
$this->app->setOutput("Error", "Authentification failed."); $this->app->setOutput("Error", "Authentification failed.");
break; break;
case 403: case 403:
$this->app->setOutput("Error", "Operation forbidden."); $this->app->setOutput("Error", "Operation forbidden.");
break; break;
case 404: case 404:
$this->app->setOutput("Error", "Ressource not found."); $this->app->setOutput("Error", "Ressource not found.");
break; break;
case 500: case 500:
$this->app->setOutput("Error", "Internal server error, please contact an administrator."); $this->app->setOutput("Error", "Internal server error, please contact an administrator.");
break; break;
case 503: case 503:
$this->app->setOutput("Error", "Service unvailable for the moment."); $this->app->setOutput("Error", "Service unvailable for the moment.");
break; break;
default: default:
$this->app->setOutput("Error", "Unknow error, please contact an administrator."); $this->app->setOutput("Error", "Unknow error, please contact an administrator.");
break; break;
} }
} }
/** /**
* Put an error message corresponding to a not implemented yet error in the output * 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 NULL
*/ */
public function NotImplementedHandler($error){ public function NotImplementedHandler($error){
$this->app->setOutput("Error", "Internal error (not implemented yet), please contact an administrator"); $this->app->setOutput("Error", "Internal error (not implemented yet), please contact an administrator");
@ -97,9 +97,9 @@ Class errorManagement{
/** /**
* Put an error message corresponding to a user input error in the output * 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 NULL
*/ */
public function UserInputHandler($error){ public function UserInputHandler($error){
$this->app->setOutput("Error", "UserInputError"); $this->app->setOutput("Error", "UserInputError");
@ -108,9 +108,9 @@ Class errorManagement{
/** /**
* Put an error message corresponding to an other error in the output * 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 NULL
*/ */
public function OtherException($error){ public function OtherException($error){
$this->app->setOutput("Error", $error->getMessage()); $this->app->setOutput("Error", $error->getMessage());

File diff suppressed because it is too large Load diff

View file

@ -51,10 +51,10 @@ class image implements Core{
* *
* @param String $action name of another function of this class * @param String $action name of another function of this class
* *
* @return void * @return NULL
*/ */
public function action($action){ public function action($action){
$this->{$action.""}(); $this->{$action.""}();
} }
/** /**
@ -78,13 +78,13 @@ class image implements Core{
if(isset($opt['name'])){ if(isset($opt['name'])){
$imagesList = $this->listImage(); $imagesList = $this->listImage();
if(isset($imagesList)){ if(isset($imagesList)){
foreach($imagesList as $image){ foreach($imagesList as $image){
if(strcmp($image->name, $opt['name']) == 0){ // if the image name already exists -> error if(strcmp($image->name, $opt['name']) == 0){ // if the image name already exists -> error
$this->app->setOutput("Error", "Image name already exists"); $this->app->setOutput("Error", "Image name already exists");
} }
} }
} }
$options['name'] = $opt['name']; $options['name'] = $opt['name'];
} }
else{ else{
$this->app->setOutput("Error", "Missing parameter 'name' for the new image"); $this->app->setOutput("Error", "Missing parameter 'name' for the new image");
@ -125,15 +125,15 @@ class image implements Core{
$image = $this->libClass->createImage($options); $image = $this->libClass->createImage($options);
}catch(BadResponseError $e){ }catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
}catch(UserInputError $e){ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e); $this->app->getErrorInstance()->UserInputHandler($e);
}catch(BaseError $e){ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e); $this->app->getErrorInstance()->BaseErrorHandler($e);
}catch(NotImplementedError $e){ }catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
}catch(Exception $e){ }catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
$this->app->setOutput("Images", $image); $this->app->setOutput("Images", $image);
} }
@ -152,15 +152,15 @@ class image implements Core{
} }
}catch(BadResponseError $e){ }catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
}catch(UserInputError $e){ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e); $this->app->getErrorInstance()->UserInputHandler($e);
}catch(BaseError $e){ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e); $this->app->getErrorInstance()->BaseErrorHandler($e);
}catch(NotImplementedError $e){ }catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
}catch(Exception $e){ }catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
$this->app->setOutput("Images", $result); $this->app->setOutput("Images", $result);
@ -191,16 +191,16 @@ class image implements Core{
} }
}catch(BadResponseError $e){ }catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
}catch(UserInputError $e){ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e); $this->app->getErrorInstance()->UserInputHandler($e);
}catch(BaseError $e){ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e); $this->app->getErrorInstance()->BaseErrorHandler($e);
}catch(NotImplementedError $e){ }catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
}catch(Exception $e){ }catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
} }
} }
/** /**
@ -254,15 +254,15 @@ class image implements Core{
$image->update($options); $image->update($options);
}catch(BadResponseError $e){ }catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
}catch(UserInputError $e){ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e); $this->app->getErrorInstance()->UserInputHandler($e);
}catch(BaseError $e){ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e); $this->app->getErrorInstance()->BaseErrorHandler($e);
}catch(NotImplementedError $e){ }catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
}catch(Exception $e){ }catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
$this->app->setOutput("Images", $image); $this->app->setOutput("Images", $image);
} }
} }
@ -272,7 +272,7 @@ class image implements Core{
* *
* @param String $id Identifier of the image * @param String $id Identifier of the image
* *
* @return void * @return NULL
*/ */
private function deleteImage(){ private function deleteImage(){
$id = $this->app->getPostParam("id"); $id = $this->app->getPostParam("id");
@ -289,16 +289,16 @@ class image implements Core{
$image->delete(); $image->delete();
}catch(BadResponseError $e){ }catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
}catch(UserInputError $e){ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e); $this->app->getErrorInstance()->UserInputHandler($e);
}catch(BaseError $e){ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e); $this->app->getErrorInstance()->BaseErrorHandler($e);
}catch(NotImplementedError $e){ }catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
}catch(Exception $e){ }catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
} }
} }
/** /**
@ -306,7 +306,7 @@ class image implements Core{
* *
* @param String $id Identifier of the image * @param String $id Identifier of the image
* *
* @return void * @return NULL
*/ */
private function reactivateImage(){ private function reactivateImage(){
$id = $this->app->getPostParam("id"); $id = $this->app->getPostParam("id");
@ -326,16 +326,16 @@ class image implements Core{
$image->reactivate(); $image->reactivate();
}catch(BadResponseError $e){ }catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
}catch(UserInputError $e){ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e); $this->app->getErrorInstance()->UserInputHandler($e);
}catch(BaseError $e){ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e); $this->app->getErrorInstance()->BaseErrorHandler($e);
}catch(NotImplementedError $e){ }catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
}catch(Exception $e){ }catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
} }
} }
/** /**
@ -343,7 +343,7 @@ class image implements Core{
* *
* @param String $id Identifier of the image * @param String $id Identifier of the image
* *
* @return void * @return NULL
*/ */
private function desactivateImage(){ private function desactivateImage(){
$id = $this->app->getPostParam("id"); $id = $this->app->getPostParam("id");
@ -362,16 +362,16 @@ class image implements Core{
$image->deactivate(); $image->deactivate();
}catch(BadResponseError $e){ }catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
}catch(UserInputError $e){ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e); $this->app->getErrorInstance()->UserInputHandler($e);
}catch(BaseError $e){ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e); $this->app->getErrorInstance()->BaseErrorHandler($e);
}catch(NotImplementedError $e){ }catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
}catch(Exception $e){ }catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
} }
} }
/** /**
@ -380,14 +380,14 @@ class image implements Core{
* @param String $id Identifier of the image * @param String $id Identifier of the image
* @param String $file_name Path of the image * @param String $file_name Path of the image
* *
* @return void * @return NULL
*/ */
private function uploadImage(){ private function uploadImage(){
$id = $this->app->getPostParam("id"); $id = $this->app->getPostParam("id");
$file_name = $this->app->getPostParam("file_name"); $file_name = $this->app->getPostParam("file_name");
$file = $this->app->getPostParam("file"); $file = $this->app->getPostParam("file");
error_log(print_r($file, true), 0); error_log(print_r($file, true), 0);
if(!isset($id)){ if(!isset($id)){
$this->app->setOutput("Error", "Incorrect id parameter"); $this->app->setOutput("Error", "Incorrect id parameter");
} }
@ -405,16 +405,16 @@ class image implements Core{
$image->uploadData($stream); $image->uploadData($stream);
}catch(BadResponseError $e){ }catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
}catch(UserInputError $e){ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e); $this->app->getErrorInstance()->UserInputHandler($e);
}catch(BaseError $e){ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e); $this->app->getErrorInstance()->BaseErrorHandler($e);
}catch(NotImplementedError $e){ }catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
}catch(Exception $e){ }catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
} }
} }
/** /**
@ -440,17 +440,17 @@ class image implements Core{
$stream = $image->downloadData(); $stream = $image->downloadData();
}catch(BadResponseError $e){ }catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
}catch(UserInputError $e){ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e); $this->app->getErrorInstance()->UserInputHandler($e);
}catch(BaseError $e){ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e); $this->app->getErrorInstance()->BaseErrorHandler($e);
}catch(NotImplementedError $e){ }catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
}catch(Exception $e){ }catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
$this->app->setOutput("Images", $stream); $this->app->setOutput("Images", $stream);
} }
} }
/** /**
@ -483,16 +483,16 @@ class image implements Core{
$this->app->setOutput("Images", $member_id); $this->app->setOutput("Images", $member_id);
}catch(BadResponseError $e){ }catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
}catch(UserInputError $e){ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e); $this->app->getErrorInstance()->UserInputHandler($e);
}catch(BaseError $e){ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e); $this->app->getErrorInstance()->BaseErrorHandler($e);
}catch(NotImplementedError $e){ }catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
}catch(Exception $e){ }catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
} }
} }
@ -526,15 +526,15 @@ class image implements Core{
} }
}catch(BadResponseError $e){ }catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
}catch(UserInputError $e){ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e); $this->app->getErrorInstance()->UserInputHandler($e);
}catch(BaseError $e){ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e); $this->app->getErrorInstance()->BaseErrorHandler($e);
}catch(NotImplementedError $e){ }catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
}catch(Exception $e){ }catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
$this->app->setOutput("Images", $members); $this->app->setOutput("Images", $members);
} }
} }
@ -572,15 +572,15 @@ class image implements Core{
} }
}catch(BadResponseError $e){ }catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
}catch(UserInputError $e){ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e); $this->app->getErrorInstance()->UserInputHandler($e);
}catch(BaseError $e){ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e); $this->app->getErrorInstance()->BaseErrorHandler($e);
}catch(NotImplementedError $e){ }catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
}catch(Exception $e){ }catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
$this->app->setOutput("Images", $member); $this->app->setOutput("Images", $member);
} }
} }
@ -591,7 +591,7 @@ class image implements Core{
* @param String $image_id Identifier of the image * @param String $image_id Identifier of the image
* @param String $member_id Identifier of the member * @param String $member_id Identifier of the member
* *
* @return void * @return NULL
*/ */
private function removeMemberImage(){ private function removeMemberImage(){
$image_id = $this->app->getPostParam("image_id"); $image_id = $this->app->getPostParam("image_id");
@ -618,16 +618,16 @@ class image implements Core{
$member->delete(); $member->delete();
}catch(BadResponseError $e){ }catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
}catch(UserInputError $e){ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e); $this->app->getErrorInstance()->UserInputHandler($e);
}catch(BaseError $e){ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e); $this->app->getErrorInstance()->BaseErrorHandler($e);
}catch(NotImplementedError $e){ }catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
}catch(Exception $e){ }catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
} }
} }
/** /**
@ -637,7 +637,7 @@ class image implements Core{
* @param String $member_id Identifier of the member * @param String $member_id Identifier of the member
* @param String $status New status for the member * @param String $status New status for the member
* *
* @return void * @return NULL
**/ **/
private function updateMemberImage(){ private function updateMemberImage(){
$image_id = $this->app->getPostParam("image_id"); $image_id = $this->app->getPostParam("image_id");
@ -665,16 +665,16 @@ class image implements Core{
$member->updateStatus($status); $member->updateStatus($status);
}catch(BadResponseError $e){ }catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
}catch(UserInputError $e){ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e); $this->app->getErrorInstance()->UserInputHandler($e);
}catch(BaseError $e){ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e); $this->app->getErrorInstance()->BaseErrorHandler($e);
}catch(NotImplementedError $e){ }catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
}catch(Exception $e){ }catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
} }
} }
} }

View file

@ -22,33 +22,33 @@ class genTokenOptions
$this->stack = HandlerStack::create(); $this->stack = HandlerStack::create();
$httpClient = new Client([ $httpClient = new Client([
'base_uri' => Utils::normalizeUrl($options['authUrl']), 'base_uri' => Utils::normalizeUrl($options['authUrl']),
'handler' => $this->stack, 'handler' => $this->stack,
]); ]);
$this->httpClient = $httpClient; $this->httpClient = $httpClient;
$options['identityService'] = Service::factory($httpClient); $options['identityService'] = Service::factory($httpClient);
$options['authHandler'] = function () use ($options) { $options['authHandler'] = function () use ($options) {
return $options['identityService']->generateToken($options); return $options['identityService']->generateToken($options);
}; };
$this->optionsGlobal['Common'] = $options; $this->optionsGlobal['Common'] = $options;
} }
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
*/ */
private function addDebugMiddleware(array $options, HandlerStack &$stack) private function addDebugMiddleware(array $options, HandlerStack &$stack)
{ {
if (!empty($options['debugLog']) if (!empty($options['debugLog'])
&& !empty($options['logger']) && !empty($options['logger'])
&& !empty($options['messageFormatter']) && !empty($options['messageFormatter'])
) { ) {
$stack->push(GuzzleMiddleware::log($options['logger'], $options['messageFormatter'])); $stack->push(GuzzleMiddleware::log($options['logger'], $options['messageFormatter']));
} }
} }
public function checkToken(){ public function checkToken(){
//error_log(print_r($this->backup['time'], true), 0); //error_log(print_r($this->backup['time'], true), 0);
@ -73,9 +73,9 @@ class genTokenOptions
$this->addDebugMiddleware($options, $stack); $this->addDebugMiddleware($options, $stack);
$options['httpClient'] = new Client([ $options['httpClient'] = new Client([
'base_uri' => Utils::normalizeUrl($baseUrl), 'base_uri' => Utils::normalizeUrl($baseUrl),
'handler' => $stack, 'handler' => $stack,
]); ]);
$this->saveBackup('Identity', array('token' => $token, 'baseUrl' => $baseUrl )); $this->saveBackup('Identity', array('token' => $token, 'baseUrl' => $baseUrl ));
$this->optionsGlobal['Identity'] = $options; $this->optionsGlobal['Identity'] = $options;
@ -98,15 +98,15 @@ class genTokenOptions
$baseUrl = $this->backup['Identity']['baseUrl']; $baseUrl = $this->backup['Identity']['baseUrl'];
$stack = HandlerStack::create(); $stack = HandlerStack::create();
$stack->push(Middleware::authHandler($options['authHandler'], $token)); $stack->push(Middleware::authHandler($options['authHandler'], $token));
$this->addDebugMiddleware($options, $stack); $this->addDebugMiddleware($options, $stack);
$options['httpClient'] = new Client([ $options['httpClient'] = new Client([
'base_uri' => Utils::normalizeUrl($baseUrl), 'base_uri' => Utils::normalizeUrl($baseUrl),
'handler' => $stack, 'handler' => $stack,
]); ]);
$this->saveBackup('Identity', array('token' => $token, 'baseUrl' => $baseUrl )); $this->saveBackup('Identity', array('token' => $token, 'baseUrl' => $baseUrl ));
$this->optionsGlobal['Identity'] = $options; $this->optionsGlobal['Identity'] = $options;
@ -122,14 +122,14 @@ class genTokenOptions
$stack = HandlerStack::create(); $stack = HandlerStack::create();
$stack->push(Middleware::authHandler($options['authHandler'], $token)); $stack->push(Middleware::authHandler($options['authHandler'], $token));
$this->addDebugMiddleware($options, $stack); $this->addDebugMiddleware($options, $stack);
$options['httpClient'] = new Client([ $options['httpClient'] = new Client([
'base_uri' => Utils::normalizeUrl($baseUrl), 'base_uri' => Utils::normalizeUrl($baseUrl),
'handler' => $stack, 'handler' => $stack,
]); ]);
$this->saveBackup('Image', array('token' => $token, 'baseUrl' => $baseUrl )); $this->saveBackup('Image', array('token' => $token, 'baseUrl' => $baseUrl ));
$this->optionsGlobal['Image'] = $options; $this->optionsGlobal['Image'] = $options;
@ -150,7 +150,7 @@ class genTokenOptions
$this->backup['Image'] = $opt; $this->backup['Image'] = $opt;
$token = $this->unserializeToken($this->backup['Image']['token']); $token = $this->unserializeToken($this->backup['Image']['token']);
$baseUrl = $this->backup['Image']['baseUrl']; $baseUrl = $this->backup['Image']['baseUrl'];
$stack = HandlerStack::create(); $stack = HandlerStack::create();
$stack->push(Middleware::authHandler($options['authHandler'], $token)); $stack->push(Middleware::authHandler($options['authHandler'], $token));
@ -158,9 +158,9 @@ class genTokenOptions
$this->addDebugMiddleware($options, $stack); $this->addDebugMiddleware($options, $stack);
$options['httpClient'] = new Client([ $options['httpClient'] = new Client([
'base_uri' => Utils::normalizeUrl($baseUrl), 'base_uri' => Utils::normalizeUrl($baseUrl),
'handler' => $stack, 'handler' => $stack,
]); ]);
$this->saveBackup('Image', array('token' => $token, 'baseUrl' => $baseUrl )); $this->saveBackup('Image', array('token' => $token, 'baseUrl' => $baseUrl ));
$this->optionsGlobal['Image'] = $options; $this->optionsGlobal['Image'] = $options;
} }
@ -175,14 +175,14 @@ class genTokenOptions
$stack = HandlerStack::create(); $stack = HandlerStack::create();
$stack->push(Middleware::authHandler($options['authHandler'], $token)); $stack->push(Middleware::authHandler($options['authHandler'], $token));
$this->addDebugMiddleware($options, $stack); $this->addDebugMiddleware($options, $stack);
$options['httpClient'] = new Client([ $options['httpClient'] = new Client([
'base_uri' => Utils::normalizeUrl($baseUrl), 'base_uri' => Utils::normalizeUrl($baseUrl),
'handler' => $stack, 'handler' => $stack,
]); ]);
$this->saveBackup('Network', array('token' => $token, 'baseUrl' => $baseUrl )); $this->saveBackup('Network', array('token' => $token, 'baseUrl' => $baseUrl ));
$this->optionsGlobal['Network'] = $options; $this->optionsGlobal['Network'] = $options;
@ -203,17 +203,17 @@ class genTokenOptions
$this->backup['Network'] = $opt; $this->backup['Network'] = $opt;
$token = $this->unserializeToken($this->backup['Network']['token']); $token = $this->unserializeToken($this->backup['Network']['token']);
$baseUrl = $this->backup['Network']['baseUrl']; $baseUrl = $this->backup['Network']['baseUrl'];
$stack = HandlerStack::create(); $stack = HandlerStack::create();
$stack->push(Middleware::authHandler($options['authHandler'], $token)); $stack->push(Middleware::authHandler($options['authHandler'], $token));
$this->addDebugMiddleware($options, $stack); $this->addDebugMiddleware($options, $stack);
$options['httpClient'] = new Client([ $options['httpClient'] = new Client([
'base_uri' => Utils::normalizeUrl($baseUrl), 'base_uri' => Utils::normalizeUrl($baseUrl),
'handler' => $stack, 'handler' => $stack,
]); ]);
$this->saveBackup('Network', array('token' => $token, 'baseUrl' => $baseUrl )); $this->saveBackup('Network', array('token' => $token, 'baseUrl' => $baseUrl ));
$this->optionsGlobal['Network'] = $options; $this->optionsGlobal['Network'] = $options;
} }
@ -228,14 +228,14 @@ class genTokenOptions
$stack = HandlerStack::create(); $stack = HandlerStack::create();
$stack->push(Middleware::authHandler($options['authHandler'], $token)); $stack->push(Middleware::authHandler($options['authHandler'], $token));
$this->addDebugMiddleware($options, $stack); $this->addDebugMiddleware($options, $stack);
$options['httpClient'] = new Client([ $options['httpClient'] = new Client([
'base_uri' => Utils::normalizeUrl($baseUrl), 'base_uri' => Utils::normalizeUrl($baseUrl),
'handler' => $stack, 'handler' => $stack,
]); ]);
$this->saveBackup('Compute', array('token' => $token, 'baseUrl' => $baseUrl )); $this->saveBackup('Compute', array('token' => $token, 'baseUrl' => $baseUrl ));
$this->optionsGlobal['Compute'] = $options; $this->optionsGlobal['Compute'] = $options;
@ -257,17 +257,17 @@ class genTokenOptions
$this->backup['Compute'] = $opt; $this->backup['Compute'] = $opt;
$token = $this->unserializeToken($this->backup['Compute']['token']); $token = $this->unserializeToken($this->backup['Compute']['token']);
$baseUrl = $this->backup['Compute']['baseUrl']; $baseUrl = $this->backup['Compute']['baseUrl'];
$stack = HandlerStack::create(); $stack = HandlerStack::create();
$stack->push(Middleware::authHandler($options['authHandler'], $token)); $stack->push(Middleware::authHandler($options['authHandler'], $token));
$this->addDebugMiddleware($options, $stack); $this->addDebugMiddleware($options, $stack);
$options['httpClient'] = new Client([ $options['httpClient'] = new Client([
'base_uri' => Utils::normalizeUrl($baseUrl), 'base_uri' => Utils::normalizeUrl($baseUrl),
'handler' => $stack, 'handler' => $stack,
]); ]);
$this->saveBackup('Compute', array('token' => $token, 'baseUrl' => $baseUrl )); $this->saveBackup('Compute', array('token' => $token, 'baseUrl' => $baseUrl ));
$this->optionsGlobal['Compute'] = $options; $this->optionsGlobal['Compute'] = $options;
} }
@ -426,7 +426,7 @@ class genTokenOptions
$token->user->description = unserialize($this->backup["user"]["description"]); $token->user->description = unserialize($this->backup["user"]["description"]);
$token->issued = unserialize($tokenSerialized["issued"]); $token->issued = unserialize($tokenSerialized["issued"]);
$token->id = unserialize($tokenSerialized["id"]); $token->id = unserialize($tokenSerialized["id"]);
return $token; return $token;
} }
} }

View file

@ -22,9 +22,9 @@ use OpenCloud\Common\Error\UserInputError;
*/ */
class network{ class network{
/** @var App $app protected, contains the main app object */ /** @var App $app protected, contains the main app object */
protected $app; protected $app;
/** @var OpenStack\Network $libClass protected, contains the library Network object */ /** @var OpenStack\Network $libClass protected, contains the library Network object */
protected $libClass; protected $libClass;
@ -49,11 +49,11 @@ class network{
* *
* @param String $action name of another function of this class * @param String $action name of another function of this class
* *
* @return void * @return NULL
*/ */
public function action($action){ public function action($action){
$this->{$action.""}(); $this->{$action.""}();
} }
@ -65,7 +65,7 @@ class network{
* @param String shared Specifies whether the network resource can be accessed by any tenant * @param String shared Specifies whether the network resource can be accessed by any tenant
* @param String tenantId Owner of network. Only admin users can specify a tenant ID other than their own * @param String tenantId Owner of network. Only admin users can specify a tenant ID other than their own
* *
* @return void * @return NULL
*/ */
private function create_network() private function create_network()
{ {
@ -102,19 +102,19 @@ class network{
catch(BadResponseError $e) catch(BadResponseError $e)
{ {
$this->app->getErrorInstance->BadResponseHandler($e); $this->app->getErrorInstance->BadResponseHandler($e);
} }
catch(UserInputError $e) catch(UserInputError $e)
{ {
$this->app->getErrorInstance->UserInputHandler($e); $this->app->getErrorInstance->UserInputHandler($e);
} }
catch(BaseError $e) catch(BaseError $e)
{ {
$this->app->getErrorInstance->BaseErrorHandler($e); $this->app->getErrorInstance->BaseErrorHandler($e);
} }
catch(NotImplementedError $e) catch(NotImplementedError $e)
{ {
$this->app->getErrorInstance->NotImplementedHandler($e); $this->app->getErrorInstance->NotImplementedHandler($e);
} }
} }
@ -136,7 +136,7 @@ class network{
* *
* *
* *
* @return void * @return NULL
*/ */
private function create_subnet() private function create_subnet()
@ -200,24 +200,24 @@ class network{
try try
{ {
$subnet = $this->libClass->createSubnet($options); $subnet = $this->libClass->createSubnet($options);
} }
catch(BadResponseError $e) catch(BadResponseError $e)
{ {
$this->app->getErrorInstance->BadResponseHandler($e); $this->app->getErrorInstance->BadResponseHandler($e);
} }
catch(UserInputError $e) catch(UserInputError $e)
{ {
$this->app->getErrorInstance->UserInputHandler($e); $this->app->getErrorInstance->UserInputHandler($e);
} }
catch(BaseError $e) catch(BaseError $e)
{ {
$this->app->getErrorInstance->BaseErrorHandler($e); $this->app->getErrorInstance->BaseErrorHandler($e);
} }
catch(NotImplementedError $e) catch(NotImplementedError $e)
{ {
$this->app->getErrorInstance->NotImplementedHandler($e); $this->app->getErrorInstance->NotImplementedHandler($e);
} }
} }
@ -233,36 +233,36 @@ class network{
try try
{ {
$ln = $this->libClass->listNetworks(); $ln = $this->libClass->listNetworks();
$list_ids = array(); $list_ids = array();
foreach($ln as $n) foreach($ln as $n)
{ {
$list_ids[] = $n->id; $list_ids[] = $n->id;
} }
} }
catch(BadResponseError $e) catch(BadResponseError $e)
{ {
$this->app->getErrorInstance->BadResponseHandler($e); $this->app->getErrorInstance->BadResponseHandler($e);
} }
catch(UserInputError $e) catch(UserInputError $e)
{ {
$this->app->getErrorInstance->UserInputHandler($e); $this->app->getErrorInstance->UserInputHandler($e);
} }
catch(BaseError $e) catch(BaseError $e)
{ {
$this->app->getErrorInstance->BaseErrorHandler($e); $this->app->getErrorInstance->BaseErrorHandler($e);
} }
catch(NotImplementedError $e) catch(NotImplementedError $e)
{ {
$this->app->getErrorInstance->NotImplementedHandler($e); $this->app->getErrorInstance->NotImplementedHandler($e);
} }
$this->app->setOutput("ListNetworkIds", $list_ids); $this->app->setOutput("ListNetworkIds", $list_ids);
} }
/** /**
@ -276,37 +276,37 @@ class network{
try try
{ {
$ln = $this->libClass->listNetworks(); $ln = $this->libClass->listNetworks();
$list_names = array(); $list_names = array();
foreach($ln as $n) foreach($ln as $n)
{ {
$list_names[] = $n->name; $list_names[] = $n->name;
} }
} }
catch(BadResponseError $e) catch(BadResponseError $e)
{ {
$this->app->getErrorInstance->BadResponseHandler($e); $this->app->getErrorInstance->BadResponseHandler($e);
} }
catch(UserInputError $e) catch(UserInputError $e)
{ {
$this->app->getErrorInstance->UserInputHandler($e); $this->app->getErrorInstance->UserInputHandler($e);
} }
catch(BaseError $e) catch(BaseError $e)
{ {
$this->app->getErrorInstance->BaseErrorHandler($e); $this->app->getErrorInstance->BaseErrorHandler($e);
} }
catch(NotImplementedError $e) catch(NotImplementedError $e)
{ {
$this->app->getErrorInstance->NotImplementedHandler($e); $this->app->getErrorInstance->NotImplementedHandler($e);
} }
$this->app->setOutput("ListNetworkNames", $list_names); $this->app->setOutput("ListNetworkNames", $list_names);
} }
/** /**
* List the CIDR of the SUBNETS * List the CIDR of the SUBNETS
@ -317,32 +317,32 @@ class network{
{ {
try try
{ {
$ls = $this->libClass->listSubnets(); $ls = $this->libClass->listSubnets();
$list_cidr = array(); $list_cidr = array();
foreach ($ls as $subnet) foreach ($ls as $subnet)
{ {
$list_cidr[] = $subnet->cidr; $list_cidr[] = $subnet->cidr;
} }
$this->app->setOutput("ListCidr", $list_cidr); $this->app->setOutput("ListCidr", $list_cidr);
} }
catch(BadResponseError $e) catch(BadResponseError $e)
{ {
$this->app->getErrorInstance->BadResponseHandler($e); $this->app->getErrorInstance->BadResponseHandler($e);
} }
catch(UserInputError $e) catch(UserInputError $e)
{ {
$this->app->getErrorInstance->UserInputHandler($e); $this->app->getErrorInstance->UserInputHandler($e);
} }
catch(BaseError $e) catch(BaseError $e)
{ {
$this->app->getErrorInstance->BaseErrorHandler($e); $this->app->getErrorInstance->BaseErrorHandler($e);
} }
catch(NotImplementedError $e) catch(NotImplementedError $e)
{ {
$this->app->getErrorInstance->NotImplementedHandler($e); $this->app->getErrorInstance->NotImplementedHandler($e);
} }
} }
/** /**
* retrieve a specific network * retrieve a specific network
@ -364,21 +364,21 @@ class network{
catch(BadResponseError $e) catch(BadResponseError $e)
{ {
$this->app->getErrorInstance->BadResponseHandler($e); $this->app->getErrorInstance->BadResponseHandler($e);
} }
catch(UserInputError $e) catch(UserInputError $e)
{ {
$this->app->getErrorInstance->UserInputHandler($e); $this->app->getErrorInstance->UserInputHandler($e);
} }
catch(BaseError $e) catch(BaseError $e)
{ {
$this->app->getErrorInstance->BaseErrorHandler($e); $this->app->getErrorInstance->BaseErrorHandler($e);
} }
catch(NotImplementedError $e) catch(NotImplementedError $e)
{ {
$this->app->getErrorInstance->NotImplementedHandler($e); $this->app->getErrorInstance->NotImplementedHandler($e);
} }
$this->app->setOutput("Network", $network); $this->app->setOutput("Network", $network);
} }
/** /**
@ -401,21 +401,21 @@ class network{
catch(BadResponseError $e) catch(BadResponseError $e)
{ {
$this->app->getErrorInstance->BadResponseHandler($e); $this->app->getErrorInstance->BadResponseHandler($e);
} }
catch(UserInputError $e) catch(UserInputError $e)
{ {
$this->app->getErrorInstance->UserInputHandler($e); $this->app->getErrorInstance->UserInputHandler($e);
} }
catch(BaseError $e) catch(BaseError $e)
{ {
$this->app->getErrorInstance->BaseErrorHandler($e); $this->app->getErrorInstance->BaseErrorHandler($e);
} }
catch(NotImplementedError $e) catch(NotImplementedError $e)
{ {
$this->app->getErrorInstance->NotImplementedHandler($e); $this->app->getErrorInstance->NotImplementedHandler($e);
} }
return $network; return $network;
} }
/** /**
@ -437,21 +437,21 @@ class network{
catch(BadResponseError $e) catch(BadResponseError $e)
{ {
$this->app->getErrorInstance->BadResponseHandler($e); $this->app->getErrorInstance->BadResponseHandler($e);
} }
catch(UserInputError $e) catch(UserInputError $e)
{ {
$this->app->getErrorInstance->UserInputHandler($e); $this->app->getErrorInstance->UserInputHandler($e);
} }
catch(BaseError $e) catch(BaseError $e)
{ {
$this->app->getErrorInstance->BaseErrorHandler($e); $this->app->getErrorInstance->BaseErrorHandler($e);
} }
catch(NotImplementedError $e) catch(NotImplementedError $e)
{ {
$this->app->getErrorInstance->NotImplementedHandler($e); $this->app->getErrorInstance->NotImplementedHandler($e);
} }
$this->app->setOutput("Subnet", subnet); $this->app->setOutput("Subnet", subnet);
} }
/** /**
* internal function * internal function
@ -472,21 +472,21 @@ class network{
catch(BadResponseError $e) catch(BadResponseError $e)
{ {
$this->app->getErrorInstance->BadResponseHandler($e); $this->app->getErrorInstance->BadResponseHandler($e);
} }
catch(UserInputError $e) catch(UserInputError $e)
{ {
$this->app->getErrorInstance->UserInputHandler($e); $this->app->getErrorInstance->UserInputHandler($e);
} }
catch(BaseError $e) catch(BaseError $e)
{ {
$this->app->getErrorInstance->BaseErrorHandler($e); $this->app->getErrorInstance->BaseErrorHandler($e);
} }
catch(NotImplementedError $e) catch(NotImplementedError $e)
{ {
$this->app->getErrorInstance->NotImplementedHandler($e); $this->app->getErrorInstance->NotImplementedHandler($e);
} }
return $subnet; return $subnet;
} }
/** /**
@ -498,11 +498,11 @@ class network{
* @param String tenantId Owner of network. Only admin users can specify a tenant ID other than their own * @param String tenantId Owner of network. Only admin users can specify a tenant ID other than their own
* *
* *
* @return void * @return NULL
**/ **/
private function updateNetwork() private function updateNetwork()
{ {
$options = array(); $options = array();
$name = $this->app->getPostParam("name"); $name = $this->app->getPostParam("name");
$shared = $this->app->getPostParam("shared"); $shared = $this->app->getPostParam("shared");
@ -524,25 +524,25 @@ class network{
{ {
$networkId = $this->app->getPostParam("networkId"); $networkId = $this->app->getPostParam("networkId");
$network = getNetworkP($networkId); $network = getNetworkP($networkId);
$network->update($options); $network->update($options);
} }
catch(BadResponseError $e) catch(BadResponseError $e)
{ {
$this->app->getErrorInstance->BadResponseHandler($e); $this->app->getErrorInstance->BadResponseHandler($e);
} }
catch(UserInputError $e) catch(UserInputError $e)
{ {
$this->app->getErrorInstance->UserInputHandler($e); $this->app->getErrorInstance->UserInputHandler($e);
} }
catch(BaseError $e) catch(BaseError $e)
{ {
$this->app->getErrorInstance->BaseErrorHandler($e); $this->app->getErrorInstance->BaseErrorHandler($e);
} }
catch(NotImplementedError $e) catch(NotImplementedError $e)
{ {
$this->app->getErrorInstance->NotImplementedHandler($e); $this->app->getErrorInstance->NotImplementedHandler($e);
} }
} }
/** /**
@ -561,11 +561,11 @@ class network{
* @param String allocationPools Subranges of the CIDR available for dynamic allocation to ports * @param String allocationPools Subranges of the CIDR available for dynamic allocation to ports
* *
* *
* @return void * @return NULL
**/ **/
private function updateSubnet() private function updateSubnet()
{ {
$options = array(); $options = array();
$name = $this->app->getPostParam("name"); $name = $this->app->getPostParam("name");
$networkId = $this->app->getPostParam("networkId"); $networkId = $this->app->getPostParam("networkId");
@ -596,19 +596,19 @@ class network{
catch(BadResponseError $e) catch(BadResponseError $e)
{ {
$this->app->getErrorInstance->BadResponseHandler($e); $this->app->getErrorInstance->BadResponseHandler($e);
} }
catch(UserInputError $e) catch(UserInputError $e)
{ {
$this->app->getErrorInstance->UserInputHandler($e); $this->app->getErrorInstance->UserInputHandler($e);
} }
catch(BaseError $e) catch(BaseError $e)
{ {
$this->app->getErrorInstance->BaseErrorHandler($e); $this->app->getErrorInstance->BaseErrorHandler($e);
} }
catch(NotImplementedError $e) catch(NotImplementedError $e)
{ {
$this->app->getErrorInstance->NotImplementedHandler($e); $this->app->getErrorInstance->NotImplementedHandler($e);
} }
} }
/** /**
@ -617,10 +617,10 @@ class network{
* @param String networkId ID if network which we want to delete * @param String networkId ID if network which we want to delete
* *
* *
* @return void * @return NULL
**/ **/
private function deleteNetwork() private function deleteNetwork()
{ {
try try
{ {
$networkId = $this->app->getPostParam("networkId"); $networkId = $this->app->getPostParam("networkId");
@ -630,19 +630,19 @@ class network{
catch(BadResponseError $e) catch(BadResponseError $e)
{ {
$this->app->getErrorInstance->BadResponseHandler($e); $this->app->getErrorInstance->BadResponseHandler($e);
} }
catch(UserInputError $e) catch(UserInputError $e)
{ {
$this->app->getErrorInstance->UserInputHandler($e); $this->app->getErrorInstance->UserInputHandler($e);
} }
catch(BaseError $e) catch(BaseError $e)
{ {
$this->app->getErrorInstance->BaseErrorHandler($e); $this->app->getErrorInstance->BaseErrorHandler($e);
} }
catch(NotImplementedError $e) catch(NotImplementedError $e)
{ {
$this->app->getErrorInstance->NotImplementedHandler($e); $this->app->getErrorInstance->NotImplementedHandler($e);
} }
} }
/** /**
@ -651,10 +651,10 @@ class network{
* @param String subnetId ID if network which we want to delete * @param String subnetId ID if network which we want to delete
* *
* *
* @return void * @return NULL
**/ **/
private function deleteSubnet() private function deleteSubnet()
{ {
try try
{ {
$subnetId = $this->app->getPostParam("subnetId"); $subnetId = $this->app->getPostParam("subnetId");
@ -664,19 +664,19 @@ class network{
catch(BadResponseError $e) catch(BadResponseError $e)
{ {
$this->app->getErrorInstance->BadResponseHandler($e); $this->app->getErrorInstance->BadResponseHandler($e);
} }
catch(UserInputError $e) catch(UserInputError $e)
{ {
$this->app->getErrorInstance->UserInputHandler($e); $this->app->getErrorInstance->UserInputHandler($e);
} }
catch(BaseError $e) catch(BaseError $e)
{ {
$this->app->getErrorInstance->BaseErrorHandler($e); $this->app->getErrorInstance->BaseErrorHandler($e);
} }
catch(NotImplementedError $e) catch(NotImplementedError $e)
{ {
$this->app->getErrorInstance->NotImplementedHandler($e); $this->app->getErrorInstance->NotImplementedHandler($e);
} }
} }
/** /**
@ -692,7 +692,7 @@ class network{
* @param String securityGroups Specifies the IDs of any security groups associated with this port * @param String securityGroups Specifies the IDs of any security groups associated with this port
* @param String tenantId Owner of the port. Only admin users can specify a tenant ID other than their own. * @param String tenantId Owner of the port. Only admin users can specify a tenant ID other than their own.
* *
* @return void * @return NULL
*/ */
private function createPort() private function createPort()
@ -751,19 +751,19 @@ class network{
catch(BadResponseError $e) catch(BadResponseError $e)
{ {
$this->app->getErrorInstance->BadResponseHandler($e); $this->app->getErrorInstance->BadResponseHandler($e);
} }
catch(UserInputError $e) catch(UserInputError $e)
{ {
$this->app->getErrorInstance->UserInputHandler($e); $this->app->getErrorInstance->UserInputHandler($e);
} }
catch(BaseError $e) catch(BaseError $e)
{ {
$this->app->getErrorInstance->BaseErrorHandler($e); $this->app->getErrorInstance->BaseErrorHandler($e);
} }
catch(NotImplementedError $e) catch(NotImplementedError $e)
{ {
$this->app->getErrorInstance->NotImplementedHandler($e); $this->app->getErrorInstance->NotImplementedHandler($e);
} }
} }
/** /**
@ -781,19 +781,19 @@ class network{
catch(BadResponseError $e) catch(BadResponseError $e)
{ {
$this->app->getErrorInstance->BadResponseHandler($e); $this->app->getErrorInstance->BadResponseHandler($e);
} }
catch(UserInputError $e) catch(UserInputError $e)
{ {
$this->app->getErrorInstance->UserInputHandler($e); $this->app->getErrorInstance->UserInputHandler($e);
} }
catch(BaseError $e) catch(BaseError $e)
{ {
$this->app->getErrorInstance->BaseErrorHandler($e); $this->app->getErrorInstance->BaseErrorHandler($e);
} }
catch(NotImplementedError $e) catch(NotImplementedError $e)
{ {
$this->app->getErrorInstance->NotImplementedHandler($e); $this->app->getErrorInstance->NotImplementedHandler($e);
} }
} }
/** /**
@ -813,20 +813,20 @@ class network{
catch(BadResponseError $e) catch(BadResponseError $e)
{ {
$this->app->getErrorInstance->BadResponseHandler($e); $this->app->getErrorInstance->BadResponseHandler($e);
} }
catch(UserInputError $e) catch(UserInputError $e)
{ {
$this->app->getErrorInstance->UserInputHandler($e); $this->app->getErrorInstance->UserInputHandler($e);
} }
catch(BaseError $e) catch(BaseError $e)
{ {
$this->app->getErrorInstance->BaseErrorHandler($e); $this->app->getErrorInstance->BaseErrorHandler($e);
} }
catch(NotImplementedError $e) catch(NotImplementedError $e)
{ {
$this->app->getErrorInstance->NotImplementedHandler($e); $this->app->getErrorInstance->NotImplementedHandler($e);
} }
} }
/** /**
@ -846,20 +846,20 @@ class network{
catch(BadResponseError $e) catch(BadResponseError $e)
{ {
$this->app->getErrorInstance->BadResponseHandler($e); $this->app->getErrorInstance->BadResponseHandler($e);
} }
catch(UserInputError $e) catch(UserInputError $e)
{ {
$this->app->getErrorInstance->UserInputHandler($e); $this->app->getErrorInstance->UserInputHandler($e);
} }
catch(BaseError $e) catch(BaseError $e)
{ {
$this->app->getErrorInstance->BaseErrorHandler($e); $this->app->getErrorInstance->BaseErrorHandler($e);
} }
catch(NotImplementedError $e) catch(NotImplementedError $e)
{ {
$this->app->getErrorInstance->NotImplementedHandler($e); $this->app->getErrorInstance->NotImplementedHandler($e);
} }
} }
@ -876,7 +876,7 @@ class network{
* @param String securityGroups Specifies the IDs of any security groups associated with this port * @param String securityGroups Specifies the IDs of any security groups associated with this port
* @param String tenantId Owner of the port. Only admin users can specify a tenant ID other than their own. * @param String tenantId Owner of the port. Only admin users can specify a tenant ID other than their own.
* *
* @return void * @return NULL
*/ */
private function updatePort() private function updatePort()
{ {
@ -935,28 +935,28 @@ class network{
catch(BadResponseError $e) catch(BadResponseError $e)
{ {
$this->app->getErrorInstance->BadResponseHandler($e); $this->app->getErrorInstance->BadResponseHandler($e);
} }
catch(UserInputError $e) catch(UserInputError $e)
{ {
$this->app->getErrorInstance->UserInputHandler($e); $this->app->getErrorInstance->UserInputHandler($e);
} }
catch(BaseError $e) catch(BaseError $e)
{ {
$this->app->getErrorInstance->BaseErrorHandler($e); $this->app->getErrorInstance->BaseErrorHandler($e);
} }
catch(NotImplementedError $e) catch(NotImplementedError $e)
{ {
$this->app->getErrorInstance->NotImplementedHandler($e); $this->app->getErrorInstance->NotImplementedHandler($e);
} }
} }
/** /**
* Delete a port given * Delete a port given
* *
* @param String portId id of port which we wante to delete * @param String portId id of port which we wante to delete
* @return void * @return NULL
*/ */
private function deletePort() private function deletePort()
{ {
try try
{ {
@ -967,19 +967,19 @@ class network{
catch(BadResponseError $e) catch(BadResponseError $e)
{ {
$this->app->getErrorInstance->BadResponseHandler($e); $this->app->getErrorInstance->BadResponseHandler($e);
} }
catch(UserInputError $e) catch(UserInputError $e)
{ {
$this->app->getErrorInstance->UserInputHandler($e); $this->app->getErrorInstance->UserInputHandler($e);
} }
catch(BaseError $e) catch(BaseError $e)
{ {
$this->app->getErrorInstance->BaseErrorHandler($e); $this->app->getErrorInstance->BaseErrorHandler($e);
} }
catch(NotImplementedError $e) catch(NotImplementedError $e)
{ {
$this->app->getErrorInstance->NotImplementedHandler($e); $this->app->getErrorInstance->NotImplementedHandler($e);
} }
} }
/** /**
@ -988,7 +988,7 @@ class network{
* @param String name A human-readable name for the security group. This name might not be unique * @param String name A human-readable name for the security group. This name might not be unique
* @param String description Description of the security group * @param String description Description of the security group
* *
* @return void * @return NULL
*/ */
private function createSecurityGroup() private function createSecurityGroup()
@ -1012,20 +1012,20 @@ class network{
catch(BadResponseError $e) catch(BadResponseError $e)
{ {
$this->app->getErrorInstance->BadResponseHandler($e); $this->app->getErrorInstance->BadResponseHandler($e);
} }
catch(UserInputError $e) catch(UserInputError $e)
{ {
$this->app->getErrorInstance->UserInputHandler($e); $this->app->getErrorInstance->UserInputHandler($e);
} }
catch(BaseError $e) catch(BaseError $e)
{ {
$this->app->getErrorInstance->BaseErrorHandler($e); $this->app->getErrorInstance->BaseErrorHandler($e);
} }
catch(NotImplementedError $e) catch(NotImplementedError $e)
{ {
$this->app->getErrorInstance->NotImplementedHandler($e); $this->app->getErrorInstance->NotImplementedHandler($e);
} }
} }
/** /**
@ -1040,7 +1040,7 @@ class network{
*@param String remoteGroupId The remote group ID to be associated with this security group rule. You can specify either remoteGroupId or remoteGroupPrefix *@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 remoteIpPrefix The remote IP prefix to be associated with this security group rule. You can specify either remoteGroupId or remoteGroupPrefix
* *
* @return void * @return NULL
*/ */
private function createSecurityGroupRule() private function createSecurityGroupRule()
{ {
@ -1093,19 +1093,19 @@ class network{
catch(BadResponseError $e) catch(BadResponseError $e)
{ {
$this->app->getErrorInstance->BadResponseHandler($e); $this->app->getErrorInstance->BadResponseHandler($e);
} }
catch(UserInputError $e) catch(UserInputError $e)
{ {
$this->app->getErrorInstance->UserInputHandler($e); $this->app->getErrorInstance->UserInputHandler($e);
} }
catch(BaseError $e) catch(BaseError $e)
{ {
$this->app->getErrorInstance->BaseErrorHandler($e); $this->app->getErrorInstance->BaseErrorHandler($e);
} }
catch(NotImplementedError $e) catch(NotImplementedError $e)
{ {
$this->app->getErrorInstance->NotImplementedHandler($e); $this->app->getErrorInstance->NotImplementedHandler($e);
} }
} }
@ -1124,19 +1124,19 @@ class network{
catch(BadResponseError $e) catch(BadResponseError $e)
{ {
$this->app->getErrorInstance->BadResponseHandler($e); $this->app->getErrorInstance->BadResponseHandler($e);
} }
catch(UserInputError $e) catch(UserInputError $e)
{ {
$this->app->getErrorInstance->UserInputHandler($e); $this->app->getErrorInstance->UserInputHandler($e);
} }
catch(BaseError $e) catch(BaseError $e)
{ {
$this->app->getErrorInstance->BaseErrorHandler($e); $this->app->getErrorInstance->BaseErrorHandler($e);
} }
catch(NotImplementedError $e) catch(NotImplementedError $e)
{ {
$this->app->getErrorInstance->NotImplementedHandler($e); $this->app->getErrorInstance->NotImplementedHandler($e);
} }
} }
@ -1150,26 +1150,26 @@ class network{
{ {
try try
{ {
$this->app->setOutput("listSecurityGroupeRule", $this->libClass->listSecurityGroupRules()); $this->app->setOutput("listSecurityGroupeRule", $this->libClass->listSecurityGroupRules());
} }
catch(BadResponseError $e) catch(BadResponseError $e)
{ {
$this->app->getErrorInstance->BadResponseHandler($e); $this->app->getErrorInstance->BadResponseHandler($e);
} }
catch(UserInputError $e) catch(UserInputError $e)
{ {
$this->app->getErrorInstance->UserInputHandler($e); $this->app->getErrorInstance->UserInputHandler($e);
} }
catch(BaseError $e) catch(BaseError $e)
{ {
$this->app->getErrorInstance->BaseErrorHandler($e); $this->app->getErrorInstance->BaseErrorHandler($e);
} }
catch(NotImplementedError $e) catch(NotImplementedError $e)
{ {
$this->app->getErrorInstance->NotImplementedHandler($e); $this->app->getErrorInstance->NotImplementedHandler($e);
} }
} }
/** /**
@ -1189,20 +1189,20 @@ class network{
catch(BadResponseError $e) catch(BadResponseError $e)
{ {
$this->app->getErrorInstance->BadResponseHandler($e); $this->app->getErrorInstance->BadResponseHandler($e);
} }
catch(UserInputError $e) catch(UserInputError $e)
{ {
$this->app->getErrorInstance->UserInputHandler($e); $this->app->getErrorInstance->UserInputHandler($e);
} }
catch(BaseError $e) catch(BaseError $e)
{ {
$this->app->getErrorInstance->BaseErrorHandler($e); $this->app->getErrorInstance->BaseErrorHandler($e);
} }
catch(NotImplementedError $e) catch(NotImplementedError $e)
{ {
$this->app->getErrorInstance->NotImplementedHandler($e); $this->app->getErrorInstance->NotImplementedHandler($e);
} }
} }
/** /**
@ -1221,28 +1221,28 @@ class network{
catch(BadResponseError $e) catch(BadResponseError $e)
{ {
$this->app->getErrorInstance->BadResponseHandler($e); $this->app->getErrorInstance->BadResponseHandler($e);
} }
catch(UserInputError $e) catch(UserInputError $e)
{ {
$this->app->getErrorInstance->UserInputHandler($e); $this->app->getErrorInstance->UserInputHandler($e);
} }
catch(BaseError $e) catch(BaseError $e)
{ {
$this->app->getErrorInstance->BaseErrorHandler($e); $this->app->getErrorInstance->BaseErrorHandler($e);
} }
catch(NotImplementedError $e) catch(NotImplementedError $e)
{ {
$this->app->getErrorInstance->NotImplementedHandler($e); $this->app->getErrorInstance->NotImplementedHandler($e);
} }
} }
/** /**
* Delete a specific Security Groupe given * Delete a specific Security Groupe given
* @param securityGroupeId ID of security Groupe which we want to get * @param securityGroupeId ID of security Groupe which we want to get
* @return void * @return NULL
*/ */
private function deleteSecurityGroupe() private function deleteSecurityGroupe()
{ {
try try
{ {
$securityGroupId = $this->app->getPostParam("securityGroupeId"); $securityGroupId = $this->app->getPostParam("securityGroupeId");
@ -1252,18 +1252,18 @@ class network{
catch(BadResponseError $e) catch(BadResponseError $e)
{ {
$this->app->getErrorInstance->BadResponseHandler($e); $this->app->getErrorInstance->BadResponseHandler($e);
} }
catch(UserInputError $e) catch(UserInputError $e)
{ {
$this->app->getErrorInstance->UserInputHandler($e); $this->app->getErrorInstance->UserInputHandler($e);
} }
catch(BaseError $e) catch(BaseError $e)
{ {
$this->app->getErrorInstance->BaseErrorHandler($e); $this->app->getErrorInstance->BaseErrorHandler($e);
} }
catch(NotImplementedError $e) catch(NotImplementedError $e)
{ {
$this->app->getErrorInstance->NotImplementedHandler($e); $this->app->getErrorInstance->NotImplementedHandler($e);
} }
} }
} }

View file

@ -51,10 +51,10 @@ class networkLayer3 {
* *
* @param String $action name of another function of this class * @param String $action name of another function of this class
* *
* @return void * @return NULL
*/ */
public function action($action){ public function action($action){
$this->{$action.""}(); $this->{$action.""}();
} }
@ -75,15 +75,15 @@ class networkLayer3 {
$this->app->setOutput("NetworkLayer3", $result); $this->app->setOutput("NetworkLayer3", $result);
}catch(BadResponseError $e){ }catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
}catch(UserInputError $e){ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e); $this->app->getErrorInstance()->UserInputHandler($e);
}catch(BaseError $e){ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e); $this->app->getErrorInstance()->BaseErrorHandler($e);
}catch(NotImplementedError $e){ }catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
}catch(Exception $e){ }catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
} }
/** /**
@ -109,15 +109,15 @@ class networkLayer3 {
} }
}catch(BadResponseError $e){ }catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
}catch(UserInputError $e){ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e); $this->app->getErrorInstance()->UserInputHandler($e);
}catch(BaseError $e){ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e); $this->app->getErrorInstance()->BaseErrorHandler($e);
}catch(NotImplementedError $e){ }catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
}catch(Exception $e){ }catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
} }
@ -147,7 +147,7 @@ class networkLayer3 {
foreach ($res as $f) { foreach ($res as $f) {
if(strcmp($f->id, $id)){ if(strcmp($f->id, $id)){
$result = $f; $result = $f;
} }
} }
@ -159,15 +159,15 @@ class networkLayer3 {
} }
}catch(BadResponseError $e){ }catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
}catch(UserInputError $e){ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e); $this->app->getErrorInstance()->UserInputHandler($e);
}catch(BaseError $e){ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e); $this->app->getErrorInstance()->BaseErrorHandler($e);
}catch(NotImplementedError $e){ }catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
}catch(Exception $e){ }catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
} }
/** /**
@ -175,7 +175,7 @@ class networkLayer3 {
* *
* @param id the id of the floatingip to update * @param id the id of the floatingip to update
* *
* @return void * @return NULL
*/ */
private function updateFloatingIp(){ private function updateFloatingIp(){
$id = $this->app->getPostParam("id"); $id = $this->app->getPostParam("id");
@ -197,7 +197,7 @@ class networkLayer3 {
foreach ($res as $f) { foreach ($res as $f) {
if(strcmp($f->id, $id)){ if(strcmp($f->id, $id)){
$result = $f; $result = $f;
} }
} }
@ -208,15 +208,15 @@ class networkLayer3 {
} }
}catch(BadResponseError $e){ }catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
}catch(UserInputError $e){ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e); $this->app->getErrorInstance()->UserInputHandler($e);
}catch(BaseError $e){ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e); $this->app->getErrorInstance()->BaseErrorHandler($e);
}catch(NotImplementedError $e){ }catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
}catch(Exception $e){ }catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
} }
/** /**
@ -224,7 +224,7 @@ class networkLayer3 {
* *
* @param string floatingip_id the floating-ip id to delete * @param string floatingip_id the floating-ip id to delete
* *
* @return void * @return NULL
*/ */
private function deleteFloatingIp(){ private function deleteFloatingIp(){
$id = $this->app->getPostParam("id"); $id = $this->app->getPostParam("id");
@ -245,7 +245,7 @@ class networkLayer3 {
foreach ($res as $f) { foreach ($res as $f) {
if(strcmp($f->id, $id)){ if(strcmp($f->id, $id)){
$result = $f; $result = $f;
} }
} }
@ -256,15 +256,15 @@ class networkLayer3 {
} }
}catch(BadResponseError $e){ }catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
}catch(UserInputError $e){ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e); $this->app->getErrorInstance()->UserInputHandler($e);
}catch(BaseError $e){ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e); $this->app->getErrorInstance()->BaseErrorHandler($e);
}catch(NotImplementedError $e){ }catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
}catch(Exception $e){ }catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
} }
@ -273,7 +273,7 @@ class networkLayer3 {
* *
* @param string floatingip_id the floating-ip id to retrieve * @param string floatingip_id the floating-ip id to retrieve
* *
* @return void * @return NULL
*/ */
private function retrieveFloatingIp(){ private function retrieveFloatingIp(){
$id = $this->app->getPostParam("id"); $id = $this->app->getPostParam("id");
@ -294,7 +294,7 @@ class networkLayer3 {
foreach ($res as $f) { foreach ($res as $f) {
if(strcmp($f->id, $id)){ if(strcmp($f->id, $id)){
$result = $f; $result = $f;
} }
} }
@ -305,15 +305,15 @@ class networkLayer3 {
} }
}catch(BadResponseError $e){ }catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
}catch(UserInputError $e){ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e); $this->app->getErrorInstance()->UserInputHandler($e);
}catch(BaseError $e){ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e); $this->app->getErrorInstance()->BaseErrorHandler($e);
}catch(NotImplementedError $e){ }catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
}catch(Exception $e){ }catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
} }
@ -344,15 +344,15 @@ class networkLayer3 {
} }
}catch(BadResponseError $e){ }catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
}catch(UserInputError $e){ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e); $this->app->getErrorInstance()->UserInputHandler($e);
}catch(BaseError $e){ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e); $this->app->getErrorInstance()->BaseErrorHandler($e);
}catch(NotImplementedError $e){ }catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
}catch(Exception $e){ }catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
} }
@ -372,15 +372,15 @@ class networkLayer3 {
$this->app->setOutput("NetworkLayer3", $result); $this->app->setOutput("NetworkLayer3", $result);
}catch(BadResponseError $e){ }catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
}catch(UserInputError $e){ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e); $this->app->getErrorInstance()->UserInputHandler($e);
}catch(BaseError $e){ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e); $this->app->getErrorInstance()->BaseErrorHandler($e);
}catch(NotImplementedError $e){ }catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
}catch(Exception $e){ }catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
} }
@ -420,15 +420,15 @@ class networkLayer3 {
} }
}catch(BadResponseError $e){ }catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
}catch(UserInputError $e){ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e); $this->app->getErrorInstance()->UserInputHandler($e);
}catch(BaseError $e){ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e); $this->app->getErrorInstance()->BaseErrorHandler($e);
}catch(NotImplementedError $e){ }catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
}catch(Exception $e){ }catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
} }
@ -437,7 +437,7 @@ class networkLayer3 {
* *
* @param string router the router to delete * @param string router the router to delete
* *
* @return void * @return NULL
*/ */
private function deleteRouter(){ private function deleteRouter(){
$id = $this->app->getPostParam("id"); $id = $this->app->getPostParam("id");
@ -468,15 +468,15 @@ class networkLayer3 {
} }
}catch(BadResponseError $e){ }catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
}catch(UserInputError $e){ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e); $this->app->getErrorInstance()->UserInputHandler($e);
}catch(BaseError $e){ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e); $this->app->getErrorInstance()->BaseErrorHandler($e);
}catch(NotImplementedError $e){ }catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
}catch(Exception $e){ }catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
} }
@ -485,7 +485,7 @@ class networkLayer3 {
* *
* @param id the id of the floatingip to update * @param id the id of the floatingip to update
* *
* @return void * @return NULL
*/ */
private function updateRouter(){ private function updateRouter(){
$id = $this->app->getPostParam("id"); $id = $this->app->getPostParam("id");
@ -507,7 +507,7 @@ class networkLayer3 {
foreach ($res as $f) { foreach ($res as $f) {
if(strcmp($f->id, $id)){ if(strcmp($f->id, $id)){
$result = $f; $result = $f;
} }
} }
@ -518,14 +518,14 @@ class networkLayer3 {
} }
}catch(BadResponseError $e){ }catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
}catch(UserInputError $e){ }catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e); $this->app->getErrorInstance()->UserInputHandler($e);
}catch(BaseError $e){ }catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e); $this->app->getErrorInstance()->BaseErrorHandler($e);
}catch(NotImplementedError $e){ }catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
}catch(Exception $e){ }catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
} }
} }

View file

@ -1,70 +1,88 @@
<?php <?php
require "vendor/autoload.php"; /**
include_once("config.inc.php"); * File containing the code for the API door.
include_once("init.php"); *
* @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"])){ $App->authenticate();
$task = $_POST["task"]; $App->show();
$action = $_POST["action"];
}else if(isset($_POST["task"]) && $_POST["task"] == "Authenticate" || $_POST["task"] == "Deauthenticate"){ }else if($task == "Deauthenticate"){
$task = $_POST["task"];
}else{ $App->deauthenticate();
//Gestion Erreur $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;
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;
} }
if($task == "Authenticate"){ }else{
//Request without authentication
$App->authenticate(); $App->setOutput("Error", "Token Invalide");
$App->show(); $App->show();
}
}else if($task == "Deauthenticate"){
$App->deauthenticate();
$App->show();
}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;
}
}else{
$App->setOutput("Error", "Token Invalide");
$App->show();
}

View file

@ -1,48 +1,55 @@
<?php <?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 = ""; include_once("core/App.php");
$password = "";
$project = "";
//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 = "";
"user" => Array( $password = "";
"name" => $user, $project = "";
"password" => $password,
"domain" => Array(
"name" => "Default")
),
"scope" => Array(
"project" => Array(
"name" => $project,
"domain" => Array(
"name" => "Default")
)
),
"authUrl" => $config["urlAuth"]
);
$App = new App($Args);
if(isset($token))
$App->setToken($token); //token processing
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"];
}
//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);
?> ?>