Merge branch 'develop' into Evan

This commit is contained in:
Yoggzo 2016-02-24 13:23:47 +01:00
commit fafb5eeaa4
25 changed files with 432 additions and 187 deletions

View file

@ -61,7 +61,7 @@
<!-- Include JQuery --> <!-- Include JQuery -->
<script src="./vendors/jquery/jquery-2.2.0.min.js"></script> <script src="./vendors/jquery/jquery-2.2.0.min.js"></script>
<!-- Include Bootstrap --> <!-- Include Bootstrap -->
<script src="./vendors/bootstrap/js/bootstrap.min.js"></script> <script src="./vendors/bootstrap/js/bootstrap.min.js"></script>
@ -69,12 +69,14 @@
<script src="./vendors/angularjs/angular.min.js"></script> <script src="./vendors/angularjs/angular.min.js"></script>
<script src="./vendors/angularjs/angular-route.min.js"></script> <script src="./vendors/angularjs/angular-route.min.js"></script>
<script src="./vendors/angularjs/angular-sanitize.min.js"></script> <script src="./vendors/angularjs/angular-sanitize.min.js"></script>
<script src="./vendors/angularjs/angular-cookies.min.js"></script>
<script src="./js/app.js"></script> <script src="./js/app.js"></script>
<!-- Include services --> <!-- Include services -->
<script src="./js/services/Identity.js"></script> <script src="./js/services/Identity.js"></script>
<script src="./js/services/Image.js"></script> <script src="./js/services/Image.js"></script>
<script src="./js/services/Compute.js"></script>
<!-- Include controller --> <!-- Include controller -->
<script src="./js/controllers/login.js"></script> <script src="./js/controllers/login.js"></script>
<script src="./js/controllers/status.js"></script> <script src="./js/controllers/status.js"></script>

View file

