From 10a6cd146db2bc509059d07ff8b7887445524cab Mon Sep 17 00:00:00 2001 From: "yogg@epsina.com" Date: Sun, 31 Jan 2016 13:00:04 +0100 Subject: [PATCH] Add create_image and delete_image --- server/core/Image.php | 26 +++++++++++++++++--------- server/test.php | 18 ++++++++++++++++-- 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/server/core/Image.php b/server/core/Image.php index 498ebe8..bf67e75 100644 --- a/server/core/Image.php +++ b/server/core/Image.php @@ -21,17 +21,25 @@ class Image { //$this->plugins = $apiP; } + + /* + * Details about an image + * + * @param array $opt + * options for the image creation + * + */ public function create_image(array $opt){ - // OPTIONS A VOIR + // VOIR COMMENT RENDRE LES CHAMPS OPTIONNELS (SAUF NAME) $image = $this->oidentity->createImage([ - 'name' => $opt[name], - 'tags' => ['{tag1}', '{tag2}'], // A VOIR - 'containerFormat' => $opt[containerFormat], - 'diskFormat' => $opt[diskFormat], - 'visibility' => $opt[visibility], - 'minDisk' => 10, - 'protected' => true, - 'minRam' => 10, + 'name' => $opt['name'], + //'tags' => $opt['tag'], // A VOIR COMMENT CA MARCHE + 'containerFormat' => $opt['containerFormat'], + 'diskFormat' => $opt['diskFormat'], + 'visibility' => $opt['visibility'], + 'minDisk' => $opt['minDisk'], + 'protected' => $opt['protected'], + 'minRam' => $opt['minRam'], ]); return $image; diff --git a/server/test.php b/server/test.php index 6881923..ce262fa 100644 --- a/server/test.php +++ b/server/test.php @@ -36,6 +36,17 @@ $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(); @@ -45,7 +56,7 @@ echo "
"; foreach($images as $i){ echo $i->name; - if($i->name == "TinyCore"){ + if($i->name == "Test"){ $id_image = $i->id; } echo "
"; @@ -54,6 +65,9 @@ echo "
"; // Détails Image -$details = $image->image_details($id_image); +//$details = $image->image_details($id_image); + +//$image->delete_image($id_image); + ?> \ No newline at end of file