merge
This commit is contained in:
parent
6349739a6c
commit
cfce59d6dc
47 changed files with 500 additions and 52 deletions
|
@ -12,6 +12,7 @@ class AppTest{
|
|||
|
||||
protected $openstack;
|
||||
protected $pluginsApi;
|
||||
protected $postParams;
|
||||
protected $tokenClass;
|
||||
protected $tokenPost;
|
||||
protected $output;
|
||||
|
@ -23,8 +24,13 @@ class AppTest{
|
|||
$this->tokenClass = new genTokenOptions($args);
|
||||
$this->openstack = new OpenStack\OpenStack([]);
|
||||
$this->pluginsApi = plugin_api::getInstance();
|
||||
$this->output = array();
|
||||
$this->errorClass = new errorManagement($this);
|
||||
$this->output = array();
|
||||
<<<<<<< HEAD
|
||||
$this->errorClass = new errorManagement($this);
|
||||
=======
|
||||
$this->postParams = $_POST;
|
||||
>>>>>>> develop
|
||||
|
||||
}
|
||||
|
||||
|
@ -48,6 +54,16 @@ class AppTest{
|
|||
$opt = $this->tokenClass->getOptions($service);
|
||||
return $this->openstack->imagesV2($opt);
|
||||
break;
|
||||
case "Compute":
|
||||
if($this->tokenPost == NULL) $this->tokenClass->genComputeToken();
|
||||
$opt = $this->tokenClass->getOptions($service);
|
||||
return $this->openstack->computeV2($opt);
|
||||
break;
|
||||
case "Network":
|
||||
if($this->tokenPost == NULL) $this->tokenClass->genNetworkToken();
|
||||
$opt = $this->tokenClass->getOptions($service);
|
||||
return $this->openstack->networkingV2($opt);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -61,10 +77,21 @@ class AppTest{
|
|||
$this->tokenClass->genNetworkToken();
|
||||
|
||||
$this->setOutput("token", $this->tokenClass->getBackup());
|
||||
}catch(Exception $e){
|
||||
echo $e;
|
||||
exit();
|
||||
}
|
||||
}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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function getPostParam($name){
|
||||
|
||||
return $this->postParams[$name];
|
||||
|
||||
}
|
||||
|
||||
|
@ -75,12 +102,16 @@ class AppTest{
|
|||
}
|
||||
|
||||
public function show(){
|
||||
echo json_encode($this->output);
|
||||
return json_encode($this->output);
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
public function getErrorInstance(){
|
||||
|
||||
return $this->errorClass;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
=======
|
||||
}
|
||||
>>>>>>> develop
|
||||
|
|
20
server/Test/computeTest.php
Normal file
20
server/Test/computeTest.php
Normal file
|
@ -0,0 +1,20 @@
|
|||
re '../vendor/autoload.php';
|
||||
include('/istic-openstack/server/init.php');
|
||||
include_once("../core/Compute.php");
|
||||
$compute = new compute($App);
|
||||
|
||||
$servers = $compute->listServers();
|
||||
|
||||
$servers= $compute->listServers(true);
|
||||
foreach($servers as $server){
|
||||
//print_r($server);
|
||||
echo $server->name." ".$server->id."<br>";
|
||||
|
||||
//$opt = Array();
|
||||
//$opt['name'] = "Test";
|
||||
//$serverid = Array("id"=>"69d5bcc4-2fab-4634-b0d2-f455fee5b7bd");
|
||||
//$serverid["id"] = "{69d5bcc4-2fab-4634-b0d2-f455fee5b7bd}";
|
||||
//unset($server);
|
||||
//$server = $compute->getServer($serverid);
|
||||
//echo $server->name." ".$server->image;
|
||||
//$server->update(array('name' => 'test'));
|
15
server/core/App.php
Normal file → Executable file
15
server/core/App.php
Normal file → Executable file
|
@ -33,7 +33,7 @@ class App{
|
|||
public function setToken($token){
|
||||
|
||||
$this->tokenPost = $token;
|
||||
$this->tokenClass->loadBackup($his->tokenPost);
|
||||
$this->tokenClass->loadBackup($this->tokenPost);
|
||||
|
||||
}
|
||||
|
||||
|
@ -50,6 +50,16 @@ class App{
|
|||
$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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -95,6 +105,7 @@ class App{
|
|||
|
||||
public function show(){
|
||||
echo json_encode($this->output);
|
||||
//error_log(var_dump(json_encode($this->output), true), 0);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1 +1,176 @@
|
|||
<?php
|
||||
//namespace istic-openstack\Server\core;
|
||||
// TODO introduce error-handling based on errors specific to the compute module
|
||||
use OpenStack\Common\Error;
|
||||
|
||||
class compute
|
||||
{
|
||||
/** @var App $app protected, contains the main app object */
|
||||
protected $app;
|
||||
|
||||
/** @var OpenStack\Identity $libClass protected, contains the library Compute object */
|
||||
protected $libClass;
|
||||
|
||||
|
||||
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
|
||||
*/
|
||||
public function action($action){
|
||||
|
||||
$this->{$action.""}();
|
||||
|
||||
}
|
||||
/**
|
||||
* List servers.
|
||||
* @return array
|
||||
*/
|
||||
public function listServers()
|
||||
{
|
||||
$servers = $this->libClass->listServers();
|
||||
$this->app->setOutput("Servers", $servers);
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* List flavors.
|
||||
* @return array
|
||||
*/
|
||||
public function listFlavors()
|
||||
{
|
||||
$flavors = $this->libClass->listFlavors();
|
||||
$this->app->setOutput("Flavors", $flavors);
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* List images.
|
||||
* @return array
|
||||
*/
|
||||
public function listImages()
|
||||
{
|
||||
$images = $this->libClass->listImages();
|
||||
$this->app->setOutput("Images", $images);
|
||||
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);
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* Get flavor details.
|
||||
* @return array
|
||||
*/
|
||||
public function getFlavor()
|
||||
{
|
||||
$flavorId = $this->app->getPostParam("flavorId");
|
||||
$opt = array('id' => $flavorId);
|
||||
$flavor = $this->libClass->getFlavor($opt);
|
||||
$flavor->retrieve();
|
||||
$this->app->setOutput("MyFlavor", $flavor);
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* Get image details.
|
||||
* @return array
|
||||
*/
|
||||
public function getImage()
|
||||
{
|
||||
$imageId = $this->app->getPostParam("imageId");
|
||||
$opt = array('id' => $imageId);
|
||||
$image = $this->libClass->getImage($opt);
|
||||
$image->retrieve();
|
||||
$this->app->setOutput("MyImage", $image);
|
||||
return;
|
||||
}
|
||||
/* working on tests
|
||||
|
||||
public function update()
|
||||
{
|
||||
$image = $this->app->getServer(array $options = []);
|
||||
|
||||
}
|
||||
public function delete()
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
public function changePassword($newPassword)
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
public function reboot($type = Enum::REBOOT_SOFT)
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
public function rebuild(array $options)
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
public function resize($flavorId)
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
public function confirmResize()
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
public function revertResize()
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
public function createImage(array $options)
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
public function listAddresses(array $options = [])
|
||||
{
|
||||
//TODO
|
||||
}
|
||||
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
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
|
10
server/core/LibOverride/genTokenOptions.php
Normal file → Executable file
10
server/core/LibOverride/genTokenOptions.php
Normal file → Executable file
|
@ -260,13 +260,14 @@ class genTokenOptions
|
|||
public function loadBackup($back){
|
||||
|
||||
$backup = unserialize($back);
|
||||
|
||||
$this->backup["roles"] = $backup["roles"];
|
||||
$this->backup["project"] = $backup["project"];
|
||||
$this->backup["user"] = $backup["user"];
|
||||
loadComputeBackup($backup["Compute"]);
|
||||
loadIdentityBackup($backup["Identity"]);
|
||||
loadImageBackup($backup["Image"]);
|
||||
loadNetworkBackup($backup["Network"]);
|
||||
$this->loadComputeBackup($backup["Compute"]);
|
||||
$this->loadIdentityBackup($backup["Identity"]);
|
||||
$this->loadImageBackup($backup["Image"]);
|
||||
$this->loadNetworkBackup($backup["Network"]);
|
||||
|
||||
}
|
||||
|
||||
|
@ -324,6 +325,7 @@ class genTokenOptions
|
|||
|
||||
private function unserializeToken($tokenSerialized){
|
||||
$Saved = file_get_contents("core/LibOverride/projectTokenData/".$this->backup["project"]);
|
||||
$Saved = unserialize($Saved);
|
||||
$api = new Api();
|
||||
$token = new Models\Token($this->httpClient, $api);
|
||||
$token->methods = unserialize($tokenSerialized["methods"]);
|
||||
|
|
|
@ -27,12 +27,26 @@
|
|||
$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;
|
||||
}
|
||||
|
||||
|
|
2
server/vendor/php-opencloud/openstack
vendored
2
server/vendor/php-opencloud/openstack
vendored
|
@ -1 +1 @@
|
|||
Subproject commit 1419eb2e01164bb6b8b837df37724423907352d7
|
||||
Subproject commit 15aca73f423166c7ef8337ba08615c103c66e931
|
Loading…
Add table
Add a link
Reference in a new issue