tests
This commit is contained in:
parent
219847749e
commit
dff92c2d58
2 changed files with 27 additions and 59 deletions
|
@ -1,35 +1,6 @@
|
|||
<?php
|
||||
require '../vendor/autoload.php';
|
||||
include('/istic-openstack/server/init.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';
|
||||
include('InitTest.php');
|
||||
include_once("../core/Image.php");
|
||||
|
||||
$image = new Image($App);
|
||||
|
||||
|
@ -45,9 +16,8 @@ $opt['minRam'] = 10;
|
|||
|
||||
//$new_image = $image->create_image($opt);
|
||||
|
||||
|
||||
//Liste des images
|
||||
$images = $image->list_images();
|
||||
$images = $image["listImages"];
|
||||
|
||||
echo "Images présentes :";
|
||||
echo "</br>";
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
<?php
|
||||
|
||||
//require 'CoreInterface.php';
|
||||
|
||||
/**
|
||||
* File containing the Image Class.
|
||||
*
|
||||
|
@ -12,7 +9,7 @@
|
|||
*
|
||||
* @todo Complete the functions with errors detection and finish the descriptions
|
||||
*/
|
||||
|
||||
use OpenStack\Common\Error;
|
||||
|
||||
/**
|
||||
* Image Class of the back-end application
|
||||
|
@ -20,7 +17,7 @@
|
|||
* ADD CLASS DESCRIPTION
|
||||
*
|
||||
*/
|
||||
class image{
|
||||
class image implements Core{
|
||||
//implements Core
|
||||
|
||||
/** @var App $app protected, contains the main app object */
|
||||
|
@ -48,7 +45,7 @@ class image{
|
|||
}
|
||||
|
||||
|
||||
|
||||
$images = array();
|
||||
|
||||
/**
|
||||
* Details about an image
|
||||
|
@ -57,7 +54,7 @@ class image{
|
|||
* options for the image creation
|
||||
*
|
||||
**/
|
||||
public function create_image(array $opt){
|
||||
public function create_image(array $opt){
|
||||
// VOIR SI MAUVAIS TYPE
|
||||
$options = Array();
|
||||
if(isset($opt['name'])){ // string, rendre le nom obligatoire, vérifier nom pas déjà pris
|
||||
|
@ -93,19 +90,20 @@ class image{
|
|||
$options['properties'] = $opt['properties'];
|
||||
}
|
||||
|
||||
$image = $this->oidentity->createImage($options);
|
||||
$image = $this->libClass->createImage($options);
|
||||
|
||||
return $image;
|
||||
}
|
||||
|
||||
/*
|
||||
* List images
|
||||
/**
|
||||
* List the images of the server
|
||||
*
|
||||
* @return the list with all images on the server
|
||||
*/
|
||||
public function list_images(){
|
||||
$images["listImages"] = function() {
|
||||
// vérifier si au moins une image
|
||||
$service = $this->oidentity;
|
||||
$images = $service->listImages();
|
||||
return $images;
|
||||
$this->libClass->listImages();
|
||||
//return $l;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -117,7 +115,7 @@ class image{
|
|||
**/
|
||||
public function image_details($id){
|
||||
//vérifier existence image
|
||||
$service = $this->oidentity;
|
||||
$service = $this->libClass;
|
||||
$image = $service->getImage($id);
|
||||
return $image;
|
||||
}
|
||||
|
@ -133,7 +131,7 @@ class image{
|
|||
**/
|
||||
public function update_image($id, array $opt){
|
||||
//vérifier existence image
|
||||
$service = $this->oidentity;
|
||||
$service = $this->libClass;
|
||||
$image = $service->getImage($id);
|
||||
$options = Array();
|
||||
|
||||
|
@ -170,7 +168,7 @@ class image{
|
|||
public function delete_image($id){
|
||||
// si protected = true, demander de le mettre a false
|
||||
// vérifier existence image
|
||||
$service = $this->oidentity;
|
||||
$service = $this->libClass;
|
||||
$service->getImage($id)->delete();
|
||||
}
|
||||
|
||||
|
@ -182,7 +180,7 @@ class image{
|
|||
**/
|
||||
public function reactivate_image($id){
|
||||
// vérifier existence image
|
||||
$service = $this->oidentity;
|
||||
$service = $this->libClass;
|
||||
$image = $service->getImage($id);
|
||||
$image->reactivate();
|
||||
}
|
||||
|
@ -195,7 +193,7 @@ class image{
|
|||
**/
|
||||
public function desactivate_image($id){
|
||||
// vérifier existence image
|
||||
$service = $this->oidentity;
|
||||
$service = $this->libClass;
|
||||
$image = $service->getImage($id);
|
||||
$image->deactivate();
|
||||
}
|
||||
|
@ -211,7 +209,7 @@ class image{
|
|||
**/
|
||||
public function upload_image($id, $file_name){
|
||||
// vérifier existence image
|
||||
$service = $this->oidentity;
|
||||
$service = $this->libClass;
|
||||
$image = $service->getImage($id);
|
||||
$stream = \GuzzleHttp\Psr7\stream_for(fopen($file_name, 'r')); // A VOIR
|
||||
$image->uploadData($stream);
|
||||
|
@ -225,7 +223,7 @@ class image{
|
|||
**/
|
||||
public function download_image($id){
|
||||
// vérifier existence image
|
||||
$service = $this->oidentity;
|
||||
$service = $this->libClass;
|
||||
$image = $service->getImage($id);
|
||||
$stream = $image->downloadData();
|
||||
return $stream;
|
||||
|
@ -244,7 +242,7 @@ class image{
|
|||
// vérifier existence image
|
||||
// on doit être le proprio de l'image
|
||||
// vérifier membre existe
|
||||
$service = $this->oidentity;
|
||||
$service = $this->libClass;
|
||||
$member_id = $service>getImage($image_id)->addMember($member_id);
|
||||
}
|
||||
|
||||
|
@ -257,7 +255,7 @@ class image{
|
|||
**/
|
||||
public function list_member($image_id, $member_id){
|
||||
// vérifier existence image
|
||||
$service = $this->oidentity;
|
||||
$service = $this->libClass;
|
||||
$image = $service->getImage($image_id);
|
||||
$members = $image->listMembers();
|
||||
return $members;
|
||||
|
@ -276,7 +274,7 @@ class image{
|
|||
// vérifier existence image
|
||||
// on doit être le proprio de l'image
|
||||
// vérifier membre existe
|
||||
$service = $this->oidentity;
|
||||
$service = $this->libClass;
|
||||
$member = $service>getImage($image_id)->getMember($member_id);
|
||||
return $member;
|
||||
}
|
||||
|
@ -294,7 +292,7 @@ class image{
|
|||
// vérifier existence image
|
||||
// on doit être le proprio de l'image
|
||||
// vérifier membre existe
|
||||
$service = $this->oidentity;
|
||||
$service = $this->libClass;
|
||||
$service>getImage($image_id)->getMember($member_id)->delete();
|
||||
}
|
||||
|
||||
|
@ -314,7 +312,7 @@ class image{
|
|||
// vérifier existence image
|
||||
// on doit être le proprio de l'image
|
||||
// vérifier membre existe
|
||||
$service = $this->oidentity;
|
||||
$service = $this->libClass;
|
||||
$member = $service>getImage($image_id)->getMember($member_id)->updateStatus($status);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue