diff --git a/server/Test/AppTestClass.php b/server/Test/AppTestClass.php index 57dd422..b398088 100755 --- a/server/Test/AppTestClass.php +++ b/server/Test/AppTestClass.php @@ -1,12 +1,24 @@ >>>>>> Stashed changes +======= include_once("../core/ErrorManagement.php"); use OpenStack\Common\Error\BadResponseError; use OpenStack\Common\Error\BaseError; use OpenStack\Common\Error\NotImplementedError; use OpenStack\Common\Error\UserInputError; +>>>>>>> develop class AppTest{ diff --git a/server/composer.lock b/server/composer.lock index 4a9581a..6ab8a7f 100644 --- a/server/composer.lock +++ b/server/composer.lock @@ -71,16 +71,16 @@ }, { "name": "guzzlehttp/promises", - "version": "1.0.3", + "version": "1.1.0", "source": { "type": "git", "url": "https://github.com/guzzle/promises.git", - "reference": "b1e1c0d55f8083c71eda2c28c12a228d708294ea" + "reference": "bb9024c526b22f3fe6ae55a561fd70653d470aa8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/b1e1c0d55f8083c71eda2c28c12a228d708294ea", - "reference": "b1e1c0d55f8083c71eda2c28c12a228d708294ea", + "url": "https://api.github.com/repos/guzzle/promises/zipball/bb9024c526b22f3fe6ae55a561fd70653d470aa8", + "reference": "bb9024c526b22f3fe6ae55a561fd70653d470aa8", "shasum": "" }, "require": { @@ -118,20 +118,20 @@ "keywords": [ "promise" ], - "time": "2015-10-15 22:28:00" + "time": "2016-03-08 01:15:46" }, { "name": "guzzlehttp/psr7", - "version": "1.2.2", + "version": "1.2.3", "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "f5d04bdd2881ac89abde1fb78cc234bce24327bb" + "reference": "2e89629ff057ebb49492ba08e6995d3a6a80021b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/f5d04bdd2881ac89abde1fb78cc234bce24327bb", - "reference": "f5d04bdd2881ac89abde1fb78cc234bce24327bb", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/2e89629ff057ebb49492ba08e6995d3a6a80021b", + "reference": "2e89629ff057ebb49492ba08e6995d3a6a80021b", "shasum": "" }, "require": { @@ -176,7 +176,7 @@ "stream", "uri" ], - "time": "2016-01-23 01:23:02" + "time": "2016-02-18 21:54:00" }, { "name": "justinrainbow/json-schema", @@ -295,23 +295,29 @@ "source": { "type": "git", "url": "https://github.com/php-opencloud/openstack.git", - "reference": "15aca73f423166c7ef8337ba08615c103c66e931" + "reference": "f2ee77024843659d970817a9e7055bb40a3724f9" }, "dist": { "type": "zip", +<<<<<<< HEAD +<<<<<<< Updated upstream + "url": "https://api.github.com/repos/php-opencloud/openstack/zipball/15aca73f423166c7ef8337ba08615c103c66e931", +======= "url": "https://api.github.com/repos/php-opencloud/openstack/zipball/f2ee77024843659d970817a9e7055bb40a3724f9", +>>>>>>> develop "reference": "15aca73f423166c7ef8337ba08615c103c66e931", +======= + "url": "https://api.github.com/repos/php-opencloud/openstack/zipball/f2ee77024843659d970817a9e7055bb40a3724f9", + "reference": "f2ee77024843659d970817a9e7055bb40a3724f9", +>>>>>>> Stashed changes "shasum": "" }, "require": { - "guzzlehttp/guzzle": "~6.1", - "justinrainbow/json-schema": "~1.3", - "php": ">=5.6" + "php-opencloud/common": "dev-master" }, "require-dev": { "fabpot/php-cs-fixer": "~1.0", "jakub-onderka/php-parallel-lint": "0.*", - "phpspec/prophecy-phpunit": "~1.0", "phpunit/phpunit": "~4.0", "psr/log": "~1.0", "sami/sami": "dev-master", @@ -320,9 +326,7 @@ "type": "library", "autoload": { "psr-4": { - "OpenStack\\": "src/", - "OpenStack\\Test\\": "tests/unit/", - "OpenStack\\Integration\\": "tests/integration/" + "OpenStack\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -333,7 +337,7 @@ "homepage": "https://github.com/jamiehannaford" } ], - "time": "2016-01-25 10:35:10" + "time": "2016-03-08 14:37:14" }, { "name": "psr/http-message", diff --git a/server/core/App.php b/server/core/App.php index ceda7c9..d35ccc0 100755 --- a/server/core/App.php +++ b/server/core/App.php @@ -56,10 +56,10 @@ class App{ 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; + if($this->tokenPost == NULL) $this->tokenClass->genComputeToken(); + $opt = $this->tokenClass->getOptions($service); + return $this->openstack->computeV2($opt); + break; } } @@ -81,7 +81,29 @@ class App{ $this->errorClass->BaseErrorHandler($e); }catch(NotImplementedError $e){ $this->errorClass->NotImplementedHandler($e); - } + } + + } + + public function deauthenticate(){ + + try{ + + $this->tokenClass->revokeComputeToken(); + $this->tokenClass->revokeImageToken(); + $this->tokenClass->revokeNetworkToken(); + $this->tokenClass->revokeIdentityToken(); + + $this->setOutput("deauthenticate", "Ok"); + }catch(BadResponseError $e){ + $this->errorClass->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->errorClass->UserInputHandler($e); + }catch(BaseError $e){ + $this->errorClass->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->errorClass->NotImplementedHandler($e); + } } diff --git a/server/core/Image.php b/server/core/Image.php index f509cd6..f2af5cc 100644 --- a/server/core/Image.php +++ b/server/core/Image.php @@ -14,8 +14,10 @@ use OpenStack\Common\Error\BaseError; use OpenStack\Common\Error\NotImplementedError; use OpenStack\Common\Error\UserInputError; + include("CoreInterface.php"); + /** * Image Class of the back-end application * @@ -68,9 +70,15 @@ class image implements Core{ * options for the image creation * **/ +<<<<<<< HEAD + private function createImage(array $opt){ + +======= private function createImage(){ +>>>>>>> develop $opt = $this->app->getPostParam("opt"); + if(!isset($opt)){ $this->app->setOutput("Error", "Incorrect parameter"); } @@ -135,6 +143,7 @@ class image implements Core{ $this->app->getErrorInstance->NotImplementedHandler($e); } $this->app->setOutput("Images", $image); + } /** @@ -158,7 +167,9 @@ class image implements Core{ }catch(NotImplementedError $e){ $this->app->getErrorInstance->NotImplementedHandler($e); } + $this->app->setOutput("Images", $result); + } /** @@ -172,6 +183,7 @@ class image implements Core{ $id = $this->app->getPostParam("id"); if(!isset($id)){ $this->app->setOutput("Error", "Incorrect id parameter"); + } try{ $service = $this->libClass; @@ -179,7 +191,9 @@ class image implements Core{ if($image == null){ // if the image don't exists -> error $this->app->setOutput("Error", "Image doesn't exist"); } + $this->app->setOutput("Images", $image); + }catch(BadResponseError $e){ $this->app->getErrorInstance()->BadResponseHandler($e); }catch(UserInputError $e){ @@ -200,9 +214,11 @@ class image implements Core{ * @param array $opt * options for the image creation **/ + private function updateImage(){ $id = $this->app->getPostParam("id"); $opt = $this->app->getPostParam("opt"); + if(!isset($id)){ $this->app->setOutput("Error", "Incorrect id parameter"); } @@ -292,6 +308,7 @@ class image implements Core{ **/ private function reactivateImage(){ $id = $this->app->getPostParam("id"); + if(!isset($id)){ $this->app->setOutput("Error", "Incorrect parameter"); } @@ -322,6 +339,7 @@ class image implements Core{ **/ private function desactivateImage(){ $id = $this->app->getPostParam("id"); + if(!isset($id)){ $this->app->setOutput("Error", "Incorrect parameter"); } @@ -357,6 +375,7 @@ class image implements Core{ $id = $this->app->getPostParam("id"); $file_name = $this->app->getPostParam("file_name"); + if(!isset($id)){ $this->app->setOutput("Error", "Incorrect id parameter"); } @@ -389,8 +408,15 @@ class image implements Core{ * @param string $id * identifier of the image **/ +<<<<<<< HEAD + private function downloadImage($id){ +<<<<<<< HEAD +======= +======= private function downloadImage(){ +>>>>>>> develop $id = $this->app->getPostParam("id"); +>>>>>>> develop if(!isset($id)){ $this->app->setOutput("Error", "Incorrect parameter"); } @@ -462,6 +488,7 @@ class image implements Core{ private function listMemberImage(){ $image_id = $this->app->getPostParam("image_id"); $member_id = $this->app->getPostParam("member_id"); + if(!isset($image_id)){ $this->app->setOutput("Error", "Incorrect parameter image_id"); } @@ -503,6 +530,7 @@ class image implements Core{ private function detailMemberImage(){ $image_id = $this->app->getPostParam("image_id"); $member_id = $this->app->getPostParam("member_id"); + if(!isset($image_id)){ $this->app->setOutput("Error", "Incorrect parameter image_id"); } diff --git a/server/core/LibOverride/genTokenOptions.php b/server/core/LibOverride/genTokenOptions.php index 18d880f..bdae8a6 100755 --- a/server/core/LibOverride/genTokenOptions.php +++ b/server/core/LibOverride/genTokenOptions.php @@ -75,6 +75,12 @@ class genTokenOptions $this->optionsGlobal['Identity'] = $options; } + public function revokeIdentityToken(){ + $token = $this->unserializeToken($this->backup['Identity']['token']); + $this->optionsGlobal['Common']['identityService']->revokeToken($token->id); + + } + public function loadIdentityBackup($opt){ $options = $this->optionsGlobal['Common']; $options['catalogName'] = 'false'; @@ -123,6 +129,12 @@ class genTokenOptions $this->optionsGlobal['Image'] = $options; } + public function revokeImageToken(){ + $token = $this->unserializeToken($this->backup['Image']['token']); + $this->optionsGlobal['Common']['identityService']->revokeToken($token->id); + + } + public function loadImageBackup($opt){ $options = $this->optionsGlobal['Common']; $options['catalogName'] = 'glance'; @@ -157,7 +169,7 @@ class genTokenOptions $stack = HandlerStack::create(); - $stack->push(Middleware::authHandler($options['authHandler'], $token)); + $stack->push(Middleware::authHandler($options['authHandler'], $token)); $this->addDebugMiddleware($options, $stack); @@ -170,6 +182,12 @@ class genTokenOptions $this->optionsGlobal['Network'] = $options; } + public function revokeNetworkToken(){ + $token = $this->unserializeToken($this->backup['Network']['token']); + $this->optionsGlobal['Common']['identityService']->revokeToken($token->id); + + } + public function loadNetworkBackup($opt){ $options = $this->optionsGlobal['Common']; $options['catalogName'] = 'neutron'; @@ -217,6 +235,12 @@ class genTokenOptions $this->optionsGlobal['Compute'] = $options; } + public function revokeComputeToken(){ + $token = $this->unserializeToken($this->backup['Compute']['token']); + $this->optionsGlobal['Common']['identityService']->revokeToken($token->id); + + } + public function loadComputeBackup($opt){ $options = $this->optionsGlobal['Common']; @@ -245,7 +269,7 @@ class genTokenOptions private function saveBackup($name, $data){ $token = $this->serializeToken($data["token"]); $path = "core/LibOverride/projectTokenData/".$token['saved']["project"]["name"]; - error_log(print_r($path, true), 0); + //error_log(print_r($path, true), 0); file_put_contents("core/LibOverride/projectTokenData/".$token['saved']["project"]["name"], serialize($token['saved'])); $this->backup["roles"] = $token["roles"]; $this->backup["project"] = $token['saved']["project"]["name"]; diff --git a/server/index.php b/server/index.php old mode 100644 new mode 100755 index f888671..31feb08 --- a/server/index.php +++ b/server/index.php @@ -6,7 +6,7 @@ if(isset($_POST["task"]) && isset($_POST["action"])){ $task = $_POST["task"]; $action = $_POST["action"]; - }else if(isset($_POST["task"]) && $_POST["task"] == "Authenticate"){ + }else if(isset($_POST["task"]) && $_POST["task"] == "Authenticate" || $_POST["task"] == "Deauthenticate"){ $task = $_POST["task"]; }else{ //Gestion Erreur @@ -17,36 +17,44 @@ $App->authenticate(); $App->show(); + }else if($task == "Deauthenticate"){ + + $App->deauthenticate(); + $App->show(); + + }else{ + 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; + } + } - 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; - } +