Browse Source

Remove ML2 references in the the ansible role

The ansible role and python API will be used in none OpenStack
contexts. This patch cleans out the OpenStack references to make
the API and role named for use as generic networking utilities.

Change-Id: I21897a1107dd3dce2f278ed46fd348043ebae7b6
Dan Radez 4 months ago
parent
commit
6dd63a3244
32 changed files with 43 additions and 43 deletions
  1. 3
    3
      doc/source/contributor/provider.rst
  2. 6
    6
      etc/ansible/roles/openstack-ml2/README.md
  3. 1
    1
      etc/ansible/roles/openstack-ml2/providers/cumulus/create_vlan.yaml
  4. 1
    1
      etc/ansible/roles/openstack-ml2/providers/cumulus/delete_vlan.yaml
  5. 1
    1
      etc/ansible/roles/openstack-ml2/providers/cumulus/update_access_port.yaml
  6. 1
    1
      etc/ansible/roles/openstack-ml2/providers/eos/create_vlan.yaml
  7. 1
    1
      etc/ansible/roles/openstack-ml2/providers/eos/delete_vlan.yaml
  8. 0
    0
      etc/ansible/roles/openstack-ml2/providers/eos/update_access_port.yaml
  9. 0
    3
      etc/ansible/roles/openstack-ml2/providers/junos/create_network.yaml
  10. 3
    0
      etc/ansible/roles/openstack-ml2/providers/junos/create_vlan.yaml
  11. 0
    4
      etc/ansible/roles/openstack-ml2/providers/junos/delete_network.yaml
  12. 4
    0
      etc/ansible/roles/openstack-ml2/providers/junos/delete_vlan.yaml
  13. 1
    1
      etc/ansible/roles/openstack-ml2/providers/junos/netconf.yaml
  14. 3
    0
      etc/ansible/roles/openstack-ml2/providers/junos/update_access_port.yaml
  15. 0
    3
      etc/ansible/roles/openstack-ml2/providers/junos/update_port.yaml
  16. 1
    1
      etc/ansible/roles/openstack-ml2/providers/nxos/create_vlan.yaml
  17. 1
    1
      etc/ansible/roles/openstack-ml2/providers/nxos/delete_vlan.yaml
  18. 0
    0
      etc/ansible/roles/openstack-ml2/providers/nxos/update_access_port.yaml
  19. 0
    0
      etc/ansible/roles/openstack-ml2/providers/openvswitch/create_vlan.yaml
  20. 0
    0
      etc/ansible/roles/openstack-ml2/providers/openvswitch/delete_vlan.yaml
  21. 0
    0
      etc/ansible/roles/openstack-ml2/providers/openvswitch/update_access_port.yaml
  22. 1
    1
      etc/ansible/roles/openstack-ml2/tasks/create_vlan.yaml
  23. 1
    1
      etc/ansible/roles/openstack-ml2/tasks/delete_port.yaml
  24. 1
    1
      etc/ansible/roles/openstack-ml2/tasks/delete_vlan.yaml
  25. 1
    1
      etc/ansible/roles/openstack-ml2/tasks/run.yaml
  26. 1
    1
      etc/ansible/roles/openstack-ml2/tasks/update_access_port.yaml
  27. 0
    0
      etc/ansible/roles/openstack-ml2/templates/junos/create_vlan.xml.j2
  28. 0
    0
      etc/ansible/roles/openstack-ml2/templates/junos/delete_vlan.xml.j2
  29. 0
    0
      etc/ansible/roles/openstack-ml2/templates/junos/update_access_port.xml.j2
  30. 3
    3
      networking_ansible/api.py
  31. 3
    3
      networking_ansible/tests/unit/ml2/test_mech_driver.py
  32. 5
    5
      networking_ansible/tests/unit/test_api.py

+ 3
- 3
doc/source/contributor/provider.rst View File

