Browse Source

Rename port variable it's reserved

Since the role's de-openstack Ansible throughs:
[WARNING]: Found variable using reserved name: port

Change-Id: I6c5ce9a6e1b443ff0fc78b7dd5d9115539927698
Dan Radez 3 months ago
parent
commit
6e7b9515b4

+ 1
- 1
etc/ansible/roles/openstack-ml2/defaults/main.yml View File

@@ -1,5 +1,5 @@
1 1
 ---
2 2
 # params to implement port resource
3 3
 #
4
-port: "{{ port }}"
4
+port_name: "{{ port_name }}"
5 5
 port_description: "{{ port_description }}"

+ 4
- 4
etc/ansible/roles/openstack-ml2/providers/cumulus/delete_port.yaml View File

@@ -1,7 +1,7 @@
1 1
 ---
2 2
 - name: "cumulus: get interfaces"
3 3
   nclu:
4
-    commands: "show interface {{ port }} json"
4
+    commands: "show interface {{ port_name }} json"
5 5
   register: output
6 6
 
7 7
 - name: "cumulus: set port facts"
@@ -10,15 +10,15 @@
10 10
 
11 11
 - name: "cumulus: verify port exists"
12 12
   fail:
13
-    msg: "port {{ port }} does not exist on this device"
13
+    msg: "port {{ port_name }} does not exist on this device"
14 14
   when: interface.mode == 'NotConfigured'
15 15
 
16 16
 - name: "cumulus: remove port configuration"
17 17
   nclu:
18
-    commands: "del interface {{ port }}"
18
+    commands: "del interface {{ port_name }}"
19 19
     commit: true
20 20
 
21 21
 - name: "cumulus: administratively disable the port"
22 22
   nclu:
23
-    commands: "add interface {{ port }} link down"
23
+    commands: "add interface {{ port_name }} link down"
24 24
     commit: true

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

@@ -3,12 +3,12 @@
3 3
   block:
4 4
     - name: "cumulus: reset interface to defaults"
5 5
       nclu:
6
-        commands: "del interface {{ port }}"
6
+        commands: "del interface {{ port_name }}"
7 7
         commit: true
8 8
 
9 9
     - name: "cumulus: build port configuration"
10 10
       nclu:
11 11
         commands:
12
-          - "add interface {{ port }} bridge access {{ _vlan_id }}"
13
-          - "del interface {{ port }} link down"
12
+          - "add interface {{ port_name }} bridge access {{ _vlan_id }}"
13
+          - "del interface {{ port_name }} link down"
14 14
         commit: true

+ 3
- 3
etc/ansible/roles/openstack-ml2/providers/eos/delete_port.yaml View File

@@ -9,12 +9,12 @@
9 9
 
10 10
 - name: "eos: verify port exists"
11 11
   fail:
12
-    msg: "port {{ port }} does not exist on this device"
12
+    msg: "port {{ port_name }} does not exist on this device"
13 13
   when: port not in output.stdout[0].interfaces | list
14 14
 
15 15
 - name: "eos: remove port configuration"
16 16
   eos_config:
17
-    lines: "default interface {{ port }}"
17
+    lines: "default interface {{ port_name }}"
18 18
   connection: network_cli
19 19
   become: True
20 20
   become_method: 'enable'
@@ -22,7 +22,7 @@
22 22
 - name: "eos: administratively disable the port"
23 23
   eos_config:
24 24
     lines: "shutdown"
25
-    parents: ["interface {{ port }}"]
25
+    parents: ["interface {{ port_name }}"]
26 26
   connection: network_cli
27 27
   become: True
28 28
   become_method: 'enable'

+ 10
- 10
etc/ansible/roles/openstack-ml2/providers/eos/update_access_port.yaml View File

@@ -2,8 +2,8 @@
2 2
 - name: "eos: get current status of the port"
3 3
   eos_command:
4 4
     commands:
5
-      - "show interface {{ port }} switchport | json"
6
-      - "show interface {{ port }} | json"
5
+      - "show interface {{ port_name }} switchport | json"
6
+      - "show interface {{ port_name }} | json"
7 7
       - "show running-config"
8 8
   register: output
9 9
   connection: network_cli
@@ -12,24 +12,24 @@
12 12
 
13 13
 - name: "eos: set port facts"
14 14
   set_fact:
15
-    switchport: "{{ output.stdout[0].switchports[port] }}"
16
-    interface: "{{ output.stdout[1].interfaces[port] }}"
15
+    switchport: "{{ output.stdout[0].switchports[port_name] }}"
16
+    interface: "{{ output.stdout[1].interfaces[port_name] }}"
17 17
 
