feature #2489: Size must be set for SOURCE based images

(cherry picked from commit cd177e6ab0566641a0e8810ed5947cc9c2ddcdeb)
(cherry picked from commit 6f979c970d)
This commit is contained in:
Ruben S. Montero authored and Javi Fontan committed 2013-11-22 23:47:35 +01:00
1 parent 4d425c62b5
commit 3963aa899b
2 files changed
+16 -8

No files matched your search

+1 -4
View File
@@ -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)
+15 -4
View File
@@ -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