From 560f20c318f8cbf3db8d72860d90a864a276e881 Mon Sep 17 00:00:00 2001 From: Rudra Rugge Date: Fri, 5 Jun 2015 15:42:55 -0700 Subject: [PATCH] Generate mac from instance ip for service VMs Generate the same mac-address for all interfaces sharing the same IP. In addition a change to daemonize the haproxy process instead of managing through supervisor. Change-Id: I2394f29c4a11bffeee4b0184ce6cd6867b01e0e9 Closes-Bug: #1461882 --- src/config/svc-monitor/svc_monitor/instance_manager.py | 10 ++++++---- src/config/svc-monitor/svc_monitor/svc_monitor.py | 5 ++--- .../opencontrail_vrouter_netns/vrouter_netns.py | 4 ++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/config/svc-monitor/svc_monitor/instance_manager.py b/src/config/svc-monitor/svc_monitor/instance_manager.py index 1fe66060900..3375835df37 100644 --- a/src/config/svc-monitor/svc_monitor/instance_manager.py +++ b/src/config/svc-monitor/svc_monitor/instance_manager.py @@ -102,7 +102,7 @@ def _allocate_iip(self, vn_obj, iip_name): try: self._vnc_lib.instance_ip_create(iip_obj) except RefsExistError: - pass + iip_obj = self._vnc_lib.instance_ip_read(fq_name=[iip_name]) return iip_obj @@ -262,7 +262,6 @@ def validate_network_config(self, st, si): nic['static-route-enable'] = st_if.get('static_route_enable') nic['static-routes'] = si_if.get('static_routes') nic['user-visible'] = user_visible - nic['mac-address'] = self.mac_alloc(vn_id) si.vn_info.insert(index, nic) if config_complete: @@ -401,8 +400,6 @@ def _create_svc_vm_port(self, nic, instance_name, si, st, vmi_updated = True if vmi_create: - mac_addrs_obj = MacAddressesType([nic['mac-address']]) - vmi_obj.set_virtual_machine_interface_mac_addresses(mac_addrs_obj) try: self._vnc_lib.virtual_machine_interface_create(vmi_obj) except RefsExistError: @@ -429,6 +426,11 @@ def _create_svc_vm_port(self, nic, instance_name, si, st, % (instance_name, proj_obj.name)) return + # set mac address + mac_addrs_obj = MacAddressesType([self.mac_alloc(iip_obj.uuid)]) + vmi_obj.set_virtual_machine_interface_mac_addresses(mac_addrs_obj) + self._vnc_lib.virtual_machine_interface_update(vmi_obj) + # check if vmi already linked to iip iip_update = True iip = InstanceIpSM.get(iip_obj.uuid) diff --git a/src/config/svc-monitor/svc_monitor/svc_monitor.py b/src/config/svc-monitor/svc_monitor/svc_monitor.py index bc29eb816ae..4e7295a796c 100644 --- a/src/config/svc-monitor/svc_monitor/svc_monitor.py +++ b/src/config/svc-monitor/svc_monitor/svc_monitor.py @@ -734,9 +734,8 @@ def _delete_service_instance(self, vm): return True def _relaunch_service_instance(self, si): - if si.state == 'active': - si.state = 'relaunch' - self._create_service_instance(si) + si.state = 'relaunch' + self._create_service_instance(si) def _check_service_running(self, si): st = ServiceTemplateSM.get(si.service_template) diff --git a/src/vnsw/opencontrail-vrouter-netns/opencontrail_vrouter_netns/vrouter_netns.py b/src/vnsw/opencontrail-vrouter-netns/opencontrail_vrouter_netns/vrouter_netns.py index 6054719ff42..63ea2628d62 100644 --- a/src/vnsw/opencontrail-vrouter-netns/opencontrail_vrouter_netns/vrouter_netns.py +++ b/src/vnsw/opencontrail-vrouter-netns/opencontrail_vrouter_netns/vrouter_netns.py @@ -134,7 +134,7 @@ def set_lbaas(self): raise ValueError('Need to create the network namespace before set ' 'up the lbaas') - haproxy_process.start_update_haproxy(self.cfg_file, self.namespace) + haproxy_process.start_update_haproxy(self.cfg_file, self.namespace, True) try: self.ip_ns.netns.execute(['route', 'add', 'default', 'gw', self.gw_ip]) @@ -146,7 +146,7 @@ def release_lbaas(self): raise ValueError('Need to create the network namespace before ' 'relasing lbaas') - haproxy_process.stop_haproxy(self.cfg_file) + haproxy_process.stop_haproxy(self.cfg_file, True) try: self.ip_ns.netns.execute(['route', 'del', 'default'])