summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstupidon <bhupendra.siyag@gmail.com>2016-03-15 22:39:50 +0100
committerstupidon <bhupendra.siyag@gmail.com>2016-03-15 22:39:50 +0100
commitb50d3cc788038122b0afc22a3e94161e1848d022 (patch)
treeb1205138e1995d76259b4b8b8f221a29c4563bfe
parent3c1ac3a13d309d3ce46b80bac51b83ee6e25e369 (diff)
parentb8e08062f35c6327dbdb210c6b3d1045bd30c1c1 (diff)
Merge branch 'compute' into develop
-rw-r--r--server/core/Compute.php106
1 files changed, 95 insertions, 11 deletions
diff --git a/server/core/Compute.php b/server/core/Compute.php
index 64a88aa..37fc8ad 100644
--- a/server/core/Compute.php
+++ b/server/core/Compute.php
@@ -224,31 +224,115 @@ class compute
$this->app->setOutput("Success", $serverId." has been deleted successfully.");
return;
}
- /*
- public function changePassword($newPassword)
+ /**
+ * Change the password of a server
+ * @return void
+ */
+ public function changePassword()
{
- //TODO
+ $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.");
+ return;
}
- public function reboot($type = Enum::REBOOT_SOFT)
+ /**
+ * Reboot a server
+ * @return void
+ */
+ public function reboot()
{
- //TODO
+ $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.");
+ return;
}
- public function rebuild(array $options)
+ /**
+ * 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;
+ }
+ $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.");
+ return;
}
- public function resize($flavorId)
+ /**
+ * Resize a server
+ * A call to this method has to be followed by either confirmResize or revertResize
+ * @return void
+ */
+ public function resize()
{
- //TODO
+ $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);
+ return;
}
+ /**
+ * Confirm resize operation on a server
+ * @return void
+ */
public function confirmResize()
{
- //TODO
+ $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.");
+ return;
}
+ /**
+ * Revert resize operation on a server
+ * @return void
+ */
public function revertResize()
{
- //TODO
+ $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.");
+ return;
}
+ /*
public function createImage(array $options)
{
//TODO