tentative ip publique
This commit is contained in:
parent
438b9b4dcd
commit
94629aeaf5
3 changed files with 111 additions and 7 deletions
|
@ -2,27 +2,84 @@
|
||||||
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/Automating.php");
|
||||||
include_once("../core/FloatingIp.php");
|
include_once("../core/FloatingIp.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);
|
||||||
|
|
||||||
// Liste des serveurs
|
// Liste des serveurs
|
||||||
|
echo "Liste des serveurs : </br>";
|
||||||
$compute->action("listServers");
|
$compute->action("listServers");
|
||||||
$servers = json_decode($App->show(), true)["Servers"];
|
$servers = json_decode($App->show(), true)["Servers"];
|
||||||
|
$id = null;
|
||||||
foreach($servers as $server){
|
foreach($servers as $server){
|
||||||
echo $server['name']." ".$server['id']."<br>";
|
echo $server['name']." ".$server['id']." ".$server['ipv4']."<br>";
|
||||||
|
if(strcmp($server['name'], "bob")){
|
||||||
|
$id = $server['id'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
echo "</br>";
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Liste des ports
|
||||||
|
echo "Liste des ports : </br>";
|
||||||
|
$network->action("listPorts");
|
||||||
|
$ports = json_decode($App->show(), true)["Network"];
|
||||||
|
foreach ($ports as $p) {
|
||||||
|
echo $p["fixedIps"]."</br>";
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
// liste des floatingip
|
// 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;
|
||||||
|
$opt['floatingip'] = $ip;
|
||||||
|
//$opt['tenantId'] = "fbf5f920a7954b61b352bc09ce5ae803 ";
|
||||||
|
//$opt['fixedIpAddress'] = "10.0.0.52";
|
||||||
|
//$opt['floatingIpAddress'] = "148.60.11.116";
|
||||||
|
//$opt['portId'] = "10.0.0.52";
|
||||||
|
|
||||||
|
$App->setPostParam('opt', $opt);
|
||||||
|
$floatingIp->action("createFloatingIp");
|
||||||
|
$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>";
|
||||||
$floatingIp->action("listFloatingIp");
|
$floatingIp->action("listFloatingIp");
|
||||||
$listFloatingIp = json_decode($App->show(), true)["FloatingIp"];
|
$listFloatingIp = json_decode($App->show(), true)["FloatingIp"];
|
||||||
foreach ($listFloatingIp as $floatIp){
|
foreach ($listFloatingIp as $floatIp){
|
||||||
echo "IP : ".$floatIp['floating_ip_address']." et ID: ".$floatIp['id']." ".$floatIp["status"]."<br>";
|
echo $floatIp['floatingIpAddress']." ".$floatIp['id']." ".$floatIp["status"]."<br>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -68,7 +68,6 @@ class floatingIp {
|
||||||
$result = array();
|
$result = array();
|
||||||
$l = $this->libClass->listFloatingIps();
|
$l = $this->libClass->listFloatingIps();
|
||||||
error_log(var_export($l, true), 0);
|
error_log(var_export($l, true), 0);
|
||||||
echo 'toto';
|
|
||||||
foreach ($l as $tmp) {
|
foreach ($l as $tmp) {
|
||||||
$result[] = $tmp;
|
$result[] = $tmp;
|
||||||
}
|
}
|
||||||
|
@ -101,13 +100,61 @@ class floatingIp {
|
||||||
$this->app->setOutput("Error", "Incorrect parameter opt");
|
$this->app->setOutput("Error", "Incorrect parameter opt");
|
||||||
}
|
}
|
||||||
try{
|
try{
|
||||||
$floatingip = $this->libClass->create($opt);
|
$floatingip = $this->libClass->createFloatingIp($opt);
|
||||||
|
echo 'YOLO';
|
||||||
if(!isset($floatingip)){
|
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{
|
||||||
$this->app->setOutput("FloatingIp", $floatingip);
|
$this->app->setOutput("FloatingIp", $floatingip);
|
||||||
}
|
}
|
||||||
|
}catch(BadResponseError $e){
|
||||||
|
echo $e."</br>";
|
||||||
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||||
|
}catch(UserInputError $e){
|
||||||
|
echo $e."</br>";
|
||||||
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
||||||
|
}catch(BaseError $e){
|
||||||
|
echo $e."</br>";
|
||||||
|
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
||||||
|
}catch(NotImplementedError $e){
|
||||||
|
echo $e."</br>";
|
||||||
|
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
||||||
|
}catch(Exception $e){
|
||||||
|
echo $e->getMessage()."</br>";
|
||||||
|
$this->app->getErrorInstance()->OtherException($e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show floatingip details
|
||||||
|
*
|
||||||
|
* @param String id the id of the floatingip
|
||||||
|
*
|
||||||
|
* @return floatingip details
|
||||||
|
*/
|
||||||
|
private function getFloatingIp(){
|
||||||
|
$id = $this->app->getPostParam("id");
|
||||||
|
if(!isset($id)){
|
||||||
|
$this->app->setOutput("Error", "Incorrect parameter opt");
|
||||||
|
}
|
||||||
|
|
||||||
|
try{
|
||||||
|
/*$l = $this->listFloatingIp();
|
||||||
|
$res = null;
|
||||||
|
foreach ($l as $f) {
|
||||||
|
if($f['id']==$id){
|
||||||
|
$res = $f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!isset($f)){
|
||||||
|
$this->app->setOutput("Error", "Unknow id");
|
||||||
|
}
|
||||||
|
else{*/
|
||||||
|
$res = $this->libClass->getFloatingIp($id);
|
||||||
|
$this->app->setOutput("FloatingIp", $res);
|
||||||
|
//}
|
||||||
}catch(BadResponseError $e){
|
}catch(BadResponseError $e){
|
||||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||||
}catch(UserInputError $e){
|
}catch(UserInputError $e){
|
||||||
|
|
|
@ -40,7 +40,7 @@ class network{
|
||||||
|
|
||||||
public function __construct($app){
|
public function __construct($app){
|
||||||
$this->app = $app;
|
$this->app = $app;
|
||||||
$this->libClass = $app->getLibClass("network");
|
$this->libClass = $app->getLibClass("Network");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue