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
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
Add a link
Reference in a new issue