Refactoring of comments beginning
This commit is contained in:
parent
477dc82182
commit
5263cf00a2
13 changed files with 1535 additions and 1744 deletions
|
@ -1,11 +1,21 @@
|
|||
<?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();
|
||||
|
||||
$config["modules_enabled"] = "";
|
||||
$config["urlAuth"] = "http://148.60.11.31:5000/v3";
|
||||
$config["tokenTime"] = 60 //minute = 60
|
||||
date_default_timezone_set('Europe/Paris');
|
||||
|
||||
$config = Array();
|
||||
|
||||
$config["modules_enabled"] = "";
|
||||
$config["urlAuth"] = "http://148.60.11.31:5000/v3";
|
||||
$config["tokenTime"] = 60; //minute = 60
|
||||
?>
|
||||
|
||||
|
||||
|
|
|
@ -1,21 +1,53 @@
|
|||
<?php
|
||||
/**
|
||||
* File containing the identity Class.
|
||||
*
|
||||
* @version 1.0 Initialisation of this file
|
||||
* @since 1.0 Core application's file
|
||||
*
|
||||
* @author Eole 'eoledev at outlook . fr'
|
||||
*
|
||||
*/
|
||||
|
||||
//Library token management override
|
||||
include_once("core/LibOverride/genTokenOptions.php");
|
||||
include_once("core/ErrorManagement.php");
|
||||
|
||||
//Library loading
|
||||
use OpenCloud\Common\Error\BadResponseError;
|
||||
use OpenCloud\Common\Error\BaseError;
|
||||
use OpenCloud\Common\Error\NotImplementedError;
|
||||
use OpenCloud\Common\Error\UserInputError;
|
||||
|
||||
/**
|
||||
* App Class of the back-end application
|
||||
*
|
||||
* This class allow the communication between the front-end application and
|
||||
* the library which allow to send requests to an Openstack instance.
|
||||
*
|
||||
*/
|
||||
class App{
|
||||
|
||||
/** @var Openstack $openstack protected, contains the main library object */
|
||||
protected $openstack;
|
||||
/** @var Array $postParams protected, contains the post parameters */
|
||||
protected $postParams;
|
||||
/** @var genTokenOptions $tokenClass protected, contains the class object for the authentication override of the library */
|
||||
protected $tokenClass;
|
||||
/** @var String $tokenPost protected, contains the token given in parameter */
|
||||
protected $tokenPost;
|
||||
/** @var errorManagement $errorClass protected, contains the errorManagement object */
|
||||
protected $errorClass;
|
||||
/** @var Array $output protected, contains the result for the API call */
|
||||
protected $output;
|
||||
|
||||
/**
|
||||
* App constructor
|
||||
*
|
||||
* @param Array $args Args for the OpenStack Library
|
||||
*
|
||||
* @return App object
|
||||
*/
|
||||
public function __construct($args){
|
||||
|
||||
$this->tokenPost = NULL;
|
||||
|
@ -27,6 +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){
|
||||
|
||||
$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(){
|
||||
return $this->tokenClass->checkToken();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the service Class given the name in parameter
|
||||
*
|
||||
* @param String $service Name of the service
|
||||
*
|
||||
* @return Core object
|
||||
*/
|
||||
public function getLibClass($service){
|
||||
|
||||
switch($service){
|
||||
case "Identity":
|
||||
if($this->tokenPost == NULL) $this->tokenClass->genIdentityToken();
|
||||
$opt = $this->tokenClass->getOptions($service);
|
||||
return $this->openstack->identityV3($opt);
|
||||
break;
|
||||
case "Image":
|
||||
if($this->tokenPost == NULL) $this->tokenClass->genImageToken();
|
||||
$opt = $this->tokenClass->getOptions($service);
|
||||
return $this->openstack->imagesV2($opt);
|
||||
break;
|
||||
case "Network":
|
||||
if($this->tokenPost == NULL) $this->tokenClass->genNetworkToken();
|
||||
$opt = $this->tokenClass->getOptions($service);
|
||||
return $this->openstack->networkingV2($opt);
|
||||
break;
|
||||
case "Compute":
|
||||
if($this->tokenPost == NULL) $this->tokenClass->genComputeToken();
|
||||
$opt = $this->tokenClass->getOptions($service);
|
||||
return $this->openstack->computeV2($opt);
|
||||
break;
|
||||
case "NetworkLayer3":
|
||||
if($this->tokenPost == NULL) $this->tokenClass->genNetworkToken();
|
||||
$opt = $this->tokenClass->getOptions('Network');
|
||||
return $this->openstack->networkingV2ExtLayer3($opt);
|
||||
break;
|
||||
case "Identity":
|
||||
if($this->tokenPost == NULL) $this->tokenClass->genIdentityToken();
|
||||
$opt = $this->tokenClass->getOptions($service);
|
||||
return $this->openstack->identityV3($opt);
|
||||
break;
|
||||
case "Image":
|
||||
if($this->tokenPost == NULL) $this->tokenClass->genImageToken();
|
||||
$opt = $this->tokenClass->getOptions($service);
|
||||
return $this->openstack->imagesV2($opt);
|
||||
break;
|
||||
case "Network":
|
||||
if($this->tokenPost == NULL) $this->tokenClass->genNetworkToken();
|
||||
$opt = $this->tokenClass->getOptions($service);
|
||||
return $this->openstack->networkingV2($opt);
|
||||
break;
|
||||
case "Compute":
|
||||
if($this->tokenPost == NULL) $this->tokenClass->genComputeToken();
|
||||
$opt = $this->tokenClass->getOptions($service);
|
||||
return $this->openstack->computeV2($opt);
|
||||
break;
|
||||
case "NetworkLayer3":
|
||||
if($this->tokenPost == NULL) $this->tokenClass->genNetworkToken();
|
||||
$opt = $this->tokenClass->getOptions('Network');
|
||||
return $this->openstack->networkingV2ExtLayer3($opt);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the token for the different services in OpenStack
|
||||
*
|
||||
* @return NULL
|
||||
*/
|
||||
public function authenticate(){
|
||||
|
||||
try{
|
||||
|
@ -81,16 +137,21 @@ class App{
|
|||
$this->setOutput("token", $this->tokenClass->getBackup());
|
||||
}catch(BadResponseError $e){
|
||||
$this->errorClass->BadResponseHandler($e);
|
||||
}catch(UserInputError $e){
|
||||
}catch(UserInputError $e){
|
||||
$this->errorClass->UserInputHandler($e);
|
||||
}catch(BaseError $e){
|
||||
}catch(BaseError $e){
|
||||
$this->errorClass->BaseErrorHandler($e);
|
||||
}catch(NotImplementedError $e){
|
||||
}catch(NotImplementedError $e){
|
||||
$this->errorClass->NotImplementedHandler($e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Revoke the openstack services' token
|
||||
*
|
||||
* @return NULL
|
||||
*/
|
||||
public function deauthenticate(){
|
||||
|
||||
try{
|
||||
|
@ -103,16 +164,23 @@ class App{
|
|||
$this->setOutput("deauthenticate", "Ok");
|
||||
}catch(BadResponseError $e){
|
||||
$this->errorClass->BadResponseHandler($e);
|
||||
}catch(UserInputError $e){
|
||||
}catch(UserInputError $e){
|
||||
$this->errorClass->UserInputHandler($e);
|
||||
}catch(BaseError $e){
|
||||
}catch(BaseError $e){
|
||||
$this->errorClass->BaseErrorHandler($e);
|
||||
}catch(NotImplementedError $e){
|
||||
}catch(NotImplementedError $e){
|
||||
$this->errorClass->NotImplementedHandler($e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a post parameter given its name
|
||||
*
|
||||
* @param String $name Expected post parameter's name
|
||||
*
|
||||
* @return Object Post value
|
||||
*/
|
||||
public function getPostParam($name){
|
||||
|
||||
if(isset($this->postParams[$name])){
|
||||
|
@ -123,28 +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){
|
||||
|
||||
$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){
|
||||
|
||||
$this->output[$key] = $out;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the errorManagement instance Object
|
||||
*
|
||||
* @return errorManagement object
|
||||
*/
|
||||
public function getErrorInstance(){
|
||||
|
||||
return $this->errorClass;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Output the messages to be send to the client
|
||||
*
|
||||
* @return NULl
|
||||
*/
|
||||
public function show(){
|
||||
echo json_encode($this->output);
|
||||
//error_log(var_dump(json_encode($this->output), true), 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,9 +5,8 @@
|
|||
* @version 1.0 Initialisation of this file
|
||||
* @since 1.0 Core application's file
|
||||
*
|
||||
* @author Evan Pisani 'yogg at epsina . com' et bhupi
|
||||
* @author Evan Pisani 'yogg at epsina . com', bhupi
|
||||
*
|
||||
* @todo Complete the functions with errors detection and finish the descriptions
|
||||
*/
|
||||
|
||||
include("Image.php");
|
||||
|
@ -44,10 +43,10 @@ class automating{
|
|||
*
|
||||
* @param String $action name of another function of this class
|
||||
*
|
||||
* @return void
|
||||
* @return NULL
|
||||
*/
|
||||
public function action($action){
|
||||
$this->{$action.""}();
|
||||
$this->{$action.""}();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -58,7 +57,7 @@ class automating{
|
|||
* @param String $serverName name ofthe new server
|
||||
* @param String $flavor kind of server
|
||||
*
|
||||
* @return void
|
||||
* @return NULL
|
||||
*/
|
||||
private function createPublicServer()
|
||||
{
|
||||
|
|
|
@ -4,170 +4,170 @@ use OpenCloud\Common\Error;
|
|||
|
||||
class compute
|
||||
{
|
||||
/** @var App $app protected, contains the main app object */
|
||||
protected $app;
|
||||
/** @var App $app protected, contains the main app object */
|
||||
protected $app;
|
||||
|
||||
/** @var OpenStack\Identity $libClass protected, contains the library Compute object */
|
||||
protected $libClass;
|
||||
/** @var OpenStack\Identity $libClass protected, contains the library Compute object */
|
||||
protected $libClass;
|
||||
|
||||
|
||||
public function __construct($app)
|
||||
{
|
||||
$this->app = $app;
|
||||
$this->libClass = $app->getLibClass("Compute");
|
||||
}
|
||||
public function __construct($app)
|
||||
{
|
||||
$this->app = $app;
|
||||
$this->libClass = $app->getLibClass("Compute");
|
||||
}
|
||||
/**
|
||||
* Execute an action
|
||||
*
|
||||
* @param String $action name of another function of this class
|
||||
*
|
||||
* @return void
|
||||
* @return NULL
|
||||
*/
|
||||
public function action($action){
|
||||
|
||||
$this->{$action.""}();
|
||||
$this->{$action.""}();
|
||||
|
||||
}
|
||||
/**
|
||||
* List servers.
|
||||
* @return array
|
||||
*/
|
||||
public function listServers()
|
||||
{
|
||||
/**
|
||||
* List servers.
|
||||
* @return array
|
||||
*/
|
||||
public function listServers()
|
||||
{
|
||||
try{
|
||||
$serverList = $this->libClass->listServers(true);
|
||||
$servers = Array();
|
||||
foreach($serverList as $server){
|
||||
$servers[$server->id] = Array();
|
||||
$server->flavor->retrieve();
|
||||
$server->image->retrieve();
|
||||
$server->retrieve();
|
||||
$servers[$server->id]["id"] = $server->id;
|
||||
$servers[$server->id]["name"] = $server->name;
|
||||
$servers[$server->id]["image"] = $server->image;
|
||||
$servers[$server->id]["ram"] = $server->flavor->ram;
|
||||
$servers[$server->id]["disk"] = $server->flavor->disk;
|
||||
$servers[$server->id]["flavor"] = $server->flavor;
|
||||
$servers[$server->id]["status"] = $server->status;
|
||||
$servers[$server->id]["created"] = $server->created;
|
||||
$servers[$server->id]["updated"] = $server->updated;
|
||||
$servers[$server->id]["ipv4"] = $server->ipv4;
|
||||
$servers[$server->id]["ipv6"] = $server->ipv6;
|
||||
$servers[$server->id]["progress"] = $server->progress;
|
||||
$servers[$server->id]["hostId"] = $server->hostId;
|
||||
$servers[$server->id]["tenantId"] = $server->tenantId;
|
||||
$servers[$server->id]["userId"] = $server->userId;
|
||||
$servers[$server->id]["taskState"] = $server->taskState;
|
||||
$servers[$server->id]["addresses"] = $server->addresses;
|
||||
$servers[$server->id]["links"] = $server->links;
|
||||
$servers[$server->id]["metadata"] = $server->metadata;
|
||||
$servers[$server->id] = Array();
|
||||
$server->flavor->retrieve();
|
||||
$server->image->retrieve();
|
||||
$server->retrieve();
|
||||
$servers[$server->id]["id"] = $server->id;
|
||||
$servers[$server->id]["name"] = $server->name;
|
||||
$servers[$server->id]["image"] = $server->image;
|
||||
$servers[$server->id]["ram"] = $server->flavor->ram;
|
||||
$servers[$server->id]["disk"] = $server->flavor->disk;
|
||||
$servers[$server->id]["flavor"] = $server->flavor;
|
||||
$servers[$server->id]["status"] = $server->status;
|
||||
$servers[$server->id]["created"] = $server->created;
|
||||
$servers[$server->id]["updated"] = $server->updated;
|
||||
$servers[$server->id]["ipv4"] = $server->ipv4;
|
||||
$servers[$server->id]["ipv6"] = $server->ipv6;
|
||||
$servers[$server->id]["progress"] = $server->progress;
|
||||
$servers[$server->id]["hostId"] = $server->hostId;
|
||||
$servers[$server->id]["tenantId"] = $server->tenantId;
|
||||
$servers[$server->id]["userId"] = $server->userId;
|
||||
$servers[$server->id]["taskState"] = $server->taskState;
|
||||
$servers[$server->id]["addresses"] = $server->addresses;
|
||||
$servers[$server->id]["links"] = $server->links;
|
||||
$servers[$server->id]["metadata"] = $server->metadata;
|
||||
}
|
||||
$this->app->setOutput("Servers", $servers);
|
||||
}
|
||||
catch(BadResponseError $e){
|
||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||
}
|
||||
}
|
||||
catch(UserInputError $e){
|
||||
$this->app->getErrorInstance()->UserInputHandler($e);
|
||||
}
|
||||
}
|
||||
catch(BaseError $e){
|
||||
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
||||
}
|
||||
}
|
||||
catch(NotImplementedError $e){
|
||||
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
||||
}
|
||||
}
|
||||
catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* List flavors.
|
||||
* @return array
|
||||
*/
|
||||
public function listFlavors()
|
||||
{
|
||||
}
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* List flavors.
|
||||
* @return array
|
||||
*/
|
||||
public function listFlavors()
|
||||
{
|
||||
try{
|
||||
$flavorList = $this->libClass->listFlavors();
|
||||
$flavors = Array();
|
||||
foreach($flavorList as $flavor){
|
||||
$flavors[$flavor->id] = Array();
|
||||
$flavor->retrieve();
|
||||
$flavors[$flavor->id]["id"] = $flavor->id;
|
||||
$flavors[$flavor->id]["name"] = $flavor->name;
|
||||
$flavors[$flavor->id]["ram"] = $flavor->ram;
|
||||
$flavors[$flavor->id]["disk"] = $flavor->disk;
|
||||
$flavors[$flavor->id]["vcpus"] = $flavor->vcpus;
|
||||
$flavors[$flavor->id]["links"] = $flavor->links;
|
||||
}
|
||||
$this->app->setOutput("Flavors", $flavors);
|
||||
$flavors[$flavor->id] = Array();
|
||||
$flavor->retrieve();
|
||||
$flavors[$flavor->id]["id"] = $flavor->id;
|
||||
$flavors[$flavor->id]["name"] = $flavor->name;
|
||||
$flavors[$flavor->id]["ram"] = $flavor->ram;
|
||||
$flavors[$flavor->id]["disk"] = $flavor->disk;
|
||||
$flavors[$flavor->id]["vcpus"] = $flavor->vcpus;
|
||||
$flavors[$flavor->id]["links"] = $flavor->links;
|
||||
}
|
||||
$this->app->setOutput("Flavors", $flavors);
|
||||
}
|
||||
catch(BadResponseError $e){
|
||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||
}
|
||||
}
|
||||
catch(UserInputError $e){
|
||||
$this->app->getErrorInstance()->UserInputHandler($e);
|
||||
}
|
||||
}
|
||||
catch(BaseError $e){
|
||||
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
||||
}
|
||||
}
|
||||
catch(NotImplementedError $e){
|
||||
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
||||
}
|
||||
}
|
||||
catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* List images.
|
||||
* @return array
|
||||
*/
|
||||
public function listImages()
|
||||
{
|
||||
try{
|
||||
}
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* List images.
|
||||
* @return array
|
||||
*/
|
||||
public function listImages()
|
||||
{
|
||||
try{
|
||||
$imageList = $this->libClass->listImages();
|
||||
$images = Array();
|
||||
foreach($imageList as $image){
|
||||
$images[$image->id] = Array();
|
||||
$image->retrieve();
|
||||
$images[$image->id]["id"] = $image->id;
|
||||
$images[$image->id]["name"] = $image->name;
|
||||
$images[$image->id]["status"] = $image->status;
|
||||
$images[$image->id]["created"] = $image->created;
|
||||
$images[$image->id]["updated"] = $image->updated;
|
||||
$images[$image->id]["minDisk"] = $image->minDisk;
|
||||
$images[$image->id]["minRam"] = $image->minRam;
|
||||
$images[$image->id]["progress"] = $image->progress;
|
||||
$images[$image->id]["links"] = $image->links;
|
||||
$images[$image->id]["metadata"] = $image->metadata;
|
||||
}
|
||||
$this->app->setOutput("Images", $images);
|
||||
$images[$image->id] = Array();
|
||||
$image->retrieve();
|
||||
$images[$image->id]["id"] = $image->id;
|
||||
$images[$image->id]["name"] = $image->name;
|
||||
$images[$image->id]["status"] = $image->status;
|
||||
$images[$image->id]["created"] = $image->created;
|
||||
$images[$image->id]["updated"] = $image->updated;
|
||||
$images[$image->id]["minDisk"] = $image->minDisk;
|
||||
$images[$image->id]["minRam"] = $image->minRam;
|
||||
$images[$image->id]["progress"] = $image->progress;
|
||||
$images[$image->id]["links"] = $image->links;
|
||||
$images[$image->id]["metadata"] = $image->metadata;
|
||||
}
|
||||
$this->app->setOutput("Images", $images);
|
||||
}
|
||||
catch(BadResponseError $e){
|
||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||
}
|
||||
}
|
||||
catch(UserInputError $e){
|
||||
$this->app->getErrorInstance()->UserInputHandler($e);
|
||||
}
|
||||
}
|
||||
catch(BaseError $e){
|
||||
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
||||
}
|
||||
}
|
||||
catch(NotImplementedError $e){
|
||||
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
||||
}
|
||||
}
|
||||
catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* Get server details.
|
||||
* @return array
|
||||
*/
|
||||
public function getServer()
|
||||
{
|
||||
try{
|
||||
}
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* Get server details.
|
||||
* @return array
|
||||
*/
|
||||
public function getServer()
|
||||
{
|
||||
try{
|
||||
$serverId = $this->app->getPostParam("serverId");
|
||||
if(!isset($serverId)){
|
||||
$this->app->setOutput("Error", "Server ID is missing!");
|
||||
|
@ -180,27 +180,27 @@ class compute
|
|||
}
|
||||
catch(BadResponseError $e){
|
||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||
}
|
||||
}
|
||||
catch(UserInputError $e){
|
||||
$this->app->getErrorInstance()->UserInputHandler($e);
|
||||
}
|
||||
}
|
||||
catch(BaseError $e){
|
||||
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
||||
}
|
||||
}
|
||||
catch(NotImplementedError $e){
|
||||
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
||||
}
|
||||
}
|
||||
catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* Get flavor details.
|
||||
* @return array
|
||||
*/
|
||||
public function getFlavor()
|
||||
{
|
||||
}
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* Get flavor details.
|
||||
* @return array
|
||||
*/
|
||||
public function getFlavor()
|
||||
{
|
||||
try{
|
||||
$flavorId = $this->app->getPostParam("flavorId");
|
||||
if(!isset($serverId)){
|
||||
|
@ -214,27 +214,27 @@ class compute
|
|||
}
|
||||
catch(BadResponseError $e){
|
||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||
}
|
||||
}
|
||||
catch(UserInputError $e){
|
||||
$this->app->getErrorInstance()->UserInputHandler($e);
|
||||
}
|
||||
}
|
||||
catch(BaseError $e){
|
||||
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
||||
}
|
||||
}
|
||||
catch(NotImplementedError $e){
|
||||
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
||||
}
|
||||
}
|
||||
catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* Get image details.
|
||||
* @return array
|
||||
*/
|
||||
public function getImage()
|
||||
{
|
||||
}
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* Get image details.
|
||||
* @return array
|
||||
*/
|
||||
public function getImage()
|
||||
{
|
||||
try{
|
||||
$imageId = $this->app->getPostParam("imageId");
|
||||
if(!isset($serverId)){
|
||||
|
@ -248,27 +248,27 @@ class compute
|
|||
}
|
||||
catch(BadResponseError $e){
|
||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||
}
|
||||
}
|
||||
catch(UserInputError $e){
|
||||
$this->app->getErrorInstance()->UserInputHandler($e);
|
||||
}
|
||||
}
|
||||
catch(BaseError $e){
|
||||
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
||||
}
|
||||
}
|
||||
catch(NotImplementedError $e){
|
||||
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
||||
}
|
||||
}
|
||||
catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* Create server.
|
||||
* @return array
|
||||
*/
|
||||
public function createServer()
|
||||
{
|
||||
}
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* Create server.
|
||||
* @return array
|
||||
*/
|
||||
public function createServer()
|
||||
{
|
||||
try{
|
||||
$name = $this->app->getPostParam("name");
|
||||
$imageId = $this->app->getPostParam("imageId");
|
||||
|
@ -282,28 +282,28 @@ class compute
|
|||
}
|
||||
catch(BadResponseError $e){
|
||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||
}
|
||||
}
|
||||
catch(UserInputError $e){
|
||||
$this->app->getErrorInstance()->UserInputHandler($e);
|
||||
}
|
||||
}
|
||||
catch(BaseError $e){
|
||||
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
||||
}
|
||||
}
|
||||
catch(NotImplementedError $e){
|
||||
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
||||
}
|
||||
}
|
||||
catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* update a server
|
||||
* @return void
|
||||
* @return NULL
|
||||
*/
|
||||
public function updateServer()
|
||||
{
|
||||
public function updateServer()
|
||||
{
|
||||
try{
|
||||
$serverId = $this->app->getPostParam("serverId");
|
||||
$newName = $this->app->getPostParam("newName");
|
||||
|
@ -329,27 +329,27 @@ class compute
|
|||
}
|
||||
catch(BadResponseError $e){
|
||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||
}
|
||||
}
|
||||
catch(UserInputError $e){
|
||||
$this->app->getErrorInstance()->UserInputHandler($e);
|
||||
}
|
||||
}
|
||||
catch(BaseError $e){
|
||||
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
||||
}
|
||||
}
|
||||
catch(NotImplementedError $e){
|
||||
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
||||
}
|
||||
}
|
||||
catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* Delete a server
|
||||
* @return void
|
||||
* @return NULL
|
||||
*/
|
||||
public function deleteServer()
|
||||
{
|
||||
public function deleteServer()
|
||||
{
|
||||
try{
|
||||
$serverId = $this->app->getPostParam("serverId");
|
||||
if(!isset($serverId)){
|
||||
|
@ -363,27 +363,27 @@ class compute
|
|||
}
|
||||
catch(BadResponseError $e){
|
||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||
}
|
||||
}
|
||||
catch(UserInputError $e){
|
||||
$this->app->getErrorInstance()->UserInputHandler($e);
|
||||
}
|
||||
}
|
||||
catch(BaseError $e){
|
||||
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
||||
}
|
||||
}
|
||||
catch(NotImplementedError $e){
|
||||
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
||||
}
|
||||
}
|
||||
catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* Change the password of a server
|
||||
* @return void
|
||||
* @return NULL
|
||||
*/
|
||||
public function changePassword()
|
||||
{
|
||||
public function changePassword()
|
||||
{
|
||||
try{
|
||||
$serverId = $this->app->getPostParam("serverId");
|
||||
$password = $this->app->getPostParam("newPassword");
|
||||
|
@ -398,27 +398,27 @@ class compute
|
|||
}
|
||||
catch(BadResponseError $e){
|
||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||
}
|
||||
}
|
||||
catch(UserInputError $e){
|
||||
$this->app->getErrorInstance()->UserInputHandler($e);
|
||||
}
|
||||
}
|
||||
catch(BaseError $e){
|
||||
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
||||
}
|
||||
}
|
||||
catch(NotImplementedError $e){
|
||||
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
||||
}
|
||||
}
|
||||
catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
/**
|
||||
}
|
||||
/**
|
||||
* Reboot a server
|
||||
* @return void
|
||||
* @return NULL
|
||||
*/
|
||||
public function reboot()
|
||||
{
|
||||
public function reboot()
|
||||
{
|
||||
try{
|
||||
$serverId = $this->app->getPostParam("serverId");
|
||||
if(!isset($serverId)){
|
||||
|
@ -432,74 +432,74 @@ class compute
|
|||
}
|
||||
catch(BadResponseError $e){
|
||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||
}
|
||||
}
|
||||
catch(UserInputError $e){
|
||||
$this->app->getErrorInstance()->UserInputHandler($e);
|
||||
}
|
||||
}
|
||||
catch(BaseError $e){
|
||||
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
||||
}
|
||||
}
|
||||
catch(NotImplementedError $e){
|
||||
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
||||
}
|
||||
}
|
||||
catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
/**
|
||||
}
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* Rebuild a server
|
||||
* @return void
|
||||
* @return NULL
|
||||
*/
|
||||
public function rebuild()
|
||||
{
|
||||
$serverId = $this->app->getPostParam("serverId");
|
||||
$imageId = $this->app->getPostParam("imageId");
|
||||
$newName = $this->app->getPostParam("newName");
|
||||
$adminPass = $this->app->getPostParam("adminPass");
|
||||
public function rebuild()
|
||||
{
|
||||
$serverId = $this->app->getPostParam("serverId");
|
||||
$imageId = $this->app->getPostParam("imageId");
|
||||
$newName = $this->app->getPostParam("newName");
|
||||
$adminPass = $this->app->getPostParam("adminPass");
|
||||
if(!isset($serverId)|| !isset($imageId) || isset($newName) || isset($adminPass)) {
|
||||
$this->app->setOutput("Error", "You'll have to provide server ID and the new image, name and admin password!");
|
||||
return;
|
||||
try{
|
||||
$serverId = $this->app->getPostParam("serverId");
|
||||
$imageId = $this->app->getPostParam("imageId");
|
||||
$newName = $this->app->getPostParam("newName");
|
||||
$adminPass = $this->app->getPostParam("adminPass");
|
||||
if(!isset($serverId)|| !isset($imageId) || isset($newName) || isset($adminPass)){
|
||||
$this->app->setOutput("Error", "You'll have to provide server ID and the new image, name and admin password!");
|
||||
return;
|
||||
}
|
||||
$opt = array('id' => $serverId);
|
||||
$server = $this->libClass->getServer($opt);
|
||||
$attr = array('imageId' => $imageId, 'name' => $newName, 'adminPass' => $adminPass);
|
||||
$server->rebuild($attr);
|
||||
$this->app->setOutput("Success", $serverId." has been rebuilt successfully with the new image.");
|
||||
}
|
||||
catch(BadResponseError $e){
|
||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||
}
|
||||
catch(UserInputError $e){
|
||||
$this->app->getErrorInstance()->UserInputHandler($e);
|
||||
}
|
||||
catch(BaseError $e){
|
||||
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
||||
}
|
||||
catch(NotImplementedError $e){
|
||||
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
||||
}
|
||||
catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
try{
|
||||
$serverId = $this->app->getPostParam("serverId");
|
||||
$imageId = $this->app->getPostParam("imageId");
|
||||
$newName = $this->app->getPostParam("newName");
|
||||
$adminPass = $this->app->getPostParam("adminPass");
|
||||
if(!isset($serverId)|| !isset($imageId) || isset($newName) || isset($adminPass)){
|
||||
$this->app->setOutput("Error", "You'll have to provide server ID and the new image, name and admin password!");
|
||||
return;
|
||||
}
|
||||
/**
|
||||
$opt = array('id' => $serverId);
|
||||
$server = $this->libClass->getServer($opt);
|
||||
$attr = array('imageId' => $imageId, 'name' => $newName, 'adminPass' => $adminPass);
|
||||
$server->rebuild($attr);
|
||||
$this->app->setOutput("Success", $serverId." has been rebuilt successfully with the new image.");
|
||||
}
|
||||
catch(BadResponseError $e){
|
||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||
}
|
||||
catch(UserInputError $e){
|
||||
$this->app->getErrorInstance()->UserInputHandler($e);
|
||||
}
|
||||
catch(BaseError $e){
|
||||
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
||||
}
|
||||
catch(NotImplementedError $e){
|
||||
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
||||
}
|
||||
catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Resize a server
|
||||
* 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{
|
||||
$serverId = $this->app->getPostParam("serverId");
|
||||
$newFlavorId = $this->app->getPostParam("newFlavorId");
|
||||
|
@ -513,27 +513,27 @@ class compute
|
|||
}
|
||||
catch(BadResponseError $e){
|
||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||
}
|
||||
}
|
||||
catch(UserInputError $e){
|
||||
$this->app->getErrorInstance()->UserInputHandler($e);
|
||||
}
|
||||
}
|
||||
catch(BaseError $e){
|
||||
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
||||
}
|
||||
}
|
||||
catch(NotImplementedError $e){
|
||||
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
||||
}
|
||||
}
|
||||
catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
/**
|
||||
}
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* Confirm resize operation on a server
|
||||
* @return void
|
||||
* @return NULL
|
||||
*/
|
||||
public function confirmResize()
|
||||
{
|
||||
public function confirmResize()
|
||||
{
|
||||
try{
|
||||
$serverId = $this->app->getPostParam("serverId");
|
||||
if(!isset($serverId)){
|
||||
|
@ -547,27 +547,27 @@ class compute
|
|||
}
|
||||
catch(BadResponseError $e){
|
||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||
}
|
||||
}
|
||||
catch(UserInputError $e){
|
||||
$this->app->getErrorInstance()->UserInputHandler($e);
|
||||
}
|
||||
}
|
||||
catch(BaseError $e){
|
||||
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
||||
}
|
||||
}
|
||||
catch(NotImplementedError $e){
|
||||
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
||||
}
|
||||
}
|
||||
catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
/**
|
||||
}
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* Revert resize operation on a server
|
||||
* @return void
|
||||
* @return NULL
|
||||
*/
|
||||
public function revertResize()
|
||||
{
|
||||
public function revertResize()
|
||||
{
|
||||
try{
|
||||
$serverId = $this->app->getPostParam("serverId");
|
||||
if(!isset($serverId)){
|
||||
|
@ -581,28 +581,28 @@ class compute
|
|||
}
|
||||
catch(BadResponseError $e){
|
||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||
}
|
||||
}
|
||||
catch(UserInputError $e){
|
||||
$this->app->getErrorInstance()->UserInputHandler($e);
|
||||
}
|
||||
}
|
||||
catch(BaseError $e){
|
||||
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
||||
}
|
||||
}
|
||||
catch(NotImplementedError $e){
|
||||
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
||||
}
|
||||
}
|
||||
catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* List private and public addresses of a server
|
||||
* @return void
|
||||
* @return NULL
|
||||
*/
|
||||
|
||||
public function listAddresses(array $options = [])
|
||||
{
|
||||
|
||||
public function listAddresses(array $options = [])
|
||||
{
|
||||
try{
|
||||
$serverId = $this->app->getPostParam("serverId");
|
||||
if(!isset($serverId)){
|
||||
|
@ -616,20 +616,20 @@ class compute
|
|||
}
|
||||
catch(BadResponseError $e){
|
||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||
}
|
||||
}
|
||||
catch(UserInputError $e){
|
||||
$this->app->getErrorInstance()->UserInputHandler($e);
|
||||
}
|
||||
}
|
||||
catch(BaseError $e){
|
||||
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
||||
}
|
||||
}
|
||||
catch(NotImplementedError $e){
|
||||
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
||||
}
|
||||
}
|
||||
catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,13 @@
|
|||
<?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{
|
||||
|
||||
public function action($action);
|
||||
|
|
|
@ -22,9 +22,9 @@ Class errorManagement{
|
|||
/**
|
||||
* ErrorManagemement constructor
|
||||
*
|
||||
* @param App $app the main app object
|
||||
* @param App $args the main app object
|
||||
*
|
||||
* @return ErrorManagement
|
||||
* @return ErrorManagement Object
|
||||
*/
|
||||
public function __construct($args){
|
||||
|
||||
|
@ -35,9 +35,9 @@ Class errorManagement{
|
|||
/**
|
||||
* Put an error message corresponding to a base error in the output
|
||||
*
|
||||
* @param $error the error triggered
|
||||
* @param Exception $error the exception triggered
|
||||
*
|
||||
* @return String BaseError message
|
||||
* @return NULL
|
||||
*/
|
||||
public function BaseErrorHandler($error){
|
||||
$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
|
||||
*
|
||||
* @param $error the error triggered
|
||||
* @param Exception $error the exception triggered
|
||||
*
|
||||
* @return String Error message
|
||||
* @return NULL
|
||||
*/
|
||||
public function BadResponseHandler($error){
|
||||
$statusCode = $error->getResponse()->getStatusCode();
|
||||
switch ($statusCode) {
|
||||
case 400:
|
||||
$this->app->setOutput("Error", "Invalid input.");
|
||||
break;
|
||||
case 400:
|
||||
$this->app->setOutput("Error", "Invalid input.");
|
||||
break;
|
||||
|
||||
case 401:
|
||||
$this->app->setOutput("Error", "Authentification failed.");
|
||||
break;
|
||||
case 401:
|
||||
$this->app->setOutput("Error", "Authentification failed.");
|
||||
break;
|
||||
|
||||
case 403:
|
||||
$this->app->setOutput("Error", "Operation forbidden.");
|
||||
break;
|
||||
case 403:
|
||||
$this->app->setOutput("Error", "Operation forbidden.");
|
||||
break;
|
||||
|
||||
case 404:
|
||||
$this->app->setOutput("Error", "Ressource not found.");
|
||||
break;
|
||||
case 404:
|
||||
$this->app->setOutput("Error", "Ressource not found.");
|
||||
break;
|
||||
|
||||
case 500:
|
||||
$this->app->setOutput("Error", "Internal server error, please contact an administrator.");
|
||||
break;
|
||||
case 500:
|
||||
$this->app->setOutput("Error", "Internal server error, please contact an administrator.");
|
||||
break;
|
||||
|
||||
case 503:
|
||||
$this->app->setOutput("Error", "Service unvailable for the moment.");
|
||||
break;
|
||||
case 503:
|
||||
$this->app->setOutput("Error", "Service unvailable for the moment.");
|
||||
break;
|
||||
|
||||
default:
|
||||
$this->app->setOutput("Error", "Unknow error, please contact an administrator.");
|
||||
break;
|
||||
default:
|
||||
$this->app->setOutput("Error", "Unknow error, please contact an administrator.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Put an error message corresponding to a not implemented yet error in the output
|
||||
*
|
||||
* @param $error the error triggered
|
||||
* @param Exception $error the exception triggered
|
||||
*
|
||||
* @return String internal error message
|
||||
* @return NULL
|
||||
*/
|
||||
public function NotImplementedHandler($error){
|
||||
$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
|
||||
*
|
||||
* @param $error the error triggered
|
||||
* @param Exception $error the exception triggered
|
||||
*
|
||||
* @return String User input error message
|
||||
* @return NULL
|
||||
*/
|
||||
public function UserInputHandler($error){
|
||||
$this->app->setOutput("Error", "UserInputError");
|
||||
|
@ -108,9 +108,9 @@ Class errorManagement{
|
|||
/**
|
||||
* Put an error message corresponding to an other error in the output
|
||||
*
|
||||
* @param $error the error triggered
|
||||
* @param Exception $error the exception triggered
|
||||
*
|
||||
* @return String error message
|
||||
* @return NULL
|
||||
*/
|
||||
public function OtherException($error){
|
||||
$this->app->setOutput("Error", $error->getMessage());
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -51,10 +51,10 @@ class image implements Core{
|
|||
*
|
||||
* @param String $action name of another function of this class
|
||||
*
|
||||
* @return void
|
||||
* @return NULL
|
||||
*/
|
||||
public function action($action){
|
||||
$this->{$action.""}();
|
||||
$this->{$action.""}();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -78,13 +78,13 @@ class image implements Core{
|
|||
if(isset($opt['name'])){
|
||||
$imagesList = $this->listImage();
|
||||
if(isset($imagesList)){
|
||||
foreach($imagesList as $image){
|
||||
if(strcmp($image->name, $opt['name']) == 0){ // if the image name already exists -> error
|
||||
$this->app->setOutput("Error", "Image name already exists");
|
||||
}
|
||||
}
|
||||
}
|
||||
$options['name'] = $opt['name'];
|
||||
foreach($imagesList as $image){
|
||||
if(strcmp($image->name, $opt['name']) == 0){ // if the image name already exists -> error
|
||||
$this->app->setOutput("Error", "Image name already exists");
|
||||
}
|
||||
}
|
||||
}
|
||||
$options['name'] = $opt['name'];
|
||||
}
|
||||
else{
|
||||
$this->app->setOutput("Error", "Missing parameter 'name' for the new image");
|
||||
|
@ -125,15 +125,15 @@ class image implements Core{
|
|||
$image = $this->libClass->createImage($options);
|
||||
}catch(BadResponseError $e){
|
||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||
}catch(UserInputError $e){
|
||||
}catch(UserInputError $e){
|
||||
$this->app->getErrorInstance()->UserInputHandler($e);
|
||||
}catch(BaseError $e){
|
||||
}catch(BaseError $e){
|
||||
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
||||
}catch(NotImplementedError $e){
|
||||
}catch(NotImplementedError $e){
|
||||
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
||||
}catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
}catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
$this->app->setOutput("Images", $image);
|
||||
|
||||
}
|
||||
|
@ -152,15 +152,15 @@ class image implements Core{
|
|||
}
|
||||
}catch(BadResponseError $e){
|
||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||
}catch(UserInputError $e){
|
||||
}catch(UserInputError $e){
|
||||
$this->app->getErrorInstance()->UserInputHandler($e);
|
||||
}catch(BaseError $e){
|
||||
}catch(BaseError $e){
|
||||
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
||||
}catch(NotImplementedError $e){
|
||||
}catch(NotImplementedError $e){
|
||||
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
||||
}catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
}catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
|
||||
$this->app->setOutput("Images", $result);
|
||||
|
||||
|
@ -191,16 +191,16 @@ class image implements Core{
|
|||
}
|
||||
}catch(BadResponseError $e){
|
||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||
}catch(UserInputError $e){
|
||||
}catch(UserInputError $e){
|
||||
$this->app->getErrorInstance()->UserInputHandler($e);
|
||||
}catch(BaseError $e){
|
||||
}catch(BaseError $e){
|
||||
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
||||
}catch(NotImplementedError $e){
|
||||
}catch(NotImplementedError $e){
|
||||
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
||||
}catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
}
|
||||
}catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -254,15 +254,15 @@ class image implements Core{
|
|||
$image->update($options);
|
||||
}catch(BadResponseError $e){
|
||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||
}catch(UserInputError $e){
|
||||
}catch(UserInputError $e){
|
||||
$this->app->getErrorInstance()->UserInputHandler($e);
|
||||
}catch(BaseError $e){
|
||||
}catch(BaseError $e){
|
||||
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
||||
}catch(NotImplementedError $e){
|
||||
}catch(NotImplementedError $e){
|
||||
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
||||
}catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
}catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
$this->app->setOutput("Images", $image);
|
||||
}
|
||||
}
|
||||
|
@ -272,7 +272,7 @@ class image implements Core{
|
|||
*
|
||||
* @param String $id Identifier of the image
|
||||
*
|
||||
* @return void
|
||||
* @return NULL
|
||||
*/
|
||||
private function deleteImage(){
|
||||
$id = $this->app->getPostParam("id");
|
||||
|
@ -289,16 +289,16 @@ class image implements Core{
|
|||
$image->delete();
|
||||
}catch(BadResponseError $e){
|
||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||
}catch(UserInputError $e){
|
||||
}catch(UserInputError $e){
|
||||
$this->app->getErrorInstance()->UserInputHandler($e);
|
||||
}catch(BaseError $e){
|
||||
}catch(BaseError $e){
|
||||
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
||||
}catch(NotImplementedError $e){
|
||||
}catch(NotImplementedError $e){
|
||||
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
||||
}catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
}
|
||||
}catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -306,7 +306,7 @@ class image implements Core{
|
|||
*
|
||||
* @param String $id Identifier of the image
|
||||
*
|
||||
* @return void
|
||||
* @return NULL
|
||||
*/
|
||||
private function reactivateImage(){
|
||||
$id = $this->app->getPostParam("id");
|
||||
|
@ -326,16 +326,16 @@ class image implements Core{
|
|||
$image->reactivate();
|
||||
}catch(BadResponseError $e){
|
||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||
}catch(UserInputError $e){
|
||||
}catch(UserInputError $e){
|
||||
$this->app->getErrorInstance()->UserInputHandler($e);
|
||||
}catch(BaseError $e){
|
||||
}catch(BaseError $e){
|
||||
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
||||
}catch(NotImplementedError $e){
|
||||
}catch(NotImplementedError $e){
|
||||
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
||||
}catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
}
|
||||
}catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -343,7 +343,7 @@ class image implements Core{
|
|||
*
|
||||
* @param String $id Identifier of the image
|
||||
*
|
||||
* @return void
|
||||
* @return NULL
|
||||
*/
|
||||
private function desactivateImage(){
|
||||
$id = $this->app->getPostParam("id");
|
||||
|
@ -362,16 +362,16 @@ class image implements Core{
|
|||
$image->deactivate();
|
||||
}catch(BadResponseError $e){
|
||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||
}catch(UserInputError $e){
|
||||
}catch(UserInputError $e){
|
||||
$this->app->getErrorInstance()->UserInputHandler($e);
|
||||
}catch(BaseError $e){
|
||||
}catch(BaseError $e){
|
||||
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
||||
}catch(NotImplementedError $e){
|
||||
}catch(NotImplementedError $e){
|
||||
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
||||
}catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
}
|
||||
}catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -380,14 +380,14 @@ class image implements Core{
|
|||
* @param String $id Identifier of the image
|
||||
* @param String $file_name Path of the image
|
||||
*
|
||||
* @return void
|
||||
* @return NULL
|
||||
*/
|
||||
private function uploadImage(){
|
||||
$id = $this->app->getPostParam("id");
|
||||
$file_name = $this->app->getPostParam("file_name");
|
||||
$file = $this->app->getPostParam("file");
|
||||
$file = $this->app->getPostParam("file");
|
||||
error_log(print_r($file, true), 0);
|
||||
|
||||
|
||||
if(!isset($id)){
|
||||
$this->app->setOutput("Error", "Incorrect id parameter");
|
||||
}
|
||||
|
@ -405,16 +405,16 @@ class image implements Core{
|
|||
$image->uploadData($stream);
|
||||
}catch(BadResponseError $e){
|
||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||
}catch(UserInputError $e){
|
||||
}catch(UserInputError $e){
|
||||
$this->app->getErrorInstance()->UserInputHandler($e);
|
||||
}catch(BaseError $e){
|
||||
}catch(BaseError $e){
|
||||
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
||||
}catch(NotImplementedError $e){
|
||||
}catch(NotImplementedError $e){
|
||||
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
||||
}catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
}
|
||||
}catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -440,17 +440,17 @@ class image implements Core{
|
|||
$stream = $image->downloadData();
|
||||
}catch(BadResponseError $e){
|
||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||
}catch(UserInputError $e){
|
||||
}catch(UserInputError $e){
|
||||
$this->app->getErrorInstance()->UserInputHandler($e);
|
||||
}catch(BaseError $e){
|
||||
}catch(BaseError $e){
|
||||
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
||||
}catch(NotImplementedError $e){
|
||||
}catch(NotImplementedError $e){
|
||||
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
||||
}catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
$this->app->setOutput("Images", $stream);
|
||||
}
|
||||
}catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
$this->app->setOutput("Images", $stream);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -483,16 +483,16 @@ class image implements Core{
|
|||
$this->app->setOutput("Images", $member_id);
|
||||
}catch(BadResponseError $e){
|
||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||
}catch(UserInputError $e){
|
||||
}catch(UserInputError $e){
|
||||
$this->app->getErrorInstance()->UserInputHandler($e);
|
||||
}catch(BaseError $e){
|
||||
}catch(BaseError $e){
|
||||
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
||||
}catch(NotImplementedError $e){
|
||||
}catch(NotImplementedError $e){
|
||||
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
||||
}catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
}
|
||||
}catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -526,15 +526,15 @@ class image implements Core{
|
|||
}
|
||||
}catch(BadResponseError $e){
|
||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||
}catch(UserInputError $e){
|
||||
}catch(UserInputError $e){
|
||||
$this->app->getErrorInstance()->UserInputHandler($e);
|
||||
}catch(BaseError $e){
|
||||
}catch(BaseError $e){
|
||||
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
||||
}catch(NotImplementedError $e){
|
||||
}catch(NotImplementedError $e){
|
||||
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
||||
}catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
}catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
$this->app->setOutput("Images", $members);
|
||||
}
|
||||
}
|
||||
|
@ -572,15 +572,15 @@ class image implements Core{
|
|||
}
|
||||
}catch(BadResponseError $e){
|
||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||
}catch(UserInputError $e){
|
||||
}catch(UserInputError $e){
|
||||
$this->app->getErrorInstance()->UserInputHandler($e);
|
||||
}catch(BaseError $e){
|
||||
}catch(BaseError $e){
|
||||
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
||||
}catch(NotImplementedError $e){
|
||||
}catch(NotImplementedError $e){
|
||||
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
||||
}catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
}catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
$this->app->setOutput("Images", $member);
|
||||
}
|
||||
}
|
||||
|
@ -591,7 +591,7 @@ class image implements Core{
|
|||
* @param String $image_id Identifier of the image
|
||||
* @param String $member_id Identifier of the member
|
||||
*
|
||||
* @return void
|
||||
* @return NULL
|
||||
*/
|
||||
private function removeMemberImage(){
|
||||
$image_id = $this->app->getPostParam("image_id");
|
||||
|
@ -618,16 +618,16 @@ class image implements Core{
|
|||
$member->delete();
|
||||
}catch(BadResponseError $e){
|
||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||
}catch(UserInputError $e){
|
||||
}catch(UserInputError $e){
|
||||
$this->app->getErrorInstance()->UserInputHandler($e);
|
||||
}catch(BaseError $e){
|
||||
}catch(BaseError $e){
|
||||
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
||||
}catch(NotImplementedError $e){
|
||||
}catch(NotImplementedError $e){
|
||||
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
||||
}catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
}
|
||||
}catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -637,7 +637,7 @@ class image implements Core{
|
|||
* @param String $member_id Identifier of the member
|
||||
* @param String $status New status for the member
|
||||
*
|
||||
* @return void
|
||||
* @return NULL
|
||||
**/
|
||||
private function updateMemberImage(){
|
||||
$image_id = $this->app->getPostParam("image_id");
|
||||
|
@ -665,16 +665,16 @@ class image implements Core{
|
|||
$member->updateStatus($status);
|
||||
}catch(BadResponseError $e){
|
||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||
}catch(UserInputError $e){
|
||||
}catch(UserInputError $e){
|
||||
$this->app->getErrorInstance()->UserInputHandler($e);
|
||||
}catch(BaseError $e){
|
||||
}catch(BaseError $e){
|
||||
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
||||
}catch(NotImplementedError $e){
|
||||
}catch(NotImplementedError $e){
|
||||
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
||||
}catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
}
|
||||
}catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,33 +22,33 @@ class genTokenOptions
|
|||
$this->stack = HandlerStack::create();
|
||||
|
||||
$httpClient = new Client([
|
||||
'base_uri' => Utils::normalizeUrl($options['authUrl']),
|
||||
'handler' => $this->stack,
|
||||
]);
|
||||
'base_uri' => Utils::normalizeUrl($options['authUrl']),
|
||||
'handler' => $this->stack,
|
||||
]);
|
||||
|
||||
$this->httpClient = $httpClient;
|
||||
|
||||
$options['identityService'] = Service::factory($httpClient);
|
||||
$options['identityService'] = Service::factory($httpClient);
|
||||
|
||||
$options['authHandler'] = function () use ($options) {
|
||||
return $options['identityService']->generateToken($options);
|
||||
};
|
||||
};
|
||||
|
||||
$this->optionsGlobal['Common'] = $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
private function addDebugMiddleware(array $options, HandlerStack &$stack)
|
||||
{
|
||||
if (!empty($options['debugLog'])
|
||||
&& !empty($options['logger'])
|
||||
&& !empty($options['messageFormatter'])
|
||||
) {
|
||||
$stack->push(GuzzleMiddleware::log($options['logger'], $options['messageFormatter']));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
private function addDebugMiddleware(array $options, HandlerStack &$stack)
|
||||
{
|
||||
if (!empty($options['debugLog'])
|
||||
&& !empty($options['logger'])
|
||||
&& !empty($options['messageFormatter'])
|
||||
) {
|
||||
$stack->push(GuzzleMiddleware::log($options['logger'], $options['messageFormatter']));
|
||||
}
|
||||
}
|
||||
|
||||
public function checkToken(){
|
||||
//error_log(print_r($this->backup['time'], true), 0);
|
||||
|
@ -73,9 +73,9 @@ class genTokenOptions
|
|||
$this->addDebugMiddleware($options, $stack);
|
||||
|
||||
$options['httpClient'] = new Client([
|
||||
'base_uri' => Utils::normalizeUrl($baseUrl),
|
||||
'handler' => $stack,
|
||||
]);
|
||||
'base_uri' => Utils::normalizeUrl($baseUrl),
|
||||
'handler' => $stack,
|
||||
]);
|
||||
$this->saveBackup('Identity', array('token' => $token, 'baseUrl' => $baseUrl ));
|
||||
|
||||
$this->optionsGlobal['Identity'] = $options;
|
||||
|
@ -98,15 +98,15 @@ class genTokenOptions
|
|||
$baseUrl = $this->backup['Identity']['baseUrl'];
|
||||
|
||||
$stack = HandlerStack::create();
|
||||
|
||||
|
||||
$stack->push(Middleware::authHandler($options['authHandler'], $token));
|
||||
|
||||
$this->addDebugMiddleware($options, $stack);
|
||||
|
||||
$options['httpClient'] = new Client([
|
||||
'base_uri' => Utils::normalizeUrl($baseUrl),
|
||||
'handler' => $stack,
|
||||
]);
|
||||
'base_uri' => Utils::normalizeUrl($baseUrl),
|
||||
'handler' => $stack,
|
||||
]);
|
||||
$this->saveBackup('Identity', array('token' => $token, 'baseUrl' => $baseUrl ));
|
||||
$this->optionsGlobal['Identity'] = $options;
|
||||
|
||||
|
@ -122,14 +122,14 @@ class genTokenOptions
|
|||
|
||||
$stack = HandlerStack::create();
|
||||
|
||||
$stack->push(Middleware::authHandler($options['authHandler'], $token));
|
||||
$stack->push(Middleware::authHandler($options['authHandler'], $token));
|
||||
|
||||
$this->addDebugMiddleware($options, $stack);
|
||||
|
||||
$options['httpClient'] = new Client([
|
||||
'base_uri' => Utils::normalizeUrl($baseUrl),
|
||||
'handler' => $stack,
|
||||
]);
|
||||
'base_uri' => Utils::normalizeUrl($baseUrl),
|
||||
'handler' => $stack,
|
||||
]);
|
||||
$this->saveBackup('Image', array('token' => $token, 'baseUrl' => $baseUrl ));
|
||||
|
||||
$this->optionsGlobal['Image'] = $options;
|
||||
|
@ -150,7 +150,7 @@ class genTokenOptions
|
|||
$this->backup['Image'] = $opt;
|
||||
$token = $this->unserializeToken($this->backup['Image']['token']);
|
||||
$baseUrl = $this->backup['Image']['baseUrl'];
|
||||
|
||||
|
||||
$stack = HandlerStack::create();
|
||||
|
||||
$stack->push(Middleware::authHandler($options['authHandler'], $token));
|
||||
|
@ -158,9 +158,9 @@ class genTokenOptions
|
|||
$this->addDebugMiddleware($options, $stack);
|
||||
|
||||
$options['httpClient'] = new Client([
|
||||
'base_uri' => Utils::normalizeUrl($baseUrl),
|
||||
'handler' => $stack,
|
||||
]);
|
||||
'base_uri' => Utils::normalizeUrl($baseUrl),
|
||||
'handler' => $stack,
|
||||
]);
|
||||
$this->saveBackup('Image', array('token' => $token, 'baseUrl' => $baseUrl ));
|
||||
$this->optionsGlobal['Image'] = $options;
|
||||
}
|
||||
|
@ -175,14 +175,14 @@ class genTokenOptions
|
|||
|
||||
$stack = HandlerStack::create();
|
||||
|
||||
$stack->push(Middleware::authHandler($options['authHandler'], $token));
|
||||
$stack->push(Middleware::authHandler($options['authHandler'], $token));
|
||||
|
||||
$this->addDebugMiddleware($options, $stack);
|
||||
|
||||
$options['httpClient'] = new Client([
|
||||
'base_uri' => Utils::normalizeUrl($baseUrl),
|
||||
'handler' => $stack,
|
||||
]);
|
||||
'base_uri' => Utils::normalizeUrl($baseUrl),
|
||||
'handler' => $stack,
|
||||
]);
|
||||
$this->saveBackup('Network', array('token' => $token, 'baseUrl' => $baseUrl ));
|
||||
|
||||
$this->optionsGlobal['Network'] = $options;
|
||||
|
@ -203,17 +203,17 @@ class genTokenOptions
|
|||
$this->backup['Network'] = $opt;
|
||||
$token = $this->unserializeToken($this->backup['Network']['token']);
|
||||
$baseUrl = $this->backup['Network']['baseUrl'];
|
||||
|
||||
|
||||
$stack = HandlerStack::create();
|
||||
|
||||
|
||||
$stack->push(Middleware::authHandler($options['authHandler'], $token));
|
||||
|
||||
$this->addDebugMiddleware($options, $stack);
|
||||
|
||||
$options['httpClient'] = new Client([
|
||||
'base_uri' => Utils::normalizeUrl($baseUrl),
|
||||
'handler' => $stack,
|
||||
]);
|
||||
'base_uri' => Utils::normalizeUrl($baseUrl),
|
||||
'handler' => $stack,
|
||||
]);
|
||||
$this->saveBackup('Network', array('token' => $token, 'baseUrl' => $baseUrl ));
|
||||
$this->optionsGlobal['Network'] = $options;
|
||||
}
|
||||
|
@ -228,14 +228,14 @@ class genTokenOptions
|
|||
|
||||
$stack = HandlerStack::create();
|
||||
|
||||
$stack->push(Middleware::authHandler($options['authHandler'], $token));
|
||||
$stack->push(Middleware::authHandler($options['authHandler'], $token));
|
||||
|
||||
$this->addDebugMiddleware($options, $stack);
|
||||
|
||||
$options['httpClient'] = new Client([
|
||||
'base_uri' => Utils::normalizeUrl($baseUrl),
|
||||
'handler' => $stack,
|
||||
]);
|
||||
'base_uri' => Utils::normalizeUrl($baseUrl),
|
||||
'handler' => $stack,
|
||||
]);
|
||||
$this->saveBackup('Compute', array('token' => $token, 'baseUrl' => $baseUrl ));
|
||||
|
||||
$this->optionsGlobal['Compute'] = $options;
|
||||
|
@ -257,17 +257,17 @@ class genTokenOptions
|
|||
$this->backup['Compute'] = $opt;
|
||||
$token = $this->unserializeToken($this->backup['Compute']['token']);
|
||||
$baseUrl = $this->backup['Compute']['baseUrl'];
|
||||
|
||||
|
||||
$stack = HandlerStack::create();
|
||||
|
||||
|
||||
$stack->push(Middleware::authHandler($options['authHandler'], $token));
|
||||
|
||||
$this->addDebugMiddleware($options, $stack);
|
||||
|
||||
$options['httpClient'] = new Client([
|
||||
'base_uri' => Utils::normalizeUrl($baseUrl),
|
||||
'handler' => $stack,
|
||||
]);
|
||||
'base_uri' => Utils::normalizeUrl($baseUrl),
|
||||
'handler' => $stack,
|
||||
]);
|
||||
$this->saveBackup('Compute', array('token' => $token, 'baseUrl' => $baseUrl ));
|
||||
$this->optionsGlobal['Compute'] = $options;
|
||||
}
|
||||
|
@ -426,7 +426,7 @@ class genTokenOptions
|
|||
$token->user->description = unserialize($this->backup["user"]["description"]);
|
||||
$token->issued = unserialize($tokenSerialized["issued"]);
|
||||
$token->id = unserialize($tokenSerialized["id"]);
|
||||
|
||||
|
||||
return $token;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,9 +22,9 @@ use OpenCloud\Common\Error\UserInputError;
|
|||
*/
|
||||
|
||||
class network{
|
||||
/** @var App $app protected, contains the main app object */
|
||||
/** @var App $app protected, contains the main app object */
|
||||
protected $app;
|
||||
/** @var OpenStack\Network $libClass protected, contains the library Network object */
|
||||
/** @var OpenStack\Network $libClass protected, contains the library Network object */
|
||||
protected $libClass;
|
||||
|
||||
|
||||
|
@ -49,11 +49,11 @@ class network{
|
|||
*
|
||||
* @param String $action name of another function of this class
|
||||
*
|
||||
* @return void
|
||||
* @return NULL
|
||||
*/
|
||||
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 tenantId Owner of network. Only admin users can specify a tenant ID other than their own
|
||||
*
|
||||
* @return void
|
||||
* @return NULL
|
||||
*/
|
||||
private function create_network()
|
||||
{
|
||||
|
@ -102,19 +102,19 @@ class network{
|
|||
catch(BadResponseError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->BadResponseHandler($e);
|
||||
}
|
||||
}
|
||||
catch(UserInputError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->UserInputHandler($e);
|
||||
}
|
||||
}
|
||||
catch(BaseError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->BaseErrorHandler($e);
|
||||
}
|
||||
}
|
||||
catch(NotImplementedError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->NotImplementedHandler($e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ class network{
|
|||
*
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
* @return NULL
|
||||
*/
|
||||
|
||||
private function create_subnet()
|
||||
|
@ -200,24 +200,24 @@ class network{
|
|||
|
||||
try
|
||||
{
|
||||
$subnet = $this->libClass->createSubnet($options);
|
||||
$subnet = $this->libClass->createSubnet($options);
|
||||
}
|
||||
catch(BadResponseError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->BadResponseHandler($e);
|
||||
}
|
||||
}
|
||||
catch(UserInputError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->UserInputHandler($e);
|
||||
}
|
||||
}
|
||||
catch(BaseError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->BaseErrorHandler($e);
|
||||
}
|
||||
}
|
||||
catch(NotImplementedError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->NotImplementedHandler($e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -233,36 +233,36 @@ class network{
|
|||
try
|
||||
{
|
||||
$ln = $this->libClass->listNetworks();
|
||||
|
||||
|
||||
$list_ids = array();
|
||||
|
||||
|
||||
|
||||
foreach($ln as $n)
|
||||
{
|
||||
|
||||
|
||||
$list_ids[] = $n->id;
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
catch(BadResponseError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->BadResponseHandler($e);
|
||||
}
|
||||
}
|
||||
catch(UserInputError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->UserInputHandler($e);
|
||||
}
|
||||
}
|
||||
catch(BaseError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->BaseErrorHandler($e);
|
||||
}
|
||||
}
|
||||
catch(NotImplementedError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->NotImplementedHandler($e);
|
||||
}
|
||||
}
|
||||
|
||||
$this->app->setOutput("ListNetworkIds", $list_ids);
|
||||
$this->app->setOutput("ListNetworkIds", $list_ids);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -276,37 +276,37 @@ class network{
|
|||
try
|
||||
{
|
||||
$ln = $this->libClass->listNetworks();
|
||||
|
||||
|
||||
$list_names = array();
|
||||
|
||||
|
||||
|
||||
foreach($ln as $n)
|
||||
{
|
||||
|
||||
|
||||
$list_names[] = $n->name;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
catch(BadResponseError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->BadResponseHandler($e);
|
||||
}
|
||||
}
|
||||
catch(UserInputError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->UserInputHandler($e);
|
||||
}
|
||||
}
|
||||
catch(BaseError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->BaseErrorHandler($e);
|
||||
}
|
||||
}
|
||||
catch(NotImplementedError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->NotImplementedHandler($e);
|
||||
}
|
||||
}
|
||||
|
||||
$this->app->setOutput("ListNetworkNames", $list_names);
|
||||
$this->app->setOutput("ListNetworkNames", $list_names);
|
||||
}
|
||||
/**
|
||||
* List the CIDR of the SUBNETS
|
||||
|
@ -317,32 +317,32 @@ class network{
|
|||
{
|
||||
try
|
||||
{
|
||||
$ls = $this->libClass->listSubnets();
|
||||
$list_cidr = array();
|
||||
foreach ($ls as $subnet)
|
||||
{
|
||||
|
||||
$list_cidr[] = $subnet->cidr;
|
||||
}
|
||||
$ls = $this->libClass->listSubnets();
|
||||
$list_cidr = array();
|
||||
foreach ($ls as $subnet)
|
||||
{
|
||||
|
||||
$list_cidr[] = $subnet->cidr;
|
||||
}
|
||||
|
||||
$this->app->setOutput("ListCidr", $list_cidr);
|
||||
$this->app->setOutput("ListCidr", $list_cidr);
|
||||
}
|
||||
catch(BadResponseError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->BadResponseHandler($e);
|
||||
}
|
||||
}
|
||||
catch(UserInputError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->UserInputHandler($e);
|
||||
}
|
||||
}
|
||||
catch(BaseError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->BaseErrorHandler($e);
|
||||
}
|
||||
}
|
||||
catch(NotImplementedError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->NotImplementedHandler($e);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* retrieve a specific network
|
||||
|
@ -364,21 +364,21 @@ class network{
|
|||
catch(BadResponseError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->BadResponseHandler($e);
|
||||
}
|
||||
}
|
||||
catch(UserInputError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->UserInputHandler($e);
|
||||
}
|
||||
}
|
||||
catch(BaseError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->BaseErrorHandler($e);
|
||||
}
|
||||
}
|
||||
catch(NotImplementedError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->NotImplementedHandler($e);
|
||||
}
|
||||
}
|
||||
|
||||
$this->app->setOutput("Network", $network);
|
||||
$this->app->setOutput("Network", $network);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -401,21 +401,21 @@ class network{
|
|||
catch(BadResponseError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->BadResponseHandler($e);
|
||||
}
|
||||
}
|
||||
catch(UserInputError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->UserInputHandler($e);
|
||||
}
|
||||
}
|
||||
catch(BaseError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->BaseErrorHandler($e);
|
||||
}
|
||||
}
|
||||
catch(NotImplementedError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->NotImplementedHandler($e);
|
||||
}
|
||||
}
|
||||
|
||||
return $network;
|
||||
return $network;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -437,21 +437,21 @@ class network{
|
|||
catch(BadResponseError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->BadResponseHandler($e);
|
||||
}
|
||||
}
|
||||
catch(UserInputError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->UserInputHandler($e);
|
||||
}
|
||||
}
|
||||
catch(BaseError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->BaseErrorHandler($e);
|
||||
}
|
||||
}
|
||||
catch(NotImplementedError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->NotImplementedHandler($e);
|
||||
}
|
||||
}
|
||||
$this->app->setOutput("Subnet", subnet);
|
||||
|
||||
|
||||
}
|
||||
/**
|
||||
* internal function
|
||||
|
@ -472,21 +472,21 @@ class network{
|
|||
catch(BadResponseError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->BadResponseHandler($e);
|
||||
}
|
||||
}
|
||||
catch(UserInputError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->UserInputHandler($e);
|
||||
}
|
||||
}
|
||||
catch(BaseError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->BaseErrorHandler($e);
|
||||
}
|
||||
}
|
||||
catch(NotImplementedError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->NotImplementedHandler($e);
|
||||
}
|
||||
}
|
||||
return $subnet;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -498,11 +498,11 @@ class network{
|
|||
* @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();
|
||||
$name = $this->app->getPostParam("name");
|
||||
$shared = $this->app->getPostParam("shared");
|
||||
|
@ -524,25 +524,25 @@ class network{
|
|||
{
|
||||
$networkId = $this->app->getPostParam("networkId");
|
||||
$network = getNetworkP($networkId);
|
||||
|
||||
|
||||
$network->update($options);
|
||||
}
|
||||
catch(BadResponseError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->BadResponseHandler($e);
|
||||
}
|
||||
}
|
||||
catch(UserInputError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->UserInputHandler($e);
|
||||
}
|
||||
}
|
||||
catch(BaseError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->BaseErrorHandler($e);
|
||||
}
|
||||
}
|
||||
catch(NotImplementedError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->NotImplementedHandler($e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -561,11 +561,11 @@ class network{
|
|||
* @param String allocationPools Subranges of the CIDR available for dynamic allocation to ports
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
* @return NULL
|
||||
**/
|
||||
|
||||
private function updateSubnet()
|
||||
{
|
||||
{
|
||||
$options = array();
|
||||
$name = $this->app->getPostParam("name");
|
||||
$networkId = $this->app->getPostParam("networkId");
|
||||
|
@ -596,19 +596,19 @@ class network{
|
|||
catch(BadResponseError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->BadResponseHandler($e);
|
||||
}
|
||||
}
|
||||
catch(UserInputError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->UserInputHandler($e);
|
||||
}
|
||||
}
|
||||
catch(BaseError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->BaseErrorHandler($e);
|
||||
}
|
||||
}
|
||||
catch(NotImplementedError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->NotImplementedHandler($e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -617,10 +617,10 @@ class network{
|
|||
* @param String networkId ID if network which we want to delete
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
* @return NULL
|
||||
**/
|
||||
private function deleteNetwork()
|
||||
{
|
||||
{
|
||||
try
|
||||
{
|
||||
$networkId = $this->app->getPostParam("networkId");
|
||||
|
@ -630,19 +630,19 @@ class network{
|
|||
catch(BadResponseError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->BadResponseHandler($e);
|
||||
}
|
||||
}
|
||||
catch(UserInputError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->UserInputHandler($e);
|
||||
}
|
||||
}
|
||||
catch(BaseError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->BaseErrorHandler($e);
|
||||
}
|
||||
}
|
||||
catch(NotImplementedError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->NotImplementedHandler($e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -651,10 +651,10 @@ class network{
|
|||
* @param String subnetId ID if network which we want to delete
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
* @return NULL
|
||||
**/
|
||||
private function deleteSubnet()
|
||||
{
|
||||
{
|
||||
try
|
||||
{
|
||||
$subnetId = $this->app->getPostParam("subnetId");
|
||||
|
@ -664,19 +664,19 @@ class network{
|
|||
catch(BadResponseError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->BadResponseHandler($e);
|
||||
}
|
||||
}
|
||||
catch(UserInputError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->UserInputHandler($e);
|
||||
}
|
||||
}
|
||||
catch(BaseError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->BaseErrorHandler($e);
|
||||
}
|
||||
}
|
||||
catch(NotImplementedError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->NotImplementedHandler($e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -692,7 +692,7 @@ class network{
|
|||
* @param String securityGroups Specifies the IDs of any security groups associated with this port
|
||||
* @param String tenantId Owner of the port. Only admin users can specify a tenant ID other than their own.
|
||||
*
|
||||
* @return void
|
||||
* @return NULL
|
||||
*/
|
||||
|
||||
private function createPort()
|
||||
|
@ -751,19 +751,19 @@ class network{
|
|||
catch(BadResponseError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->BadResponseHandler($e);
|
||||
}
|
||||
}
|
||||
catch(UserInputError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->UserInputHandler($e);
|
||||
}
|
||||
}
|
||||
catch(BaseError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->BaseErrorHandler($e);
|
||||
}
|
||||
}
|
||||
catch(NotImplementedError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->NotImplementedHandler($e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -781,19 +781,19 @@ class network{
|
|||
catch(BadResponseError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->BadResponseHandler($e);
|
||||
}
|
||||
}
|
||||
catch(UserInputError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->UserInputHandler($e);
|
||||
}
|
||||
}
|
||||
catch(BaseError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->BaseErrorHandler($e);
|
||||
}
|
||||
}
|
||||
catch(NotImplementedError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->NotImplementedHandler($e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -813,20 +813,20 @@ class network{
|
|||
catch(BadResponseError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->BadResponseHandler($e);
|
||||
}
|
||||
}
|
||||
catch(UserInputError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->UserInputHandler($e);
|
||||
}
|
||||
}
|
||||
catch(BaseError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->BaseErrorHandler($e);
|
||||
}
|
||||
}
|
||||
catch(NotImplementedError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->NotImplementedHandler($e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -846,20 +846,20 @@ class network{
|
|||
catch(BadResponseError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->BadResponseHandler($e);
|
||||
}
|
||||
}
|
||||
catch(UserInputError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->UserInputHandler($e);
|
||||
}
|
||||
}
|
||||
catch(BaseError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->BaseErrorHandler($e);
|
||||
}
|
||||
}
|
||||
catch(NotImplementedError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->NotImplementedHandler($e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -876,7 +876,7 @@ class network{
|
|||
* @param String securityGroups Specifies the IDs of any security groups associated with this port
|
||||
* @param String tenantId Owner of the port. Only admin users can specify a tenant ID other than their own.
|
||||
*
|
||||
* @return void
|
||||
* @return NULL
|
||||
*/
|
||||
private function updatePort()
|
||||
{
|
||||
|
@ -935,28 +935,28 @@ class network{
|
|||
catch(BadResponseError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->BadResponseHandler($e);
|
||||
}
|
||||
}
|
||||
catch(UserInputError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->UserInputHandler($e);
|
||||
}
|
||||
}
|
||||
catch(BaseError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->BaseErrorHandler($e);
|
||||
}
|
||||
}
|
||||
catch(NotImplementedError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->NotImplementedHandler($e);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Delete a port given
|
||||
*
|
||||
* @param String portId id of port which we wante to delete
|
||||
* @return void
|
||||
* @return NULL
|
||||
*/
|
||||
private function deletePort()
|
||||
{
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -967,19 +967,19 @@ class network{
|
|||
catch(BadResponseError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->BadResponseHandler($e);
|
||||
}
|
||||
}
|
||||
catch(UserInputError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->UserInputHandler($e);
|
||||
}
|
||||
}
|
||||
catch(BaseError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->BaseErrorHandler($e);
|
||||
}
|
||||
}
|
||||
catch(NotImplementedError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->NotImplementedHandler($e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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 description Description of the security group
|
||||
*
|
||||
* @return void
|
||||
* @return NULL
|
||||
*/
|
||||
|
||||
private function createSecurityGroup()
|
||||
|
@ -1012,20 +1012,20 @@ class network{
|
|||
catch(BadResponseError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->BadResponseHandler($e);
|
||||
}
|
||||
}
|
||||
catch(UserInputError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->UserInputHandler($e);
|
||||
}
|
||||
}
|
||||
catch(BaseError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->BaseErrorHandler($e);
|
||||
}
|
||||
}
|
||||
catch(NotImplementedError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->NotImplementedHandler($e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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 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()
|
||||
{
|
||||
|
@ -1093,19 +1093,19 @@ class network{
|
|||
catch(BadResponseError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->BadResponseHandler($e);
|
||||
}
|
||||
}
|
||||
catch(UserInputError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->UserInputHandler($e);
|
||||
}
|
||||
}
|
||||
catch(BaseError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->BaseErrorHandler($e);
|
||||
}
|
||||
}
|
||||
catch(NotImplementedError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->NotImplementedHandler($e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1124,19 +1124,19 @@ class network{
|
|||
catch(BadResponseError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->BadResponseHandler($e);
|
||||
}
|
||||
}
|
||||
catch(UserInputError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->UserInputHandler($e);
|
||||
}
|
||||
}
|
||||
catch(BaseError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->BaseErrorHandler($e);
|
||||
}
|
||||
}
|
||||
catch(NotImplementedError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->NotImplementedHandler($e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1150,26 +1150,26 @@ class network{
|
|||
{
|
||||
try
|
||||
{
|
||||
|
||||
$this->app->setOutput("listSecurityGroupeRule", $this->libClass->listSecurityGroupRules());
|
||||
|
||||
$this->app->setOutput("listSecurityGroupeRule", $this->libClass->listSecurityGroupRules());
|
||||
|
||||
}
|
||||
catch(BadResponseError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->BadResponseHandler($e);
|
||||
}
|
||||
}
|
||||
catch(UserInputError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->UserInputHandler($e);
|
||||
}
|
||||
}
|
||||
catch(BaseError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->BaseErrorHandler($e);
|
||||
}
|
||||
}
|
||||
catch(NotImplementedError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->NotImplementedHandler($e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1189,20 +1189,20 @@ class network{
|
|||
catch(BadResponseError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->BadResponseHandler($e);
|
||||
}
|
||||
}
|
||||
catch(UserInputError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->UserInputHandler($e);
|
||||
}
|
||||
}
|
||||
catch(BaseError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->BaseErrorHandler($e);
|
||||
}
|
||||
}
|
||||
catch(NotImplementedError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->NotImplementedHandler($e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1221,28 +1221,28 @@ class network{
|
|||
catch(BadResponseError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->BadResponseHandler($e);
|
||||
}
|
||||
}
|
||||
catch(UserInputError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->UserInputHandler($e);
|
||||
}
|
||||
}
|
||||
catch(BaseError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->BaseErrorHandler($e);
|
||||
}
|
||||
}
|
||||
catch(NotImplementedError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->NotImplementedHandler($e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Delete a specific Security Groupe given
|
||||
* @param securityGroupeId ID of security Groupe which we want to get
|
||||
* @return void
|
||||
* @return NULL
|
||||
*/
|
||||
private function deleteSecurityGroupe()
|
||||
{
|
||||
{
|
||||
try
|
||||
{
|
||||
$securityGroupId = $this->app->getPostParam("securityGroupeId");
|
||||
|
@ -1252,18 +1252,18 @@ class network{
|
|||
catch(BadResponseError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->BadResponseHandler($e);
|
||||
}
|
||||
}
|
||||
catch(UserInputError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->UserInputHandler($e);
|
||||
}
|
||||
}
|
||||
catch(BaseError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->BaseErrorHandler($e);
|
||||
}
|
||||
}
|
||||
catch(NotImplementedError $e)
|
||||
{
|
||||
$this->app->getErrorInstance->NotImplementedHandler($e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,10 +51,10 @@ class networkLayer3 {
|
|||
*
|
||||
* @param String $action name of another function of this class
|
||||
*
|
||||
* @return void
|
||||
* @return NULL
|
||||
*/
|
||||
public function action($action){
|
||||
$this->{$action.""}();
|
||||
$this->{$action.""}();
|
||||
}
|
||||
|
||||
|
||||
|
@ -75,15 +75,15 @@ class networkLayer3 {
|
|||
$this->app->setOutput("NetworkLayer3", $result);
|
||||
}catch(BadResponseError $e){
|
||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||
}catch(UserInputError $e){
|
||||
}catch(UserInputError $e){
|
||||
$this->app->getErrorInstance()->UserInputHandler($e);
|
||||
}catch(BaseError $e){
|
||||
}catch(BaseError $e){
|
||||
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
||||
}catch(NotImplementedError $e){
|
||||
}catch(NotImplementedError $e){
|
||||
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
||||
}catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
}catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -109,15 +109,15 @@ class networkLayer3 {
|
|||
}
|
||||
}catch(BadResponseError $e){
|
||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||
}catch(UserInputError $e){
|
||||
}catch(UserInputError $e){
|
||||
$this->app->getErrorInstance()->UserInputHandler($e);
|
||||
}catch(BaseError $e){
|
||||
}catch(BaseError $e){
|
||||
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
||||
}catch(NotImplementedError $e){
|
||||
}catch(NotImplementedError $e){
|
||||
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
||||
}catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
}catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -147,7 +147,7 @@ class networkLayer3 {
|
|||
foreach ($res as $f) {
|
||||
if(strcmp($f->id, $id)){
|
||||
$result = $f;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -159,15 +159,15 @@ class networkLayer3 {
|
|||
}
|
||||
}catch(BadResponseError $e){
|
||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||
}catch(UserInputError $e){
|
||||
}catch(UserInputError $e){
|
||||
$this->app->getErrorInstance()->UserInputHandler($e);
|
||||
}catch(BaseError $e){
|
||||
}catch(BaseError $e){
|
||||
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
||||
}catch(NotImplementedError $e){
|
||||
}catch(NotImplementedError $e){
|
||||
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
||||
}catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
}catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -175,7 +175,7 @@ class networkLayer3 {
|
|||
*
|
||||
* @param id the id of the floatingip to update
|
||||
*
|
||||
* @return void
|
||||
* @return NULL
|
||||
*/
|
||||
private function updateFloatingIp(){
|
||||
$id = $this->app->getPostParam("id");
|
||||
|
@ -197,7 +197,7 @@ class networkLayer3 {
|
|||
foreach ($res as $f) {
|
||||
if(strcmp($f->id, $id)){
|
||||
$result = $f;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -208,15 +208,15 @@ class networkLayer3 {
|
|||
}
|
||||
}catch(BadResponseError $e){
|
||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||
}catch(UserInputError $e){
|
||||
}catch(UserInputError $e){
|
||||
$this->app->getErrorInstance()->UserInputHandler($e);
|
||||
}catch(BaseError $e){
|
||||
}catch(BaseError $e){
|
||||
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
||||
}catch(NotImplementedError $e){
|
||||
}catch(NotImplementedError $e){
|
||||
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
||||
}catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
}catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -224,7 +224,7 @@ class networkLayer3 {
|
|||
*
|
||||
* @param string floatingip_id the floating-ip id to delete
|
||||
*
|
||||
* @return void
|
||||
* @return NULL
|
||||
*/
|
||||
private function deleteFloatingIp(){
|
||||
$id = $this->app->getPostParam("id");
|
||||
|
@ -245,7 +245,7 @@ class networkLayer3 {
|
|||
foreach ($res as $f) {
|
||||
if(strcmp($f->id, $id)){
|
||||
$result = $f;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -256,15 +256,15 @@ class networkLayer3 {
|
|||
}
|
||||
}catch(BadResponseError $e){
|
||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||
}catch(UserInputError $e){
|
||||
}catch(UserInputError $e){
|
||||
$this->app->getErrorInstance()->UserInputHandler($e);
|
||||
}catch(BaseError $e){
|
||||
}catch(BaseError $e){
|
||||
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
||||
}catch(NotImplementedError $e){
|
||||
}catch(NotImplementedError $e){
|
||||
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
||||
}catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
}catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -273,7 +273,7 @@ class networkLayer3 {
|
|||
*
|
||||
* @param string floatingip_id the floating-ip id to retrieve
|
||||
*
|
||||
* @return void
|
||||
* @return NULL
|
||||
*/
|
||||
private function retrieveFloatingIp(){
|
||||
$id = $this->app->getPostParam("id");
|
||||
|
@ -294,7 +294,7 @@ class networkLayer3 {
|
|||
foreach ($res as $f) {
|
||||
if(strcmp($f->id, $id)){
|
||||
$result = $f;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -305,15 +305,15 @@ class networkLayer3 {
|
|||
}
|
||||
}catch(BadResponseError $e){
|
||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||
}catch(UserInputError $e){
|
||||
}catch(UserInputError $e){
|
||||
$this->app->getErrorInstance()->UserInputHandler($e);
|
||||
}catch(BaseError $e){
|
||||
}catch(BaseError $e){
|
||||
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
||||
}catch(NotImplementedError $e){
|
||||
}catch(NotImplementedError $e){
|
||||
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
||||
}catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
}catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -344,15 +344,15 @@ class networkLayer3 {
|
|||
}
|
||||
}catch(BadResponseError $e){
|
||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||
}catch(UserInputError $e){
|
||||
}catch(UserInputError $e){
|
||||
$this->app->getErrorInstance()->UserInputHandler($e);
|
||||
}catch(BaseError $e){
|
||||
}catch(BaseError $e){
|
||||
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
||||
}catch(NotImplementedError $e){
|
||||
}catch(NotImplementedError $e){
|
||||
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
||||
}catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
}catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -372,15 +372,15 @@ class networkLayer3 {
|
|||
$this->app->setOutput("NetworkLayer3", $result);
|
||||
}catch(BadResponseError $e){
|
||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||
}catch(UserInputError $e){
|
||||
}catch(UserInputError $e){
|
||||
$this->app->getErrorInstance()->UserInputHandler($e);
|
||||
}catch(BaseError $e){
|
||||
}catch(BaseError $e){
|
||||
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
||||
}catch(NotImplementedError $e){
|
||||
}catch(NotImplementedError $e){
|
||||
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
||||
}catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
}catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -420,15 +420,15 @@ class networkLayer3 {
|
|||
}
|
||||
}catch(BadResponseError $e){
|
||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||
}catch(UserInputError $e){
|
||||
}catch(UserInputError $e){
|
||||
$this->app->getErrorInstance()->UserInputHandler($e);
|
||||
}catch(BaseError $e){
|
||||
}catch(BaseError $e){
|
||||
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
||||
}catch(NotImplementedError $e){
|
||||
}catch(NotImplementedError $e){
|
||||
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
||||
}catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
}catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -437,7 +437,7 @@ class networkLayer3 {
|
|||
*
|
||||
* @param string router the router to delete
|
||||
*
|
||||
* @return void
|
||||
* @return NULL
|
||||
*/
|
||||
private function deleteRouter(){
|
||||
$id = $this->app->getPostParam("id");
|
||||
|
@ -468,15 +468,15 @@ class networkLayer3 {
|
|||
}
|
||||
}catch(BadResponseError $e){
|
||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||
}catch(UserInputError $e){
|
||||
}catch(UserInputError $e){
|
||||
$this->app->getErrorInstance()->UserInputHandler($e);
|
||||
}catch(BaseError $e){
|
||||
}catch(BaseError $e){
|
||||
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
||||
}catch(NotImplementedError $e){
|
||||
}catch(NotImplementedError $e){
|
||||
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
||||
}catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
}catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -485,7 +485,7 @@ class networkLayer3 {
|
|||
*
|
||||
* @param id the id of the floatingip to update
|
||||
*
|
||||
* @return void
|
||||
* @return NULL
|
||||
*/
|
||||
private function updateRouter(){
|
||||
$id = $this->app->getPostParam("id");
|
||||
|
@ -507,7 +507,7 @@ class networkLayer3 {
|
|||
foreach ($res as $f) {
|
||||
if(strcmp($f->id, $id)){
|
||||
$result = $f;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -518,14 +518,14 @@ class networkLayer3 {
|
|||
}
|
||||
}catch(BadResponseError $e){
|
||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||
}catch(UserInputError $e){
|
||||
}catch(UserInputError $e){
|
||||
$this->app->getErrorInstance()->UserInputHandler($e);
|
||||
}catch(BaseError $e){
|
||||
}catch(BaseError $e){
|
||||
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
||||
}catch(NotImplementedError $e){
|
||||
}catch(NotImplementedError $e){
|
||||
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
||||
}catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
}catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
150
server/index.php
150
server/index.php
|
@ -1,70 +1,88 @@
|
|||
<?php
|
||||
require "vendor/autoload.php";
|
||||
include_once("config.inc.php");
|
||||
include_once("init.php");
|
||||
/**
|
||||
* File containing the code for the API door.
|
||||
*
|
||||
* @version 1.0 Initialisation of this file
|
||||
* @since 1.0 Core application's file
|
||||
*
|
||||
* @author Eole 'eoledev at outlook . fr'
|
||||
*
|
||||
*/
|
||||
|
||||
//loading dependencies
|
||||
require "vendor/autoload.php";
|
||||
//Include general config file
|
||||
include_once("config.inc.php");
|
||||
//Include API initialisation
|
||||
include_once("init.php");
|
||||
|
||||
if(isset($_POST["task"]) && isset($_POST["action"])){
|
||||
$task = $_POST["task"];
|
||||
$action = $_POST["action"];
|
||||
}else if(isset($_POST["task"]) && $_POST["task"] == "Authenticate" || $_POST["task"] == "Deauthenticate"){
|
||||
$task = $_POST["task"];
|
||||
}else{
|
||||
$App->setOutput("Error", "Invalid Request!");
|
||||
$App->show();
|
||||
exit();
|
||||
}
|
||||
|
||||
//Authentification and deauthentification request
|
||||
if($task == "Authenticate"){
|
||||
|
||||
if(isset($_POST["task"]) && isset($_POST["action"])){
|
||||
$task = $_POST["task"];
|
||||
$action = $_POST["action"];
|
||||
}else if(isset($_POST["task"]) && $_POST["task"] == "Authenticate" || $_POST["task"] == "Deauthenticate"){
|
||||
$task = $_POST["task"];
|
||||
}else{
|
||||
//Gestion Erreur
|
||||
$App->authenticate();
|
||||
$App->show();
|
||||
|
||||
}else if($task == "Deauthenticate"){
|
||||
|
||||
$App->deauthenticate();
|
||||
$App->show();
|
||||
|
||||
}else if($App->checkToken()){
|
||||
//Task switcher and task's file loader
|
||||
switch($task)
|
||||
{
|
||||
case "identity":
|
||||
include_once("core/Identity.php");
|
||||
$identityObject = new identity($App);
|
||||
$identityObject->action($action);
|
||||
$App->show();
|
||||
break;
|
||||
|
||||
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"){
|
||||
|
||||
$App->authenticate();
|
||||
$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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}else{
|
||||
//Request without authentication
|
||||
$App->setOutput("Error", "Token Invalide");
|
||||
$App->show();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,48 +1,55 @@
|
|||
<?php
|
||||
include_once("core/App.php");
|
||||
/**
|
||||
* File containing the initialisation of the API.
|
||||
*
|
||||
* @version 1.0 Initialisation of this file
|
||||
* @since 1.0 Core application's file
|
||||
*
|
||||
* @author Eole 'eoledev at outlook . fr'
|
||||
*
|
||||
*/
|
||||
|
||||
$user = "";
|
||||
$password = "";
|
||||
$project = "";
|
||||
|
||||
|
||||
//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";
|
||||
|
||||
}*/
|
||||
include_once("core/App.php");
|
||||
|
||||
$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"]
|
||||
);
|
||||
|
||||
$App = new App($Args);
|
||||
$user = "";
|
||||
$password = "";
|
||||
$project = "";
|
||||
|
||||
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);
|
||||
?>
|
||||
|
|
Loading…
Add table
Reference in a new issue