end of floatingip
This commit is contained in:
parent
20dc35d9ab
commit
94ce37f517
3 changed files with 172 additions and 63 deletions
|
@ -44,18 +44,7 @@ foreach($servers as $server){
|
|||
}
|
||||
echo "</br>";
|
||||
|
||||
// liste des floatingip
|
||||
echo "Liste des floatingip : </br>";
|
||||
$floatingIp->action("listFloatingIp");
|
||||
$listFloatingIp = json_decode($App->show(), true)["FloatingIp"];
|
||||
$ip = null;
|
||||
foreach ($listFloatingIp as $floatIp){
|
||||
echo $floatIp['floatingIpAddress']." ".$floatIp['id']." ".$floatIp["status"]."<br>";
|
||||
$ip = $floatIp;
|
||||
}
|
||||
|
||||
echo "</br>";
|
||||
|
||||
/*
|
||||
// Création d'une ip flotante
|
||||
$opt = array();
|
||||
//$opt['floatingNetworkId'] = $id; !!!!! TOTALEMENT FAUX ici tu passe en parametre l id du serveur et non du network
|
||||
|
@ -72,15 +61,10 @@ $float = json_decode($App->show(), true)["FloatingIp"];
|
|||
if(!isset($float)){
|
||||
echo "Erreur pendant la création</br>";
|
||||
}
|
||||
else{
|
||||
foreach ($float as $f) {
|
||||
echo $f." ";
|
||||
}
|
||||
echo "<br>";
|
||||
}
|
||||
|
||||
|
||||
echo "</br>";
|
||||
*/
|
||||
|
||||
|
||||
|
||||
// liste des floatingip
|
||||
echo "Liste des floatingip : </br>";
|
||||
|
|
88
server/Test/floatingIpTests.php
Normal file
88
server/Test/floatingIpTests.php
Normal file
|
@ -0,0 +1,88 @@
|
|||
<?php
|
||||
|
||||
include('InitTest.php');
|
||||
include_once("../core/Compute.php");
|
||||
include_once("../core/Network.php");
|
||||
include_once("../core/FloatingIp.php");
|
||||
|
||||
$compute = new Compute($App);
|
||||
$network = new Network($App);
|
||||
$floatingIp = new FloatingIp($App);
|
||||
|
||||
|
||||
// Liste des serveurs
|
||||
echo "Liste des serveurs : </br>";
|
||||
$compute->action("listServers");
|
||||
$servers = json_decode($App->show(), true)["Servers"];
|
||||
$id = null;
|
||||
foreach($servers as $server){
|
||||
echo $server['name']." ".$server['id']." ".$server['ipv4']."<br>";
|
||||
if(strcmp($server['name'], "bob")){
|
||||
$id = $server['id'];
|
||||
}
|
||||
}
|
||||
echo "</br>";
|
||||
|
||||
|
||||
// Liste des networks
|
||||
echo "Liste des network : </br>";
|
||||
$network->action("list_network_ids");
|
||||
$servers = json_decode($App->show(), true)["ListNetworkIds"];
|
||||
$id = null;
|
||||
foreach($servers as $server){
|
||||
echo $server."<br>";
|
||||
}
|
||||
echo "</br>";
|
||||
|
||||
|
||||
// Liste des floatingip
|
||||
echo "Liste des floatingip : </br>";
|
||||
$floatingIp->action("listFloatingIp");
|
||||
$listFloatingIp = json_decode($App->show(), true)["FloatingIp"];
|
||||
$id = null;
|
||||
foreach ($listFloatingIp as $floatIp){
|
||||
echo $floatIp['floatingIpAddress']." ".$floatIp['id']." ".$floatIp["status"]."<br>";
|
||||
$id = $floatIp['id'];
|
||||
}
|
||||
echo "</br>";
|
||||
|
||||
|
||||
// Liste des floatingip
|
||||
echo "Get floatingip : </br>";
|
||||
$App->setPostParam('id', $id);
|
||||
$floatingIp->action("getFloatingIp");
|
||||
$getFloatingIp = json_decode($App->show(), true)["FloatingIp"];
|
||||
echo $getFloatingIp['id']."<br>";
|
||||
echo "</br>";
|
||||
|
||||
|
||||
/*
|
||||
// Création d'une ip flotante
|
||||
$opt = array();
|
||||
$opt['floatingNetworkId'] = "251b4641-20ff-4a72-8549-1758788b51ce";
|
||||
|
||||
$App->setPostParam('opt', $opt);
|
||||
$floatingIp->action("createFloatingIp");
|
||||
$float = json_decode($App->show(), true)["FloatingIp"];
|
||||
if(!isset($float)){
|
||||
echo "Erreur pendant la création</br>";
|
||||
}
|
||||
echo "</br>";
|
||||
*/
|
||||
|
||||
/*
|
||||
// Suppression d'une ip flotante
|
||||
$App->setPostParam('id', $id);
|
||||
$floatingIp->action("deleteFloatingIp");
|
||||
*/
|
||||
|
||||
// Liste des floatingip
|
||||
echo "Liste des floatingip : </br>";
|
||||
$floatingIp->action("listFloatingIp");
|
||||
$listFloatingIp = json_decode($App->show(), true)["FloatingIp"];
|
||||
foreach ($listFloatingIp as $floatIp){
|
||||
echo $floatIp['floatingIpAddress']." ".$floatIp['id']." ".$floatIp["status"]."<br>";
|
||||
}
|
||||
|
||||
|
||||
?>
|
|
@ -101,11 +101,10 @@ class floatingIp {
|
|||
}
|
||||
try{
|
||||
$floatingip = $this->libClass->createFloatingIp($opt);
|
||||
echo 'YOLO';
|
||||
|
||||
if(!isset($floatingip)){
|
||||
$this->app->setOutput("Error", "Unknowing error during floating ip creation");
|
||||
}
|
||||
else{
|
||||
}else{
|
||||
$this->app->setOutput("FloatingIp", $floatingip);
|
||||
}
|
||||
}catch(BadResponseError $e){
|
||||
|
@ -141,20 +140,29 @@ class floatingIp {
|
|||
}
|
||||
|
||||
try{
|
||||
/*$l = $this->listFloatingIp();
|
||||
$res = null;
|
||||
foreach ($l as $f) {
|
||||
if($f['id']==$id){
|
||||
$res = $f;
|
||||
// List of floating IPs
|
||||
$res = array();
|
||||
$l = $this->libClass->listFloatingIps();
|
||||
foreach ($l as $tmp) {
|
||||
$res[] = $tmp;
|
||||
}
|
||||
|
||||
// Verification if id exists
|
||||
$result = null;
|
||||
foreach ($res as $f) {
|
||||
if(strcmp($res['id'], $id)){
|
||||
$result = $f;
|
||||
|
||||
}
|
||||
}
|
||||
if(!isset($f)){
|
||||
|
||||
if(!isset($result)){ // If id doesn't exists
|
||||
$this->app->setOutput("Error", "Unknow id");
|
||||
}
|
||||
else{*/
|
||||
}else{ // If id exists
|
||||
$res = $this->libClass->getFloatingIp($id);
|
||||
$this->app->setOutput("FloatingIp", $res);
|
||||
//}
|
||||
}
|
||||
|
||||
}catch(BadResponseError $e){
|
||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||
}catch(UserInputError $e){
|
||||
|
@ -182,18 +190,29 @@ class floatingIp {
|
|||
$this->app->setOutput("Error", "Incorrect parameter opt");
|
||||
}
|
||||
try{
|
||||
$floatingips = listFloatingIps();
|
||||
$floatingIp = null;
|
||||
foreach ($floatingips as $f) {
|
||||
if($f['id'] == $id){
|
||||
$floatingIp = $f;
|
||||
}
|
||||
}
|
||||
if(!isset($floatingIp)){
|
||||
$this->app->setOutput("Error", "Unknowing floatingip id");
|
||||
|
||||
// List of floating IPs
|
||||
$res = array();
|
||||
$l = $this->libClass->listFloatingIps();
|
||||
foreach ($l as $tmp) {
|
||||
$res[] = $tmp;
|
||||
}
|
||||
|
||||
$floatingip->update();
|
||||
// Verification if id exists
|
||||
$result = null;
|
||||
foreach ($res as $f) {
|
||||
if(strcmp($res['id'], $id)){
|
||||
$result = $f;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(!isset($result)){ // If id doesn't exists
|
||||
$this->app->setOutput("Error", "Unknowing floatingip id");
|
||||
}else{
|
||||
$result->update();
|
||||
}
|
||||
|
||||
|
||||
}catch(BadResponseError $e){
|
||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||
|
@ -222,19 +241,27 @@ class floatingIp {
|
|||
$this->app->setOutput("Error", "Incorrect parameter opt");
|
||||
}
|
||||
try{
|
||||
$floatingips = listFloatingIps();
|
||||
$floatingIp = null;
|
||||
foreach ($floatingips as $f) {
|
||||
if($f['id'] == $id){
|
||||
$floatingIp = $f;
|
||||
}
|
||||
}
|
||||
if(!isset($floatingIp)){
|
||||
$this->app->setOutput("Error", "Unknowing floatingip id");
|
||||
// List of floating IPs
|
||||
$res = array();
|
||||
$l = $this->libClass->listFloatingIps();
|
||||
foreach ($l as $tmp) {
|
||||
$res[] = $tmp;
|
||||
}
|
||||
|
||||
$floatingip->delete();
|
||||
|
||||
// Verification if id exists
|
||||
$result = null;
|
||||
foreach ($res as $f) {
|
||||
if(strcmp($res['id'], $id)){
|
||||
$result = $f;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(!isset($result)){ // If id doesn't exists
|
||||
$this->app->setOutput("Error", "Unknowing floatingip id");
|
||||
}else{
|
||||
$result->delete();
|
||||
}
|
||||
}catch(BadResponseError $e){
|
||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||
}catch(UserInputError $e){
|
||||
|
@ -248,6 +275,7 @@ class floatingIp {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve a floating ip
|
||||
*
|
||||
|
@ -262,18 +290,27 @@ class floatingIp {
|
|||
$this->app->setOutput("Error", "Incorrect parameter opt");
|
||||
}
|
||||
try{
|
||||
$floatingips = listFloatingIps();
|
||||
$floatingIp = null;
|
||||
foreach ($floatingips as $f) {
|
||||
if($f['id'] == $id){
|
||||
$floatingIp = $f;
|
||||
}
|
||||
}
|
||||
if(!isset($floatingIp)){
|
||||
$this->app->setOutput("Error", "Unknowing floatingip id");
|
||||
// List of floating IPs
|
||||
$res = array();
|
||||
$l = $this->libClass->listFloatingIps();
|
||||
foreach ($l as $tmp) {
|
||||
$res[] = $tmp;
|
||||
}
|
||||
|
||||
$floatingip->retrieve();
|
||||
// Verification if id exists
|
||||
$result = null;
|
||||
foreach ($res as $f) {
|
||||
if(strcmp($res['id'], $id)){
|
||||
$result = $f;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(!isset($result)){ // If id doesn't exists
|
||||
$this->app->setOutput("Error", "Unknowing floatingip id");
|
||||
}else{
|
||||
$result->retrieve();
|
||||
}
|
||||
}catch(BadResponseError $e){
|
||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||
}catch(UserInputError $e){
|
||||
|
|
Loading…
Add table
Reference in a new issue