Modifications qui seront validées :
modifié : server/core/Image.php
This commit is contained in:
parent
ba8bbc77fb
commit
721620a549
1 changed files with 96 additions and 1 deletions
|
@ -1 +1,96 @@
|
|||
|
||||
<?php
|
||||
ini_set('display_errors', 1);
|
||||
date_default_timezone_set("Europe/Paris");
|
||||
require '../vendor/autoload.php';
|
||||
|
||||
$options = Array();
|
||||
$options["user"] = Array("name"=>"admin", "password"=>"ae5or6cn", "domain"=>["id"=>"Default"]);
|
||||
$options["scope"] = Array("project"=>Array("name"=>"admin", "domain"=>["id"=>"Default"]));
|
||||
$options["authUrl"] = "http://148.60.11.31:5000/v3";
|
||||
|
||||
$openstack = OpenStack\OpenStack($options);
|
||||
|
||||
|
||||
public function create_image(array $opt){
|
||||
$service = $openstack->imagesV2();
|
||||
|
||||
// OPTIONS A VOIR
|
||||
$image = $service->createImage([
|
||||
'name' => $opt[name],
|
||||
'tags' => ['{tag1}', '{tag2}'], // A VOIR
|
||||
'containerFormat' => $opt[containerFormat],
|
||||
'diskFormat' => $opt[diskFormat],
|
||||
'visibility' => $opt[visibility],
|
||||
'minDisk' => 10,
|
||||
'protected' => true,
|
||||
'minRam' => 10,
|
||||
]);
|
||||
|
||||
return $image;
|
||||
}
|
||||
|
||||
public function list_image(){
|
||||
$images = $openstack->imagesV2()->listImages();
|
||||
return $images;
|
||||
}
|
||||
|
||||
|
||||
public function image_details($id){
|
||||
$service = $openstack->imagesV2();
|
||||
$image = $service->getImage($id);
|
||||
return $image;
|
||||
}
|
||||
|
||||
|
||||
public function update_image($id, array $opt){
|
||||
$service = $openstack->imagesV2();
|
||||
|
||||
//OPTIONS A VOIR
|
||||
$image = $service->getImage($id);
|
||||
$image->update([
|
||||
'minDisk' => 1,
|
||||
'minRam' => 1,
|
||||
'name' => $opt[name],
|
||||
'protected' => false,
|
||||
'visibility' => $opt[visibility],
|
||||
]);
|
||||
|
||||
return $image;
|
||||
}
|
||||
|
||||
// RETOUR A VOIR
|
||||
public function delete_image($name){
|
||||
$openstack->imagesV2()->getImage($name)->delete();
|
||||
}
|
||||
|
||||
// RETOUR A VOIR
|
||||
public function reactivate_image($id){
|
||||
$service = $openstack->imagesV2();
|
||||
$image = $service->getImage($id);
|
||||
$image->reactivate();
|
||||
}
|
||||
|
||||
// RETOUR A VOIR
|
||||
public function desactivate_function($id){
|
||||
$service = $openstack->imagesV2();
|
||||
$image = $service->getImage($id);
|
||||
$image->deactivate();
|
||||
}
|
||||
|
||||
// RETOUR A VOIR
|
||||
public function upload_image($id, $file_name){
|
||||
$service = $openstack->imagesV2();
|
||||
$image = $service->getImage($id);
|
||||
$stream = \GuzzleHttp\Psr7\stream_for(fopen($file_name, 'r')); // A VOIR
|
||||
$image->uploadData($stream);
|
||||
}
|
||||
|
||||
// RETOUR A VOIR
|
||||
public function download_image($id){
|
||||
$service = $openstack->imagesV2();
|
||||
$image = $service->getImage($id);
|
||||
$stream = $image->downloadData();
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
|
Loading…
Add table
Reference in a new issue