Request Analyse reviewed, Server Initialisation Reviewed, Core Class Interface Created, App created
This commit is contained in:
parent
b39f5c1cd4
commit
c2a5b1880c
6 changed files with 147 additions and 83 deletions
68
server/core/App.php
Executable file
68
server/core/App.php
Executable file
|
@ -0,0 +1,68 @@
|
||||||
|
<?php
|
||||||
|
include_once("core/Plugin_Api.php");
|
||||||
|
include_once("core/LibOverride/genTokenOptions.php");
|
||||||
|
|
||||||
|
class App{
|
||||||
|
|
||||||
|
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($tokenPost == NULL) $tokenClass->genIdentityToken();
|
||||||
|
$opt = $tokenClass->getOptions($service);
|
||||||
|
return $this->openstack->identityV3($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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
7
server/core/CoreInterface.php
Executable file
7
server/core/CoreInterface.php
Executable file
|
@ -0,0 +1,7 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
interface Core{
|
||||||
|
|
||||||
|
public function action($action);
|
||||||
|
|
||||||
|
}
|
27
server/core/Identity.php
Normal file → Executable file
27
server/core/Identity.php
Normal file → Executable file
|
@ -1,19 +1,28 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class identity {
|
class identity implements Core{
|
||||||
|
|
||||||
protected $oidentity;
|
protected $app;
|
||||||
|
protected $libClass;
|
||||||
|
protected $action;
|
||||||
|
|
||||||
public function __construct($ostack, $apiP){
|
public function __construct($app){
|
||||||
|
|
||||||
$this->oidentity = $ostack->identityV3();
|
$this->app = $app;
|
||||||
$this->plugins = $apiP;
|
if($app->getOptions("Identity"))
|
||||||
|
$this->libClass = $app->getLibClass("Identity");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function action($action){
|
||||||
|
|
||||||
|
//To be Complete
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public function genToken(){
|
public function genToken(){
|
||||||
global $Args;
|
|
||||||
$token = $this->oidentity->generateToken($Args);
|
//To be Complete
|
||||||
return $token;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,7 @@ class genTokenOptions
|
||||||
$options['catalogType'] = 'false';
|
$options['catalogType'] = 'false';
|
||||||
$options['region'] = 'RegionOne';
|
$options['region'] = 'RegionOne';
|
||||||
|
|
||||||
$this->backup['Identity'] = unserialize($opt);
|
$this->backup['Identity'] = $opt;
|
||||||
$token = $this->unserializeToken($this->backup['Identity']['token']);
|
$token = $this->unserializeToken($this->backup['Identity']['token']);
|
||||||
$baseUrl = $this->backup['Identity']['baseUrl'];
|
$baseUrl = $this->backup['Identity']['baseUrl'];
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ class genTokenOptions
|
||||||
$options['catalogType'] = 'image';
|
$options['catalogType'] = 'image';
|
||||||
$options['region'] = 'RegionOne';
|
$options['region'] = 'RegionOne';
|
||||||
|
|
||||||
$this->backup['Image'] = unserialize($opt);
|
$this->backup['Image'] = $opt;
|
||||||
$token = $this->unserializeToken($this->backup['Image']['token']);
|
$token = $this->unserializeToken($this->backup['Image']['token']);
|
||||||
$baseUrl = $this->backup['Image']['baseUrl'];
|
$baseUrl = $this->backup['Image']['baseUrl'];
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ class genTokenOptions
|
||||||
$options['catalogType'] = 'network';
|
$options['catalogType'] = 'network';
|
||||||
$options['region'] = 'RegionOne';
|
$options['region'] = 'RegionOne';
|
||||||
|
|
||||||
$this->backup['Network'] = unserialize($opt);
|
$this->backup['Network'] = $opt;
|
||||||
$token = $this->unserializeToken($this->backup['Network']['token']);
|
$token = $this->unserializeToken($this->backup['Network']['token']);
|
||||||
$baseUrl = $this->backup['Network']['baseUrl'];
|
$baseUrl = $this->backup['Network']['baseUrl'];
|
||||||
|
|
||||||
|
@ -224,7 +224,7 @@ class genTokenOptions
|
||||||
$options['catalogType'] = 'compute';
|
$options['catalogType'] = 'compute';
|
||||||
$options['region'] = 'RegionOne';
|
$options['region'] = 'RegionOne';
|
||||||
|
|
||||||
$this->backup['Compute'] = unserialize($opt);
|
$this->backup['Compute'] = $opt;
|
||||||
$token = $this->unserializeToken($this->backup['Compute']['token']);
|
$token = $this->unserializeToken($this->backup['Compute']['token']);
|
||||||
$baseUrl = $this->backup['Compute']['baseUrl'];
|
$baseUrl = $this->backup['Compute']['baseUrl'];
|
||||||
|
|
||||||
|
@ -242,8 +242,18 @@ class genTokenOptions
|
||||||
$this->optionsGlobal['Compute'] = $options;
|
$this->optionsGlobal['Compute'] = $options;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getBackup($service){
|
public function getBackup(){
|
||||||
return serialize($this->backup[$service]);
|
return serialize($this->backup);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function loadBackup($back){
|
||||||
|
|
||||||
|
$backup = unserialize($back);
|
||||||
|
loadComputeBackup($backup["Compute"]);
|
||||||
|
loadIdentityBackup($backup["Identity"]);
|
||||||
|
loadImageBackup($backup["Image"]);
|
||||||
|
loadNetworkBackup($backup["Network"]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getOptions($service){
|
public function getOptions($service){
|
||||||
|
|
|
@ -3,33 +3,29 @@
|
||||||
include_once("config.inc.php");
|
include_once("config.inc.php");
|
||||||
include_once("init.php");
|
include_once("init.php");
|
||||||
|
|
||||||
// $task = $_POST["task"];
|
if(isset($_POST["task"]) && isset($_POST["action"])){
|
||||||
// $action = $_POST["action"];
|
$task = $_POST["task"];
|
||||||
|
$action = $_POST["action"];
|
||||||
|
}else if(isset($_POST["task"]) && $_POST["task"] == "Authenticate"){
|
||||||
//$id = new identity($openstack_api, $pluginApi);
|
$task = $_POST["task"];
|
||||||
|
}else{
|
||||||
// var_dump($id->genToken());
|
//Gestion Erreur
|
||||||
// $identity = $openstack_api->identityV3($Args);
|
}
|
||||||
//$tmp = $identity->listEndpoints();
|
|
||||||
//foreach($tmp as $cred){
|
if($task == "Authenticate"){
|
||||||
// echo $cred->id." %%%%%% ";
|
|
||||||
//}
|
$App->authenticate();
|
||||||
//$servers = $compute->listServers(true);
|
$App->show();
|
||||||
//var_dump($servers);
|
|
||||||
//foreach($servers as $server){
|
}
|
||||||
// echo $server->id." !!!!!!!!! ";
|
|
||||||
//}
|
switch($task)
|
||||||
|
{
|
||||||
$tmp = new genTokenOptions($Args);
|
case "identity":
|
||||||
$tmp->loadIdentityBackup($identityBack);
|
include_once("core/Identity.php");
|
||||||
$array = $tmp->getOptions("Identity");
|
$identityObject = new identity($App);
|
||||||
|
$identityObject->action($action);
|
||||||
$openstackTest = new OpenStack\OpenStack([]);
|
$App->show();
|
||||||
$identityTest = $openstackTest->identityV3($array);
|
break;
|
||||||
$domainsTest = $identityTest->listDomains();
|
|
||||||
foreach($domainsTest as $domain){
|
|
||||||
echo $domain->id." %%%%%% ";
|
|
||||||
}
|
}
|
||||||
// var_dump($openstack_api->getBuilderOptions());
|
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
include_once("config.inc.php");
|
include_once("core/App.php");
|
||||||
include_once("core/Plugin_Api.php");
|
|
||||||
require "vendor/autoload.php";
|
|
||||||
include_once("core/LibOverride/genTokenOptions.php");
|
|
||||||
include_once("core/Identity.php");
|
|
||||||
|
|
||||||
|
$user = "";
|
||||||
|
$password = "";
|
||||||
|
$project = "";
|
||||||
|
|
||||||
|
|
||||||
//traitement requete, recuperation data
|
//traitement requete, recuperation data
|
||||||
if(isset($_POST["key"])){
|
if(isset($_POST["token"])){
|
||||||
//recuperation des donnes sauvegardes
|
|
||||||
|
$token = $_POST["token"];
|
||||||
|
|
||||||
}else if(isset($_POST["user"]) && isset($_POST["password"]) && isset($_POST["project"]) ){
|
}else if(isset($_POST["user"]) && isset($_POST["password"]) && isset($_POST["project"]) ){
|
||||||
|
|
||||||
|
@ -15,28 +17,14 @@
|
||||||
$password = $_POST["password"];
|
$password = $_POST["password"];
|
||||||
$project = $_POST["project"];
|
$project = $_POST["project"];
|
||||||
|
|
||||||
$Args = Array(
|
} /*else { // Test Backend
|
||||||
"user" => Array(
|
|
||||||
"name" => $user,
|
|
||||||
"password" => $password,
|
|
||||||
"domain" => Array(
|
|
||||||
"name" => "Default")
|
|
||||||
),
|
|
||||||
"scope" => Array(
|
|
||||||
"project" => Array(
|
|
||||||
"name" => $project,
|
|
||||||
"domain" => Array(
|
|
||||||
"name" => "Default")
|
|
||||||
)
|
|
||||||
),
|
|
||||||
"authUrl" => $config["urlAuth"]
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
$user = "admin";
|
$user = "admin";
|
||||||
$password = "ae5or6cn";
|
$password = "ae5or6cn";
|
||||||
$project = "admin";
|
$project = "admin";
|
||||||
|
|
||||||
$Args = Array(
|
}*/
|
||||||
|
|
||||||
|
$Args = Array(
|
||||||
"user" => Array(
|
"user" => Array(
|
||||||
"name" => $user,
|
"name" => $user,
|
||||||
"password" => $password,
|
"password" => $password,
|
||||||
|
@ -52,21 +40,7 @@
|
||||||
),
|
),
|
||||||
"authUrl" => $config["urlAuth"]
|
"authUrl" => $config["urlAuth"]
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
$pluginApi = plugin_api::getInstance();
|
|
||||||
|
|
||||||
//$openstack_api = new OpenStack\OpenStack($Args);
|
$App = new App($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));
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Add table
Reference in a new issue