18 18
 - name: "eos: port is configured as routed"
19 19
   block:
20 20
     - name: "eos: reset interface to defaults"
21 21
       eos_config:
22
-        lines: "default interface {{ port }}"
22
+        lines: "default interface {{ port_name }}"
23 23
 
24 24
     - name: "eos: build port configuration"
25 25
       eos_config:
26 26
         lines:
27
-          - "interface {{ port }}"
27
+          - "interface {{ port_name }}"
28 28
           - "description {{ port_description }}"
29 29
           - "switchport access vlan {{ _vlan_id }}"
30 30
           - "no shutdown"
31 31
         parents:
32
-          - "interface {{ port }}"
32
+          - "interface {{ port_name }}"
33 33
         running_config: "{{ output.stdout[2] }}"
34 34
   when: not switchport.enabled
35 35
   connection: network_cli
@@ -41,7 +41,7 @@
41 41
     - name: "eos: set the switchport mode to access"
42 42
       eos_config:
43 43
         lines: "switchport mode access"
44
-        parents: ["interface {{ port }}"]
44
+        parents: ["interface {{ port_name }}"]
45 45
       when: switchport.switchportInfo.mode != 'access'
46 46
 
47 47
     - name: "eos: configure port settings"
@@ -49,13 +49,13 @@
49 49
         lines:
50 50
           - "description {{ port_description }}"
51 51
           - "switchport access vlan {{ _vlan_id }}"
52
-        parents: ["interface {{ port }}"]
52
+        parents: ["interface {{ port_name }}"]
53 53
         running_config: "{{ output.stdout[2] }}"
54 54
 
55 55
     - name: "eos: administratively enable the port"
56 56
       eos_config:
57 57
         lines: "no shutdown"
58
-        parents: ["interface {{ port }}"]
58
+        parents: ["interface {{ port_name }}"]
59 59
       when: interface.interfaceStatus == 'disabled'
60 60
   when: switchport.enabled
61 61
   connection: network_cli

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

@@ -3,6 +3,6 @@
3 3
   junos_command:
4 4
     commands:
5 5
       - config
6
-      - "delete interfaces {{ port }}"
6
+      - "delete interfaces {{ port_name }}"
7 7
       - commit
8 8
   connection: network_cli

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

@@ -3,8 +3,8 @@
3 3
   junos_command:
4 4
     commands:
5 5
       - config
6
-      - "delete interfaces {{ port }}"
7
-      - "set interfaces {{ port }} unit 0 family ethernet-switching interface-mode access"
8
-      - "set interfaces {{ port }} unit 0 family ethernet-switching vlan members {{ _vlan_id }}"
6
+      - "delete interfaces {{ port_name }}"
7
+      - "set interfaces {{ port_name }} unit 0 family ethernet-switching interface-mode access"
8
+      - "set interfaces {{ port_name }} unit 0 family ethernet-switching vlan members {{ _vlan_id }}"
9 9
       - commit
10 10
   connection: network_cli

+ 2
- 2
etc/ansible/roles/openstack-ml2/providers/nxos/delete_port.yaml View File

@@ -1,9 +1,9 @@
1 1
 ---
2 2
 - name: "nxos: remove port configuration"
3 3
   nxos_config:
4
-    lines: "default interface {{ port }}"
4
+    lines: "default interface {{ port_name }}"
5 5
 
6 6
 - name: "nxos: administratively disable the port"
7 7
   nxos_config:
8 8
     lines: "shutdown"
9
-    parents: ["interface {{ port }}"]
9
+    parents: ["interface {{ port_name }}"]

+ 7
- 7
etc/ansible/roles/openstack-ml2/providers/nxos/update_access_port.yaml View File

@@ -2,8 +2,8 @@
2 2
 - name: "nxos: get current status of the port"
3 3
   nxos_command:
4 4
     commands:
5
-      - "show interface {{ port }} switchport | json"
6
-      - "show interface {{ port }} | json"
5
+      - "show interface {{ port_name }} switchport | json"
6
+      - "show interface {{ port_name }} | json"
7 7
       - "show running-config"
8 8
   register: output
9 9
 
@@ -16,7 +16,7 @@
16 16
   block:
17 17
     - name: "nxos: reset interface to defaults"
18 18
       nxos_config:
19
-        lines: "default interface {{ port }}"
19
+        lines: "default interface {{ port_name }}"
20 20
 
21 21
     - name: "nxos: build port configuration"
22 22
       nxos_config:
@@ -25,7 +25,7 @@
25 25
           - "switchport"
26 26
           - "switchport access vlan {{ _vlan_id }}"
