From 721620a549f38ca13f82351ae12d777f929b7372 Mon Sep 17 00:00:00 2001 From: "yogg@epsina.com" Date: Wed, 27 Jan 2016 19:19:42 +0100 Subject: Modifications qui seront validées : modifié : server/core/Image.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/core/Image.php | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 96 insertions(+), 1 deletion(-) (limited to 'server') diff --git a/server/core/Image.php b/server/core/Image.php index 8d1c8b6..984f03a 100644 --- a/server/core/Image.php +++ b/server/core/Image.php @@ -1 +1,96 @@ - +"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(); +} + + +?> -- cgit v1.2.3 From 83fd3eb19dc9943d3ad53154f330ed4782ccff81 Mon Sep 17 00:00:00 2001 From: "yogg@epsina.com" Date: Sun, 31 Jan 2016 10:56:52 +0100 Subject: Modifications qui seront validées : modifié : server/core/Image.php modifié : server/test.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/core/Image.php | 194 +++++++++++++++++++++++++++----------------------- server/test.php | 21 ++++-- 2 files changed, 119 insertions(+), 96 deletions(-) (limited to 'server') diff --git a/server/core/Image.php b/server/core/Image.php index 984f03a..242bb5f 100644 --- a/server/core/Image.php +++ b/server/core/Image.php @@ -1,96 +1,108 @@ "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; +//require '../vendor/autoload.php'; + +class Image { + + protected $oidentity; + //protected $plugins; + + /* + * Constructor + * + * @param $openstack + * + * @param $options + * + */ + public function __construct($ostack, $options){ //, $apiP + $this->oidentity = $ostack->imagesV2($options); + //$this->plugins = $apiP; + } + + 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; + } + + /* + * List images + */ + public function list_images(){ + $images = $this->oidentity->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(); + } } - -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(); -} - - ?> diff --git a/server/test.php b/server/test.php index 16555e4..4e6743f 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"]); @@ -26,11 +27,21 @@ $openstack = new OpenStack\OpenStack($options); ] ]); */ -$compute = $openstack->computeV2(["region" => "RegionOne"]); +//$compute = $openstack->computeV2(["region" => "RegionOne"]); + +//$image= $openstack->imagesV2(["region" => "RegionOne"]); +$optImage = Array(); +$optImage["region"] = "RegionOne"; +$image = new Image($openstack, $optImage); + + +$images = $image->list_images(); + //var_dump($compute->client); //$servers = $compute->listServers(true); -//foreach($servers as $server){ -// echo $server->id." !!! "; -// echo $server->name." !!! "; -//} +foreach($images as $i){ + //echo $server->id." !!! "; + echo $i->name; + echo "
"; +} -- cgit v1.2.3 From 325362a386687dd77c6c42dc5ab266d646bd9842 Mon Sep 17 00:00:00 2001 From: "yogg@epsina.com" Date: Sun, 31 Jan 2016 11:36:58 +0100 Subject: list_images and images_details --- server/core/Image.php | 30 ++++++++++++++++++------------ server/test.php | 22 +++++++++++++++++----- 2 files changed, 35 insertions(+), 17 deletions(-) (limited to 'server') diff --git a/server/core/Image.php b/server/core/Image.php index 242bb5f..498ebe8 100644 --- a/server/core/Image.php +++ b/server/core/Image.php @@ -22,10 +22,8 @@ class Image { } public function create_image(array $opt){ - $service = $openstack->imagesV2(); - // OPTIONS A VOIR - $image = $service->createImage([ + $image = $this->oidentity->createImage([ 'name' => $opt[name], 'tags' => ['{tag1}', '{tag2}'], // A VOIR 'containerFormat' => $opt[containerFormat], @@ -43,20 +41,27 @@ class Image { * List images */ public function list_images(){ - $images = $this->oidentity->listImages(); + $service = $this->oidentity; + $images = $service->listImages(); return $images; } - + /* + * Details about an image + * + * @param string $id + * identifier of the image + * + */ public function image_details($id){ - $service = $openstack->imagesV2(); + $service = $this->oidentity; $image = $service->getImage($id); return $image; } public function update_image($id, array $opt){ - $service = $openstack->imagesV2(); + $service = $this->oidentity; //OPTIONS A VOIR $image = $service->getImage($id); @@ -73,26 +78,27 @@ class Image { // RETOUR A VOIR public function delete_image($name){ - $openstack->imagesV2()->getImage($name)->delete(); + $service = $this->oidentity; + $service->getImage($name)->delete(); } // RETOUR A VOIR public function reactivate_image($id){ - $service = $openstack->imagesV2(); + $service = $this->oidentity; $image = $service->getImage($id); $image->reactivate(); } // RETOUR A VOIR public function desactivate_function($id){ - $service = $openstack->imagesV2(); + $service = $this->oidentity; $image = $service->getImage($id); $image->deactivate(); } // RETOUR A VOIR public function upload_image($id, $file_name){ - $service = $openstack->imagesV2(); + $service = $this->oidentity; $image = $service->getImage($id); $stream = \GuzzleHttp\Psr7\stream_for(fopen($file_name, 'r')); // A VOIR $image->uploadData($stream); @@ -100,7 +106,7 @@ class Image { // RETOUR A VOIR public function download_image($id){ - $service = $openstack->imagesV2(); + $service = $this->oidentity; $image = $service->getImage($id); $stream = $image->downloadData(); } diff --git a/server/test.php b/server/test.php index 4e6743f..6881923 100644 --- a/server/test.php +++ b/server/test.php @@ -16,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', @@ -28,20 +27,33 @@ $openstack = new OpenStack\OpenStack($options); ]); */ //$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); +//Liste des images $images = $image->list_images(); -//var_dump($compute->client); -//$servers = $compute->listServers(true); +echo "Images présentes :"; +echo "
"; foreach($images as $i){ - //echo $server->id." !!! "; echo $i->name; + if($i->name == "TinyCore"){ + $id_image = $i->id; + } echo "
"; } +echo "
"; + + +// Détails Image +$details = $image->image_details($id_image); + +?> \ No newline at end of file -- cgit v1.2.3 From 10a6cd146db2bc509059d07ff8b7887445524cab Mon Sep 17 00:00:00 2001 From: "yogg@epsina.com" Date: Sun, 31 Jan 2016 13:00:04 +0100 Subject: Add create_image and delete_image --- server/core/Image.php | 26 +++++++++++++++++--------- server/test.php | 18 ++++++++++++++++-- 2 files changed, 33 insertions(+), 11 deletions(-) (limited to 'server') diff --git a/server/core/Image.php b/server/core/Image.php index 498ebe8..bf67e75 100644 --- a/server/core/Image.php +++ b/server/core/Image.php @@ -21,17 +21,25 @@ class Image { //$this->plugins = $apiP; } + + /* + * Details about an image + * + * @param array $opt + * options for the image creation + * + */ public function create_image(array $opt){ - // OPTIONS A VOIR + // VOIR COMMENT RENDRE LES CHAMPS OPTIONNELS (SAUF NAME) $image = $this->oidentity->createImage([ - 'name' => $opt[name], - 'tags' => ['{tag1}', '{tag2}'], // A VOIR - 'containerFormat' => $opt[containerFormat], - 'diskFormat' => $opt[diskFormat], - 'visibility' => $opt[visibility], - 'minDisk' => 10, - 'protected' => true, - 'minRam' => 10, + 'name' => $opt['name'], + //'tags' => $opt['tag'], // A VOIR COMMENT CA MARCHE + 'containerFormat' => $opt['containerFormat'], + 'diskFormat' => $opt['diskFormat'], + 'visibility' => $opt['visibility'], + 'minDisk' => $opt['minDisk'], + 'protected' => $opt['protected'], + 'minRam' => $opt['minRam'], ]); return $image; diff --git a/server/test.php b/server/test.php index 6881923..ce262fa 100644 --- a/server/test.php +++ b/server/test.php @@ -36,6 +36,17 @@ $optImage = Array(); $optImage["region"] = "RegionOne"; $image = new Image($openstack, $optImage); +$opt = Array(); +$opt['name'] = "Test"; +//$opt['tags'] = 'test'; +$opt['containerFormat'] = 'ami'; +$opt['diskFormat'] = 'iso'; +$opt['visibility'] = 'public'; +$opt['minDisk'] = 1; +$opt['protected'] = true; +$opt['minRam'] = 10; + +//$new_image = $image->create_image($opt); //Liste des images $images = $image->list_images(); @@ -45,7 +56,7 @@ echo "
"; foreach($images as $i){ echo $i->name; - if($i->name == "TinyCore"){ + if($i->name == "Test"){ $id_image = $i->id; } echo "
"; @@ -54,6 +65,9 @@ echo "
"; // Détails Image -$details = $image->image_details($id_image); +//$details = $image->image_details($id_image); + +//$image->delete_image($id_image); + ?> \ No newline at end of file -- cgit v1.2.3 From 0db8d0ebbe36528346987cb21db67f31bfbe6017 Mon Sep 17 00:00:00 2001 From: "yogg@epsina.com" Date: Sun, 31 Jan 2016 17:47:06 +0100 Subject: Add activate_image, desactivate_image, uplaod_image --- server/core/Image.php | 49 ++++++++++++++++++++++++++++++++++++------------- server/test.php | 8 +++++++- 2 files changed, 43 insertions(+), 14 deletions(-) (limited to 'server') diff --git a/server/core/Image.php b/server/core/Image.php index bf67e75..c9d9845 100644 --- a/server/core/Image.php +++ b/server/core/Image.php @@ -8,27 +8,27 @@ class Image { protected $oidentity; //protected $plugins; - /* + /** * Constructor * * @param $openstack * * @param $options * - */ + **/ public function __construct($ostack, $options){ //, $apiP $this->oidentity = $ostack->imagesV2($options); //$this->plugins = $apiP; } - /* + /** * Details about an image * * @param array $opt * options for the image creation * - */ + **/ public function create_image(array $opt){ // VOIR COMMENT RENDRE LES CHAMPS OPTIONNELS (SAUF NAME) $image = $this->oidentity->createImage([ @@ -54,13 +54,13 @@ class Image { return $images; } - /* + /** * Details about an image * * @param string $id * identifier of the image * - */ + **/ public function image_details($id){ $service = $this->oidentity; $image = $service->getImage($id); @@ -84,27 +84,50 @@ class 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->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){ $service = $this->oidentity; $image = $service->getImage($id); $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; $image = $service->getImage($id); $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){ $service = $this->oidentity; $image = $service->getImage($id); diff --git a/server/test.php b/server/test.php index ce262fa..322dee4 100644 --- a/server/test.php +++ b/server/test.php @@ -43,7 +43,7 @@ $opt['containerFormat'] = 'ami'; $opt['diskFormat'] = 'iso'; $opt['visibility'] = 'public'; $opt['minDisk'] = 1; -$opt['protected'] = true; +$opt['protected'] = false; $opt['minRam'] = 10; //$new_image = $image->create_image($opt); @@ -58,6 +58,7 @@ foreach($images as $i){ echo $i->name; if($i->name == "Test"){ $id_image = $i->id; + echo $i->status; } echo "
"; } @@ -69,5 +70,10 @@ echo "
"; //$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); ?> \ No newline at end of file -- cgit v1.2.3 From 6e7c71db77fc68b7c3d1149b830a838b81cdb718 Mon Sep 17 00:00:00 2001 From: "yogg@epsina.com" Date: Sun, 31 Jan 2016 18:28:09 +0100 Subject: Add update_image and download_image --- server/core/Image.php | 32 ++++++++++++++++++++++---------- server/test.php | 13 +++++++++++++ 2 files changed, 35 insertions(+), 10 deletions(-) (limited to 'server') diff --git a/server/core/Image.php b/server/core/Image.php index c9d9845..a986a40 100644 --- a/server/core/Image.php +++ b/server/core/Image.php @@ -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; } } ?> diff --git a/server/test.php b/server/test.php index 322dee4..71039e8 100644 --- a/server/test.php +++ b/server/test.php @@ -76,4 +76,17 @@ echo "
"; //$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; +*/ ?> \ No newline at end of file -- cgit v1.2.3 From 8ad2a0aacd280ec29a6b53e7663b968068f89ab9 Mon Sep 17 00:00:00 2001 From: "yogg@epsina.com" Date: Sun, 31 Jan 2016 19:48:30 +0100 Subject: Modification of options for create_image --- server/core/Image.php | 46 ++++++++++++++++++++++++++++++++++------------ server/test.php | 11 ++++++++--- 2 files changed, 42 insertions(+), 15 deletions(-) (limited to 'server') diff --git a/server/core/Image.php b/server/core/Image.php index a986a40..37efa9d 100644 --- a/server/core/Image.php +++ b/server/core/Image.php @@ -1,7 +1,6 @@ oidentity->createImage([ - 'name' => $opt['name'], - //'tags' => $opt['tag'], // A VOIR COMMENT CA MARCHE - 'containerFormat' => $opt['containerFormat'], - 'diskFormat' => $opt['diskFormat'], - 'visibility' => $opt['visibility'], - 'minDisk' => $opt['minDisk'], - 'protected' => $opt['protected'], - 'minRam' => $opt['minRam'], - ]); + // VOIR SI MAUVAIS TYPE + $options = Array(); + if(array_key_exists('name', $opt)){ // string, rendre le nom obligatoire + $options['name'] = $opt['name']; + } + if(array_key_exists('id', $opt)){ // UUID : nnnnnnnn-nnnn-nnnn-nnnn-nnnnnnnnnnnn + $options['id'] = $opt['id']; + } + if(array_key_exists('visibility', $opt)){ // public, private + $options['visibility'] = $opt['visibility']; + } + if(array_key_exists('tags', $opt)){ // list + $options['tags'] = $opt['tags']; + } + if(array_key_exists('containerFormat', $opt)){ // string : ami, ari, aki, bare, ovf, ova, docker + $options['containerFormat'] = $opt['containerFormat']; + } + if(array_key_exists('diskFormat', $opt)){ // string : ami, ari, aki, vhd, vmdk, raw, qcow2, vdi, iso + $options['diskFormat'] = $opt['diskFormat']; + } + if(array_key_exists('minDisk', $opt)){ //int + $options['minDisk'] = $opt['minDisk']; + } + if(array_key_exists('minRam', $opt)){ // int + $options['minRam'] = $opt['minRam']; + } + if(array_key_exists('protected', $opt)){ // boolean + $options['protected'] = $opt['protected']; + } + if(array_key_exists('properties', $opt)){ // type dict ? + $options['properties'] = $opt['properties']; + } + + $image = $this->oidentity->createImage($options); return $image; } diff --git a/server/test.php b/server/test.php index 71039e8..47d780b 100644 --- a/server/test.php +++ b/server/test.php @@ -38,9 +38,9 @@ $image = new Image($openstack, $optImage); $opt = Array(); $opt['name'] = "Test"; -//$opt['tags'] = 'test'; -$opt['containerFormat'] = 'ami'; -$opt['diskFormat'] = 'iso'; +$opt['tags'] = ['test', 'openstack']; +//$opt['containerFormat'] = 'ami'; +//$opt['diskFormat'] = 'iso'; $opt['visibility'] = 'public'; $opt['minDisk'] = 1; $opt['protected'] = false; @@ -58,12 +58,17 @@ foreach($images as $i){ echo $i->name; if($i->name == "Test"){ $id_image = $i->id; + $list = $i->tags; echo $i->status; } echo "
"; } echo "
"; +foreach ($list as $l) { + echo $l; + echo "
"; +} // Détails Image //$details = $image->image_details($id_image); -- cgit v1.2.3 From e2dacb129e75111559a6f16252009b031c2baeb4 Mon Sep 17 00:00:00 2001 From: "yogg@epsina.com" Date: Sun, 31 Jan 2016 19:57:05 +0100 Subject: Modification of options for update_image --- server/core/Image.php | 26 +++++++++++++++++++------- server/test.php | 6 +----- 2 files changed, 20 insertions(+), 12 deletions(-) (limited to 'server') diff --git a/server/core/Image.php b/server/core/Image.php index 37efa9d..cfd190d 100644 --- a/server/core/Image.php +++ b/server/core/Image.php @@ -101,13 +101,25 @@ class Image { public function update_image($id, array $opt){ $service = $this->oidentity; $image = $service->getImage($id); - $image->update([ - 'minDisk' => $opt['minDisk'], - 'minRam' => $opt['minRam'], - 'name' => $opt['name'], - 'protected' => $opt['protected'], - 'visibility' => $opt['visibility'], - ]); + $options = Array(); + + // Voir vérification des types + if(array_key_exists('name', $opt)){ //string + $options['name'] = $opt['name']; + } + if(array_key_exists('minDisk', $opt)){ //int + $options['minDisk'] = $opt['minDisk']; + } + if(array_key_exists('minRam', $opt)){ // int + $options['minRam'] = $opt['minRam']; + } + if(array_key_exists('protected', $opt)){ // boolean + $options['protected'] = $opt['protected']; + } + if(array_key_exists('visibility', $opt)){ // public, private + $options['visibility'] = $opt['visibility']; + } + $image->update($options); return $image; } diff --git a/server/test.php b/server/test.php index 47d780b..d7ee6f6 100644 --- a/server/test.php +++ b/server/test.php @@ -85,11 +85,7 @@ foreach ($list as $l) { /* $opt_update = Array(); -$opt_update['name'] = "TestUpdate"; -$opt_update['visibility'] = 'public'; -$opt_update['minDisk'] = 1; -$opt_update['protected'] = false; -$opt_update['minRam'] = 15; +$opt_update['name'] = "Test"; $update = $image->update_image($id_image, $opt_update); echo $update->name; -- cgit v1.2.3 From ab6e45d5e152518fd07c7bbce6f5eb2f42b30e07 Mon Sep 17 00:00:00 2001 From: Yoggzo Date: Tue, 2 Feb 2016 11:15:51 +0100 Subject: Modifications of create_image and update_image --- server/core/Image.php | 33 ++++++++++++++++++--------------- server/test.php | 10 +++++++--- 2 files changed, 25 insertions(+), 18 deletions(-) (limited to 'server') diff --git a/server/core/Image.php b/server/core/Image.php index cfd190d..d345034 100644 --- a/server/core/Image.php +++ b/server/core/Image.php @@ -31,34 +31,34 @@ class Image { public function create_image(array $opt){ // VOIR SI MAUVAIS TYPE $options = Array(); - if(array_key_exists('name', $opt)){ // string, rendre le nom obligatoire + if(isset($opt['name'])){ // string, rendre le nom obligatoire $options['name'] = $opt['name']; } - if(array_key_exists('id', $opt)){ // UUID : nnnnnnnn-nnnn-nnnn-nnnn-nnnnnnnnnnnn + if(isset($opt['id'])){ // UUID : nnnnnnnn-nnnn-nnnn-nnnn-nnnnnnnnnnnn $options['id'] = $opt['id']; } - if(array_key_exists('visibility', $opt)){ // public, private + if(isset($opt['visibility'])){ // public, private $options['visibility'] = $opt['visibility']; } - if(array_key_exists('tags', $opt)){ // list + if(isset($opt['tags'])){ // list $options['tags'] = $opt['tags']; } - if(array_key_exists('containerFormat', $opt)){ // string : ami, ari, aki, bare, ovf, ova, docker + if(isset($opt['containerFormat'])){ // string : ami, ari, aki, bare, ovf, ova, docker $options['containerFormat'] = $opt['containerFormat']; } - if(array_key_exists('diskFormat', $opt)){ // string : ami, ari, aki, vhd, vmdk, raw, qcow2, vdi, iso + if(isset($opt['diskFormat'])){ // string : ami, ari, aki, vhd, vmdk, raw, qcow2, vdi, iso $options['diskFormat'] = $opt['diskFormat']; } - if(array_key_exists('minDisk', $opt)){ //int + if(isset($opt['minDisk'])){ //int $options['minDisk'] = $opt['minDisk']; } - if(array_key_exists('minRam', $opt)){ // int + if(isset($opt['minRam'])){ // int $options['minRam'] = $opt['minRam']; } - if(array_key_exists('protected', $opt)){ // boolean + if(isset($opt['protected'])){ // boolean $options['protected'] = $opt['protected']; } - if(array_key_exists('properties', $opt)){ // type dict ? + if(isset($opt['properties'])){ // type dict ? $options['properties'] = $opt['properties']; } @@ -104,21 +104,24 @@ class Image { $options = Array(); // Voir vérification des types - if(array_key_exists('name', $opt)){ //string + if(isset($opt['name'])){ //string $options['name'] = $opt['name']; } - if(array_key_exists('minDisk', $opt)){ //int + if(isset($opt['minDisk'])){ //int $options['minDisk'] = $opt['minDisk']; } - if(array_key_exists('minRam', $opt)){ // int + if(isset($opt['minRam'])){ // int $options['minRam'] = $opt['minRam']; } - if(array_key_exists('protected', $opt)){ // boolean + if(isset($opt['protected'])){ // boolean $options['protected'] = $opt['protected']; } - if(array_key_exists('visibility', $opt)){ // public, private + if(isset($opt['visibility'])){ // public, private $options['visibility'] = $opt['visibility']; } + if(isset($opt['tags'])){ // list + $options['tags'] = $opt['tags']; + } $image->update($options); return $image; diff --git a/server/test.php b/server/test.php index d7ee6f6..196be0d 100644 --- a/server/test.php +++ b/server/test.php @@ -65,9 +65,11 @@ foreach($images as $i){ } echo "
"; -foreach ($list as $l) { - echo $l; - echo "
"; +if(isset($list)){ + foreach ($list as $l) { + echo $l; + echo "
"; + } } // Détails Image @@ -86,8 +88,10 @@ foreach ($list as $l) { /* $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 b39f5c1cd4631be3259b272e1f6cbe9b4915410b Mon Sep 17 00:00:00 2001 From: Yoggzo Date: Thu, 4 Feb 2016 23:48:43 +0100 Subject: Ajout des fonctionnalités de base des images, sans gestion la d'erreurs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/core/Image.php | 195 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 194 insertions(+), 1 deletion(-) (limited to 'server') diff --git a/server/core/Image.php b/server/core/Image.php index 8d1c8b6..d345034 100644 --- a/server/core/Image.php +++ b/server/core/Image.php @@ -1 +1,194 @@ - +oidentity = $ostack->imagesV2($options); + //$this->plugins = $apiP; + } + + + /** + * Details about an image + * + * @param array $opt + * options for the image creation + * + **/ + public function create_image(array $opt){ + // VOIR SI MAUVAIS TYPE + $options = Array(); + if(isset($opt['name'])){ // string, rendre le nom obligatoire + $options['name'] = $opt['name']; + } + if(isset($opt['id'])){ // UUID : nnnnnnnn-nnnn-nnnn-nnnn-nnnnnnnnnnnn + $options['id'] = $opt['id']; + } + if(isset($opt['visibility'])){ // public, private + $options['visibility'] = $opt['visibility']; + } + if(isset($opt['tags'])){ // list + $options['tags'] = $opt['tags']; + } + if(isset($opt['containerFormat'])){ // string : ami, ari, aki, bare, ovf, ova, docker + $options['containerFormat'] = $opt['containerFormat']; + } + if(isset($opt['diskFormat'])){ // string : ami, ari, aki, vhd, vmdk, raw, qcow2, vdi, iso + $options['diskFormat'] = $opt['diskFormat']; + } + if(isset($opt['minDisk'])){ //int + $options['minDisk'] = $opt['minDisk']; + } + if(isset($opt['minRam'])){ // int + $options['minRam'] = $opt['minRam']; + } + if(isset($opt['protected'])){ // boolean + $options['protected'] = $opt['protected']; + } + if(isset($opt['properties'])){ // type dict ? + $options['properties'] = $opt['properties']; + } + + $image = $this->oidentity->createImage($options); + + return $image; + } + + /* + * List images + */ + public function list_images(){ + $service = $this->oidentity; + $images = $service->listImages(); + return $images; + } + + /** + * Details about an image + * + * @param string $id + * identifier of the image + * + **/ + public function image_details($id){ + $service = $this->oidentity; + $image = $service->getImage($id); + 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; + $image = $service->getImage($id); + $options = Array(); + + // Voir vérification des types + if(isset($opt['name'])){ //string + $options['name'] = $opt['name']; + } + if(isset($opt['minDisk'])){ //int + $options['minDisk'] = $opt['minDisk']; + } + if(isset($opt['minRam'])){ // int + $options['minRam'] = $opt['minRam']; + } + if(isset($opt['protected'])){ // boolean + $options['protected'] = $opt['protected']; + } + if(isset($opt['visibility'])){ // public, private + $options['visibility'] = $opt['visibility']; + } + if(isset($opt['tags'])){ // list + $options['tags'] = $opt['tags']; + } + $image->update($options); + + return $image; + } + + /** + * Delete an image + * + * @param string $id + * identifier of the image + **/ + public function delete_image($id){ + $service = $this->oidentity; + $service->getImage($id)->delete(); + } + + /** + * Resactive an image + * + * @param string $id + * identifier of the image + **/ + public function reactivate_image($id){ + $service = $this->oidentity; + $image = $service->getImage($id); + $image->reactivate(); + } + + /** + * Desactive an image + * + * @param string $id + * identifier of the image + **/ + public function desactivate_image($id){ + $service = $this->oidentity; + $image = $service->getImage($id); + $image->deactivate(); + } + + /** + * 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){ + $service = $this->oidentity; + $image = $service->getImage($id); + $stream = \GuzzleHttp\Psr7\stream_for(fopen($file_name, 'r')); // A VOIR + $image->uploadData($stream); + } + + /** + * 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; + } +} +?> -- cgit v1.2.3 From c2a5b1880c19c1490c42eb40a6a15ce2bc64b9e9 Mon Sep 17 00:00:00 2001 From: EoleDev Date: Fri, 5 Feb 2016 00:07:31 +0100 Subject: Request Analyse reviewed, Server Initialisation Reviewed, Core Class Interface Created, App created --- server/core/App.php | 68 +++++++++++++++++++++++++++++ server/core/CoreInterface.php | 7 +++ server/core/Identity.php | 27 ++++++++---- server/core/LibOverride/genTokenOptions.php | 22 +++++++--- server/index.php | 52 ++++++++++------------ server/init.php | 54 ++++++----------------- 6 files changed, 147 insertions(+), 83 deletions(-) create mode 100755 server/core/App.php create mode 100755 server/core/CoreInterface.php mode change 100644 => 100755 server/core/Identity.php (limited to 'server') diff --git a/server/core/App.php b/server/core/App.php new file mode 100755 index 0000000..45f6922 --- /dev/null +++ b/server/core/App.php @@ -0,0 +1,68 @@ +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($tokenPost == NULL) $tokenClass->genIdentityToken(); + $opt = $tokenClass->getOptions($service); + return $this->openstack->identityV3($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/core/CoreInterface.php b/server/core/CoreInterface.php new file mode 100755 index 0000000..ed0d959 --- /dev/null +++ b/server/core/CoreInterface.php @@ -0,0 +1,7 @@ +oidentity = $ostack->identityV3(); - $this->plugins = $apiP; + $this->app = $app; + if($app->getOptions("Identity")) + $this->libClass = $app->getLibClass("Identity"); } + public function action($action){ + + //To be Complete + + } + public function genToken(){ - global $Args; - $token = $this->oidentity->generateToken($Args); - return $token; - } + + //To be Complete + + } } diff --git a/server/core/LibOverride/genTokenOptions.php b/server/core/LibOverride/genTokenOptions.php index 81ecfc8..58b87c1 100755 --- a/server/core/LibOverride/genTokenOptions.php +++ b/server/core/LibOverride/genTokenOptions.php @@ -81,7 +81,7 @@ class genTokenOptions $options['catalogType'] = 'false'; $options['region'] = 'RegionOne'; - $this->backup['Identity'] = unserialize($opt); + $this->backup['Identity'] = $opt; $token = $this->unserializeToken($this->backup['Identity']['token']); $baseUrl = $this->backup['Identity']['baseUrl']; @@ -129,7 +129,7 @@ class genTokenOptions $options['catalogType'] = 'image'; $options['region'] = 'RegionOne'; - $this->backup['Image'] = unserialize($opt); + $this->backup['Image'] = $opt; $token = $this->unserializeToken($this->backup['Image']['token']); $baseUrl = $this->backup['Image']['baseUrl']; @@ -176,7 +176,7 @@ class genTokenOptions $options['catalogType'] = 'network'; $options['region'] = 'RegionOne'; - $this->backup['Network'] = unserialize($opt); + $this->backup['Network'] = $opt; $token = $this->unserializeToken($this->backup['Network']['token']); $baseUrl = $this->backup['Network']['baseUrl']; @@ -224,7 +224,7 @@ class genTokenOptions $options['catalogType'] = 'compute'; $options['region'] = 'RegionOne'; - $this->backup['Compute'] = unserialize($opt); + $this->backup['Compute'] = $opt; $token = $this->unserializeToken($this->backup['Compute']['token']); $baseUrl = $this->backup['Compute']['baseUrl']; @@ -242,8 +242,18 @@ class genTokenOptions $this->optionsGlobal['Compute'] = $options; } - public function getBackup($service){ - return serialize($this->backup[$service]); + public function getBackup(){ + return serialize($this->backup); + } + + public function loadBackup($back){ + + $backup = unserialize($back); + loadComputeBackup($backup["Compute"]); + loadIdentityBackup($backup["Identity"]); + loadImageBackup($backup["Image"]); + loadNetworkBackup($backup["Network"]); + } public function getOptions($service){ diff --git a/server/index.php b/server/index.php index b3c061a..41f77b8 100755 --- a/server/index.php +++ b/server/index.php @@ -3,33 +3,29 @@ include_once("config.inc.php"); include_once("init.php"); -// $task = $_POST["task"]; -// $action = $_POST["action"]; - - - //$id = new identity($openstack_api, $pluginApi); - -// var_dump($id->genToken()); -// $identity = $openstack_api->identityV3($Args); - //$tmp = $identity->listEndpoints(); - //foreach($tmp as $cred){ -// echo $cred->id." %%%%%% "; - //} - //$servers = $compute->listServers(true); - //var_dump($servers); - //foreach($servers as $server){ - // echo $server->id." !!!!!!!!! "; - //} - - $tmp = new genTokenOptions($Args); - $tmp->loadIdentityBackup($identityBack); - $array = $tmp->getOptions("Identity"); - - $openstackTest = new OpenStack\OpenStack([]); - $identityTest = $openstackTest->identityV3($array); - $domainsTest = $identityTest->listDomains(); - foreach($domainsTest as $domain){ - echo $domain->id." %%%%%% "; + if(isset($_POST["task"]) && isset($_POST["action"])){ + $task = $_POST["task"]; + $action = $_POST["action"]; + }else if(isset($_POST["task"]) && $_POST["task"] == "Authenticate"){ + $task = $_POST["task"]; + }else{ + //Gestion Erreur + } + + if($task == "Authenticate"){ + + $App->authenticate(); + $App->show(); + + } + + switch($task) + { + case "identity": + include_once("core/Identity.php"); + $identityObject = new identity($App); + $identityObject->action($action); + $App->show(); + break; } - // var_dump($openstack_api->getBuilderOptions()); diff --git a/server/init.php b/server/init.php index 2c07947..cf08523 100755 --- a/server/init.php +++ b/server/init.php @@ -1,13 +1,15 @@ Array( - "name" => $user, - "password" => $password, - "domain" => Array( - "name" => "Default") - ), - "scope" => Array( - "project" => Array( - "name" => $project, - "domain" => Array( - "name" => "Default") - ) - ), - "authUrl" => $config["urlAuth"] - ); - } else { + } /*else { // Test Backend $user = "admin"; $password = "ae5or6cn"; $project = "admin"; - $Args = Array( + }*/ + + $Args = Array( "user" => Array( "name" => $user, "password" => $password, @@ -52,21 +40,7 @@ ), "authUrl" => $config["urlAuth"] ); - } - - $pluginApi = plugin_api::getInstance(); - //$openstack_api = new OpenStack\OpenStack($Args); - //$id = new identity($openstack_api, $pluginApi); - - //$token = $id->genToken(); - - $tmp = new genTokenOptions($Args); - $tmp->genIdentityToken(); - $array = $tmp->getOptions("Identity"); - $openstack_api = new OpenStack\OpenStack([]); - - $identityBack = $tmp->getBackup("Identity"); - //file_put_contents("token", serialize($tmp)); + $App = new App($Args); ?> -- cgit v1.2.3 From f58a83ffdad5b70026b05cb94874fa8824e6d93a Mon Sep 17 00:00:00 2001 From: Yoggzo Date: Sat, 6 Feb 2016 13:18:55 +0100 Subject: Add features for image members --- server/core/Image.php | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 79 insertions(+), 1 deletion(-) (limited to 'server') diff --git a/server/core/Image.php b/server/core/Image.php index d345034..75c1305 100644 --- a/server/core/Image.php +++ b/server/core/Image.php @@ -34,6 +34,9 @@ class Image { if(isset($opt['name'])){ // string, rendre le nom obligatoire $options['name'] = $opt['name']; } + else{ + //ERROR + } if(isset($opt['id'])){ // UUID : nnnnnnnn-nnnn-nnnn-nnnn-nnnnnnnnnnnn $options['id'] = $opt['id']; } @@ -183,12 +186,87 @@ class 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; } + + /** + * Add a member to image + * + * @param string $image_id + * identifier of the image + * + * @param string $member_id + * identifier of the member + **/ + public function add_member($image_id, $member_id){ + $service = $this->oidentity; + $member_id = $service>getImage($image_id)->addMember($member_id); + } + + + /** + * List members of an image + * + * @param string $image_id + * identifier of the image + **/ + public function list_member($image_id, $member_id){ + $service = $this->oidentity; + $image = $service->getImage($image_id); + $members = $image->listMembers(); + return $members; + } + + /** + * Show details of a member of an image + * + * @param string $image_id + * identifier of the image + * + * @param string $member_id + * identifier of the member + **/ + public function detail_member($image_id, $member_id){ + $service = $this->oidentity; + $member = $service>getImage($image_id)->getMember($member_id); + return $member; + } + + /** + * Remove a member of an image + * + * @param string $image_id + * identifier of the image + * + * @param string $member_id + * identifier of the member + **/ + public function remove_member($image_id, $member_id){ + $service = $this->oidentity; + $service>getImage($image_id)->getMember($member_id)->delete(); + } + + /** + * Update a member of an image + * + * @param string $image_id + * identifier of the image + * + * @param string $member_id + * identifier of the member + * + * @param string $status + * new status for the member + **/ + public function update_member($image_id, $member_id, $status){ + $service = $this->oidentity; + $member = $service>getImage($image_id)->getMember($member_id)->updateStatus($status); + } + } ?> -- cgit v1.2.3 From 43b65e1dbb53300d076f5885b5393ff68e248dd1 Mon Sep 17 00:00:00 2001 From: Yoggzo Date: Sun, 7 Feb 2016 10:24:59 +0100 Subject: Ajout de commentaires pour la gestion d'erreurs --- server/core/Image.php | 27 ++++++++++++++++++++++++--- server/test.php | 2 +- 2 files changed, 25 insertions(+), 4 deletions(-) (limited to 'server') diff --git a/server/core/Image.php b/server/core/Image.php index 75c1305..b83d155 100644 --- a/server/core/Image.php +++ b/server/core/Image.php @@ -31,8 +31,7 @@ class Image { public function create_image(array $opt){ // VOIR SI MAUVAIS TYPE $options = Array(); - if(isset($opt['name'])){ // string, rendre le nom obligatoire - $options['name'] = $opt['name']; + if(isset($opt['name'])){ // string, rendre le nom obligatoire, vérifier nom pas déjà pris } else{ //ERROR @@ -74,6 +73,7 @@ class Image { * List images */ public function list_images(){ + // vérifier si au moins une image $service = $this->oidentity; $images = $service->listImages(); return $images; @@ -87,6 +87,7 @@ class Image { * **/ public function image_details($id){ + //vérifier existence image $service = $this->oidentity; $image = $service->getImage($id); return $image; @@ -102,6 +103,7 @@ class Image { * options for the image creation **/ public function update_image($id, array $opt){ + //vérifier existence image $service = $this->oidentity; $image = $service->getImage($id); $options = Array(); @@ -137,6 +139,8 @@ class Image { * identifier of the image **/ public function delete_image($id){ + // si protected = true, demander de le mettre a false + // vérifier existence image $service = $this->oidentity; $service->getImage($id)->delete(); } @@ -148,6 +152,7 @@ class Image { * identifier of the image **/ public function reactivate_image($id){ + // vérifier existence image $service = $this->oidentity; $image = $service->getImage($id); $image->reactivate(); @@ -160,6 +165,7 @@ class Image { * identifier of the image **/ public function desactivate_image($id){ + // vérifier existence image $service = $this->oidentity; $image = $service->getImage($id); $image->deactivate(); @@ -175,6 +181,7 @@ class Image { * path of the image **/ public function upload_image($id, $file_name){ + // vérifier existence image $service = $this->oidentity; $image = $service->getImage($id); $stream = \GuzzleHttp\Psr7\stream_for(fopen($file_name, 'r')); // A VOIR @@ -187,7 +194,8 @@ class Image { * @param string $id * identifier of the image **/ - public function download_image($id){ + public function download_image($id){ + // vérifier existence image $service = $this->oidentity; $image = $service->getImage($id); $stream = $image->downloadData(); @@ -204,6 +212,9 @@ class Image { * identifier of the member **/ public function add_member($image_id, $member_id){ + // vérifier existence image + // on doit être le proprio de l'image + // vérifier membre existe $service = $this->oidentity; $member_id = $service>getImage($image_id)->addMember($member_id); } @@ -216,6 +227,7 @@ class Image { * identifier of the image **/ public function list_member($image_id, $member_id){ + // vérifier existence image $service = $this->oidentity; $image = $service->getImage($image_id); $members = $image->listMembers(); @@ -232,6 +244,9 @@ class Image { * identifier of the member **/ public function detail_member($image_id, $member_id){ + // vérifier existence image + // on doit être le proprio de l'image + // vérifier membre existe $service = $this->oidentity; $member = $service>getImage($image_id)->getMember($member_id); return $member; @@ -247,6 +262,9 @@ class Image { * identifier of the member **/ public function remove_member($image_id, $member_id){ + // vérifier existence image + // on doit être le proprio de l'image + // vérifier membre existe $service = $this->oidentity; $service>getImage($image_id)->getMember($member_id)->delete(); } @@ -264,6 +282,9 @@ class Image { * new status for the member **/ public function update_member($image_id, $member_id, $status){ + // vérifier existence image + // on doit être le proprio de l'image + // vérifier membre existe $service = $this->oidentity; $member = $service>getImage($image_id)->getMember($member_id)->updateStatus($status); } diff --git a/server/test.php b/server/test.php index 196be0d..f0e68c4 100644 --- a/server/test.php +++ b/server/test.php @@ -75,7 +75,7 @@ if(isset($list)){ // Détails Image //$details = $image->image_details($id_image); -//$image->delete_image($id_image); +//$image->delete_image('123456'); //$image->desactivate_image($id_image); //$image->reactivate_image($id_image); -- cgit v1.2.3 From ee36719e20e6a72ca07849d4a2fea32c6ca9734f Mon Sep 17 00:00:00 2001 From: Yoggzo Date: Sun, 7 Feb 2016 10:29:12 +0100 Subject: Add commentaries for errors managing --- server/core/Image.php | 107 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 103 insertions(+), 4 deletions(-) (limited to 'server') diff --git a/server/core/Image.php b/server/core/Image.php index d345034..b83d155 100644 --- a/server/core/Image.php +++ b/server/core/Image.php @@ -31,8 +31,10 @@ class Image { public function create_image(array $opt){ // VOIR SI MAUVAIS TYPE $options = Array(); - if(isset($opt['name'])){ // string, rendre le nom obligatoire - $options['name'] = $opt['name']; + if(isset($opt['name'])){ // string, rendre le nom obligatoire, vérifier nom pas déjà pris + } + else{ + //ERROR } if(isset($opt['id'])){ // UUID : nnnnnnnn-nnnn-nnnn-nnnn-nnnnnnnnnnnn $options['id'] = $opt['id']; @@ -71,6 +73,7 @@ class Image { * List images */ public function list_images(){ + // vérifier si au moins une image $service = $this->oidentity; $images = $service->listImages(); return $images; @@ -84,6 +87,7 @@ class Image { * **/ public function image_details($id){ + //vérifier existence image $service = $this->oidentity; $image = $service->getImage($id); return $image; @@ -99,6 +103,7 @@ class Image { * options for the image creation **/ public function update_image($id, array $opt){ + //vérifier existence image $service = $this->oidentity; $image = $service->getImage($id); $options = Array(); @@ -134,6 +139,8 @@ class Image { * identifier of the image **/ public function delete_image($id){ + // si protected = true, demander de le mettre a false + // vérifier existence image $service = $this->oidentity; $service->getImage($id)->delete(); } @@ -145,6 +152,7 @@ class Image { * identifier of the image **/ public function reactivate_image($id){ + // vérifier existence image $service = $this->oidentity; $image = $service->getImage($id); $image->reactivate(); @@ -157,6 +165,7 @@ class Image { * identifier of the image **/ public function desactivate_image($id){ + // vérifier existence image $service = $this->oidentity; $image = $service->getImage($id); $image->deactivate(); @@ -172,6 +181,7 @@ class Image { * path of the image **/ public function upload_image($id, $file_name){ + // vérifier existence image $service = $this->oidentity; $image = $service->getImage($id); $stream = \GuzzleHttp\Psr7\stream_for(fopen($file_name, 'r')); // A VOIR @@ -183,12 +193,101 @@ class Image { * * @param string $id * identifier of the image - */ - public function download_image($id){ + **/ + public function download_image($id){ + // vérifier existence image $service = $this->oidentity; $image = $service->getImage($id); $stream = $image->downloadData(); return $stream; } + + /** + * Add a member to image + * + * @param string $image_id + * identifier of the image + * + * @param string $member_id + * identifier of the member + **/ + public function add_member($image_id, $member_id){ + // vérifier existence image + // on doit être le proprio de l'image + // vérifier membre existe + $service = $this->oidentity; + $member_id = $service>getImage($image_id)->addMember($member_id); + } + + + /** + * List members of an image + * + * @param string $image_id + * identifier of the image + **/ + public function list_member($image_id, $member_id){ + // vérifier existence image + $service = $this->oidentity; + $image = $service->getImage($image_id); + $members = $image->listMembers(); + return $members; + } + + /** + * Show details of a member of an image + * + * @param string $image_id + * identifier of the image + * + * @param string $member_id + * identifier of the member + **/ + public function detail_member($image_id, $member_id){ + // vérifier existence image + // on doit être le proprio de l'image + // vérifier membre existe + $service = $this->oidentity; + $member = $service>getImage($image_id)->getMember($member_id); + return $member; + } + + /** + * Remove a member of an image + * + * @param string $image_id + * identifier of the image + * + * @param string $member_id + * identifier of the member + **/ + public function remove_member($image_id, $member_id){ + // vérifier existence image + // on doit être le proprio de l'image + // vérifier membre existe + $service = $this->oidentity; + $service>getImage($image_id)->getMember($member_id)->delete(); + } + + /** + * Update a member of an image + * + * @param string $image_id + * identifier of the image + * + * @param string $member_id + * identifier of the member + * + * @param string $status + * new status for the member + **/ + public function update_member($image_id, $member_id, $status){ + // vérifier existence image + // on doit être le proprio de l'image + // vérifier membre existe + $service = $this->oidentity; + $member = $service>getImage($image_id)->getMember($member_id)->updateStatus($status); + } + } ?> -- cgit v1.2.3 From 1cd1ae92f414573942262f65dc1644e8ff9bb8f6 Mon Sep 17 00:00:00 2001 From: EoleDev Date: Sun, 7 Feb 2016 22:42:33 +0100 Subject: Structure identity Class, beginning of descriptions. --- server/core/Identity.php | 929 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 920 insertions(+), 9 deletions(-) (limited to 'server') diff --git a/server/core/Identity.php b/server/core/Identity.php index d607957..7b6293c 100755 --- a/server/core/Identity.php +++ b/server/core/Identity.php @@ -1,28 +1,939 @@ ] + * + * @return identity + */ public function __construct($app){ $this->app = $app; - if($app->getOptions("Identity")) $this->libClass = $app->getLibClass("Identity"); - } + } - public function action($action){ + $credentials = array(); + + /** + * Add a credential for the given user/project. + * + * Create a secret/access pair for use with ec2 style auth. + * This operation will generates a new set of credentials that map the user/project pair. + * + * @throws [Type] [] + * + * @return void + */ + $credentials["addCredential"] = function(){ - //To be Complete } - public function genToken(){ - - //To be Complete + /** + * List the credentials for a given user. + * + * @throws [Type] [] + * + * @return void + */ + $credentials["listCredentials"] = function(){ + + + } + + /** + * Retrieve a user’s access/secret pair by the access key. + * + * @throws [Type] [] + * + * @return void + */ + $credentials["showCredential"] = function(){ + + + } + + /** + * Update a user’s access/secret pair. + * + * @throws [Type] [] + * + * @return void + */ + $credentials["updateCredential"] = function(){ + + + } + + /** + * Delete a user’s access/secret pair. + * + * @throws [Type] [] + * + * @return void + */ + $credentials["deleteCredential"] = function(){ + + + } + + $domains = array(); + + /** + * Add a domain to an OpenStack instance. + * + * @throws [Type] [] + * + * @return void + */ + $domains["addDomain"] = function(){ + + + } + + /** + * Retrieve the different domain's list. + * + * @throws [Type] [] + * + * @return void + */ + $domains["listDomains"] = function(){ + + + } + + /** + * Retrieve the details of a given domain. + * + * @throws [Type] [] + * + * @return void + */ + $domains["showDomain"] = function(){ + + + } + + /** + * Update the given domain. + * + * @throws [Type] [] + * + * @return void + */ + $domains["updateDomain"] = function(){ + + + } + + /** + * Delete the given domain. + * + * @throws [Type] [] + * + * @return void + */ + $domains["deleteDomain"] = function(){ + + + } + + /** + * Retrieve the different roles of a given user in a domain. + * + * @throws [Type] [] + * + * @return void + */ + $domains["listRolesDomainUser"] = function(){ + + + } + + /** + * Grant a role to a given user in a domain. + * + * @throws [Type] [] + * + * @return void + */ + $domains["grantRoleDomainUser"] = function(){ + + + } + + /** + * Verify that a user has a given role in a domain. + * + * @throws [Type] [] + * + * @return void + */ + $domains["checkRoleDomainUser"] = function(){ + + + } + + /** + * Delete a role for a given user in a domain. + * + * @throws [Type] [] + * + * @return void + */ + $domains["revokeRoleDomainUser"] = function(){ + + + } + + /** + * Retrieve the roles of a given group in a domain. + * + * @throws [Type] [] + * + * @return void + */ + $domains["listRolesDomainGroup"] = function(){ + + + } + + /** + * Add a role to a given group in a domain. + * + * @throws [Type] [] + * + * @return void + */ + $domains["grantRoleDomainGroup"] = function(){ + + + } + + /** + * Verify that a role is associated with a given group in a domain. + * + * @throws [Type] [] + * + * @return void + */ + $domains["checkRoleDomainGroup"] = function(){ + + + } + + /** + * Delete a role for a given group in a domain. + * + * A *description*, that can span multiple lines, to go _in-depth_ into the details of this element + * and to provide some background information or textual references. + * + * @param string $myArgument With a *description* of this argument, these may also + * span multiple lines. + * + * @throws [Type] [] + * + * @return void + */ + $domains["revokeRoleDomainGroup"] = function(){ + + + } + + $endpoints = array(); + + /** + * Add an endpoint to the Openstack instance + * + * @throws [Type] [] + * + * @return void + */ + $endpoints["addEndpoint"] = function(){ + + + } + + /** + * Retrieve the endpoint for the given id + * + * @throws [Type] [] + * + * @return void + */ + $endpoints["getEndpoint"] = function(){ + + + } + + /** + * Retrieve the list of the different endpoints + * + * @throws [Type] [] + * + * @return void + */ + $endpoints["listEndpoints"] = function(){ + + + } + + /** + * Update a given endpoint + * + * @throws [Type] [] + * + * @return void + */ + $endpoints["updateEndpoint"] = function(){ + + + } + + /** + * Delete a given endpoint + * + * @throws [Type] [] + * + * @return void + */ + $endpoints["deleteEndpoint"] = function(){ + + + } + + $groups = array(); + + /** + * Add a group. + * + * @throws [Type] [] + * + * @return void + */ + $groups["addGroup"] = function(){ + + + } + + /** + * Retrieve the group's list. + * + * @throws [Type] [] + * + * @return void + */ + $groups["listGroups"] = function(){ + + + } + + /** + * Retrieve the details of a given group. + * + * @throws [Type] [] + * + * @return void + */ + $groups["showGroup"] = function(){ + + + } + + /** + * Update a given group. + * + * @throws [Type] [] + * + * @return void + */ + $groups["updateGroup"] = function(){ + + + } + + /** + * Delete the given group. + * + * @throws [Type] [] + * + * @return void + */ + $groups["deleteGroup"] = function(){ + + + } + + /** + * Retrieve the users of a given group. + * + * @throws [Type] [] + * + * @return void + */ + $groups["listGroupUsers"] = function(){ + + + } + + /** + * Add a user to a group. + * + * @throws [Type] [] + * + * @return void + */ + $groups["addGroupUser"] = function(){ + + + } + + /** + * Remove a user from a given group. + * + * @throws [Type] [] + * + * @return void + */ + $groups["removeGroupUser"] = function(){ + + + } + + /** + * Check if a group contains a given user. + * + * @throws [Type] [] + * + * @return void + */ + $groups["checkGroupUser"] = function(){ + + + } + + $policies = array(); + + /** + * @todo + * + * @throws [Type] [] + * + * @return void + */ + $policies["addPolicies"] = function(){ + + + } + + /** + * @todo + * + * @throws [Type] [] + * + * @return void + */ + $policies["listPolicies"] = function(){ + + + } + + /** + * @todo + * + * @throws [Type] [] + * + * @return void + */ + $policies["showPolicie"] = function(){ + + + } + + /** + * @todo + * + * @throws [Type] [] + * + * @return void + */ + $policies["updatePolicies"] = function(){ + } + + /** + * @todo + * + * @throws [Type] [] + * + * @return void + */ + $policies["deletePolicies"] = function(){ + + + } + + $projects = array(); + + /** + * Add a project. + * + * @throws [Type] [] + * + * @return void + */ + $projects["addProject"] = function(){ + + + } + + /** + * Retrieve the different projects. + * + * @throws [Type] [] + * + * @return void + */ + $projects["listProjects"] = function(){ + + + } + + /** + * Retrieve the details of a given project. + * + * @throws [Type] [] + * + * @return void + */ + $projects["showProject"] = function(){ + + + } + + /** + * Update a given project. + * + * @throws [Type] [] + * + * @return void + */ + $projects["updateProject"] = function(){ + + + } + + /** + * Delete a given project. + * + * @throws [Type] [] + * + * @return void + */ + $projects["deleteProject"] = function(){ + + + } + + /** + * List the roles of a given user in a project. + * + * @throws [Type] [] + * + * @return void + */ + $projects["listRolesProjectUser"] = function(){ + + + } + + /** + * Grant a role to an user in a project. + * + * @throws [Type] [] + * + * @return void + */ + $projects["grantRoleProjectUser"] = function(){ + + + } + + /** + * Check if a given user has a role in a project. + * + * @throws [Type] [] + * + * @return void + */ + $projects["checkRoleProjectUser"] = function(){ + + + } + + /** + * Delete a role for a given user in a project. + * + * @throws [Type] [] + * + * @return void + */ + $projects["revokeRoleProjectUser"] = function(){ + + + } + + /** + * List the roles of a group in a project. + * + * @throws [Type] [] + * + * @return void + */ + $projects["listRolesProjectGroup"] = function(){ + + + } + + /** + * Add a role to a group in a project. + * + * @throws [Type] [] + * + * @return void + */ + $projects["grantRoleProjectGroup"] = function(){ + + + } + + /** + * Check if a group has a given role in a project. + * + * @throws [Type] [] + * + * @return void + */ + $projects["checkRoleProjectGroup"] = function(){ + + + } + + /** + * Delete a role for a group in a project. + * + * @throws [Type] [] + * + * @return void + */ + $projects["revokeRoleProjectGroup"] = function(){ + + + } + + $roles = array(); + + /** + * Add a role. + * + * @throws [Type] [] + * + * @return void + */ + $roles["addRole"] = function(){ + + + } + + /** + * List the different roles + * + * @throws [Type] [] + * + * @return void + */ + $roles["listRoles"] = function(){ + + + } + + /** + * @todo + * + * @throws [Type] [] + * + * @return void + */ + $roles["listRoleAssignements"] = function(){ + + + } + + $services = array(); + + /** + * Add a service. + * + * @throws [Type] [] + * + * @return void + */ + $services["addService"] = function(){ + + + } + + /** + * Retrieve the different services. + * + * @throws [Type] [] + * + * @return void + */ + $services["listServices"] = function(){ + + + } + + /** + * Retrieve the details for a given service. + * + * @throws [Type] [] + * + * @return void + */ + $services["showService"] = function(){ + + + } + + /** + * Delete a given service. + * + * @throws [Type] [] + * + * @return void + */ + $services["deleteService"] = function(){ + + + } + + $tokens = array(); + + /** + * Generate a new token for a given user id. + * + * @throws [Type] [] + * + * @return void + */ + $tokens["genTokenUserID"] = function(){ + + + } + + /** + * Generate a new token for a given user name. + * + * @throws [Type] [] + * + * @return void + */ + $tokens["genTokenUserName"] = function(){ + + + } + + /** + * Generate a new token from another token ID. + * + * @throws [Type] [] + * + * @return void + */ + $tokens["geneTokenID"] = function(){ + + + } + + /** + * Generate a new token scoped by a project ID. + * + * @throws [Type] [] + * + * @return void + */ + $tokens["genTokenScopedProjectID"] = function(){ + + + } + + /** + * Generate a new token scoped by a project name. + * + * @throws [Type] [] + * + * @return void + */ + $tokens["genTokenScopedProjectName"] = function(){ + + + } + + /** + * Check if a token is validate. + * + * @throws [Type] [] + * + * @return void + */ + $tokens["validateToken"] = function(){ + + + } + + /** + * Delete a given token. + * + * @throws [Type] [] + * + * @return void + */ + $tokens["revokeToken"] = function(){ + + + } + + $users = array(); + + /** + * Add a new user. + * + * @throws [Type] [] + * + * @return void + */ + $users["addUser"] = function(){ + + + } + + /** + * Retrieve the different users. + * + * @throws [Type] [] + * + * @return void + */ + $users["listUsers"] = function(){ + + + } + + /** + * Retrieve the details of a given user. + * + * @throws [Type] [] + * + * @return void + */ + $users["showUser"] = function(){ + + + } + + /** + * Update a given user. + * + * @throws [Type] [] + * + * @return void + */ + $users["updateUser"] = function(){ + + + } + + /** + * Delete a given user. + * + * @throws [Type] [] + * + * @return void + */ + $users["deleteUser"] = function(){ + + + } + + /** + * Retrieve the groups which contains a given user. + * + * @throws [Type] [] + * + * @return void + */ + $users["listUserGroups"] = function(){ + + + } + + /** + * Retrieve the projects which contains a given user. + * + * @throws [Type] [] + * + * @return void + */ + $users["listUserProjects"] = function(){ + + + } + + $actions["Credentials"] = $credentials; + $actions["Domains"] = $domains; + $actions["Endpoints"] = $endpoints; + $actions["Groups"] = $groups; + $actions["Policies"] = $policies; + $actions["Projects"] = $projects; + $actions["Roles"] = $roles; + $actions["Services"] = $services; + $actions["Tokens"] = $tokens; + $actions["Users"] = $users; } -- cgit v1.2.3 From 7b9f17ba036f016078aea27565e1d31fce586b3f Mon Sep 17 00:00:00 2001 From: EoleDev Date: Wed, 10 Feb 2016 18:09:44 +0100 Subject: Add REST request management for Image Service --- server/core/App.php | 5 +++++ server/index.php | 7 +++++++ 2 files changed, 12 insertions(+) (limited to 'server') 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; } -- cgit v1.2.3 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 ++++++++++++++++++++++++++++++++++++++++++++++ server/test.php | 97 ---------------------------------------------- 2 files changed, 97 insertions(+), 97 deletions(-) create mode 100644 server/Test/imageTests.php delete mode 100644 server/test.php (limited to 'server') 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 diff --git a/server/test.php b/server/test.php deleted file mode 100644 index f0e68c4..0000000 --- a/server/test.php +++ /dev/null @@ -1,97 +0,0 @@ -"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') 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') 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') 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') 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 294fbb4d11b9399be231bd999447f2a214e11a1f Mon Sep 17 00:00:00 2001 From: EoleDev Date: Fri, 12 Feb 2016 12:45:00 +0100 Subject: ErrorManagement Class Introduction --- server/core/App.php | 32 ++++++++++++++++++++++++++-- server/core/ErrorManagement.php | 39 +++++++++++++++++++++++++++++++++++ server/core/Identity.php | 34 ++++++++++++++++++++++++++---- server/vendor/php-opencloud/openstack | 2 +- 4 files changed, 100 insertions(+), 7 deletions(-) create mode 100755 server/core/ErrorManagement.php (limited to 'server') diff --git a/server/core/App.php b/server/core/App.php index bba99b4..ff2e1af 100755 --- a/server/core/App.php +++ b/server/core/App.php @@ -1,13 +1,21 @@ tokenClass = new genTokenOptions($args); $this->openstack = new OpenStack\OpenStack([]); $this->pluginsApi = plugin_api::getInstance(); + $this->errorClass = new errorManagement($this); $this->output = array(); + $this->postParams = $_POST; } @@ -53,19 +63,37 @@ class App{ $this->tokenClass->genNetworkToken(); $this->setOutput("token", $this->tokenClass->getBackup()); - }catch(Exception $e){ - echo $e; + }catch(BadResponseError $e){ + var_dump($e); + }catch(UserInputError $e){ + var_dump($e); + }catch(BaseError $e){ + var_dump($e); exit(); + }catch(NotImplementedError $e){ + var_dump($e); } } + public function getPostParam($name){ + + return $this->postParams[$name]; + + } + public function setOutput($key, $out){ $this->output[$key] = $out; } + public function getErrorInstance(){ + + return $this->errorClass; + + } + public function show(){ echo json_encode($this->output); } diff --git a/server/core/ErrorManagement.php b/server/core/ErrorManagement.php new file mode 100755 index 0000000..ebd5abe --- /dev/null +++ b/server/core/ErrorManagement.php @@ -0,0 +1,39 @@ +app = $args; + + } + + public function BaseErrorHandler($error){ + + } + + public function BadResponseHandler($error){ + + } + + public function NotImplementedHandler($error){ + + } + + public function UserInputHandler($error){ + + } + + +} + +?> \ No newline at end of file diff --git a/server/core/Identity.php b/server/core/Identity.php index 7b6293c..1dc8373 100755 --- a/server/core/Identity.php +++ b/server/core/Identity.php @@ -9,7 +9,7 @@ * * @todo Complete the functions and finish the descriptions */ - +use OpenStack\Common\Error; /** * Identity Class of the back-end application @@ -59,6 +59,25 @@ class identity implements Core{ */ $credentials["addCredential"] = function(){ + $blob = $this->app->getPostParam("blob"); + $projectId = $this->app->getPostParam("projectId"); + $type = $this->app->getPostParam("type"); + $userId = $this->app->getPostParam("userId"); + + if(!isset($blob) || !isset($projectId) || !isset($type) || !isset($userId)){ + $this->app->setOutput("Error", "Parameters Incorrect"); + } + + try{ + + $opt = array('blob' => $blob, 'projectId' => $projectId, 'type' => $type, 'userId' => $userId); + $res = $this->libClass->createCredential($opt); + + }catch(Exception $e){ + + } + + ] } @@ -82,7 +101,8 @@ class identity implements Core{ * @return void */ $credentials["showCredential"] = function(){ - + $credential = $identity->getCredential('credentialId'); +$credential->retrieve(); } @@ -94,7 +114,12 @@ class identity implements Core{ * @return void */ $credentials["updateCredential"] = function(){ - + $credential = $identity->getCredential('credentialId'); + +$credential->type = 'foo'; +$credential->blob = 'bar'; + +$credential->update(); } @@ -106,7 +131,8 @@ class identity implements Core{ * @return void */ $credentials["deleteCredential"] = function(){ - + $credential = $identity->getCredential('credentialId'); +$credential->delete(); } diff --git a/server/vendor/php-opencloud/openstack b/server/vendor/php-opencloud/openstack index 15aca73..1419eb2 160000 --- a/server/vendor/php-opencloud/openstack +++ b/server/vendor/php-opencloud/openstack @@ -1 +1 @@ -Subproject commit 15aca73f423166c7ef8337ba08615c103c66e931 +Subproject commit 1419eb2e01164bb6b8b837df37724423907352d7 -- 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') 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 @@ Date: Fri, 12 Feb 2016 15:45:25 +0100 Subject: Identity Class first function --- server/core/Identity.php | 59 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 47 insertions(+), 12 deletions(-) (limited to 'server') diff --git a/server/core/Identity.php b/server/core/Identity.php index 1dc8373..df07f5d 100755 --- a/server/core/Identity.php +++ b/server/core/Identity.php @@ -53,7 +53,10 @@ class identity implements Core{ * Create a secret/access pair for use with ec2 style auth. * This operation will generates a new set of credentials that map the user/project pair. * - * @throws [Type] [] + * @param JsonString $blob credentials information with this structure for ec2: "{\"access\":\"181920\",\"secret\":\"secretKey\"}" + * @param String $projectId project's UUID + * @param String $type Type of credential : ec2, cert... + * @param String $userId Id of the user which own the credential * * @return void */ @@ -73,36 +76,68 @@ class identity implements Core{ $opt = array('blob' => $blob, 'projectId' => $projectId, 'type' => $type, 'userId' => $userId); $res = $this->libClass->createCredential($opt); - }catch(Exception $e){ - - } - - ] + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } /** * List the credentials for a given user. * - * @throws [Type] [] - * * @return void */ $credentials["listCredentials"] = function(){ - + try{ + + $this->libClass->listCredentials() + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } /** * Retrieve a user’s access/secret pair by the access key. * - * @throws [Type] [] + * @param String $credentialId credential id for which it retrieve the details * * @return void */ $credentials["showCredential"] = function(){ - $credential = $identity->getCredential('credentialId'); -$credential->retrieve(); + $credentId = $this->app->getPostParam("credentialId"); + + try{ + + $cred = $this->libClass->getCredential($credentId); + $cred->retrieve(); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } -- cgit v1.2.3 From 6890283bcf2e2f0cd0aa9923a18298fada6426c1 Mon Sep 17 00:00:00 2001 From: EoleDev Date: Fri, 12 Feb 2016 18:01:18 +0100 Subject: Identity Some functions Implementations, App error class binding on authenticate, ErrorManagement Implementation Beginning --- server/core/App.php | 17 ++-- server/core/ErrorManagement.php | 4 +- server/core/Identity.php | 221 ++++++++++++++++++++++++++++++++++++---- 3 files changed, 210 insertions(+), 32 deletions(-) (limited to 'server') diff --git a/server/core/App.php b/server/core/App.php index ff2e1af..babb3d9 100755 --- a/server/core/App.php +++ b/server/core/App.php @@ -64,15 +64,14 @@ class App{ $this->setOutput("token", $this->tokenClass->getBackup()); }catch(BadResponseError $e){ - var_dump($e); - }catch(UserInputError $e){ - var_dump($e); - }catch(BaseError $e){ - var_dump($e); - exit(); - }catch(NotImplementedError $e){ - var_dump($e); - } + $this->errorClass->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->errorClass->UserInputHandler($e); + }catch(BaseError $e){ + $this->errorClass->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->errorClass->NotImplementedHandler($e); + } } diff --git a/server/core/ErrorManagement.php b/server/core/ErrorManagement.php index ebd5abe..6bff61f 100755 --- a/server/core/ErrorManagement.php +++ b/server/core/ErrorManagement.php @@ -22,11 +22,11 @@ Class errorManagement{ } public function BadResponseHandler($error){ - + $this->app->setOutput("Error", "Erreur Interne, Merci de contacter un administrateur!"); } public function NotImplementedHandler($error){ - + $this->app->setOutput("Error", "Erreur Interne, Merci de contacter un administrateur!"); } public function UserInputHandler($error){ diff --git a/server/core/Identity.php b/server/core/Identity.php index df07f5d..7ad238b 100755 --- a/server/core/Identity.php +++ b/server/core/Identity.php @@ -53,10 +53,10 @@ class identity implements Core{ * Create a secret/access pair for use with ec2 style auth. * This operation will generates a new set of credentials that map the user/project pair. * - * @param JsonString $blob credentials information with this structure for ec2: "{\"access\":\"181920\",\"secret\":\"secretKey\"}" - * @param String $projectId project's UUID - * @param String $type Type of credential : ec2, cert... - * @param String $userId Id of the user which own the credential + * @param JsonString $blob Required credentials information with this structure for ec2: "{\"access\":\"181920\",\"secret\":\"secretKey\"}" + * @param String $projectId Required project's UUID + * @param String $type Required Type of credential : ec2, cert... + * @param String $userId Required Id of the user which own the credential * * @return void */ @@ -69,6 +69,7 @@ class identity implements Core{ if(!isset($blob) || !isset($projectId) || !isset($type) || !isset($userId)){ $this->app->setOutput("Error", "Parameters Incorrect"); + return; } try{ @@ -76,6 +77,8 @@ class identity implements Core{ $opt = array('blob' => $blob, 'projectId' => $projectId, 'type' => $type, 'userId' => $userId); $res = $this->libClass->createCredential($opt); + //TODO parse answer + }catch(BadResponseError $e){ $this->app->getErrorInstance->BadResponseHandler($e); }catch(UserInputError $e){ @@ -115,13 +118,17 @@ class identity implements Core{ /** * Retrieve a user’s access/secret pair by the access key. * - * @param String $credentialId credential id for which it retrieve the details + * @param String $credentialId Required credential id for which it retrieve the details * * @return void */ $credentials["showCredential"] = function(){ $credentId = $this->app->getPostParam("credentialId"); + if(!isset($credentId)){ + $this->app->setOutput("Error", "Parameters Incorrect"); + } + try{ $cred = $this->libClass->getCredential($credentId); @@ -144,93 +151,265 @@ class identity implements Core{ /** * Update a user’s access/secret pair. * - * @throws [Type] [] + * @param String $credentialId Required credential id to update + * @param JsonString $blob Required credentials information with this structure for ec2: "{\"access\":\"181920\",\"secret\":\"secretKey\"}" + * @param String $type Required Type of credential : ec2, cert... * * @return void */ $credentials["updateCredential"] = function(){ - $credential = $identity->getCredential('credentialId'); + + $credentId = $this->app->getPostParam("credentialId"); + $blob = $this->app->getPostParam("blob"); + $type = $this->app->getPostParam("type"); + + if(!isset($blob) || !isset($credentId) || !isset($type)){ + $this->app->setOutput("Error", "Parameters Incorrect"); + } + + + try{ + + $credential = $this->libClass->getCredential($credentId); -$credential->type = 'foo'; -$credential->blob = 'bar'; + $credential->type = $type; + $credential->blob = $blob; -$credential->update(); - + $credential->update(); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } /** * Delete a user’s access/secret pair. * - * @throws [Type] [] + * @param String $credentialId Required credential id to delete * * @return void */ $credentials["deleteCredential"] = function(){ - $credential = $identity->getCredential('credentialId'); -$credential->delete(); - } + $credentId = $this->app->getPostParam("credentialId"); + + if(!isset($credentId)){ + $this->app->setOutput("Error", "Parameters Incorrect"); + } + + try{ + + $credential = $this->libClass->getCredential($credentId); + $credential->delete(); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } + }- $domains = array(); /** * Add a domain to an OpenStack instance. * - * @throws [Type] [] + * @param String $desc Optional Domain Description + * @param String $enabled Optional Domain enabled or not : value true or false + * @param String $name Required Domain Name * * @return void */ $domains["addDomain"] = function(){ + $description = $this->app->getPostParam("desc"); + $enabled = $this->app->getPostParam("enabled"); + $name = $this->app->getPostParam("name"); + + if(!isset($name)){ + $this->app->setOutput("Error", "Parameters Incorrect"); + return; + } + + if(isset($enabled) && isset($description)) + $opt = array('description' => $description, 'enabled' => $enabled, 'name' => $name); + elseif(isset($enabled)) + $opt = array('enabled' => $enabled, 'name' => $name); + elseif(isset($description)) + $opt = array('description' => $description, 'name' => $name); + else + $opt = array('name' => $name); + + try{ + + $res = $this->libClass->createCredential($opt); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } /** * Retrieve the different domain's list. * - * @throws [Type] [] - * * @return void */ $domains["listDomains"] = function(){ + try{ + + $this->libClass->listDomains() + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } /** * Retrieve the details of a given domain. * - * @throws [Type] [] + * @param String $domainId Required Domain id for which it retrieve the details * * @return void */ $domains["showDomain"] = function(){ + $domId = $this->app->getPostParam("domainId"); + + if(!isset($domId)){ + $this->app->setOutput("Error", "Parameters Incorrect"); + } + try{ + + $domain = $this->libClass->getDomain($domId); + $domain->retrieve(); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } /** * Update the given domain. * - * @throws [Type] [] + * @param String $domainId Required domain id to update + * @param String $desc Optional Domain Description + * @param String $enabled Optional Domain enabled or not : value true or false + * @param String $name Required Domain Name * * @return void */ $domains["updateDomain"] = function(){ + $domId = $this->app->getPostParam("domainId"); + $description = $this->app->getPostParam("desc"); + $enabled = $this->app->getPostParam("enabled"); + $name = $this->app->getPostParam("name"); + + if(!isset($domId)){ + $this->app->setOutput("Error", "Parameters Incorrect"); + return; + } + + try{ + + $domain = $this->libClass->getDomain($domId); + + if(isset($name)) + $domain->name = $name; + if(isset($enabled)) + $domain->enabled = $enabled; + if(isset($description)) + $domain->description = $description; + + $domain->update(); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } /** * Delete the given domain. * - * @throws [Type] [] + * @param String $domainId Required Domain id to delete * * @return void */ $domains["deleteDomain"] = function(){ + $domId = $this->app->getPostParam("domainId"); + if(!isset($domId)){ + $this->app->setOutput("Error", "Parameters Incorrect"); + } + + try{ + + $domain = $this->libClass->getDomain($domId); + $domain->delete(); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } /** -- cgit v1.2.3 From 219847749e0cb26f11c0f4231fccdcb73e919d97 Mon Sep 17 00:00:00 2001 From: EoleDev Date: Fri, 12 Feb 2016 20:03:21 +0100 Subject: Implementation Major Functionality --- server/core/Identity.php | 1482 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 1448 insertions(+), 34 deletions(-) (limited to 'server') diff --git a/server/core/Identity.php b/server/core/Identity.php index 7ad238b..00199ec 100755 --- a/server/core/Identity.php +++ b/server/core/Identity.php @@ -421,7 +421,30 @@ class identity implements Core{ */ $domains["listRolesDomainUser"] = function(){ + $domId = $this->app->getPostParam("domainId"); + $userId = $this->app->getPostParam("userId"); + + if(!isset($domId) || !isset($userId)){ + + } + try{ + + $domain = $this->libClass->getDomain($domId); + + $domain->listUserRoles(['userId' => $userId]); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } /** @@ -432,8 +455,34 @@ class identity implements Core{ * @return void */ $domains["grantRoleDomainUser"] = function(){ + $domId = $this->app->getPostParam("domainId"); + $roleId = $this->app->getPostParam("roleId"); + $userId = $this->app->getPostParam("userId"); + if(!isset($domId) || !isset($roleId) || !isset($userId)){ + + } + try{ + + $domain = $this->libClass->getDomain($domId); + + $domain->grantUserRole([ + 'userId' => $userId, + 'roleId' => $roleId, + ]); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } /** @@ -444,8 +493,35 @@ class identity implements Core{ * @return void */ $domains["checkRoleDomainUser"] = function(){ + $domId = $this->app->getPostParam("domainId"); + $roleId = $this->app->getPostParam("roleId"); + $userId = $this->app->getPostParam("userId"); - + if(!isset($domId) || !isset($roleId) || !isset($userId)){ + + } + + try{ + + $domain = $this->libClass->getDomain($domId); + + $result = $domain->checkUserRole(['userId' => $userId, 'roleId' => $roleId]); + + /*if (true === $result) { + // It exists! + }*/ + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } /** @@ -456,8 +532,34 @@ class identity implements Core{ * @return void */ $domains["revokeRoleDomainUser"] = function(){ + $domId = $this->app->getPostParam("domainId"); + $roleId = $this->app->getPostParam("roleId"); + $userId = $this->app->getPostParam("userId"); + if(!isset($domId) || !isset($roleId) || !isset($userId)){ + + } + try{ + + $domain = $this->libClass->getDomain($domId); + + $domain->revokeUserRole([ + 'userId' => $userId, + 'roleId' => $roleId, + ]); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } /** @@ -468,8 +570,31 @@ class identity implements Core{ * @return void */ $domains["listRolesDomainGroup"] = function(){ + $domId = $this->app->getPostParam("domainId"); + $groupId = $this->app->getPostParam("groupId"); - + if(!isset($domId) || !isset($groupId)){ + + } + + + try{ + + $domain = $this->libClass->getDomain($domId); + + $domain->listGroupRoles(['groupId' => $groupId]); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } /** @@ -480,8 +605,34 @@ class identity implements Core{ * @return void */ $domains["grantRoleDomainGroup"] = function(){ + $domId = $this->app->getPostParam("domainId"); + $groupId = $this->app->getPostParam("groupId"); + $roleId = $this->app->getPostParam("roleId"); - + if(!isset($domId) || !isset($groupId) || !isset($roleId)){ + + } + + try{ + + $domain = $this->libClass->getDomain($domId); + + $domain->grantGroupRole([ + 'groupId' => $groupId, + 'roleId' => $roleId, + ]); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } /** @@ -492,8 +643,35 @@ class identity implements Core{ * @return void */ $domains["checkRoleDomainGroup"] = function(){ + $domId = $this->app->getPostParam("domainId"); + $groupId = $this->app->getPostParam("groupId"); + $roleId = $this->app->getPostParam("roleId"); - + if(!isset($domId) || !isset($groupId) || !isset($roleId)){ + + } + + try{ + + $domain = $this->libClass->getDomain($domId); + + $result = $domain->checkGroupRole(['groupId' => $groupId, 'roleId' => $roleId]); + + /*if (true === $result) { + // It exists! + }*/ + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } /** @@ -510,8 +688,35 @@ class identity implements Core{ * @return void */ $domains["revokeRoleDomainGroup"] = function(){ + $domId = $this->app->getPostParam("domainId"); + $groupId = $this->app->getPostParam("groupId"); + $roleId = $this->app->getPostParam("roleId"); + if(!isset($domId) || !isset($groupId) || !isset($roleId)){ + + } + try{ + + $domain = $this->libClass->getDomain($roleId); + + $domain->revokeGroupRole([ + 'groupId' => $groupId, + 'roleId' => $roleId, + ]); + + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } $endpoints = array(); @@ -524,8 +729,36 @@ class identity implements Core{ * @return void */ $endpoints["addEndpoint"] = function(){ + $servId = $this->app->getPostParam("serviceId"); + $name = $this->app->getPostParam("name"); + $region = $this->app->getPostParam("region"); + $url = $this->app->getPostParam("url"); + if(!isset($servId) || !isset($name) || !isset($region) || !isset($url)){ + + } + try{ + + $endpoint = $this->libClass->createEndpoint([ + 'interface' => \OpenStack\Identity\v3\Enum::INTERFACE_INTERNAL, + 'name' => $name, + 'region' => $region, + 'url' => $url, + 'serviceId' => $servId + ]); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } /** @@ -537,19 +770,51 @@ class identity implements Core{ */ $endpoints["getEndpoint"] = function(){ + $endId = $this->app->getPostParam("endpointId"); + + if(!isset($endId)){ + + } + try{ + + $endpoint = $this->libClass->getEndpoint($endId); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } /** * Retrieve the list of the different endpoints * - * @throws [Type] [] - * * @return void */ $endpoints["listEndpoints"] = function(){ - - + + try{ + + $res = $this->libClass->listEndpoints(); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } /** @@ -560,8 +825,35 @@ class identity implements Core{ * @return void */ $endpoints["updateEndpoint"] = function(){ + //Not Implemented Yet + /*$domId = $this->app->getPostParam("domainId"); + $groupId = $this->app->getPostParam("groupId"); + if(!isset($domId) || !isset($groupId)){ + + } + + //TODO PARAMETERS + try{ + + $endpoint = $this->libClass->getEndpoint('{endpointId}'); + + $endpoint->interface = \OpenStack\Identity\v3\Enum::INTERFACE_PUBLIC; + + $endpoint->update(); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + }*/ } /** @@ -572,8 +864,28 @@ class identity implements Core{ * @return void */ $endpoints["deleteEndpoint"] = function(){ + $endId = $this->app->getPostParam("endpointId"); + if(!isset($endId)){ + + } + try{ + + $endpoint = $this->libClass->getEndpoint($endId); + $endpoint->delete(); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } $groups = array(); @@ -586,10 +898,31 @@ class identity implements Core{ * @return void */ $groups["addGroup"] = function(){ + //Not Implemented Yet + /*$domId = $this->app->getPostParam("domainId"); + $groupId = $this->app->getPostParam("groupId"); - } - + if(!isset($domId) || !isset($groupId)){ + + } + try{ + + $this->libClass->listCredentials() + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + }*/ + } + /** * Retrieve the group's list. * @@ -598,8 +931,29 @@ class identity implements Core{ * @return void */ $groups["listGroups"] = function(){ + //Not Implemented Yet + /* + $domId = $this->app->getPostParam("domainId"); + $groupId = $this->app->getPostParam("groupId"); - + if(!isset($domId) || !isset($groupId)){ + + } + try{ + + $this->libClass->listCredentials() + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + }*/ } /** @@ -610,8 +964,30 @@ class identity implements Core{ * @return void */ $groups["showGroup"] = function(){ + //Not Implemented Yet + /* + $domId = $this->app->getPostParam("domainId"); + $groupId = $this->app->getPostParam("groupId"); + if(!isset($domId) || !isset($groupId)){ + + } + try{ + + $this->libClass->listCredentials() + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + }*/ } /** @@ -622,8 +998,37 @@ class identity implements Core{ * @return void */ $groups["updateGroup"] = function(){ + //Todo Argument Optional + $groupId = $this->app->getPostParam("groupId"); + $description = $this->app->getPostParam("description"); + $name = $this->app->getPostParam("name"); + if(!isset($groupId)){ + + } + try{ + + $group = $this->libClass->getGroup($groupId); + + if(isset($description)) + $group->description = 'foo'; + if(isset($name)) + $group->name = 'bar'; + + $group->update(); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } /** @@ -635,7 +1040,29 @@ class identity implements Core{ */ $groups["deleteGroup"] = function(){ + $groupId = $this->app->getPostParam("groupId"); + + if(!isset($groupId)){ + + } + try{ + + $group = $this->libClass->getGroup($groupId); + + $group->delete(); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } /** @@ -647,7 +1074,29 @@ class identity implements Core{ */ $groups["listGroupUsers"] = function(){ + $groupId = $this->app->getPostParam("groupId"); + if(!isset($groupId)){ + + } + + try{ + + $group = $this->libClass->getGroup($groupId); + + $users = $group->listUsers(); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } /** @@ -659,7 +1108,30 @@ class identity implements Core{ */ $groups["addGroupUser"] = function(){ + $userId = $this->app->getPostParam("userId"); + $groupId = $this->app->getPostParam("groupId"); + if(!isset($userId) || !isset($groupId)){ + + } + + try{ + + $group = $this->libClass->getGroup($groupId); + + $group->addUser(['userId' => $userId]); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } /** @@ -671,7 +1143,30 @@ class identity implements Core{ */ $groups["removeGroupUser"] = function(){ + $userId = $this->app->getPostParam("userId"); + $groupId = $this->app->getPostParam("groupId"); + + if(!isset($userId) || !isset($groupId)){ + + } + try{ + + $group = $this->libClass->getGroup($groupId); + + $group->removeUser(['userId' => $userId]); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } /** @@ -683,7 +1178,30 @@ class identity implements Core{ */ $groups["checkGroupUser"] = function(){ + $userId = $this->app->getPostParam("userId"); + $groupId = $this->app->getPostParam("groupId"); + + if(!isset($userId) || !isset($groupId)){ + + } + try{ + + $group = $this->libClass->getGroup($groupId); + + $result = $group->checkMembership(['userId' => $userId]); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } $policies = array(); @@ -696,8 +1214,29 @@ class identity implements Core{ * @return void */ $policies["addPolicies"] = function(){ + //Not Implemented Yet + /* + $domId = $this->app->getPostParam("domainId"); + $groupId = $this->app->getPostParam("groupId"); - + if(!isset($domId) || !isset($groupId)){ + + } + try{ + + $this->libClass->listCredentials() + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + }*/ } /** @@ -708,8 +1247,29 @@ class identity implements Core{ * @return void */ $policies["listPolicies"] = function(){ + //Not Implemented Yet + /* + $domId = $this->app->getPostParam("domainId"); + $groupId = $this->app->getPostParam("groupId"); - + if(!isset($domId) || !isset($groupId)){ + + } + try{ + + $this->libClass->listCredentials() + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + }*/ } /** @@ -720,7 +1280,29 @@ class identity implements Core{ * @return void */ $policies["showPolicie"] = function(){ + //Not Implemented Yet + /* + $domId = $this->app->getPostParam("domainId"); + $groupId = $this->app->getPostParam("groupId"); + if(!isset($domId) || !isset($groupId)){ + + } + try{ + + $this->libClass->listCredentials() + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + }*/ } @@ -732,8 +1314,29 @@ class identity implements Core{ * @return void */ $policies["updatePolicies"] = function(){ + //Not Implemented Yet + /* + $domId = $this->app->getPostParam("domainId"); + $groupId = $this->app->getPostParam("groupId"); - + if(!isset($domId) || !isset($groupId)){ + + } + try{ + + $this->libClass->listCredentials() + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + }*/ } /** @@ -744,8 +1347,29 @@ class identity implements Core{ * @return void */ $policies["deletePolicies"] = function(){ + //Not Implemented Yet + /* + $domId = $this->app->getPostParam("domainId"); + $groupId = $this->app->getPostParam("groupId"); - + if(!isset($domId) || !isset($groupId)){ + + } + try{ + + $this->libClass->listCredentials() + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + }*/ } $projects = array(); @@ -758,20 +1382,57 @@ class identity implements Core{ * @return void */ $projects["addProject"] = function(){ + //Todo Parameters Optional + $description = $this->app->getPostParam("description"); + $name = $this->app->getPostParam("name"); + if(!isset($name) || !isset($description)){ + + } + try{ + + $project = $this->libClass->createProject([ + 'description' => $description, + 'enabled' => true, + 'name' => $name + ]); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } /** * Retrieve the different projects. * - * @throws [Type] [] - * * @return void */ $projects["listProjects"] = function(){ - + try{ + + $projects = $this->libClass->listProjects(); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } /** @@ -783,7 +1444,28 @@ class identity implements Core{ */ $projects["showProject"] = function(){ + $projId = $this->app->getPostParam("projetId"); + if(!isset($projId)){ + + } + + try{ + + $project = $this->libClass->getProject($projId); + $project->retrieve(); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } /** @@ -794,8 +1476,36 @@ class identity implements Core{ * @return void */ $projects["updateProject"] = function(){ + //Todo Parameters Optionnal + $description = $this->app->getPostParam("description"); + $name = $this->app->getPostParam("name"); + $projId = $this->app->getPostParam("projetId"); + if(!isset($projId) || !isset($name) || !isset($description)){ + + } + try{ + + $project = $this->libClass->getProject($projId); + + $project->enabled = false; + $project->description = $description; + $project->name = $name; + + $project->update(); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } /** @@ -806,8 +1516,29 @@ class identity implements Core{ * @return void */ $projects["deleteProject"] = function(){ + $projId = $this->app->getPostParam("projId"); - + if(!isset($projId)){ + + } + + try{ + + $project = $this->libClass->getProject($projId); + + $project->delete(); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } /** @@ -819,7 +1550,30 @@ class identity implements Core{ */ $projects["listRolesProjectUser"] = function(){ + $projId = $this->app->getPostParam("projetId"); + $userId = $this->app->getPostParam("userId"); + if(!isset($projId) || !isset($userId)){ + + } + + try{ + + $project = $this->libClass->getProject($projId); + + $project->listUserRoles(['userId' => $userId]); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } /** @@ -831,7 +1585,34 @@ class identity implements Core{ */ $projects["grantRoleProjectUser"] = function(){ + $projId = $this->app->getPostParam("projId"); + $userId = $this->app->getPostParam("userId"); + $roleId = $this->app->getPostParam("roleId"); + if(!isset($projId) || !isset($userId) || !isset($roleId)){ + + } + + try{ + + $project = $this->libClass->getProject($projId); + + $project->grantUserRole([ + 'userId' => $userId, + 'roleId' => $roleId, + ]); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } /** @@ -842,8 +1623,37 @@ class identity implements Core{ * @return void */ $projects["checkRoleProjectUser"] = function(){ + $projId = $this->app->getPostParam("projetId"); + $userId = $this->app->getPostParam("userId"); + $roleId = $this->app->getPostParam("roleId"); + if(!isset($projId) || !isset($userId) || !isset($roleId)){ + + } + try{ + + $project = $this->libClass->getProject($projId); + + $result = $project->checkUserRole([ + 'userId' => $userId, + 'roleId' => $roleId, + ]); + + /*if (true === $result) { + }*/ + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } /** @@ -855,7 +1665,34 @@ class identity implements Core{ */ $projects["revokeRoleProjectUser"] = function(){ + $projId = $this->app->getPostParam("projetId"); + $userId = $this->app->getPostParam("userId"); + $roleId = $this->app->getPostParam("roleId"); + + if(!isset($projId) || !isset($userId) || !isset($roleId)){ + + } + try{ + + $project = $this->libClass->getProject($projId); + + $project->revokeUserRole([ + 'userId' => $userId, + 'roleId' => $roleId, + ]); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } /** @@ -866,8 +1703,32 @@ class identity implements Core{ * @return void */ $projects["listRolesProjectGroup"] = function(){ + + $projId = $this->app->getPostParam("projetId"); + $groupId = $this->app->getPostParam("groupId"); + + + if(!isset($projId) || !isset($groupId)){ + + } - + try{ + + $project = $this->libClass->getProject($projId); + + $project->listGroupRoles(['groupId' => $groupId]); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } /** @@ -878,8 +1739,35 @@ class identity implements Core{ * @return void */ $projects["grantRoleProjectGroup"] = function(){ + + $projId = $this->app->getPostParam("projetId"); + $userId = $this->app->getPostParam("userId"); + $roleId = $this->app->getPostParam("roleId"); + + if(!isset($projId) || !isset($userId) || !isset($roleId)){ + + } - + try{ + + $project = $this->libClass->getProject($projId); + + $project->grantUserRole([ + 'userId' => $userId, + 'roleId' => $roleId, + ]); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } /** @@ -891,7 +1779,36 @@ class identity implements Core{ */ $projects["checkRoleProjectGroup"] = function(){ + $projId = $this->app->getPostParam("projetId"); + $userId = $this->app->getPostParam("userId"); + $roleId = $this->app->getPostParam("roleId"); + if(!isset($projId) || !isset($userId) || !isset($roleId)){ + + } + + try{ + + $project = $this->libClass->getProject($projId); + + $result = $project->checkGroupRole([ + 'groupId' => $groupId, + 'roleId' => $roleId, + ]); + + /*if (true === $result) { + }*/ + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } /** @@ -903,7 +1820,34 @@ class identity implements Core{ */ $projects["revokeRoleProjectGroup"] = function(){ + $projId = $this->app->getPostParam("projetId"); + $userId = $this->app->getPostParam("userId"); + $roleId = $this->app->getPostParam("roleId"); + + if(!isset($projId) || !isset($userId) || !isset($roleId)){ + + } + try{ + + $project = $this->libClass->getProject($projId); + + $project->revokeGroupRole([ + 'groupId' => $groupId, + 'roleId' => $roleId, + ]); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } $roles = array(); @@ -917,31 +1861,77 @@ class identity implements Core{ */ $roles["addRole"] = function(){ + $name = $this->app->getPostParam("name"); + if(!isset($name)){ + + } + + try{ + + $role = $this->libClass->createRole([ + 'name' => $name, + ]); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } /** * List the different roles * - * @throws [Type] [] - * * @return void */ $roles["listRoles"] = function(){ - - + + try{ + + $roles = $this->libClass->listRoles(); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } /** * @todo * - * @throws [Type] [] - * * @return void */ $roles["listRoleAssignements"] = function(){ - + try{ + + $assignements = $this->libClass->listRoleAssignments(); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } $services = array(); @@ -954,20 +1944,55 @@ class identity implements Core{ * @return void */ $services["addService"] = function(){ + $name = $this->app->getPostParam("name"); + $type = $this->app->getPostParam("type"); + if(!isset($name) || !isset($type)){ + + } + try{ + + $service = $this->libClass->createService([ + 'name' => $name, + 'type' => $type, + ]); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } /** * Retrieve the different services. * - * @throws [Type] [] - * * @return void */ $services["listServices"] = function(){ - + try{ + + $services = $this->libClass->listServices(); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } /** @@ -978,8 +2003,27 @@ class identity implements Core{ * @return void */ $services["showService"] = function(){ + $servId = $this->app->getPostParam("serviceId"); + if(!isset($servId)){ + + } + try{ + + $service = $this->libClass->getService($servId); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } /** @@ -991,7 +2035,29 @@ class identity implements Core{ */ $services["deleteService"] = function(){ + $servId = $this->app->getPostParam("serviceId"); + $groupId = $this->app->getPostParam("groupId"); + if(!isset($servId) || !isset($groupId)){ + + } + + try{ + + $service = $this->libClass->getService($servId); + $service->delete(); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } $tokens = array(); @@ -1005,7 +2071,33 @@ class identity implements Core{ */ $tokens["genTokenUserID"] = function(){ + $userId = $this->app->getPostParam("userId"); + $userPass = $this->app->getPostParam("userPassword"); + + if(!isset($userId) || !isset($userPass)){ + + } + try{ + + $token = $this->libClass->generateToken([ + 'user' => [ + 'id' => $userId, + 'password' => $userPass + ] + ]); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } /** @@ -1016,8 +2108,38 @@ class identity implements Core{ * @return void */ $tokens["genTokenUserName"] = function(){ + $username = $this->app->getPostParam("username"); + $userPass = $this->app->getPostParam("userPassword"); + $domId = $this->app->getPostParam("domainId"); + + if(!isset($userId) || !isset($userPass) || !isset($domId)){ + + } + try{ + + $token = $this->libClass->generateToken([ + 'user' => [ + 'name' => $username, + 'password' => $userPass, + 'domain' => [ + 'id' => $domId + ] + ] + ]); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } /** @@ -1029,7 +2151,31 @@ class identity implements Core{ */ $tokens["geneTokenID"] = function(){ + $tokenId = $this->app->getPostParam("tokenId"); + $projectId = $this->app->getPostParam("projectId"); + + if(!isset($tokenId) || !isset($projectId)){ + + } + try{ + + $token = $this->libClass->generateToken([ + 'tokenId' => $tokenId, + 'scope' => ['project' => ['id' => $projectId]] + ]); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } /** @@ -1041,7 +2187,37 @@ class identity implements Core{ */ $tokens["genTokenScopedProjectID"] = function(){ + $userId = $this->app->getPostParam("userId"); + $userPass = $this->app->getPostParam("userPass"); + $projId = $this->app->getPostParam("projetId"); + + if(!isset($userId) || !isset($projId) || !isset($userPass)){ + + } + try{ + + $token = $this->libClass->generateToken([ + 'user' => [ + 'id' => $userId, + 'password' => $userPass + ], + 'scope' => [ + 'project' => ['id' => $projId] + ] + ]); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } /** @@ -1053,7 +2229,43 @@ class identity implements Core{ */ $tokens["genTokenScopedProjectName"] = function(){ + $userId = $this->app->getPostParam("userId"); + $userPass = $this->app->getPostParam("userPass"); + $projName = $this->app->getPostParam("projetName"); + $domId = $this->app->getPostParam("domId"); + if(!isset($userId) || !isset($projName) || !isset($userPass) || !isset($domId)){ + + } + + try{ + + $token = $this->libClass->generateToken([ + 'user' => [ + 'id' => $userId, + 'password' => $userPass + ], + 'scope' => [ + 'project' => [ + 'name' => $projName, + 'domain' => [ + 'id' => $domId + ] + ] + ] + ]); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } /** @@ -1065,7 +2277,31 @@ class identity implements Core{ */ $tokens["validateToken"] = function(){ + $tokenId = $this->app->getPostParam("tokenId"); + if(!isset($tokenId)){ + + } + + try{ + + $result = $this->libClass->validateToken($tokenId); + + /*if (true === $result) { + // It's valid! + }*/ + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } /** @@ -1077,7 +2313,27 @@ class identity implements Core{ */ $tokens["revokeToken"] = function(){ + $tokenId = $this->app->getPostParam("tokenId"); + + if(!isset($tokenId)){ + + } + try{ + + $this->libClass->revokeToken($tokenId); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } $users = array(); @@ -1090,20 +2346,65 @@ class identity implements Core{ * @return void */ $users["addUser"] = function(){ + //Todo Optionnal Parameter + $projId = $this->app->getPostParam("projId"); + $desc = $this->app->getPostParam("description"); + $email = $this->app->getPostParam("email"); + $name = $this->app->getPostParam("name"); + $pass = $this->app->getPostParam("pass"); + $domId = $this->app->getPostParam("domId"); + if(!isset($domId) || !isset($groupId)){ + } + + try{ + + $user = $this->libClass->createUser([ + 'defaultProjectId' => $projId, + 'description' => $desc, + 'domainId' => $domId, + 'email' => $email, + 'enabled' => true, + 'name' => $name, + 'password' => $pass + ]); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } /** * Retrieve the different users. * - * @throws [Type] [] - * * @return void */ $users["listUsers"] = function(){ - + try{ + + $users = $this->libClass->listUsers(); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } /** @@ -1115,7 +2416,28 @@ class identity implements Core{ */ $users["showUser"] = function(){ + $userId = $this->app->getPostParam("userId"); + + if(!isset($userId)){ + + } + try{ + + $user = $this->libClass->getUser($userId); + $user->retrieve(); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } /** @@ -1127,7 +2449,34 @@ class identity implements Core{ */ $users["updateUser"] = function(){ + $userId = $this->app->getPostParam("userId"); + $desc = $this->app->getPostParam("description"); + $name = $this->app->getPostParam("name"); + + if(!isset($userId) || !isset($desc) || !isset($name)){ + + } + try{ + + $user = $this->libClass->getUser($userId); + + $user->description = $desc; + $user->name = $name; + + $user->update(); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } /** @@ -1139,7 +2488,28 @@ class identity implements Core{ */ $users["deleteUser"] = function(){ + $userId = $this->app->getPostParam("userId"); + + if(!isset($userId)){ + + } + try{ + + $user = $this->libClass->getUser($userId); + $user->delete(); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } /** @@ -1151,7 +2521,29 @@ class identity implements Core{ */ $users["listUserGroups"] = function(){ + $userId = $this->app->getPostParam("userId"); + if(!isset($userId)){ + + } + + try{ + + $user = $this->libClass->getUser($userId); + + $groups = $user->listGroups(); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } /** @@ -1163,7 +2555,29 @@ class identity implements Core{ */ $users["listUserProjects"] = function(){ + $userId = $this->app->getPostParam("userId"); + + if(!isset($userId)){ + + } + try{ + + $user = $this->libClass->getUser($userId); + + $projects = $user->listProjects(); + + //TODO parse answer + + }catch(BadResponseError $e){ + $this->app->getErrorInstance->BadResponseHandler($e); + }catch(UserInputError $e){ + $this->app->getErrorInstance->UserInputHandler($e); + }catch(BaseError $e){ + $this->app->getErrorInstance->BaseErrorHandler($e); + }catch(NotImplementedError $e){ + $this->app->getErrorInstance->NotImplementedHandler($e); + } } $actions["Credentials"] = $credentials; -- cgit v1.2.3 From 7e5db6b5420755a76c1efcd87bf2a61b111b4c09 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Wed, 17 Feb 2016 14:01:13 +0100 Subject: Use angular-cookirs --- client/index.html | 3 +- client/js/app.js | 3 +- client/js/controllers/.#status.js | 1 + client/js/controllers/login.js | 16 +++-- client/js/controllers/status.js | 11 ++- client/js/services/Identity.js | 77 +++++++++++++++++++-- client/js/services/Image.js | 21 +++--- client/partials/login.html | 2 +- client/partials/nav.html | 3 +- client/vendors/angularjs/angular-cookies.min.js | 9 +++ server/Test/genTokenOptionsTest.php | 0 server/composer.phar | Bin server/core/App.php | 0 server/core/CoreInterface.php | 0 server/core/Identity.php | 0 server/core/LibOverride/genTokenOptions.php | 0 server/index.php | 0 server/init.php | 0 .../justinrainbow/json-schema/bin/validate-json | 0 19 files changed, 119 insertions(+), 27 deletions(-) create mode 120000 client/js/controllers/.#status.js create mode 100644 client/vendors/angularjs/angular-cookies.min.js mode change 100755 => 100644 server/Test/genTokenOptionsTest.php mode change 100755 => 100644 server/composer.phar mode change 100755 => 100644 server/core/App.php mode change 100755 => 100644 server/core/CoreInterface.php mode change 100755 => 100644 server/core/Identity.php mode change 100755 => 100644 server/core/LibOverride/genTokenOptions.php mode change 100755 => 100644 server/index.php mode change 100755 => 100644 server/init.php mode change 100755 => 100644 server/vendor/justinrainbow/json-schema/bin/validate-json (limited to 'server') diff --git a/client/index.html b/client/index.html index ab5f00f..26430f9 100644 --- a/client/index.html +++ b/client/index.html @@ -61,7 +61,7 @@ - + @@ -69,6 +69,7 @@ + diff --git a/client/js/app.js b/client/js/app.js index 90fae89..e2d5b9b 100644 --- a/client/js/app.js +++ b/client/js/app.js @@ -3,7 +3,7 @@ * The main app module instance * @type angular.module.angular-1_3_6_L1749.moduleInstance */ -var mainApp=angular.module("mainApp",['ngRoute', 'ngSanitize']); +var mainApp=angular.module("mainApp",['ngRoute', 'ngSanitize', 'ngCookies']); /** * Configure routeProvider @@ -29,6 +29,5 @@ mainApp.config(['$routeProvider', function($routeProvider){ */ mainApp.config(['$httpProvider', function($httpProvider){ $httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8'; - }]); diff --git a/client/js/controllers/.#status.js b/client/js/controllers/.#status.js new file mode 120000 index 0000000..e6c258f --- /dev/null +++ b/client/js/controllers/.#status.js @@ -0,0 +1 @@ +loic@Manzerbredes.home.30343:1455008378 \ No newline at end of file diff --git a/client/js/controllers/login.js b/client/js/controllers/login.js index 6358a6d..829fc1d 100644 --- a/client/js/controllers/login.js +++ b/client/js/controllers/login.js @@ -9,14 +9,20 @@ */ mainApp.controller('loginCtrl', ['$scope','$sce','Identity', function ($scope,$sce, Identity) { - // Define default states - $('#loginModal').modal({backdrop: 'static', keyboard: false}); + // Check for login and define default states + if(!Identity.isAlreadyLogin()){ + $('#loginModal').modal({backdrop: 'static', keyboard: false}); + } + $scope.$on('logoutEvent', function(){ + $('#loginModal').modal({backdrop: 'static', keyboard: false}); + }); + $('#loadingLoginButton').hide(); $('#failedToLoginAlert').hide(); - $('#loginButton').click(function(){ - + $scope.loginAction=function(){ + // Begin login state for template $('#loginButton').hide(); $('#loadingLoginButton').show(); @@ -49,6 +55,6 @@ mainApp.controller('loginCtrl', ['$scope','$sce','Identity', function ($scope,$s // Try to login Identity.login(username, password, projectname, responseCallback); - }); + }; }]); diff --git a/client/js/controllers/status.js b/client/js/controllers/status.js index 2930e34..6bc602a 100644 --- a/client/js/controllers/status.js +++ b/client/js/controllers/status.js @@ -6,9 +6,14 @@ * @param {$scope} $scope The $scope service from angular * @param {Identity} The Identity service */ -mainApp.controller('statusCtrl', ['$scope','Identity', function ($scope, Identity) +mainApp.controller('statusCtrl', ['$scope','Identity', '$rootScope', function ($scope, Identity, $rootScope) { $scope.profile=Identity.profile; - - + + $scope.logout=function(){ + Identity.logout(); + $rootScope.$broadcast('logoutEvent'); + + }; + }]); diff --git a/client/js/services/Identity.js b/client/js/services/Identity.js index 4c8919c..d96b3ab 100644 --- a/client/js/services/Identity.js +++ b/client/js/services/Identity.js @@ -1,5 +1,5 @@ -mainApp.factory('Identity',[ '$http', function($http){ +mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){ /* Create profile structure to store informations * about current session @@ -9,7 +9,72 @@ mainApp.factory('Identity',[ '$http', function($http){ profile.projectname=null; profile.token=null; +/* var tokenFragment=9; + + var saveTokenInCookies=function(){ + var i=0; + var currentStart=0; + var currentEnd=parseInt(profile.token.length/tokenFragment); + var facto=currentEnd; + + alert("current ren" + currentEnd); + for(i=0;iClose--> - Login + Login diff --git a/client/partials/nav.html b/client/partials/nav.html index 7c34174..3c72844 100644 --- a/client/partials/nav.html +++ b/client/partials/nav.html @@ -32,8 +32,7 @@
  • Informations
  • Settings
  • -
  • Logout -
  • +
  • Logout
  • diff --git a/client/vendors/angularjs/angular-cookies.min.js b/client/vendors/angularjs/angular-cookies.min.js new file mode 100644 index 0000000..d0f126a --- /dev/null +++ b/client/vendors/angularjs/angular-cookies.min.js @@ -0,0 +1,9 @@ +/* + AngularJS v1.5.0 + (c) 2010-2016 Google, Inc. http://angularjs.org + License: MIT +*/ +(function(p,c,n){'use strict';function l(b,a,g){var d=g.baseHref(),k=b[0];return function(b,e,f){var g,h;f=f||{};h=f.expires;g=c.isDefined(f.path)?f.path:d;c.isUndefined(e)&&(h="Thu, 01 Jan 1970 00:00:00 GMT",e="");c.isString(h)&&(h=new Date(h));e=encodeURIComponent(b)+"="+encodeURIComponent(e);e=e+(g?";path="+g:"")+(f.domain?";domain="+f.domain:"");e+=h?";expires="+h.toUTCString():"";e+=f.secure?";secure":"";f=e.length+1;4096 4096 bytes)!");k.cookie=e}}c.module("ngCookies",["ng"]).provider("$cookies",[function(){var b=this.defaults={};this.$get=["$$cookieReader","$$cookieWriter",function(a,g){return{get:function(d){return a()[d]},getObject:function(d){return(d=this.get(d))?c.fromJson(d):d},getAll:function(){return a()},put:function(d,a,m){g(d,a,m?c.extend({},b,m):b)},putObject:function(d,b,a){this.put(d,c.toJson(b),a)},remove:function(a,k){g(a,n,k?c.extend({},b,k):b)}}}]}]);c.module("ngCookies").factory("$cookieStore", +["$cookies",function(b){return{get:function(a){return b.getObject(a)},put:function(a,c){b.putObject(a,c)},remove:function(a){b.remove(a)}}}]);l.$inject=["$document","$log","$browser"];c.module("ngCookies").provider("$$cookieWriter",function(){this.$get=l})})(window,window.angular); +//# sourceMappingURL=angular-cookies.min.js.map diff --git a/server/Test/genTokenOptionsTest.php b/server/Test/genTokenOptionsTest.php old mode 100755 new mode 100644 diff --git a/server/composer.phar b/server/composer.phar old mode 100755 new mode 100644 diff --git a/server/core/App.php b/server/core/App.php old mode 100755 new mode 100644 diff --git a/server/core/CoreInterface.php b/server/core/CoreInterface.php old mode 100755 new mode 100644 diff --git a/server/core/Identity.php b/server/core/Identity.php old mode 100755 new mode 100644 diff --git a/server/core/LibOverride/genTokenOptions.php b/server/core/LibOverride/genTokenOptions.php old mode 100755 new mode 100644 diff --git a/server/index.php b/server/index.php old mode 100755 new mode 100644 diff --git a/server/init.php b/server/init.php old mode 100755 new mode 100644 diff --git a/server/vendor/justinrainbow/json-schema/bin/validate-json b/server/vendor/justinrainbow/json-schema/bin/validate-json old mode 100755 new mode 100644 -- cgit v1.2.3 From 47e7d7d5402b3096a7554193eec10ff4b8bb2c3b Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Wed, 17 Feb 2016 14:03:21 +0100 Subject: Update --- server/vendor/php-opencloud/openstack | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'server') diff --git a/server/vendor/php-opencloud/openstack b/server/vendor/php-opencloud/openstack index 1419eb2..15aca73 160000 --- a/server/vendor/php-opencloud/openstack +++ b/server/vendor/php-opencloud/openstack @@ -1 +1 @@ -Subproject commit 1419eb2e01164bb6b8b837df37724423907352d7 +Subproject commit 15aca73f423166c7ef8337ba08615c103c66e931 -- cgit v1.2.3 From a8b6e051b4a4346ec4b22e07207f8dc766833c9b Mon Sep 17 00:00:00 2001 From: EoleDev Date: Wed, 17 Feb 2016 16:53:06 +0100 Subject: Token management reviewed --- server/core/LibOverride/genTokenOptions.php | 115 ++++++++++++++------------ server/core/LibOverride/projectTokenData/demo | 1 + 2 files changed, 65 insertions(+), 51 deletions(-) create mode 100644 server/core/LibOverride/projectTokenData/demo (limited to 'server') diff --git a/server/core/LibOverride/genTokenOptions.php b/server/core/LibOverride/genTokenOptions.php index 58b87c1..b71defa 100755 --- a/server/core/LibOverride/genTokenOptions.php +++ b/server/core/LibOverride/genTokenOptions.php @@ -70,7 +70,7 @@ class genTokenOptions 'base_uri' => Utils::normalizeUrl($baseUrl), 'handler' => $stack, ]); - $this->backup['Identity'] = array('token' => $this->serializeToken($token), 'baseUrl' => $baseUrl ); + $this->saveBackup('Identity', array('token' => $token, 'baseUrl' => $baseUrl )); $this->optionsGlobal['Identity'] = $options; } @@ -95,7 +95,7 @@ class genTokenOptions 'base_uri' => Utils::normalizeUrl($baseUrl), 'handler' => $stack, ]); - $this->backup['Identity'] = array('token' => $this->serializeToken($token), 'baseUrl' => $baseUrl ); + $this->saveBackup('Identity', array('token' => $token, 'baseUrl' => $baseUrl )); $this->optionsGlobal['Identity'] = $options; } @@ -118,7 +118,7 @@ class genTokenOptions 'base_uri' => Utils::normalizeUrl($baseUrl), 'handler' => $stack, ]); - $this->backup['Image'] = array('token' => $this->serializeToken($token), 'baseUrl' => $baseUrl ); + $this->saveBackup('Image', array('token' => $token, 'baseUrl' => $baseUrl )); $this->optionsGlobal['Image'] = $options; } @@ -143,7 +143,7 @@ class genTokenOptions 'base_uri' => Utils::normalizeUrl($baseUrl), 'handler' => $stack, ]); - $this->backup['Image'] = array('token' => $this->serializeToken($token), 'baseUrl' => $baseUrl ); + $this->saveBackup('Image', array('token' => $token, 'baseUrl' => $baseUrl )); $this->optionsGlobal['Image'] = $options; } @@ -165,7 +165,7 @@ class genTokenOptions 'base_uri' => Utils::normalizeUrl($baseUrl), 'handler' => $stack, ]); - $this->backup['Network'] = array('token' => $this->serializeToken($token), 'baseUrl' => $baseUrl ); + $this->saveBackup('Network', array('token' => $token, 'baseUrl' => $baseUrl )); $this->optionsGlobal['Network'] = $options; } @@ -190,7 +190,7 @@ class genTokenOptions 'base_uri' => Utils::normalizeUrl($baseUrl), 'handler' => $stack, ]); - $this->backup['Network'] = array('token' => $this->serializeToken($token), 'baseUrl' => $baseUrl ); + $this->saveBackup('Network', array('token' => $token, 'baseUrl' => $baseUrl )); $this->optionsGlobal['Network'] = $options; } @@ -212,7 +212,7 @@ class genTokenOptions 'base_uri' => Utils::normalizeUrl($baseUrl), 'handler' => $stack, ]); - $this->backup['Compute'] = array('token' => $this->serializeToken($token), 'baseUrl' => $baseUrl ); + $this->saveBackup('Compute', array('token' => $token, 'baseUrl' => $baseUrl )); $this->optionsGlobal['Compute'] = $options; } @@ -238,10 +238,21 @@ class genTokenOptions 'base_uri' => Utils::normalizeUrl($baseUrl), 'handler' => $stack, ]); - $this->backup['Compute'] = array('token' => $this->serializeToken($token), 'baseUrl' => $baseUrl ); + $this->saveBackup('Compute', array('token' => $token, 'baseUrl' => $baseUrl )); $this->optionsGlobal['Compute'] = $options; } + private function saveBackup($name, $data){ + $token = $this->serializeToken($data["token"]); + $path = "core/LibOverride/projectTokenData/".$token['saved']["project"]["name"]; + error_log(print_r($path, true), 0); + file_put_contents("core/LibOverride/projectTokenData/".$token['saved']["project"]["name"], serialize($token['saved'])); + $this->backup["roles"] = $token["roles"]; + $this->backup["project"] = $token['saved']["project"]["name"]; + $this->backup["user"] = $token["user"]; + $this->backup[$name] = array('token' => $token["token"], 'baseUrl' => $data["baseUrl"] ); + } + public function getBackup(){ return serialize($this->backup); } @@ -249,6 +260,9 @@ class genTokenOptions public function loadBackup($back){ $backup = unserialize($back); + $this->backup["roles"] = $backup["roles"]; + $this->backup["project"] = $backup["project"]; + $this->backup["user"] = $backup["user"]; loadComputeBackup($backup["Compute"]); loadIdentityBackup($backup["Identity"]); loadImageBackup($backup["Image"]); @@ -262,7 +276,7 @@ class genTokenOptions private function serializeToken($token){ $tokenSerialized = []; - $tokenSerialized["methods"] = serialize($token->methods); + $tokenSerialized["token"]["methods"] = serialize($token->methods); $tokenSerialized["roles"] = []; foreach($token->roles as $role){ @@ -270,30 +284,30 @@ class genTokenOptions $tokenSerialized["roles"][serialize($role->id)]["name"] = serialize($role->name); } - $tokenSerialized["expires"] = serialize($token->expires); - $tokenSerialized["project"]["domainId"] = serialize($token->project->domainId); - $tokenSerialized["project"]["parentId"] = serialize($token->project->parentId); - $tokenSerialized["project"]["enabled"] = serialize($token->project->enabled); - $tokenSerialized["project"]["description"] = serialize($token->project->description); - $tokenSerialized["project"]["id"] = serialize($token->project->id); - $tokenSerialized["project"]["links"] = serialize($token->project->links); - $tokenSerialized["project"]["name"] = serialize($token->project->name); + $tokenSerialized["token"]["expires"] = serialize($token->expires); + $tokenSerialized['saved']["project"]["domainId"] = serialize($token->project->domainId); + $tokenSerialized['saved']["project"]["parentId"] = serialize($token->project->parentId); + $tokenSerialized['saved']["project"]["enabled"] = serialize($token->project->enabled); + $tokenSerialized['saved']["project"]["description"] = serialize($token->project->description); + $tokenSerialized['saved']["project"]["id"] = serialize($token->project->id); + $tokenSerialized['saved']["project"]["links"] = serialize($token->project->links); + $tokenSerialized['saved']["project"]["name"] = $token->project->name; foreach($token->catalog->services as $service){ - $tokenSerialized["catalog"][serialize($service->id)]["name"] = serialize($service->name); - $tokenSerialized["catalog"][serialize($service->id)]["description"] = serialize($service->description); - $tokenSerialized["catalog"][serialize($service->id)]["type"] = serialize($service->type); + $tokenSerialized['saved']["catalog"][serialize($service->id)]["name"] = serialize($service->name); + $tokenSerialized['saved']["catalog"][serialize($service->id)]["description"] = serialize($service->description); + $tokenSerialized['saved']["catalog"][serialize($service->id)]["type"] = serialize($service->type); foreach($service->endpoints as $end){ - $tokenSerialized["catalog"][serialize($service->id)]["endpoints"][serialize($end->id)]["interface"] = serialize($end->interface); - $tokenSerialized["catalog"][serialize($service->id)]["endpoints"][serialize($end->id)]["name"] = serialize($end->name); - $tokenSerialized["catalog"][serialize($service->id)]["endpoints"][serialize($end->id)]["serviceId"] = serialize($end->serviceId); - $tokenSerialized["catalog"][serialize($service->id)]["endpoints"][serialize($end->id)]["region"] = serialize($end->region); - $tokenSerialized["catalog"][serialize($service->id)]["endpoints"][serialize($end->id)]["links"] = serialize($end->links); - $tokenSerialized["catalog"][serialize($service->id)]["endpoints"][serialize($end->id)]["url"] = serialize($end->url); + $tokenSerialized['saved']["catalog"][serialize($service->id)]["endpoints"][serialize($end->id)]["interface"] = serialize($end->interface); + $tokenSerialized['saved']["catalog"][serialize($service->id)]["endpoints"][serialize($end->id)]["name"] = serialize($end->name); + $tokenSerialized['saved']["catalog"][serialize($service->id)]["endpoints"][serialize($end->id)]["serviceId"] = serialize($end->serviceId); + $tokenSerialized['saved']["catalog"][serialize($service->id)]["endpoints"][serialize($end->id)]["region"] = serialize($end->region); + $tokenSerialized['saved']["catalog"][serialize($service->id)]["endpoints"][serialize($end->id)]["links"] = serialize($end->links); + $tokenSerialized['saved']["catalog"][serialize($service->id)]["endpoints"][serialize($end->id)]["url"] = serialize($end->url); } - $tokenSerialized["roles"][serialize($service->id)]["links"] = serialize($service->links); + $tokenSerialized['saved']["catalog"][serialize($service->id)]["links"] = serialize($service->links); } - $tokenSerialized["extras"] = serialize($token->extras); + $tokenSerialized["token"]["extras"] = serialize($token->extras); $tokenSerialized["user"]["domainId"] = serialize($token->user->domainId); $tokenSerialized["user"]["defaultProjectId"] = serialize($token->user->defaultProjectId); $tokenSerialized["user"]["id"] = serialize($token->user->id); @@ -302,42 +316,42 @@ class genTokenOptions $tokenSerialized["user"]["description"] = serialize($token->user->description); $tokenSerialized["user"]["links"] = serialize($token->user->links); $tokenSerialized["user"]["name"] = serialize($token->user->name); - $tokenSerialized["issued"] = serialize($token->issued); - $tokenSerialized["id"] = serialize($token->id); + $tokenSerialized["token"]["issued"] = serialize($token->issued); + $tokenSerialized["token"]["id"] = serialize($token->id); return $tokenSerialized; } private function unserializeToken($tokenSerialized){ + $Saved = file_get_contents("core/LibOverride/projectTokenData/".$this->backup["project"]); $api = new Api(); $token = new Models\Token($this->httpClient, $api); $token->methods = unserialize($tokenSerialized["methods"]); $token->roles = []; - foreach($tokenSerialized["roles"] as $key => $role){ + foreach($this->backup["roles"] as $key => $role){ $tmp = new Models\Role($this->httpClient, $api); $tmp->id = unserialize($key); $tmp->links = unserialize($role["links"]); - if(isset($role["name"])) - $tmp->name = unserialize($role["name"]); + $tmp->name = unserialize($role["name"]); $token->roles[] = $tmp; } $token->expires = unserialize($tokenSerialized["expires"]); $token->project = new Models\Project($this->httpClient, $api); - $token->project->domainId = unserialize($tokenSerialized["project"]["domainId"]); - $token->project->parentId = unserialize($tokenSerialized["project"]["parentId"]); - $token->project->enabled = unserialize($tokenSerialized["project"]["enabled"]); - $token->project->description = unserialize($tokenSerialized["project"]["description"]); - $token->project->id = unserialize($tokenSerialized["project"]["id"]); - $token->project->links = unserialize($tokenSerialized["project"]["links"]); - $token->project->name = unserialize($tokenSerialized["project"]["name"]); + $token->project->domainId = unserialize($Saved["project"]["domainId"]); + $token->project->parentId = unserialize($Saved["project"]["parentId"]); + $token->project->enabled = unserialize($Saved["project"]["enabled"]); + $token->project->description = unserialize($Saved["project"]["description"]); + $token->project->id = unserialize($Saved["project"]["id"]); + $token->project->links = unserialize($Saved["project"]["links"]); + $token->project->name = $Saved["project"]["name"]; $token->catalog = new Models\Catalog($this->httpClient, $api); $token->catalog->services = []; - foreach($tokenSerialized["catalog"] as $key => $service){ + foreach($Saved["catalog"] as $key => $service){ $tmp = new Models\Service($this->httpClient, $api); $tmp->id = unserialize($key); @@ -356,21 +370,20 @@ class genTokenOptions $tmpEnd->url = unserialize($end["url"]); $tmp->endpoints[] = $tmpEnd; } - if(isset($service["links"])) - $tmp->links = unserialize($service["links"]); + $tmp->links = unserialize($service["links"]); $token->catalog->services[] = $tmp; } $token->extras = unserialize($tokenSerialized["extras"]); $token->user = new Models\User($this->httpClient, $api); - $token->user->domainId = unserialize($tokenSerialized["user"]["domainId"]); - $token->user->defaultProjectId = unserialize($tokenSerialized["user"]["defaultProjectId"]); - $token->user->id = unserialize($tokenSerialized["user"]["id"]); - $token->user->email = unserialize($tokenSerialized["user"]["email"]); - $token->user->enabled = unserialize($tokenSerialized["user"]["enabled"]); - $token->user->links = unserialize($tokenSerialized["user"]["links"]); - $token->user->name = unserialize($tokenSerialized["user"]["name"]); - $token->user->description = unserialize($tokenSerialized["user"]["description"]); + $token->user->domainId = unserialize($this->backup["user"]["domainId"]); + $token->user->defaultProjectId = unserialize($this->backup["user"]["defaultProjectId"]); + $token->user->id = unserialize($this->backup["user"]["id"]); + $token->user->email = unserialize($this->backup["user"]["email"]); + $token->user->enabled = unserialize($this->backup["user"]["enabled"]); + $token->user->links = unserialize($this->backup["user"]["links"]); + $token->user->name = unserialize($this->backup["user"]["name"]); + $token->user->description = unserialize($this->backup["user"]["description"]); $token->issued = unserialize($tokenSerialized["issued"]); $token->id = unserialize($tokenSerialized["id"]); diff --git a/server/core/LibOverride/projectTokenData/demo b/server/core/LibOverride/projectTokenData/demo new file mode 100644 index 0000000..95d1e10 --- /dev/null +++ b/server/core/LibOverride/projectTokenData/demo @@ -0,0 +1 @@ +a:2:{s:7:"project";a:7:{s:8:"domainId";s:2:"N;";s:8:"parentId";s:2:"N;";s:7:"enabled";s:2:"N;";s:11:"description";s:2:"N;";s:2:"id";s:40:"s:32:"bdb42ccd0a074d15a9808ed0d2f09ce7";";s:5:"links";s:2:"N;";s:4:"name";s:4:"demo";}s:7:"catalog";a:4:{s:40:"s:32:"52c1f2e9782b47a697df38185d72a3f9";";a:5:{s:4:"name";s:14:"s:7:"neutron";";s:11:"description";s:2:"N;";s:4:"type";s:14:"s:7:"network";";s:9:"endpoints";a:3:{s:40:"s:32:"2c765b2eb502467fba360a1188174f6a";";a:6:{s:9:"interface";s:15:"s:8:"internal";";s:4:"name";s:2:"N;";s:9:"serviceId";s:2:"N;";s:6:"region";s:16:"s:9:"RegionOne";";s:5:"links";s:2:"N;";s:3:"url";s:30:"s:22:"http://controller:9696";";}s:40:"s:32:"499dc9aeb1c3438fb23b0168d75bbef1";";a:6:{s:9:"interface";s:13:"s:6:"public";";s:4:"name";s:2:"N;";s:9:"serviceId";s:2:"N;";s:6:"region";s:16:"s:9:"RegionOne";";s:5:"links";s:2:"N;";s:3:"url";s:32:"s:24:"http://148.60.11.31:9696";";}s:40:"s:32:"d0672225fe1a4fce89794f3825deec2b";";a:6:{s:9:"interface";s:12:"s:5:"admin";";s:4:"name";s:2:"N;";s:9:"serviceId";s:2:"N;";s:6:"region";s:16:"s:9:"RegionOne";";s:5:"links";s:2:"N;";s:3:"url";s:30:"s:22:"http://controller:9696";";}}s:5:"links";s:2:"N;";}s:40:"s:32:"5d48cf5c41b9412a8bfcf87e4b6b4bb4";";a:5:{s:4:"name";s:13:"s:6:"glance";";s:11:"description";s:2:"N;";s:4:"type";s:12:"s:5:"image";";s:9:"endpoints";a:3:{s:40:"s:32:"03aed8cd676d4b1b8b6ed69ba7750d72";";a:6:{s:9:"interface";s:15:"s:8:"internal";";s:4:"name";s:2:"N;";s:9:"serviceId";s:2:"N;";s:6:"region";s:16:"s:9:"RegionOne";";s:5:"links";s:2:"N;";s:3:"url";s:30:"s:22:"http://controller:9292";";}s:40:"s:32:"06ba5f2c1cb24eaebe3ef3b258ff0841";";a:6:{s:9:"interface";s:13:"s:6:"public";";s:4:"name";s:2:"N;";s:9:"serviceId";s:2:"N;";s:6:"region";s:16:"s:9:"RegionOne";";s:5:"links";s:2:"N;";s:3:"url";s:32:"s:24:"http://148.60.11.31:9292";";}s:40:"s:32:"32dd6e5e7acd44d88c1e89a4d805a355";";a:6:{s:9:"interface";s:12:"s:5:"admin";";s:4:"name";s:2:"N;";s:9:"serviceId";s:2:"N;";s:6:"region";s:16:"s:9:"RegionOne";";s:5:"links";s:2:"N;";s:3:"url";s:30:"s:22:"http://controller:9292";";}}s:5:"links";s:2:"N;";}s:40:"s:32:"be984e9e4da645449c645a3dad056d6b";";a:5:{s:4:"name";s:15:"s:8:"keystone";";s:11:"description";s:2:"N;";s:4:"type";s:15:"s:8:"identity";";s:9:"endpoints";a:3:{s:40:"s:32:"0f292b615b544869841c349dbbfead32";";a:6:{s:9:"interface";s:13:"s:6:"public";";s:4:"name";s:2:"N;";s:9:"serviceId";s:2:"N;";s:6:"region";s:16:"s:9:"RegionOne";";s:5:"links";s:2:"N;";s:3:"url";s:36:"s:28:"http://148.60.11.31:5000/2.0";";}s:40:"s:32:"6a01f770c4014bec933cccc28d378c78";";a:6:{s:9:"interface";s:12:"s:5:"admin";";s:4:"name";s:2:"N;";s:9:"serviceId";s:2:"N;";s:6:"region";s:16:"s:9:"RegionOne";";s:5:"links";s:2:"N;";s:3:"url";s:36:"s:28:"http://controller:35357/v2.0";";}s:40:"s:32:"d94955c39c784602a1ab49003056a4a4";";a:6:{s:9:"interface";s:15:"s:8:"internal";";s:4:"name";s:2:"N;";s:9:"serviceId";s:2:"N;";s:6:"region";s:16:"s:9:"RegionOne";";s:5:"links";s:2:"N;";s:3:"url";s:35:"s:27:"http://controller:5000/v2.0";";}}s:5:"links";s:2:"N;";}s:40:"s:32:"edc16c0a3e4042b7b396727fa8e57e7e";";a:5:{s:4:"name";s:11:"s:4:"nova";";s:11:"description";s:2:"N;";s:4:"type";s:14:"s:7:"compute";";s:9:"endpoints";a:3:{s:40:"s:32:"0d61ec232f3b4975b3e3d32f2b7a6122";";a:6:{s:9:"interface";s:13:"s:6:"public";";s:4:"name";s:2:"N;";s:9:"serviceId";s:2:"N;";s:6:"region";s:16:"s:9:"RegionOne";";s:5:"links";s:2:"N;";s:3:"url";s:68:"s:60:"http://148.60.11.31:8774/v2/bdb42ccd0a074d15a9808ed0d2f09ce7";";}s:40:"s:32:"20ac63e325274a5bbde914f3bb582c45";";a:6:{s:9:"interface";s:12:"s:5:"admin";";s:4:"name";s:2:"N;";s:9:"serviceId";s:2:"N;";s:6:"region";s:16:"s:9:"RegionOne";";s:5:"links";s:2:"N;";s:3:"url";s:66:"s:58:"http://controller:8774/v2/bdb42ccd0a074d15a9808ed0d2f09ce7";";}s:40:"s:32:"749e7483b9b04dceb1838095dd877aa8";";a:6:{s:9:"interface";s:15:"s:8:"internal";";s:4:"name";s:2:"N;";s:9:"serviceId";s:2:"N;";s:6:"region";s:16:"s:9:"RegionOne";";s:5:"links";s:2:"N;";s:3:"url";s:66:"s:58:"http://controller:8774/v2/bdb42ccd0a074d15a9808ed0d2f09ce7";";}}s:5:"links";s:2:"N;";}}} \ No newline at end of file -- cgit v1.2.3 From e595e9adaf5ef8db3514a2093de660c2a6bea8b6 Mon Sep 17 00:00:00 2001 From: EoleDev Date: Wed, 17 Feb 2016 16:59:07 +0100 Subject: Add token Post --- server/init.php | 2 ++ 1 file changed, 2 insertions(+) mode change 100644 => 100755 server/init.php (limited to 'server') diff --git a/server/init.php b/server/init.php old mode 100644 new mode 100755 index cf08523..a00927d --- a/server/init.php +++ b/server/init.php @@ -43,4 +43,6 @@ $App = new App($Args); + if(isset($token)) + $App->setToken($token); ?> -- cgit v1.2.3 From 5ac2313bea3f186acdeeb8594542a3702e3dc305 Mon Sep 17 00:00:00 2001 From: EoleDev Date: Wed, 17 Feb 2016 17:20:38 +0100 Subject: Modification of the Identity's function's implementation, MAJ of the library php-opencloud/openstack --- server/core/Identity.php | 188 +++++++++++++++------------------- server/vendor/php-opencloud/openstack | 2 +- 2 files changed, 84 insertions(+), 106 deletions(-) mode change 100644 => 100755 server/core/Identity.php (limited to 'server') diff --git a/server/core/Identity.php b/server/core/Identity.php old mode 100644 new mode 100755 index 00199ec..2638985 --- a/server/core/Identity.php +++ b/server/core/Identity.php @@ -25,9 +25,6 @@ class identity implements Core{ /** @var OpenStack\Identity $libClass protected, contains the library Identity object */ protected $libClass; - - /** @var array $actions protected, contains the functions which can be call by the front-end */ - protected $actions = array(); /** * identity constructor @@ -44,9 +41,19 @@ class identity implements Core{ $this->libClass = $app->getLibClass("Identity"); } - - $credentials = array(); + /** + * Execute an action + * + * @param String $action name of another function of this class + * + * @return void + */ + public function action($action){ + + $this->{$action.""}(); + + } /** * Add a credential for the given user/project. * @@ -60,7 +67,7 @@ class identity implements Core{ * * @return void */ - $credentials["addCredential"] = function(){ + private function addCredential(){ $blob = $this->app->getPostParam("blob"); $projectId = $this->app->getPostParam("projectId"); @@ -96,7 +103,7 @@ class identity implements Core{ * * @return void */ - $credentials["listCredentials"] = function(){ + private function listCredentials(){ try{ $this->libClass->listCredentials() @@ -122,7 +129,7 @@ class identity implements Core{ * * @return void */ - $credentials["showCredential"] = function(){ + private function showCredential(){ $credentId = $this->app->getPostParam("credentialId"); if(!isset($credentId)){ @@ -157,7 +164,7 @@ class identity implements Core{ * * @return void */ - $credentials["updateCredential"] = function(){ + private function updateCredential(){ $credentId = $this->app->getPostParam("credentialId"); $blob = $this->app->getPostParam("blob"); @@ -197,7 +204,7 @@ class identity implements Core{ * * @return void */ - $credentials["deleteCredential"] = function(){ + private function deleteCredential(){ $credentId = $this->app->getPostParam("credentialId"); @@ -223,8 +230,6 @@ class identity implements Core{ } }- - $domains = array(); - /** * Add a domain to an OpenStack instance. * @@ -234,7 +239,7 @@ class identity implements Core{ * * @return void */ - $domains["addDomain"] = function(){ + private function addDomain(){ $description = $this->app->getPostParam("desc"); $enabled = $this->app->getPostParam("enabled"); @@ -277,7 +282,7 @@ class identity implements Core{ * * @return void */ - $domains["listDomains"] = function(){ + private function listDomains(){ try{ @@ -304,7 +309,7 @@ class identity implements Core{ * * @return void */ - $domains["showDomain"] = function(){ + private function showDomain(){ $domId = $this->app->getPostParam("domainId"); @@ -340,7 +345,7 @@ class identity implements Core{ * * @return void */ - $domains["updateDomain"] = function(){ + private function updateDomain(){ $domId = $this->app->getPostParam("domainId"); $description = $this->app->getPostParam("desc"); @@ -386,7 +391,7 @@ class identity implements Core{ * * @return void */ - $domains["deleteDomain"] = function(){ + private function deleteDomain(){ $domId = $this->app->getPostParam("domainId"); @@ -419,7 +424,7 @@ class identity implements Core{ * * @return void */ - $domains["listRolesDomainUser"] = function(){ + private function listRolesDomainUser(){ $domId = $this->app->getPostParam("domainId"); $userId = $this->app->getPostParam("userId"); @@ -454,7 +459,7 @@ class identity implements Core{ * * @return void */ - $domains["grantRoleDomainUser"] = function(){ + private function grantRoleDomainUser(){ $domId = $this->app->getPostParam("domainId"); $roleId = $this->app->getPostParam("roleId"); $userId = $this->app->getPostParam("userId"); @@ -492,7 +497,7 @@ class identity implements Core{ * * @return void */ - $domains["checkRoleDomainUser"] = function(){ + private function checkRoleDomainUser(){ $domId = $this->app->getPostParam("domainId"); $roleId = $this->app->getPostParam("roleId"); $userId = $this->app->getPostParam("userId"); @@ -531,7 +536,7 @@ class identity implements Core{ * * @return void */ - $domains["revokeRoleDomainUser"] = function(){ + private function revokeRoleDomainUser(){ $domId = $this->app->getPostParam("domainId"); $roleId = $this->app->getPostParam("roleId"); $userId = $this->app->getPostParam("userId"); @@ -569,7 +574,7 @@ class identity implements Core{ * * @return void */ - $domains["listRolesDomainGroup"] = function(){ + private function listRolesDomainGroup(){ $domId = $this->app->getPostParam("domainId"); $groupId = $this->app->getPostParam("groupId"); @@ -604,7 +609,7 @@ class identity implements Core{ * * @return void */ - $domains["grantRoleDomainGroup"] = function(){ + private function grantRoleDomainGroup(){ $domId = $this->app->getPostParam("domainId"); $groupId = $this->app->getPostParam("groupId"); $roleId = $this->app->getPostParam("roleId"); @@ -642,7 +647,7 @@ class identity implements Core{ * * @return void */ - $domains["checkRoleDomainGroup"] = function(){ + private function checkRoleDomainGroup(){ $domId = $this->app->getPostParam("domainId"); $groupId = $this->app->getPostParam("groupId"); $roleId = $this->app->getPostParam("roleId"); @@ -687,7 +692,7 @@ class identity implements Core{ * * @return void */ - $domains["revokeRoleDomainGroup"] = function(){ + private function revokeRoleDomainGroup(){ $domId = $this->app->getPostParam("domainId"); $groupId = $this->app->getPostParam("groupId"); $roleId = $this->app->getPostParam("roleId"); @@ -719,8 +724,6 @@ class identity implements Core{ } } - $endpoints = array(); - /** * Add an endpoint to the Openstack instance * @@ -728,7 +731,7 @@ class identity implements Core{ * * @return void */ - $endpoints["addEndpoint"] = function(){ + private function addEndpoint(){ $servId = $this->app->getPostParam("serviceId"); $name = $this->app->getPostParam("name"); $region = $this->app->getPostParam("region"); @@ -768,7 +771,7 @@ class identity implements Core{ * * @return void */ - $endpoints["getEndpoint"] = function(){ + private function getEndpoint(){ $endId = $this->app->getPostParam("endpointId"); @@ -798,7 +801,7 @@ class identity implements Core{ * * @return void */ - $endpoints["listEndpoints"] = function(){ + private function listEndpoints(){ try{ @@ -824,7 +827,7 @@ class identity implements Core{ * * @return void */ - $endpoints["updateEndpoint"] = function(){ + private function updateEndpoint(){ //Not Implemented Yet /*$domId = $this->app->getPostParam("domainId"); @@ -863,7 +866,7 @@ class identity implements Core{ * * @return void */ - $endpoints["deleteEndpoint"] = function(){ + private function deleteEndpoint(){ $endId = $this->app->getPostParam("endpointId"); if(!isset($endId)){ @@ -888,8 +891,6 @@ class identity implements Core{ } } - $groups = array(); - /** * Add a group. * @@ -897,7 +898,7 @@ class identity implements Core{ * * @return void */ - $groups["addGroup"] = function(){ + private function addGroup(){ //Not Implemented Yet /*$domId = $this->app->getPostParam("domainId"); @@ -930,7 +931,7 @@ class identity implements Core{ * * @return void */ - $groups["listGroups"] = function(){ + private function listGroups(){ //Not Implemented Yet /* $domId = $this->app->getPostParam("domainId"); @@ -963,7 +964,7 @@ class identity implements Core{ * * @return void */ - $groups["showGroup"] = function(){ + private function showGroup(){ //Not Implemented Yet /* @@ -997,7 +998,7 @@ class identity implements Core{ * * @return void */ - $groups["updateGroup"] = function(){ + private function updateGroup(){ //Todo Argument Optional $groupId = $this->app->getPostParam("groupId"); $description = $this->app->getPostParam("description"); @@ -1038,7 +1039,7 @@ class identity implements Core{ * * @return void */ - $groups["deleteGroup"] = function(){ + private function deleteGroup(){ $groupId = $this->app->getPostParam("groupId"); @@ -1072,7 +1073,7 @@ class identity implements Core{ * * @return void */ - $groups["listGroupUsers"] = function(){ + private function listGroupUsers(){ $groupId = $this->app->getPostParam("groupId"); @@ -1106,7 +1107,7 @@ class identity implements Core{ * * @return void */ - $groups["addGroupUser"] = function(){ + private function addGroupUser(){ $userId = $this->app->getPostParam("userId"); $groupId = $this->app->getPostParam("groupId"); @@ -1141,7 +1142,7 @@ class identity implements Core{ * * @return void */ - $groups["removeGroupUser"] = function(){ + private function removeGroupUser(){ $userId = $this->app->getPostParam("userId"); $groupId = $this->app->getPostParam("groupId"); @@ -1176,7 +1177,7 @@ class identity implements Core{ * * @return void */ - $groups["checkGroupUser"] = function(){ + private function checkGroupUser(){ $userId = $this->app->getPostParam("userId"); $groupId = $this->app->getPostParam("groupId"); @@ -1204,8 +1205,6 @@ class identity implements Core{ } } - $policies = array(); - /** * @todo * @@ -1213,7 +1212,7 @@ class identity implements Core{ * * @return void */ - $policies["addPolicies"] = function(){ + private function addPolicies(){ //Not Implemented Yet /* $domId = $this->app->getPostParam("domainId"); @@ -1246,7 +1245,7 @@ class identity implements Core{ * * @return void */ - $policies["listPolicies"] = function(){ + private function listPolicies(){ //Not Implemented Yet /* $domId = $this->app->getPostParam("domainId"); @@ -1279,7 +1278,7 @@ class identity implements Core{ * * @return void */ - $policies["showPolicie"] = function(){ + private function showPolicie(){ //Not Implemented Yet /* $domId = $this->app->getPostParam("domainId"); @@ -1313,7 +1312,7 @@ class identity implements Core{ * * @return void */ - $policies["updatePolicies"] = function(){ + private function updatePolicies(){ //Not Implemented Yet /* $domId = $this->app->getPostParam("domainId"); @@ -1346,7 +1345,7 @@ class identity implements Core{ * * @return void */ - $policies["deletePolicies"] = function(){ + private function deletePolicies(){ //Not Implemented Yet /* $domId = $this->app->getPostParam("domainId"); @@ -1372,8 +1371,6 @@ class identity implements Core{ }*/ } - $projects = array(); - /** * Add a project. * @@ -1381,7 +1378,7 @@ class identity implements Core{ * * @return void */ - $projects["addProject"] = function(){ + private function addProject(){ //Todo Parameters Optional $description = $this->app->getPostParam("description"); $name = $this->app->getPostParam("name"); @@ -1416,7 +1413,7 @@ class identity implements Core{ * * @return void */ - $projects["listProjects"] = function(){ + private function listProjects(){ try{ @@ -1442,7 +1439,7 @@ class identity implements Core{ * * @return void */ - $projects["showProject"] = function(){ + private function showProject(){ $projId = $this->app->getPostParam("projetId"); @@ -1475,7 +1472,7 @@ class identity implements Core{ * * @return void */ - $projects["updateProject"] = function(){ + private function updateProject(){ //Todo Parameters Optionnal $description = $this->app->getPostParam("description"); $name = $this->app->getPostParam("name"); @@ -1515,7 +1512,7 @@ class identity implements Core{ * * @return void */ - $projects["deleteProject"] = function(){ + private function deleteProject(){ $projId = $this->app->getPostParam("projId"); if(!isset($projId)){ @@ -1548,7 +1545,7 @@ class identity implements Core{ * * @return void */ - $projects["listRolesProjectUser"] = function(){ + private function listRolesProjectUser(){ $projId = $this->app->getPostParam("projetId"); $userId = $this->app->getPostParam("userId"); @@ -1583,7 +1580,7 @@ class identity implements Core{ * * @return void */ - $projects["grantRoleProjectUser"] = function(){ + private function grantRoleProjectUser(){ $projId = $this->app->getPostParam("projId"); $userId = $this->app->getPostParam("userId"); @@ -1622,7 +1619,7 @@ class identity implements Core{ * * @return void */ - $projects["checkRoleProjectUser"] = function(){ + private function checkRoleProjectUser(){ $projId = $this->app->getPostParam("projetId"); $userId = $this->app->getPostParam("userId"); $roleId = $this->app->getPostParam("roleId"); @@ -1663,7 +1660,7 @@ class identity implements Core{ * * @return void */ - $projects["revokeRoleProjectUser"] = function(){ + private function revokeRoleProjectUser(){ $projId = $this->app->getPostParam("projetId"); $userId = $this->app->getPostParam("userId"); @@ -1702,7 +1699,7 @@ class identity implements Core{ * * @return void */ - $projects["listRolesProjectGroup"] = function(){ + private function listRolesProjectGroup(){ $projId = $this->app->getPostParam("projetId"); $groupId = $this->app->getPostParam("groupId"); @@ -1738,7 +1735,7 @@ class identity implements Core{ * * @return void */ - $projects["grantRoleProjectGroup"] = function(){ + private function grantRoleProjectGroup(){ $projId = $this->app->getPostParam("projetId"); $userId = $this->app->getPostParam("userId"); @@ -1777,7 +1774,7 @@ class identity implements Core{ * * @return void */ - $projects["checkRoleProjectGroup"] = function(){ + private function checkRoleProjectGroup(){ $projId = $this->app->getPostParam("projetId"); $userId = $this->app->getPostParam("userId"); @@ -1818,7 +1815,7 @@ class identity implements Core{ * * @return void */ - $projects["revokeRoleProjectGroup"] = function(){ + private function revokeRoleProjectGroup(){ $projId = $this->app->getPostParam("projetId"); $userId = $this->app->getPostParam("userId"); @@ -1850,8 +1847,6 @@ class identity implements Core{ } } - $roles = array(); - /** * Add a role. * @@ -1859,7 +1854,7 @@ class identity implements Core{ * * @return void */ - $roles["addRole"] = function(){ + private function addRole(){ $name = $this->app->getPostParam("name"); @@ -1891,7 +1886,7 @@ class identity implements Core{ * * @return void */ - $roles["listRoles"] = function(){ + private function listRoles(){ try{ @@ -1915,7 +1910,7 @@ class identity implements Core{ * * @return void */ - $roles["listRoleAssignements"] = function(){ + private function listRoleAssignements(){ try{ @@ -1934,8 +1929,6 @@ class identity implements Core{ } } - $services = array(); - /** * Add a service. * @@ -1943,7 +1936,7 @@ class identity implements Core{ * * @return void */ - $services["addService"] = function(){ + private function addService(){ $name = $this->app->getPostParam("name"); $type = $this->app->getPostParam("type"); @@ -1976,7 +1969,7 @@ class identity implements Core{ * * @return void */ - $services["listServices"] = function(){ + private function listServices(){ try{ @@ -2002,7 +1995,7 @@ class identity implements Core{ * * @return void */ - $services["showService"] = function(){ + private function showService(){ $servId = $this->app->getPostParam("serviceId"); if(!isset($servId)){ @@ -2033,7 +2026,7 @@ class identity implements Core{ * * @return void */ - $services["deleteService"] = function(){ + private function deleteService(){ $servId = $this->app->getPostParam("serviceId"); $groupId = $this->app->getPostParam("groupId"); @@ -2060,8 +2053,6 @@ class identity implements Core{ } } - $tokens = array(); - /** * Generate a new token for a given user id. * @@ -2069,7 +2060,7 @@ class identity implements Core{ * * @return void */ - $tokens["genTokenUserID"] = function(){ + private function genTokenUserID(){ $userId = $this->app->getPostParam("userId"); $userPass = $this->app->getPostParam("userPassword"); @@ -2107,7 +2098,7 @@ class identity implements Core{ * * @return void */ - $tokens["genTokenUserName"] = function(){ + private function genTokenUserName(){ $username = $this->app->getPostParam("username"); $userPass = $this->app->getPostParam("userPassword"); $domId = $this->app->getPostParam("domainId"); @@ -2149,7 +2140,7 @@ class identity implements Core{ * * @return void */ - $tokens["geneTokenID"] = function(){ + private function genTokenID(){ $tokenId = $this->app->getPostParam("tokenId"); $projectId = $this->app->getPostParam("projectId"); @@ -2185,7 +2176,7 @@ class identity implements Core{ * * @return void */ - $tokens["genTokenScopedProjectID"] = function(){ + private function genTokenScopedProjectID(){ $userId = $this->app->getPostParam("userId"); $userPass = $this->app->getPostParam("userPass"); @@ -2227,7 +2218,7 @@ class identity implements Core{ * * @return void */ - $tokens["genTokenScopedProjectName"] = function(){ + private function genTokenScopedProjectName(){ $userId = $this->app->getPostParam("userId"); $userPass = $this->app->getPostParam("userPass"); @@ -2275,7 +2266,7 @@ class identity implements Core{ * * @return void */ - $tokens["validateToken"] = function(){ + private function validateToken(){ $tokenId = $this->app->getPostParam("tokenId"); @@ -2311,7 +2302,7 @@ class identity implements Core{ * * @return void */ - $tokens["revokeToken"] = function(){ + private function revokeToken(){ $tokenId = $this->app->getPostParam("tokenId"); @@ -2336,8 +2327,6 @@ class identity implements Core{ } } - $users = array(); - /** * Add a new user. * @@ -2345,7 +2334,7 @@ class identity implements Core{ * * @return void */ - $users["addUser"] = function(){ + private function addUser(){ //Todo Optionnal Parameter $projId = $this->app->getPostParam("projId"); $desc = $this->app->getPostParam("description"); @@ -2388,7 +2377,7 @@ class identity implements Core{ * * @return void */ - $users["listUsers"] = function(){ + private function listUsers(){ try{ @@ -2414,7 +2403,7 @@ class identity implements Core{ * * @return void */ - $users["showUser"] = function(){ + private function showUser(){ $userId = $this->app->getPostParam("userId"); @@ -2447,7 +2436,7 @@ class identity implements Core{ * * @return void */ - $users["updateUser"] = function(){ + private function updateUser(){ $userId = $this->app->getPostParam("userId"); $desc = $this->app->getPostParam("description"); @@ -2486,7 +2475,7 @@ class identity implements Core{ * * @return void */ - $users["deleteUser"] = function(){ + private function deleteUser(){ $userId = $this->app->getPostParam("userId"); @@ -2519,7 +2508,7 @@ class identity implements Core{ * * @return void */ - $users["listUserGroups"] = function(){ + private function listUserGroups(){ $userId = $this->app->getPostParam("userId"); @@ -2553,7 +2542,7 @@ class identity implements Core{ * * @return void */ - $users["listUserProjects"] = function(){ + private function listUserProjects(){ $userId = $this->app->getPostParam("userId"); @@ -2579,15 +2568,4 @@ class identity implements Core{ $this->app->getErrorInstance->NotImplementedHandler($e); } } - - $actions["Credentials"] = $credentials; - $actions["Domains"] = $domains; - $actions["Endpoints"] = $endpoints; - $actions["Groups"] = $groups; - $actions["Policies"] = $policies; - $actions["Projects"] = $projects; - $actions["Roles"] = $roles; - $actions["Services"] = $services; - $actions["Tokens"] = $tokens; - $actions["Users"] = $users; } diff --git a/server/vendor/php-opencloud/openstack b/server/vendor/php-opencloud/openstack index 15aca73..1419eb2 160000 --- a/server/vendor/php-opencloud/openstack +++ b/server/vendor/php-opencloud/openstack @@ -1 +1 @@ -Subproject commit 15aca73f423166c7ef8337ba08615c103c66e931 +Subproject commit 1419eb2e01164bb6b8b837df37724423907352d7 -- cgit v1.2.3