This commit is contained in:
root 2016-03-23 11:31:51 +01:00
commit a26989103d
131 changed files with 8056 additions and 1164 deletions

View file

@ -3,10 +3,10 @@ include_once("core/Plugin_Api.php");
include_once("core/LibOverride/genTokenOptions.php");
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;
use OpenCloud\Common\Error\BadResponseError;
use OpenCloud\Common\Error\BaseError;
use OpenCloud\Common\Error\NotImplementedError;
use OpenCloud\Common\Error\UserInputError;
class App{
@ -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);
}
}

637
server/core/Compute.php Normal file → Executable file
View file

@ -1,7 +1,6 @@
<?php
//namespace istic-openstack\Server\core;
// TODO introduce error-handling based on errors specific to the compute module
use OpenStack\Common\Error;
use OpenCloud\Common\Error;
class compute
{
@ -12,11 +11,11 @@ class compute
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
*
@ -35,21 +34,51 @@ class compute
*/
public function listServers()
{
$serverList = $this->libClass->listServers(true);
$servers = Array();
foreach($serverList as $server){
$servers[$server->id] = Array();
$server->flavor->retrieve();
$server->image->retrieve();
$servers[$server->id]["id"] = $server->id;
$servers[$server->id]["name"] = $server->name;
$servers[$server->id]["imageId"] = $server->image->id;
$servers[$server->id]["flavorId"] = $server->flavor->id;
$servers[$server->id]["status"] = $server->status;
$servers[$server->id]["ram"] = $server->flavor->ram;
$servers[$server->id]["disk"] = $server->flavor->disk;
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;
}
$this->app->setOutput("Servers", $servers);
}
$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;
}
/**
@ -58,14 +87,36 @@ class compute
*/
public function listFlavors()
{
$flavorList = $this->libClass->listFlavors();
$flavors = Array();
foreach($flavorList as $flavor){
$flavors[$flavor->id] = Array();
$flavors[$flavor->id]["id"] = $flavor->id;
$flavors[$flavor->id]["name"] = $flavor->name;
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);
}
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;
}
/**
@ -74,37 +125,74 @@ class compute
*/
public function listImages()
{
$imageList = $this->libClass->listImages();
$images = Array();
foreach($imageList as $image){
$images[$image->id] = Array();
$images[$image->id]["id"] = $image->id;
$images[$image->id]["name"] = $image->name;
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);
}
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()
{
$server = $this->libClass->createServer();
}
*/
/**
/**
* Get server details.
* @return array
*/
public function getServer()
{
$serverId = $this->app->getPostParam("serverId");
$opt = array('id' => $serverId);
$server = $this->libClass->getServer($opt);
$server->retrieve();
$this->app->setOutput("MyServer", $server);
try{
$serverId = $this->app->getPostParam("serverId");
if(!isset($serverId)){
$this->app->setOutput("Error", "Server ID is missing, son!");
return;
}
$opt = array('id' => $serverId);
$server = $this->libClass->getServer($opt);
$server->retrieve();
$this->app->setOutput("MyServer", $server);
}
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;
}
/**
@ -113,11 +201,32 @@ class compute
*/
public function getFlavor()
{
$flavorId = $this->app->getPostParam("flavorId");
$opt = array('id' => $flavorId);
$flavor = $this->libClass->getFlavor($opt);
$flavor->retrieve();
$this->app->setOutput("MyFlavor", $flavor);
try{
$flavorId = $this->app->getPostParam("flavorId");
if(!isset($serverId)){
$this->app->setOutput("Error", "Flavor ID is missing, son!");
return;
}
$opt = array('id' => $flavorId);
$flavor = $this->libClass->getFlavor($opt);
$flavor->retrieve();
$this->app->setOutput("MyFlavor", $flavor);
}
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;
}
/**
@ -126,76 +235,400 @@ class compute
*/
public function getImage()
{
$imageId = $this->app->getPostParam("imageId");
$opt = array('id' => $imageId);
$image = $this->libClass->getImage($opt);
$image->retrieve();
$this->app->setOutput("MyImage", $image);
try{
$imageId = $this->app->getPostParam("imageId");
if(!isset($serverId)){
$this->app->setOutput("Error", "Image ID is missing, son!");
return;
}
$opt = array('id' => $imageId);
$image = $this->libClass->getImage($opt);
$image->retrieve();
$this->app->setOutput("MyImage", $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;
}
/* working on tests
public function update()
/**
* Create server.
* @return array
*/
public function createServer()
{
$image = $this->app->getServer(array $options = []);
try{
$name = $this->app->getPostParam("name");
$imageId = $this->app->getPostParam("imageId");
$flavorId = $this->app->getPostParam("flavorId");
if(!isset($name) || !isset($imageId) || !isset($flavorId)){
$this->app->setOutput("Error", "No, we don't let you create a server without a name OR image ID OR flavor ID.");
return;
}
$opt = array('name' => $name, 'imageId' => $imageId, 'flavorId' => $flavorId);
$server = $this->libClass->createServer($opt);
}
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;
}
public function delete()
/**
* update a server
* @return void
*/
public function updateServer()
{
//TODO
try{
$serverId = $this->app->getPostParam("serverId");
$newName = $this->app->getPostParam("newName");
$newIpv4 = $this->app->getPostParam("newIpv4");
$newIpv6 = $this->app->getPostParam("newIpv6");
if(!isset($serverId)|| !(isset($newName) || isset($newIpv4) || isset($newIpv6)) ){
$this->app->setOutput("Error", "You'll have to provide server ID and the new attribute(IP(v4/v6)/Name) you desire to update!");
return;
}
$opt = array('id' => $serverId);
$server = $this->libClass->getServer($opt);
if (isset($newName)){
if(isset($newIpv4)){
if(isset($newIpv6)){
$attr = array('name' => $newName, 'accessIPv4' => $newIPv4, 'accessIPv6' => $newIpv6);
}
else $attr = array('name' => $newName, 'accessIPv4' => $newIPv4);
}
else $attr = array('name' => $newName);
}
$server->update($attr);
$this->app->setOutput("Success", $serverId." has been updated successfully.");
}
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;
}
public function changePassword($newPassword)
/**
* Delete a server
* @return void
*/
public function deleteServer()
{
//TODO
try{
$serverId = $this->app->getPostParam("serverId");
if(!isset($serverId)){
$this->app->setOutput("Error", "Server ID is missing, son!");
return;
}
$opt = array('id' => $serverId);
$server = $this->libClass->getServer($opt);
$server->delete();
$this->app->setOutput("Success", $serverId." has been deleted successfully.");
}
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;
}
public function reboot($type = Enum::REBOOT_SOFT)
/**
* Change the password of a server
* @return void
*/
public function changePassword()
{
//TODO
try{
$serverId = $this->app->getPostParam("serverId");
$password = $this->app->getPostParam("newPassword");
if(!isset($serverId) || !isset($password)){
$this->app->setOutput("Error", "Server ID or new password missing.");
return;
}
$opt = array('id' => $serverId);
$server = $this->libClass->getServer($opt);
$server->changePassword($password);
$this->app->setOutput("Success", "Password for ".$serverId." has been updated successfully.");
}
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;
}
public function rebuild(array $options)
/**
* Reboot a server
* @return void
*/
public function reboot()
{
//TODO
try{
$serverId = $this->app->getPostParam("serverId");
if(!isset($serverId)){
$this->app->setOutput("Error", "Server ID is missing, son!");
return;
}
$opt = array('id' => $serverId);
$server = $this->libClass->getServer($opt);
$server->reboot();
$this->app->setOutput("Success", $serverId." has been deleted successfully.");
}
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;
}
public function resize($flavorId)
/**
* Rebuild a server
* @return void
*/
public function rebuild()
{
//TODO
$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;
}
/**
* Resize a server
* A call to this method has to be followed by either confirmResize or revertResize
* @return void
*/
public function resize()
{
try{
$serverId = $this->app->getPostParam("serverId");
$newFlavorId = $this->app->getPostParam("newFlavorId");
if(!isset($serverId)|| !isset($flavorId)){
$this->app->setOutput("Error", "You'll have to provide server ID and the new flavor ID!");
return;
}
$opt = array('id' => $serverId);
$server = $this->libClass->getServer($opt);
$server->resize($newFlavorId);
}
catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
}
catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
}
catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
}
catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
}
catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
return;
}
/**
* Confirm resize operation on a server
* @return void
*/
public function confirmResize()
{
//TODO
try{
$serverId = $this->app->getPostParam("serverId");
if(!isset($serverId)){
$this->app->setOutput("Error", "Server ID is missing!");
return;
}
$opt = array('id' => $serverId);
$server = $this->libClass->getServer($opt);
$server->confirmResize();
$this->app->setOutput("Success", $serverId." has been resized successfully as the new flavor.");
}
catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
}
catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
}
catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
}
catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
}
catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
return;
}
/**
* Revert resize operation on a server
* @return void
*/
public function revertResize()
{
//TODO
}
public function createImage(array $options)
{
//TODO
try{
$serverId = $this->app->getPostParam("serverId");
if(!isset($serverId)){
$this->app->setOutput("Error", "Server ID is missing!");
return;
}
$opt = array('id' => $serverId);
$server = $this->libClass->getServer($opt);
$server->revertResize();
$this->app->setOutput("Success", $serverId." : resize operation has been reverted to the old flavor.");
}
catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
}
catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
}
catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
}
catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
}
catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
return;
}
/**
* List private and public addresses of a server
* @return void
*/
public function listAddresses(array $options = [])
{
//TODO
try{
$serverId = $this->app->getPostParam("serverId");
if(!isset($serverId)){
$this->app->setOutput("Error", "Server ID is missing!");
return;
}
$opt = array('id' => $serverId);
$server = $this->libClass->getServer($opt);
$addresses = $server->listAddresses();
$this->app->setOutput("Addresses", $addresses);
}
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;
}
public function getMetadata()
{
//TODO
}
public function resetMetadata(array $metadata)
{
//TODO
}
public function mergeMetadata(array $metadata)
{
//TODO
}
public function getMetadataItem($key)
{
//TODO
}
public function deleteMetadataItem($key)
{
//TODO
}
*/
}

