Browse Source

Partial Revert "Remove VLAN support"

This reverts commit a41f9fc80e.

This commit re-introduces the VLAN support in networking-dpm.
A corresponding patch in nova-dpm should make sure, that it is
not yet exploited. For nova-dpm, still the config drive is
missing.

Change-Id: Id2b9055d59a5e5b621eb788906a21e9d5b8b9f25
Andreas Scheuring 1 year ago
parent
commit
4b9a571546

+ 1
- 1
devstack/override-defaults View File

@@ -7,4 +7,4 @@ Q_USE_PROVIDER_NETWORKING=True
7 7
 PROVIDER_SUBNET_NAME="provider_net"
8 8
 PROVIDER_NETWORK_TYPE="flat"
9 9
 # andreas_s (Feb 2017): Required for provider networking
10
-USE_SUBNETPOOL=False
10
+USE_SUBNETPOOL=False

+ 6
- 2
networking_dpm/ml2/mech_dpm.py View File

@@ -27,7 +27,6 @@ AGENT_TYPE_DPM = 'DPM agent'
27 27
 VIF_TYPE_DPM_VSWITCH = 'dpm_vswitch'
28 28
 VIF_TYPE_DPM_ADAPTER = 'dpm_adapter'
29 29
 VIF_DETAILS_OBJECT_ID = 'object_id'
30
-VLAN_MODE_INBAND = 'inband'
31 30
 
32 31
 
33 32
 class DPMMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase):
@@ -47,7 +46,7 @@ class DPMMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase):
47 46
             {portbindings.CAP_PORT_FILTER: False})
48 47
 
49 48
     def get_allowed_network_types(self, agent):
50
-        return [p_constants.TYPE_FLAT]
49
+        return [p_constants.TYPE_FLAT, p_constants.TYPE_VLAN]
51 50
 
52 51
     def get_mappings(self, agent):
53 52
         return agent.get('configurations', {}).get('adapter_mappings', {})
@@ -79,6 +78,11 @@ class DPMMechanismDriver(mech_agent.SimpleAgentMechanismDriverBase):
79 78
 
80 79
         vif_details_segment = self.vif_details
81 80
 
81
+        network_type = segment[api.NETWORK_TYPE]
82
+        if network_type == p_constants.TYPE_VLAN:
83
+            vlan_id = segment[api.SEGMENTATION_ID]
84
+            vif_details_segment[portbindings.VIF_DETAILS_VLAN] = vlan_id
85
+
82 86
         vif_details_segment[VIF_DETAILS_OBJECT_ID] = object_id
83 87
         # TODO(andreas_s): For RoCE Support add the port-element-id to the
84 88
         # vif_details

+ 25
- 0
networking_dpm/tests/unit/ml2/test_mech_dpm.py View File

@@ -16,6 +16,7 @@
16 16
 from networking_dpm.ml2 import mech_dpm
17 17
 
18 18
 from neutron.tests.unit.plugins.ml2 import _test_mech_agent as base
19
+from neutron_lib.api.definitions import portbindings
19 20
 
20 21
 
21 22
 class DPMMechanismBaseTestCase(base.AgentMechanismBaseTestCase):
@@ -83,3 +84,27 @@ class DPMMechanismFlatTestCase(DPMMechanismBaseTestCase,
83 84
                                        vnic_type=self.VNIC_TYPE)
84 85
         self.driver.bind_port(context)
85 86
         self._check_unbound(context)
87
+
88
+
89
+class DPMMechanismVlanTestCase(DPMMechanismBaseTestCase,
90
+                               base.AgentMechanismVlanTestCase):
91
+
92
+    def test_type_vlan_vif_details(self):
93
+        context = base.FakePortContext(self.AGENT_TYPE,
94
+                                       self.AGENTS,
95
+                                       self.VLAN_SEGMENTS,
96
+                                       vnic_type=self.VNIC_TYPE)
97
+        self.driver.bind_port(context)
98
+        vif_details = context._bound_vif_details
99
+
100
+        self.assertEqual(1234, vif_details.get(portbindings.VIF_DETAILS_VLAN))
101
+        self.assertEqual("fake_vswitch1",
102
+                         vif_details.get('object_id'))
103
+
104
+    def test_no_vswitch_ids(self):
105
+        context = base.FakePortContext(self.AGENT_TYPE,
106
+                                       self.AGENTS_NO_VSWITCH,
107
+                                       segments=self.VLAN_SEGMENTS,
108
+                                       vnic_type=self.VNIC_TYPE)
109
+        self.driver.bind_port(context)
110
+        self._check_unbound(context)

Loading…
Cancel
Save