Skip to content

Commit

Permalink
Port tuple list modification during iip udpate
Browse files Browse the repository at this point in the history
Copy the list of instance-ip uuids from vmi so that
any modification in the iterations does not cause
set change size issues.

Also fix issue with reseting of service-chain-ip
flag.

Change-Id: I9332bc371cd4d7534d488e76186e930c4bfe1ccb
Closes-Bug: 1581118
Closes-bug: 1548920
  • Loading branch information
rrugge committed May 17, 2016
1 parent 3fa727f commit 0c13646
Showing 1 changed file with 26 additions and 22 deletions.
48 changes: 26 additions & 22 deletions src/config/svc-monitor/svc_monitor/port_tuple.py
Expand Up @@ -26,7 +26,7 @@ class PortTupleAgent(Agent):
def __init__(self, svc_mon, vnc_lib, cassandra, config_section, logger):
super(PortTupleAgent, self).__init__(svc_mon, vnc_lib,
cassandra, config_section)
self._logger = logger
self.logger = logger

def handle_service_type(self):
return 'port-tuple'
Expand Down Expand Up @@ -88,7 +88,7 @@ def set_port_service_health_check(self, port, vmi):
'service-health-check', health_id, None, 'ADD')
vmi.update()
# handle deletes
for health_id in vmi.service_health_checks:
for health_id in list(vmi.service_health_checks):
if health_id in port['service-health-checks']:
continue
self._vnc_lib.ref_update('virtual-machine-interface', vmi.uuid,
Expand All @@ -104,42 +104,45 @@ def set_port_static_routes(self, port, vmi):
'interface-route-table', irt_id, None, 'ADD')
vmi.update()
# handle deletes
for irt_id in vmi.interface_route_tables:
for irt_id in list(vmi.interface_route_tables):
if irt_id in port['interface-route-tables']:
continue
self._vnc_lib.ref_update('virtual-machine-interface', vmi.uuid,
'interface-route-table', irt_id, None, 'DELETE')
vmi.update()

def update_secondary_iip(self, vmi):
for iip_id in vmi.instance_ips:
for iip_id in list(vmi.instance_ips):
iip = InstanceIpSM.get(iip_id)
if not iip or not iip.instance_ip_secondary:
if not iip:
continue
if not iip.instance_ip_secondary or not iip.service_instance_ip:
continue

update = False
iip_obj = InstanceIp()
iip_obj.name = iip.name
iip_obj.uuid = iip.uuid

if vmi.aaps and len(vmi.aaps):
if iip.secondary_tracking_ip != vmi.aaps[0]['ip']:
iip_obj.set_secondary_ip_tracking_ip(vmi.aaps[0]['ip'])
update = True
if iip.instance_ip_mode != vmi.aaps[0].get('address_mode', 'active-standby'):
iip_obj.set_instance_ip_mode(vmi.aaps[0].get('address_mode', 'active-standby'))
tracking_ip = vmi.aaps[0]['ip']
ip_mode = vmi.aaps[0].get('address_mode', 'active-standby')
update = True
else:
if iip.secondary_tracking_ip:
iip_obj.set_secondary_ip_tracking_ip(None)
update = True
if iip.instance_ip_mode != 'active-active':
iip_obj.set_instance_ip_mode('active-active')
tracking_ip = None
ip_mode = 'active-active'
update = True

if update:
if not update:
continue

try:
iip_obj = self._vnc_lib.instance_ip_read(id=iip.uuid)
iip_obj.set_secondary_ip_tracking_ip(tracking_ip)
iip_obj.set_instance_ip_mode(ip_mode)
self._vnc_lib.instance_ip_update(iip_obj)
iip.update(iip_obj.serialize_to_json())
iip.update()
except NoIdError:
self.logger.error("Instance IP %s update failed" % (iip.name))
continue

def set_port_allowed_address_pairs(self, port, vmi, vmi_obj):
if not port['allowed-address-pairs'] or \
Expand Down Expand Up @@ -172,14 +175,15 @@ def delete_shared_iip(self, iip):
return
if iip.service_instance:
return
for vmi_id in iip.virtual_machine_interfaces:
for vmi_id in list(iip.virtual_machine_interfaces):
self._vnc_lib.ref_update('instance-ip', iip.uuid,
'virtual-machine-interface', vmi_id, None, 'DELETE')

try:
self._vnc_lib.instance_ip_delete(id=iip.uuid)
InstanceIpSM.delete(iip.uuid)
except NoIdError:
self.logger.error("Instance IP %s delete failed" % (iip.name))
return

def delete_old_vmi_links(self, vmi):
Expand All @@ -191,14 +195,14 @@ def delete_old_vmi_links(self, vmi):
'virtual-machine-interface', vmi.uuid, None, 'DELETE')
vmi.instance_ips.remove(iip_id)

for irt_id in vmi.interface_route_tables:
for irt_id in list(vmi.interface_route_tables):
irt = InterfaceRouteTableSM.get(irt_id)
if irt and irt.service_instance:
self._vnc_lib.ref_update('virtual-machine-interface', vmi.uuid,
'interface-route-table', irt.uuid, None, 'DELETE')
vmi.interface_route_tables.remove(irt_id)

for health_id in vmi.service_health_checks:
for health_id in list(vmi.service_health_checks):
health = ServiceHealthCheckSM.get(health_id)
if health and health.service_instance:
self._vnc_lib.ref_update('virtual-machine-interface', vmi.uuid,
Expand Down

0 comments on commit 0c13646

Please sign in to comment.