Architecture modification
This commit is contained in:
parent
b6d7d2c30e
commit
0298591cee
2 changed files with 79 additions and 81 deletions
|
@ -1,35 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
require '../vendor/autoload.php';
|
include('InitTest.php');
|
||||||
include('/istic-openstack/server/init.php');
|
include_once("../core/Image.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);
|
$image = new Image($App);
|
||||||
|
|
||||||
|
@ -43,52 +14,54 @@ $opt['minDisk'] = 1;
|
||||||
$opt['protected'] = false;
|
$opt['protected'] = false;
|
||||||
$opt['minRam'] = 10;
|
$opt['minRam'] = 10;
|
||||||
|
|
||||||
//$new_image = $image->create_image($opt);
|
//$new_image = $image->createImage($opt);
|
||||||
|
|
||||||
|
|
||||||
//Liste des images
|
//Liste des images
|
||||||
$images = $image->list_images();
|
$image->action("listImage");
|
||||||
|
//$images = $image->listImage();
|
||||||
echo "Images présentes :";
|
$im = $App->show();
|
||||||
echo "</br>";
|
$images = json_decode($im, true)["Images"];
|
||||||
|
if(isset($images)){
|
||||||
foreach($images as $i){
|
echo "Images présentes :";
|
||||||
echo $i->name;
|
echo "</br>";
|
||||||
if($i->name == "Test"){
|
foreach($images as $i){
|
||||||
$id_image = $i->id;
|
echo $i['name'];
|
||||||
$list = $i->tags;
|
echo "</br>";
|
||||||
echo $i->status;
|
|
||||||
}
|
}
|
||||||
echo "</br>";
|
echo "</br>";
|
||||||
}
|
|
||||||
echo "</br>";
|
|
||||||
|
|
||||||
if(isset($list)){
|
if(isset($list)){
|
||||||
foreach ($list as $l) {
|
foreach ($list as $l) {
|
||||||
echo $l;
|
echo $l;
|
||||||
echo "</br>";
|
echo "</br>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
echo "Aucune image présente\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Détails Image
|
// Détails Image
|
||||||
//$details = $image->image_details($id_image);
|
//$details = $image->imageDetails($id_image);
|
||||||
|
|
||||||
//$image->delete_image('123456');
|
//$image->deleteImage('123456');
|
||||||
|
|
||||||
//$image->desactivate_image($id_image);
|
//$image->desactivateImage($id_image);
|
||||||
//$image->reactivate_image($id_image);
|
//$image->reactivateImage($id_image);
|
||||||
|
|
||||||
//$file_name = "/home/yogg/Downloads/TinyCore-6.4.1.iso";
|
//$file_name = "/home/yogg/Downloads/TinyCore-6.4.1.iso";
|
||||||
//$image->upload_image($id_image, $file_name);
|
//$image->uploadImage($id_image, $file_name);
|
||||||
|
|
||||||
//$image->download_image($id_image);
|
//$image->downloadImage($id_image);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
$opt_update = Array();
|
$opt_update = Array();
|
||||||
$opt_update['name'] = "Test";
|
$opt_update['name'] = "Test";
|
||||||
$opt_update['tags'] = null;
|
$opt_update['tags'] = null;
|
||||||
|
|
||||||
$update = $image->update_image($id_image, $opt_update);
|
$update = $image->updateImage($id_image, $opt_update);
|
||||||
echo $update->name;
|
echo $update->name;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,8 @@ use OpenStack\Common\Error\BaseError;
|
||||||
use OpenStack\Common\Error\NotImplementedError;
|
use OpenStack\Common\Error\NotImplementedError;
|
||||||
use OpenStack\Common\Error\UserInputError;
|
use OpenStack\Common\Error\UserInputError;
|
||||||
|
|
||||||
|
include("CoreInterface.php");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Image Class of the back-end application
|
* Image Class of the back-end application
|
||||||
*
|
*
|
||||||
|
@ -77,6 +79,7 @@ class image implements Core{
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
private function createImage(array $opt){
|
private function createImage(array $opt){
|
||||||
|
$opt = $this->app->getPostParam("opt");
|
||||||
|
|
||||||
if(!isset($opt)){
|
if(!isset($opt)){
|
||||||
$this->app->setOutput("Error", "Incorrect parameter");
|
$this->app->setOutput("Error", "Incorrect parameter");
|
||||||
|
@ -141,7 +144,7 @@ class image implements Core{
|
||||||
}catch(NotImplementedError $e){
|
}catch(NotImplementedError $e){
|
||||||
$this->app->getErrorInstance->NotImplementedHandler($e);
|
$this->app->getErrorInstance->NotImplementedHandler($e);
|
||||||
}
|
}
|
||||||
return $image;
|
$this->app->setOutput("Images", $image);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -151,9 +154,10 @@ class image implements Core{
|
||||||
*/
|
*/
|
||||||
private function listImage(){
|
private function listImage(){
|
||||||
try{
|
try{
|
||||||
|
$result = array();
|
||||||
$l = $this->libClass->listImages();
|
$l = $this->libClass->listImages();
|
||||||
if(!isset($l)){ // if the list is empty there is no images
|
foreach($l as $tmp){
|
||||||
$this->app->setOutput("Error", "No image");
|
$result[] = $tmp;
|
||||||
}
|
}
|
||||||
}catch(BadResponseError $e){
|
}catch(BadResponseError $e){
|
||||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||||
|
@ -164,8 +168,7 @@ class image implements Core{
|
||||||
}catch(NotImplementedError $e){
|
}catch(NotImplementedError $e){
|
||||||
$this->app->getErrorInstance->NotImplementedHandler($e);
|
$this->app->getErrorInstance->NotImplementedHandler($e);
|
||||||
}
|
}
|
||||||
return $l;
|
$this->app->setOutput("Images", $result);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -175,9 +178,10 @@ class image implements Core{
|
||||||
* identifier of the image
|
* identifier of the image
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
private function detailsImage($id){
|
private function detailsImage(){
|
||||||
|
$id = $this->app->getPostParam("id");
|
||||||
if(!isset($id)){
|
if(!isset($id)){
|
||||||
// Renvoyer erreur
|
$this->app->setOutput("Error", "Incorrect id parameter");
|
||||||
}
|
}
|
||||||
try{
|
try{
|
||||||
$service = $this->libClass;
|
$service = $this->libClass;
|
||||||
|
@ -185,8 +189,7 @@ class image implements Core{
|
||||||
if($image == null){ // if the image don't exists -> error
|
if($image == null){ // if the image don't exists -> error
|
||||||
$this->app->setOutput("Error", "Image doesn't exist");
|
$this->app->setOutput("Error", "Image doesn't exist");
|
||||||
}
|
}
|
||||||
|
$this->app->setOutput("Images", $image);
|
||||||
return $image;
|
|
||||||
}catch(BadResponseError $e){
|
}catch(BadResponseError $e){
|
||||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||||
}catch(UserInputError $e){
|
}catch(UserInputError $e){
|
||||||
|
@ -207,7 +210,9 @@ class image implements Core{
|
||||||
* @param array $opt
|
* @param array $opt
|
||||||
* options for the image creation
|
* options for the image creation
|
||||||
**/
|
**/
|
||||||
private function updateImage($id, array $opt){
|
private function updateImage(){
|
||||||
|
$id = $this->app->getPostParam("id");
|
||||||
|
$opt = $this->app->getPostParam("opt");
|
||||||
if(!isset($id)){
|
if(!isset($id)){
|
||||||
$this->app->setOutput("Error", "Incorrect id parameter");
|
$this->app->setOutput("Error", "Incorrect id parameter");
|
||||||
}
|
}
|
||||||
|
@ -254,7 +259,7 @@ class image implements Core{
|
||||||
}catch(NotImplementedError $e){
|
}catch(NotImplementedError $e){
|
||||||
$this->app->getErrorInstance->NotImplementedHandler($e);
|
$this->app->getErrorInstance->NotImplementedHandler($e);
|
||||||
}
|
}
|
||||||
return $image;
|
$this->app->setOutput("Images", $image);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -263,9 +268,10 @@ class image implements Core{
|
||||||
* @param string $id
|
* @param string $id
|
||||||
* identifier of the image
|
* identifier of the image
|
||||||
**/
|
**/
|
||||||
private function deleteImage($id){
|
private function deleteImage(){
|
||||||
// si protected = true, demander de le mettre a false
|
// si protected = true, demander de le mettre a false
|
||||||
// vérifier existence image
|
// vérifier existence image
|
||||||
|
$id = $this->app->getPostParam("id");
|
||||||
if(!isset($id)){
|
if(!isset($id)){
|
||||||
$this->app->setOutput("Error", "Image doesn't exist");
|
$this->app->setOutput("Error", "Image doesn't exist");
|
||||||
}
|
}
|
||||||
|
@ -285,8 +291,7 @@ class image implements Core{
|
||||||
$this->app->getErrorInstance->BaseErrorHandler($e);
|
$this->app->getErrorInstance->BaseErrorHandler($e);
|
||||||
}catch(NotImplementedError $e){
|
}catch(NotImplementedError $e){
|
||||||
$this->app->getErrorInstance->NotImplementedHandler($e);
|
$this->app->getErrorInstance->NotImplementedHandler($e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -295,7 +300,8 @@ class image implements Core{
|
||||||
* @param string $id
|
* @param string $id
|
||||||
* identifier of the image
|
* identifier of the image
|
||||||
**/
|
**/
|
||||||
private function reactivateImage($id){
|
private function reactivateImage(){
|
||||||
|
$id = $this->app->getPostParam("id");
|
||||||
if(!isset($id)){
|
if(!isset($id)){
|
||||||
$this->app->setOutput("Error", "Incorrect parameter");
|
$this->app->setOutput("Error", "Incorrect parameter");
|
||||||
}
|
}
|
||||||
|
@ -324,7 +330,8 @@ class image implements Core{
|
||||||
* @param string $id
|
* @param string $id
|
||||||
* identifier of the image
|
* identifier of the image
|
||||||
**/
|
**/
|
||||||
private function desactivateImage($id){
|
private function desactivateImage(){
|
||||||
|
$id = $this->app->getPostParam("id");
|
||||||
if(!isset($id)){
|
if(!isset($id)){
|
||||||
$this->app->setOutput("Error", "Incorrect parameter");
|
$this->app->setOutput("Error", "Incorrect parameter");
|
||||||
}
|
}
|
||||||
|
@ -357,6 +364,9 @@ class image implements Core{
|
||||||
* path of the image
|
* path of the image
|
||||||
**/
|
**/
|
||||||
private function uploadImage($id, $file_name){
|
private function uploadImage($id, $file_name){
|
||||||
|
$id = $this->app->getPostParam("id");
|
||||||
|
$file_name = $this->app->getPostParam("file_name");
|
||||||
|
|
||||||
if(!isset($id)){
|
if(!isset($id)){
|
||||||
$this->app->setOutput("Error", "Incorrect id parameter");
|
$this->app->setOutput("Error", "Incorrect id parameter");
|
||||||
}
|
}
|
||||||
|
@ -390,6 +400,7 @@ class image implements Core{
|
||||||
* identifier of the image
|
* identifier of the image
|
||||||
**/
|
**/
|
||||||
private function downloadImage($id){
|
private function downloadImage($id){
|
||||||
|
$id = $this->app->getPostParam("id");
|
||||||
if(!isset($id)){
|
if(!isset($id)){
|
||||||
$this->app->setOutput("Error", "Incorrect parameter");
|
$this->app->setOutput("Error", "Incorrect parameter");
|
||||||
}
|
}
|
||||||
|
@ -410,7 +421,7 @@ class image implements Core{
|
||||||
}catch(NotImplementedError $e){
|
}catch(NotImplementedError $e){
|
||||||
$this->app->getErrorInstance->NotImplementedHandler($e);
|
$this->app->getErrorInstance->NotImplementedHandler($e);
|
||||||
}
|
}
|
||||||
return $stream;
|
$this->app->setOutput("Images", $stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -422,7 +433,10 @@ class image implements Core{
|
||||||
* @param string $member_id
|
* @param string $member_id
|
||||||
* identifier of the member
|
* identifier of the member
|
||||||
**/
|
**/
|
||||||
private function addMemberImage($image_id, $member_id){
|
private function addMemberImage(){
|
||||||
|
$image_id = $this->app->getPostParam("image_id");
|
||||||
|
$member_id = $this->app->getPostParam("member_id");
|
||||||
|
|
||||||
if(!isset($image_id)){
|
if(!isset($image_id)){
|
||||||
$this->app->setOutput("Error", "Incorrect parameter image_id");
|
$this->app->setOutput("Error", "Incorrect parameter image_id");
|
||||||
}
|
}
|
||||||
|
@ -455,7 +469,9 @@ class image implements Core{
|
||||||
* @param string $image_id
|
* @param string $image_id
|
||||||
* identifier of the image
|
* identifier of the image
|
||||||
**/
|
**/
|
||||||
private function listMemberImage($image_id, $member_id){
|
private function listMemberImage(){
|
||||||
|
$image_id = $this->app->getPostParam("image_id");
|
||||||
|
$member_id = $this->app->getPostParam("member_id");
|
||||||
if(!isset($image_id)){
|
if(!isset($image_id)){
|
||||||
$this->app->setOutput("Error", "Incorrect parameter image_id");
|
$this->app->setOutput("Error", "Incorrect parameter image_id");
|
||||||
}
|
}
|
||||||
|
@ -482,7 +498,7 @@ class image implements Core{
|
||||||
}catch(NotImplementedError $e){
|
}catch(NotImplementedError $e){
|
||||||
$this->app->getErrorInstance->NotImplementedHandler($e);
|
$this->app->getErrorInstance->NotImplementedHandler($e);
|
||||||
}
|
}
|
||||||
return $members;
|
$this->app->setOutput("Images", $member);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -494,7 +510,9 @@ class image implements Core{
|
||||||
* @param string $member_id
|
* @param string $member_id
|
||||||
* identifier of the member
|
* identifier of the member
|
||||||
**/
|
**/
|
||||||
private function detailMemberImage($image_id, $member_id){
|
private function detailMemberImage(){
|
||||||
|
$image_id = $this->app->getPostParam("image_id");
|
||||||
|
$member_id = $this->app->getPostParam("member_id");
|
||||||
if(!isset($image_id)){
|
if(!isset($image_id)){
|
||||||
$this->app->setOutput("Error", "Incorrect parameter image_id");
|
$this->app->setOutput("Error", "Incorrect parameter image_id");
|
||||||
}
|
}
|
||||||
|
@ -525,7 +543,7 @@ class image implements Core{
|
||||||
}catch(NotImplementedError $e){
|
}catch(NotImplementedError $e){
|
||||||
$this->app->getErrorInstance->NotImplementedHandler($e);
|
$this->app->getErrorInstance->NotImplementedHandler($e);
|
||||||
}
|
}
|
||||||
return $member;
|
$this->app->setOutput("Images", $member);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -537,7 +555,10 @@ class image implements Core{
|
||||||
* @param string $member_id
|
* @param string $member_id
|
||||||
* identifier of the member
|
* identifier of the member
|
||||||
**/
|
**/
|
||||||
private function removeMemberImage($image_id, $member_id){
|
private function removeMemberImage(){
|
||||||
|
$image_id = $this->app->getPostParam("image_id");
|
||||||
|
$member_id = $this->app->getPostParam("member_id");
|
||||||
|
|
||||||
if(!isset($image_id)){
|
if(!isset($image_id)){
|
||||||
$this->app->setOutput("Error", "Incorrect parameter image_id");
|
$this->app->setOutput("Error", "Incorrect parameter image_id");
|
||||||
}
|
}
|
||||||
|
@ -580,6 +601,10 @@ class image implements Core{
|
||||||
* new status for the member
|
* new status for the member
|
||||||
**/
|
**/
|
||||||
private function updateMemberImage($image_id, $member_id, $status){
|
private function updateMemberImage($image_id, $member_id, $status){
|
||||||
|
$image_id = $this->app->getPostParam("image_id");
|
||||||
|
$member_id = $this->app->getPostParam("member_id");
|
||||||
|
$status = $this->app->getPostParam("status");
|
||||||
|
|
||||||
if(!isset($image_id)){
|
if(!isset($image_id)){
|
||||||
$this->app->setOutput("Error", "Incorrect parameter image_id");
|
$this->app->setOutput("Error", "Incorrect parameter image_id");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue