mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-22 18:50:08 +03:00
Vector attributes are merged with DISK/NIC attribute
This commit is contained in:
parent
bfa711b617
commit
e02a9f9424
@ -154,13 +154,31 @@ void Datastore::disk_attribute(
|
||||
|
||||
for (const auto& inherit : inherit_attrs)
|
||||
{
|
||||
current_val = disk->vector_value(inherit);
|
||||
|
||||
get_template_attribute(inherit, inherit_val);
|
||||
|
||||
if ( current_val.empty() && !inherit_val.empty() )
|
||||
if (auto va = PoolObjectSQL::get_template_attribute(inherit))
|
||||
{
|
||||
disk->replace(inherit, inherit_val);
|
||||
// Vector attribute, inherit all its values
|
||||
const auto& values = va->value();
|
||||
|
||||
for (const auto& val : values)
|
||||
{
|
||||
string current_val = disk->vector_value(val.first);
|
||||
|
||||
if (current_val.empty() && !val.second.empty())
|
||||
{
|
||||
disk->replace(val.first, val.second);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Simple attribute, inherit value
|
||||
string current_val = disk->vector_value(inherit);
|
||||
PoolObjectSQL::get_template_attribute(inherit, inherit_val);
|
||||
|
||||
if (current_val.empty() && !inherit_val.empty())
|
||||
{
|
||||
disk->replace(inherit, inherit_val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -678,12 +678,31 @@ void Image::disk_attribute(VirtualMachineDisk * disk,
|
||||
|
||||
for (const auto& inherit : inherit_attrs)
|
||||
{
|
||||
string current_val = disk->vector_value(inherit);
|
||||
get_template_attribute(inherit, inherit_val);
|
||||
|
||||
if (current_val.empty() && !inherit_val.empty())
|
||||
if (auto va = PoolObjectSQL::get_template_attribute(inherit))
|
||||
{
|
||||
disk->replace(inherit, inherit_val);
|
||||
// Vector attribute, inherit all its values
|
||||
const auto& values = va->value();
|
||||
|
||||
for (const auto& val : values)
|
||||
{
|
||||
string current_val = disk->vector_value(val.first);
|
||||
|
||||
if (current_val.empty() && !val.second.empty())
|
||||
{
|
||||
disk->replace(val.first, val.second);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Simple attribute, inherit value
|
||||
string current_val = disk->vector_value(inherit);
|
||||
PoolObjectSQL::get_template_attribute(inherit, inherit_val);
|
||||
|
||||
if (current_val.empty() && !inherit_val.empty())
|
||||
{
|
||||
disk->replace(inherit, inherit_val);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -882,14 +882,33 @@ int VirtualNetwork::nic_attribute(
|
||||
inherit_attrs);
|
||||
}
|
||||
|
||||
for (const auto& inherited : inherit_attrs)
|
||||
for (const auto& inherit : inherit_attrs)
|
||||
{
|
||||
string current_val = nic->vector_value(inherited);
|
||||
PoolObjectSQL::get_template_attribute(inherited, inherit_val);
|
||||
|
||||
if (current_val.empty() && !inherit_val.empty())
|
||||
if (auto va = PoolObjectSQL::get_template_attribute(inherit))
|
||||
{
|
||||
nic->replace(inherited, inherit_val);
|
||||
// Vector attribute, inherit all its values
|
||||
const auto& values = va->value();
|
||||
|
||||
for (const auto& val : values)
|
||||
{
|
||||
string current_val = nic->vector_value(val.first);
|
||||
|
||||
if (current_val.empty() && !val.second.empty())
|
||||
{
|
||||
nic->replace(val.first, val.second);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Simple attribute, inherit value
|
||||
string current_val = nic->vector_value(inherit);
|
||||
PoolObjectSQL::get_template_attribute(inherit, inherit_val);
|
||||
|
||||
if (current_val.empty() && !inherit_val.empty())
|
||||
{
|
||||
nic->replace(inherit, inherit_val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user