defined rest of the server functions
This commit is contained in:
parent
3da0e2d81c
commit
b8e08062f3
1 changed files with 95 additions and 11 deletions
|
@ -224,31 +224,115 @@ class compute
|
||||||
$this->app->setOutput("Success", $serverId." has been deleted successfully.");
|
$this->app->setOutput("Success", $serverId." has been deleted successfully.");
|
||||||
return;
|
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()
|
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()
|
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)
|
public function createImage(array $options)
|
||||||
{
|
{
|
||||||
//TODO
|
//TODO
|
||||||
|
|
Loading…
Add table
Reference in a new issue