syntax correction

This commit is contained in:
stupidon 2016-03-22 17:13:08 +01:00
commit 58f772e69c

View file

@ -34,6 +34,7 @@ class compute
*/
public function listServers()
{
try{
$serverList = $this->libClass->listServers(true);
$servers = Array();
foreach($serverList as $server){
@ -62,6 +63,22 @@ class compute
$servers[$server->id]["metadata"] = $server->metadata;
}
$this->app->setOutput("Servers", $servers);
}
catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
}
catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
}
catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
}
catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
}
catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
return;
}
/**
@ -70,6 +87,7 @@ class compute
*/
public function listFlavors()
{
try{
$flavorList = $this->libClass->listFlavors();
$flavors = Array();
foreach($flavorList as $flavor){
@ -83,6 +101,22 @@ class compute
$flavors[$flavor->id]["links"] = $flavor->links;
}
$this->app->setOutput("Flavors", $flavors);
}
catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
}
catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
}
catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
}
catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
}
catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
return;
}
/**
@ -91,6 +125,7 @@ class compute
*/
public function listImages()
{
try{
$imageList = $this->libClass->listImages();
$images = Array();
foreach($imageList as $image){
@ -108,6 +143,22 @@ class compute
$images[$image->id]["metadata"] = $image->metadata;
}
$this->app->setOutput("Images", $images);
}
catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
}
catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
}
catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
}
catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
}
catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
return;
}
/**
@ -116,6 +167,7 @@ class compute
*/
public function getServer()
{
try{
$serverId = $this->app->getPostParam("serverId");
if(!isset($serverId)){
$this->app->setOutput("Error", "Server ID is missing, son!");
@ -125,6 +177,22 @@ class compute
$server = $this->libClass->getServer($opt);
$server->retrieve();
$this->app->setOutput("MyServer", $server);
}
catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
}
catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
}
catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
}
catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
}
catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
return;
}
/**
@ -133,6 +201,7 @@ class compute
*/
public function getFlavor()
{
try{
$flavorId = $this->app->getPostParam("flavorId");
if(!isset($serverId)){
$this->app->setOutput("Error", "Flavor ID is missing, son!");
@ -142,6 +211,22 @@ class compute
$flavor = $this->libClass->getFlavor($opt);
$flavor->retrieve();
$this->app->setOutput("MyFlavor", $flavor);
}
catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
}
catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
}
catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
}
catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
}
catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
return;
}
/**
@ -150,6 +235,7 @@ class compute
*/
public function getImage()
{
try{
$imageId = $this->app->getPostParam("imageId");
if(!isset($serverId)){
$this->app->setOutput("Error", "Image ID is missing, son!");
@ -159,6 +245,22 @@ class compute
$image = $this->libClass->getImage($opt);
$image->retrieve();
$this->app->setOutput("MyImage", $image);
}
catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
}
catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
}
catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
}
catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
}
catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
return;
}
/**
@ -167,6 +269,7 @@ class compute
*/
public function createServer()
{
try{
$name = $this->app->getPostParam("name");
$imageId = $this->app->getPostParam("imageId");
$flavorId = $this->app->getPostParam("flavorId");
@ -177,6 +280,23 @@ class compute
$opt = array('name' => $name, 'imageId' => $imageId, 'flavorId' => $flavorId);
$server = $this->libClass->createServer($opt);
}
catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
}
catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
}
catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
}
catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
}
catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
return;
}
/**
* update a server
@ -184,6 +304,7 @@ class compute
*/
public function updateServer()
{
try{
$serverId = $this->app->getPostParam("serverId");
$newName = $this->app->getPostParam("newName");
$newIpv4 = $this->app->getPostParam("newIpv4");
@ -205,6 +326,22 @@ class compute
}
$server->update($attr);
$this->app->setOutput("Success", $serverId." has been updated successfully.");
}
catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
}
catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
}
catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
}
catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
}
catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
return;
}
/**
@ -213,6 +350,7 @@ class compute
*/
public function deleteServer()
{
try{
$serverId = $this->app->getPostParam("serverId");
if(!isset($serverId)){
$this->app->setOutput("Error", "Server ID is missing, son!");
@ -222,6 +360,22 @@ class compute
$server = $this->libClass->getServer($opt);
$server->delete();
$this->app->setOutput("Success", $serverId." has been deleted successfully.");
}
catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
}
catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
}
catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
}
catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
}
catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
return;
}
/**
@ -230,6 +384,7 @@ class compute
*/
public function changePassword()
{
try{
$serverId = $this->app->getPostParam("serverId");
$password = $this->app->getPostParam("newPassword");
if(!isset($serverId) || !isset($password)){
@ -240,6 +395,22 @@ class compute
$server = $this->libClass->getServer($opt);
$server->changePassword($password);
$this->app->setOutput("Success", "Password for ".$serverId." has been updated successfully.");
}
catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
}
catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
}
catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
}
catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
}
catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
return;
}
/**
@ -248,6 +419,7 @@ class compute
*/
public function reboot()
{
try{
$serverId = $this->app->getPostParam("serverId");
if(!isset($serverId)){
$this->app->setOutput("Error", "Server ID is missing, son!");
@ -257,6 +429,22 @@ class compute
$server = $this->libClass->getServer($opt);
$server->reboot();
$this->app->setOutput("Success", $serverId." has been deleted successfully.");
}
catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
}
catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
}
catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
}
catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
}
catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
return;
}
/**
@ -272,12 +460,36 @@ class compute
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;
try{
$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.");
}
catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
}
catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
}
catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
}
catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
}
catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
return;
}
/**
@ -287,6 +499,7 @@ class compute
*/
public function resize()
{
try{
$serverId = $this->app->getPostParam("serverId");
$newFlavorId = $this->app->getPostParam("newFlavorId");
if(!isset($serverId)|| !isset($flavorId)){
@ -296,6 +509,22 @@ class compute
$opt = array('id' => $serverId);
$server = $this->libClass->getServer($opt);
$server->resize($newFlavorId);
}
catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
}
catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
}
catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
}
catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
}
catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
return;
}
/**
@ -304,6 +533,7 @@ class compute
*/
public function confirmResize()
{
try{
$serverId = $this->app->getPostParam("serverId");
if(!isset($serverId)){
$this->app->setOutput("Error", "Server ID is missing!");
@ -313,6 +543,22 @@ class compute
$server = $this->libClass->getServer($opt);
$server->confirmResize();
$this->app->setOutput("Success", $serverId." has been resized successfully as the new flavor.");
}
catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
}
catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
}
catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
}
catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
}
catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
return;
}
/**
@ -321,6 +567,7 @@ class compute
*/
public function revertResize()
{
try{
$serverId = $this->app->getPostParam("serverId");
if(!isset($serverId)){
$this->app->setOutput("Error", "Server ID is missing!");
@ -330,37 +577,58 @@ class compute
$server = $this->libClass->getServer($opt);
$server->revertResize();
$this->app->setOutput("Success", $serverId." : resize operation has been reverted to the old flavor.");
}
catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
}
catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
}
catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
}
catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
}
catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
return;
}
/*
public function createImage(array $options)
{
//TODO
}
/**
* List private and public addresses of a server
* @return void
*/
public function listAddresses(array $options = [])
{
//TODO
try{
$serverId = $this->app->getPostParam("serverId");
if(!isset($serverId)){
$this->app->setOutput("Error", "Server ID is missing!");
return;
}
public function getMetadata()
{
//TODO
$opt = array('id' => $serverId);
$server = $this->libClass->getServer($opt);
$addresses = $server->listAddresses();
$this->app->setOutput("Addresses", $addresses);
}
public function resetMetadata(array $metadata)
{
//TODO
catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e);
}
public function mergeMetadata(array $metadata)
{
//TODO
catch(UserInputError $e){
$this->app->getErrorInstance()->UserInputHandler($e);
}
public function getMetadataItem($key)
{
//TODO
catch(BaseError $e){
$this->app->getErrorInstance()->BaseErrorHandler($e);
}
public function deleteMetadataItem($key)
{
//TODO
catch(NotImplementedError $e){
$this->app->getErrorInstance()->NotImplementedHandler($e);
}
catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e);
}
return;
}
*/
}