Merge branch 'develop' into loic

This commit is contained in:
manzerbredes 2016-03-30 14:14:10 +02:00
commit 237b627bf6
8 changed files with 147 additions and 58 deletions

19
client/Test/index.html Normal file
View file

@ -0,0 +1,19 @@
<head>
<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/services/Test.js"></script>
<script src="../js/app.js"></script>
</head>
<body ng-app="mainApp">
<div ng-controller="hassan">
<ul>
<li ng-repeat="person in persons">
{{person.Name + ' : ' + person.Age}}
</li>
</ul>
</div>
</body>

View file

@ -0,0 +1,27 @@
mainApp.factory('Network',[ '$http', 'Identity', function($http, Identity){
var data={};
data.networks=null;
var ListId=function(fileToUpload, callback) {
var result=$http.post('../server/index.php',
$.param({"token" : Identity.getToken(), "task" : "network", 'action':'list_network_ids'}));
// Wait and handle the response
result.then(function (response){
callback(parseUploadImageAnswer(response, false));
},function(response){
callback(parseUploadImageAnswer(response, true));
});
console.log(result)
}
}]);

View file

@ -0,0 +1,8 @@
var app = angular.module('mainApp',[]);
app.controller('hassan', function($scope,$http){
$http.get('http://127.0.0.1/database.json').success(function(response){
$scope.persons = response.records;
});
});

View file

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

View file

@ -5,7 +5,7 @@
* @version 1.0 Initialisation of this file * @version 1.0 Initialisation of this file
* @since 1.0 Core application's 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 * @todo Complete the functions with errors detection and finish the descriptions
*/ */
@ -16,25 +16,28 @@ include("Network.php");
include("Compute.php"); include("Compute.php");
class automating implements Core{ class automating implements Core{
/** @var App $app protected, contains the main app object */ /** @var App $app protected, contains the main app object */
protected $app; protected $appCompute;
protected $appImage;
/** @var OpenStack\Identity $libClass protected, contains the library Identity object */ protected $appNetwork;
protected $libClass; 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){ public function __construct($app){
if(!isset($app)){ if(!isset($app)){
$this->app->setOutput("Error", "Incorrect parameter app"); $this->app->setOutput("Error", "Parameter app missing.");
} }
$this->app = $app; $this->appCompute = $appCompute;
$this->libClass = $app->getLibClass("Automating"); $this->appImage = $appImage;
$this->appNetwork = $appNetwork;
$this->appIdentity = $appIdentity;
} }
/** /**
@ -48,6 +51,27 @@ class automating implements Core{
$this->{$action.""}(); $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 * Create a new image on a new server
* *
@ -124,4 +148,4 @@ class automating implements Core{
} }
} }
?> ?>

View file

@ -170,7 +170,7 @@ class compute
try{ try{
$serverId = $this->app->getPostParam("serverId"); $serverId = $this->app->getPostParam("serverId");
if(!isset($serverId)){ if(!isset($serverId)){
$this->app->setOutput("Error", "Server ID is missing, son!"); $this->app->setOutput("Error", "Server ID is missing!");
return; return;
} }
$opt = array('id' => $serverId); $opt = array('id' => $serverId);
@ -204,7 +204,7 @@ class compute
try{ try{
$flavorId = $this->app->getPostParam("flavorId"); $flavorId = $this->app->getPostParam("flavorId");
if(!isset($serverId)){ if(!isset($serverId)){
$this->app->setOutput("Error", "Flavor ID is missing, son!"); $this->app->setOutput("Error", "Flavor ID is missing!");
return; return;
} }
$opt = array('id' => $flavorId); $opt = array('id' => $flavorId);
@ -238,7 +238,7 @@ class compute
try{ try{
$imageId = $this->app->getPostParam("imageId"); $imageId = $this->app->getPostParam("imageId");
if(!isset($serverId)){ if(!isset($serverId)){
$this->app->setOutput("Error", "Image ID is missing, son!"); $this->app->setOutput("Error", "Image ID is missing!");
return; return;
} }
$opt = array('id' => $imageId); $opt = array('id' => $imageId);
@ -274,7 +274,7 @@ class compute
$imageId = $this->app->getPostParam("imageId"); $imageId = $this->app->getPostParam("imageId");
$flavorId = $this->app->getPostParam("flavorId"); $flavorId = $this->app->getPostParam("flavorId");
if(!isset($name) || !isset($imageId) || !isset($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; return;
} }
$opt = array('name' => $name, 'imageId' => $imageId, 'flavorId' => $flavorId); $opt = array('name' => $name, 'imageId' => $imageId, 'flavorId' => $flavorId);
@ -353,7 +353,7 @@ class compute
try{ try{
$serverId = $this->app->getPostParam("serverId"); $serverId = $this->app->getPostParam("serverId");
if(!isset($serverId)){ if(!isset($serverId)){
$this->app->setOutput("Error", "Server ID is missing, son!"); $this->app->setOutput("Error", "Server ID is missing!");
return; return;
} }
$opt = array('id' => $serverId); $opt = array('id' => $serverId);
@ -422,7 +422,7 @@ class compute
try{ try{
$serverId = $this->app->getPostParam("serverId"); $serverId = $this->app->getPostParam("serverId");
if(!isset($serverId)){ if(!isset($serverId)){
$this->app->setOutput("Error", "Server ID is missing, son!"); $this->app->setOutput("Error", "Server ID is missing!");
return; return;
} }
$opt = array('id' => $serverId); $opt = array('id' => $serverId);

View file

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

View file

@ -69,7 +69,7 @@ class network{
* *
* @return void * @return void
*/ */
public function create_network() private function create_network()
{ {
$options = array(); $options = array();
// check the name if it is null // check the name if it is null
@ -136,7 +136,7 @@ class network{
* @return void * @return void
*/ */
public function create_subnet() private function create_subnet()
{ $options = array(); { $options = array();
if (isset($this->app->getPostParam("networkId"))) if (isset($this->app->getPostParam("networkId")))
{ {
@ -213,7 +213,7 @@ class network{
* @return List of Networks ID * @return List of Networks ID
*/ */
public function list_network_ids() private function list_network_ids()
{ {
try try
{ {
@ -256,7 +256,7 @@ class network{
* @return List of Networks name * @return List of Networks name
*/ */
public function list_network_names() private function list_network_names()
{ {
try try
{ {
@ -298,7 +298,7 @@ class network{
* *
* @return List of SUBNETS CIDR * @return List of SUBNETS CIDR
*/ */
public function list_cidr() private function list_cidr()
{ {
try try
{ {
@ -335,7 +335,7 @@ class network{
* @return Network * @return Network
*/ */
retrieve a specific network retrieve a specific network
public function getNetwork() private function getNetwork()
{ {
$network=""; $network="";
@ -409,7 +409,7 @@ class network{
* @param subnetId ID of subnet which we want to get * @param subnetId ID of subnet which we want to get
* @return subnet * @return subnet
*/ */
public function getSubnet() private function getSubnet()
{ {
$sbnet=""; $sbnet="";
@ -487,7 +487,7 @@ class network{
* @return void * @return void
**/ **/
public function updateNetwork() private function updateNetwork()
{ {
$options = array(); $options = array();
if(isset($this->app->getPostParam("name"))) if(isset($this->app->getPostParam("name")))
@ -545,7 +545,7 @@ class network{
* @return void * @return void
**/ **/
public function updateSubnet() private function updateSubnet()
{ {
$options = array(); $options = array();
if(isset($this->app->getPostParam("name"))) if(isset($this->app->getPostParam("name")))
@ -597,7 +597,7 @@ class network{
* *
* @return void * @return void
**/ **/
public function deleteNetwork() private function deleteNetwork()
{ {
try try
{ {
@ -632,7 +632,7 @@ class network{
* *
* @return void * @return void
**/ **/
public function deleteSubnet() private function deleteSubnet()
{ {
try try
{ {
@ -673,7 +673,7 @@ class network{
* @return void * @return void
*/ */
public function createPort() private function createPort()
{ {
$options = array(); $options = array();
if (isset($this->app->getPostParam("networkId"))) if (isset($this->app->getPostParam("networkId")))
@ -740,7 +740,7 @@ class network{
* @return List of ports * @return List of ports
*/ */
public function listPorts() private function listPorts()
{ {
try try
{ {
@ -770,7 +770,7 @@ class network{
* @return port * @return port
*/ */
public function getPort() private function getPort()
{ {
try try
{ {
@ -845,7 +845,7 @@ class network{
* *
* @return void * @return void
*/ */
public function updatePort() private function updatePort()
{ {
$options = array(); $options = array();
@ -914,7 +914,7 @@ class network{
* @return void * @return void
*/ */
public function deletePort() private function deletePort()
{ {
try try
@ -949,7 +949,7 @@ class network{
* @return void * @return void
*/ */
public function createSecurityGroup() private function createSecurityGroup()
{ {
$options = array(); $options = array();
if (isset($this->app->getPostParam("name"))) if (isset($this->app->getPostParam("name")))
@ -997,7 +997,7 @@ class network{
* *
* @return void * @return void
*/ */
public function createSecurityGroupRule() private function createSecurityGroupRule()
{ {
$options = array(); $options = array();
if (isset($this->app->getPostParam("securityGroupId"))) if (isset($this->app->getPostParam("securityGroupId")))
@ -1061,7 +1061,7 @@ class network{
* @return List of Security Groupes * @return List of Security Groupes
*/ */
public function listSecurityGroupe() private function listSecurityGroupe()
{ {
try try
{ {
@ -1092,7 +1092,7 @@ class network{
* @return List of Security Groupe Rules * @return List of Security Groupe Rules
*/ */
public function listSecurityGroupeRule() private function listSecurityGroupeRule()
{ {
try try
{ {
@ -1124,7 +1124,7 @@ class network{
* @return securityGroupe * @return securityGroupe
*/ */
public function getSecurityGroupe() private function getSecurityGroupe()
{ {
try try
{ {
@ -1186,7 +1186,7 @@ class network{
* @param securityGroupeId ID of security Groupe which we want to get * @param securityGroupeId ID of security Groupe which we want to get
* @return void * @return void
*/ */
public function deleteSecurityGroupe() private function deleteSecurityGroupe()
{ {
try try
{ {