Modifications of create_image and update_image

This commit is contained in:
Yoggzo 2016-02-02 11:15:51 +01:00
parent e2dacb129e
commit ab6e45d5e1
2 changed files with 25 additions and 18 deletions

View file

@ -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;

View file

@ -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;
*/
?>