list_images and images_details
This commit is contained in:
parent
83fd3eb19d
commit
325362a386
2 changed files with 35 additions and 17 deletions
|
@ -22,10 +22,8 @@ class Image {
|
|||
}
|
||||
|
||||
public function create_image(array $opt){
|
||||
$service = $openstack->imagesV2();
|
||||
|
||||
// OPTIONS A VOIR
|
||||
$image = $service->createImage([
|
||||
$image = $this->oidentity->createImage([
|
||||
'name' => $opt[name],
|
||||
'tags' => ['{tag1}', '{tag2}'], // A VOIR
|
||||
'containerFormat' => $opt[containerFormat],
|
||||
|
@ -43,20 +41,27 @@ class Image {
|
|||
* List images
|
||||
*/
|
||||
public function list_images(){
|
||||
$images = $this->oidentity->listImages();
|
||||
$service = $this->oidentity;
|
||||
$images = $service->listImages();
|
||||
return $images;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Details about an image
|
||||
*
|
||||
* @param string $id
|
||||
* identifier of the image
|
||||
*
|
||||
*/
|
||||
public function image_details($id){
|
||||
$service = $openstack->imagesV2();
|
||||
$service = $this->oidentity;
|
||||
$image = $service->getImage($id);
|
||||
return $image;
|
||||
}
|
||||
|
||||
|
||||
public function update_image($id, array $opt){
|
||||
$service = $openstack->imagesV2();
|
||||
$service = $this->oidentity;
|
||||
|
||||
//OPTIONS A VOIR
|
||||
$image = $service->getImage($id);
|
||||
|
@ -73,26 +78,27 @@ class Image {
|
|||
|
||||
// RETOUR A VOIR
|
||||
public function delete_image($name){
|
||||
$openstack->imagesV2()->getImage($name)->delete();
|
||||
$service = $this->oidentity;
|
||||
$service->getImage($name)->delete();
|
||||
}
|
||||
|
||||
// RETOUR A VOIR
|
||||
public function reactivate_image($id){
|
||||
$service = $openstack->imagesV2();
|
||||
$service = $this->oidentity;
|
||||
$image = $service->getImage($id);
|
||||
$image->reactivate();
|
||||
}
|
||||
|
||||
// RETOUR A VOIR
|
||||
public function desactivate_function($id){
|
||||
$service = $openstack->imagesV2();
|
||||
$service = $this->oidentity;
|
||||
$image = $service->getImage($id);
|
||||
$image->deactivate();
|
||||
}
|
||||
|
||||
// RETOUR A VOIR
|
||||
public function upload_image($id, $file_name){
|
||||
$service = $openstack->imagesV2();
|
||||
$service = $this->oidentity;
|
||||
$image = $service->getImage($id);
|
||||
$stream = \GuzzleHttp\Psr7\stream_for(fopen($file_name, 'r')); // A VOIR
|
||||
$image->uploadData($stream);
|
||||
|
@ -100,7 +106,7 @@ class Image {
|
|||
|
||||
// RETOUR A VOIR
|
||||
public function download_image($id){
|
||||
$service = $openstack->imagesV2();
|
||||
$service = $this->oidentity;
|
||||
$image = $service->getImage($id);
|
||||
$stream = $image->downloadData();
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ $openstack = new OpenStack\OpenStack($options);
|
|||
// 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',
|
||||
|
@ -28,20 +27,33 @@ $openstack = new OpenStack\OpenStack($options);
|
|||
]);
|
||||
*/
|
||||
//$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);
|
||||
|
||||
|
||||
//Liste des images
|
||||
$images = $image->list_images();
|
||||
|
||||
//var_dump($compute->client);
|
||||
//$servers = $compute->listServers(true);
|
||||
echo "Images présentes :";
|
||||
echo "</br>";
|
||||
|
||||
foreach($images as $i){
|
||||
//echo $server->id." !!! ";
|
||||
echo $i->name;
|
||||
if($i->name == "TinyCore"){
|
||||
$id_image = $i->id;
|
||||
}
|
||||
echo "</br>";
|
||||
}
|
||||
echo "</br>";
|
||||
|
||||
|
||||
// Détails Image
|
||||
$details = $image->image_details($id_image);
|
||||
|
||||
?>
|
Loading…
Add table
Reference in a new issue