View file

@ -1,9 +1,9 @@
<?php
use OpenStack\Common\Error\BadResponseError;
use OpenStack\Common\Error\BaseError;
use OpenStack\Common\Error\NotImplementedError;
use OpenStack\Common\Error\UserInputError;
use OpenCloud\Common\Error\BadResponseError;
use OpenCloud\Common\Error\BaseError;
use OpenCloud\Common\Error\NotImplementedError;
use OpenCloud\Common\Error\UserInputError;
Class errorManagement{
@ -32,8 +32,12 @@ Class errorManagement{
public function UserInputHandler($error){
}
public function OtherException($error){
$this->app->setOutput("Error", $error->getMessage());
}
}
?>
?>

File diff suppressed because it is too large Load diff

860
server/core/Image.php Normal file → Executable file

File diff suppressed because it is too large Load diff

View file

@ -1,12 +1,12 @@
<?php
use GuzzleHttp\Client;
use OpenStack\Common\Transport\HandlerStack;
use OpenStack\Common\Transport\Middleware;
use OpenCloud\Common\Transport\HandlerStack;
use OpenCloud\Common\Transport\Middleware;
use OpenStack\Identity\v3\Service;
use OpenStack\Identity\v3\Api;
use OpenStack\Common\Auth\Token;
use OpenStack\Common\Transport\Utils;
use OpenCloud\Common\Auth\Token;
use OpenCloud\Common\Transport\Utils;
use OpenStack\Identity\v3\Models;
class genTokenOptions
@ -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"];