diff --git a/server/core/Image.php b/server/core/Image.php index a986a40..37efa9d 100644 --- a/server/core/Image.php +++ b/server/core/Image.php @@ -1,7 +1,6 @@ oidentity->createImage([ - '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'], - ]); + // VOIR SI MAUVAIS TYPE + $options = Array(); + if(array_key_exists('name', $opt)){ // string, rendre le nom obligatoire + $options['name'] = $opt['name']; + } + if(array_key_exists('id', $opt)){ // UUID : nnnnnnnn-nnnn-nnnn-nnnn-nnnnnnnnnnnn + $options['id'] = $opt['id']; + } + if(array_key_exists('visibility', $opt)){ // public, private + $options['visibility'] = $opt['visibility']; + } + if(array_key_exists('tags', $opt)){ // list + $options['tags'] = $opt['tags']; + } + if(array_key_exists('containerFormat', $opt)){ // string : ami, ari, aki, bare, ovf, ova, docker + $options['containerFormat'] = $opt['containerFormat']; + } + if(array_key_exists('diskFormat', $opt)){ // string : ami, ari, aki, vhd, vmdk, raw, qcow2, vdi, iso + $options['diskFormat'] = $opt['diskFormat']; + } + if(array_key_exists('minDisk', $opt)){ //int + $options['minDisk'] = $opt['minDisk']; + } + if(array_key_exists('minRam', $opt)){ // int + $options['minRam'] = $opt['minRam']; + } + if(array_key_exists('protected', $opt)){ // boolean + $options['protected'] = $opt['protected']; + } + if(array_key_exists('properties', $opt)){ // type dict ? + $options['properties'] = $opt['properties']; + } + + $image = $this->oidentity->createImage($options); return $image; } diff --git a/server/test.php b/server/test.php index 71039e8..47d780b 100644 --- a/server/test.php +++ b/server/test.php @@ -38,9 +38,9 @@ $image = new Image($openstack, $optImage); $opt = Array(); $opt['name'] = "Test"; -//$opt['tags'] = 'test'; -$opt['containerFormat'] = 'ami'; -$opt['diskFormat'] = 'iso'; +$opt['tags'] = ['test', 'openstack']; +//$opt['containerFormat'] = 'ami'; +//$opt['diskFormat'] = 'iso'; $opt['visibility'] = 'public'; $opt['minDisk'] = 1; $opt['protected'] = false; @@ -58,12 +58,17 @@ foreach($images as $i){ echo $i->name; if($i->name == "Test"){ $id_image = $i->id; + $list = $i->tags; echo $i->status; } echo "
"; } echo "
"; +foreach ($list as $l) { + echo $l; + echo "
"; +} // Détails Image //$details = $image->image_details($id_image);