This commit is contained in:
manzerbredes 2016-03-28 12:17:43 +02:00
commit 53f65de9d4
88 changed files with 3596 additions and 694 deletions

View file

@ -22,7 +22,7 @@ class AppTest{
$this->tokenPost = NULL;
$this->tokenClass = new genTokenOptions($args);
$this->openstack = new OpenStack\OpenStack([]);
$this->openstack = new OpenStack\OpenStack(['authUrl' => $args["authUrl"]]);
$this->pluginsApi = plugin_api::getInstance();
$this->errorClass = new errorManagement($this);
$this->output = array();
@ -89,9 +89,11 @@ class AppTest{
}
public function getPostParam($name){
return $this->postParams[$name];
if(isset($this->postParams[$name])){
return $this->postParams[$name];
}else{
$this->setOutput("Error", "Missing parameter ".$name);
}
}
public function setPostParam($name, $value){

View file

@ -0,0 +1,26 @@
<?php
ini_set('display_errors', 1);
date_default_timezone_set("Europe/Paris");
require 'vendor/autoload.php';
$options = Array();
$options["user"] = Array("name"=>"admin", "password"=>"ae5or6cn", "domain"=>["id"=>"Default"]);
$options["scope"] = Array("project"=>Array("name"=>"admin", "domain"=>["id"=>"Default"]));
$options["authUrl"] = "http://148.60.11.31:5000/v3";
$openstack = new OpenStack\OpenStack($options);
$networking = $openstack->networkingV2(["region"=>"RegionOne"]);
$ls = $networking->listSubnets();
foreach ($ls as $subnet) {
echo $subnet->cidr."<br>";
}

View file

@ -0,0 +1,34 @@
<?php
ini_set('display_errors', 1);
date_default_timezone_set("Europe/Paris");
require 'vendor/autoload.php';
$options = Array();
$options["user"] = Array("name"=>"admin", "password"=>"ae5or6cn", "domain"=>["id"=>"Default"]);
$options["scope"] = Array("project"=>Array("name"=>"admin", "domain"=>["id"=>"Default"]));
$options["authUrl"] = "http://148.60.11.31:5000/v3";
$openstack = new OpenStack\OpenStack($options);
$networking = $openstack->networkingV2(["region"=>"RegionOne"]);
$ls = $networking->getNetwork('5f78d3c1-1f53-4be7-897b-cf3c797961e0');
try{
$ls->retrieve();
echo "oui";}
catch (OpenStack\Common\Error\BadResponseError $e){
echo "non"; }

View file

@ -0,0 +1,26 @@
<?php
ini_set('display_errors', 1);
date_default_timezone_set("Europe/Paris");
require 'vendor/autoload.php';
$options = Array();
$options["user"] = Array("name"=>"admin", "password"=>"ae5or6cn", "domain"=>["id"=>"Default"]);
$options["scope"] = Array("project"=>Array("name"=>"admin", "domain"=>["id"=>"Default"]));
$options["authUrl"] = "http://148.60.11.31:5000/v3";
$openstack = new OpenStack\OpenStack($options);
$networking = $openstack->networkingV2(["region"=>"RegionOne"]);
$ls = $networking->listNetworks();
foreach ($ls as $subnet) {
echo $subnet->id."<br>";
}

View file

@ -1,9 +1,14 @@
<?php
include('InitTest.php');
include_once("../core/Image.php");
include_once("../core/Compute.php");
$image = new Image($App);
$compute = new Compute($App);
// Création image
/*
echo "Création image :</br>";
$opt = Array();
$opt['name'] = "Test";
$opt['tags'] = ['test', 'openstack'];
@ -14,39 +19,96 @@ $opt['minDisk'] = 1;
$opt['protected'] = false;
$opt['minRam'] = 10;
//$App->setPostParam('id', 'sdfihlus154dfhj');
$err = $image->action("createImage");
$App->setPostParam('opt', $opt);
$image->action("createImage");
$retCreate = json_decode($App->show(), true)["Images"];
$idNew = $retCreate['id'];
*/
/*
// Delete Image
$App->setPostParam('id', $idNew);
$image->action("deleteImage");
*/
//Liste des images
// Liste images
$image->action("listImage");
$im = $App->show();
$images = json_decode($im, true)["Images"];
$recup;
echo "Images présentes :";
echo "</br>";
echo "List images :</br>";
foreach($images as $i){
$recup = $i;
echo $recup['name'];
echo $i['name']."</br>"; // Nom
echo $i['status']."</br>"; // Status
$id = $i['id']; // Id
echo $id."</br>";
foreach ($i['tags'] as $tag) { // Tags
echo $tag."</br>";
}
echo "</br>";
}
// Details images
echo "Détail image :</br>";
$App->setPostParam('id', $id);
$image->action("detailsImage");
$retDetails = json_decode($App->show(), true)["Images"];
echo $retDetails['id']."</br>";
echo "</br>";
/*
// Download image
$App->setPostParam('id', $id);
$image->action("downloadImage");
*/
// Desactivate Images
echo "Desactivate image : </br>";
echo $id."</br>";
$App->setPostParam('id', $id);
$err = $image->action("desactivateImage");
echo "</br>";
/*
// Resactivate Images
echo $id."</br>";
$App->setPostParam('id', $id);
$err = $image->action("resactivateImage");
*/
/*
// Details images
echo "Update image :</br>";
$optUpdate = Array();
$optUpdate['tags'] = ['ciros', 'testUpdate'];
$App->setPostParam('id', $id);
$App->setPostParam('opt', $optUpdate);
$image->action("updateImage");
$retDetails = json_decode($App->show(), true)["Images"];
foreach ($retDetails['tags'] as $tag) { // Tags
echo $tag."</br>";
}
*/
/*
echo "Flavors: ";
echo "</br>";
$compute->action("listFlavors");
$flavors = json_decode($App->show(), true)["Flavors"];
foreach($flavors as $f){
echo "Id=".$f['id'].", ";
echo "name=".$f['name'].", ";
echo "ram=".$f['ram'].", ";
echo "disk=".$f['disk'].", ";
echo "vcpus=".$f['vcpus'];
echo "</br>";
//echo $recup['id'];
}
echo "</br>";
echo "Erreur capturée: ";
echo "</br>";
/*
//$App->setPostParam('id', $recup['id']);
$App->setPostParam('id', 'sdfihlus154dfhj');
$err = $image->action("detailsImage");
$temp = $App->show();
$ret = json_decode($temp, true)["Images"];
echo $ret['id'];
*/
//$App->getPostParam("id");
*/
?>