This commit is contained in:
root 2016-03-30 12:42:40 +02:00
commit b6ffc16d78
4 changed files with 71 additions and 36 deletions

View file

@ -14,7 +14,7 @@ $opt['name'] = "Test";
$opt['tags'] = ['test', 'openstack'];
//$opt['containerFormat'] = 'ami';
//$opt['diskFormat'] = 'iso';
$opt['visibility'] = 'public';
//$opt['visibility'] = 'public';
$opt['minDisk'] = 1;
$opt['protected'] = false;
$opt['minRam'] = 10;
@ -25,30 +25,39 @@ $retCreate = json_decode($App->show(), true)["Images"];
$idNew = $retCreate['id'];
*/
/*
// Delete Image
$App->setPostParam('id', $idNew);
$image->action("deleteImage");
*/
// Liste images
$image->action("listImage");
$im = $App->show();
$images = json_decode($im, true)["Images"];
echo "List images :</br>";
$res;
echo "List images :</br></br>";
foreach($images as $i){
echo $i['name']."</br>"; // Nom
$name = $i['name'];
if(strcmp($name,"Test") == 0)
{
$res = $i['id'];
}
echo $name."</br>"; // Nom
echo $i['status']."</br>"; // Status
$id = $i['id']; // Id
echo $id."</br>";
foreach ($i['tags'] as $tag) { // Tags
/*foreach ($i['tags'] as $tag) { // Tags
echo $tag."</br>";
}
}*/
echo "</br>";
}
// Delete Image
/*
$App->setPostParam('id', $res);
$image->action("deleteImage");
*/
/*
// Details images
echo "Détail image :</br>";
$App->setPostParam('id', $id);
@ -56,7 +65,7 @@ $image->action("detailsImage");
$retDetails = json_decode($App->show(), true)["Images"];
echo $retDetails['id']."</br>";
echo "</br>";
*/
/*
// Download image
@ -66,18 +75,20 @@ $image->action("downloadImage");
// Desactivate Images
/*
echo "Desactivate image : </br>";
echo $id."</br>";
$App->setPostParam('id', $id);
$err = $image->action("desactivateImage");
echo "</br>";
*/
// Reactivate Images
/*
// Resactivate Images
echo $id."</br>";
$App->setPostParam('id', $id);
$err = $image->action("resactivateImage");
$App->setPostParam('id', $res);
$image->action("reactivateImage");
*/

View file

@ -5,7 +5,7 @@
* @version 1.0 Initialisation of this file
* @since 1.0 Core application's file
*
* @author Evan Pisani 'yogg at epsina . com'
* @author Evan Pisani 'yogg at epsina . com' et bhupi
*
* @todo Complete the functions with errors detection and finish the descriptions
*/
@ -16,25 +16,28 @@ include("Network.php");
include("Compute.php");
class automating 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 App $app protected, contains the main app object */
protected $appCompute;
protected $appImage;
protected $appNetwork;
protected $appIdentity;
/**
* Image constructor
* Our library's app constructor for all server app objects
*
* @param App $app the main app object
* @param App $app the main app object, e.g. compute, image, network, etc.
*
* @return Image
* @return
*/
public function __construct($app){
if(!isset($app)){
$this->app->setOutput("Error", "Incorrect parameter app");
$this->app->setOutput("Error", "Parameter app missing.");
}
$this->app = $app;
$this->libClass = $app->getLibClass("Automating");
$this->appCompute = $appCompute;
$this->appImage = $appImage;
$this->appNetwork = $appNetwork;
$this->appIdentity = $appIdentity;
}
/**
@ -48,6 +51,27 @@ class automating implements Core{
$this->{$action.""}();
}
public function script()
{
$opt = Array();
$opt['name'] = getPostParam('name');
appImage->setPostParam('opt' $opt);
appImage->createImage();
appNetwork->create_network();
appnetwork->list_network_ids();
appNetwork->create_subnet();
appCompute->listFlavors(); //to show all flavors with detail.
appCompute->listImages(); //to show all images with detail and to verify that the image was created successfully by the call above.
appCompute->setPostParam("name","Test");
appCompute->setPostParam("imageId","CREATED_ABOVE");
appCompute->setPostParam("flavorId","1");
appCompute->createServer();
}
/**
* Create a new image on a new server
*

View file

@ -170,7 +170,7 @@ class compute
try{
$serverId = $this->app->getPostParam("serverId");
if(!isset($serverId)){
$this->app->setOutput("Error", "Server ID is missing, son!");
$this->app->setOutput("Error", "Server ID is missing!");
return;
}
$opt = array('id' => $serverId);
@ -204,7 +204,7 @@ class compute
try{
$flavorId = $this->app->getPostParam("flavorId");
if(!isset($serverId)){
$this->app->setOutput("Error", "Flavor ID is missing, son!");
$this->app->setOutput("Error", "Flavor ID is missing!");
return;
}
$opt = array('id' => $flavorId);
@ -238,7 +238,7 @@ class compute
try{
$imageId = $this->app->getPostParam("imageId");
if(!isset($serverId)){
$this->app->setOutput("Error", "Image ID is missing, son!");
$this->app->setOutput("Error", "Image ID is missing!");
return;
}
$opt = array('id' => $imageId);
@ -274,7 +274,7 @@ class compute
$imageId = $this->app->getPostParam("imageId");
$flavorId = $this->app->getPostParam("flavorId");
if(!isset($name) || !isset($imageId) || !isset($flavorId)){
$this->app->setOutput("Error", "No, we don't let you create a server without a name OR image ID OR flavor ID.");
$this->app->setOutput("Error", "Server name OR image ID OR flavor ID is missing.");
return;
}
$opt = array('name' => $name, 'imageId' => $imageId, 'flavorId' => $flavorId);
@ -353,7 +353,7 @@ class compute
try{
$serverId = $this->app->getPostParam("serverId");
if(!isset($serverId)){
$this->app->setOutput("Error", "Server ID is missing, son!");
$this->app->setOutput("Error", "Server ID is missing!");
return;
}
$opt = array('id' => $serverId);
@ -422,7 +422,7 @@ class compute
try{
$serverId = $this->app->getPostParam("serverId");
if(!isset($serverId)){
$this->app->setOutput("Error", "Server ID is missing, son!");
$this->app->setOutput("Error", "Server ID is missing!");
return;
}
$opt = array('id' => $serverId);

View file

@ -51,9 +51,9 @@ class genTokenOptions
}
public function checkToken(){
//error_log($this->backup['time'], 0);
//return $this->backup['time'] > time();
return true;
//error_log(print_r($this->backup['time'], true), 0);
return $this->backup['time'] > time();
//return true;
}
public function genIdentityToken(){
@ -386,7 +386,7 @@ class genTokenOptions
$token->catalog = new Models\Catalog($this->httpClient, $api);
$token->catalog->services = [];
error_log(print_r($Saved["catalog"], true), 0);
//error_log(print_r($Saved["catalog"], true), 0);
foreach($Saved["catalog"] as $key => $service){
$tmp = new Models\Service($this->httpClient, $api);