Browse Source

adding trunk port configuration

This does not include ability to update ports/subports in this patch.
It only handles initial binding for a node.

Change-Id: I2b2ebbfb33022eefdc60b61473459ce5b55f6bf4
(cherry picked from commit 9a40060781)
changes/69/681269/2
Dan Radez 2 months ago
parent
commit
9c0230b8c0

+ 66
- 12
doc/source/user/ironic.rst View File

@@ -2,22 +2,28 @@
2 2
 Ironic Baremetal Guest
3 3
 ======================
4 4
 
5
-Networking-Ansible can be used as the ML2 driver that communicates with the
5
+Networking-Ansible can be used as the ML2 driver that configures the
6 6
 switch that baremetal guests are cabled to. These guests need to have their
7
-port configuration updated depending on their deployment status.
7
+port configuration updated depending on their deployment configuration and status.
8 8
 
9
-In this section, this use case will be exercised in a set of example commands to
10
-show how end users would use ironic to provision baremetal nodes. Provisioning
11
-baremetal nodes using ironic with networking-ansible would use networking-ansible
12
-to manage the guest's switch level network configuration. Networking-Ansible is used by
9
+In this section, the ironic baremetal use case will be exercised in a set of example
10
+commands to show how end users can use ironic to provision baremetal nodes using
11
+networking-ansble to configure the guest's switch port. Networking-Ansible is used by
13 12
 ironic to first assign a baremetal guest's switchport to the Ironic provisoning
14 13
 network to provision the baremetal guest. After provisoning, the baremetal
15
-guest's switchport is assigned to the VLAN assigned by Neutron to guest's tenant network.
14
+guest's switchport is assigned to the VLAN(s) assigned by Neutron to the guest's
15
+tenant network(s).
16
+
17
+
18
+Guest's Port in Access Mode
19
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
20
+
21
+This first example shows deploying a guest with Ironic using an administrator supplied
22
+baremetal guest using a single network. The end user's experience using networking-ansible
23
+is via Neutron and Nova. Nova will select a baremetal node and configure the guest's
24
+switchport will be configured in access mode using the assigned VLAN designated by neutron
25
+from the supplied tenant network.
16 26
 
17
-The example shown here mirrors a user's expereience deploying a guest with
18
-Ironic. The end user's experience using networking-ansible is via Neutron and
19
-Nova. Nova will select a baremetal node as its target when a properly configured
20
-baremetal flavor is provided to the OpenStack server create command.
21 27
 
22 28
 #. An administrator will provide Ironic node(s) that are available for
23 29
    provisioning and a baremetal flavor.
@@ -32,7 +38,7 @@ baremetal flavor is provided to the OpenStack server create command.
32 38
   .. code-block:: console
33 39
 
34 40
     openstack network create --provider-network-type vlan --provider-physical-network datacentre my-tenant-net
35
-    openstack subnet create --network tenant-net --subnet-range 192.168.3.0/24 --allocation-pool start=192.168.3.10,end=192.168.3.20 tenant-subnet
41
+    openstack subnet create --network tenant-net --subnet-range 192.168.37.0/24 --allocation-pool start=192.168.37.10,end=192.168.37.20 tenant-subnet
36 42
 
37 43
 #. Execute server create using the tenant network just created. This assumes
38 44
    disk images and keypairs are already created and available.
@@ -40,3 +46,51 @@ baremetal flavor is provided to the OpenStack server create command.
40 46
   .. code-block:: console
41 47
 
42 48
     openstack server create --image a-baremetal-image --flavor baremetal --nic net-id={my-tenant-net uuid} --key-name my-keypair bm-instance
49
+
50
+
51
+Guest's Port in Trunk Mode
52
+~~~~~~~~~~~~~~~~~~~~~~~~~~
53
+
54
+This second example shows deploying a guest with Ironic using an administrator supplied
55
+baremetal guest using multiple networks on a single switchport. The the guest's
56
+switchport will be configured in trunk mode using the assigned VLANs designated by neutron
57
+from the supplied networks.
58
+
59
+
60
+#. An administrator will provide Ironic node(s) that are available for
61
+   provisioning and a baremetal flavor.
62
+
63
+  .. code-block:: console
64
+
65
+    openstack baremetal node list
66
+    openstack flavor list
67
+
68
+#. Create a primary tenant VLAN network, a secondary tenant network, and subnets for each that uses the physical network the guest is attached to.
69
+
70
+  .. code-block:: console
71
+
72
+    openstack network create --provider-network-type vlan --provider-physical-network datacentre primary-tenant-net
73
+    openstack network create --provider-network-type vlan --provider-physical-network datacentre secondary-tenant-net
74
+    openstack subnet create --network primary-tenant-net --subnet-range 192.168.3.0/24 --allocation-pool start=192.168.3.10,end=192.168.3.20 primary-tenant-subnet
75
+    openstack subnet create --network secondary-tenant-net --subnet-range 192.168.7.0/24 --allocation-pool start=192.168.7.10,end=192.168.7.20 secondary-tenant-subnet
76
+
77
+#. Create a port and create a trunk assigning the port to the trunk as the parent port.
78
+
79
+  .. code-block:: console
80
+
81
+    port create --network primary-tenant-net primary-port
82
+    network trunk create --parent-port primary-port my-trunk
83
+
84
+#. Create a port for the secondary network and add it as a subport to the trunk.
85
+
86
+  .. code-block:: console
87
+
88
+    port create --network secondary-tenant-net secondary-port
89
+    network trunk set --subport port=secondary-port,segmentation-type=vlan,segmentation-id=1234 my-trunk
90
+
91
+#. Execute server create using the port ID of the primary port in the trunk. This assumes
92
+   disk images and keypairs are already created and available.
93
+
94
+  .. code-block:: console
95
+
96
+    openstack server create --image a-baremetal-image --flavor baremetal --port {primary-port uuid} --key-name my-keypair bm-instance

