summaryrefslogtreecommitdiff
path: root/server/Test
diff options
context:
space:
mode:
Diffstat (limited to 'server/Test')
-rwxr-xr-xserver/Test/AppTestClass.php10
-rw-r--r--server/Test/DisplayListCidr.php26
-rw-r--r--server/Test/getIdNetwork.php34
-rw-r--r--server/Test/getNetwork.php26
-rwxr-xr-xserver/Test/imageTests.php104
5 files changed, 175 insertions, 25 deletions
diff --git a/server/Test/AppTestClass.php b/server/Test/AppTestClass.php
index e1631c5..a663514 100755
--- a/server/Test/AppTestClass.php
+++ b/server/Test/AppTestClass.php
@@ -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){
diff --git a/server/Test/DisplayListCidr.php b/server/Test/DisplayListCidr.php
new file mode 100644
index 0000000..119b218
--- /dev/null
+++ b/server/Test/DisplayListCidr.php
@@ -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>";
+}
+
+
+
+
+
+
+
+
+
diff --git a/server/Test/getIdNetwork.php b/server/Test/getIdNetwork.php
new file mode 100644
index 0000000..1e38627
--- /dev/null
+++ b/server/Test/getIdNetwork.php
@@ -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"; }
+
+
+
+
+
+
+
+
+
+
+
diff --git a/server/Test/getNetwork.php b/server/Test/getNetwork.php
new file mode 100644
index 0000000..4c76480
--- /dev/null
+++ b/server/Test/getNetwork.php
@@ -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>";
+}
+
+
+
+
+
+
+
+
+
diff --git a/server/Test/imageTests.php b/server/Test/imageTests.php
index 883387d..4adec08 100755
--- a/server/Test/imageTests.php
+++ b/server/Test/imageTests.php
@@ -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>";
- //echo $recup['id'];
- }
+ }
+
+
+// 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>";
-echo "Erreur capturée: ";
+
+
+/*
+// 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>";
-
- /*
- //$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");
+/*
+// 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>";
+ }
+*/
?> \ No newline at end of file