Test
This commit is contained in:
commit
a3ff4d243e
261 changed files with 46 additions and 31048 deletions
|
@ -22,6 +22,7 @@ class automating implements Core{
|
|||
protected $appImage;
|
||||
protected $appNetwork;
|
||||
protected $appIdentity;
|
||||
protected $app;
|
||||
|
||||
/**
|
||||
* Our library's app constructor for all server app objects
|
||||
|
@ -38,6 +39,7 @@ class automating implements Core{
|
|||
$this->appImage = $appImage;
|
||||
$this->appNetwork = $appNetwork;
|
||||
$this->appIdentity = $appIdentity;
|
||||
$this->app = $app;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -72,79 +74,28 @@ class automating implements Core{
|
|||
appCompute->createServer();
|
||||
|
||||
}
|
||||
/**
|
||||
* Create a new image on a new server
|
||||
*
|
||||
* @param $name the name of the new image
|
||||
* @param $falvor_id the id of the flavor it will be used to create the new server
|
||||
*
|
||||
* @return Image the new image created
|
||||
*/
|
||||
private function createImageOnNewServer(){
|
||||
try{
|
||||
/* POURRI
|
||||
$image = new Image($this->app);
|
||||
$compute = new Compute($this->app);
|
||||
|
||||
$name = $this->app->getPostParam("name");
|
||||
$falvor_id = $this->app->getPostParam("falvor_id"); // Compris entre 1 et 5 (1=petit serveur, 5=gros serveur)
|
||||
|
||||
private function createServer()
|
||||
{
|
||||
$imageName = $this->app->getPostParam('imageName');
|
||||
$serverName = $this->app->getPostParam('serverName');
|
||||
$flavor = $this->app->getPostParam('flavor');
|
||||
|
||||
$opt = Array();
|
||||
$opt['name'] = $name;
|
||||
$opt['visibility'] = 'public';
|
||||
$opt['minDisk'] = 100; // A VOIR
|
||||
$opt['minRam'] = 128; // A VOIR
|
||||
$opt['protected'] = false;
|
||||
// Création image
|
||||
$opt = Array();
|
||||
$opt['name'] = $imageName;
|
||||
$this->app->setPostParam('opt' $opt);
|
||||
$this->appImage->createImage();
|
||||
$image = json_decode($this->app->show(), true)["Images"];
|
||||
|
||||
$this->app->setPostParam("opt", $opt);
|
||||
// Création server
|
||||
$this->app->setPostParam('name', $serverName);
|
||||
$this->app->setPostParam('imageId', $image['id']);
|
||||
$this->app->setPostParam('flavorId', $flavor);
|
||||
$this->appNetwork->createServer();
|
||||
|
||||
$image->action("createImage");
|
||||
$res = json_decode($this->app->show(), true)["Images"];
|
||||
// Ajout adresse IP public
|
||||
|
||||
|
||||
$this->app->setPostParam("name", $name);
|
||||
$this->app->setPostParam("imageId", $res['id']);
|
||||
$this->app->setPostParam("flavorId", $falvor_id);
|
||||
|
||||
$compute->action("createServer");
|
||||
*/
|
||||
}catch(BadResponseError $e){
|
||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||
}catch(UserInputError $e){
|
||||
$this->app->getErrorInstance()->UserInputHandler($e);
|
||||
}catch(BaseError $e){
|
||||
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
||||
}catch(NotImplementedError $e){
|
||||
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
||||
}catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
//$this->app->setOutput("Auto", $res);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a new image on an existing server
|
||||
*
|
||||
* @param $name the name of the new image
|
||||
* @param $server_id the id of the server
|
||||
*
|
||||
* @return Image the new image created
|
||||
*/
|
||||
private function createImageOnServer(){
|
||||
try{
|
||||
|
||||
}catch(BadResponseError $e){
|
||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||
}catch(UserInputError $e){
|
||||
$this->app->getErrorInstance()->UserInputHandler($e);
|
||||
}catch(BaseError $e){
|
||||
$this->app->getErrorInstance()->BaseErrorHandler($e);
|
||||
}catch(NotImplementedError $e){
|
||||
$this->app->getErrorInstance()->NotImplementedHandler($e);
|
||||
}catch(Exception $e){
|
||||
$this->app->getErrorInstance()->OtherException($e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -274,8 +274,8 @@ class genTokenOptions
|
|||
|
||||
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);
|
||||
//$path = "core/LibOverride/projectTokenData/".$token['saved']["project"]["name"];
|
||||
//error_log("Path a ecrire ".print_r($path, true), 0);
|
||||
file_put_contents("core/LibOverride/projectTokenData/".$token['saved']["project"]["name"], serialize($token['saved']));
|
||||
$this->backup['time'] = $token['time'];
|
||||
$this->backup["roles"] = $token["roles"];
|
||||
|
@ -311,10 +311,10 @@ class genTokenOptions
|
|||
$tokenSerialized = [];
|
||||
$tokenSerialized["token"]["methods"] = serialize($token->methods);
|
||||
$tokenSerialized["roles"] = [];
|
||||
|
||||
|
||||
foreach($token->roles as $role){
|
||||
$tokenSerialized["roles"][serialize($role->id)]["links"] = serialize($role->links);
|
||||
$tokenSerialized["roles"][serialize($role->id)]["name"] = serialize($role->name);
|
||||
$tokenSerialized["roles"][$role->id]["links"] = serialize($role->links);
|
||||
$tokenSerialized["roles"][$role->id]["name"] = serialize($role->name);
|
||||
}
|
||||
|
||||
$tokenSerialized["token"]["expires"] = serialize($token->expires);
|
||||
|
@ -326,19 +326,21 @@ class genTokenOptions
|
|||
$tokenSerialized['saved']["project"]["links"] = serialize($token->project->links);
|
||||
$tokenSerialized['saved']["project"]["name"] = $token->project->name;
|
||||
|
||||
$tokenSerialized['saved']["catalog"] = array();
|
||||
foreach($token->catalog->services as $service){
|
||||
$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);
|
||||
$tokenSerialized['saved']["catalog"][$service->id]["name"] = serialize($service->name);
|
||||
$tokenSerialized['saved']["catalog"][$service->id]["description"] = serialize($service->description);
|
||||
$tokenSerialized['saved']["catalog"][$service->id]["type"] = serialize($service->type);
|
||||
|
||||
foreach($service->endpoints as $end){
|
||||
$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['saved']["catalog"][$service->id]["endpoints"][$end->id]["interface"] = serialize($end->interface);
|
||||
$tokenSerialized['saved']["catalog"][$service->id]["endpoints"][$end->id]["name"] = serialize($end->name);
|
||||
$tokenSerialized['saved']["catalog"][$service->id]["endpoints"][$end->id]["serviceId"] = serialize($end->serviceId);
|
||||
$tokenSerialized['saved']["catalog"][$service->id]["endpoints"][$end->id]["region"] = serialize($end->region);
|
||||
$tokenSerialized['saved']["catalog"][$service->id]["endpoints"][$end->id]["links"] = serialize($end->links);
|
||||
$tokenSerialized['saved']["catalog"][$service->id]["endpoints"][$end->id]["url"] = serialize($end->url);
|
||||
}
|
||||
$tokenSerialized['saved']["catalog"][serialize($service->id)]["links"] = serialize($service->links);
|
||||
$tokenSerialized['saved']["catalog"][$service->id]["links"] = serialize($service->links);
|
||||
}
|
||||
$tokenSerialized["token"]["extras"] = serialize($token->extras);
|
||||
$tokenSerialized["user"]["domainId"] = serialize($token->user->domainId);
|
||||
|
@ -359,15 +361,16 @@ class genTokenOptions
|
|||
private function unserializeToken($tokenSerialized){
|
||||
$Saved = file_get_contents("core/LibOverride/projectTokenData/".$this->backup["project"]);
|
||||
$Saved = unserialize($Saved);
|
||||
|
||||
$api = new Api();
|
||||
$token = new Models\Token($this->httpClient, $api);
|
||||
$token->methods = unserialize($tokenSerialized["methods"]);
|
||||
$token->roles = [];
|
||||
|
||||
|
||||
foreach($this->backup["roles"] as $key => $role){
|
||||
$tmp = new Models\Role($this->httpClient, $api);
|
||||
|
||||
$tmp->id = unserialize($key);
|
||||
$tmp->id = $key;
|
||||
$tmp->links = unserialize($role["links"]);
|
||||
$tmp->name = unserialize($role["name"]);
|
||||
|
||||
|
@ -386,18 +389,19 @@ class genTokenOptions
|
|||
|
||||
$token->catalog = new Models\Catalog($this->httpClient, $api);
|
||||
$token->catalog->services = [];
|
||||
//error_log(print_r($Saved["catalog"], true), 0);
|
||||
|
||||
foreach($Saved["catalog"] as $key => $service){
|
||||
$tmp = new Models\Service($this->httpClient, $api);
|
||||
|
||||
$tmp->id = unserialize($key);
|
||||
$tmp->id = $key;
|
||||
$tmp->name = unserialize($service["name"]);
|
||||
$tmp->description = unserialize($service["description"]);
|
||||
$tmp->type = unserialize($service["type"]);
|
||||
$tmp->endpoints = [];
|
||||
|
||||
foreach($service["endpoints"] as $key => $end){
|
||||
$tmpEnd = new Models\Endpoint($this->httpClient, $api);
|
||||
$tmpEnd->id = unserialize($key);
|
||||
$tmpEnd->id = $key;
|
||||
$tmpEnd->interface = unserialize($end["interface"]);
|
||||
$tmpEnd->name = unserialize($end["name"]);
|
||||
$tmpEnd->serviceId = unserialize($end["serviceId"]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue