def _get_allowed_adress_pairs(vmi_obj): allowed_address_pairs = ( vmi_obj.get_virtual_machine_interface_allowed_address_pairs())
if (allowed_address_pairs and allowed_address_pairs.allowed_address_pair): address_pairs = []
for aap in allowed_address_pairs.allowed_address_pair: pair = {} pair['mac_address'] = aap.mac
if aap.ip.get_ip_prefix_len() == 32: pair['ip_address'] = '%s' % (aap.ip.get_ip_prefix()) else: pair['ip_address'] = '%s/%s' % (aap.ip.get_ip_prefix(), aap.ip.get_ip_prefix_len()) address_pairs.append(pair)
return address_pairs
by moving address_pairs = [] before the if clause "if (allowed_address_pairs and allowed_address_pairs.allowed_address_pair):"
and "return address_pairs" out of the if clause
This could make it returning allowed_address_pairs[] in the vmi response even if it's not set.
"openstack port create" was introduced in Newton.
Could it be fixed here in https:/ /github. com/Juniper/ contrail- neutron- plugin/ blob/master/ neutron_ plugin_ contrail/ plugins/ opencontrail/ vnc_client/ vmi_res_ handler. py?
def _get_allowed_ adress_ pairs(vmi_ obj):
allowed_ address_ pairs = (
vmi_ obj.get_ virtual_ machine_ interface_ allowed_ address_ pairs() ) address_ pairs and
allowed_ address_ pairs.allowed_ address_ pair):
address_ pairs = [] address_ pairs.allowed_ address_ pair:
pair = {}
pair[ 'mac_address' ] = aap.mac get_ip_ prefix_ len() == 32:
pair[ 'ip_address' ] = '%s' % (aap.ip. get_ip_ prefix( ))
else:
pair[ 'ip_address' ] = '%s/%s' % (aap.ip. get_ip_ prefix( ),
aap. ip.get_ ip_prefix_ len())
address_ pairs.append( pair)
if (allowed_
for aap in allowed_
if aap.ip.
return address_pairs
by moving address_pairs = [] before the if clause "if (allowed_ address_ pairs and
allowed_ address_ pairs.allowed_ address_ pair):"
and "return address_pairs" out of the if clause
This could make it returning allowed_ address_ pairs[] in the vmi response even if it's not set.