Browse Source

renaming ansible role variables

Change-Id: I8784de4d480f0ba0a2b55365ab27c611173372b0
Dan Radez 4 months ago
parent
commit
5c346b9865
31 changed files with 92 additions and 93 deletions
  1. 1
    1
      doc/source/contributor/provider.rst
  2. 6
    7
      etc/ansible/roles/openstack-ml2/README.md
  3. 3
    3
      etc/ansible/roles/openstack-ml2/defaults/main.yml
  4. 1
    1
      etc/ansible/roles/openstack-ml2/providers/cumulus/create_vlan.yaml
  5. 2
    2
      etc/ansible/roles/openstack-ml2/providers/cumulus/defaults.yaml
  6. 4
    4
      etc/ansible/roles/openstack-ml2/providers/cumulus/delete_port.yaml
  7. 1
    1
      etc/ansible/roles/openstack-ml2/providers/cumulus/delete_vlan.yaml
  8. 3
    3
      etc/ansible/roles/openstack-ml2/providers/cumulus/update_access_port.yaml
  9. 2
    2
      etc/ansible/roles/openstack-ml2/providers/eos/create_vlan.yaml
  10. 2
    2
      etc/ansible/roles/openstack-ml2/providers/eos/defaults.yaml
  11. 4
    4
      etc/ansible/roles/openstack-ml2/providers/eos/delete_port.yaml
  12. 1
    1
      etc/ansible/roles/openstack-ml2/providers/eos/delete_vlan.yaml
  13. 14
    14
      etc/ansible/roles/openstack-ml2/providers/eos/update_access_port.yaml
  14. 1
    1
      etc/ansible/roles/openstack-ml2/providers/junos/create_vlan.yaml
  15. 2
    2
      etc/ansible/roles/openstack-ml2/providers/junos/defaults.yaml
  16. 1
    1
      etc/ansible/roles/openstack-ml2/providers/junos/delete_port.yaml
  17. 1
    1
      etc/ansible/roles/openstack-ml2/providers/junos/delete_vlan.yaml
  18. 3
    3
      etc/ansible/roles/openstack-ml2/providers/junos/update_access_port.yaml
  19. 2
    2
      etc/ansible/roles/openstack-ml2/providers/nxos/create_vlan.yaml
  20. 2
    2
      etc/ansible/roles/openstack-ml2/providers/nxos/defaults.yaml
  21. 2
    2
      etc/ansible/roles/openstack-ml2/providers/nxos/delete_port.yaml
  22. 1
    1
      etc/ansible/roles/openstack-ml2/providers/nxos/delete_vlan.yaml
  23. 11
    11
      etc/ansible/roles/openstack-ml2/providers/nxos/update_access_port.yaml
  24. 2
    2
      etc/ansible/roles/openstack-ml2/providers/openvswitch/defaults.yaml
  25. 1
    1
      etc/ansible/roles/openstack-ml2/providers/openvswitch/delete_port.yaml
  26. 2
    2
      etc/ansible/roles/openstack-ml2/providers/openvswitch/update_access_port.yaml
  27. 3
    3
      etc/ansible/roles/openstack-ml2/tasks/delete_port.yaml
  28. 4
    4
      etc/ansible/roles/openstack-ml2/tasks/update_access_port.yaml
  29. 5
    5
      etc/ansible/roles/openstack-ml2/vars/main.yml
  30. 3
    3
      networking_ansible/api.py
  31. 2
    2
      networking_ansible/tests/unit/test_api.py

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

@@ -22,7 +22,7 @@ networking-ansible.
22 22
 
23 23
 * defaults.yaml
24 24
 
25
-  Defines default values for segmentation name and ID. For example some
25
+  Defines default values for VLAN name and ID. For example some
26 26
   switch vendors use the name "default" and VLAN ID 1 as a default VLAN
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.

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

@@ -8,9 +8,8 @@ Requirements
8 8
 
9 9
 Role Variables
10 10
 --------------
11
-
12
-* ml2_segmenation_id
13
-* ml2_segmentation_name (default depends on provider)
11
+* vlan_id
12
+* vlan_name (default depends on provider)
14 13
 
15 14
 Dependencies
16 15
 ------------
