Add activate_image, desactivate_image, uplaod_image
This commit is contained in:
parent
10a6cd146d
commit
0db8d0ebbe
2 changed files with 43 additions and 14 deletions
|
@ -8,27 +8,27 @@ class Image {
|
||||||
protected $oidentity;
|
protected $oidentity;
|
||||||
//protected $plugins;
|
//protected $plugins;
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param $openstack
|
* @param $openstack
|
||||||
*
|
*
|
||||||
* @param $options
|
* @param $options
|
||||||
*
|
*
|
||||||
*/
|
**/
|
||||||
public function __construct($ostack, $options){ //, $apiP
|
public function __construct($ostack, $options){ //, $apiP
|
||||||
$this->oidentity = $ostack->imagesV2($options);
|
$this->oidentity = $ostack->imagesV2($options);
|
||||||
//$this->plugins = $apiP;
|
//$this->plugins = $apiP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Details about an image
|
* Details about an image
|
||||||
*
|
*
|
||||||
* @param array $opt
|
* @param array $opt
|
||||||
* options for the image creation
|
* options for the image creation
|
||||||
*
|
*
|
||||||
*/
|
**/
|
||||||
public function create_image(array $opt){
|
public function create_image(array $opt){
|
||||||
// VOIR COMMENT RENDRE LES CHAMPS OPTIONNELS (SAUF NAME)
|
// VOIR COMMENT RENDRE LES CHAMPS OPTIONNELS (SAUF NAME)
|
||||||
$image = $this->oidentity->createImage([
|
$image = $this->oidentity->createImage([
|
||||||
|
@ -54,13 +54,13 @@ class Image {
|
||||||
return $images;
|
return $images;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Details about an image
|
* Details about an image
|
||||||
*
|
*
|
||||||
* @param string $id
|
* @param string $id
|
||||||
* identifier of the image
|
* identifier of the image
|
||||||
*
|
*
|
||||||
*/
|
**/
|
||||||
public function image_details($id){
|
public function image_details($id){
|
||||||
$service = $this->oidentity;
|
$service = $this->oidentity;
|
||||||
$image = $service->getImage($id);
|
$image = $service->getImage($id);
|
||||||
|
@ -84,27 +84,50 @@ class Image {
|
||||||
return $image;
|
return $image;
|
||||||
}
|
}
|
||||||
|
|
||||||
// RETOUR A VOIR
|
/**
|
||||||
public function delete_image($name){
|
* Delete an image
|
||||||
|
*
|
||||||
|
* @param string $id
|
||||||
|
* identifier of the image
|
||||||
|
**/
|
||||||
|
public function delete_image($id){
|
||||||
$service = $this->oidentity;
|
$service = $this->oidentity;
|
||||||
$service->getImage($name)->delete();
|
$service->getImage($id)->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
// RETOUR A VOIR
|
/**
|
||||||
|
* Resactive an image
|
||||||
|
*
|
||||||
|
* @param string $id
|
||||||
|
* identifier of the image
|
||||||
|
**/
|
||||||
public function reactivate_image($id){
|
public function reactivate_image($id){
|
||||||
$service = $this->oidentity;
|
$service = $this->oidentity;
|
||||||
$image = $service->getImage($id);
|
$image = $service->getImage($id);
|
||||||
$image->reactivate();
|
$image->reactivate();
|
||||||
}
|
}
|
||||||
|
|
||||||
// RETOUR A VOIR
|
/**
|
||||||
public function desactivate_function($id){
|
* Desactive an image
|
||||||
|
*
|
||||||
|
* @param string $id
|
||||||
|
* identifier of the image
|
||||||
|
**/
|
||||||
|
public function desactivate_image($id){
|
||||||
$service = $this->oidentity;
|
$service = $this->oidentity;
|
||||||
$image = $service->getImage($id);
|
$image = $service->getImage($id);
|
||||||
$image->deactivate();
|
$image->deactivate();
|
||||||
}
|
}
|
||||||
|
|
||||||
// RETOUR A VOIR
|
/**
|
||||||
|
* Upload an image
|
||||||
|
*
|
||||||
|
* @param string $id
|
||||||
|
* identifier of the image
|
||||||
|
*
|
||||||
|
* @param string $file_name
|
||||||
|
* path of the image
|
||||||
|
**/
|
||||||
public function upload_image($id, $file_name){
|
public function upload_image($id, $file_name){
|
||||||
$service = $this->oidentity;
|
$service = $this->oidentity;
|
||||||
$image = $service->getImage($id);
|
$image = $service->getImage($id);
|
||||||
|
|
|
@ -43,7 +43,7 @@ $opt['containerFormat'] = 'ami';
|
||||||
$opt['diskFormat'] = 'iso';
|
$opt['diskFormat'] = 'iso';
|
||||||
$opt['visibility'] = 'public';
|
$opt['visibility'] = 'public';
|
||||||
$opt['minDisk'] = 1;
|
$opt['minDisk'] = 1;
|
||||||
$opt['protected'] = true;
|
$opt['protected'] = false;
|
||||||
$opt['minRam'] = 10;
|
$opt['minRam'] = 10;
|
||||||
|
|
||||||
//$new_image = $image->create_image($opt);
|
//$new_image = $image->create_image($opt);
|
||||||
|
@ -58,6 +58,7 @@ 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;
|
||||||
|
echo $i->status;
|
||||||
}
|
}
|
||||||
echo "</br>";
|
echo "</br>";
|
||||||
}
|
}
|
||||||
|
@ -69,5 +70,10 @@ echo "</br>";
|
||||||
|
|
||||||
//$image->delete_image($id_image);
|
//$image->delete_image($id_image);
|
||||||
|
|
||||||
|
//$image->desactivate_image($id_image);
|
||||||
|
//$image->reactivate_image($id_image);
|
||||||
|
|
||||||
|
//$file_name = "/home/yogg/Downloads/TinyCore-6.4.1.iso";
|
||||||
|
//$image->upload_image($id_image, $file_name);
|
||||||
|
|
||||||
?>
|
?>
|
Loading…
Add table
Reference in a new issue