From 869538121bdc07adba1637252bf1d7338f1a27de Mon Sep 17 00:00:00 2001 From: stupidon Date: Sun, 28 Feb 2016 10:48:28 +0100 Subject: updated Compute.php --- server/core/Compute.php | 146 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 146 insertions(+) (limited to 'server/core/Compute.php') diff --git a/server/core/Compute.php b/server/core/Compute.php index 8d1c8b6..3df3ada 100644 --- a/server/core/Compute.php +++ b/server/core/Compute.php @@ -1 +1,147 @@ +app = $app; + $this->libClass = $app->getLibClass("Compute"); + } + /** + * List servers. + * @return array + */ + public function listServers() + { + $servers = $this->libClass->listServers(); + return $servers; + } + /** + * List flavors. + * @return array + */ + public function listFlavors() + { + $flavors = $this->libClass->listFlavors(); + return $flavors; + } + /** + * List images. + * @return array + */ + public function listImages() + { + $images = $this->libClass->listImages(); + return $images; + } + /** + * Create server. + * @return array + + public function createServer(array $options) + { + + $server = $this->libClass->createServer(); + } + /** + * Get server details. + * @return array + */ + public function getServer(array $options = []) + { + $server = $this->libClass->getServer($options); + return $server; + } + /** + * Get flavor details. + * @return array + */ + public function getFlavor(array $options = []) + { + $flavor = $this->libClass->getFlavor($options); + return $flavor; + } + /** + * Get image details. + * @return array + */ + public function getImage(array $options = []) + { + $image = $this->libClass->getImage($options); + return $image; + } + //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 + } + +} -- cgit v1.2.3 From c6abd77fc241894a4052d4212c25b0e2291683a1 Mon Sep 17 00:00:00 2001 From: stupidon Date: Sun, 28 Feb 2016 10:56:56 +0100 Subject: syntax correction --- server/core/Compute.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'server/core/Compute.php') diff --git a/server/core/Compute.php b/server/core/Compute.php index 3df3ada..e95380e 100644 --- a/server/core/Compute.php +++ b/server/core/Compute.php @@ -47,7 +47,7 @@ class compute /** * Create server. * @return array - + */ public function createServer(array $options) { -- cgit v1.2.3 From 153c1f4602e7a8247c7dc3e59e64d5eb65260ef2 Mon Sep 17 00:00:00 2001 From: stupidon Date: Sun, 28 Feb 2016 19:50:33 +0100 Subject: updated Compute to use formatted return --- server/core/Compute.php | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'server/core/Compute.php') diff --git a/server/core/Compute.php b/server/core/Compute.php index e95380e..5a45362 100644 --- a/server/core/Compute.php +++ b/server/core/Compute.php @@ -24,7 +24,8 @@ class compute public function listServers() { $servers = $this->libClass->listServers(); - return $servers; + $this->app->setOutput("Servers", $servers); + return; } /** * List flavors. @@ -33,7 +34,8 @@ class compute public function listFlavors() { $flavors = $this->libClass->listFlavors(); - return $flavors; + $this->app->setOutput("Flavors", $flavors); + return; } /** * List images. @@ -42,7 +44,8 @@ class compute public function listImages() { $images = $this->libClass->listImages(); - return $images; + $this->app->setOutput("Images", $images); + return; } /** * Create server. @@ -60,7 +63,8 @@ class compute public function getServer(array $options = []) { $server = $this->libClass->getServer($options); - return $server; + $this->app->setOutput("MyServer", $server); + return; } /** * Get flavor details. @@ -69,7 +73,8 @@ class compute public function getFlavor(array $options = []) { $flavor = $this->libClass->getFlavor($options); - return $flavor; + $this->app->setOutput("MyFlavor", $flavor); + return; } /** * Get image details. @@ -78,9 +83,11 @@ class compute public function getImage(array $options = []) { $image = $this->libClass->getImage($options); - return $image; + $this->app->setOutput("MyImage", $image); + return; } - //working on tests + /* working on tests + public function update() { $image = $this->app->getServer(array $options = []); @@ -142,6 +149,6 @@ class compute { //TODO } - +*/ } -- cgit v1.2.3 From 847e4c04aea8c56ac4e4b8d12fcb405e78159026 Mon Sep 17 00:00:00 2001 From: stupidon Date: Sun, 28 Feb 2016 20:21:05 +0100 Subject: updated getserver, getimage and getflavor --- server/core/Compute.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'server/core/Compute.php') diff --git a/server/core/Compute.php b/server/core/Compute.php index 5a45362..1312083 100644 --- a/server/core/Compute.php +++ b/server/core/Compute.php @@ -51,7 +51,7 @@ class compute * Create server. * @return array */ - public function createServer(array $options) + public function createServer() { $server = $this->libClass->createServer(); @@ -60,9 +60,11 @@ class compute * Get server details. * @return array */ - public function getServer(array $options = []) + public function getServer() { - $server = $this->libClass->getServer($options); + $serverId = $this->app->getPostParam("serverId"); + $opt = array('id' => $serverId); + $server = $this->libClass->getServer($opt); $this->app->setOutput("MyServer", $server); return; } @@ -70,9 +72,11 @@ class compute * Get flavor details. * @return array */ - public function getFlavor(array $options = []) + public function getFlavor() { - $flavor = $this->libClass->getFlavor($options); + $flavorId = $this->app->getPostParam("flavorId"); + $opt = array('id' => $flavorId); + $flavor = $this->libClass->getFlavor($opt); $this->app->setOutput("MyFlavor", $flavor); return; } @@ -82,7 +86,9 @@ class compute */ public function getImage(array $options = []) { - $image = $this->libClass->getImage($options); + $imageId = $this->app->getPostParam("imageId"); + $opt = array('id' => $imageId); + $image = $this->libClass->getImage($opt); $this->app->setOutput("MyImage", $image); return; } -- cgit v1.2.3 From 79a65198e45076c5db58be3e749d533d3f4acc03 Mon Sep 17 00:00:00 2001 From: stupidon Date: Sun, 28 Feb 2016 20:29:18 +0100 Subject: minor corrections --- server/core/Compute.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'server/core/Compute.php') diff --git a/server/core/Compute.php b/server/core/Compute.php index 1312083..84af889 100644 --- a/server/core/Compute.php +++ b/server/core/Compute.php @@ -84,7 +84,7 @@ class compute * Get image details. * @return array */ - public function getImage(array $options = []) + public function getImage() { $imageId = $this->app->getPostParam("imageId"); $opt = array('id' => $imageId); -- cgit v1.2.3 From c67651168a08cdd5209fafedea86c48c3fe6d6f0 Mon Sep 17 00:00:00 2001 From: stupidon Date: Sun, 28 Feb 2016 20:49:52 +0100 Subject: updated action --- server/core/Compute.php | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'server/core/Compute.php') diff --git a/server/core/Compute.php b/server/core/Compute.php index 84af889..fdc6b20 100644 --- a/server/core/Compute.php +++ b/server/core/Compute.php @@ -17,10 +17,22 @@ class compute $this->app = $app; $this->libClass = $app->getLibClass("Compute"); } - /** - * List servers. - * @return array - */ + /** + * 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(); @@ -50,12 +62,13 @@ class compute /** * Create server. * @return array - */ + * public function createServer() { $server = $this->libClass->createServer(); } + */ /** * Get server details. * @return array -- cgit v1.2.3 From 8ea4b64f9305fd493bce2967063190586531e3aa Mon Sep 17 00:00:00 2001 From: stupidon Date: Sun, 28 Feb 2016 21:23:28 +0100 Subject: updated get functions --- server/core/Compute.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'server/core/Compute.php') diff --git a/server/core/Compute.php b/server/core/Compute.php index fdc6b20..94e219c 100644 --- a/server/core/Compute.php +++ b/server/core/Compute.php @@ -78,6 +78,7 @@ class compute $serverId = $this->app->getPostParam("serverId"); $opt = array('id' => $serverId); $server = $this->libClass->getServer($opt); + $server->retrieve(); $this->app->setOutput("MyServer", $server); return; } @@ -90,6 +91,7 @@ class compute $flavorId = $this->app->getPostParam("flavorId"); $opt = array('id' => $flavorId); $flavor = $this->libClass->getFlavor($opt); + $flavor->retrieve(); $this->app->setOutput("MyFlavor", $flavor); return; } @@ -102,6 +104,7 @@ class compute $imageId = $this->app->getPostParam("imageId"); $opt = array('id' => $imageId); $image = $this->libClass->getImage($opt); + $image->retrieve(); $this->app->setOutput("MyImage", $image); return; } -- cgit v1.2.3 From 2d0a01358def95161d45d41f728b9bec93d652dc Mon Sep 17 00:00:00 2001 From: stupidon Date: Mon, 29 Feb 2016 16:59:27 +0100 Subject: fixed list function output format --- server/core/Compute.php | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'server/core/Compute.php') diff --git a/server/core/Compute.php b/server/core/Compute.php index 94e219c..6bdb46a 100644 --- a/server/core/Compute.php +++ b/server/core/Compute.php @@ -35,7 +35,15 @@ class compute */ public function listServers() { - $servers = $this->libClass->listServers(); + $serverList = $this->libClass->listServers(); + $servers = Array(); + foreach($serverList as $server){ + $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"; + } $this->app->setOutput("Servers", $servers); return; } @@ -45,7 +53,12 @@ class compute */ public function listFlavors() { - $flavors = $this->libClass->listFlavors(); + $flavorList = $this->libClass->listFlavors(); + $flavors = Array(); + foreach($flavorList as $flavor){ + $flavors["$flavor->id"]["id"] = "$flavor->id; + $flavors["$flavor->id"]["name"] = "$flavor->name"; + } $this->app->setOutput("Flavors", $flavors); return; } @@ -55,7 +68,12 @@ class compute */ public function listImages() { - $images = $this->libClass->listImages(); + $imageList = $this->libClass->listImages(); + $images = Array(); + foreach($imageList as $image){ + $images["$image->id"]["id"] = "$image->id; + $images["$image->id"]["name"] = "$image->name"; + } $this->app->setOutput("Images", $images); return; } -- cgit v1.2.3 From 3bf50ae06f84d60a5890454ef216c9251d3670d2 Mon Sep 17 00:00:00 2001 From: stupidon Date: Tue, 1 Mar 2016 13:19:39 +0100 Subject: fixed syntax error --- server/core/Compute.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'server/core/Compute.php') diff --git a/server/core/Compute.php b/server/core/Compute.php index 6bdb46a..17cd2ea 100644 --- a/server/core/Compute.php +++ b/server/core/Compute.php @@ -38,11 +38,11 @@ class compute $serverList = $this->libClass->listServers(); $servers = Array(); foreach($serverList as $server){ - $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"]["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; } $this->app->setOutput("Servers", $servers); return; @@ -56,8 +56,8 @@ class compute $flavorList = $this->libClass->listFlavors(); $flavors = Array(); foreach($flavorList as $flavor){ - $flavors["$flavor->id"]["id"] = "$flavor->id; - $flavors["$flavor->id"]["name"] = "$flavor->name"; + $flavors["$flavor->id"]["id"] = $flavor->id; + $flavors["$flavor->id"]["name"] = $flavor->name; } $this->app->setOutput("Flavors", $flavors); return; @@ -71,8 +71,8 @@ class compute $imageList = $this->libClass->listImages(); $images = Array(); foreach($imageList as $image){ - $images["$image->id"]["id"] = "$image->id; - $images["$image->id"]["name"] = "$image->name"; + $images["$image->id"]["id"] = $image->id; + $images["$image->id"]["name"] = $image->name; } $this->app->setOutput("Images", $images); return; -- cgit v1.2.3 From dfd0566a9dfb8c012db832b4aea119858056a7d2 Mon Sep 17 00:00:00 2001 From: stupidon Date: Tue, 1 Mar 2016 16:12:19 +0100 Subject: minor correction in list output format --- server/core/Compute.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'server/core/Compute.php') diff --git a/server/core/Compute.php b/server/core/Compute.php index 17cd2ea..bdc9753 100644 --- a/server/core/Compute.php +++ b/server/core/Compute.php @@ -38,11 +38,11 @@ class compute $serverList = $this->libClass->listServers(); $servers = Array(); foreach($serverList as $server){ - $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]["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; } $this->app->setOutput("Servers", $servers); return; @@ -56,8 +56,8 @@ class compute $flavorList = $this->libClass->listFlavors(); $flavors = Array(); foreach($flavorList as $flavor){ - $flavors["$flavor->id"]["id"] = $flavor->id; - $flavors["$flavor->id"]["name"] = $flavor->name; + $flavors[$flavor->id]["id"] = $flavor->id; + $flavors[$flavor->id]["name"] = $flavor->name; } $this->app->setOutput("Flavors", $flavors); return; @@ -71,8 +71,8 @@ class compute $imageList = $this->libClass->listImages(); $images = Array(); foreach($imageList as $image){ - $images["$image->id"]["id"] = $image->id; - $images["$image->id"]["name"] = $image->name; + $images[$image->id]["id"] = $image->id; + $images[$image->id]["name"] = $image->name; } $this->app->setOutput("Images", $images); return; -- cgit v1.2.3 From 53c507194d2304254f0ce7541568be29377f65c8 Mon Sep 17 00:00:00 2001 From: stupidon Date: Tue, 1 Mar 2016 16:29:49 +0100 Subject: further fix for 2-dimensional array output --- server/core/Compute.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'server/core/Compute.php') diff --git a/server/core/Compute.php b/server/core/Compute.php index bdc9753..1aad8a9 100644 --- a/server/core/Compute.php +++ b/server/core/Compute.php @@ -38,6 +38,7 @@ class compute $serverList = $this->libClass->listServers(); $servers = Array(); foreach($serverList as $server){ + $servers[$server->id] = Array(); $servers[$server->id]["id"] = $server->id; $servers[$server->id]["name"] = $server->name; $servers[$server->id]["imageId"] = $server->image->id; @@ -56,6 +57,7 @@ class compute $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; } @@ -71,6 +73,7 @@ class compute $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; } -- cgit v1.2.3 From f551dffd8a960d4a322ba2b99fd98a02dd98b402 Mon Sep 17 00:00:00 2001 From: stupidon Date: Tue, 1 Mar 2016 16:53:23 +0100 Subject: compute listServers fix --- server/core/Compute.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'server/core/Compute.php') diff --git a/server/core/Compute.php b/server/core/Compute.php index 1aad8a9..131d02c 100644 --- a/server/core/Compute.php +++ b/server/core/Compute.php @@ -35,7 +35,7 @@ class compute */ public function listServers() { - $serverList = $this->libClass->listServers(); + $serverList = $this->libClass->listServers(true); $servers = Array(); foreach($serverList as $server){ $servers[$server->id] = Array(); -- cgit v1.2.3 From 3c1fe7e6dcd80b19ed01ecf15fd0a69812a1bffa Mon Sep 17 00:00:00 2001 From: stupidon Date: Tue, 1 Mar 2016 18:52:29 +0100 Subject: added disksize and ram to listServers --- server/core/Compute.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'server/core/Compute.php') diff --git a/server/core/Compute.php b/server/core/Compute.php index 131d02c..720ab0c 100644 --- a/server/core/Compute.php +++ b/server/core/Compute.php @@ -44,6 +44,8 @@ class compute $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; } $this->app->setOutput("Servers", $servers); return; -- cgit v1.2.3 From 603645dbeb9e4a20f0b086c15fbc418bdee58d2b Mon Sep 17 00:00:00 2001 From: stupidon Date: Tue, 1 Mar 2016 20:02:27 +0100 Subject: fetch ram and disk for server's flavor in listServers --- server/core/Compute.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'server/core/Compute.php') diff --git a/server/core/Compute.php b/server/core/Compute.php index 720ab0c..a5b8375 100644 --- a/server/core/Compute.php +++ b/server/core/Compute.php @@ -39,6 +39,8 @@ class compute $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; -- cgit v1.2.3