@@ -27,15 +27,15 @@ networking-ansible.
27 27
   to assign switchports to. Open vSwitch expects no VLAN ID and VLAN name
28 28
   in the case that port is not assigned to a specific VLAN.
29 29
 
30
-* create_network.yaml
30
+* create_vlan.yaml
31 31
 
32 32
   Defines the Ansible tasks to create a VLAN on a switch.
33 33
 
34
-* delete_network.yaml
34
+* delete_vlan.yaml
35 35
 
36 36
   Defines the Ansible tasks to delete a VLAN on a switch.
37 37
 
38
-* update_port.yaml
38
+* update_access_port.yaml
39 39
 
40 40
   Defines the Ansible tasks to assign a VLAN to a switchport in access mode.
41 41
 

+ 6
- 6
etc/ansible/roles/openstack-ml2/README.md View File

@@ -11,8 +11,8 @@ Role Variables
11 11
 
12 12
 * junos_enable_netconf
13 13
 
14
-* segmenation_id
15
-* segmentation_name (default depends on provider)
14
+* ml2_segmenation_id
15
+* ml2_segmentation_name (default depends on provider)
16 16
 
17 17
 Dependencies
18 18
 ------------
@@ -29,18 +29,18 @@ Example Playbook
29 29
 - hosts: all
30 30
 
31 31
   tasks:
32
-    - name: do create_network
32
+    - name: do create_vlan
33 33
       import_role:
34 34
         name: openstack-ml2
35
-        tasks_from: create_network
35
+        tasks_from: create_vlan
36 36
       vars:
37 37
         segmentation_name: v101
38 38
         segmentation_id: 101
39 39
 
40
-    - name: do create_network
40
+    - name: do create_vlan
41 41
       import_role:
42 42
         name: openstack-ml2
43
-        tasks_from: delete_network
43
+        tasks_from: delete_vlan
44 44
       vars:
45 45
         segmentation_id: 101
46 46
         segmentation_name: v101

etc/ansible/roles/openstack-ml2/providers/cumulus/create_network.yaml → etc/ansible/roles/openstack-ml2/providers/cumulus/create_vlan.yaml View File

@@ -1,5 +1,5 @@
1 1
 ---
2
-- name: "nclu: run create_network using nclu"
2
+- name: "cumulus: create vlan using nclu"
3 3
   nclu:
4 4
     commands: "add vlan {{ ml2_segmentation_id }}"
5 5
     commit: true

etc/ansible/roles/openstack-ml2/providers/cumulus/delete_network.yaml → etc/ansible/roles/openstack-ml2/providers/cumulus/delete_vlan.yaml View File

@@ -1,5 +1,5 @@
1 1
 ---
2
-- name: "cumulus: run delete_network using nclu"
2
+- name: "cumulus: delete vlan using nclu"
3 3
   nclu:
4 4
     commands: 'del vlan {{ ml2_segmentation_id }}'
5 5
     commit: true

etc/ansible/roles/openstack-ml2/providers/cumulus/update_port.yaml → etc/ansible/roles/openstack-ml2/providers/cumulus/update_access_port.yaml View File

@@ -1,5 +1,5 @@
1 1
 ---
2
-- name: "cumulus: port is configured as routed"
2
+- name: "cumulus: configure access port using nclu"
3 3
   block:
4 4
     - name: "cumulus: reset interface to defaults"
5 5
       nclu:

etc/ansible/roles/openstack-ml2/providers/eos/create_network.yaml → etc/ansible/roles/openstack-ml2/providers/eos/create_vlan.yaml View File

@@ -1,5 +1,5 @@
1 1
 ---
2
-- name: "eos: run create_network using network_cli"
2
+- name: "eos: create vlan using network_cli"
3 3
   eos_config:
4 4
     lines:
5 5
       - "name {{ ml2_segmentation_name }}"

etc/ansible/roles/openstack-ml2/providers/eos/delete_network.yaml → etc/ansible/roles/openstack-ml2/providers/eos/delete_vlan.yaml View File

