Add create_image and delete_image

This commit is contained in:
yogg@epsina.com 2016-01-31 13:00:04 +01:00
parent 325362a386
commit 10a6cd146d
2 changed files with 33 additions and 11 deletions

View file

@ -21,17 +21,25 @@ class Image {
//$this->plugins = $apiP; //$this->plugins = $apiP;
} }
/*
* Details about an image
*
* @param array $opt
* options for the image creation
*
*/
public function create_image(array $opt){ public function create_image(array $opt){
// OPTIONS A VOIR // VOIR COMMENT RENDRE LES CHAMPS OPTIONNELS (SAUF NAME)
$image = $this->oidentity->createImage([ $image = $this->oidentity->createImage([
'name' => $opt[name], 'name' => $opt['name'],
'tags' => ['{tag1}', '{tag2}'], // A VOIR //'tags' => $opt['tag'], // A VOIR COMMENT CA MARCHE
'containerFormat' => $opt[containerFormat], 'containerFormat' => $opt['containerFormat'],
'diskFormat' => $opt[diskFormat], 'diskFormat' => $opt['diskFormat'],
'visibility' => $opt[visibility], 'visibility' => $opt['visibility'],
'minDisk' => 10, 'minDisk' => $opt['minDisk'],
'protected' => true, 'protected' => $opt['protected'],
'minRam' => 10, 'minRam' => $opt['minRam'],
]); ]);
return $image; return $image;

View file

@ -36,6 +36,17 @@ $optImage = Array();
$optImage["region"] = "RegionOne"; $optImage["region"] = "RegionOne";
$image = new Image($openstack, $optImage); $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 //Liste des images
$images = $image->list_images(); $images = $image->list_images();
@ -45,7 +56,7 @@ echo "</br>";
foreach($images as $i){ foreach($images as $i){
echo $i->name; echo $i->name;
if($i->name == "TinyCore"){ if($i->name == "Test"){
$id_image = $i->id; $id_image = $i->id;
} }
echo "</br>"; echo "</br>";
@ -54,6 +65,9 @@ echo "</br>";
// Détails Image // Détails Image
$details = $image->image_details($id_image); //$details = $image->image_details($id_image);
//$image->delete_image($id_image);
?> ?>