From 721620a549f38ca13f82351ae12d777f929b7372 Mon Sep 17 00:00:00 2001 From: "yogg@epsina.com" Date: Wed, 27 Jan 2016 19:19:42 +0100 Subject: [PATCH 01/45] =?UTF-8?q?=20Modifications=20qui=20seront=20valid?= =?UTF-8?q?=C3=A9es=20:=20=09modifi=C3=A9=C2=A0:=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20server/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(-) 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(); +} + + +?> From 83fd3eb19dc9943d3ad53154f330ed4782ccff81 Mon Sep 17 00:00:00 2001 From: "yogg@epsina.com" Date: Sun, 31 Jan 2016 10:56:52 +0100 Subject: [PATCH 02/45] =?UTF-8?q?=20Modifications=20qui=20seront=20valid?= =?UTF-8?q?=C3=A9es=20:=20=09modifi=C3=A9=C2=A0:=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20server/core/Image.php=20=09modifi=C3=A9=C2=A0:=20=20=20=20?= =?UTF-8?q?=20=20=20=20=20server/test.php?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/core/Image.php | 184 ++++++++++++++++++++++-------------------- server/test.php | 21 +++-- 2 files changed, 114 insertions(+), 91 deletions(-) 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); +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 create_image(array $opt){ - $service = $openstack->imagesV2(); + public function image_details($id){ + $service = $openstack->imagesV2(); + $image = $service->getImage($id); + return $image; + } - // 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 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 "
"; +} From 325362a386687dd77c6c42dc5ab266d646bd9842 Mon Sep 17 00:00:00 2001 From: "yogg@epsina.com" Date: Sun, 31 Jan 2016 11:36:58 +0100 Subject: [PATCH 03/45] list_images and images_details --- server/core/Image.php | 30 ++++++++++++++++++------------ server/test.php | 22 +++++++++++++++++----- 2 files changed, 35 insertions(+), 17 deletions(-) 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 From 10a6cd146db2bc509059d07ff8b7887445524cab Mon Sep 17 00:00:00 2001 From: "yogg@epsina.com" Date: Sun, 31 Jan 2016 13:00:04 +0100 Subject: [PATCH 04/45] Add create_image and delete_image --- server/core/Image.php | 26 +++++++++++++++++--------- server/test.php | 18 ++++++++++++++++-- 2 files changed, 33 insertions(+), 11 deletions(-) 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 From 0db8d0ebbe36528346987cb21db67f31bfbe6017 Mon Sep 17 00:00:00 2001 From: "yogg@epsina.com" Date: Sun, 31 Jan 2016 17:47:06 +0100 Subject: [PATCH 05/45] Add activate_image, desactivate_image, uplaod_image --- server/core/Image.php | 49 +++++++++++++++++++++++++++++++------------ server/test.php | 8 ++++++- 2 files changed, 43 insertions(+), 14 deletions(-) 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 From 6e7c71db77fc68b7c3d1149b830a838b81cdb718 Mon Sep 17 00:00:00 2001 From: "yogg@epsina.com" Date: Sun, 31 Jan 2016 18:28:09 +0100 Subject: [PATCH 06/45] Add update_image and download_image --- server/core/Image.php | 32 ++++++++++++++++++++++---------- server/test.php | 13 +++++++++++++ 2 files changed, 35 insertions(+), 10 deletions(-) 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 From 8ad2a0aacd280ec29a6b53e7663b968068f89ab9 Mon Sep 17 00:00:00 2001 From: "yogg@epsina.com" Date: Sun, 31 Jan 2016 19:48:30 +0100 Subject: [PATCH 07/45] Modification of options for create_image --- server/core/Image.php | 46 ++++++++++++++++++++++++++++++++----------- server/test.php | 11 ++++++++--- 2 files changed, 42 insertions(+), 15 deletions(-) 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); From e2dacb129e75111559a6f16252009b031c2baeb4 Mon Sep 17 00:00:00 2001 From: "yogg@epsina.com" Date: Sun, 31 Jan 2016 19:57:05 +0100 Subject: [PATCH 08/45] Modification of options for update_image --- server/core/Image.php | 26 +++++++++++++++++++------- server/test.php | 6 +----- 2 files changed, 20 insertions(+), 12 deletions(-) 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; From ab6e45d5e152518fd07c7bbce6f5eb2f42b30e07 Mon Sep 17 00:00:00 2001 From: Yoggzo Date: Tue, 2 Feb 2016 11:15:51 +0100 Subject: [PATCH 09/45] Modifications of create_image and update_image --- server/core/Image.php | 33 ++++++++++++++++++--------------- server/test.php | 10 +++++++--- 2 files changed, 25 insertions(+), 18 deletions(-) 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 From 784b25754c6b168a6c015aa39837c34339c88444 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Thu, 4 Feb 2016 13:20:45 +0100 Subject: [PATCH 10/45] Add error checking, add method handler for login --- client/index.html | 1 + client/js/controllers/login.js | 48 ++++++++++++++++++---------------- client/js/requests/errors.js | 14 ++++++++++ client/js/requests/identity.js | 9 +++++-- client/partials/login.html | 12 ++++----- 5 files changed, 53 insertions(+), 31 deletions(-) create mode 100644 client/js/requests/errors.js diff --git a/client/index.html b/client/index.html index a4845e8..fe53069 100644 --- a/client/index.html +++ b/client/index.html @@ -73,6 +73,7 @@ + diff --git a/client/js/controllers/login.js b/client/js/controllers/login.js index 2f74414..d08a9f2 100644 --- a/client/js/controllers/login.js +++ b/client/js/controllers/login.js @@ -1,8 +1,3 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ /** * Represents a book. @@ -10,30 +5,37 @@ */ mainApp.controller('loginCtrl', function ($scope,$interval,$sce) { - // Define default states - $('#loginModal').modal({backdrop: 'static', keyboard: false}); - $('#loadingLoginButton').hide(); - $('#failedToLoginAlert').hide(); + // Define default states + $('#loginModal').modal({backdrop: 'static', keyboard: false}); + $('#loadingLoginButton').hide(); + $('#failedToLoginAlert').hide(); - $('#loginButton').click(function(){ - $('#loginButton').hide(); - $('#loadingLoginButton').show(); - $('#failedToLoginAlert').hide(); + $('#loginButton').click(function(){ + $('#loginButton').hide(); + $('#loadingLoginButton').show(); + $('#failedToLoginAlert').hide(); - + var result=identity.login($("#loginFormUsername").val(), $("#loginFormProjectname").val(), $("#loginFormPassword").val()); - $interval( - function() - { - $('#failedToLoginAlert').show(); + $interval( + function() + { + // Check for error + if(!errors.checkForLogin(result)){ + $('#failedToLoginAlert').show(); + } + else { + $('#loginModal').modal('hide'); + } + + // Reset button state $('#loginButton').show(); - $('#loadingLoginButton').hide(); - - }, 2000,1); - + $('#loadingLoginButton').hide(); + }, 2000,1); + }); -}) +}); diff --git a/client/js/requests/errors.js b/client/js/requests/errors.js new file mode 100644 index 0000000..cc9389a --- /dev/null +++ b/client/js/requests/errors.js @@ -0,0 +1,14 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ + + +var errors={}; + + +errors.checkForLogin=function(result){ + // TODO + return true; +}; \ No newline at end of file diff --git a/client/js/requests/identity.js b/client/js/requests/identity.js index cad1261..61f06ed 100644 --- a/client/js/requests/identity.js +++ b/client/js/requests/identity.js @@ -1,9 +1,14 @@ // Make Namespace -var identity = {} ; - +var identity = {}; +identity.login=function(username, projectname, password){ + + // Todo + + return "tokens"; +}; diff --git a/client/partials/login.html b/client/partials/login.html index 387b075..aa974ab 100644 --- a/client/partials/login.html +++ b/client/partials/login.html @@ -12,18 +12,18 @@ - \ No newline at end of file + From bfac8211479dbeddd16d2044a4cf41d3ea592016 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Wed, 10 Feb 2016 17:55:13 +0100 Subject: [PATCH 23/45] Optimize Identity --- client/js/controllers/login.js | 5 +---- client/js/services/Identity.js | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/client/js/controllers/login.js b/client/js/controllers/login.js index e9308b8..106e889 100644 --- a/client/js/controllers/login.js +++ b/client/js/controllers/login.js @@ -37,10 +37,7 @@ mainApp.controller('loginCtrl', ['$scope','$sce','Identity', function ($scope,$s $('#failedToLoginAlert').show(); } else { - $('#loginModal').modal('hide'); - Identity.profile.username=username; - Identity.profile.projectname=projectname; - + $('#loginModal').modal('hide'); } // Reset button state diff --git a/client/js/services/Identity.js b/client/js/services/Identity.js index 2164592..7021003 100644 --- a/client/js/services/Identity.js +++ b/client/js/services/Identity.js @@ -1,11 +1,15 @@ mainApp.factory('Identity',[ '$http', function($http){ + + /* Create profile structure */ var profile={}; - profile.username="None"; - profile.projectname="None"; - + profile.username="Undefined"; + profile.projectname="Undefined"; + profile.token=""; + /** + * Function to connect to OpenStack * * @param {object} $http Angular $http service * @param {string} username The user name @@ -14,6 +18,9 @@ mainApp.factory('Identity',[ '$http', function($http){ * @returns {promise} The result of the request */ var login=function(username, password,projectname){ + profile.username=username; + profile.projectname=projectname; + return $http.post('../server/index.php', $.param({"task" : "Authenticate", "user" : username, "password" : password, "project" : projectname})); }; @@ -29,7 +36,7 @@ mainApp.factory('Identity',[ '$http', function($http){ requestParserResult.status=0; requestParserResult.data=response.data; - + profile.token="Un Token"; // TODO @@ -39,6 +46,7 @@ mainApp.factory('Identity',[ '$http', function($http){ + // Return services objects return { login: login, parseLoginAnswer: parseLoginAnswer, From 7b9f17ba036f016078aea27565e1d31fce586b3f Mon Sep 17 00:00:00 2001 From: EoleDev Date: Wed, 10 Feb 2016 18:09:44 +0100 Subject: [PATCH 24/45] Add REST request management for Image Service --- server/core/App.php | 5 +++++ server/index.php | 7 +++++++ 2 files changed, 12 insertions(+) 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; } From 0c985435949c1b7cd034d70559f8bcce744418de Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Wed, 10 Feb 2016 19:27:28 +0100 Subject: [PATCH 25/45] Simplify Identity... --- client/js/controllers/login.js | 4 ++-- client/js/services/Identity.js | 11 +++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/client/js/controllers/login.js b/client/js/controllers/login.js index 106e889..60eb52f 100644 --- a/client/js/controllers/login.js +++ b/client/js/controllers/login.js @@ -29,10 +29,10 @@ mainApp.controller('loginCtrl', ['$scope','$sce','Identity', function ($scope,$s result.then(function (response){ // Parser result - var requestResultObject=Identity.parseLoginAnswer(response); + var response=Identity.getResponse(); // Check for error - if(requestResultObject.status!==0){ + if(response.status!==0){ $('#failedToLoginAlert').show(); } diff --git a/client/js/services/Identity.js b/client/js/services/Identity.js index 7021003..509f800 100644 --- a/client/js/services/Identity.js +++ b/client/js/services/Identity.js @@ -7,6 +7,8 @@ mainApp.factory('Identity',[ '$http', function($http){ profile.projectname="Undefined"; profile.token=""; + /* Will contain the result of the $http request */ + var $httpResponse; /** * Function to connect to OpenStack @@ -21,8 +23,9 @@ mainApp.factory('Identity',[ '$http', function($http){ profile.username=username; profile.projectname=projectname; - return $http.post('../server/index.php', + $httpResponse=$http.post('../server/index.php', $.param({"task" : "Authenticate", "user" : username, "password" : password, "project" : projectname})); + return $httpResponse; }; @@ -45,11 +48,15 @@ mainApp.factory('Identity',[ '$http', function($http){ }; + var getResponse=function(){ + return parseLoginAnswer($httpResponse); + } + // Return services objects return { login: login, - parseLoginAnswer: parseLoginAnswer, + getResponse: getResponse, profile: profile }; From 3f83cae4178226084dcbf1e826271a04cc97086d Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Wed, 10 Feb 2016 21:45:52 +0100 Subject: [PATCH 26/45] Login Service complete ! --- client/index.html | 1 + client/js/controllers/login.js | 41 ++++++++--------- client/js/controllers/status.js | 2 +- client/js/services/Identity.js | 82 ++++++++++++++++++--------------- client/js/services/Image.js | 25 ++++++++++ client/partials/login.html | 4 +- 6 files changed, 94 insertions(+), 61 deletions(-) create mode 100644 client/js/services/Image.js diff --git a/client/index.html b/client/index.html index 10eceb3..ab5f00f 100644 --- a/client/index.html +++ b/client/index.html @@ -73,6 +73,7 @@ + diff --git a/client/js/controllers/login.js b/client/js/controllers/login.js index 60eb52f..6358a6d 100644 --- a/client/js/controllers/login.js +++ b/client/js/controllers/login.js @@ -4,7 +4,7 @@ * @param {$scope} $scope The $scope angular service * @param {$sce} $sce The $sce angular service * @param {$http} $http The $http angular service - * @param {sharedProfile} sharedProfile The sharedProfile service + * @param {Identity} The Identity service */ mainApp.controller('loginCtrl', ['$scope','$sce','Identity', function ($scope,$sce, Identity) @@ -16,42 +16,39 @@ mainApp.controller('loginCtrl', ['$scope','$sce','Identity', function ($scope,$s $('#loginButton').click(function(){ + + // Begin login state for template $('#loginButton').hide(); $('#loadingLoginButton').show(); $('#failedToLoginAlert').hide(); + // Get data from templates var username=$("#loginFormUsername").val(); var password=$("#loginFormPassword").val(); var projectname=$("#loginFormProjectname").val(); - var result=Identity.login(username, password, projectname); - - - result.then(function (response){ - // Parser result - var response=Identity.getResponse(); - - // Check for error + // Function to call to handle result + var responseCallback=function(response){ + if(response.status!==0){ - + // Set reason of fail + $scope.failReason=response.failReason; + + // Display the error $('#failedToLoginAlert').show(); } else { + // Else the user is online ! $('#loginModal').modal('hide'); } // Reset button state $('#loginButton').show(); - $('#loadingLoginButton').hide(); - },function(response){ - $('#failedToLoginAlert').show(); - - // Reset button state - $('#loginButton').show(); - $('#loadingLoginButton').hide(); - }); - - - - }); + $('#loadingLoginButton').hide(); + } + + // Try to login + Identity.login(username, password, projectname, responseCallback); + }); + }]); diff --git a/client/js/controllers/status.js b/client/js/controllers/status.js index 7425244..2930e34 100644 --- a/client/js/controllers/status.js +++ b/client/js/controllers/status.js @@ -4,7 +4,7 @@ * The status controller * * @param {$scope} $scope The $scope service from angular - * @param {sharedProfile} sharedProfile The sharedProfile build by ourself + * @param {Identity} The Identity service */ mainApp.controller('statusCtrl', ['$scope','Identity', function ($scope, Identity) { diff --git a/client/js/services/Identity.js b/client/js/services/Identity.js index 509f800..4c8919c 100644 --- a/client/js/services/Identity.js +++ b/client/js/services/Identity.js @@ -1,14 +1,42 @@ mainApp.factory('Identity',[ '$http', function($http){ - /* Create profile structure */ + /* Create profile structure to store informations + * about current session + */ var profile={}; - profile.username="Undefined"; - profile.projectname="Undefined"; - profile.token=""; + profile.username=null; + profile.projectname=null; + profile.token=null; + + + /** + * + * @param {string} response The response to parse + * @param {boolean} to check if the request is send or not + * @returns {requestParserResult} Formated data + */ + var parseLoginAnswer=function(response, failedToSendRequest){ + + var requestParserResult={}; + requestParserResult.status=1; + requestParserResult.failReason=null; + + if (typeof response.data.token !== 'undefined') { + requestParserResult.status=0; + profile.token=response.data.token; + } + else if(failedToSendRequest){ + requestParserResult.failReason="Failed to send request"; + } + else{ + requestParserResult.failReason="Please check your username, password and project name !"; + } + + return requestParserResult; + }; + - /* Will contain the result of the $http request */ - var $httpResponse; /** * Function to connect to OpenStack @@ -17,46 +45,28 @@ mainApp.factory('Identity',[ '$http', function($http){ * @param {string} username The user name * @param {string} password The user password * @param {string} projectname The user project name - * @returns {promise} The result of the request + * @param {function} function to call when data is avalaible */ - var login=function(username, password,projectname){ + var login=function(username, password,projectname, callback){ + + // Set profile information (early) profile.username=username; profile.projectname=projectname; - $httpResponse=$http.post('../server/index.php', + var result=$http.post('../server/index.php', $.param({"task" : "Authenticate", "user" : username, "password" : password, "project" : projectname})); - return $httpResponse; - }; - - /** - * - * @param {string} response The response to parse - * @returns {requestParserResult} Formated data - */ - var parseLoginAnswer=function(response){ - var requestParserResult={}; - - requestParserResult.status=0; - requestParserResult.data=response.data; - profile.token="Un Token"; - - // TODO - - - return requestParserResult; - }; - - - var getResponse=function(){ - return parseLoginAnswer($httpResponse); - } - + // Wait and handle the response + result.then(function (response){ + callback(parseLoginAnswer(response), false); + },function(response){ + callback(parseLoginAnswer(response), true) + }); + }; // Return services objects return { login: login, - getResponse: getResponse, profile: profile }; diff --git a/client/js/services/Image.js b/client/js/services/Image.js new file mode 100644 index 0000000..4cb3590 --- /dev/null +++ b/client/js/services/Image.js @@ -0,0 +1,25 @@ + +mainApp.factory('Image',[ '$http', 'Identity', function($http, Identity){ + + var httpResponse; + + var uploadImage=function(image){ + + }; + + var parseUploadImageRequest=function(){ + + }; + + var getResponse=function(){ + return parseUploadImageRequest(httpResponse); + }; + + // Return services objects + return { + uploadImage: uploadImage, + getResponse: getResponse + }; + + +}]); diff --git a/client/partials/login.html b/client/partials/login.html index e0ce876..cd7d9ec 100644 --- a/client/partials/login.html +++ b/client/partials/login.html @@ -33,9 +33,9 @@ - \ No newline at end of file + From c31c3bb28155c401d295a4bea6c43b72bbe30206 Mon Sep 17 00:00:00 2001 From: Yoggzo Date: Thu, 11 Feb 2016 17:01:37 +0100 Subject: [PATCH 27/45] move image tests file --- server/{test.php => Test/imageTests.php} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename server/{test.php => Test/imageTests.php} (100%) diff --git a/server/test.php b/server/Test/imageTests.php similarity index 100% rename from server/test.php rename to server/Test/imageTests.php From 6db5da757b5c9947106ab483e9894083a9d98e45 Mon Sep 17 00:00:00 2001 From: Yoggzo Date: Thu, 11 Feb 2016 20:06:50 +0100 Subject: [PATCH 28/45] test foireux --- server/Test/imageTests.php | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) 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 "
"; From d81a376894b526b5769a553d07487b0b46fecaa2 Mon Sep 17 00:00:00 2001 From: Yoggzo Date: Thu, 11 Feb 2016 20:38:15 +0100 Subject: [PATCH 29/45] 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(-) 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 * From ad33435ce05302c76618fa77282811ade5a53119 Mon Sep 17 00:00:00 2001 From: EoleDev Date: Fri, 12 Feb 2016 11:57:18 +0100 Subject: [PATCH 30/45] Links Correction --- server/Test/genTokenOptionsTest.php | 6 +++--- server/core/App.php | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) 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: [PATCH 31/45] 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 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; } From 294fbb4d11b9399be231bd999447f2a214e11a1f Mon Sep 17 00:00:00 2001 From: EoleDev Date: Fri, 12 Feb 2016 12:45:00 +0100 Subject: [PATCH 32/45] 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 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 From 06d229a37ecb64d1777de31d49251239a9d285d1 Mon Sep 17 00:00:00 2001 From: EoleDev Date: Fri, 12 Feb 2016 13:20:20 +0100 Subject: [PATCH 33/45] Import Correction --- server/Test/InitTest.php | 2 ++ 1 file changed, 2 insertions(+) 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: [PATCH 34/45] Identity Class first function --- server/core/Identity.php | 59 ++++++++++++++++++++++++++++++++-------- 1 file changed, 47 insertions(+), 12 deletions(-) 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); + } } From 6890283bcf2e2f0cd0aa9923a18298fada6426c1 Mon Sep 17 00:00:00 2001 From: EoleDev Date: Fri, 12 Feb 2016 18:01:18 +0100 Subject: [PATCH 35/45] 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 | 223 ++++++++++++++++++++++++++++---- 3 files changed, 211 insertions(+), 33 deletions(-) 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'); - -$credential->type = 'foo'; -$credential->blob = 'bar'; - -$credential->update(); + $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 = $type; + $credential->blob = $blob; + + $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); + } } /** From 219847749e0cb26f11c0f4231fccdcb73e919d97 Mon Sep 17 00:00:00 2001 From: EoleDev Date: Fri, 12 Feb 2016 20:03:21 +0100 Subject: [PATCH 36/45] Implementation Major Functionality --- server/core/Identity.php | 1478 +++++++++++++++++++++++++++++++++++++- 1 file changed, 1446 insertions(+), 32 deletions(-) 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,8 +898,29 @@ 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); + }*/ } /** @@ -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; From 7e5db6b5420755a76c1efcd87bf2a61b111b4c09 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Wed, 17 Feb 2016 14:01:13 +0100 Subject: [PATCH 37/45] 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 +- .../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 .../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 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 From 47e7d7d5402b3096a7554193eec10ff4b8bb2c3b Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Wed, 17 Feb 2016 14:03:21 +0100 Subject: [PATCH 38/45] Update --- server/vendor/php-opencloud/openstack | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 6f1dd0cabf5680b1ad9e6a42ba3f24ac471ae853 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Wed, 17 Feb 2016 14:13:02 +0100 Subject: [PATCH 39/45] update --- server/vendor/php-opencloud/openstack | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From a8b6e051b4a4346ec4b22e07207f8dc766833c9b Mon Sep 17 00:00:00 2001 From: EoleDev Date: Wed, 17 Feb 2016 16:53:06 +0100 Subject: [PATCH 40/45] 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 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 From e595e9adaf5ef8db3514a2093de660c2a6bea8b6 Mon Sep 17 00:00:00 2001 From: EoleDev Date: Wed, 17 Feb 2016 16:59:07 +0100 Subject: [PATCH 41/45] Add token Post --- server/init.php | 2 ++ 1 file changed, 2 insertions(+) mode change 100644 => 100755 server/init.php 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); ?> From 5ac2313bea3f186acdeeb8594542a3702e3dc305 Mon Sep 17 00:00:00 2001 From: EoleDev Date: Wed, 17 Feb 2016 17:20:38 +0100 Subject: [PATCH 42/45] 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 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 From d3047bb539a2256cf357784ff49e0ad58e638500 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Thu, 18 Feb 2016 18:06:06 +0100 Subject: [PATCH 43/45] Add compute service --- client/index.html | 3 ++- client/js/controllers/home/main.js | 4 ++-- client/js/services/Compute.js | 30 ++++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 client/js/services/Compute.js diff --git a/client/index.html b/client/index.html index 26430f9..ba183df 100644 --- a/client/index.html +++ b/client/index.html @@ -75,7 +75,8 @@ - + + diff --git a/client/js/controllers/home/main.js b/client/js/controllers/home/main.js index e629779..d42e413 100644 --- a/client/js/controllers/home/main.js +++ b/client/js/controllers/home/main.js @@ -3,8 +3,8 @@ * * @param {$scope} $scope The $scope service from angular */ -mainApp.controller('homeCtrl', function ($scope) +mainApp.controller('homeCtrl', [ '$scope', 'Compute', function ($scope, Compute) { -}); \ No newline at end of file +}]); diff --git a/client/js/services/Compute.js b/client/js/services/Compute.js new file mode 100644 index 0000000..748510e --- /dev/null +++ b/client/js/services/Compute.js @@ -0,0 +1,30 @@ + +mainApp.factory('Compute',[ '$http', 'Identity', function($http, Identity){ + + + + // Parser + var parseGetMachinesAnswer=function(response, failedToSendRequest){ + + }; + + + // Get Machine + var getMachines=function(callback){ + + var result=$http.post('../server/index.php', + $.param({"token" : Identity.profile.token, "task" : "Compute"})); + + + + }; + + + + // Return services objects + return { + getMachines: getMachines + }; + + +}]); From 0c31cbdbd4aaf41c5f24f96e1ee0ae79a8baee24 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Mon, 22 Feb 2016 17:14:11 +0100 Subject: [PATCH 44/45] Comment and update things --- client/js/services/Identity.js | 56 ++++++++-------------------------- 1 file changed, 12 insertions(+), 44 deletions(-) diff --git a/client/js/services/Identity.js b/client/js/services/Identity.js index d96b3ab..8ee664c 100644 --- a/client/js/services/Identity.js +++ b/client/js/services/Identity.js @@ -9,56 +9,18 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){ 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;i Date: Mon, 22 Feb 2016 17:30:25 +0100 Subject: [PATCH 45/45] Edit Compute service and home controller --- client/js/controllers/.#status.js | 1 - client/js/controllers/home/main.js | 9 ++++++++- client/js/controllers/status.js | 5 ++++- client/js/services/Compute.js | 14 ++++++++++++-- 4 files changed, 24 insertions(+), 5 deletions(-) delete mode 120000 client/js/controllers/.#status.js diff --git a/client/js/controllers/.#status.js b/client/js/controllers/.#status.js deleted file mode 120000 index e6c258f..0000000 --- a/client/js/controllers/.#status.js +++ /dev/null @@ -1 +0,0 @@ -loic@Manzerbredes.home.30343:1455008378 \ No newline at end of file diff --git a/client/js/controllers/home/main.js b/client/js/controllers/home/main.js index d42e413..d25bfad 100644 --- a/client/js/controllers/home/main.js +++ b/client/js/controllers/home/main.js @@ -5,6 +5,13 @@ */ mainApp.controller('homeCtrl', [ '$scope', 'Compute', function ($scope, Compute) { - + + + var updatePage=function(){ + // TODO Update graph etc... + } + + // Retrieve all Data + Compute.pullData(updatePage); }]); diff --git a/client/js/controllers/status.js b/client/js/controllers/status.js index 6bc602a..e01df34 100644 --- a/client/js/controllers/status.js +++ b/client/js/controllers/status.js @@ -8,8 +8,11 @@ */ mainApp.controller('statusCtrl', ['$scope','Identity', '$rootScope', function ($scope, Identity, $rootScope) { + + // Give profile to model $scope.profile=Identity.profile; - + + // Function to logout $scope.logout=function(){ Identity.logout(); $rootScope.$broadcast('logoutEvent'); diff --git a/client/js/services/Compute.js b/client/js/services/Compute.js index 748510e..c5c8da9 100644 --- a/client/js/services/Compute.js +++ b/client/js/services/Compute.js @@ -2,6 +2,10 @@ mainApp.factory('Compute',[ '$http', 'Identity', function($http, Identity){ + + var data={}; + data.machines={}; + // Parser var parseGetMachinesAnswer=function(response, failedToSendRequest){ @@ -13,17 +17,23 @@ mainApp.factory('Compute',[ '$http', 'Identity', function($http, Identity){ var getMachines=function(callback){ var result=$http.post('../server/index.php', - $.param({"token" : Identity.profile.token, "task" : "Compute"})); + $.param({"token" : Identity.profile.token, "task" : "Compute"})); - }; + + var pullData=function(callback){ + // TODO call getMachines etc... + } + // Return services objects return { getMachines: getMachines + pullData: pullData + data:data };