Merge branch 'develop' of https://github.com/manzerbredes/istic-openstack into othmane
This commit is contained in:
commit
d2f5ae5c83
30 changed files with 3675 additions and 307 deletions
|
@ -61,7 +61,7 @@
|
|||
|
||||
<!-- Include JQuery -->
|
||||
<script src="./vendors/jquery/jquery-2.2.0.min.js"></script>
|
||||
|
||||
|
||||
<!-- Include Bootstrap -->
|
||||
<script src="./vendors/bootstrap/js/bootstrap.min.js"></script>
|
||||
|
||||
|
@ -69,18 +69,22 @@
|
|||
<script src="./vendors/angularjs/angular.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-cookies.min.js"></script>
|
||||
<script src="./js/app.js"></script>
|
||||
|
||||
<!-- Include resquest dependencies -->
|
||||
<script src="./js/requests/identity.js"></script>
|
||||
|
||||
<!-- Include services -->
|
||||
<script src="./js/services/Identity.js"></script>
|
||||
<script src="./js/services/Image.js"></script>
|
||||
<script src="./js/services/Compute.js"></script>
|
||||
|
||||
<!-- Include controller -->
|
||||
<script src="./js/controllers/login.js"></script>
|
||||
<script src="./js/controllers/status.js"></script>
|
||||
<script src="./js/controllers/home/main.js"></script>
|
||||
<script src="./js/controllers/network/main.js"></script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</html>
|
||||
</html>
|
||||
|
|
|
@ -1,9 +1,16 @@
|
|||
|
||||
// Declare main app
|
||||
var mainApp=angular.module("mainApp",['ngRoute', 'ngSanitize']);
|
||||
|
||||
/**
|
||||
* The main app module instance
|
||||
* @type angular.module.angular-1_3_6_L1749.moduleInstance
|
||||
*/
|
||||
var mainApp=angular.module("mainApp",['ngRoute', 'ngSanitize', 'ngCookies']);
|
||||
|
||||
/**
|
||||
* Configure routeProvider
|
||||
*/
|
||||
mainApp.config(['$routeProvider', function($routeProvider){
|
||||
|
||||
|
||||
$routeProvider.
|
||||
when('/home',{
|
||||
templateUrl: 'partials/home/main.html',
|
||||
|
@ -15,4 +22,12 @@ mainApp.config(['$routeProvider', function($routeProvider){
|
|||
}).otherwise({
|
||||
redirectTo: '/home'
|
||||
});
|
||||
}]);
|
||||
}]);
|
||||
|
||||
/**
|
||||
* Configure httpProvider
|
||||
*/
|
||||
mainApp.config(['$httpProvider', function($httpProvider){
|
||||
$httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8';
|
||||
}]);
|
||||
|
||||
|
|
|
@ -1,11 +1,17 @@
|
|||
/*
|
||||
* home Controller
|
||||
/**
|
||||
* The home controller
|
||||
*
|
||||
* @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);
|
||||
|
||||
});
|
||||
}]);
|
||||
|
|
|
@ -1,39 +1,60 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Represents a book.
|
||||
* @constructor
|
||||
* The login controler
|
||||
* @param {$scope} $scope The $scope angular service
|
||||
* @param {$sce} $sce The $sce angular service
|
||||
* @param {$http} $http The $http angular service
|
||||
* @param {Identity} The Identity service
|
||||
|
||||
*/
|
||||
mainApp.controller('loginCtrl', function ($scope,$interval,$sce)
|
||||
mainApp.controller('loginCtrl', ['$scope','$sce','Identity', function ($scope,$sce, Identity)
|
||||
{
|
||||
// Define default states
|
||||
$('#loginModal').modal({backdrop: 'static', keyboard: false});
|
||||
$('#loadingLoginButton').hide();
|
||||
$('#failedToLoginAlert').hide();
|
||||
// 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();
|
||||
$('#failedToLoginAlert').hide();
|
||||
|
||||
|
||||
// Get data from templates
|
||||
var username=$("#loginFormUsername").val();
|
||||
var password=$("#loginFormPassword").val();
|
||||
var projectname=$("#loginFormProjectname").val();
|
||||
|
||||
$interval(
|
||||
function()
|
||||
{
|
||||
$('#failedToLoginAlert').show();
|
||||
// Function to call to handle result
|
||||
var responseCallback=function(response){
|
||||
|
||||
if(response.status!==0){
|
||||
// Set reason of fail
|
||||
$scope.failReason=response.failReason;
|
||||
|
||||
// Display the error
|
||||
$('#failedToLoginAlert').show();
|
||||
}
|
||||
else {
|
||||
// Else the user is online !
|
||||
$('#loginModal').modal('hide');
|
||||
}
|
||||
|
||||
// Reset button state
|
||||
$('#loginButton').show();
|
||||
$('#loadingLoginButton').hide();
|
||||
|
||||
}, 2000,1);
|
||||
|
||||
|
||||
|
||||
});
|
||||
})
|
||||
$('#loadingLoginButton').hide();
|
||||
}
|
||||
|
||||
// Try to login
|
||||
Identity.login(username, password, projectname, responseCallback);
|
||||
};
|
||||
|
||||
}]);
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
/*
|
||||
* network Controller
|
||||
/**
|
||||
* The network controller
|
||||
*
|
||||
* @param {$scope} $scope The $scope service from angular
|
||||
*/
|
||||
|
||||
|
||||
|
||||
mainApp.controller('networkCtrl', function ($scope)
|
||||
{
|
||||
});
|
|
@ -1,28 +1,22 @@
|
|||
/*
|
||||
* mainApp Controller
|
||||
|
||||
|
||||
/**
|
||||
* The status controller
|
||||
*
|
||||
* @param {$scope} $scope The $scope service from angular
|
||||
* @param {Identity} The Identity service
|
||||
*/
|
||||
|
||||
|
||||
|
||||
mainApp.controller('statusCtrl', function ($scope,$interval,$sce)
|
||||
mainApp.controller('statusCtrl', ['$scope','Identity', '$rootScope', function ($scope, Identity, $rootScope)
|
||||
{
|
||||
$scope.username="John Doe";
|
||||
$scope.projectname="Web Server";
|
||||
// Update status every 2 seconds
|
||||
/*$interval(function(){
|
||||
var status=identity.fetchStatus();
|
||||
$scope.username=status[1];
|
||||
$scope.lastconnection=status[2];
|
||||
if(status[0] == "1"){
|
||||
$scope.connection=$sce.trustAsHtml("<span style=\"color:green;\">Online</span>");
|
||||
}
|
||||
else{
|
||||
$scope.connection=$sce.trustAsHtml("<span style=\"color:red;\">Offline</span>");
|
||||
}
|
||||
}, 2000);*/
|
||||
|
||||
// Give profile to model
|
||||
$scope.profile=Identity.profile;
|
||||
|
||||
// Function to logout
|
||||
$scope.logout=function(){
|
||||
Identity.logout();
|
||||
$rootScope.$broadcast('logoutEvent');
|
||||
|
||||
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
}]);
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
|
||||
// Make Namespace
|
||||
var identity = {} ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
mainApp.controller('identityCtrl', function($scope, $http) {
|
||||
|
||||
$scope.identityFormData = {};
|
||||
|
||||
$scope.processForm = function() {
|
||||
|
||||
$http({
|
||||
method : 'POST',
|
||||
url : 'http://148.60.11.31/',
|
||||
data : $.param($scope.identityFormData),
|
||||
headers : { 'Content-Type': 'application/x-www-form-urlencoded' }
|
||||
})
|
||||
.success(function(data) {
|
||||
console.log(data);
|
||||
|
||||
if (!data.success) {
|
||||
// if not successful, bind errors to error variables
|
||||
//$scope.errorName = data.errors.name;
|
||||
//$scope.errorSuperhero = data.errors.superheroAlias;
|
||||
} else {
|
||||
// if successful, bind success message to message
|
||||
//$scope.message = data.message;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
});*/
|
||||
|
||||
|
||||
|
40
client/js/services/Compute.js
Normal file
40
client/js/services/Compute.js
Normal 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
|
||||
};
|
||||
|
||||
|
||||
}]);
|
111
client/js/services/Identity.js
Normal file
111
client/js/services/Identity.js
Normal file
|
@ -0,0 +1,111 @@
|
|||
|
||||
mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){
|
||||
|
||||
/* Create profile structure to store informations
|
||||
* about current session
|
||||
*/
|
||||
var profile={};
|
||||
profile.username=null;
|
||||
profile.projectname=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 {boolean} to check if the request is send or not
|
||||
* @returns {requestParserResult} Formated data
|
||||
*/
|
||||
var parseLoginAnswer=function(response, failedToSendRequest){
|
||||
|
||||
|
||||
var requestParserResult={};
|
||||
requestParserResult.status=1;
|
||||
requestParserResult.failReason=null;
|
||||
|
||||
if (typeof response.data.token !== 'undefined') {
|
||||
requestParserResult.status=0;
|
||||
profile.token=response.data.token;
|
||||
saveCookieForSession();
|
||||
}
|
||||
else if(failedToSendRequest){
|
||||
requestParserResult.failReason="Failed to send request";
|
||||
}
|
||||
else{
|
||||
requestParserResult.failReason="Please check your username, password and project name !";
|
||||
}
|
||||
|
||||
return requestParserResult;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Function to connect to OpenStack
|
||||
*
|
||||
* @param {object} $http Angular $http service
|
||||
* @param {string} username The user name
|
||||
* @param {string} password The user password
|
||||
* @param {string} projectname The user project name
|
||||
* @param {function} function to call when data is avalaible
|
||||
*/
|
||||
var login=function(username, password,projectname, callback){
|
||||
|
||||
// Set profile information (early)
|
||||
profile.username=username;
|
||||
profile.projectname=projectname;
|
||||
|
||||
var result=$http.post('../server/index.php',
|
||||
$.param({"task" : "Authenticate", "user" : username, "password" : password, "project" : projectname}));
|
||||
|
||||
// Wait and handle the response
|
||||
result.then(function (response){
|
||||
callback(parseLoginAnswer(response), false);
|
||||
},function(response){
|
||||
callback(parseLoginAnswer(response), true)
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
// Return services objects
|
||||
return {
|
||||
login: login,
|
||||
profile: profile,
|
||||
isAlreadyLogin: isAlreadyLogin,
|
||||
logout:logout
|
||||
};
|
||||
|
||||
|
||||
}]);
|
28
client/js/services/Image.js
Normal file
28
client/js/services/Image.js
Normal file
|
@ -0,0 +1,28 @@
|
|||
|
||||
mainApp.factory('Image',[ '$http', 'Identity', function($http, Identity){
|
||||
|
||||
|
||||
|
||||
var parseUploadImageAnswer=function(response, failedToSendRequest){
|
||||
|
||||
};
|
||||
|
||||
|
||||
var getImages=function(callback){
|
||||
|
||||
var result=$http.post('../server/index.php',
|
||||
$.param({"token" : Identity.profile.token, "task" : "Image"}));
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
// Return services objects
|
||||
return {
|
||||
uploadImage: uploadImage
|
||||
};
|
||||
|
||||
|
||||
}]);
|
|
@ -12,18 +12,18 @@
|
|||
<div class="modal-body">
|
||||
|
||||
<div class="form-group">
|
||||
<label label-default="" for="inputUser">User</label>
|
||||
<input class="form-control" id="inputUser"
|
||||
<label label-default="" for="loginFormUsername">User</label>
|
||||
<input class="form-control" id="loginFormUsername"
|
||||
placeholder="Email" type="text" ng-model="identityFormData.user">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label label-default="" for="inputProject">Project</label>
|
||||
<input class="form-control" id="inputProject"
|
||||
placeholder="Project Name" type="password" ng-model="identityFormData.project">
|
||||
<label label-default="" for="loginFormProjectname">Project</label>
|
||||
<input class="form-control" id="loginFormProjectname"
|
||||
placeholder="Project Name" type="text" ng-model="identityFormData.project">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label label-default="" for="inputPassword">Password</label>
|
||||
<input class="form-control" id="inputPassword"
|
||||
<label label-default="" for="loginFormPassword">Password</label>
|
||||
<input class="form-control" id="loginFormPassword"
|
||||
placeholder="Password" type="password" ng-model="identityFormData.password">
|
||||
</div>
|
||||
|
||||
|
@ -33,9 +33,9 @@
|
|||
<div class="modal-footer">
|
||||
<!--<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>
|
||||
<div class="alert alert-danger text-center" role="alert" id="failedToLoginAlert">Failed to login</div>
|
||||
<a href="#" class="btn btn-lg btn-primary btn-block" id="loginButton" ng-click="processForm()">Login</a>
|
||||
<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="loginAction()">Login</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
|
||||
<ul class="nav navbar-nav">
|
||||
<li class="nav-divider"></li>
|
||||
<li><a href="#">User : {{ username }}</a></li>
|
||||
<li><a href="#">Project Name : {{ projectname }}</a></li>
|
||||
<li><a href="#">User : {{ profile.username }}</a></li>
|
||||
<li><a href="#">Project Name : {{ profile.projectname }}</a></li>
|
||||
|
||||
<!--<li><a href="#" >Connection : <span ng-bind-html="connection"></span></a></li>-->
|
||||
|
||||
|
@ -32,11 +32,10 @@
|
|||
<li><a href="#">Informations</a></li>
|
||||
<li><a href="#">Settings</a></li>
|
||||
<li role="separator" class="divider"></li>
|
||||
<li><a href="#myModal" data-toggle="modal">Logout</a>
|
||||
</li>
|
||||
<li><a href="#" ng-click="logout()">Logout</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div><!-- /.navbar-collapse -->
|
||||
</div><!-- /.container-fluid -->
|
||||
</nav>
|
||||
</nav>
|
||||
|
|
9
client/vendors/angularjs/angular-cookies.min.js
vendored
Normal file
9
client/vendors/angularjs/angular-cookies.min.js
vendored
Normal 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
|
73
server/Test/AppTestClass.php
Executable file
73
server/Test/AppTestClass.php
Executable file
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
include_once("../core/Plugin_Api.php");
|
||||
include_once("../core/LibOverride/genTokenOptions.php");
|
||||
|
||||
class AppTest{
|
||||
|
||||
protected $openstack;
|
||||
protected $pluginsApi;
|
||||
protected $tokenClass;
|
||||
protected $tokenPost;
|
||||
protected $output;
|
||||
|
||||
public function __construct($args){
|
||||
|
||||
$this->tokenPost = NULL;
|
||||
$this->tokenClass = new genTokenOptions($args);
|
||||
$this->openstack = new OpenStack\OpenStack([]);
|
||||
$this->pluginsApi = plugin_api::getInstance();
|
||||
$this->output = array();
|
||||
|
||||
}
|
||||
|
||||
public function setToken($token){
|
||||
|
||||
$this->tokenPost = $token;
|
||||
$this->tokenClass->loadBackup($his->tokenPost);
|
||||
|
||||
}
|
||||
|
||||
public function getLibClass($service){
|
||||
|
||||
switch($service){
|
||||
case "Identity":
|
||||
if($this->tokenPost == NULL) $this->tokenClass->genIdentityToken();
|
||||
$opt = $this->tokenClass->getOptions($service);
|
||||
return $this->openstack->identityV3($opt);
|
||||
break;
|
||||
case "Image":
|
||||
if($this->tokenPost == NULL) $this->tokenClass->genImageToken();
|
||||
$opt = $this->tokenClass->getOptions($service);
|
||||
return $this->openstack->imagesV2($opt);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function authenticate(){
|
||||
|
||||
try{
|
||||
$this->tokenClass->genIdentityToken();
|
||||
$this->tokenClass->genComputeToken();
|
||||
$this->tokenClass->genImageToken();
|
||||
$this->tokenClass->genNetworkToken();
|
||||
|
||||
$this->setOutput("token", $this->tokenClass->getBackup());
|
||||
}catch(Exception $e){
|
||||
echo $e;
|
||||
exit();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function setOutput($key, $out){
|
||||
|
||||
$this->output[$key] = $out;
|
||||
|
||||
}
|
||||
|
||||
public function show(){
|
||||
echo json_encode($this->output);
|
||||
}
|
||||
|
||||
}
|
30
server/Test/InitTest.php
Executable file
30
server/Test/InitTest.php
Executable file
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
require '../vendor/autoload.php';
|
||||
include_once("../config.inc.php");
|
||||
include_once("AppTestClass.php");
|
||||
|
||||
|
||||
$user = "demo";
|
||||
$password = "demopass";
|
||||
$project = "demo";
|
||||
|
||||
$Args = Array(
|
||||
"user" => Array(
|
||||
"name" => $user,
|
||||
"password" => $password,
|
||||
"domain" => Array(
|
||||
"name" => "Default")
|
||||
),
|
||||
"scope" => Array(
|
||||
"project" => Array(
|
||||
"name" => $project,
|
||||
"domain" => Array(
|
||||
"name" => "Default")
|
||||
)
|
||||
),
|
||||
"authUrl" => $config["urlAuth"]
|
||||
);
|
||||
|
||||
$App = new AppTest($Args);
|
||||
|
||||
?>
|
6
server/Test/genTokenOptionsTest.php
Executable file → Normal file
6
server/Test/genTokenOptionsTest.php
Executable file → Normal file
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
include_once("../config.inc.php");
|
||||
include_once("config.inc.php");
|
||||
require "../vendor/autoload.php";
|
||||
include_once("../core/Plugin_Api.php");
|
||||
include_once("../core/LibOverride/genTokenOptions.php");
|
||||
include_once("core/Plugin_Api.php");
|
||||
include_once("core/LibOverride/genTokenOptions.php");
|
||||
|
||||
$user = "admin";
|
||||
$password = "ae5or6cn";
|
||||
|
|
95
server/Test/imageTests.php
Normal file
95
server/Test/imageTests.php
Normal file
|
@ -0,0 +1,95 @@
|
|||
<?php
|
||||
require '../vendor/autoload.php';
|
||||
include('/istic-openstack/server/init.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);
|
||||
|
||||
//$identity = $openstack->identityV3();
|
||||
//var_dump($identity);
|
||||
// Since usernames will not be unique across an entire OpenStack installation,
|
||||
// when authenticating with them you must also provide your domain ID. You do
|
||||
// not have to do this if you authenticate with a user ID.
|
||||
/*$token = $identity->generateToken([
|
||||
'user' => [
|
||||
'name' => 'admin',
|
||||
'password' => 'ae5or6cn',
|
||||
'domain' => [
|
||||
'id' => 'Default'
|
||||
]
|
||||
]
|
||||
]);
|
||||
*/
|
||||
//$compute = $openstack->computeV2(["region" => "RegionOne"]);
|
||||
//$image= $openstack->imagesV2(["region" => "RegionOne"]);
|
||||
//var_dump($compute->client);
|
||||
//$servers = $compute->listServers(true);
|
||||
echo 'toto';
|
||||
|
||||
$image = new Image($App);
|
||||
|
||||
$opt = Array();
|
||||
$opt['name'] = "Test";
|
||||
$opt['tags'] = ['test', 'openstack'];
|
||||
//$opt['containerFormat'] = 'ami';
|
||||
//$opt['diskFormat'] = 'iso';
|
||||
$opt['visibility'] = 'public';
|
||||
$opt['minDisk'] = 1;
|
||||
$opt['protected'] = false;
|
||||
$opt['minRam'] = 10;
|
||||
|
||||
//$new_image = $image->create_image($opt);
|
||||
|
||||
|
||||
//Liste des images
|
||||
$images = $image->list_images();
|
||||
|
||||
echo "Images présentes :";
|
||||
echo "</br>";
|
||||
|
||||
foreach($images as $i){
|
||||
echo $i->name;
|
||||
if($i->name == "Test"){
|
||||
$id_image = $i->id;
|
||||
$list = $i->tags;
|
||||
echo $i->status;
|
||||
}
|
||||
echo "</br>";
|
||||
}
|
||||
echo "</br>";
|
||||
|
||||
if(isset($list)){
|
||||
foreach ($list as $l) {
|
||||
echo $l;
|
||||
echo "</br>";
|
||||
}
|
||||
}
|
||||
|
||||
// Détails Image
|
||||
//$details = $image->image_details($id_image);
|
||||
|
||||
//$image->delete_image('123456');
|
||||
|
||||
//$image->desactivate_image($id_image);
|
||||
//$image->reactivate_image($id_image);
|
||||
|
||||
//$file_name = "/home/yogg/Downloads/TinyCore-6.4.1.iso";
|
||||
//$image->upload_image($id_image, $file_name);
|
||||
|
||||
//$image->download_image($id_image);
|
||||
|
||||
/*
|
||||
$opt_update = Array();
|
||||
$opt_update['name'] = "Test";
|
||||
$opt_update['tags'] = null;
|
||||
|
||||
$update = $image->update_image($id_image, $opt_update);
|
||||
echo $update->name;
|
||||
*/
|
||||
|
||||
?>
|
0
server/composer.phar
Executable file → Normal file
0
server/composer.phar
Executable file → Normal file
100
server/core/App.php
Normal file
100
server/core/App.php
Normal file
|
@ -0,0 +1,100 @@
|
|||
<?php
|
||||
include_once("core/Plugin_Api.php");
|
||||
include_once("core/LibOverride/genTokenOptions.php");
|
||||
include_once("core/ErrorManagement.php");
|
||||
|
||||
use OpenStack\Common\Error\BadResponseError;
|
||||
use OpenStack\Common\Error\BaseError;
|
||||
use OpenStack\Common\Error\NotImplementedError;
|
||||
use OpenStack\Common\Error\UserInputError;
|
||||
|
||||
class App{
|
||||
|
||||
protected $openstack;
|
||||
protected $pluginsApi;
|
||||
protected $postParams;
|
||||
protected $tokenClass;
|
||||
protected $tokenPost;
|
||||
protected $errorClass;
|
||||
protected $output;
|
||||
|
||||
public function __construct($args){
|
||||
|
||||
$this->tokenPost = NULL;
|
||||
$this->tokenClass = new genTokenOptions($args);
|
||||
$this->openstack = new OpenStack\OpenStack([]);
|
||||
$this->pluginsApi = plugin_api::getInstance();
|
||||
$this->errorClass = new errorManagement($this);
|
||||
$this->output = array();
|
||||
$this->postParams = $_POST;
|
||||
|
||||
}
|
||||
|
||||
public function setToken($token){
|
||||
|
||||
$this->tokenPost = $token;
|
||||
$this->tokenClass->loadBackup($his->tokenPost);
|
||||
|
||||
}
|
||||
|
||||
public function getLibClass($service){
|
||||
|
||||
switch($service){
|
||||
case "Identity":
|
||||
if($this->tokenPost == NULL) $this->tokenClass->genIdentityToken();
|
||||
$opt = $this->tokenClass->getOptions($service);
|
||||
return $this->openstack->identityV3($opt);
|
||||
break;
|
||||
case "Image":
|
||||
if($this->tokenPost == NULL) $this->tokenClass->genImageToken();
|
||||
$opt = $this->tokenClass->getOptions($service);
|
||||
return $this->openstack->imagesV2($opt);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function authenticate(){
|
||||
|
||||
try{
|
||||
$this->tokenClass->genIdentityToken();
|
||||
$this->tokenClass->genComputeToken();
|
||||
$this->tokenClass->genImageToken();
|
||||
$this->tokenClass->genNetworkToken();
|
||||
|
||||
$this->setOutput("token", $this->tokenClass->getBackup());
|
||||
}catch(BadResponseError $e){
|
||||
$this->errorClass->BadResponseHandler($e);
|
||||
}catch(UserInputError $e){
|
||||
$this->errorClass->UserInputHandler($e);
|
||||
}catch(BaseError $e){
|
||||
$this->errorClass->BaseErrorHandler($e);
|
||||
}catch(NotImplementedError $e){
|
||||
$this->errorClass->NotImplementedHandler($e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function getPostParam($name){
|
||||
|
||||
return $this->postParams[$name];
|
||||
|
||||
}
|
||||
|
||||
public function setOutput($key, $out){
|
||||
|
||||
$this->output[$key] = $out;
|
||||
|
||||
}
|
||||
|
||||
public function getErrorInstance(){
|
||||
|
||||
return $this->errorClass;
|
||||
|
||||
}
|
||||
|
||||
public function show(){
|
||||
echo json_encode($this->output);
|
||||
}
|
||||
|
||||
}
|
7
server/core/CoreInterface.php
Normal file
7
server/core/CoreInterface.php
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
interface Core{
|
||||
|
||||
public function action($action);
|
||||
|
||||
}
|
39
server/core/ErrorManagement.php
Executable file
39
server/core/ErrorManagement.php
Executable file
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
use OpenStack\Common\Error\BadResponseError;
|
||||
use OpenStack\Common\Error\BaseError;
|
||||
use OpenStack\Common\Error\NotImplementedError;
|
||||
use OpenStack\Common\Error\UserInputError;
|
||||
|
||||
|
||||
Class errorManagement{
|
||||
|
||||
protected $app;
|
||||
|
||||
|
||||
public function __construct($args){
|
||||
|
||||
$this->app = $args;
|
||||
|
||||
}
|
||||
|
||||
public function BaseErrorHandler($error){
|
||||
|
||||
}
|
||||
|
||||
public function BadResponseHandler($error){
|
||||
$this->app->setOutput("Error", "Erreur Interne, Merci de contacter un administrateur!");
|
||||
}
|
||||
|
||||
public function NotImplementedHandler($error){
|
||||
$this->app->setOutput("Error", "Erreur Interne, Merci de contacter un administrateur!");
|
||||
}
|
||||
|
||||
public function UserInputHandler($error){
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
2576
server/core/Identity.php
Normal file → Executable file
2576
server/core/Identity.php
Normal file → Executable file
File diff suppressed because it is too large
Load diff
|
@ -1 +1,322 @@
|
|||
<?php
|
||||
|
||||
//require 'CoreInterface.php';
|
||||
|
||||
/**
|
||||
* File containing the Image Class.
|
||||
*
|
||||
* @version 1.0 Initialisation of this file
|
||||
* @since 1.0 Core application's file
|
||||
*
|
||||
* @author Yogg 'yogg at epsina . com'
|
||||
*
|
||||
* @todo Complete the functions with errors detection and finish the descriptions
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Image Class of the back-end application
|
||||
*
|
||||
* ADD CLASS DESCRIPTION
|
||||
*
|
||||
*/
|
||||
class image{
|
||||
//implements Core
|
||||
|
||||
/** @var App $app protected, contains the main app object */
|
||||
protected $app;
|
||||
|
||||
/** @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();
|
||||
|
||||
|
||||
/**
|
||||
* Image constructor
|
||||
*
|
||||
* @param App $app the main app object
|
||||
*
|
||||
* @throws [Type] [<description>]
|
||||
*
|
||||
* @return Image
|
||||
*/
|
||||
public function __construct($app){
|
||||
$this->app = $app;
|
||||
$this->libClass = $app->getLibClass("Image");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Details about an image
|
||||
*
|
||||
* @param array $opt
|
||||
* options for the image creation
|
||||
*
|
||||
**/
|
||||
public function create_image(array $opt){
|
||||
// VOIR SI MAUVAIS TYPE
|
||||
$options = Array();
|
||||
if(isset($opt['name'])){ // string, rendre le nom obligatoire, vérifier nom pas déjà pris
|
||||
}
|
||||
else{
|
||||
//ERROR
|
||||
}
|
||||
if(isset($opt['id'])){ // UUID : nnnnnnnn-nnnn-nnnn-nnnn-nnnnnnnnnnnn
|
||||
$options['id'] = $opt['id'];
|
||||
}
|
||||
if(isset($opt['visibility'])){ // public, private
|
||||
$options['visibility'] = $opt['visibility'];
|
||||
}
|
||||
if(isset($opt['tags'])){ // list
|
||||
$options['tags'] = $opt['tags'];
|
||||
}
|
||||
if(isset($opt['containerFormat'])){ // string : ami, ari, aki, bare, ovf, ova, docker
|
||||
$options['containerFormat'] = $opt['containerFormat'];
|
||||
}
|
||||
if(isset($opt['diskFormat'])){ // string : ami, ari, aki, vhd, vmdk, raw, qcow2, vdi, iso
|
||||
$options['diskFormat'] = $opt['diskFormat'];
|
||||
}
|
||||
if(isset($opt['minDisk'])){ //int
|
||||
$options['minDisk'] = $opt['minDisk'];
|
||||
}
|
||||
if(isset($opt['minRam'])){ // int
|
||||
$options['minRam'] = $opt['minRam'];
|
||||
}
|
||||
if(isset($opt['protected'])){ // boolean
|
||||
$options['protected'] = $opt['protected'];
|
||||
}
|
||||
if(isset($opt['properties'])){ // type dict ?
|
||||
$options['properties'] = $opt['properties'];
|
||||
}
|
||||
|
||||
$image = $this->oidentity->createImage($options);
|
||||
|
||||
return $image;
|
||||
}
|
||||
|
||||
/*
|
||||
* List images
|
||||
*/
|
||||
public function list_images(){
|
||||
// vérifier si au moins une image
|
||||
$service = $this->oidentity;
|
||||
$images = $service->listImages();
|
||||
return $images;
|
||||
}
|
||||
|
||||
/**
|
||||
* Details about an image
|
||||
*
|
||||
* @param string $id
|
||||
* identifier of the image
|
||||
*
|
||||
**/
|
||||
public function image_details($id){
|
||||
//vérifier existence image
|
||||
$service = $this->oidentity;
|
||||
$image = $service->getImage($id);
|
||||
return $image;
|
||||
}
|
||||
|
||||
/**
|
||||
* Details about an image
|
||||
*
|
||||
* @param string $id
|
||||
* id of the image
|
||||
*
|
||||
* @param array $opt
|
||||
* options for the image creation
|
||||
**/
|
||||
public function update_image($id, array $opt){
|
||||
//vérifier existence image
|
||||
$service = $this->oidentity;
|
||||
$image = $service->getImage($id);
|
||||
$options = Array();
|
||||
|
||||
// Voir vérification des types
|
||||
if(isset($opt['name'])){ //string
|
||||
$options['name'] = $opt['name'];
|
||||
}
|
||||
if(isset($opt['minDisk'])){ //int
|
||||
$options['minDisk'] = $opt['minDisk'];
|
||||
}
|
||||
if(isset($opt['minRam'])){ // int
|
||||
$options['minRam'] = $opt['minRam'];
|
||||
}
|
||||
if(isset($opt['protected'])){ // boolean
|
||||
$options['protected'] = $opt['protected'];
|
||||
}
|
||||
if(isset($opt['visibility'])){ // public, private
|
||||
$options['visibility'] = $opt['visibility'];
|
||||
}
|
||||
if(isset($opt['tags'])){ // list
|
||||
$options['tags'] = $opt['tags'];
|
||||
}
|
||||
$image->update($options);
|
||||
|
||||
return $image;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an image
|
||||
*
|
||||
* @param string $id
|
||||
* identifier of the image
|
||||
**/
|
||||
public function delete_image($id){
|
||||
// si protected = true, demander de le mettre a false
|
||||
// vérifier existence image
|
||||
$service = $this->oidentity;
|
||||
$service->getImage($id)->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Resactive an image
|
||||
*
|
||||
* @param string $id
|
||||
* identifier of the image
|
||||
**/
|
||||
public function reactivate_image($id){
|
||||
// vérifier existence image
|
||||
$service = $this->oidentity;
|
||||
$image = $service->getImage($id);
|
||||
$image->reactivate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Desactive an image
|
||||
*
|
||||
* @param string $id
|
||||
* identifier of the image
|
||||
**/
|
||||
public function desactivate_image($id){
|
||||
// vérifier existence image
|
||||
$service = $this->oidentity;
|
||||
$image = $service->getImage($id);
|
||||
$image->deactivate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload an image
|
||||
*
|
||||
* @param string $id
|
||||
* identifier of the image
|
||||
*
|
||||
* @param string $file_name
|
||||
* path of the image
|
||||
**/
|
||||
public function upload_image($id, $file_name){
|
||||
// vérifier existence image
|
||||
$service = $this->oidentity;
|
||||
$image = $service->getImage($id);
|
||||
$stream = \GuzzleHttp\Psr7\stream_for(fopen($file_name, 'r')); // A VOIR
|
||||
$image->uploadData($stream);
|
||||
}
|
||||
|
||||
/**
|
||||
* Download an image
|
||||
*
|
||||
* @param string $id
|
||||
* identifier of the image
|
||||
**/
|
||||
public function download_image($id){
|
||||
// vérifier existence image
|
||||
$service = $this->oidentity;
|
||||
$image = $service->getImage($id);
|
||||
$stream = $image->downloadData();
|
||||
return $stream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a member to image
|
||||
*
|
||||
* @param string $image_id
|
||||
* identifier of the image
|
||||
*
|
||||
* @param string $member_id
|
||||
* identifier of the member
|
||||
**/
|
||||
public function add_member($image_id, $member_id){
|
||||
// vérifier existence image
|
||||
// on doit être le proprio de l'image
|
||||
// vérifier membre existe
|
||||
$service = $this->oidentity;
|
||||
$member_id = $service>getImage($image_id)->addMember($member_id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* List members of an image
|
||||
*
|
||||
* @param string $image_id
|
||||
* identifier of the image
|
||||
**/
|
||||
public function list_member($image_id, $member_id){
|
||||
// vérifier existence image
|
||||
$service = $this->oidentity;
|
||||
$image = $service->getImage($image_id);
|
||||
$members = $image->listMembers();
|
||||
return $members;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show details of a member of an image
|
||||
*
|
||||
* @param string $image_id
|
||||
* identifier of the image
|
||||
*
|
||||
* @param string $member_id
|
||||
* identifier of the member
|
||||
**/
|
||||
public function detail_member($image_id, $member_id){
|
||||
// vérifier existence image
|
||||
// on doit être le proprio de l'image
|
||||
// vérifier membre existe
|
||||
$service = $this->oidentity;
|
||||
$member = $service>getImage($image_id)->getMember($member_id);
|
||||
return $member;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a member of an image
|
||||
*
|
||||
* @param string $image_id
|
||||
* identifier of the image
|
||||
*
|
||||
* @param string $member_id
|
||||
* identifier of the member
|
||||
**/
|
||||
public function remove_member($image_id, $member_id){
|
||||
// vérifier existence image
|
||||
// on doit être le proprio de l'image
|
||||
// vérifier membre existe
|
||||
$service = $this->oidentity;
|
||||
$service>getImage($image_id)->getMember($member_id)->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a member of an image
|
||||
*
|
||||
* @param string $image_id
|
||||
* identifier of the image
|
||||
*
|
||||
* @param string $member_id
|
||||
* identifier of the member
|
||||
*
|
||||
* @param string $status
|
||||
* new status for the member
|
||||
**/
|
||||
public function update_member($image_id, $member_id, $status){
|
||||
// vérifier existence image
|
||||
// on doit être le proprio de l'image
|
||||
// vérifier membre existe
|
||||
$service = $this->oidentity;
|
||||
$member = $service>getImage($image_id)->getMember($member_id)->updateStatus($status);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
|
137
server/core/LibOverride/genTokenOptions.php
Executable file → Normal file
137
server/core/LibOverride/genTokenOptions.php
Executable file → Normal file
|
@ -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;
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ class genTokenOptions
|
|||
$options['catalogType'] = 'false';
|
||||
$options['region'] = 'RegionOne';
|
||||
|
||||
$this->backup['Identity'] = unserialize($opt);
|
||||
$this->backup['Identity'] = $opt;
|
||||
$token = $this->unserializeToken($this->backup['Identity']['token']);
|
||||
$baseUrl = $this->backup['Identity']['baseUrl'];
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ class genTokenOptions
|
|||
$options['catalogType'] = 'image';
|
||||
$options['region'] = 'RegionOne';
|
||||
|
||||
$this->backup['Image'] = unserialize($opt);
|
||||
$this->backup['Image'] = $opt;
|
||||
$token = $this->unserializeToken($this->backup['Image']['token']);
|
||||
$baseUrl = $this->backup['Image']['baseUrl'];
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -176,7 +176,7 @@ class genTokenOptions
|
|||
$options['catalogType'] = 'network';
|
||||
$options['region'] = 'RegionOne';
|
||||
|
||||
$this->backup['Network'] = unserialize($opt);
|
||||
$this->backup['Network'] = $opt;
|
||||
$token = $this->unserializeToken($this->backup['Network']['token']);
|
||||
$baseUrl = $this->backup['Network']['baseUrl'];
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -224,7 +224,7 @@ class genTokenOptions
|
|||
$options['catalogType'] = 'compute';
|
||||
$options['region'] = 'RegionOne';
|
||||
|
||||
$this->backup['Compute'] = unserialize($opt);
|
||||
$this->backup['Compute'] = $opt;
|
||||
$token = $this->unserializeToken($this->backup['Compute']['token']);
|
||||
$baseUrl = $this->backup['Compute']['baseUrl'];
|
||||
|
||||
|
@ -238,12 +238,36 @@ 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;
|
||||
}
|
||||
|
||||
public function getBackup($service){
|
||||
return serialize($this->backup[$service]);
|
||||
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);
|
||||
}
|
||||
|
||||
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"]);
|
||||
loadNetworkBackup($backup["Network"]);
|
||||
|
||||
}
|
||||
|
||||
public function getOptions($service){
|
||||
|
@ -252,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){
|
||||
|
@ -260,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);
|
||||
|
@ -292,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);
|
||||
|
@ -346,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"]);
|
||||
|
||||
|
|
1
server/core/LibOverride/projectTokenData/demo
Normal file
1
server/core/LibOverride/projectTokenData/demo
Normal 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;";}}}
|
59
server/index.php
Executable file → Normal file
59
server/index.php
Executable file → Normal file
|
@ -3,33 +3,36 @@
|
|||
include_once("config.inc.php");
|
||||
include_once("init.php");
|
||||
|
||||
// $task = $_POST["task"];
|
||||
// $action = $_POST["action"];
|
||||
|
||||
|
||||
//$id = new identity($openstack_api, $pluginApi);
|
||||
|
||||
// var_dump($id->genToken());
|
||||
// $identity = $openstack_api->identityV3($Args);
|
||||
//$tmp = $identity->listEndpoints();
|
||||
//foreach($tmp as $cred){
|
||||
// echo $cred->id." %%%%%% ";
|
||||
//}
|
||||
//$servers = $compute->listServers(true);
|
||||
//var_dump($servers);
|
||||
//foreach($servers as $server){
|
||||
// echo $server->id." !!!!!!!!! ";
|
||||
//}
|
||||
|
||||
$tmp = new genTokenOptions($Args);
|
||||
$tmp->loadIdentityBackup($identityBack);
|
||||
$array = $tmp->getOptions("Identity");
|
||||
|
||||
$openstackTest = new OpenStack\OpenStack([]);
|
||||
$identityTest = $openstackTest->identityV3($array);
|
||||
$domainsTest = $identityTest->listDomains();
|
||||
foreach($domainsTest as $domain){
|
||||
echo $domain->id." %%%%%% ";
|
||||
if(isset($_POST["task"]) && isset($_POST["action"])){
|
||||
$task = $_POST["task"];
|
||||
$action = $_POST["action"];
|
||||
}else if(isset($_POST["task"]) && $_POST["task"] == "Authenticate"){
|
||||
$task = $_POST["task"];
|
||||
}else{
|
||||
//Gestion Erreur
|
||||
}
|
||||
|
||||
if($task == "Authenticate"){
|
||||
|
||||
$App->authenticate();
|
||||
$App->show();
|
||||
|
||||
}
|
||||
|
||||
switch($task)
|
||||
{
|
||||
case "identity":
|
||||
include_once("core/Identity.php");
|
||||
$identityObject = new identity($App);
|
||||
$identityObject->action($action);
|
||||
$App->show();
|
||||
break;
|
||||
|
||||
case "image":
|
||||
include_once("core/Image.php");
|
||||
$imageObject = new image($App);
|
||||
$imageObject->action($action);
|
||||
$App->show();
|
||||
break;
|
||||
}
|
||||
// var_dump($openstack_api->getBuilderOptions());
|
||||
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
<?php
|
||||
include_once("config.inc.php");
|
||||
include_once("core/Plugin_Api.php");
|
||||
require "vendor/autoload.php";
|
||||
include_once("core/LibOverride/genTokenOptions.php");
|
||||
include_once("core/Identity.php");
|
||||
include_once("core/App.php");
|
||||
|
||||
$user = "";
|
||||
$password = "";
|
||||
$project = "";
|
||||
|
||||
|
||||
//traitement requete, recuperation data
|
||||
if(isset($_POST["key"])){
|
||||
//recuperation des donnes sauvegardes
|
||||
if(isset($_POST["token"])){
|
||||
|
||||
$token = $_POST["token"];
|
||||
|
||||
}else if(isset($_POST["user"]) && isset($_POST["password"]) && isset($_POST["project"]) ){
|
||||
|
||||
|
@ -15,28 +17,14 @@
|
|||
$password = $_POST["password"];
|
||||
$project = $_POST["project"];
|
||||
|
||||
$Args = Array(
|
||||
"user" => Array(
|
||||
"name" => $user,
|
||||
"password" => $password,
|
||||
"domain" => Array(
|
||||
"name" => "Default")
|
||||
),
|
||||
"scope" => Array(
|
||||
"project" => Array(
|
||||
"name" => $project,
|
||||
"domain" => Array(
|
||||
"name" => "Default")
|
||||
)
|
||||
),
|
||||
"authUrl" => $config["urlAuth"]
|
||||
);
|
||||
} else {
|
||||
} /*else { // Test Backend
|
||||
$user = "admin";
|
||||
$password = "ae5or6cn";
|
||||
$project = "admin";
|
||||
|
||||
$Args = Array(
|
||||
}*/
|
||||
|
||||
$Args = Array(
|
||||
"user" => Array(
|
||||
"name" => $user,
|
||||
"password" => $password,
|
||||
|
@ -52,21 +40,9 @@
|
|||
),
|
||||
"authUrl" => $config["urlAuth"]
|
||||
);
|
||||
}
|
||||
|
||||
$pluginApi = plugin_api::getInstance();
|
||||
|
||||
//$openstack_api = new OpenStack\OpenStack($Args);
|
||||
//$id = new identity($openstack_api, $pluginApi);
|
||||
|
||||
//$token = $id->genToken();
|
||||
|
||||
$tmp = new genTokenOptions($Args);
|
||||
$tmp->genIdentityToken();
|
||||
$array = $tmp->getOptions("Identity");
|
||||
$openstack_api = new OpenStack\OpenStack([]);
|
||||
|
||||
$identityBack = $tmp->getBackup("Identity");
|
||||
//file_put_contents("token", serialize($tmp));
|
||||
$App = new App($Args);
|
||||
|
||||
if(isset($token))
|
||||
$App->setToken($token);
|
||||
?>
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
<?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);
|
||||
|
||||
//$identity = $openstack->identityV3();
|
||||
//var_dump($identity);
|
||||
// Since usernames will not be unique across an entire OpenStack installation,
|
||||
// when authenticating with them you must also provide your domain ID. You do
|
||||
// not have to do this if you authenticate with a user ID.
|
||||
|
||||
/*$token = $identity->generateToken([
|
||||
'user' => [
|
||||
'name' => 'admin',
|
||||
'password' => 'ae5or6cn',
|
||||
'domain' => [
|
||||
'id' => 'Default'
|
||||
]
|
||||
]
|
||||
]);
|
||||
*/
|
||||
$compute = $openstack->computeV2(["region" => "RegionOne"]);
|
||||
//var_dump($compute->client);
|
||||
//$servers = $compute->listServers(true);
|
||||
|
||||
//foreach($servers as $server){
|
||||
// echo $server->id." !!! ";
|
||||
// echo $server->name." !!! ";
|
||||
//}
|
0
server/vendor/justinrainbow/json-schema/bin/validate-json
vendored
Executable file → Normal file
0
server/vendor/justinrainbow/json-schema/bin/validate-json
vendored
Executable file → Normal file
2
server/vendor/php-opencloud/openstack
vendored
2
server/vendor/php-opencloud/openstack
vendored
|
@ -1 +1 @@
|
|||
Subproject commit 15aca73f423166c7ef8337ba08615c103c66e931
|
||||
Subproject commit 1419eb2e01164bb6b8b837df37724423907352d7
|
Loading…
Add table
Reference in a new issue