1
0
mirror of https://github.com/OpenNebula/one.git synced 2024-12-22 13:33:52 +03:00

Feature #2479: Allow CONTEXT/DEV_PREFIX, and make 'hd' the default prefix for cdrom type disks

This commit is contained in:
Carlos Martín 2013-11-21 16:01:35 +01:00
parent f69e86f2bb
commit bc6ae465d9
4 changed files with 41 additions and 4 deletions

View File

@ -185,6 +185,11 @@ public:
return _default_dev_prefix;
};
static const string& default_cdrom_dev_prefix()
{
return _default_cdrom_dev_prefix;
};
/**
* Get the effective uid to get an image. Used in VM parsers
* @param disk a vector attribute with the image data
@ -215,6 +220,11 @@ private:
**/
static string _default_dev_prefix;
/**
* Default device prefix for cdrom disks
**/
static string _default_cdrom_dev_prefix;
/**
* Image attributes to be inherited into the VM disk
*/

View File

@ -148,8 +148,18 @@ int Image::insert(SqlDB *db, string& error_str)
if( dev_prefix.empty() )
{
SingleAttribute * dev_att = new SingleAttribute("DEV_PREFIX",
ImagePool::default_dev_prefix());
if (type == CDROM)
{
dev_prefix = ImagePool::default_cdrom_dev_prefix();
}
else
{
dev_prefix = ImagePool::default_dev_prefix();
}
SingleAttribute * dev_att =
new SingleAttribute("DEV_PREFIX", dev_prefix);
obj_template->set(dev_att);
}
break;
@ -508,7 +518,14 @@ int Image::disk_attribute( VectorAttribute * disk,
if (dev_prefix.empty())//Removed from image template, get it again
{
dev_prefix = ImagePool::default_dev_prefix();
if ( type == CDROM )
{
dev_prefix = ImagePool::default_cdrom_dev_prefix();
}
else
{
dev_prefix = ImagePool::default_dev_prefix();
}
}
disk->replace("DEV_PREFIX", dev_prefix);

View File

@ -27,6 +27,7 @@
/* -------------------------------------------------------------------------- */
string ImagePool::_default_type;
string ImagePool::_default_dev_prefix;
string ImagePool::_default_cdrom_dev_prefix;
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
@ -46,6 +47,8 @@ ImagePool::ImagePool(
_default_type = __default_type;
_default_dev_prefix = __default_dev_prefix;
_default_cdrom_dev_prefix = "hd";
// Init inherit attributes
vector<const Attribute *>::const_iterator it;

View File

@ -1682,7 +1682,14 @@ int VirtualMachine::get_disk_images(string& error_str)
}
else
{
cdrom_disks.push(make_pair(ipool->default_dev_prefix(), disk));
dev_prefix = disk->vector_value("DEV_PREFIX");
if ( dev_prefix.empty() )
{
dev_prefix = ipool->default_cdrom_dev_prefix();
}
cdrom_disks.push(make_pair(dev_prefix, disk));
}
// Disk IDs are 0..num-1, context disk is is num