+ 10
- 4
networking_ansible/ml2/mech_driver.py View File

@@ -16,6 +16,7 @@
16 16
 from neutron.db import provisioning_blocks
17 17
 from neutron.plugins.ml2.common import exceptions as ml2_exc
18 18
 from neutron_lib.api.definitions import portbindings
19
+from neutron_lib.api.definitions import trunk_details
19 20
 from neutron_lib.callbacks import resources
20 21
 from neutron_lib.plugins.ml2 import api as ml2api
21 22
 from oslo_log import log as logging
@@ -24,7 +25,6 @@ from networking_ansible import api
24 25
 from networking_ansible import config
25 26
 from networking_ansible.ml2 import exceptions
26 27
 
27
-
28 28
 LOG = logging.getLogger(__name__)
29 29
 
30 30
 ANSIBLE_NETWORKING_ENTITY = 'ANSIBLENETWORKING'
@@ -287,9 +287,15 @@ class AnsibleMechanismDriver(ml2api.MechanismDriver):
287 287
 
288 288
         # Assign port to network
289 289
         try:
290
-            self.ansnet.update_access_port(switch_name,
291
-                                           switch_port,
292
-                                           segmentation_id)
290
+            if trunk_details.TRUNK_DETAILS in port:
291
+                sub_ports = port[trunk_details.TRUNK_DETAILS]['sub_ports']
292
+                trunked_vlans = [sp['segmentation_id'] for sp in sub_ports]
293
+                self.ansnet.conf_trunk_port(switch_name, switch_port,
294
+                                            segmentation_id, trunked_vlans)
295
+            else:
296
+                self.ansnet.update_access_port(switch_name,
297
+                                               switch_port,
298
+                                               segmentation_id)
293 299
             context.set_binding(segments[0][ml2api.ID],
294 300
                                 portbindings.VIF_TYPE_OTHER, {})
295 301
             LOG.info('Port {neutron_port} has been plugged into '

+ 3
- 1
networking_ansible/tests/unit/base.py View File

@@ -84,6 +84,7 @@ class NetworkingAnsibleTestCase(BaseTestCase):
84 84
             self.mech = mech_driver.AnsibleMechanismDriver()
85 85
             self.mech.initialize()
86 86
         self.testsegid = '37'
87
+        self.testsegid2 = '73'
87 88
         self.testport = 'switchportid'
88 89
 
89 90
         # Define mocked network context
@@ -93,7 +94,8 @@ class NetworkingAnsibleTestCase(BaseTestCase):
93 94
             'id': 37,
94 95
             'provider:network_type': 'vlan',
95 96
             'provider:segmentation_id': self.testsegid,
96
-            'provider:physical_network': 'physnet'}
97
+            'provider:physical_network': 'physnet',
98
+        }
97 99
 
98 100
         # define mocked port context
99 101
         self.mock_port_context = mock.create_autospec(

+ 14
- 0
networking_ansible/tests/unit/ml2/test_mech_driver.py View File

@@ -23,6 +23,7 @@ from neutron.plugins.ml2.common import exceptions as ml2_exc
23 23
 from neutron.tests.unit.plugins.ml2 import test_plugin
24 24
 from neutron_lib.api.definitions import portbindings
25 25
 from neutron_lib.api.definitions import provider_net
26
+from neutron_lib.api.definitions import trunk_details
26 27
 import webob.exc
27 28
 
28 29
 from networking_ansible import api
@@ -89,6 +90,19 @@ class TestBindPort(base.NetworkingAnsibleTestCase):
89 90
                           self.mock_port_context)
90 91
         mock_update_access_port.assert_not_called()
91 92
 
93
+    @mock.patch.object(api.NetworkingAnsible, 'conf_trunk_port')
94
+    def test_bind_port_trunk_port(self,
95
+                                  mock_conf_trunk_port,
96
+                                  mock_prov_blks,
97
+                                  mock_update_access_port):
98
+        td = {'sub_ports': [{'segmentation_id': self.testsegid2}]}
99
+        self.mock_port_context.current[trunk_details.TRUNK_DETAILS] = td
100
+        self.mech.bind_port(self.mock_port_context)
101
+        mock_conf_trunk_port.assert_called_once_with(self.testhost,
102
+                                                     self.testport,
103
+                                                     self.testsegid,
104
+                                                     [self.testsegid2])
105
+
92 106
 
93 107
 class TestIsPortSupported(base.NetworkingAnsibleTestCase):
94 108
     def test_is_port_supported(self):

+ 1
- 1
zuul.d/jobs.yaml View File

@@ -65,7 +65,7 @@
65 65
         Q_PLUGIN: ml2
66 66
         SWIFT_ENABLE_TEMPURLS: True
67 67
         SWIFT_TEMPURL_KEY: secretkey
68
-        TEMPEST_PLUGINS: "'{{ ansible_user_dir }}/src/opendev.org/openstack/ironic-tempest-plugin'"
68
+        TEMPEST_PLUGINS: "{{ ansible_user_dir }}/src/opendev.org/openstack/ironic-tempest-plugin"
69 69
         TENANT_VLAN_RANGE: 100:150
70 70
         VIRT_DRIVER: ironic
71 71
       devstack_plugins:

Loading…
Cancel
Save