diff options
Diffstat (limited to 'server/core')
| -rwxr-xr-x | server/core/App.php | 32 | ||||
| -rw-r--r-- | server/core/Image.php | 28 | ||||
| -rwxr-xr-x | server/core/LibOverride/genTokenOptions.php | 28 |
3 files changed, 81 insertions, 7 deletions
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"]; |
