mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
feature #2489: Size must be set for SOURCE based images
(cherry picked from commit cd177e6ab0566641a0e8810ed5947cc9c2ddcdeb)
This commit is contained in:
parent
291f50ba43
commit
6f979c970d
@ -124,12 +124,9 @@ class OneImageHelper < OpenNebulaHelper::OneHelper
|
||||
{
|
||||
:name => "size",
|
||||
:large => "--size size",
|
||||
:description => "Size in MB. Used for DATABLOCK type",
|
||||
:description => "Size in MB. Used for DATABLOCK type or SOURCE based images.",
|
||||
:format => String,
|
||||
:proc => lambda do |o, options|
|
||||
if !options[:type] || !(options[:type].upcase=='DATABLOCK')
|
||||
next [-1, "Size is only used for DATABLOCK type images"]
|
||||
end
|
||||
|
||||
m=o.strip.match(/^(\d+(?:\.\d+)?)(m|mb|g|gb)?$/i)
|
||||
|
||||
|
@ -770,7 +770,16 @@ int ImageManager::stat_image(Template* img_tmpl,
|
||||
|
||||
if (!res.empty())
|
||||
{
|
||||
res = "0";
|
||||
long long size_l;
|
||||
|
||||
if (!img_tmpl->get("SIZE", size_l))
|
||||
{
|
||||
res = "Wrong number or missing SIZE attribute.";
|
||||
return -1;
|
||||
}
|
||||
|
||||
img_tmpl->get("SIZE", res);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -790,14 +799,16 @@ int ImageManager::stat_image(Template* img_tmpl,
|
||||
|
||||
if (res.empty())//no PATH
|
||||
{
|
||||
img_tmpl->get("SIZE", res);
|
||||
long long size_l;
|
||||
|
||||
if (res.empty())
|
||||
if (!img_tmpl->get("SIZE", size_l))
|
||||
{
|
||||
res = "Either SIZE or PATH are mandatory for DATABLOCK.";
|
||||
res = "Wrong number or missing SIZE attribute.";
|
||||
return -1;
|
||||
}
|
||||
|
||||
img_tmpl->get("SIZE", res);
|
||||
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
|
Loading…
x
Reference in New Issue
Block a user