NSX|V+V3: Use the right port device id for octavia vip

Octavia vip port device ids has a prefix that should be removed/added
when trying to get the lb id from it, or get hte relevnat ports.

Change-Id: Ie39e358969eb9c0080c6bac823b373e512270be1
This commit is contained in:
Adit Sarfaty 2019-02-12 13:23:09 +02:00
parent a67bf12ede
commit 82c5da84f6
3 changed files with 8 additions and 4 deletions

View File

@ -2855,6 +2855,8 @@ class NsxV3Plugin(nsx_plugin_common.NsxPluginV3Base,
# update the load balancer virtual server's VIP with
# floating ip, but don't add NAT rules
device_id = port['device_id']
if device_id.startswith(oct_const.DEVICE_ID_PREFIX):
device_id = device_id[len(oct_const.DEVICE_ID_PREFIX):]
lb_tag = [{'scope': 'os-lbaas-lb-id', 'tag': device_id}]
vs_list = self.nsxlib.search_by_tags(
tags=lb_tag, resource_type='LbVirtualServer')

View File

@ -114,7 +114,7 @@ class EdgeLoadBalancerManagerFromDict(base_mgr.EdgeLoadbalancerBaseManager):
def delete(self, context, lb, completor):
# Discard any ports which are associated with LB
filters = {
'device_id': [lb['id']],
'device_id': [lb['id'], oct_const.DEVICE_ID_PREFIX + lb['id']],
'device_owner': [constants.DEVICE_OWNER_NEUTRON_PREFIX + 'LB']}
lb_ports = self.core_plugin.get_ports(context.elevated(),
filters=filters)
@ -236,11 +236,12 @@ class EdgeLoadBalancerManagerFromDict(base_mgr.EdgeLoadbalancerBaseManager):
if lb_ports:
for lb_port in lb_ports:
# TODO(asarfaty): for Octavia this code might need to change
# as the device_id is different
if lb_port['device_id']:
device_id = lb_port['device_id']
if device_id.startswith(oct_const.DEVICE_ID_PREFIX):
device_id = device_id[len(oct_const.DEVICE_ID_PREFIX):]
edge_bind = nsxv_db.get_nsxv_lbaas_loadbalancer_binding(
context.session, lb_port['device_id'])
context.session, device_id)
edge_id = edge_bind['edge_id']
routes = [{'cidr': r['destination'],

View File

@ -43,3 +43,4 @@ OPERATING_STATUS = 'operating_status'
PROVISIONING_STATUS = 'provisioning_status'
DEVICE_OWNER_OCTAVIA = 'Octavia'
DEVICE_ID_PREFIX = 'lb-'