indentation and comments

This commit is contained in:
stupidon 2016-03-22 17:05:39 +01:00
parent 3372268aa1
commit 7a61955d85

View file

@ -35,34 +35,34 @@ class compute
public function listServers() public function listServers()
{ {
try{ try{
$serverList = $this->libClass->listServers(true); $serverList = $this->libClass->listServers(true);
$servers = Array(); $servers = Array();
foreach($serverList as $server){ foreach($serverList as $server){
$servers[$server->id] = Array(); $servers[$server->id] = Array();
$server->flavor->retrieve(); $server->flavor->retrieve();
$server->image->retrieve(); $server->image->retrieve();
$server->retrieve(); $server->retrieve();
$servers[$server->id]["id"] = $server->id; $servers[$server->id]["id"] = $server->id;
$servers[$server->id]["name"] = $server->name; $servers[$server->id]["name"] = $server->name;
$servers[$server->id]["image"] = $server->image; $servers[$server->id]["image"] = $server->image;
$servers[$server->id]["ram"] = $server->flavor->ram; $servers[$server->id]["ram"] = $server->flavor->ram;
$servers[$server->id]["disk"] = $server->flavor->disk; $servers[$server->id]["disk"] = $server->flavor->disk;
$servers[$server->id]["flavor"] = $server->flavor; $servers[$server->id]["flavor"] = $server->flavor;
$servers[$server->id]["status"] = $server->status; $servers[$server->id]["status"] = $server->status;
$servers[$server->id]["created"] = $server->created; $servers[$server->id]["created"] = $server->created;
$servers[$server->id]["updated"] = $server->updated; $servers[$server->id]["updated"] = $server->updated;
$servers[$server->id]["ipv4"] = $server->ipv4; $servers[$server->id]["ipv4"] = $server->ipv4;
$servers[$server->id]["ipv6"] = $server->ipv6; $servers[$server->id]["ipv6"] = $server->ipv6;
$servers[$server->id]["progress"] = $server->progress; $servers[$server->id]["progress"] = $server->progress;
$servers[$server->id]["hostId"] = $server->hostId; $servers[$server->id]["hostId"] = $server->hostId;
$servers[$server->id]["tenantId"] = $server->tenantId; $servers[$server->id]["tenantId"] = $server->tenantId;
$servers[$server->id]["userId"] = $server->userId; $servers[$server->id]["userId"] = $server->userId;
$servers[$server->id]["taskState"] = $server->taskState; $servers[$server->id]["taskState"] = $server->taskState;
$servers[$server->id]["addresses"] = $server->addresses; $servers[$server->id]["addresses"] = $server->addresses;
$servers[$server->id]["links"] = $server->links; $servers[$server->id]["links"] = $server->links;
$servers[$server->id]["metadata"] = $server->metadata; $servers[$server->id]["metadata"] = $server->metadata;
} }
$this->app->setOutput("Servers", $servers); $this->app->setOutput("Servers", $servers);
} }
catch(BadResponseError $e){ catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
@ -77,7 +77,7 @@ class compute
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
} }
catch(Exception $e){ catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
return; return;
} }
@ -88,17 +88,17 @@ class compute
public function listFlavors() public function listFlavors()
{ {
try{ try{
$flavorList = $this->libClass->listFlavors(); $flavorList = $this->libClass->listFlavors();
$flavors = Array(); $flavors = Array();
foreach($flavorList as $flavor){ foreach($flavorList as $flavor){
$flavors[$flavor->id] = Array(); $flavors[$flavor->id] = Array();
$flavor->retrieve(); $flavor->retrieve();
$flavors[$flavor->id]["id"] = $flavor->id; $flavors[$flavor->id]["id"] = $flavor->id;
$flavors[$flavor->id]["name"] = $flavor->name; $flavors[$flavor->id]["name"] = $flavor->name;
$flavors[$flavor->id]["ram"] = $flavor->ram; $flavors[$flavor->id]["ram"] = $flavor->ram;
$flavors[$flavor->id]["disk"] = $flavor->disk; $flavors[$flavor->id]["disk"] = $flavor->disk;
$flavors[$flavor->id]["vcpus"] = $flavor->vcpus; $flavors[$flavor->id]["vcpus"] = $flavor->vcpus;
$flavors[$flavor->id]["links"] = $flavor->links; $flavors[$flavor->id]["links"] = $flavor->links;
} }
$this->app->setOutput("Flavors", $flavors); $this->app->setOutput("Flavors", $flavors);
} }
@ -115,7 +115,7 @@ class compute
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
} }
catch(Exception $e){ catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
return; return;
} }
@ -126,21 +126,21 @@ class compute
public function listImages() public function listImages()
{ {
try{ try{
$imageList = $this->libClass->listImages(); $imageList = $this->libClass->listImages();
$images = Array(); $images = Array();
foreach($imageList as $image){ foreach($imageList as $image){
$images[$image->id] = Array(); $images[$image->id] = Array();
$image->retrieve(); $image->retrieve();
$images[$image->id]["id"] = $image->id; $images[$image->id]["id"] = $image->id;
$images[$image->id]["name"] = $image->name; $images[$image->id]["name"] = $image->name;
$images[$image->id]["status"] = $image->status; $images[$image->id]["status"] = $image->status;
$images[$image->id]["created"] = $image->created; $images[$image->id]["created"] = $image->created;
$images[$image->id]["updated"] = $image->updated; $images[$image->id]["updated"] = $image->updated;
$images[$image->id]["minDisk"] = $image->minDisk; $images[$image->id]["minDisk"] = $image->minDisk;
$images[$image->id]["minRam"] = $image->minRam; $images[$image->id]["minRam"] = $image->minRam;
$images[$image->id]["progress"] = $image->progress; $images[$image->id]["progress"] = $image->progress;
$images[$image->id]["links"] = $image->links; $images[$image->id]["links"] = $image->links;
$images[$image->id]["metadata"] = $image->metadata; $images[$image->id]["metadata"] = $image->metadata;
} }
$this->app->setOutput("Images", $images); $this->app->setOutput("Images", $images);
} }
@ -157,7 +157,7 @@ class compute
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
} }
catch(Exception $e){ catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
return; return;
} }
@ -168,15 +168,15 @@ class compute
public function getServer() public function getServer()
{ {
try{ try{
$serverId = $this->app->getPostParam("serverId"); $serverId = $this->app->getPostParam("serverId");
if(!isset($serverId)){ if(!isset($serverId)){
$this->app->setOutput("Error", "Server ID is missing, son!"); $this->app->setOutput("Error", "Server ID is missing, son!");
return; return;
} }
$opt = array('id' => $serverId); $opt = array('id' => $serverId);
$server = $this->libClass->getServer($opt); $server = $this->libClass->getServer($opt);
$server->retrieve(); $server->retrieve();
$this->app->setOutput("MyServer", $server); $this->app->setOutput("MyServer", $server);
} }
catch(BadResponseError $e){ catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
@ -191,7 +191,7 @@ class compute
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
} }
catch(Exception $e){ catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
return; return;
} }
@ -202,15 +202,15 @@ class compute
public function getFlavor() public function getFlavor()
{ {
try{ try{
$flavorId = $this->app->getPostParam("flavorId"); $flavorId = $this->app->getPostParam("flavorId");
if(!isset($serverId)){ if(!isset($serverId)){
$this->app->setOutput("Error", "Flavor ID is missing, son!"); $this->app->setOutput("Error", "Flavor ID is missing, son!");
return; return;
} }
$opt = array('id' => $flavorId); $opt = array('id' => $flavorId);
$flavor = $this->libClass->getFlavor($opt); $flavor = $this->libClass->getFlavor($opt);
$flavor->retrieve(); $flavor->retrieve();
$this->app->setOutput("MyFlavor", $flavor); $this->app->setOutput("MyFlavor", $flavor);
} }
catch(BadResponseError $e){ catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
@ -225,7 +225,7 @@ class compute
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
} }
catch(Exception $e){ catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
return; return;
} }
@ -236,15 +236,15 @@ class compute
public function getImage() public function getImage()
{ {
try{ try{
$imageId = $this->app->getPostParam("imageId"); $imageId = $this->app->getPostParam("imageId");
if(!isset($serverId)){ if(!isset($serverId)){
$this->app->setOutput("Error", "Image ID is missing, son!"); $this->app->setOutput("Error", "Image ID is missing, son!");
return; return;
} }
$opt = array('id' => $imageId); $opt = array('id' => $imageId);
$image = $this->libClass->getImage($opt); $image = $this->libClass->getImage($opt);
$image->retrieve(); $image->retrieve();
$this->app->setOutput("MyImage", $image); $this->app->setOutput("MyImage", $image);
} }
catch(BadResponseError $e){ catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
@ -259,7 +259,7 @@ class compute
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
} }
catch(Exception $e){ catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
return; return;
} }
@ -270,15 +270,15 @@ class compute
public function createServer() public function createServer()
{ {
try{ try{
$name = $this->app->getPostParam("name"); $name = $this->app->getPostParam("name");
$imageId = $this->app->getPostParam("imageId"); $imageId = $this->app->getPostParam("imageId");
$flavorId = $this->app->getPostParam("flavorId"); $flavorId = $this->app->getPostParam("flavorId");
if(!isset($name) || !isset($imageId) || !isset($flavorId)){ if(!isset($name) || !isset($imageId) || !isset($flavorId)){
$this->app->setOutput("Error", "No, we don't let you create a server without a name OR image ID OR flavor ID."); $this->app->setOutput("Error", "No, we don't let you create a server without a name OR image ID OR flavor ID.");
return; return;
} }
$opt = array('name' => $name, 'imageId' => $imageId, 'flavorId' => $flavorId); $opt = array('name' => $name, 'imageId' => $imageId, 'flavorId' => $flavorId);
$server = $this->libClass->createServer($opt); $server = $this->libClass->createServer($opt);
} }
catch(BadResponseError $e){ catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
@ -293,7 +293,7 @@ class compute
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
} }
catch(Exception $e){ catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
return; return;
} }
@ -305,27 +305,27 @@ class compute
public function updateServer() public function updateServer()
{ {
try{ try{
$serverId = $this->app->getPostParam("serverId"); $serverId = $this->app->getPostParam("serverId");
$newName = $this->app->getPostParam("newName"); $newName = $this->app->getPostParam("newName");
$newIpv4 = $this->app->getPostParam("newIpv4"); $newIpv4 = $this->app->getPostParam("newIpv4");
$newIpv6 = $this->app->getPostParam("newIpv6"); $newIpv6 = $this->app->getPostParam("newIpv6");
if(!isset($serverId)|| !(isset($newName) || isset($newIpv4) || isset($newIpv6)) ){ if(!isset($serverId)|| !(isset($newName) || isset($newIpv4) || isset($newIpv6)) ){
$this->app->setOutput("Error", "You'll have to provide server ID and the new attribute(IP(v4/v6)/Name) you desire to update!"); $this->app->setOutput("Error", "You'll have to provide server ID and the new attribute(IP(v4/v6)/Name) you desire to update!");
return; return;
}
$opt = array('id' => $serverId);
$server = $this->libClass->getServer($opt);
if (isset($newName)){
if(isset($newIpv4)){
if(isset($newIpv6)){
$attr = array('name' => $newName, 'accessIPv4' => $newIPv4, 'accessIPv6' => $newIpv6);
}
else $attr = array('name' => $newName, 'accessIPv4' => $newIPv4);
} }
else $attr = array('name' => $newName); $opt = array('id' => $serverId);
} $server = $this->libClass->getServer($opt);
$server->update($attr); if (isset($newName)){
$this->app->setOutput("Success", $serverId." has been updated successfully."); if(isset($newIpv4)){
if(isset($newIpv6)){
$attr = array('name' => $newName, 'accessIPv4' => $newIPv4, 'accessIPv6' => $newIpv6);
}
else $attr = array('name' => $newName, 'accessIPv4' => $newIPv4);
}
else $attr = array('name' => $newName);
}
$server->update($attr);
$this->app->setOutput("Success", $serverId." has been updated successfully.");
} }
catch(BadResponseError $e){ catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
@ -340,7 +340,7 @@ class compute
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
} }
catch(Exception $e){ catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
return; return;
} }
@ -351,15 +351,15 @@ class compute
public function deleteServer() public function deleteServer()
{ {
try{ try{
$serverId = $this->app->getPostParam("serverId"); $serverId = $this->app->getPostParam("serverId");
if(!isset($serverId)){ if(!isset($serverId)){
$this->app->setOutput("Error", "Server ID is missing, son!"); $this->app->setOutput("Error", "Server ID is missing, son!");
return; return;
} }
$opt = array('id' => $serverId); $opt = array('id' => $serverId);
$server = $this->libClass->getServer($opt); $server = $this->libClass->getServer($opt);
$server->delete(); $server->delete();
$this->app->setOutput("Success", $serverId." has been deleted successfully."); $this->app->setOutput("Success", $serverId." has been deleted successfully.");
} }
catch(BadResponseError $e){ catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
@ -374,7 +374,7 @@ class compute
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
} }
catch(Exception $e){ catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
return; return;
} }
@ -385,16 +385,16 @@ class compute
public function changePassword() public function changePassword()
{ {
try{ try{
$serverId = $this->app->getPostParam("serverId"); $serverId = $this->app->getPostParam("serverId");
$password = $this->app->getPostParam("newPassword"); $password = $this->app->getPostParam("newPassword");
if(!isset($serverId) || !isset($password)){ if(!isset($serverId) || !isset($password)){
$this->app->setOutput("Error", "Server ID or new password missing."); $this->app->setOutput("Error", "Server ID or new password missing.");
return; return;
} }
$opt = array('id' => $serverId); $opt = array('id' => $serverId);
$server = $this->libClass->getServer($opt); $server = $this->libClass->getServer($opt);
$server->changePassword($password); $server->changePassword($password);
$this->app->setOutput("Success", "Password for ".$serverId." has been updated successfully."); $this->app->setOutput("Success", "Password for ".$serverId." has been updated successfully.");
} }
catch(BadResponseError $e){ catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
@ -409,7 +409,7 @@ class compute
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
} }
catch(Exception $e){ catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
return; return;
} }
@ -420,15 +420,15 @@ class compute
public function reboot() public function reboot()
{ {
try{ try{
$serverId = $this->app->getPostParam("serverId"); $serverId = $this->app->getPostParam("serverId");
if(!isset($serverId)){ if(!isset($serverId)){
$this->app->setOutput("Error", "Server ID is missing, son!"); $this->app->setOutput("Error", "Server ID is missing, son!");
return; return;
} }
$opt = array('id' => $serverId); $opt = array('id' => $serverId);
$server = $this->libClass->getServer($opt); $server = $this->libClass->getServer($opt);
$server->reboot(); $server->reboot();
$this->app->setOutput("Success", $serverId." has been deleted successfully."); $this->app->setOutput("Success", $serverId." has been deleted successfully.");
} }
catch(BadResponseError $e){ catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
@ -443,7 +443,7 @@ class compute
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
} }
catch(Exception $e){ catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
return; return;
} }
@ -454,19 +454,19 @@ class compute
public function rebuild() public function rebuild()
{ {
try{ try{
$serverId = $this->app->getPostParam("serverId"); $serverId = $this->app->getPostParam("serverId");
$imageId = $this->app->getPostParam("imageId"); $imageId = $this->app->getPostParam("imageId");
$newName = $this->app->getPostParam("newName"); $newName = $this->app->getPostParam("newName");
$adminPass = $this->app->getPostParam("adminPass"); $adminPass = $this->app->getPostParam("adminPass");
if(!isset($serverId)|| !isset($imageId) || isset($newName) || isset($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!"); $this->app->setOutput("Error", "You'll have to provide server ID and the new image, name and admin password!");
return; return;
} }
$opt = array('id' => $serverId); $opt = array('id' => $serverId);
$server = $this->libClass->getServer($opt); $server = $this->libClass->getServer($opt);
$attr = array('imageId' => $imageId, 'name' => $newName, 'adminPass' => $adminPass); $attr = array('imageId' => $imageId, 'name' => $newName, 'adminPass' => $adminPass);
$server->rebuild($attr); $server->rebuild($attr);
$this->app->setOutput("Success", $serverId." has been rebuilt successfully with the new image."); $this->app->setOutput("Success", $serverId." has been rebuilt successfully with the new image.");
} }
catch(BadResponseError $e){ catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
@ -481,7 +481,7 @@ class compute
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
} }
catch(Exception $e){ catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
return; return;
} }
@ -493,15 +493,15 @@ class compute
public function resize() public function resize()
{ {
try{ try{
$serverId = $this->app->getPostParam("serverId"); $serverId = $this->app->getPostParam("serverId");
$newFlavorId = $this->app->getPostParam("newFlavorId"); $newFlavorId = $this->app->getPostParam("newFlavorId");
if(!isset($serverId)|| !isset($flavorId)){ if(!isset($serverId)|| !isset($flavorId)){
$this->app->setOutput("Error", "You'll have to provide server ID and the new flavor ID!"); $this->app->setOutput("Error", "You'll have to provide server ID and the new flavor ID!");
return; return;
} }
$opt = array('id' => $serverId); $opt = array('id' => $serverId);
$server = $this->libClass->getServer($opt); $server = $this->libClass->getServer($opt);
$server->resize($newFlavorId); $server->resize($newFlavorId);
} }
catch(BadResponseError $e){ catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
@ -516,7 +516,7 @@ class compute
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
} }
catch(Exception $e){ catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
return; return;
} }
@ -527,15 +527,15 @@ class compute
public function confirmResize() public function confirmResize()
{ {
try{ try{
$serverId = $this->app->getPostParam("serverId"); $serverId = $this->app->getPostParam("serverId");
if(!isset($serverId)){ if(!isset($serverId)){
$this->app->setOutput("Error", "Server ID is missing!"); $this->app->setOutput("Error", "Server ID is missing!");
return; return;
} }
$opt = array('id' => $serverId); $opt = array('id' => $serverId);
$server = $this->libClass->getServer($opt); $server = $this->libClass->getServer($opt);
$server->confirmResize(); $server->confirmResize();
$this->app->setOutput("Success", $serverId." has been resized successfully as the new flavor."); $this->app->setOutput("Success", $serverId." has been resized successfully as the new flavor.");
} }
catch(BadResponseError $e){ catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
@ -550,7 +550,7 @@ class compute
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
} }
catch(Exception $e){ catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
return; return;
} }
@ -561,15 +561,15 @@ class compute
public function revertResize() public function revertResize()
{ {
try{ try{
$serverId = $this->app->getPostParam("serverId"); $serverId = $this->app->getPostParam("serverId");
if(!isset($serverId)){ if(!isset($serverId)){
$this->app->setOutput("Error", "Server ID is missing!"); $this->app->setOutput("Error", "Server ID is missing!");
return; return;
} }
$opt = array('id' => $serverId); $opt = array('id' => $serverId);
$server = $this->libClass->getServer($opt); $server = $this->libClass->getServer($opt);
$server->revertResize(); $server->revertResize();
$this->app->setOutput("Success", $serverId." : resize operation has been reverted to the old flavor."); $this->app->setOutput("Success", $serverId." : resize operation has been reverted to the old flavor.");
} }
catch(BadResponseError $e){ catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
@ -584,22 +584,27 @@ class compute
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
} }
catch(Exception $e){ catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
return; return;
} }
/**
* List private and public addresses of a server
* @return void
*/
public function listAddresses(array $options = []) public function listAddresses(array $options = [])
{ {
try{ try{
$serverId = $this->app->getPostParam("serverId"); $serverId = $this->app->getPostParam("serverId");
if(!isset($serverId)){ if(!isset($serverId)){
$this->app->setOutput("Error", "Server ID is missing!"); $this->app->setOutput("Error", "Server ID is missing!");
return; return;
} }
$opt = array('id' => $serverId); $opt = array('id' => $serverId);
$server = $this->libClass->getServer($opt); $server = $this->libClass->getServer($opt);
$addresses = $server->listAddresses(); $addresses = $server->listAddresses();
$this->app->setOutput("Addresses", $addresses); $this->app->setOutput("Addresses", $addresses);
} }
catch(BadResponseError $e){ catch(BadResponseError $e){
$this->app->getErrorInstance()->BadResponseHandler($e); $this->app->getErrorInstance()->BadResponseHandler($e);
@ -614,7 +619,7 @@ class compute
$this->app->getErrorInstance()->NotImplementedHandler($e); $this->app->getErrorInstance()->NotImplementedHandler($e);
} }
catch(Exception $e){ catch(Exception $e){
$this->app->getErrorInstance()->OtherException($e); $this->app->getErrorInstance()->OtherException($e);
} }
return; return;
} }