Finishing upload !!!
This commit is contained in:
parent
f0e77d6b65
commit
80ce348e43
2 changed files with 630 additions and 599 deletions
|
@ -38,7 +38,6 @@
|
||||||
<input type="hidden" name="task" value="image" />
|
<input type="hidden" name="task" value="image" />
|
||||||
<input type="hidden" name="token" value="{{ getToken()}}" />
|
<input type="hidden" name="token" value="{{ getToken()}}" />
|
||||||
<input type="hidden" name="action" value="uploadImage" />
|
<input type="hidden" name="action" value="uploadImage" />
|
||||||
<input type="hidden" name="diskFormat" value="QCOW2" />
|
|
||||||
|
|
||||||
<input type="hidden" name="id" value="{{ image.id}}" />
|
<input type="hidden" name="id" value="{{ image.id}}" />
|
||||||
<input type="hidden" name="file_name" value="cirros-0.3.4-x86_64-disk.img" />
|
<input type="hidden" name="file_name" value="cirros-0.3.4-x86_64-disk.img" />
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* File containing the Image Class.
|
* File containing the Image Class.
|
||||||
*
|
*
|
||||||
|
@ -9,6 +8,7 @@
|
||||||
* @author Evan Pisani 'yogg at epsina . com'
|
* @author Evan Pisani 'yogg at epsina . com'
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use OpenCloud\Common\Error\BadResponseError;
|
use OpenCloud\Common\Error\BadResponseError;
|
||||||
use OpenCloud\Common\Error\BaseError;
|
use OpenCloud\Common\Error\BaseError;
|
||||||
use OpenCloud\Common\Error\NotImplementedError;
|
use OpenCloud\Common\Error\NotImplementedError;
|
||||||
|
@ -45,6 +45,7 @@ class image implements Core {
|
||||||
$this->libClass = $app->getLibClass("Image");
|
$this->libClass = $app->getLibClass("Image");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute an action
|
* Execute an action
|
||||||
*
|
*
|
||||||
|
@ -84,7 +85,8 @@ class image implements Core {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$options['name'] = $opt['name'];
|
$options['name'] = $opt['name'];
|
||||||
} else {
|
}
|
||||||
|
else{
|
||||||
$this->app->setOutput("Error", "Missing parameter 'name' for the new image");
|
$this->app->setOutput("Error", "Missing parameter 'name' for the new image");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,9 +105,13 @@ class image implements Core {
|
||||||
}
|
}
|
||||||
if(isset($opt['containerFormat'])){ // string : ami, ari, aki, bare, ovf, ova, docker
|
if(isset($opt['containerFormat'])){ // string : ami, ari, aki, bare, ovf, ova, docker
|
||||||
$options['containerFormat'] = $opt['containerFormat'];
|
$options['containerFormat'] = $opt['containerFormat'];
|
||||||
|
}else{
|
||||||
|
$options['containerFormat'] = "bare";
|
||||||
}
|
}
|
||||||
if(isset($opt['diskFormat'])){ // string : ami, ari, aki, vhd, vmdk, raw, qcow2, vdi, iso
|
if(isset($opt['diskFormat'])){ // string : ami, ari, aki, vhd, vmdk, raw, qcow2, vdi, iso
|
||||||
$options['diskFormat'] = $opt['diskFormat'];
|
$options['diskFormat'] = $opt['diskFormat'];
|
||||||
|
}else{
|
||||||
|
$options['diskFormat'] = "iso";
|
||||||
}
|
}
|
||||||
if(isset($opt['minDisk'])){ //int
|
if(isset($opt['minDisk'])){ //int
|
||||||
$options['minDisk'] = $opt['minDisk'];
|
$options['minDisk'] = $opt['minDisk'];
|
||||||
|
@ -133,6 +139,7 @@ class image implements Core {
|
||||||
$this->app->getErrorInstance()->OtherException($e);
|
$this->app->getErrorInstance()->OtherException($e);
|
||||||
}
|
}
|
||||||
$this->app->setOutput("Images", $image);
|
$this->app->setOutput("Images", $image);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -160,6 +167,7 @@ class image implements Core {
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->app->setOutput("Images", $result);
|
$this->app->setOutput("Images", $result);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -174,13 +182,15 @@ class image implements Core {
|
||||||
|
|
||||||
if(!isset($id)){
|
if(!isset($id)){
|
||||||
$this->app->setOutput("Error", "Incorrect id parameter");
|
$this->app->setOutput("Error", "Incorrect id parameter");
|
||||||
} else {
|
}
|
||||||
|
else{
|
||||||
try{
|
try{
|
||||||
$service = $this->libClass;
|
$service = $this->libClass;
|
||||||
$image = $service->getImage($id);
|
$image = $service->getImage($id);
|
||||||
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");
|
||||||
} else {
|
}
|
||||||
|
else{
|
||||||
$this->app->setOutput("Images", $image);
|
$this->app->setOutput("Images", $image);
|
||||||
}
|
}
|
||||||
}catch(BadResponseError $e){
|
}catch(BadResponseError $e){
|
||||||
|
@ -205,15 +215,18 @@ class image implements Core {
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
|
||||||
private function updateImage(){
|
private function updateImage(){
|
||||||
$id = $this->app->getPostParam("id");
|
$id = $this->app->getPostParam("id");
|
||||||
$opt = $this->app->getPostParam("opt");
|
$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");
|
||||||
} else if (!isset($opt)) {
|
}
|
||||||
|
else if(!isset($opt)){
|
||||||
$this->app->setOutput("Error", "Incorrect opt parameter");
|
$this->app->setOutput("Error", "Incorrect opt parameter");
|
||||||
} else {
|
}
|
||||||
|
else{
|
||||||
try{
|
try{
|
||||||
$service = $this->libClass;
|
$service = $this->libClass;
|
||||||
$image = $service->getImage($id);
|
$image = $service->getImage($id);
|
||||||
|
@ -234,7 +247,7 @@ class image implements Core {
|
||||||
$options['minRam'] = $opt['minRam'];
|
$options['minRam'] = $opt['minRam'];
|
||||||
}
|
}
|
||||||
if(isset($opt['protected'])){ // boolean
|
if(isset($opt['protected'])){ // boolean
|
||||||
$options['protected'] = $opt['protected'] == "true" ? true : false;
|
$options['protected'] = $opt['protected'];
|
||||||
}
|
}
|
||||||
if(isset($opt['visibility'])){ // public, private
|
if(isset($opt['visibility'])){ // public, private
|
||||||
$options['visibility'] = $opt['visibility'];
|
$options['visibility'] = $opt['visibility'];
|
||||||
|
@ -269,7 +282,8 @@ class image implements Core {
|
||||||
$id = $this->app->getPostParam("id");
|
$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");
|
||||||
} else {
|
}
|
||||||
|
else{
|
||||||
try{
|
try{
|
||||||
$service = $this->libClass;
|
$service = $this->libClass;
|
||||||
$image = $this->libClass->getImage($id);
|
$image = $this->libClass->getImage($id);
|
||||||
|
@ -303,7 +317,9 @@ class image implements Core {
|
||||||
|
|
||||||
if(!isset($id)){
|
if(!isset($id)){
|
||||||
$this->app->setOutput("Error", "Incorrect parameter");
|
$this->app->setOutput("Error", "Incorrect parameter");
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
try{
|
try{
|
||||||
$service = $this->libClass;
|
$service = $this->libClass;
|
||||||
$image = $service->getImage($id);
|
$image = $service->getImage($id);
|
||||||
|
@ -338,7 +354,9 @@ class image implements Core {
|
||||||
|
|
||||||
if(!isset($id)){
|
if(!isset($id)){
|
||||||
$this->app->setOutput("Error", "Incorrect parameter");
|
$this->app->setOutput("Error", "Incorrect parameter");
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
try{
|
try{
|
||||||
$service = $this->libClass;
|
$service = $this->libClass;
|
||||||
$image = $service->getImage($id);
|
$image = $service->getImage($id);
|
||||||
|
@ -376,9 +394,11 @@ class image implements Core {
|
||||||
|
|
||||||
if(!isset($id)){
|
if(!isset($id)){
|
||||||
$this->app->setOutput("Error", "Incorrect id parameter");
|
$this->app->setOutput("Error", "Incorrect id parameter");
|
||||||
} else if (!isset($file_name)) {
|
}
|
||||||
|
else if(!isset($file_name)){
|
||||||
$this->app->setOutput("Error", "Incorrect file name parameter");
|
$this->app->setOutput("Error", "Incorrect file name parameter");
|
||||||
} else {
|
}
|
||||||
|
else{
|
||||||
try{
|
try{
|
||||||
$service = $this->libClass;
|
$service = $this->libClass;
|
||||||
$image = $service->getImage($id);
|
$image = $service->getImage($id);
|
||||||
|
@ -388,7 +408,8 @@ class image implements Core {
|
||||||
$stream = \GuzzleHttp\Psr7\stream_for($file);
|
$stream = \GuzzleHttp\Psr7\stream_for($file);
|
||||||
$image->uploadData($stream);
|
$image->uploadData($stream);
|
||||||
}catch(BadResponseError $e){
|
}catch(BadResponseError $e){
|
||||||
$this->app->getErrorInstance()->BadResponseHandler($e);
|
echo $e;
|
||||||
|
//$this->app->getErrorInstance()->BadResponseHandler($e);
|
||||||
}catch(UserInputError $e){
|
}catch(UserInputError $e){
|
||||||
$this->app->getErrorInstance()->UserInputHandler($e);
|
$this->app->getErrorInstance()->UserInputHandler($e);
|
||||||
}catch(BaseError $e){
|
}catch(BaseError $e){
|
||||||
|
@ -413,7 +434,8 @@ class image implements Core {
|
||||||
|
|
||||||
if(!isset($id)){
|
if(!isset($id)){
|
||||||
$this->app->setOutput("Error", "Incorrect id parameter");
|
$this->app->setOutput("Error", "Incorrect id parameter");
|
||||||
} else {
|
}
|
||||||
|
else{
|
||||||
try{
|
try{
|
||||||
$service = $this->libClass;
|
$service = $this->libClass;
|
||||||
$image = $service->getImage($id);
|
$image = $service->getImage($id);
|
||||||
|
@ -450,9 +472,11 @@ class image implements Core {
|
||||||
|
|
||||||
if(!isset($image_id)){
|
if(!isset($image_id)){
|
||||||
$this->app->setOutput("Error", "Incorrect image id parameter");
|
$this->app->setOutput("Error", "Incorrect image id parameter");
|
||||||
} else if (!isset($member_id)) {
|
}
|
||||||
|
else if(!isset($member_id)){
|
||||||
$this->app->setOutput("Error", "Incorrect member id parameter");
|
$this->app->setOutput("Error", "Incorrect member id parameter");
|
||||||
} else {
|
}
|
||||||
|
else{
|
||||||
try{
|
try{
|
||||||
$service = $this->libClass;
|
$service = $this->libClass;
|
||||||
|
|
||||||
|
@ -476,6 +500,7 @@ class image implements Core {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List members of an image
|
* List members of an image
|
||||||
*
|
*
|
||||||
|
@ -489,9 +514,11 @@ class image implements Core {
|
||||||
|
|
||||||
if(!isset($image_id)){
|
if(!isset($image_id)){
|
||||||
$this->app->setOutput("Error", "Incorrect image id parameter");
|
$this->app->setOutput("Error", "Incorrect image id parameter");
|
||||||
} else if (!isset($member_id)) {
|
}
|
||||||
|
else if(!isset($member_id)){
|
||||||
$this->app->setOutput("Error", "Incorrect member id parameter");
|
$this->app->setOutput("Error", "Incorrect member id parameter");
|
||||||
} else {
|
}
|
||||||
|
else{
|
||||||
try{
|
try{
|
||||||
$service = $this->libClass;
|
$service = $this->libClass;
|
||||||
$image = $service->getImage($image_id);
|
$image = $service->getImage($image_id);
|
||||||
|
@ -531,9 +558,11 @@ class image implements Core {
|
||||||
|
|
||||||
if(!isset($image_id)){
|
if(!isset($image_id)){
|
||||||
$this->app->setOutput("Error", "Incorrect image id parameter");
|
$this->app->setOutput("Error", "Incorrect image id parameter");
|
||||||
} else if (!isset($member_id)) {
|
}
|
||||||
|
else if(!isset($member_id)){
|
||||||
$this->app->setOutput("Error", "Incorrect member id parameter");
|
$this->app->setOutput("Error", "Incorrect member id parameter");
|
||||||
} else {
|
}
|
||||||
|
else{
|
||||||
try{
|
try{
|
||||||
$service = $this->libClass;
|
$service = $this->libClass;
|
||||||
|
|
||||||
|
@ -575,9 +604,11 @@ class image implements Core {
|
||||||
|
|
||||||
if(!isset($image_id)){
|
if(!isset($image_id)){
|
||||||
$this->app->setOutput("Error", "Incorrect image id parameter");
|
$this->app->setOutput("Error", "Incorrect image id parameter");
|
||||||
} else if (!isset($member_id)) {
|
}
|
||||||
|
else if(!isset($member_id)){
|
||||||
$this->app->setOutput("Error", "Incorrect member id parameter");
|
$this->app->setOutput("Error", "Incorrect member id parameter");
|
||||||
} else {
|
}
|
||||||
|
else{
|
||||||
try{
|
try{
|
||||||
$service = $this->libClass;
|
$service = $this->libClass;
|
||||||
|
|
||||||
|
@ -620,9 +651,11 @@ class image implements Core {
|
||||||
|
|
||||||
if(!isset($image_id)){
|
if(!isset($image_id)){
|
||||||
$this->app->setOutput("Error", "Incorrect image id parameter");
|
$this->app->setOutput("Error", "Incorrect image id parameter");
|
||||||
} else if (!isset($member_id)) {
|
}
|
||||||
|
else if(!isset($member_id)){
|
||||||
$this->app->setOutput("Error", "Incorrect member id parameter");
|
$this->app->setOutput("Error", "Incorrect member id parameter");
|
||||||
} else {
|
}
|
||||||
|
else{
|
||||||
try{
|
try{
|
||||||
$service = $this->libClass;
|
$service = $this->libClass;
|
||||||
|
|
||||||
|
@ -650,5 +683,4 @@ class image implements Core {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Add table
Reference in a new issue