@@ -1,5 +1,5 @@
1 1
 ---
2
-- name: "eos: run delete_network using network_cli"
2
+- name: "eos: delete vlan using network_cli"
3 3
   eos_config:
4 4
     lines: "no vlan {{ ml2_segmentation_id }}"
5 5
   connection: network_cli

etc/ansible/roles/openstack-ml2/providers/eos/update_port.yaml → etc/ansible/roles/openstack-ml2/providers/eos/update_access_port.yaml View File


+ 0
- 3
etc/ansible/roles/openstack-ml2/providers/junos/create_network.yaml View File

@@ -1,3 +0,0 @@
1
----
2
-- name: "junos: run create_network using netconf"
3
-  include_tasks: netconf.yaml

+ 3
- 0
etc/ansible/roles/openstack-ml2/providers/junos/create_vlan.yaml View File

@@ -0,0 +1,3 @@
1
+---
2
+- name: "junos: run create vlan using netconf"
3
+  include_tasks: netconf.yaml

+ 0
- 4
etc/ansible/roles/openstack-ml2/providers/junos/delete_network.yaml View File

@@ -1,4 +0,0 @@
1
----
2
-- name: "junos: run delete_network using netconf"
3
-  include_tasks: netconf.yaml
4
-

+ 4
- 0
etc/ansible/roles/openstack-ml2/providers/junos/delete_vlan.yaml View File

@@ -0,0 +1,4 @@
1
+---
2
+- name: "junos: run delete vlan using netconf"
3
+  include_tasks: netconf.yaml
4
+

+ 1
- 1
etc/ansible/roles/openstack-ml2/providers/junos/netconf.yaml View File

@@ -19,7 +19,7 @@
19 19
 
20 20
 - name: "junos: set netconf template"
21 21
   set_fact:
22
-    ml2_junos_netconf_template: "templates/junos/{{ ml2_resource }}.xml.j2"
22
+    ml2_junos_netconf_template: "templates/junos/{{ network_action }}.xml.j2"
23 23
 
24 24
 - name: "junos: send configuration to device"
25 25
   netconf_config:

+ 3
- 0
etc/ansible/roles/openstack-ml2/providers/junos/update_access_port.yaml View File

@@ -0,0 +1,3 @@
1
+---
2
+- name: "junos: run update access port using netconf"
3
+  include_tasks: netconf.yaml

+ 0
- 3
etc/ansible/roles/openstack-ml2/providers/junos/update_port.yaml View File

@@ -1,3 +0,0 @@
1
----
2
-- name: "junos: run update_port using netconf"
3
-  include_tasks: netconf.yaml

etc/ansible/roles/openstack-ml2/providers/nxos/create_network.yaml → etc/ansible/roles/openstack-ml2/providers/nxos/create_vlan.yaml View File

@@ -1,5 +1,5 @@
1 1
 ---
2
-- name: "nxos: run create_network using network_cli"
2
+- name: "nxos: run create vlan using network_cli"
3 3
   nxos_config:
4 4
     lines:
5 5
       - "name {{ ml2_segmentation_name }}"

etc/ansible/roles/openstack-ml2/providers/nxos/delete_network.yaml → etc/ansible/roles/openstack-ml2/providers/nxos/delete_vlan.yaml View File

@@ -1,5 +1,5 @@
1 1
 ---
2
-- name: "nxos: run delete_network using network_cli"
2
+- name: "nxos: run delete vlan using network_cli"
3 3
   nxos_config:
4 4
     lines: "no vlan {{ ml2_segmentation_id }}"
5 5
   connection: network_cli

etc/ansible/roles/openstack-ml2/providers/nxos/update_port.yaml → etc/ansible/roles/openstack-ml2/providers/nxos/update_access_port.yaml View File


