From c31c3bb28155c401d295a4bea6c43b72bbe30206 Mon Sep 17 00:00:00 2001 From: Yoggzo Date: Thu, 11 Feb 2016 17:01:37 +0100 Subject: move image tests file --- server/Test/imageTests.php | 97 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 server/Test/imageTests.php (limited to 'server/Test') diff --git a/server/Test/imageTests.php b/server/Test/imageTests.php new file mode 100644 index 0000000..f0e68c4 --- /dev/null +++ b/server/Test/imageTests.php @@ -0,0 +1,97 @@ +"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 = new OpenStack\OpenStack($options); + +//$identity = $openstack->identityV3(); +//var_dump($identity); +// 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', + 'password' => 'ae5or6cn', + 'domain' => [ + 'id' => 'Default' + ] + ] + ]); + */ +//$compute = $openstack->computeV2(["region" => "RegionOne"]); +//$image= $openstack->imagesV2(["region" => "RegionOne"]); +//var_dump($compute->client); +//$servers = $compute->listServers(true); + +// 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 "
"; + +foreach($images as $i){ + echo $i->name; + if($i->name == "Test"){ + $id_image = $i->id; + $list = $i->tags; + echo $i->status; + } + echo "
"; +} +echo "
"; + +if(isset($list)){ + foreach ($list as $l) { + echo $l; + echo "
"; + } +} + +// 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 -- cgit v1.2.3 From 6db5da757b5c9947106ab483e9894083a9d98e45 Mon Sep 17 00:00:00 2001 From: Yoggzo Date: Thu, 11 Feb 2016 20:06:50 +0100 Subject: test foireux --- server/Test/imageTests.php | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'server/Test') diff --git a/server/Test/imageTests.php b/server/Test/imageTests.php index f0e68c4..c3089e3 100644 --- a/server/Test/imageTests.php +++ b/server/Test/imageTests.php @@ -1,9 +1,8 @@ "admin", "password"=>"ae5or6cn", "domain"=>["id"=>"Default"]); $options["scope"] = Array("project"=>Array("name"=>"admin", "domain"=>["id"=>"Default"])); @@ -30,11 +29,8 @@ $openstack = new OpenStack\OpenStack($options); //$image= $openstack->imagesV2(["region" => "RegionOne"]); //var_dump($compute->client); //$servers = $compute->listServers(true); +echo 'toto'; -// Initialisation Image() -$optImage = Array(); -$optImage["region"] = "RegionOne"; -$image = new Image($openstack, $optImage); $opt = Array(); $opt['name'] = "Test"; @@ -48,8 +44,9 @@ $opt['minRam'] = 10; //$new_image = $image->create_image($opt); + //Liste des images -$images = $image->list_images(); +$images = $imageObject->list_images(); echo "Images présentes :"; echo "
"; -- cgit v1.2.3 From d81a376894b526b5769a553d07487b0b46fecaa2 Mon Sep 17 00:00:00 2001 From: Yoggzo Date: Thu, 11 Feb 2016 20:38:15 +0100 Subject: bugs --- server/Test/genTokenOptionsTest.php | 6 ++-- server/Test/imageTests.php | 5 ++-- server/core/App.php | 4 +-- server/core/Image.php | 55 ++++++++++++++++++++++++++++--------- 4 files changed, 50 insertions(+), 20 deletions(-) (limited to 'server/Test') diff --git a/server/Test/genTokenOptionsTest.php b/server/Test/genTokenOptionsTest.php index 54c22d2..d1571f0 100755 --- a/server/Test/genTokenOptionsTest.php +++ b/server/Test/genTokenOptionsTest.php @@ -1,8 +1,8 @@ listServers(true); echo 'toto'; +$image = new Image($App); $opt = Array(); $opt['name'] = "Test"; @@ -46,7 +47,7 @@ $opt['minRam'] = 10; //Liste des images -$images = $imageObject->list_images(); +$images = $image->list_images(); echo "Images présentes :"; echo "
"; diff --git a/server/core/App.php b/server/core/App.php index dafdaad..09da394 100755 --- a/server/core/App.php +++ b/server/core/App.php @@ -1,6 +1,6 @@ oidentity = $ostack->imagesV2($options); - //$this->plugins = $apiP; + * @throws [Type] [] + * + * @return Image + */ + public function __construct($app){ + $this->app = $app; + $this->libClass = $app->getLibClass("Image"); } + + /** * Details about an image * -- cgit v1.2.3 From ad33435ce05302c76618fa77282811ade5a53119 Mon Sep 17 00:00:00 2001 From: EoleDev Date: Fri, 12 Feb 2016 11:57:18 +0100 Subject: Links Correction --- server/Test/genTokenOptionsTest.php | 6 +++--- server/core/App.php | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'server/Test') diff --git a/server/Test/genTokenOptionsTest.php b/server/Test/genTokenOptionsTest.php index d1571f0..f7d0ee4 100755 --- a/server/Test/genTokenOptionsTest.php +++ b/server/Test/genTokenOptionsTest.php @@ -1,8 +1,8 @@ Date: Fri, 12 Feb 2016 12:11:11 +0100 Subject: Add Init and AppClass to do tests, Error Correction in App.php --- server/Test/AppTestClass.php | 73 ++++++++++++++++++++++++++++++++++++++++++++ server/Test/InitTest.php | 28 +++++++++++++++++ server/core/App.php | 10 +++--- 3 files changed, 106 insertions(+), 5 deletions(-) create mode 100755 server/Test/AppTestClass.php create mode 100755 server/Test/InitTest.php (limited to 'server/Test') diff --git a/server/Test/AppTestClass.php b/server/Test/AppTestClass.php new file mode 100755 index 0000000..311b9bf --- /dev/null +++ b/server/Test/AppTestClass.php @@ -0,0 +1,73 @@ +tokenPost = NULL; + $this->tokenClass = new genTokenOptions($args); + $this->openstack = new OpenStack\OpenStack([]); + $this->pluginsApi = plugin_api::getInstance(); + $this->output = array(); + + } + + public function setToken($token){ + + $this->tokenPost = $token; + $this->tokenClass->loadBackup($his->tokenPost); + + } + + public function getLibClass($service){ + + switch($service){ + case "Identity": + if($this->tokenPost == NULL) $this->tokenClass->genIdentityToken(); + $opt = $this->tokenClass->getOptions($service); + return $this->openstack->identityV3($opt); + break; + case "Image": + if($this->tokenPost == NULL) $this->tokenClass->genImageToken(); + $opt = $this->tokenClass->getOptions($service); + return $this->openstack->imagesV2($opt); + break; + } + + } + + public function authenticate(){ + + try{ + $this->tokenClass->genIdentityToken(); + $this->tokenClass->genComputeToken(); + $this->tokenClass->genImageToken(); + $this->tokenClass->genNetworkToken(); + + $this->setOutput("token", $this->tokenClass->getBackup()); + }catch(Exception $e){ + echo $e; + exit(); + } + + } + + public function setOutput($key, $out){ + + $this->output[$key] = $out; + + } + + public function show(){ + echo json_encode($this->output); + } + +} \ No newline at end of file diff --git a/server/Test/InitTest.php b/server/Test/InitTest.php new file mode 100755 index 0000000..c1900a6 --- /dev/null +++ b/server/Test/InitTest.php @@ -0,0 +1,28 @@ + Array( + "name" => $user, + "password" => $password, + "domain" => Array( + "name" => "Default") + ), + "scope" => Array( + "project" => Array( + "name" => $project, + "domain" => Array( + "name" => "Default") + ) + ), + "authUrl" => $config["urlAuth"] + ); + + $App = new AppTest($Args); + +?> diff --git a/server/core/App.php b/server/core/App.php index dafdaad..bba99b4 100755 --- a/server/core/App.php +++ b/server/core/App.php @@ -31,14 +31,14 @@ class App{ switch($service){ case "Identity": - if($tokenPost == NULL) $tokenClass->genIdentityToken(); - $opt = $tokenClass->getOptions($service); + if($this->tokenPost == NULL) $this->tokenClass->genIdentityToken(); + $opt = $this->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); + if($this->tokenPost == NULL) $this->tokenClass->genImageToken(); + $opt = $this->tokenClass->getOptions($service); + return $this->openstack->imagesV2($opt); break; } -- cgit v1.2.3 From 06d229a37ecb64d1777de31d49251239a9d285d1 Mon Sep 17 00:00:00 2001 From: EoleDev Date: Fri, 12 Feb 2016 13:20:20 +0100 Subject: Import Correction --- server/Test/InitTest.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'server/Test') diff --git a/server/Test/InitTest.php b/server/Test/InitTest.php index c1900a6..ab90864 100755 --- a/server/Test/InitTest.php +++ b/server/Test/InitTest.php @@ -1,6 +1,8 @@