From 8f29f768d8cfb70d71e314269e7cecebd21ebafa Mon Sep 17 00:00:00 2001 From: Rudra Rugge Date: Mon, 1 Jun 2015 13:54:10 -0700 Subject: [PATCH] Allocate mac address for service instance ports Service instance VM, netns do not request mac-addresses for its ports. In cases of active-standby, active-active instances there is an issue which can cause the standby mac-address to be picked up. This change ensures that the same mac-address is used for all VMs using a particular virtual network. This is achieved by allocating the mac-address extracted from the virtual-network the port is attached to. Change-Id: Ie96bd757f75f78b4aaa1c2a87a0e0ed2f902af01 Closes-Bug: #1460767 --- src/config/svc-monitor/svc_monitor/instance_manager.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/config/svc-monitor/svc_monitor/instance_manager.py b/src/config/svc-monitor/svc_monitor/instance_manager.py index 80658221e3b..1fe66060900 100644 --- a/src/config/svc-monitor/svc_monitor/instance_manager.py +++ b/src/config/svc-monitor/svc_monitor/instance_manager.py @@ -49,6 +49,10 @@ def delete_service(self, vm): def check_service(self, si): pass + def mac_alloc(self, uuid): + return '02:%s:%s:%s:%s:%s' % (uuid[0:2], uuid[2:4], + uuid[4:6], uuid[6:8], uuid[9:11]) + def _get_default_security_group(self, vn): sg_fq_name = vn.fq_name[:-1] + ['default'] for sg in SecurityGroupSM.values(): @@ -258,6 +262,7 @@ 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: @@ -396,6 +401,8 @@ 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: