istic-openstack/server/Test/imageTests.php

125 lines
2.4 KiB
PHP
Raw Normal View History

<?php
2016-03-02 16:00:46 +01:00
include('InitTest.php');
include_once("../core/Image.php");
2016-03-23 15:46:57 +01:00
include_once("../core/Compute.php");
2016-01-31 11:36:58 +01:00
2016-02-11 20:38:15 +01:00
$image = new Image($App);
2016-03-23 15:46:57 +01:00
$compute = new Compute($App);
// Création image
/*
echo "Création image :</br>";
2016-01-31 13:00:04 +01:00
$opt = Array();
$opt['name'] = "Test";
$opt['tags'] = ['test', 'openstack'];
//$opt['containerFormat'] = 'ami';
//$opt['diskFormat'] = 'iso';
2016-03-30 12:14:11 +02:00
//$opt['visibility'] = 'public';
2016-01-31 13:00:04 +01:00
$opt['minDisk'] = 1;
$opt['protected'] = false;
2016-01-31 13:00:04 +01:00
$opt['minRam'] = 10;
$App->setPostParam('opt', $opt);
$image->action("createImage");
$retCreate = json_decode($App->show(), true)["Images"];
$idNew = $retCreate['id'];
*/
2016-03-30 12:14:11 +02:00
2016-02-11 20:06:50 +01:00
// Liste images
2016-03-02 16:00:46 +01:00
$image->action("listImage");
$im = $App->show();
$images = json_decode($im, true)["Images"];
2016-03-30 12:14:11 +02:00
$res;
echo "List images :</br></br>";
foreach($images as $i){
2016-03-30 12:14:11 +02:00
$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>";
2016-03-30 12:14:11 +02:00
/*foreach ($i['tags'] as $tag) { // Tags
echo $tag."</br>";
2016-03-30 12:14:11 +02:00
}*/
echo "</br>";
}
2016-03-30 12:14:11 +02:00
// Delete Image
/*
$App->setPostParam('id', $res);
$image->action("deleteImage");
*/
2016-03-30 12:14:11 +02:00
/*
// 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>";
2016-03-30 12:14:11 +02:00
*/
/*
// Download image
$App->setPostParam('id', $id);
$image->action("downloadImage");
*/
// Desactivate Images
2016-03-30 12:14:11 +02:00
/*
echo "Desactivate image : </br>";
echo $id."</br>";
$App->setPostParam('id', $id);
$err = $image->action("desactivateImage");
echo "</br>";
2016-03-30 12:14:11 +02:00
*/
2016-03-23 15:46:57 +01:00
2016-03-30 12:14:11 +02:00
// Reactivate Images
/*
echo $id."</br>";
2016-03-30 12:14:11 +02:00
$App->setPostParam('id', $res);
$image->action("reactivateImage");
*/
/*
// 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>";
}
*/
/*
2016-03-23 15:46:57 +01:00
echo "Flavors: ";
echo "</br>";
2016-03-23 15:46:57 +01:00
$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>";
}
*/
2016-01-31 11:36:58 +01:00
?>