summaryrefslogtreecommitdiff
path: root/server/test.php
blob: ce262fa562213205abc3d0d44f2b4e35d9f7420c (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
<?php
ini_set('display_errors', 1);
date_default_timezone_set("Europe/Paris");
require 'vendor/autoload.php';
include("core/Image.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);

//$identity = $openstack->identityV3();
//var_dump($identity);
// Since usernames will not be unique across an entire OpenStack installation,
// when authenticating with them you must also provide your domain ID. You do
// not have to do this if you authenticate with a user ID.
/*$token = $identity->generateToken([
    'user' => [
        'name'     => 'admin',
        'password' => 'ae5or6cn',
        'domain'   => [
            'id' => 'Default'
        ]
    ]
	]);
 */
//$compute = $openstack->computeV2(["region" => "RegionOne"]);
//$image= $openstack->imagesV2(["region" => "RegionOne"]);
//var_dump($compute->client);
//$servers = $compute->listServers(true);

// Initialisation Image()
$optImage = Array();
$optImage["region"] = "RegionOne";
$image = new Image($openstack, $optImage);

$opt = Array();
$opt['name'] = "Test";
//$opt['tags'] = 'test';
$opt['containerFormat'] = 'ami';
$opt['diskFormat'] = 'iso';
$opt['visibility'] = 'public';
$opt['minDisk'] = 1;
$opt['protected'] = true;
$opt['minRam'] = 10;

//$new_image = $image->create_image($opt);

//Liste des images
$images = $image->list_images();

echo "Images présentes :";
echo "</br>";

foreach($images as $i){
	echo $i->name;
    if($i->name == "Test"){
        $id_image = $i->id;
    }
    echo "</br>";
}
echo "</br>";


// Détails Image
//$details = $image->image_details($id_image);

//$image->delete_image($id_image);


?>