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
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -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 "</br>";
|
||||
}
|
||||
echo "</br>";
|
||||
|
||||
foreach ($list as $l) {
|
||||
echo $l;
|
||||
echo "</br>";
|
||||
}
|
||||
|
||||
// Détails Image
|
||||
//$details = $image->image_details($id_image);
|
||||
|
|
Loading…
Add table
Reference in a new issue