From 6e9df92ea809f55391c18bcc2de9cf2b483af5f4 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 10 Feb 2016 12:36:26 +0100 Subject: [PATCH 01/11] scripte creation de serverw --- server/create_serv.php | 55 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 server/create_serv.php diff --git a/server/create_serv.php b/server/create_serv.php new file mode 100644 index 0000000..da39842 --- /dev/null +++ b/server/create_serv.php @@ -0,0 +1,55 @@ +"admin", "password"=>"ae5or6cn", "domain"=>["id"=>"Default"]); + $options["scope"] = Array("project"=>Array("name"=>"admin", "domain"=>["id"=>"Default"])); + $options["authUrl"] = "http://148.60.11.31:5000/v3"; + $openstack = new OpenStack\OpenStack($options); + $compute=$openstack->computeV2(["region" => "RegionOne"]); + $servers = $compute->listServers(true); + foreach($servers as $server) + { + $monserv = $server; + echo $server->name."
"; + } + echo "

"; + + $images = $compute->ListImages(); + + $monim = ""; + foreach($images as $image) + { + + + $monim = $image; + echo $image->name."
"; + break; + + + + + } + + $flavors = $compute->ListFlavors(); + + echo "

"; + + $monflav = ""; + + foreach($flavors as $flavor) + { + + $monflav=$flavor; + echo $flavor->name."
"; + break; + } + + $response= $compute->createServer(array('name' => "TestOthmane2",'imageId' => $monim->id , 'flavorId'=>$monflav->id , "networks" => array + ( array("uuid"=> "251b4641-20ff-4a72-8549-1758788b51ce")))); + + + From 7e5db6b5420755a76c1efcd87bf2a61b111b4c09 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Wed, 17 Feb 2016 14:01:13 +0100 Subject: [PATCH 02/11] 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 03/11] 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 04/11] 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 05/11] 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 06/11] 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 07/11] 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 08/11] 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 09/11] 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 10/11] 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 }; From 1eff9ee90bf26127463cae0ae2cb2e1951527591 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 22 Feb 2016 23:08:38 +0100 Subject: [PATCH 11/11] display idnetwork --- server/Test/DisplayNetIds.php | 25 +++++++++++++++++++++++++ server/Test/create_network.php | 31 +++++++++++++++++++++++++++++++ server/Test/create_subnet.php | 30 ++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+) create mode 100644 server/Test/DisplayNetIds.php create mode 100644 server/Test/create_network.php create mode 100644 server/Test/create_subnet.php diff --git a/server/Test/DisplayNetIds.php b/server/Test/DisplayNetIds.php new file mode 100644 index 0000000..ade15e4 --- /dev/null +++ b/server/Test/DisplayNetIds.php @@ -0,0 +1,25 @@ +"admin", "password"=>"ae5or6cn", "domain"=>["id"=>"Default"]); + $options["scope"] = Array("project"=>Array("name"=>"admin", "domain"=>["id"=>"Default"])); + $options["authUrl"] = "http://148.60.11.31:5000/v3"; + $openstack = new OpenStack\OpenStack($options); + $networking = $openstack->networkingV2(["region"=>"RegionOne"]); + $ln = $networking->listNetworks(); + + +// affiche les id des reseaux qu on a + foreach($ln as $n) +{ +//var_dump($n); +echo $n->id; +echo "

    "; + +} + + diff --git a/server/Test/create_network.php b/server/Test/create_network.php new file mode 100644 index 0000000..c267322 --- /dev/null +++ b/server/Test/create_network.php @@ -0,0 +1,31 @@ +"admin", "password"=>"ae5or6cn", "domain"=>["id"=>"Default"]); + $options["scope"] = Array("project"=>Array("name"=>"admin", "domain"=>["id"=>"Default"])); + $options["authUrl"] = "http://148.60.11.31:5000/v3"; + $openstack = new OpenStack\OpenStack($options); + $networking = $openstack->networkingV2(["region"=>"RegionOne"]); + $ln = $networking->listNetworks(); + + + + +$op = array( + 'networks' => + array( + 'name' => 'TestOthmane', + 'shared' => true, + 'adminStateUp' => true, + )); +$array = $networking->createNetworks($op); + + + + + + diff --git a/server/Test/create_subnet.php b/server/Test/create_subnet.php new file mode 100644 index 0000000..644a77d --- /dev/null +++ b/server/Test/create_subnet.php @@ -0,0 +1,30 @@ +"admin", "password"=>"ae5or6cn", "domain"=>["id"=>"Default"]); + $options["scope"] = Array("project"=>Array("name"=>"admin", "domain"=>["id"=>"Default"])); + $options["authUrl"] = "http://148.60.11.31:5000/v3"; + $openstack = new OpenStack\OpenStack($options); + $networking = $openstack->networkingV2(["region"=>"RegionOne"]); + $ln = $networking->listNetworks(); + + + + + +$array = $networking->createSubnet(array( + 'name' => 'SubOthmane', + 'networkId' => '5f78d3c1-1f53-4be7-897b-cf3c797961e0', + 'ipVersion' => 4, + 'cidr' => '192.168.0.0/24' +)); + + + + + +