etc/ansible/roles/openstack-ml2/providers/openvswitch/create_network.yaml → etc/ansible/roles/openstack-ml2/providers/openvswitch/create_vlan.yaml View File


etc/ansible/roles/openstack-ml2/providers/openvswitch/delete_network.yaml → etc/ansible/roles/openstack-ml2/providers/openvswitch/delete_vlan.yaml View File


etc/ansible/roles/openstack-ml2/providers/openvswitch/update_port.yaml → etc/ansible/roles/openstack-ml2/providers/openvswitch/update_access_port.yaml View File


etc/ansible/roles/openstack-ml2/tasks/create_network.yaml → etc/ansible/roles/openstack-ml2/tasks/create_vlan.yaml View File

@@ -2,4 +2,4 @@
2 2
 - name: include and run device provider specific tasks
3 3
   include_tasks: run.yaml
4 4
   vars:
5
-    ml2_resource: create_network
5
+    network_action: create_vlan

+ 1
- 1
etc/ansible/roles/openstack-ml2/tasks/delete_port.yaml View File

@@ -9,4 +9,4 @@
9 9
 - name: include and run device provider specific tasks
10 10
   include_tasks: run.yaml
11 11
   vars:
12
-    ml2_resource: delete_port
12
+    network_action: delete_port

etc/ansible/roles/openstack-ml2/tasks/delete_network.yaml → etc/ansible/roles/openstack-ml2/tasks/delete_vlan.yaml View File

@@ -2,4 +2,4 @@
2 2
 - name: include and run device provider specific tasks
3 3
   include_tasks: run.yaml
4 4
   vars:
5
-    ml2_resource: delete_network
5
+    network_action: delete_vlan

+ 1
- 1
etc/ansible/roles/openstack-ml2/tasks/run.yaml View File

@@ -12,7 +12,7 @@
12 12
   include_tasks: "{{ item }}"
13 13
   with_first_found:
14 14
     - files:
15
-        - "{{ ml2_resource }}.yaml"
15
+        - "{{ network_action }}.yaml"
16 16
       paths:
17 17
         - "{{ playbook_dir }}/providers/{{ ansible_network_os }}"
18 18
         - "/etc/ansible/openstack_ml2/providers/{{ ansible_network_os }}"

etc/ansible/roles/openstack-ml2/tasks/update_port.yaml → etc/ansible/roles/openstack-ml2/tasks/update_access_port.yaml View File

@@ -16,4 +16,4 @@
16 16
 - name: include and run device provider specific tasks
17 17
   include_tasks: run.yaml
18 18
   vars:
19
-    ml2_resource: update_port
19
+    network_action: update_access_port

etc/ansible/roles/openstack-ml2/templates/junos/create_network.xml.j2 → etc/ansible/roles/openstack-ml2/templates/junos/create_vlan.xml.j2 View File


etc/ansible/roles/openstack-ml2/templates/junos/delete_network.xml.j2 → etc/ansible/roles/openstack-ml2/templates/junos/delete_vlan.xml.j2 View File


etc/ansible/roles/openstack-ml2/templates/junos/update_port.xml.j2 → etc/ansible/roles/openstack-ml2/templates/junos/update_access_port.xml.j2 View File


+ 3
- 3
networking_ansible/api.py View File

@@ -70,10 +70,10 @@ class NetworkingAnsible(object):
70 70
         return result
71 71
 
72 72
     def create_vlan(self, hostname, vlan_id):
73
-        return self._run_task('create_network', hostname, vlan_id=vlan_id)
73
+        return self._run_task('create_vlan', hostname, vlan_id=vlan_id)
74 74
 
75 75
     def delete_vlan(self, hostname, vlan_id):
76
-        return self._run_task('delete_network', hostname, vlan_id=vlan_id)
76
+        return self._run_task('delete_vlan', hostname, vlan_id=vlan_id)
77 77
 
78 78
     def update_access_port(self, hostname, port, vlan_id):
