mirror of
https://github.com/OpenNebula/one.git
synced 2026-11-17 02:03:15 +09:00
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:
1 parent
4d425c62b5
commit
3963aa899b
2 files changed
+16
-8
No files matched your search
@@ -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
|
||||
|
||||
Reference in new issue
Block a user