summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorYoggzo <yogg@epsina.com>2016-02-02 11:15:51 +0100
committerYoggzo <yogg@epsina.com>2016-02-02 11:15:51 +0100
commitab6e45d5e152518fd07c7bbce6f5eb2f42b30e07 (patch)
tree7916319125395a5f41e54295080222cfceec8c42 /server
parente2dacb129e75111559a6f16252009b031c2baeb4 (diff)
Modifications of create_image and update_image
Diffstat (limited to 'server')
-rw-r--r--server/core/Image.php33
-rw-r--r--server/test.php10
2 files changed, 25 insertions, 18 deletions
diff --git a/server/core/Image.php b/server/core/Image.php
index cfd190d..d345034 100644
--- a/server/core/Image.php
+++ b/server/core/Image.php
@@ -31,34 +31,34 @@ class Image {
public function create_image(array $opt){
// VOIR SI MAUVAIS TYPE
$options = Array();
- if(array_key_exists('name', $opt)){ // string, rendre le nom obligatoire
+ if(isset($opt['name'])){ // string, rendre le nom obligatoire
$options['name'] = $opt['name'];
}
- if(array_key_exists('id', $opt)){ // UUID : nnnnnnnn-nnnn-nnnn-nnnn-nnnnnnnnnnnn
+ if(isset($opt['id'])){ // UUID : nnnnnnnn-nnnn-nnnn-nnnn-nnnnnnnnnnnn
$options['id'] = $opt['id'];
}
- if(array_key_exists('visibility', $opt)){ // public, private
+ if(isset($opt['visibility'])){ // public, private
$options['visibility'] = $opt['visibility'];
}
- if(array_key_exists('tags', $opt)){ // list
+ if(isset($opt['tags'])){ // list
$options['tags'] = $opt['tags'];
}
- if(array_key_exists('containerFormat', $opt)){ // string : ami, ari, aki, bare, ovf, ova, docker
+ if(isset($opt['containerFormat'])){ // 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
+ if(isset($opt['diskFormat'])){ // string : ami, ari, aki, vhd, vmdk, raw, qcow2, vdi, iso
$options['diskFormat'] = $opt['diskFormat'];
}
- if(array_key_exists('minDisk', $opt)){ //int
+ if(isset($opt['minDisk'])){ //int
$options['minDisk'] = $opt['minDisk'];
}
- if(array_key_exists('minRam', $opt)){ // int
+ if(isset($opt['minRam'])){ // int
$options['minRam'] = $opt['minRam'];
}
- if(array_key_exists('protected', $opt)){ // boolean
+ if(isset($opt['protected'])){ // boolean
$options['protected'] = $opt['protected'];
}
- if(array_key_exists('properties', $opt)){ // type dict ?
+ if(isset($opt['properties'])){ // type dict ?
$options['properties'] = $opt['properties'];
}
@@ -104,21 +104,24 @@ class Image {
$options = Array();
// Voir vérification des types
- if(array_key_exists('name', $opt)){ //string
+ if(isset($opt['name'])){ //string
$options['name'] = $opt['name'];
}
- if(array_key_exists('minDisk', $opt)){ //int
+ if(isset($opt['minDisk'])){ //int
$options['minDisk'] = $opt['minDisk'];
}
- if(array_key_exists('minRam', $opt)){ // int
+ if(isset($opt['minRam'])){ // int
$options['minRam'] = $opt['minRam'];
}
- if(array_key_exists('protected', $opt)){ // boolean
+ if(isset($opt['protected'])){ // boolean
$options['protected'] = $opt['protected'];
}
- if(array_key_exists('visibility', $opt)){ // public, private
+ if(isset($opt['visibility'])){ // public, private
$options['visibility'] = $opt['visibility'];
}
+ if(isset($opt['tags'])){ // list
+ $options['tags'] = $opt['tags'];
+ }
$image->update($options);
return $image;
diff --git a/server/test.php b/server/test.php
index d7ee6f6..196be0d 100644
--- a/server/test.php
+++ b/server/test.php
@@ -65,9 +65,11 @@ foreach($images as $i){
}
echo "</br>";
-foreach ($list as $l) {
- echo $l;
- echo "</br>";
+if(isset($list)){
+ foreach ($list as $l) {
+ echo $l;
+ echo "</br>";
+ }
}
// Détails Image
@@ -86,8 +88,10 @@ foreach ($list as $l) {
/*
$opt_update = Array();
$opt_update['name'] = "Test";
+$opt_update['tags'] = null;
$update = $image->update_image($id_image, $opt_update);
echo $update->name;
*/
+
?> \ No newline at end of file