Modification of options for create_image
This commit is contained in:
parent
6e7c71db77
commit
8ad2a0aacd
2 changed files with 42 additions and 15 deletions
|
@ -1,7 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
ini_set('display_errors', 1);
|
ini_set('display_errors', 1);
|
||||||
date_default_timezone_set("Europe/Paris");
|
date_default_timezone_set("Europe/Paris");
|
||||||
//require '../vendor/autoload.php';
|
|
||||||
|
|
||||||
class Image {
|
class Image {
|
||||||
|
|
||||||
|
@ -30,17 +29,40 @@ class Image {
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
public function create_image(array $opt){
|
public function create_image(array $opt){
|
||||||
// VOIR COMMENT RENDRE LES CHAMPS OPTIONNELS (SAUF NAME)
|
// VOIR SI MAUVAIS TYPE
|
||||||
$image = $this->oidentity->createImage([
|
$options = Array();
|
||||||
'name' => $opt['name'],
|
if(array_key_exists('name', $opt)){ // string, rendre le nom obligatoire
|
||||||
//'tags' => $opt['tag'], // A VOIR COMMENT CA MARCHE
|
$options['name'] = $opt['name'];
|
||||||
'containerFormat' => $opt['containerFormat'],
|
}
|
||||||
'diskFormat' => $opt['diskFormat'],
|
if(array_key_exists('id', $opt)){ // UUID : nnnnnnnn-nnnn-nnnn-nnnn-nnnnnnnnnnnn
|
||||||
'visibility' => $opt['visibility'],
|
$options['id'] = $opt['id'];
|
||||||
'minDisk' => $opt['minDisk'],
|
}
|
||||||
'protected' => $opt['protected'],
|
if(array_key_exists('visibility', $opt)){ // public, private
|
||||||
'minRam' => $opt['minRam'],
|
$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;
|
return $image;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,9 +38,9 @@ $image = new Image($openstack, $optImage);
|
||||||
|
|
||||||
$opt = Array();
|
$opt = Array();
|
||||||
$opt['name'] = "Test";
|
$opt['name'] = "Test";
|
||||||
//$opt['tags'] = 'test';
|
$opt['tags'] = ['test', 'openstack'];
|
||||||
$opt['containerFormat'] = 'ami';
|
//$opt['containerFormat'] = 'ami';
|
||||||
$opt['diskFormat'] = 'iso';
|
//$opt['diskFormat'] = 'iso';
|
||||||
$opt['visibility'] = 'public';
|
$opt['visibility'] = 'public';
|
||||||
$opt['minDisk'] = 1;
|
$opt['minDisk'] = 1;
|
||||||
$opt['protected'] = false;
|
$opt['protected'] = false;
|
||||||
|
@ -58,12 +58,17 @@ foreach($images as $i){
|
||||||
echo $i->name;
|
echo $i->name;
|
||||||
if($i->name == "Test"){
|
if($i->name == "Test"){
|
||||||
$id_image = $i->id;
|
$id_image = $i->id;
|
||||||
|
$list = $i->tags;
|
||||||
echo $i->status;
|
echo $i->status;
|
||||||
}
|
}
|
||||||
echo "</br>";
|
echo "</br>";
|
||||||
}
|
}
|
||||||
echo "</br>";
|
echo "</br>";
|
||||||
|
|
||||||
|
foreach ($list as $l) {
|
||||||
|
echo $l;
|
||||||
|
echo "</br>";
|
||||||
|
}
|
||||||
|
|
||||||
// Détails Image
|
// Détails Image
|
||||||
//$details = $image->image_details($id_image);
|
//$details = $image->image_details($id_image);
|
||||||
|
|
Loading…
Add table
Reference in a new issue