@ -3,7 +3,7 @@
* The main app module instance * The main app module instance
* @type angular.module.angular-1_3_6_L1749.moduleInstance * @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 * Configure routeProvider
@ -29,6 +29,5 @@ mainApp.config(['$routeProvider', function($routeProvider){
*/ */
mainApp.config(['$httpProvider', function($httpProvider){ mainApp.config(['$httpProvider', function($httpProvider){
$httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8'; $httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8';
}]); }]);

View file

@ -3,8 +3,15 @@
* *
* @param {$scope} $scope The $scope service from angular * @param {$scope} $scope The $scope service from angular
*/ */
mainApp.controller('homeCtrl', function ($scope) mainApp.controller('homeCtrl', [ '$scope', 'Compute', function ($scope, Compute)
{ {
var updatePage=function(){
// TODO Update graph etc...
}
// Retrieve all Data
Compute.pullData(updatePage);
}); }]);

View file

@ -9,14 +9,20 @@
*/ */
mainApp.controller('loginCtrl', ['$scope','$sce','Identity', function ($scope,$sce, Identity) mainApp.controller('loginCtrl', ['$scope','$sce','Identity', function ($scope,$sce, Identity)
{ {
// Define default states // Check for login and define default states
$('#loginModal').modal({backdrop: 'static', keyboard: false}); if(!Identity.isAlreadyLogin()){
$('#loginModal').modal({backdrop: 'static', keyboard: false});
}
$scope.$on('logoutEvent', function(){
$('#loginModal').modal({backdrop: 'static', keyboard: false});
});
$('#loadingLoginButton').hide(); $('#loadingLoginButton').hide();
$('#failedToLoginAlert').hide(); $('#failedToLoginAlert').hide();
$('#loginButton').click(function(){ $scope.loginAction=function(){
// Begin login state for template // Begin login state for template
$('#loginButton').hide(); $('#loginButton').hide();
$('#loadingLoginButton').show(); $('#loadingLoginButton').show();
@ -49,6 +55,6 @@ mainApp.controller('loginCtrl', ['$scope','$sce','Identity', function ($scope,$s
// Try to login // Try to login
Identity.login(username, password, projectname, responseCallback); Identity.login(username, password, projectname, responseCallback);
}); };
}]); }]);

View file

@ -6,9 +6,17 @@
* @param {$scope} $scope The $scope service from angular * @param {$scope} $scope The $scope service from angular
* @param {Identity} The Identity service * @param {Identity} The Identity service
*/ */
mainApp.controller('statusCtrl', ['$scope','Identity', function ($scope, Identity) mainApp.controller('statusCtrl', ['$scope','Identity', '$rootScope', function ($scope, Identity, $rootScope)
{ {
// Give profile to model
$scope.profile=Identity.profile; $scope.profile=Identity.profile;
// Function to logout
$scope.logout=function(){
Identity.logout();
$rootScope.$broadcast('logoutEvent');
};
}]); }]);

View file

@ -0,0 +1,40 @@
mainApp.factory('Compute',[ '$http', 'Identity', function($http, Identity){
var data={};
data.machines={};
// 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"}));
};
var pullData=function(callback){
// TODO call getMachines etc...
}
// Return services objects
return {
getMachines: getMachines
pullData: pullData
data:data
};
}]);

View file

@ -1,5 +1,5 @@
mainApp.factory('Identity',[ '$http', function($http){ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){
/* Create profile structure to store informations /* Create profile structure to store informations
* about current session * about current session
@ -10,6 +10,37 @@ mainApp.factory('Identity',[ '$http', function($http){
profile.token=null; profile.token=null;
/**
* Save profile in cookies
*/
var saveCookieForSession=function(){
$cookies.putObject('profile', 5);
};
/*
* @returns {boolean} Return true if a cookie is found (and load it in profile) false else
*/
var isAlreadyLogin=function(){
var profileInCookie=$cookies.getObject('profile');
console.log(profileInCookie);
if(typeof profileInCookie !== 'undefined'){
angular.extend(profile, profileInCookie);
return true;
}
return false;
}
/*
* Destroy profile cookies
*/
var logout=function(){
$cookies.remove('profile');
}
/** /**
* *
* @param {string} response The response to parse * @param {string} response The response to parse
@ -17,6 +48,7 @@ mainApp.factory('Identity',[ '$http', function($http){
* @returns {requestParserResult} Formated data * @returns {requestParserResult} Formated data
*/ */
var parseLoginAnswer=function(response, failedToSendRequest){ var parseLoginAnswer=function(response, failedToSendRequest){
var requestParserResult={}; var requestParserResult={};
requestParserResult.status=1; requestParserResult.status=1;
@ -24,7 +56,8 @@ mainApp.factory('Identity',[ '$http', function($http){
if (typeof response.data.token !== 'undefined') { if (typeof response.data.token !== 'undefined') {
requestParserResult.status=0; requestParserResult.status=0;
profile.token=response.data.token; profile.token=response.data.token;
saveCookieForSession();
} }
else if(failedToSendRequest){ else if(failedToSendRequest){
requestParserResult.failReason="Failed to send request"; requestParserResult.failReason="Failed to send request";
@ -48,7 +81,7 @@ mainApp.factory('Identity',[ '$http', function($http){
* @param {function} function to call when data is avalaible * @param {function} function to call when data is avalaible
*/ */
var login=function(username, password,projectname, callback){ var login=function(username, password,projectname, callback){
// Set profile information (early) // Set profile information (early)
profile.username=username; profile.username=username;
profile.projectname=projectname; profile.projectname=projectname;
@ -64,10 +97,14 @@ mainApp.factory('Identity',[ '$http', function($http){
}); });
}; };
// Return services objects // Return services objects
return { return {
login: login, login: login,
profile: profile profile: profile,
isAlreadyLogin: isAlreadyLogin,
logout:logout
}; };

View file

@ -1,24 +1,27 @@
mainApp.factory('Image',[ '$http', 'Identity', function($http, Identity){ mainApp.factory('Image',[ '$http', 'Identity', function($http, Identity){
var httpResponse;
var uploadImage=function(image){
var parseUploadImageAnswer=function(response, failedToSendRequest){
}; };
var parseUploadImageRequest=function(){
var getImages=function(callback){
var result=$http.post('../server/index.php',
$.param({"token" : Identity.profile.token, "task" : "Image"}));
}; };
var getResponse=function(){
return parseUploadImageRequest(httpResponse);
};
// Return services objects // Return services objects
return { return {
uploadImage: uploadImage, uploadImage: uploadImage
getResponse: getResponse
}; };

View file

@ -34,7 +34,7 @@
<!--<a href="#" data-dismiss="modal" class="btn btn-default">Close</a>--> <!--<a href="#" data-dismiss="modal" class="btn btn-default">Close</a>-->
<button class="btn btn-lg btn-warning btn-block" id="loadingLoginButton"><span class="glyphicon glyphicon-refresh glyphicon-refresh-animate"></span> Loading...</button> <button class="btn btn-lg btn-warning btn-block" id="loadingLoginButton"><span class="glyphicon glyphicon-refresh glyphicon-refresh-animate"></span> Loading...</button>
<div class="alert alert-danger text-center" role="alert" id="failedToLoginAlert"><b>Failed to login</b></b><br />{{ failReason }}</div> <div class="alert alert-danger text-center" role="alert" id="failedToLoginAlert"><b>Failed to login</b></b><br />{{ failReason }}</div>
<a href="#" class="btn btn-lg btn-primary btn-block" id="loginButton" ng-click="processForm()">Login</a> <a href="#" class="btn btn-lg btn-primary btn-block" id="loginButton" ng-click="loginAction()">Login</a>
</div> </div>
</div> </div>
</div> </div>

View file

@ -32,8 +32,7 @@
<li><a href="#">Informations</a></li> <li><a href="#">Informations</a></li>
<li><a href="#">Settings</a></li> <li><a href="#">Settings</a></li>
<li role="separator" class="divider"></li> <li role="separator" class="divider"></li>
<li><a href="#myModal" data-toggle="modal">Logout</a> <li><a href="#" ng-click="logout()">Logout</a></li>
</li>
</ul> </ul>
</li> </li>
</ul> </ul>

View file

@ -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<f&&a.warn("Cookie '"+b+"' possibly not set or overflowed because it was too large ("+
f+" > 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

View file

@ -0,0 +1,25 @@
<?php
ini_set('display_errors', 1);
date_default_timezone_set("Europe/Paris");
require 'vendor/autoload.php';
$options = Array();
$options["user"] = Array("name"=>"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 "<br><br>";
}

View file

@ -0,0 +1,31 @@
<?php
ini_set('display_errors', 1);
date_default_timezone_set("Europe/Paris");
require 'vendor/autoload.php';
$options = Array();
$options["user"] = Array("name"=>"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);

View file

@ -0,0 +1,30 @@
<?php
ini_set('display_errors', 1);
date_default_timezone_set("Europe/Paris");
require 'vendor/autoload.php';
$options = Array();
$options["user"] = Array("name"=>"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'
));

0
server/Test/genTokenOptionsTest.php Executable file → Normal file
View file

0
server/composer.phar Executable file → Normal file
View file

0
server/core/App.php Executable file → Normal file
View file

0
server/core/CoreInterface.php Executable file → Normal file
View file

View file

@ -25,9 +25,6 @@ class identity implements Core{
/** @var OpenStack\Identity $libClass protected, contains the library Identity object */ /** @var OpenStack\Identity $libClass protected, contains the library Identity object */
protected $libClass; protected $libClass;
/** @var array $actions protected, contains the functions which can be call by the front-end */
protected $actions = array();
/** /**
* identity constructor * identity constructor
@ -44,9 +41,19 @@ class identity implements Core{
$this->libClass = $app->getLibClass("Identity"); $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. * Add a credential for the given user/project.
* *
@ -60,7 +67,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$credentials["addCredential"] = function(){ private function addCredential(){
$blob = $this->app->getPostParam("blob"); $blob = $this->app->getPostParam("blob");
$projectId = $this->app->getPostParam("projectId"); $projectId = $this->app->getPostParam("projectId");
@ -96,7 +103,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$credentials["listCredentials"] = function(){ private function listCredentials(){
try{ try{
$this->libClass->listCredentials() $this->libClass->listCredentials()
@ -122,7 +129,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$credentials["showCredential"] = function(){ private function showCredential(){
$credentId = $this->app->getPostParam("credentialId"); $credentId = $this->app->getPostParam("credentialId");
if(!isset($credentId)){ if(!isset($credentId)){
@ -157,7 +164,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$credentials["updateCredential"] = function(){ private function updateCredential(){
$credentId = $this->app->getPostParam("credentialId"); $credentId = $this->app->getPostParam("credentialId");
$blob = $this->app->getPostParam("blob"); $blob = $this->app->getPostParam("blob");
@ -197,7 +204,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$credentials["deleteCredential"] = function(){ private function deleteCredential(){
$credentId = $this->app->getPostParam("credentialId"); $credentId = $this->app->getPostParam("credentialId");
@ -223,8 +230,6 @@ class identity implements Core{
} }
}- }-
$domains = array();
/** /**
* Add a domain to an OpenStack instance. * Add a domain to an OpenStack instance.
* *
@ -234,7 +239,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$domains["addDomain"] = function(){ private function addDomain(){
$description = $this->app->getPostParam("desc"); $description = $this->app->getPostParam("desc");
$enabled = $this->app->getPostParam("enabled"); $enabled = $this->app->getPostParam("enabled");
@ -277,7 +282,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$domains["listDomains"] = function(){ private function listDomains(){
try{ try{
@ -304,7 +309,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$domains["showDomain"] = function(){ private function showDomain(){
$domId = $this->app->getPostParam("domainId"); $domId = $this->app->getPostParam("domainId");
@ -340,7 +345,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$domains["updateDomain"] = function(){ private function updateDomain(){
$domId = $this->app->getPostParam("domainId"); $domId = $this->app->getPostParam("domainId");
$description = $this->app->getPostParam("desc"); $description = $this->app->getPostParam("desc");
@ -386,7 +391,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$domains["deleteDomain"] = function(){ private function deleteDomain(){
$domId = $this->app->getPostParam("domainId"); $domId = $this->app->getPostParam("domainId");
@ -419,7 +424,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$domains["listRolesDomainUser"] = function(){ private function listRolesDomainUser(){
$domId = $this->app->getPostParam("domainId"); $domId = $this->app->getPostParam("domainId");
$userId = $this->app->getPostParam("userId"); $userId = $this->app->getPostParam("userId");
@ -454,7 +459,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$domains["grantRoleDomainUser"] = function(){ private function grantRoleDomainUser(){
$domId = $this->app->getPostParam("domainId"); $domId = $this->app->getPostParam("domainId");
$roleId = $this->app->getPostParam("roleId"); $roleId = $this->app->getPostParam("roleId");
$userId = $this->app->getPostParam("userId"); $userId = $this->app->getPostParam("userId");
@ -492,7 +497,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$domains["checkRoleDomainUser"] = function(){ private function checkRoleDomainUser(){
$domId = $this->app->getPostParam("domainId"); $domId = $this->app->getPostParam("domainId");
$roleId = $this->app->getPostParam("roleId"); $roleId = $this->app->getPostParam("roleId");
$userId = $this->app->getPostParam("userId"); $userId = $this->app->getPostParam("userId");
@ -531,7 +536,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$domains["revokeRoleDomainUser"] = function(){ private function revokeRoleDomainUser(){
$domId = $this->app->getPostParam("domainId"); $domId = $this->app->getPostParam("domainId");
$roleId = $this->app->getPostParam("roleId"); $roleId = $this->app->getPostParam("roleId");
$userId = $this->app->getPostParam("userId"); $userId = $this->app->getPostParam("userId");
@ -569,7 +574,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$domains["listRolesDomainGroup"] = function(){ private function listRolesDomainGroup(){
$domId = $this->app->getPostParam("domainId"); $domId = $this->app->getPostParam("domainId");
$groupId = $this->app->getPostParam("groupId"); $groupId = $this->app->getPostParam("groupId");
@ -604,7 +609,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$domains["grantRoleDomainGroup"] = function(){ private function grantRoleDomainGroup(){
$domId = $this->app->getPostParam("domainId"); $domId = $this->app->getPostParam("domainId");
$groupId = $this->app->getPostParam("groupId"); $groupId = $this->app->getPostParam("groupId");
$roleId = $this->app->getPostParam("roleId"); $roleId = $this->app->getPostParam("roleId");
@ -642,7 +647,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$domains["checkRoleDomainGroup"] = function(){ private function checkRoleDomainGroup(){
$domId = $this->app->getPostParam("domainId"); $domId = $this->app->getPostParam("domainId");
$groupId = $this->app->getPostParam("groupId"); $groupId = $this->app->getPostParam("groupId");
$roleId = $this->app->getPostParam("roleId"); $roleId = $this->app->getPostParam("roleId");
@ -687,7 +692,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$domains["revokeRoleDomainGroup"] = function(){ private function revokeRoleDomainGroup(){
$domId = $this->app->getPostParam("domainId"); $domId = $this->app->getPostParam("domainId");
$groupId = $this->app->getPostParam("groupId"); $groupId = $this->app->getPostParam("groupId");
$roleId = $this->app->getPostParam("roleId"); $roleId = $this->app->getPostParam("roleId");
@ -719,8 +724,6 @@ class identity implements Core{
} }
} }
$endpoints = array();
/** /**
* Add an endpoint to the Openstack instance * Add an endpoint to the Openstack instance
* *
@ -728,7 +731,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$endpoints["addEndpoint"] = function(){ private function addEndpoint(){
$servId = $this->app->getPostParam("serviceId"); $servId = $this->app->getPostParam("serviceId");
$name = $this->app->getPostParam("name"); $name = $this->app->getPostParam("name");
$region = $this->app->getPostParam("region"); $region = $this->app->getPostParam("region");
@ -768,7 +771,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$endpoints["getEndpoint"] = function(){ private function getEndpoint(){
$endId = $this->app->getPostParam("endpointId"); $endId = $this->app->getPostParam("endpointId");
@ -798,7 +801,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$endpoints["listEndpoints"] = function(){ private function listEndpoints(){
try{ try{
@ -824,7 +827,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$endpoints["updateEndpoint"] = function(){ private function updateEndpoint(){
//Not Implemented Yet //Not Implemented Yet
/*$domId = $this->app->getPostParam("domainId"); /*$domId = $this->app->getPostParam("domainId");
@ -863,7 +866,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$endpoints["deleteEndpoint"] = function(){ private function deleteEndpoint(){
$endId = $this->app->getPostParam("endpointId"); $endId = $this->app->getPostParam("endpointId");
if(!isset($endId)){ if(!isset($endId)){
@ -888,8 +891,6 @@ class identity implements Core{
} }
} }
$groups = array();
/** /**
* Add a group. * Add a group.
* *
@ -897,7 +898,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$groups["addGroup"] = function(){ private function addGroup(){
//Not Implemented Yet //Not Implemented Yet
/*$domId = $this->app->getPostParam("domainId"); /*$domId = $this->app->getPostParam("domainId");
@ -930,7 +931,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$groups["listGroups"] = function(){ private function listGroups(){
//Not Implemented Yet //Not Implemented Yet
/* /*
$domId = $this->app->getPostParam("domainId"); $domId = $this->app->getPostParam("domainId");
@ -963,7 +964,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$groups["showGroup"] = function(){ private function showGroup(){
//Not Implemented Yet //Not Implemented Yet
/* /*
@ -997,7 +998,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$groups["updateGroup"] = function(){ private function updateGroup(){
//Todo Argument Optional //Todo Argument Optional
$groupId = $this->app->getPostParam("groupId"); $groupId = $this->app->getPostParam("groupId");
$description = $this->app->getPostParam("description"); $description = $this->app->getPostParam("description");
@ -1038,7 +1039,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$groups["deleteGroup"] = function(){ private function deleteGroup(){
$groupId = $this->app->getPostParam("groupId"); $groupId = $this->app->getPostParam("groupId");
@ -1072,7 +1073,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$groups["listGroupUsers"] = function(){ private function listGroupUsers(){
$groupId = $this->app->getPostParam("groupId"); $groupId = $this->app->getPostParam("groupId");
@ -1106,7 +1107,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$groups["addGroupUser"] = function(){ private function addGroupUser(){
$userId = $this->app->getPostParam("userId"); $userId = $this->app->getPostParam("userId");
$groupId = $this->app->getPostParam("groupId"); $groupId = $this->app->getPostParam("groupId");
@ -1141,7 +1142,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$groups["removeGroupUser"] = function(){ private function removeGroupUser(){
$userId = $this->app->getPostParam("userId"); $userId = $this->app->getPostParam("userId");
$groupId = $this->app->getPostParam("groupId"); $groupId = $this->app->getPostParam("groupId");
@ -1176,7 +1177,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$groups["checkGroupUser"] = function(){ private function checkGroupUser(){
$userId = $this->app->getPostParam("userId"); $userId = $this->app->getPostParam("userId");
$groupId = $this->app->getPostParam("groupId"); $groupId = $this->app->getPostParam("groupId");
@ -1204,8 +1205,6 @@ class identity implements Core{
} }
} }
$policies = array();
/** /**
* @todo * @todo
* *
@ -1213,7 +1212,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$policies["addPolicies"] = function(){ private function addPolicies(){
//Not Implemented Yet //Not Implemented Yet
/* /*
$domId = $this->app->getPostParam("domainId"); $domId = $this->app->getPostParam("domainId");
@ -1246,7 +1245,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$policies["listPolicies"] = function(){ private function listPolicies(){
//Not Implemented Yet //Not Implemented Yet
/* /*
$domId = $this->app->getPostParam("domainId"); $domId = $this->app->getPostParam("domainId");
@ -1279,7 +1278,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$policies["showPolicie"] = function(){ private function showPolicie(){
//Not Implemented Yet //Not Implemented Yet
/* /*
$domId = $this->app->getPostParam("domainId"); $domId = $this->app->getPostParam("domainId");
@ -1313,7 +1312,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$policies["updatePolicies"] = function(){ private function updatePolicies(){
//Not Implemented Yet //Not Implemented Yet
/* /*
$domId = $this->app->getPostParam("domainId"); $domId = $this->app->getPostParam("domainId");
@ -1346,7 +1345,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$policies["deletePolicies"] = function(){ private function deletePolicies(){
//Not Implemented Yet //Not Implemented Yet
/* /*
$domId = $this->app->getPostParam("domainId"); $domId = $this->app->getPostParam("domainId");
@ -1372,8 +1371,6 @@ class identity implements Core{
}*/ }*/
} }
$projects = array();
/** /**
* Add a project. * Add a project.
* *
@ -1381,7 +1378,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$projects["addProject"] = function(){ private function addProject(){
//Todo Parameters Optional //Todo Parameters Optional
$description = $this->app->getPostParam("description"); $description = $this->app->getPostParam("description");
$name = $this->app->getPostParam("name"); $name = $this->app->getPostParam("name");
@ -1416,7 +1413,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$projects["listProjects"] = function(){ private function listProjects(){
try{ try{
@ -1442,7 +1439,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$projects["showProject"] = function(){ private function showProject(){
$projId = $this->app->getPostParam("projetId"); $projId = $this->app->getPostParam("projetId");
@ -1475,7 +1472,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$projects["updateProject"] = function(){ private function updateProject(){
//Todo Parameters Optionnal //Todo Parameters Optionnal
$description = $this->app->getPostParam("description"); $description = $this->app->getPostParam("description");
$name = $this->app->getPostParam("name"); $name = $this->app->getPostParam("name");
@ -1515,7 +1512,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$projects["deleteProject"] = function(){ private function deleteProject(){
$projId = $this->app->getPostParam("projId"); $projId = $this->app->getPostParam("projId");
if(!isset($projId)){ if(!isset($projId)){
@ -1548,7 +1545,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$projects["listRolesProjectUser"] = function(){ private function listRolesProjectUser(){
$projId = $this->app->getPostParam("projetId"); $projId = $this->app->getPostParam("projetId");
$userId = $this->app->getPostParam("userId"); $userId = $this->app->getPostParam("userId");
@ -1583,7 +1580,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$projects["grantRoleProjectUser"] = function(){ private function grantRoleProjectUser(){
$projId = $this->app->getPostParam("projId"); $projId = $this->app->getPostParam("projId");
$userId = $this->app->getPostParam("userId"); $userId = $this->app->getPostParam("userId");
@ -1622,7 +1619,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$projects["checkRoleProjectUser"] = function(){ private function checkRoleProjectUser(){
$projId = $this->app->getPostParam("projetId"); $projId = $this->app->getPostParam("projetId");
$userId = $this->app->getPostParam("userId"); $userId = $this->app->getPostParam("userId");
$roleId = $this->app->getPostParam("roleId"); $roleId = $this->app->getPostParam("roleId");
@ -1663,7 +1660,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$projects["revokeRoleProjectUser"] = function(){ private function revokeRoleProjectUser(){
$projId = $this->app->getPostParam("projetId"); $projId = $this->app->getPostParam("projetId");
$userId = $this->app->getPostParam("userId"); $userId = $this->app->getPostParam("userId");
@ -1702,7 +1699,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$projects["listRolesProjectGroup"] = function(){ private function listRolesProjectGroup(){
$projId = $this->app->getPostParam("projetId"); $projId = $this->app->getPostParam("projetId");
$groupId = $this->app->getPostParam("groupId"); $groupId = $this->app->getPostParam("groupId");
@ -1738,7 +1735,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$projects["grantRoleProjectGroup"] = function(){ private function grantRoleProjectGroup(){
$projId = $this->app->getPostParam("projetId"); $projId = $this->app->getPostParam("projetId");
$userId = $this->app->getPostParam("userId"); $userId = $this->app->getPostParam("userId");
@ -1777,7 +1774,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$projects["checkRoleProjectGroup"] = function(){ private function checkRoleProjectGroup(){
$projId = $this->app->getPostParam("projetId"); $projId = $this->app->getPostParam("projetId");
$userId = $this->app->getPostParam("userId"); $userId = $this->app->getPostParam("userId");
@ -1818,7 +1815,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$projects["revokeRoleProjectGroup"] = function(){ private function revokeRoleProjectGroup(){
$projId = $this->app->getPostParam("projetId"); $projId = $this->app->getPostParam("projetId");
$userId = $this->app->getPostParam("userId"); $userId = $this->app->getPostParam("userId");
@ -1850,8 +1847,6 @@ class identity implements Core{
} }
} }
$roles = array();
/** /**
* Add a role. * Add a role.
* *
@ -1859,7 +1854,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$roles["addRole"] = function(){ private function addRole(){
$name = $this->app->getPostParam("name"); $name = $this->app->getPostParam("name");
@ -1891,7 +1886,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$roles["listRoles"] = function(){ private function listRoles(){
try{ try{
@ -1915,7 +1910,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$roles["listRoleAssignements"] = function(){ private function listRoleAssignements(){
try{ try{
@ -1934,8 +1929,6 @@ class identity implements Core{
} }
} }
$services = array();
/** /**
* Add a service. * Add a service.
* *
@ -1943,7 +1936,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$services["addService"] = function(){ private function addService(){
$name = $this->app->getPostParam("name"); $name = $this->app->getPostParam("name");
$type = $this->app->getPostParam("type"); $type = $this->app->getPostParam("type");
@ -1976,7 +1969,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$services["listServices"] = function(){ private function listServices(){
try{ try{
@ -2002,7 +1995,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$services["showService"] = function(){ private function showService(){
$servId = $this->app->getPostParam("serviceId"); $servId = $this->app->getPostParam("serviceId");
if(!isset($servId)){ if(!isset($servId)){
@ -2033,7 +2026,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$services["deleteService"] = function(){ private function deleteService(){
$servId = $this->app->getPostParam("serviceId"); $servId = $this->app->getPostParam("serviceId");
$groupId = $this->app->getPostParam("groupId"); $groupId = $this->app->getPostParam("groupId");
@ -2060,8 +2053,6 @@ class identity implements Core{
} }
} }
$tokens = array();
/** /**
* Generate a new token for a given user id. * Generate a new token for a given user id.
* *
@ -2069,7 +2060,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$tokens["genTokenUserID"] = function(){ private function genTokenUserID(){
$userId = $this->app->getPostParam("userId"); $userId = $this->app->getPostParam("userId");
$userPass = $this->app->getPostParam("userPassword"); $userPass = $this->app->getPostParam("userPassword");
@ -2107,7 +2098,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$tokens["genTokenUserName"] = function(){ private function genTokenUserName(){
$username = $this->app->getPostParam("username"); $username = $this->app->getPostParam("username");
$userPass = $this->app->getPostParam("userPassword"); $userPass = $this->app->getPostParam("userPassword");
$domId = $this->app->getPostParam("domainId"); $domId = $this->app->getPostParam("domainId");
@ -2149,7 +2140,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$tokens["geneTokenID"] = function(){ private function genTokenID(){
$tokenId = $this->app->getPostParam("tokenId"); $tokenId = $this->app->getPostParam("tokenId");
$projectId = $this->app->getPostParam("projectId"); $projectId = $this->app->getPostParam("projectId");
@ -2185,7 +2176,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$tokens["genTokenScopedProjectID"] = function(){ private function genTokenScopedProjectID(){
$userId = $this->app->getPostParam("userId"); $userId = $this->app->getPostParam("userId");
$userPass = $this->app->getPostParam("userPass"); $userPass = $this->app->getPostParam("userPass");
@ -2227,7 +2218,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$tokens["genTokenScopedProjectName"] = function(){ private function genTokenScopedProjectName(){
$userId = $this->app->getPostParam("userId"); $userId = $this->app->getPostParam("userId");
$userPass = $this->app->getPostParam("userPass"); $userPass = $this->app->getPostParam("userPass");
@ -2275,7 +2266,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$tokens["validateToken"] = function(){ private function validateToken(){
$tokenId = $this->app->getPostParam("tokenId"); $tokenId = $this->app->getPostParam("tokenId");
@ -2311,7 +2302,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$tokens["revokeToken"] = function(){ private function revokeToken(){
$tokenId = $this->app->getPostParam("tokenId"); $tokenId = $this->app->getPostParam("tokenId");
@ -2336,8 +2327,6 @@ class identity implements Core{
} }
} }
$users = array();
/** /**
* Add a new user. * Add a new user.
* *
@ -2345,7 +2334,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$users["addUser"] = function(){ private function addUser(){
//Todo Optionnal Parameter //Todo Optionnal Parameter
$projId = $this->app->getPostParam("projId"); $projId = $this->app->getPostParam("projId");
$desc = $this->app->getPostParam("description"); $desc = $this->app->getPostParam("description");
@ -2388,7 +2377,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$users["listUsers"] = function(){ private function listUsers(){
try{ try{
@ -2414,7 +2403,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$users["showUser"] = function(){ private function showUser(){
$userId = $this->app->getPostParam("userId"); $userId = $this->app->getPostParam("userId");
@ -2447,7 +2436,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$users["updateUser"] = function(){ private function updateUser(){
$userId = $this->app->getPostParam("userId"); $userId = $this->app->getPostParam("userId");
$desc = $this->app->getPostParam("description"); $desc = $this->app->getPostParam("description");
@ -2486,7 +2475,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$users["deleteUser"] = function(){ private function deleteUser(){
$userId = $this->app->getPostParam("userId"); $userId = $this->app->getPostParam("userId");
@ -2519,7 +2508,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$users["listUserGroups"] = function(){ private function listUserGroups(){
$userId = $this->app->getPostParam("userId"); $userId = $this->app->getPostParam("userId");
@ -2553,7 +2542,7 @@ class identity implements Core{
* *
* @return void * @return void
*/ */
$users["listUserProjects"] = function(){ private function listUserProjects(){
$userId = $this->app->getPostParam("userId"); $userId = $this->app->getPostParam("userId");
@ -2579,15 +2568,4 @@ class identity implements Core{
$this->app->getErrorInstance->NotImplementedHandler($e); $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;
} }

115
server/core/LibOverride/genTokenOptions.php Executable file → Normal file
View file

@ -70,7 +70,7 @@ class genTokenOptions
'base_uri' => Utils::normalizeUrl($baseUrl), 'base_uri' => Utils::normalizeUrl($baseUrl),
'handler' => $stack, 'handler' => $stack,
]); ]);
$this->backup['Identity'] = array('token' => $this->serializeToken($token), 'baseUrl' => $baseUrl ); $this->saveBackup('Identity', array('token' => $token, 'baseUrl' => $baseUrl ));
$this->optionsGlobal['Identity'] = $options; $this->optionsGlobal['Identity'] = $options;
} }
@ -95,7 +95,7 @@ class genTokenOptions
'base_uri' => Utils::normalizeUrl($baseUrl), 'base_uri' => Utils::normalizeUrl($baseUrl),
'handler' => $stack, 'handler' => $stack,
]); ]);
$this->backup['Identity'] = array('token' => $this->serializeToken($token), 'baseUrl' => $baseUrl ); $this->saveBackup('Identity', array('token' => $token, 'baseUrl' => $baseUrl ));
$this->optionsGlobal['Identity'] = $options; $this->optionsGlobal['Identity'] = $options;
} }
@ -118,7 +118,7 @@ class genTokenOptions
'base_uri' => Utils::normalizeUrl($baseUrl), 'base_uri' => Utils::normalizeUrl($baseUrl),
'handler' => $stack, 'handler' => $stack,
]); ]);
$this->backup['Image'] = array('token' => $this->serializeToken($token), 'baseUrl' => $baseUrl ); $this->saveBackup('Image', array('token' => $token, 'baseUrl' => $baseUrl ));
$this->optionsGlobal['Image'] = $options; $this->optionsGlobal['Image'] = $options;
} }
@ -143,7 +143,7 @@ class genTokenOptions
'base_uri' => Utils::normalizeUrl($baseUrl), 'base_uri' => Utils::normalizeUrl($baseUrl),
'handler' => $stack, 'handler' => $stack,
]); ]);
$this->backup['Image'] = array('token' => $this->serializeToken($token), 'baseUrl' => $baseUrl ); $this->saveBackup('Image', array('token' => $token, 'baseUrl' => $baseUrl ));
$this->optionsGlobal['Image'] = $options; $this->optionsGlobal['Image'] = $options;
} }
@ -165,7 +165,7 @@ class genTokenOptions
'base_uri' => Utils::normalizeUrl($baseUrl), 'base_uri' => Utils::normalizeUrl($baseUrl),
'handler' => $stack, 'handler' => $stack,
]); ]);
$this->backup['Network'] = array('token' => $this->serializeToken($token), 'baseUrl' => $baseUrl ); $this->saveBackup('Network', array('token' => $token, 'baseUrl' => $baseUrl ));
$this->optionsGlobal['Network'] = $options; $this->optionsGlobal['Network'] = $options;
} }
@ -190,7 +190,7 @@ class genTokenOptions
'base_uri' => Utils::normalizeUrl($baseUrl), 'base_uri' => Utils::normalizeUrl($baseUrl),
'handler' => $stack, 'handler' => $stack,
]); ]);
$this->backup['Network'] = array('token' => $this->serializeToken($token), 'baseUrl' => $baseUrl ); $this->saveBackup('Network', array('token' => $token, 'baseUrl' => $baseUrl ));
$this->optionsGlobal['Network'] = $options; $this->optionsGlobal['Network'] = $options;
} }
@ -212,7 +212,7 @@ class genTokenOptions
'base_uri' => Utils::normalizeUrl($baseUrl), 'base_uri' => Utils::normalizeUrl($baseUrl),
'handler' => $stack, 'handler' => $stack,
]); ]);
$this->backup['Compute'] = array('token' => $this->serializeToken($token), 'baseUrl' => $baseUrl ); $this->saveBackup('Compute', array('token' => $token, 'baseUrl' => $baseUrl ));
$this->optionsGlobal['Compute'] = $options; $this->optionsGlobal['Compute'] = $options;
} }
@ -238,10 +238,21 @@ class genTokenOptions
'base_uri' => Utils::normalizeUrl($baseUrl), 'base_uri' => Utils::normalizeUrl($baseUrl),
'handler' => $stack, 'handler' => $stack,
]); ]);
$this->backup['Compute'] = array('token' => $this->serializeToken($token), 'baseUrl' => $baseUrl ); $this->saveBackup('Compute', array('token' => $token, 'baseUrl' => $baseUrl ));
$this->optionsGlobal['Compute'] = $options; $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(){ public function getBackup(){
return serialize($this->backup); return serialize($this->backup);
} }
@ -249,6 +260,9 @@ class genTokenOptions
public function loadBackup($back){ public function loadBackup($back){
$backup = unserialize($back); $backup = unserialize($back);
$this->backup["roles"] = $backup["roles"];
$this->backup["project"] = $backup["project"];
$this->backup["user"] = $backup["user"];
loadComputeBackup($backup["Compute"]); loadComputeBackup($backup["Compute"]);
loadIdentityBackup($backup["Identity"]); loadIdentityBackup($backup["Identity"]);
loadImageBackup($backup["Image"]); loadImageBackup($backup["Image"]);
@ -262,7 +276,7 @@ class genTokenOptions
private function serializeToken($token){ private function serializeToken($token){
$tokenSerialized = []; $tokenSerialized = [];
$tokenSerialized["methods"] = serialize($token->methods); $tokenSerialized["token"]["methods"] = serialize($token->methods);
$tokenSerialized["roles"] = []; $tokenSerialized["roles"] = [];
foreach($token->roles as $role){ foreach($token->roles as $role){
@ -270,30 +284,30 @@ class genTokenOptions
$tokenSerialized["roles"][serialize($role->id)]["name"] = serialize($role->name); $tokenSerialized["roles"][serialize($role->id)]["name"] = serialize($role->name);
} }
$tokenSerialized["expires"] = serialize($token->expires); $tokenSerialized["token"]["expires"] = serialize($token->expires);
$tokenSerialized["project"]["domainId"] = serialize($token->project->domainId); $tokenSerialized['saved']["project"]["domainId"] = serialize($token->project->domainId);
$tokenSerialized["project"]["parentId"] = serialize($token->project->parentId); $tokenSerialized['saved']["project"]["parentId"] = serialize($token->project->parentId);
$tokenSerialized["project"]["enabled"] = serialize($token->project->enabled); $tokenSerialized['saved']["project"]["enabled"] = serialize($token->project->enabled);
$tokenSerialized["project"]["description"] = serialize($token->project->description); $tokenSerialized['saved']["project"]["description"] = serialize($token->project->description);
$tokenSerialized["project"]["id"] = serialize($token->project->id); $tokenSerialized['saved']["project"]["id"] = serialize($token->project->id);
$tokenSerialized["project"]["links"] = serialize($token->project->links); $tokenSerialized['saved']["project"]["links"] = serialize($token->project->links);
$tokenSerialized["project"]["name"] = serialize($token->project->name); $tokenSerialized['saved']["project"]["name"] = $token->project->name;
foreach($token->catalog->services as $service){ foreach($token->catalog->services as $service){
$tokenSerialized["catalog"][serialize($service->id)]["name"] = serialize($service->name); $tokenSerialized['saved']["catalog"][serialize($service->id)]["name"] = serialize($service->name);
$tokenSerialized["catalog"][serialize($service->id)]["description"] = serialize($service->description); $tokenSerialized['saved']["catalog"][serialize($service->id)]["description"] = serialize($service->description);
$tokenSerialized["catalog"][serialize($service->id)]["type"] = serialize($service->type); $tokenSerialized['saved']["catalog"][serialize($service->id)]["type"] = serialize($service->type);
foreach($service->endpoints as $end){ foreach($service->endpoints as $end){
$tokenSerialized["catalog"][serialize($service->id)]["endpoints"][serialize($end->id)]["interface"] = serialize($end->interface); $tokenSerialized['saved']["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['saved']["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['saved']["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['saved']["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['saved']["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)]["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"]["domainId"] = serialize($token->user->domainId);
$tokenSerialized["user"]["defaultProjectId"] = serialize($token->user->defaultProjectId); $tokenSerialized["user"]["defaultProjectId"] = serialize($token->user->defaultProjectId);
$tokenSerialized["user"]["id"] = serialize($token->user->id); $tokenSerialized["user"]["id"] = serialize($token->user->id);
@ -302,42 +316,42 @@ class genTokenOptions
$tokenSerialized["user"]["description"] = serialize($token->user->description); $tokenSerialized["user"]["description"] = serialize($token->user->description);
$tokenSerialized["user"]["links"] = serialize($token->user->links); $tokenSerialized["user"]["links"] = serialize($token->user->links);
$tokenSerialized["user"]["name"] = serialize($token->user->name); $tokenSerialized["user"]["name"] = serialize($token->user->name);
$tokenSerialized["issued"] = serialize($token->issued); $tokenSerialized["token"]["issued"] = serialize($token->issued);
$tokenSerialized["id"] = serialize($token->id); $tokenSerialized["token"]["id"] = serialize($token->id);
return $tokenSerialized; return $tokenSerialized;
} }
private function unserializeToken($tokenSerialized){ private function unserializeToken($tokenSerialized){
$Saved = file_get_contents("core/LibOverride/projectTokenData/".$this->backup["project"]);
$api = new Api(); $api = new Api();
$token = new Models\Token($this->httpClient, $api); $token = new Models\Token($this->httpClient, $api);
$token->methods = unserialize($tokenSerialized["methods"]); $token->methods = unserialize($tokenSerialized["methods"]);
$token->roles = []; $token->roles = [];
foreach($tokenSerialized["roles"] as $key => $role){ foreach($this->backup["roles"] as $key => $role){
$tmp = new Models\Role($this->httpClient, $api); $tmp = new Models\Role($this->httpClient, $api);
$tmp->id = unserialize($key); $tmp->id = unserialize($key);
$tmp->links = unserialize($role["links"]); $tmp->links = unserialize($role["links"]);
if(isset($role["name"])) $tmp->name = unserialize($role["name"]);
$tmp->name = unserialize($role["name"]);
$token->roles[] = $tmp; $token->roles[] = $tmp;
} }
$token->expires = unserialize($tokenSerialized["expires"]); $token->expires = unserialize($tokenSerialized["expires"]);
$token->project = new Models\Project($this->httpClient, $api); $token->project = new Models\Project($this->httpClient, $api);
$token->project->domainId = unserialize($tokenSerialized["project"]["domainId"]); $token->project->domainId = unserialize($Saved["project"]["domainId"]);
$token->project->parentId = unserialize($tokenSerialized["project"]["parentId"]); $token->project->parentId = unserialize($Saved["project"]["parentId"]);
$token->project->enabled = unserialize($tokenSerialized["project"]["enabled"]); $token->project->enabled = unserialize($Saved["project"]["enabled"]);
$token->project->description = unserialize($tokenSerialized["project"]["description"]); $token->project->description = unserialize($Saved["project"]["description"]);
$token->project->id = unserialize($tokenSerialized["project"]["id"]); $token->project->id = unserialize($Saved["project"]["id"]);
$token->project->links = unserialize($tokenSerialized["project"]["links"]); $token->project->links = unserialize($Saved["project"]["links"]);
$token->project->name = unserialize($tokenSerialized["project"]["name"]); $token->project->name = $Saved["project"]["name"];
$token->catalog = new Models\Catalog($this->httpClient, $api); $token->catalog = new Models\Catalog($this->httpClient, $api);
$token->catalog->services = []; $token->catalog->services = [];
foreach($tokenSerialized["catalog"] as $key => $service){ foreach($Saved["catalog"] as $key => $service){
$tmp = new Models\Service($this->httpClient, $api); $tmp = new Models\Service($this->httpClient, $api);
$tmp->id = unserialize($key); $tmp->id = unserialize($key);
@ -356,21 +370,20 @@ class genTokenOptions
$tmpEnd->url = unserialize($end["url"]); $tmpEnd->url = unserialize($end["url"]);
$tmp->endpoints[] = $tmpEnd; $tmp->endpoints[] = $tmpEnd;
} }
if(isset($service["links"])) $tmp->links = unserialize($service["links"]);
$tmp->links = unserialize($service["links"]);
$token->catalog->services[] = $tmp; $token->catalog->services[] = $tmp;
} }
$token->extras = unserialize($tokenSerialized["extras"]); $token->extras = unserialize($tokenSerialized["extras"]);
$token->user = new Models\User($this->httpClient, $api); $token->user = new Models\User($this->httpClient, $api);
$token->user->domainId = unserialize($tokenSerialized["user"]["domainId"]); $token->user->domainId = unserialize($this->backup["user"]["domainId"]);
$token->user->defaultProjectId = unserialize($tokenSerialized["user"]["defaultProjectId"]); $token->user->defaultProjectId = unserialize($this->backup["user"]["defaultProjectId"]);
$token->user->id = unserialize($tokenSerialized["user"]["id"]); $token->user->id = unserialize($this->backup["user"]["id"]);
$token->user->email = unserialize($tokenSerialized["user"]["email"]); $token->user->email = unserialize($this->backup["user"]["email"]);
$token->user->enabled = unserialize($tokenSerialized["user"]["enabled"]); $token->user->enabled = unserialize($this->backup["user"]["enabled"]);
$token->user->links = unserialize($tokenSerialized["user"]["links"]); $token->user->links = unserialize($this->backup["user"]["links"]);
$token->user->name = unserialize($tokenSerialized["user"]["name"]); $token->user->name = unserialize($this->backup["user"]["name"]);
$token->user->description = unserialize($tokenSerialized["user"]["description"]); $token->user->description = unserialize($this->backup["user"]["description"]);
$token->issued = unserialize($tokenSerialized["issued"]); $token->issued = unserialize($tokenSerialized["issued"]);
$token->id = unserialize($tokenSerialized["id"]); $token->id = unserialize($tokenSerialized["id"]);

View file

@ -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;";}}}

55
server/create_serv.php Normal file
View file

@ -0,0 +1,55 @@
<?php
ini_set('display_errors', 1);
date_default_timezone_set("Europe/Paris");
require 'vendor/autoload.php';
$options = Array();
$options["user"] = Array("name"=>"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."<br>";
}
echo "<br><br>";
$images = $compute->ListImages();
$monim = "";
foreach($images as $image)
{
$monim = $image;
echo $image->name."<br>";
break;
}
$flavors = $compute->ListFlavors();
echo "<br><br>";
$monflav = "";
foreach($flavors as $flavor)
{
$monflav=$flavor;
echo $flavor->name."<br>";
break;
}
$response= $compute->createServer(array('name' => "TestOthmane2",'imageId' => $monim->id , 'flavorId'=>$monflav->id , "networks" => array
( array("uuid"=> "251b4641-20ff-4a72-8549-1758788b51ce"))));

0
server/index.php Executable file → Normal file
View file

View file

@ -43,4 +43,6 @@
$App = new App($Args); $App = new App($Args);
if(isset($token))
$App->setToken($token);
?> ?>

0
server/vendor/justinrainbow/json-schema/bin/validate-json vendored Executable file → Normal file
View file