Add update_image and download_image

This commit is contained in:
yogg@epsina.com 2016-01-31 18:28:09 +01:00
parent 0db8d0ebbe
commit 6e7c71db77
2 changed files with 35 additions and 10 deletions

View file

@ -67,18 +67,24 @@ class Image {
return $image;
}
/**
* Details about an image
*
* @param string $id
* id of the image
*
* @param array $opt
* options for the image creation
**/
public function update_image($id, array $opt){
$service = $this->oidentity;
//OPTIONS A VOIR
$image = $service->getImage($id);
$image->update([
'minDisk' => 1,
'minRam' => 1,
'name' => $opt[name],
'protected' => false,
'visibility' => $opt[visibility],
'minDisk' => $opt['minDisk'],
'minRam' => $opt['minRam'],
'name' => $opt['name'],
'protected' => $opt['protected'],
'visibility' => $opt['visibility'],
]);
return $image;
@ -135,11 +141,17 @@ class Image {
$image->uploadData($stream);
}
// RETOUR A VOIR
public function download_image($id){
/**
* Download an image
*
* @param string $id
* identifier of the image
*/
public function download_image($id){
$service = $this->oidentity;
$image = $service->getImage($id);
$stream = $image->downloadData();
return $stream;
}
}
?>

View file

@ -76,4 +76,17 @@ echo "</br>";
//$file_name = "/home/yogg/Downloads/TinyCore-6.4.1.iso";
//$image->upload_image($id_image, $file_name);
//$image->download_image($id_image);
/*
$opt_update = Array();
$opt_update['name'] = "TestUpdate";
$opt_update['visibility'] = 'public';
$opt_update['minDisk'] = 1;
$opt_update['protected'] = false;
$opt_update['minRam'] = 15;
$update = $image->update_image($id_image, $opt_update);
echo $update->name;
*/
?>