27 27
           - "no shutdown"
28
-        parents: ["interface {{ port }}"]
28
+        parents: ["interface {{ port_name }}"]
29 29
         running_config: "{{ output.stdout[2] }}"
30 30
   when: switchport.switchport == 'Disabled'
31 31
 
@@ -34,7 +34,7 @@
34 34
     - name: "nxos: set the switchport mode to access"
35 35
       nxos_config:
36 36
         lines: "switchport mode access"
37
-        parents: ["interface {{ port }}"]
37
+        parents: ["interface {{ port_name }}"]
38 38
       when: switchport.oper_mode != 'access'
39 39
 
40 40
     - name: "nxos: configure port settings"
@@ -42,12 +42,12 @@
42 42
         lines:
43 43
           - "description {{ port_description }}"
44 44
           - "switchport access vlan {{ _vlan_id }}"
45
-        parents: ["interface {{ port }}"]
45
+        parents: ["interface {{ port_name }}"]
46 46
         running_config: "{{ output.stdout[2] }}"
47 47
 
48 48
     - name: "nxos: administratively enable the port"
49 49
       nxos_config:
50 50
         lines: "no shutdown"
51
-        parents: ["interface {{ port }}"]
51
+        parents: ["interface {{ port_name }}"]
52 52
       when: interface.admin_state == 'down'
53 53
   when: switchport.switchport == 'Enabled'

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

@@ -2,7 +2,7 @@
2 2
 - name: "openvswitch: run delete_port"
3 3
   openvswitch_db:
4 4
     table: Port
5
-    record: "{{ port }}"
5
+    record: "{{ port_name }}"
6 6
     col: tag
7 7
     value: "[]"
8 8
   become: yes

+ 1
- 1
etc/ansible/roles/openstack-ml2/providers/openvswitch/update_access_port.yaml View File

@@ -2,7 +2,7 @@
2 2
 - name: "openvswitch: run update_port"
3 3
   openvswitch_db:
4 4
     table: Port
5
-    record: "{{ port }}"
5
+    record: "{{ port_name }}"
6 6
     col: tag
7 7
     value: "{{ _vlan_id }}"
8 8
   become: yes

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

@@ -1,9 +1,9 @@
1 1
 ---
2 2
 # delegate task to localhost to avoid starting the device connection
3
-- name: "check for required fact: port"
3
+- name: "check for required fact: port_name"
4 4
   fail:
5
-    msg: "missing required fact: port"
6
-  when: not port
5
+    msg: "missing required fact: port_name"
6
+  when: not port_name
7 7
   delegate_to: localhost
8 8
 
9 9
 - name: include and run device provider specific tasks

+ 3
- 3
etc/ansible/roles/openstack-ml2/tasks/update_access_port.yaml View File

@@ -1,9 +1,9 @@
1 1
 ---
2 2
 # delegate task to localhost to avoid starting the device connection
3
-- name: "check for required fact: port"
3
+- name: "check for required fact: port_name"
4 4
   fail:
5
-    msg: "missing required fact: port"
6
-  when: not port
5
+    msg: "missing required fact: port_name"
6
+  when: not port_name
7 7
   delegate_to: localhost
8 8
 
9 9
 # delegate task to localhost to avoid starting the device connection

+ 1
- 1
etc/ansible/roles/openstack-ml2/vars/main.yml View File

@@ -4,5 +4,5 @@ vlan_id: null
4 4
 vlan_name: null
5 5
 
6 6
 # vars required for managing ports
7
-port: null
7
+port_name: null
8 8
 port_description: null

+ 1
- 1
networking_ansible/api.py View File

@@ -60,7 +60,7 @@ class NetworkingAnsible(object):
60 60
         if vlan_name:
61 61
             playbook[0]['tasks'][0]['vars']['vlan_name'] = vlan_name
62 62
         if port:
63
-            playbook[0]['tasks'][0]['vars']['port'] = port
63
+            playbook[0]['tasks'][0]['vars']['port_name'] = port
64 64
             playbook[0]['tasks'][0]['vars']['port_description'] = port
65 65
 
66 66
         # invoke ansible networking via ansible runner

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

@@ -70,7 +70,7 @@ class TestRunTask(base.NetworkingAnsibleTestCase):
70 70
         self.assertEqual(
71 71
             self.testport,
72 72
             mock_ans_runner.run.call_args[1]['playbook'][0]['tasks']
73
-                                         [0]['vars']['port'])
73
+                                         [0]['vars']['port_name'])
74 74
         # Assert switch_port is set
75 75
         self.assertEqual(
76 76
             self.testport,

Loading…
Cancel
Save