trying test floatingip
This commit is contained in:
parent
2d260aa6f5
commit
3795d05a97
3 changed files with 53 additions and 24 deletions
|
@ -63,6 +63,11 @@ class AppTest{
|
||||||
$opt = $this->tokenClass->getOptions($service);
|
$opt = $this->tokenClass->getOptions($service);
|
||||||
return $this->openstack->networkingV2($opt);
|
return $this->openstack->networkingV2($opt);
|
||||||
break;
|
break;
|
||||||
|
case "FloatingIp":
|
||||||
|
if($this->tokenPost == NULL) $this->tokenClass->genNetworkToken();
|
||||||
|
$opt = $this->tokenClass->getOptions($service);
|
||||||
|
return $this->openstack->networkingV2ExtLayer3($opt);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,23 +2,27 @@
|
||||||
include('InitTest.php');
|
include('InitTest.php');
|
||||||
include_once("../core/Image.php");
|
include_once("../core/Image.php");
|
||||||
include_once("../core/Compute.php");
|
include_once("../core/Compute.php");
|
||||||
include_once("../core/Network.php");
|
//include_once("../core/Network.php");
|
||||||
|
//include_once("../core/Automating.php");
|
||||||
include_once("../core/FloatingIp.php");
|
include_once("../core/FloatingIp.php");
|
||||||
include_once("../core/Automating.php");
|
|
||||||
|
|
||||||
$image = new Image($App);
|
$image = new Image($App);
|
||||||
$compute = new Compute($App);
|
$compute = new Compute($App);
|
||||||
$network = new Network($App);
|
//$network = new Network($App);
|
||||||
$floatingIp = new FloatingIp($App);
|
$floatingIp = new FloatingIp($App);
|
||||||
$automating = new Automating($App);
|
//$automating = new Automating($App);
|
||||||
|
|
||||||
|
|
||||||
$compute->listServers();
|
|
||||||
|
|
||||||
|
// Liste des serveurs
|
||||||
|
$compute->action("listServers");
|
||||||
$servers = json_decode($App->show(), true)["Servers"];
|
$servers = json_decode($App->show(), true)["Servers"];
|
||||||
|
|
||||||
foreach($servers as $server){
|
foreach($servers as $server){
|
||||||
echo $server->name." ".$server->id."<br>";
|
echo $server['name']." ".$server['id']."<br>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// liste des floatingip
|
||||||
|
$floatingIp->action("listFloatingIp");
|
||||||
|
$listFloatingIp = json_decode($App->show(), true)["FloatingIp"];
|
||||||
|
foreach ($listFloatingIp as $floatIp){
|
||||||
|
echo $floatIp['floating_ip_address']." ".$floatIp['id']." ".$floatIp["status"]."<br>";
|
||||||
|
}
|
||||||
?>
|
?>
|
|
@ -14,7 +14,7 @@ use OpenCloud\Common\Error\BaseError;
|
||||||
use OpenCloud\Common\Error\NotImplementedError;
|
use OpenCloud\Common\Error\NotImplementedError;
|
||||||
use OpenCloud\Common\Error\UserInputError;
|
use OpenCloud\Common\Error\UserInputError;
|
||||||
|
|
||||||
include("CoreInterface.php");
|
//include("CoreInterface.php");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Image Class of the back-end application
|
* Image Class of the back-end application
|
||||||
|
@ -22,7 +22,7 @@ include("CoreInterface.php");
|
||||||
* Management of images
|
* Management of images
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class floatingIp implements Core{
|
class floatingIp {
|
||||||
|
|
||||||
/** @var App $app protected, contains the main app object */
|
/** @var App $app protected, contains the main app object */
|
||||||
protected $app;
|
protected $app;
|
||||||
|
@ -31,11 +31,11 @@ class floatingIp implements Core{
|
||||||
protected $libClass;
|
protected $libClass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Image constructor
|
* floatingip constructor
|
||||||
*
|
*
|
||||||
* @param App $app the main app object
|
* @param App $app the main app object
|
||||||
*
|
*
|
||||||
* @return Image
|
* @return floatingip
|
||||||
*/
|
*/
|
||||||
public function __construct($app){
|
public function __construct($app){
|
||||||
if(!isset($app)){
|
if(!isset($app)){
|
||||||
|
@ -57,6 +57,36 @@ class floatingIp implements Core{
|
||||||
$this->{$action.""}();
|
$this->{$action.""}();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List floatingip
|
||||||
|
*
|
||||||
|
* @return list of the floatingip
|
||||||
|
*/
|
||||||
|
private function listFloatingIp(){
|
||||||
|
try{
|
||||||
|
$result = array();
|
||||||
|
$l = $this->libClass->getFloatingIps();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
foreach ($l as $tmp) {
|
||||||
|
$serult[] = $tmp;
|
||||||
|
}
|
||||||
|
$this->app->setOutput("FloatingIp", $result);
|
||||||
|
}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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new floating IP adress
|
* Create a new floating IP adress
|
||||||
*
|
*
|
||||||
|
@ -72,7 +102,7 @@ class floatingIp implements Core{
|
||||||
}
|
}
|
||||||
try{
|
try{
|
||||||
$floatingip = $this->libClass->create($opt);
|
$floatingip = $this->libClass->create($opt);
|
||||||
if(!isset){
|
if(!isset($floatingip)){
|
||||||
$this->app->setOutput("Error", "Unknowing error during floating ip creation");
|
$this->app->setOutput("Error", "Unknowing error during floating ip creation");
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
@ -118,9 +148,6 @@ class floatingIp implements Core{
|
||||||
|
|
||||||
$floatingip->update();
|
$floatingip->update();
|
||||||
|
|
||||||
if(!isset){
|
|
||||||
$this->app->setOutput("Error", "Unknowing error during floating ip creation");
|
|
||||||
}
|
|
||||||
}catch(BadResponseError $e){
|
}catch(BadResponseError $e){
|
||||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||||
}catch(UserInputError $e){
|
}catch(UserInputError $e){
|
||||||
|
@ -161,9 +188,6 @@ class floatingIp implements Core{
|
||||||
|
|
||||||
$floatingip->delete();
|
$floatingip->delete();
|
||||||
|
|
||||||
if(!isset){
|
|
||||||
$this->app->setOutput("Error", "Unknowing error during floating ip creation");
|
|
||||||
}
|
|
||||||
}catch(BadResponseError $e){
|
}catch(BadResponseError $e){
|
||||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||||
}catch(UserInputError $e){
|
}catch(UserInputError $e){
|
||||||
|
@ -203,10 +227,6 @@ class floatingIp implements Core{
|
||||||
}
|
}
|
||||||
|
|
||||||
$floatingip->retrieve();
|
$floatingip->retrieve();
|
||||||
|
|
||||||
if(!isset){
|
|
||||||
$this->app->setOutput("Error", "Unknowing error during floating ip creation");
|
|
||||||
}
|
|
||||||
}catch(BadResponseError $e){
|
}catch(BadResponseError $e){
|
||||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||||
}catch(UserInputError $e){
|
}catch(UserInputError $e){
|
||||||
|
|
Loading…
Add table
Reference in a new issue