Skip to content

Commit

Permalink
F #2593: Inherit IPAM_MAD from vnet to ar (#450)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel Czerný authored Nov 19, 2020
1 parent d4037ec commit c9c08f0
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/vnm/VirtualNetwork.cc
Original file line number Diff line number Diff line change
Expand Up @@ -997,10 +997,18 @@ void VirtualNetwork::process_security_rule(

int VirtualNetwork::add_var(vector<VectorAttribute *> &var, string& error_msg)
{
string ipam_mad;
PoolObjectSQL::get_template_attribute("IPAM_MAD", ipam_mad);

for (auto vattr : var)
{
VectorAttribute * ar = vattr->clone();

if (!ipam_mad.empty() && ar->vector_value("IPAM_MAD").empty())
{
ar->replace("IPAM_MAD", ipam_mad);
}

if (ar_pool.from_vattr(ar, error_msg) != 0)
{
delete ar;
Expand All @@ -1025,6 +1033,16 @@ int VirtualNetwork::add_ar(VirtualNetworkTemplate * ars_tmpl, string& error_msg)

VectorAttribute * nar = ar->clone();

string ipam_mad_vnet;
string ipam_mad_ar = nar->vector_value("IPAM_MAD");

if (ipam_mad_ar.empty() &&
PoolObjectSQL::get_template_attribute("IPAM_MAD", ipam_mad_vnet) &&
!ipam_mad_vnet.empty())
{
nar->replace("IPAM_MAD", ipam_mad_vnet);
}

if (ar_pool.from_vattr(nar, error_msg) != 0)
{
delete nar;
Expand Down

0 comments on commit c9c08f0

Please sign in to comment.