summaryrefslogtreecommitdiff
path: root/server/Test/imageTests.php
diff options
context:
space:
mode:
Diffstat (limited to 'server/Test/imageTests.php')
-rwxr-xr-x[-rw-r--r--]server/Test/imageTests.php127
1 files changed, 92 insertions, 35 deletions
diff --git a/server/Test/imageTests.php b/server/Test/imageTests.php
index 3af12fc..a99fbd7 100644..100755
--- a/server/Test/imageTests.php
+++ b/server/Test/imageTests.php
@@ -1,68 +1,125 @@
<?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'];
//$opt['containerFormat'] = 'ami';
//$opt['diskFormat'] = 'iso';
-$opt['visibility'] = 'public';
+//$opt['visibility'] = 'public';
$opt['minDisk'] = 1;
$opt['protected'] = false;
$opt['minRam'] = 10;
-//$new_image = $image->createImage($opt);
+$App->setPostParam('opt', $opt);
+$image->action("createImage");
+$retCreate = json_decode($App->show(), true)["Images"];
+$idNew = $retCreate['id'];
+*/
+
+
-//Liste des images
+
+// Liste images
$image->action("listImage");
-//$images = $image->listImage();
$im = $App->show();
-$images = json_decode($im, true)["Images"];
-if(isset($images)){
- echo "Images présentes :";
- echo "</br>";
- foreach($images as $i){
- echo $i['name'];
- echo "</br>";
+$images = json_decode($im, true)["Images"];
+
+$res;
+echo "List images :</br></br>";
+foreach($images as $i){
+ $name = $i['name'];
+ if(strcmp($name,"Test") == 0)
+ {
+ $res = $i['id'];
}
+ echo $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>";
+ }
- if(isset($list)){
- foreach ($list as $l) {
- echo $l;
- echo "</br>";
- }
-}
-}
-else{
- echo "Aucune image présente\n";
-}
+// Delete Image
+ /*
+$App->setPostParam('id', $res);
+$image->action("deleteImage");
+*/
+/*
+// 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");
+*/
-// Détails Image
-//$details = $image->imageDetails($id_image);
-//$image->deleteImage('123456');
+// Desactivate Images
+/*
+echo "Desactivate image : </br>";
+echo $id."</br>";
+$App->setPostParam('id', $id);
+$err = $image->action("desactivateImage");
+echo "</br>";
+*/
-//$image->desactivateImage($id_image);
-//$image->reactivateImage($id_image);
-//$file_name = "/home/yogg/Downloads/TinyCore-6.4.1.iso";
-//$image->uploadImage($id_image, $file_name);
+// Reactivate Images
+/*
+echo $id."</br>";
+$App->setPostParam('id', $res);
+$image->action("reactivateImage");
+*/
-//$image->downloadImage($id_image);
/*
-$opt_update = Array();
-$opt_update['name'] = "Test";
-$opt_update['tags'] = null;
-
-$update = $image->updateImage($id_image, $opt_update);
-echo $update->name;
+// 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