Modifications qui seront validées :

modifié :         server/core/Image.php
	modifié :         server/test.php
This commit is contained in:
yogg@epsina.com 2016-01-31 10:56:52 +01:00
parent 721620a549
commit 83fd3eb19d
2 changed files with 114 additions and 91 deletions

View file

@ -1,15 +1,25 @@
<?php <?php
ini_set('display_errors', 1); ini_set('display_errors', 1);
date_default_timezone_set("Europe/Paris"); date_default_timezone_set("Europe/Paris");
require '../vendor/autoload.php'; //require '../vendor/autoload.php';
$options = Array(); class Image {
$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 = OpenStack\OpenStack($options); protected $oidentity;
//protected $plugins;
/*
* Constructor
*
* @param $openstack
*
* @param $options
*
*/
public function __construct($ostack, $options){ //, $apiP
$this->oidentity = $ostack->imagesV2($options);
//$this->plugins = $apiP;
}
public function create_image(array $opt){ public function create_image(array $opt){
$service = $openstack->imagesV2(); $service = $openstack->imagesV2();
@ -29,8 +39,11 @@ public function create_image(array $opt){
return $image; return $image;
} }
public function list_image(){ /*
$images = $openstack->imagesV2()->listImages(); * List images
*/
public function list_images(){
$images = $this->oidentity->listImages();
return $images; return $images;
} }
@ -91,6 +104,5 @@ public function download_image($id){
$image = $service->getImage($id); $image = $service->getImage($id);
$stream = $image->downloadData(); $stream = $image->downloadData();
} }
}
?> ?>

View file

@ -2,6 +2,7 @@
ini_set('display_errors', 1); ini_set('display_errors', 1);
date_default_timezone_set("Europe/Paris"); date_default_timezone_set("Europe/Paris");
require 'vendor/autoload.php'; require 'vendor/autoload.php';
include("core/Image.php");
$options = Array(); $options = Array();
$options["user"] = Array("name"=>"admin", "password"=>"ae5or6cn", "domain"=>["id"=>"Default"]); $options["user"] = Array("name"=>"admin", "password"=>"ae5or6cn", "domain"=>["id"=>"Default"]);
@ -26,11 +27,21 @@ $openstack = new OpenStack\OpenStack($options);
] ]
]); ]);
*/ */
$compute = $openstack->computeV2(["region" => "RegionOne"]); //$compute = $openstack->computeV2(["region" => "RegionOne"]);
//$image= $openstack->imagesV2(["region" => "RegionOne"]);
$optImage = Array();
$optImage["region"] = "RegionOne";
$image = new Image($openstack, $optImage);
$images = $image->list_images();
//var_dump($compute->client); //var_dump($compute->client);
//$servers = $compute->listServers(true); //$servers = $compute->listServers(true);
//foreach($servers as $server){ foreach($images as $i){
//echo $server->id." !!! "; //echo $server->id." !!! ";
// echo $server->name." !!! "; echo $i->name;
//} echo "</br>";
}