diff options
| author | Yoggzo <yogg@epsina.com> | 2016-02-29 14:20:13 +0100 |
|---|---|---|
| committer | Yoggzo <yogg@epsina.com> | 2016-02-29 14:20:13 +0100 |
| commit | cfce59d6dc120848624e105614575ae0f48af81b (patch) | |
| tree | 348540cbed9dfce254a64ceee69977e9954b65e1 /server/core | |
| parent | 6349739a6c42d413e1bc1ea5068336187055c277 (diff) | |
merge
Diffstat (limited to 'server/core')
| -rwxr-xr-x[-rw-r--r--] | server/core/App.php | 15 | ||||
| -rw-r--r-- | server/core/Compute.php | 175 | ||||
| -rwxr-xr-x[-rw-r--r--] | server/core/LibOverride/genTokenOptions.php | 10 |
3 files changed, 194 insertions, 6 deletions
diff --git a/server/core/App.php b/server/core/App.php index babb3d9..edb75f6 100644..100755 --- a/server/core/App.php +++ b/server/core/App.php @@ -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);
}
-}
\ No newline at end of file +}
diff --git a/server/core/Compute.php b/server/core/Compute.php index 8d1c8b6..94e219c 100644 --- a/server/core/Compute.php +++ b/server/core/Compute.php @@ -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 + } +*/ +} diff --git a/server/core/LibOverride/genTokenOptions.php b/server/core/LibOverride/genTokenOptions.php index b71defa..50826ed 100644..100755 --- a/server/core/LibOverride/genTokenOptions.php +++ b/server/core/LibOverride/genTokenOptions.php @@ -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"]); |