@@ -32,16 +31,16 @@ Example Playbook
32 31
         name: openstack-ml2
33 32
         tasks_from: create_vlan
34 33
       vars:
35
-        segmentation_name: v101
36
-        segmentation_id: 101
34
+        vlan_name: v101
35
+        vlan_id: 101
37 36
 
38 37
     - name: do create_vlan
39 38
       import_role:
40 39
         name: openstack-ml2
41 40
         tasks_from: delete_vlan
42 41
       vars:
43
-        segmentation_id: 101
44
-        segmentation_name: v101
42
+        vlan_id: 101
43
+        vlan_name: v101
45 44
 ```
46 45
 
47 46
 

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

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

+ 1
- 1
etc/ansible/roles/openstack-ml2/providers/cumulus/create_vlan.yaml View File

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

+ 2
- 2
etc/ansible/roles/openstack-ml2/providers/cumulus/defaults.yaml View File

@@ -1,3 +1,3 @@
1 1
 ---
2
-ml2_segmentation_id: "{{ segmentation_id | default(1, True)}}"
3
-ml2_segmentation_name: '{{segmentation_name if segmentation_name else "default" if ml2_segmentation_id|string == "1" else "vlan"+segmentation_id|string }}'
2
+_vlan_id: "{{ vlan_id | default(1, True)}}"
3
+_vlan_name: '{{ vlan_name if vlan_name else "default" if vlan_id|string == "1" else "vlan"+vlan_id|string }}'

+ 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 {{ ml2_port_name }} json"
4
+    commands: "show interface {{ port }} 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 {{ ml2_port_name }} does not exist on this device"
13
+    msg: "port {{ port }} 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 {{ ml2_port_name }}"
18
+    commands: "del interface {{ port }}"
19 19
     commit: true
20 20
 
21 21
 - name: "cumulus: administratively disable the port"
22 22
   nclu:
23
-    commands: "add interface {{ ml2_port_name }} link down"
23
+    commands: "add interface {{ port }} link down"
24 24
     commit: true

+ 1
- 1
etc/ansible/roles/openstack-ml2/providers/cumulus/delete_vlan.yaml View File

@@ -1,5 +1,5 @@
1 1
 ---
2 2
 - name: "cumulus: delete vlan using nclu"
3 3
   nclu:
4
-    commands: 'del vlan {{ ml2_segmentation_id }}'
4
+    commands: 'del vlan {{ _vlan_id }}'
5 5
     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 {{ ml2_port_name }}"
6
+        commands: "del interface {{ port }}"
7 7
         commit: true
8 8
 
9 9
     - name: "cumulus: build port configuration"
10 10
       nclu:
11 11
         commands:
12
-          - "add interface {{ ml2_port_name }} bridge access {{ ml2_segmentation_id }}"
13
-          - "del interface {{ ml2_port_name }} link down"
12
+          - "add interface {{ port }} bridge access {{ _vlan_id }}"
13
+          - "del interface {{ port }} link down"
14 14
         commit: true

+ 2
- 2
etc/ansible/roles/openstack-ml2/providers/eos/create_vlan.yaml View File

@@ -2,9 +2,9 @@
2 2
 - name: "eos: create vlan using network_cli"
3 3
   eos_config:
4 4
     lines:
5
-      - "name {{ ml2_segmentation_name }}"
5
+      - "name {{ _vlan_name }}"
6 6
     parents:
7
-      - "vlan {{ ml2_segmentation_id }}"
7
+      - "vlan {{ _vlan_id }}"
8 8
   connection: network_cli
9 9
   become: True
10 10
   become_method: 'enable'

+ 2
- 2
etc/ansible/roles/openstack-ml2/providers/eos/defaults.yaml View File

@@ -1,3 +1,3 @@
1 1
 ---
2
-ml2_segmentation_id: "{{ segmentation_id | default(1, True)}}"
3
-ml2_segmentation_name: '{{segmentation_name if segmentation_name else "default" if ml2_segmentation_id|string == "1" else "vlan"+segmentation_id|string }}'
2
+_vlan_id: "{{ vlan_id | default(1, True)}}"
3
+_vlan_name: '{{ vlan_name if vlan_name else "default" if vlan_id|string == "1" else "vlan"+vlan_id|string }}'

+ 4
- 4
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 {{ ml2_port_name }} does not exist on this device"
13
-  when: ml2_port_name not in output.stdout[0].interfaces | list
12
+    msg: "port {{ port }} does not exist on this device"
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 {{ ml2_port_name }}"
17
+    lines: "default interface {{ port }}"
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 {{ ml2_port_name }}"]
25
+    parents: ["interface {{ port }}"]
26 26
   connection: network_cli
27 27
   become: True
28 28
   become_method: 'enable'

+ 1
- 1
etc/ansible/roles/openstack-ml2/providers/eos/delete_vlan.yaml View File

@@ -1,7 +1,7 @@
1 1
 ---
2 2
 - name: "eos: delete vlan using network_cli"
3 3
   eos_config:
4
-    lines: "no vlan {{ ml2_segmentation_id }}"
4
+    lines: "no vlan {{ _vlan_id }}"
5 5
   connection: network_cli
6 6
   become: True
7 7
   become_method: 'enable'

+ 14
- 14
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 {{ ml2_port_name }} switchport | json"
6
-      - "show interface {{ ml2_port_name }} | json"
5
+      - "show interface {{ port }} switchport | json"
6
+      - "show interface {{ port }} | 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[ml2_port_name] }}"
16
-    interface: "{{ output.stdout[1].interfaces[ml2_port_name] }}"
15
+    switchport: "{{ output.stdout[0].switchports[port] }}"
16
+    interface: "{{ output.stdout[1].interfaces[port] }}"
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 {{ ml2_port_name }}"
22
+        lines: "default interface {{ port }}"
23 23
 
24 24
     - name: "eos: build port configuration"
25 25
       eos_config:
26 26
         lines:
27
-          - "interface {{ ml2_port_name }}"
28
-          - "description {{ ml2_port_description }}"
29
-          - "switchport access vlan {{ ml2_segmentation_id }}"
27
+          - "interface {{ port }}"
28
+          - "description {{ port_description }}"
29
+          - "switchport access vlan {{ _vlan_id }}"
30 30
           - "no shutdown"
31 31
         parents:
32
-          - "interface {{ ml2_port_name }}"
32
+          - "interface {{ port }}"
33 33
         running_config: "{{ output.stdout[2] }}"
34 34
   when: not switchport.enabled
35 35
   connection: network_cli
@@ -41,21 +41,21 @@
41 41
     - name: "eos: set the switchport mode to access"
42 42
       eos_config:
43 43
         lines: "switchport mode access"
44
-        parents: ["interface {{ ml2_port_name }}"]
44
+        parents: ["interface {{ port }}"]
45 45
       when: switchport.switchportInfo.mode != 'access'
46 46
 
47 47
     - name: "eos: configure port settings"
48 48
       eos_config:
49 49
         lines:
50
-          - "description {{ ml2_port_description }}"
51
-          - "switchport access vlan {{ ml2_segmentation_id }}"
52
-        parents: ["interface {{ ml2_port_name }}"]
50
+          - "description {{ port_description }}"
51
+          - "switchport access vlan {{ _vlan_id }}"
52
+        parents: ["interface {{ port }}"]
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 {{ ml2_port_name }}"]
58
+        parents: ["interface {{ port }}"]
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/create_vlan.yaml View File

@@ -3,6 +3,6 @@
3 3
   junos_command:
4 4
     commands:
5 5
       - config
6
-      - "set vlans {{ ml2_segmentation_name }} vlan-id {{ ml2_segmentation_id }}"
6
+      - "set vlans {{ _vlan_name }} vlan-id {{ _vlan_id }}"
7 7
       - commit
8 8
   connection: network_cli

+ 2
- 2
etc/ansible/roles/openstack-ml2/providers/junos/defaults.yaml View File

@@ -1,3 +1,3 @@
1 1
 ---
2
-ml2_segmentation_id: "{{ segmentation_id | default(1, True)}}"
3
-ml2_segmentation_name: '{{segmentation_name if segmentation_name else "default" if ml2_segmentation_id|string == "1" else "vlan"+segmentation_id|string }}'
2
+_vlan_id: "{{ vlan_id | default(1, True)}}"
3
+_vlan_name: '{{ vlan_name if vlan_name else "default" if vlan_id|string == "1" else "vlan"+vlan_id|string }}'

+ 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 {{ ml2_port_name }}"
6
+      - "delete interfaces {{ port }}"
7 7
       - commit
8 8
   connection: network_cli

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

@@ -3,6 +3,6 @@
3 3
   junos_command:
4 4
     commands:
5 5
       - config
6
-      - "delete vlans {{ ml2_segmentation_name }}"
6
+      - "delete vlans {{ _vlan_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 {{ ml2_port_name }}"
7
-      - "set interfaces {{ ml2_port_name }} unit 0 family ethernet-switching interface-mode access"
8
-      - "set interfaces {{ ml2_port_name }} unit 0 family ethernet-switching vlan members {{ ml2_segmentation_id }}"
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 }}"
9 9
       - commit
10 10
   connection: network_cli

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

@@ -2,8 +2,8 @@
2 2
 - name: "nxos: run create vlan using network_cli"
3 3
   nxos_config:
4 4
     lines:
5
-      - "name {{ ml2_segmentation_name }}"
5
+      - "name {{ _vlan_name }}"
6 6
     parents:
7
-      - "vlan {{ ml2_segmentation_id }}"
7
+      - "vlan {{ _vlan_id }}"
8 8
   connection: network_cli
9 9
 

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

@@ -1,3 +1,3 @@
1 1
 ---
2
-ml2_segmentation_id: "{{ segmentation_id | default(1, True)}}"
3
-ml2_segmentation_name: '{{segmentation_name if segmentation_name else "default" if ml2_segmentation_id|string == "1" else "vlan"+segmentation_id|string }}'
2
+_vlan_id: "{{ vlan_id | default(1, True)}}"
3
+_vlan_name: '{{ vlan_name if vlan_name else "default" if vlan_id|string == "1" else "vlan"+vlan_id|string }}'

+ 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 {{ ml2_port_name }}"
4
+    lines: "default interface {{ port }}"
5 5
 
6 6
 - name: "nxos: administratively disable the port"
7 7
   nxos_config:
8 8
     lines: "shutdown"
9
-    parents: ["interface {{ ml2_port_name }}"]
9
+    parents: ["interface {{ port }}"]

+ 1
- 1
etc/ansible/roles/openstack-ml2/providers/nxos/delete_vlan.yaml View File

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

+ 11
- 11
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 {{ ml2_port_name }} switchport | json"
6
-      - "show interface {{ ml2_port_name }} | json"
5
+      - "show interface {{ port }} switchport | json"
6
+      - "show interface {{ port }} | json"
7 7
       - "show running-config"
8 8
   register: output
9 9
 
@@ -16,16 +16,16 @@
16 16
   block:
17 17
     - name: "nxos: reset interface to defaults"
18 18
       nxos_config:
19
-        lines: "default interface {{ ml2_port_name }}"
19
+        lines: "default interface {{ port }}"
20 20
 
21 21
     - name: "nxos: build port configuration"
22 22
       nxos_config:
23 23
         lines:
24
-          - "description {{ ml2_port_description }}"
24
+          - "description {{ port_description }}"
25 25
           - "switchport"
26
-          - "switchport access vlan {{ ml2_segmentation_id }}"
26
+          - "switchport access vlan {{ _vlan_id }}"
27 27
           - "no shutdown"
28
-        parents: ["interface {{ ml2_port_name }}"]
28
+        parents: ["interface {{ port }}"]
29 29
         running_config: "{{ output.stdout[2] }}"
30 30
   when: switchport.switchport == 'Disabled'
31 31
 
@@ -34,20 +34,20 @@
34 34
     - name: "nxos: set the switchport mode to access"
35 35
       nxos_config:
36 36
         lines: "switchport mode access"
37
-        parents: ["interface {{ ml2_port_name }}"]
37
+        parents: ["interface {{ port }}"]
38 38
       when: switchport.oper_mode != 'access'
39 39
 
40 40
     - name: "nxos: configure port settings"
41 41
       nxos_config:
42 42
         lines:
43
-          - "description {{ ml2_port_description }}"
44
-          - "switchport access vlan {{ ml2_segmentation_id }}"
45
-        parents: ["interface {{ ml2_port_name }}"]
43
+          - "description {{ port_description }}"
44
+          - "switchport access vlan {{ _vlan_id }}"
45
+        parents: ["interface {{ port }}"]
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 {{ ml2_port_name }}"]
51
+        parents: ["interface {{ port }}"]
52 52
       when: interface.admin_state == 'down'
53 53
   when: switchport.switchport == 'Enabled'

+ 2
- 2
etc/ansible/roles/openstack-ml2/providers/openvswitch/defaults.yaml View File

@@ -1,3 +1,3 @@
1 1
 ---
2
-ml2_segmentation_id: "{{ segmentation_id | default([], True)}}"
3
-ml2_segmentation_name: '{{segmentation_name if segmentation_name else "vlan"+segmentation_id|string }}'
2
+_vlan_id: "{{ vlan_id | default([], True)}}"
3
+_vlan_name: '{{ vlan_name if vlan_name else "vlan"+vlan_id|string }}'

+ 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: "{{ ml2_port_name }}"
5
+    record: "{{ port }}"
6 6
     col: tag
7 7
     value: "[]"
8 8
   become: yes

+ 2
- 2
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: "{{ ml2_port_name }}"
5
+    record: "{{ port }}"
6 6
     col: tag
7
-    value: "{{ ml2_segmentation_id }}"
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_name"
3
+- name: "check for required fact: port"
4 4
   fail:
5
-    msg: "missing required fact: port_name"
6
-  when: not ml2_port_name
5
+    msg: "missing required fact: port"
6
+  when: not port
7 7
   delegate_to: localhost
8 8
 
9 9
 - name: include and run device provider specific tasks

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

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

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

@@ -1,8 +1,8 @@
1 1
 ---
2
-# vars required for managing ML2 networks
3
-segmentation_id: null
4
-segmentation_name: null
2
+# vars required for managing VLANs
3
+vlan_id: null
4
+vlan_name: null
5 5
 
6
-# vars required for managing ML2 ports
7
-port_name: null
6
+# vars required for managing ports
7
+port: null
8 8
 port_description: null

+ 3
- 3
networking_ansible/api.py View File

@@ -33,7 +33,7 @@ class NetworkingAnsible(object):
33 33
 
34 34
         :param task: name of task in openstack-ml2 ansible role
35 35
         :param host_name: name of a host defined in ml2 conf ini files
36
-        :param segmentation_id: vlan id of the network
36
+        :param vlan_id: vlan id of the network
37 37
         :param switch_port: port name on the switch (optional)
38 38
 
39 39
         See etc/ansible/roles/openstack-ml2/README.md for an exmaple playbook
@@ -51,12 +51,12 @@ class NetworkingAnsible(object):
51 51
                     'tasks_from': task,
52 52
                 },
53 53
                 'vars': {
54
-                    'segmentation_id': vlan_id,
54
+                    'vlan_id': vlan_id,
55 55
                 }
56 56
             }]
57 57
         }]
58 58
         if port:
59
-            playbook[0]['tasks'][0]['vars']['port_name'] = port
59
+            playbook[0]['tasks'][0]['vars']['port'] = port
60 60
             playbook[0]['tasks'][0]['vars']['port_description'] = port
61 61
 
62 62
         # invoke ansible networking via ansible runner

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

@@ -47,7 +47,7 @@ class TestRunTask(base.NetworkingAnsibleTestCase):
47 47
         self.mech.ansnet._run_task('fake_task',
48 48
                                    self.testhost)
49 49
         # Assert switch_port is not set
50
-        self.assertNotIn('port_name',
50
+        self.assertNotIn('port',
51 51
                          mock_ans_runner.run.call_args[1]['playbook'][0]
52 52
                                                       ['tasks'][0]['vars']
53 53
                          )
@@ -69,7 +69,7 @@ class TestRunTask(base.NetworkingAnsibleTestCase):
69 69
         self.assertEqual(
70 70
             self.testport,
71 71
             mock_ans_runner.run.call_args[1]['playbook'][0]['tasks']
72
-                                         [0]['vars']['port_name'])
72
+                                         [0]['vars']['port'])
73 73
         # Assert switch_port is set
74 74
         self.assertEqual(
75 75
             self.testport,

Loading…
Cancel
Save