]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Fixes Hyper-V agent issue with mixed network types
authorAlessandro Pilotti <ap@pilotti.it>
Sun, 10 Mar 2013 15:53:36 +0000 (17:53 +0200)
committerAlessandro Pilotti <ap@pilotti.it>
Mon, 11 Mar 2013 00:35:11 +0000 (02:35 +0200)
Fixes bug: 1153274

Due to a bug in setting up external ports the Hyper-V agent fails to work in
scenarios with VLAN and flat networks.

Furthermore, a warning message on Hyper-V 2012 indicates that external
port settings are ignored. As a result the agent can be simplified by
avoiding vswitch external ports configurations.

Change-Id: I860d22f427cb10dbeac422c1db2b3bcf9e84150f

quantum/plugins/hyperv/agent/hyperv_quantum_agent.py
quantum/plugins/hyperv/agent/utils.py

index 3ce925551e03798616cd98e2995dbe2a4c9c2efd..1ffdc91230155930708e5d06fda8f77ab450849b 100644 (file)
@@ -152,10 +152,9 @@ class HyperVQuantumAgent(object):
 
         vswitch_name = self._get_vswitch_name(network_type, physical_network)
 
-        if network_type == constants.TYPE_VLAN:
-            self._utils.add_vlan_id_to_vswitch(segmentation_id, vswitch_name)
-        elif network_type == constants.TYPE_FLAT:
-            self._utils.set_vswitch_mode_access(vswitch_name)
+        if network_type in [constants.TYPE_VLAN, constants.TYPE_FLAT]:
+            #Nothing to do
+            pass
         elif network_type == constants.TYPE_LOCAL:
             #TODO (alexpilotti): Check that the switch type is private
             #or create it if not existing
@@ -174,17 +173,6 @@ class HyperVQuantumAgent(object):
 
     def _reclaim_local_network(self, net_uuid):
         LOG.info(_("Reclaiming local network %s"), net_uuid)
-        map = self._network_vswitch_map[net_uuid]
-
-        if map['network_type'] == constants.TYPE_VLAN:
-            LOG.info(_("Reclaiming VLAN ID %s "), map['vlan_id'])
-            self._utils.remove_vlan_id_from_vswitch(
-                map['vlan_id'], map['vswitch_name'])
-        else:
-            raise utils.HyperVException(_("Cannot reclaim unsupported "
-                                          "network type %s for network %s"),
-                                        map['network_type'], net_uuid)
-
         del self._network_vswitch_map[net_uuid]
 
     def _port_bound(self, port_id,
index 84c318d6158d4e1d17a5b3e60c55c9d9dd384452..a49248682bb0b401f5f730be8385585d672b683c 100644 (file)
@@ -37,12 +37,6 @@ LOG = logging.getLogger(__name__)
 class HyperVException(q_exc.QuantumException):
     message = _('HyperVException: %(msg)s')
 
-SET_ACCESS_MODE = 0
-VLAN_ID_ADD = 1
-VLAN_ID_REMOVE = 2
-ENDPOINT_MODE_ACCESS = 2
-ENDPOINT_MODE_TRUNK = 5
-
 WMI_JOB_STATE_RUNNING = 4
 WMI_JOB_STATE_COMPLETED = 7
 
@@ -208,41 +202,6 @@ class HyperVUtils(object):
                 if ext_port:
                     return vswitch_port
 
-    def _set_vswitch_external_port_vlan_id(self, vswitch_name, action,
-                                           vlan_id=None):
-        vswitch = self._get_vswitch(vswitch_name)
-        ext_port = self._get_vswitch_external_port(vswitch)
-        if not ext_port:
-            return
-
-        vlan_endpoint = ext_port.associators(
-            wmi_association_class='Msvm_BindsTo')[0]
-        vlan_endpoint_settings = vlan_endpoint.associators(
-            wmi_association_class='Msvm_NetworkElementSettingData')[0]
-
-        mode = ENDPOINT_MODE_TRUNK
-        trunked_vlans = vlan_endpoint_settings.TrunkedVLANList
-        new_trunked_vlans = trunked_vlans
-        if action == VLAN_ID_ADD:
-            if vlan_id not in trunked_vlans:
-                new_trunked_vlans += (vlan_id,)
-        elif action == VLAN_ID_REMOVE:
-            if vlan_id in trunked_vlans:
-                new_trunked_vlans = [
-                    v for v in trunked_vlans if v != vlan_id
-                ]
-        elif action == SET_ACCESS_MODE:
-            mode = ENDPOINT_MODE_ACCESS
-            new_trunked_vlans = ()
-
-        if vlan_endpoint.DesiredEndpointMode != mode:
-            vlan_endpoint.DesiredEndpointMode = mode
-            vlan_endpoint.put()
-
-        if len(trunked_vlans) != len(new_trunked_vlans):
-            vlan_endpoint_settings.TrunkedVLANList = new_trunked_vlans
-            vlan_endpoint_settings.put()
-
     def set_vswitch_port_vlan_id(self, vlan_id, switch_port_name):
         vlan_endpoint_settings = self._conn.Msvm_VLANEndpointSettingData(
             ElementName=switch_port_name)[0]
@@ -250,22 +209,6 @@ class HyperVUtils(object):
             vlan_endpoint_settings.AccessVLAN = vlan_id
             vlan_endpoint_settings.put()
 
-    def set_vswitch_mode_access(self, vswitch_name):
-        LOG.info(_('Setting vswitch %s in access mode (flat)'), vswitch_name)
-        self._set_vswitch_external_port_vlan_id(vswitch_name, SET_ACCESS_MODE)
-
-    def add_vlan_id_to_vswitch(self, vlan_id, vswitch_name):
-        LOG.info(_('Adding VLAN %s to vswitch %s'),
-                 vlan_id, vswitch_name)
-        self._set_vswitch_external_port_vlan_id(vswitch_name, VLAN_ID_ADD,
-                                                vlan_id)
-
-    def remove_vlan_id_from_vswitch(self, vlan_id, vswitch_name):
-        LOG.info(_('Removing VLAN %s from vswitch %s'),
-                 vlan_id, vswitch_name)
-        self._set_vswitch_external_port_vlan_id(vswitch_name, VLAN_ID_REMOVE,
-                                                vlan_id)
-
     def _get_switch_port_path_by_name(self, switch_port_name):
         vswitch = self._conn.Msvm_SwitchPort(ElementName=switch_port_name)
         if vswitch: