1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-11 05:17:41 +03:00

F #1089 Allow creation of "Empty disk image" for type OS

This commit is contained in:
Christian González 2018-10-18 11:18:15 +02:00 committed by Ruben S. Montero
parent 023063b804
commit a6b8f48c4f
2 changed files with 30 additions and 12 deletions

View File

@ -185,7 +185,7 @@ int Image::insert(SqlDB *db, string& error_str)
if (!is_saving())
{
if ( source.empty() && path.empty() && type != DATABLOCK )
if ( source.empty() && path.empty() && type != DATABLOCK && type != OS)
{
goto error_no_path;
}
@ -194,7 +194,7 @@ int Image::insert(SqlDB *db, string& error_str)
goto error_path_and_source;
}
if ( path.empty() && type == Image::DATABLOCK )
if ( path.empty() && (type == Image::DATABLOCK || type == Image::OS))
{
if ( fs_type.empty() )
{

View File

@ -836,14 +836,7 @@ int ImageManager::register_image(int iid,
{
string source = img->get_source();
if ( img->is_saving() || img->get_type() == Image::DATABLOCK )
{
imd->mkfs(img->get_oid(), *drv_msg);
oss << "Creating disk at " << source << " of "<< img->get_size()
<< "Mb (type: " << img->get_fstype() << ")";
}
else if ( !source.empty() ) //Source in Template
if ( !source.empty() ) //Source in Template
{
img->set_state_unlock();
ipool->update(img);
@ -851,6 +844,14 @@ int ImageManager::register_image(int iid,
oss << "Using source " << source
<< " from template for image " << img->get_name();
}
else if ( img->is_saving() || img->get_type() == Image::DATABLOCK
|| img->get_type() == Image::OS)
{
imd->mkfs(img->get_oid(), *drv_msg);
oss << "Creating disk at " << source << " of "<< img->get_size()
<< "Mb (type: " << img->get_fstype() << ")";
}
}
else //PATH -> COPY TO REPOSITORY AS SOURCE
{
@ -895,7 +896,6 @@ int ImageManager::stat_image(Template* img_tmpl,
switch (Image::str_to_type(type_att))
{
case Image::OS:
case Image::CDROM:
case Image::KERNEL:
case Image::RAMDISK:
@ -929,11 +929,29 @@ int ImageManager::stat_image(Template* img_tmpl,
<< one_util::xml_escape(res)
<< "</PATH></IMAGE>";
break;
case Image::OS:
img_tmpl->get("SOURCE", res);
if (!res.empty()) //SOURCE in Image
{
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;
}
case Image::DATABLOCK:
img_tmpl->get("PATH", res);
if (res.empty())//no PATH
if (res.empty())//no PATH, created using mkfs
{
long long size_l;