summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xserver/core/App.php5
-rwxr-xr-xserver/index.php7
-rw-r--r--server/test.php73
3 files changed, 79 insertions, 6 deletions
diff --git a/server/core/App.php b/server/core/App.php
index 45f6922..dafdaad 100755
--- a/server/core/App.php
+++ b/server/core/App.php
@@ -35,6 +35,11 @@ class App{
$opt = $tokenClass->getOptions($service);
return $this->openstack->identityV3($opt);
break;
+ case "Image":
+ if($tokenPost == NULL) $tokenClass->genImageToken();
+ $opt = $tokenClass->getOptions($service);
+ return $this->$openstack->imagesV2($opt);
+ break;
}
}
diff --git a/server/index.php b/server/index.php
index 41f77b8..166e82e 100755
--- a/server/index.php
+++ b/server/index.php
@@ -27,5 +27,12 @@
$identityObject->action($action);
$App->show();
break;
+
+ case "image":
+ include_once("core/Image.php");
+ $imageObject = new image($App);
+ $imageObject->action($action);
+ $App->show();
+ break;
}
diff --git a/server/test.php b/server/test.php
index 16555e4..f0e68c4 100644
--- a/server/test.php
+++ b/server/test.php
@@ -2,6 +2,7 @@
ini_set('display_errors', 1);
date_default_timezone_set("Europe/Paris");
require 'vendor/autoload.php';
+include("core/Image.php");
$options = Array();
$options["user"] = Array("name"=>"admin", "password"=>"ae5or6cn", "domain"=>["id"=>"Default"]);
@@ -15,7 +16,6 @@ $openstack = new OpenStack\OpenStack($options);
// Since usernames will not be unique across an entire OpenStack installation,
// when authenticating with them you must also provide your domain ID. You do
// not have to do this if you authenticate with a user ID.
-
/*$token = $identity->generateToken([
'user' => [
'name' => 'admin',
@@ -26,11 +26,72 @@ $openstack = new OpenStack\OpenStack($options);
]
]);
*/
-$compute = $openstack->computeV2(["region" => "RegionOne"]);
+//$compute = $openstack->computeV2(["region" => "RegionOne"]);
+//$image= $openstack->imagesV2(["region" => "RegionOne"]);
//var_dump($compute->client);
//$servers = $compute->listServers(true);
-//foreach($servers as $server){
-// echo $server->id." !!! ";
-// echo $server->name." !!! ";
-//}
+// Initialisation Image()
+$optImage = Array();
+$optImage["region"] = "RegionOne";
+$image = new Image($openstack, $optImage);
+
+$opt = Array();
+$opt['name'] = "Test";
+$opt['tags'] = ['test', 'openstack'];
+//$opt['containerFormat'] = 'ami';
+//$opt['diskFormat'] = 'iso';
+$opt['visibility'] = 'public';
+$opt['minDisk'] = 1;
+$opt['protected'] = false;
+$opt['minRam'] = 10;
+
+//$new_image = $image->create_image($opt);
+
+//Liste des images
+$images = $image->list_images();
+
+echo "Images présentes :";
+echo "</br>";
+
+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>";
+
+if(isset($list)){
+ foreach ($list as $l) {
+ echo $l;
+ echo "</br>";
+ }
+}
+
+// Détails Image
+//$details = $image->image_details($id_image);
+
+//$image->delete_image('123456');
+
+//$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);
+
+//$image->download_image($id_image);
+
+/*
+$opt_update = Array();
+$opt_update['name'] = "Test";
+$opt_update['tags'] = null;
+
+$update = $image->update_image($id_image, $opt_update);
+echo $update->name;
+*/
+
+?> \ No newline at end of file