summaryrefslogtreecommitdiff
path: root/server/core
diff options
context:
space:
mode:
Diffstat (limited to 'server/core')
-rw-r--r--server/core/Image.php46
1 files changed, 34 insertions, 12 deletions
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 @@
<?php
ini_set('display_errors', 1);
date_default_timezone_set("Europe/Paris");
-//require '../vendor/autoload.php';
class Image {
@@ -30,17 +29,40 @@ class Image {
*
**/
public function create_image(array $opt){
- // VOIR COMMENT RENDRE LES CHAMPS OPTIONNELS (SAUF NAME)
- $image = $this->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;
}