summaryrefslogtreecommitdiff
path: root/server/Test/imageTests.php
blob: a99fbd742d52a9c9078300a8002424909bd63a88 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
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['minDisk'] = 1;
$opt['protected'] = false;
$opt['minRam'] = 10;

$App->setPostParam('opt', $opt);
$image->action("createImage");
$retCreate = json_decode($App->show(), true)["Images"];
$idNew = $retCreate['id'];
*/




// Liste images
$image->action("listImage");
$im = $App->show();
$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>";
 }  

// 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");
*/


// Desactivate Images
/*
echo "Desactivate image : </br>";
echo $id."</br>";
$App->setPostParam('id', $id);
$err = $image->action("desactivateImage");
echo "</br>";
*/


// Reactivate Images
/*
echo $id."</br>";
$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>";
}
*/


/*
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>";
 }
*/
?>