79 79
         """Configure access port on a vlan or shutdown the port.
@@ -88,7 +88,7 @@ class NetworkingAnsible(object):
88 88
                        An empty is will get translated in Ansible to the
89 89
                        target device's default VLAN assignment.
90 90
         """
91
-        return self._run_task('update_port', hostname, port, vlan_id)
91
+        return self._run_task('update_access_port', hostname, port, vlan_id)
92 92
 
93 93
     def delete_port(self, hostname, port):
94 94
         return self._run_task('delete_port', hostname, port)

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

@@ -334,7 +334,7 @@ class TestML2PluginIntegration(NetAnsibleML2Base):
334 334
         self.assertEqual(webob.exc.HTTPCreated.code, res.status_int)
335 335
         expected_calls = [
336 336
             mock.call(
337
-                'create_network',
337
+                'create_vlan',
338 338
                 host,
339 339
                 vlan_id=int(self.network_spec[provider_net.SEGMENTATION_ID]))
340 340
             for host in self.HOSTS if 'manage_vlans=False' not in
@@ -352,7 +352,7 @@ class TestML2PluginIntegration(NetAnsibleML2Base):
352 352
         self.assertEqual(webob.exc.HTTPNoContent.code, res.status_int)
353 353
         expected_calls = [
354 354
             mock.call(
355
-                'delete_network',
355
+                'delete_vlan',
356 356
                 host,
357 357
                 vlan_id=int(self.network_spec[provider_net.SEGMENTATION_ID]))
358 358
             for host in self.HOSTS if 'manage_vlans=False' not in
@@ -390,7 +390,7 @@ class TestML2PluginIntegration(NetAnsibleML2Base):
390 390
                 self.fmt, req.get_response(self.api))
391 391
 
392 392
             m_run_task.called_once_with(
393
-                'update_port',
393
+                'update_access_port',
394 394
                 self.HOSTS[0],
395 395
                 self.LOCAL_LINK_INFORMATION[0]['port_id'],
396 396
                 self.network_spec[provider_net.SEGMENTATION_ID])

+ 5
- 5
networking_ansible/tests/unit/test_api.py View File

@@ -23,17 +23,17 @@ class TestCreateDeleteNetwork(base.NetworkingAnsibleTestCase):
23 23
 
24 24
     @mock.patch('networking_ansible.api'
25 25
                 '.NetworkingAnsible._run_task')
26
-    def test_create_network(self, mock_run_task):
26
+    def test_create_vlan(self, mock_run_task):
27 27
         self.mech.ansnet.create_vlan(self.testhost, self.testsegid)
28
-        mock_run_task.assert_called_once_with('create_network',
28
+        mock_run_task.assert_called_once_with('create_vlan',
29 29
                                               self.testhost,
30 30
                                               vlan_id=self.testsegid)
31 31
 
32 32
     @mock.patch('networking_ansible.api'
33 33
                 '.NetworkingAnsible._run_task')
34
-    def test_delete_network(self, mock_run_task):
34
+    def test_delete_vlan(self, mock_run_task):
35 35
         self.mech.ansnet.delete_vlan(self.testhost, self.testsegid)
36
-        mock_run_task.assert_called_once_with('delete_network',
36
+        mock_run_task.assert_called_once_with('delete_vlan',
37 37
                                               self.testhost,
38 38
                                               vlan_id=self.testsegid)
39 39
 
@@ -104,7 +104,7 @@ class TestVlanAccessPort(base.NetworkingAnsibleTestCase):
104 104
         self.mech.ansnet.update_access_port(self.testhost,
105 105
                                             self.testport,
106 106
                                             self.testsegid)
107
-        mock_run_task.assert_called_once_with('update_port',
107
+        mock_run_task.assert_called_once_with('update_access_port',
108 108
                                               self.testhost,
109 109
                                               self.testport,
110 110
                                               self.testsegid)

Loading…
Cancel
Save