mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-23 22:50:09 +03:00
feature #1617: Fix bugs when checking DS and FILE types. Fix bug to stat FILE images
This commit is contained in:
parent
0496414051
commit
8feb9206c4
@ -34,14 +34,14 @@ class OneImageHelper < OpenNebulaHelper::OneHelper
|
||||
:name => "type",
|
||||
:large => "--type type",
|
||||
:format => String,
|
||||
:description => "Type of the new Image: OS, CDROM or DATABLOCK",
|
||||
:description => "Type of the new Image: #{Image::IMAGE_TYPES.join(", ")}",
|
||||
:proc => lambda do |o, options|
|
||||
type=o.strip.upcase
|
||||
|
||||
if %w{OS CDROM DATABLOCK}.include? type
|
||||
if Image::IMAGE_TYPES.include? type
|
||||
[0, type]
|
||||
else
|
||||
[-1, "Type should be OS, CDROM or DATABLOCK"]
|
||||
[-1, "Type should be: #{Image::IMAGE_TYPES.join(", ")}"]
|
||||
end
|
||||
end
|
||||
},
|
||||
|
@ -682,6 +682,7 @@ int ImageManager::stat_image(Template* img_tmpl,
|
||||
{
|
||||
case Image::OS:
|
||||
case Image::CDROM:
|
||||
case Image::DATAFILE:
|
||||
img_tmpl->get("SOURCE", res);
|
||||
|
||||
if (!res.empty())
|
||||
@ -720,6 +721,7 @@ int ImageManager::stat_image(Template* img_tmpl,
|
||||
{
|
||||
img_data << "<IMAGE><PATH>" << res << "</PATH></IMAGE>";
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
add_request(&sr);
|
||||
|
@ -108,9 +108,14 @@ int ImagePool::allocate (
|
||||
if ( ds_type == Datastore::FILE_DS &&
|
||||
img->str_to_type(type) != Image::DATAFILE )
|
||||
{
|
||||
goto error_types_missmatch;
|
||||
goto error_types_missmatch_file;
|
||||
}
|
||||
|
||||
if ( ds_type == Datastore::IMAGE_DS &&
|
||||
img->str_to_type(type) == Image::DATAFILE )
|
||||
{
|
||||
goto error_types_missmatch_image;
|
||||
}
|
||||
img_aux = get(name,uid,false);
|
||||
|
||||
if( img_aux != 0 )
|
||||
@ -191,10 +196,14 @@ error_name_length:
|
||||
oss << "NAME is too long; max length is 128 chars.";
|
||||
goto error_common;
|
||||
|
||||
error_types_missmatch:
|
||||
error_types_missmatch_file:
|
||||
oss << "Only IMAGES of type FILE can be registered in FILE_DS Datastore";
|
||||
goto error_common;
|
||||
|
||||
error_types_missmatch_image:
|
||||
oss << "IMAGES of type FILE can be registered in IMAGE_DS Datastore";
|
||||
goto error_common;
|
||||
|
||||
error_duplicated:
|
||||
oss << "NAME is already taken by IMAGE "
|
||||
<< img_aux->get_oid() << ".";
|
||||
|
@ -203,7 +203,7 @@ void ImageClone::request_execute(
|
||||
if ( img->get_type() == Image::DATAFILE )
|
||||
{
|
||||
failure_response(ACTION,
|
||||
"Image of type FILE cannot be clonned",
|
||||
allocate_error("Image of type FILE cannot be clonned"),
|
||||
att);
|
||||
|
||||
img->unlock();
|
||||
|
Loading…
x
Reference in New Issue
Block a user