ansible-collections/cisco.nxos

cisco.nxos.nxos_zone_zoneset does not find initiator device alias to be removed from smart zone

colinet opened this issue · 6 comments

SUMMARY

Upon using cisco.nxos.nxos_zone_zoneset to remove FC alias from smart zone, the output states that FC alias provided in playbook is not in zmart zone. Checking with CLI, the FC alias is in smart zone. The module performs consequently no action.

Collection version 4.1.0

ISSUE TYPE
  • Bug Report
COMPONENT NAME

cisco.nxos.nxos_zone_zoneset

ANSIBLE VERSION
ansible [core 2.11.9]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/xxxxxx/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.9/site-packages/ansible
  ansible collection location = /home/xxxxxx/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.9.14 (main, Sep 21 2022, 00:00:00) [GCC 11.3.1 20220421 (Red Hat 11.3.1-2)]
  jinja version = 3.1.2
  libyaml = True
COLLECTION VERSION
$ ansible-galaxy collection list | grep nxos
cisco.nxos        4.1.0     <-- manually updated
cisco.nxos                    2.8.2  
$ 
CONFIGURATION

Standard configuration

OS / ENVIRONMENT

OS is RHEL 8.7

STEPS TO REPRODUCE

With one fabric, one smart zone and one FC alias, try remove the FC alias from the smart zone.

- name: switch_fc | helpers | smartzone update | remove devalias to smartzone
  cisco.nxos.nxos_zone_zoneset:
    zone_zoneset_details:
    - mode: basic
      smart_zoning: true
      vsan: 1000
      zone:
      - members:
        - devtype: initiator
          device_alias: host_fc0
          remove: true
        name: sz_host_fc0
EXPECTED RESULTS

The module should remove the FC alias from the smart zone.

ACTUAL RESULTS

The output exposed, states that "zone member 'host_fc0' of device type 'initiator' is not present in zone 'sz_host_fc0' in vsan 1000 hence nothing to remove" which is false. FC alias host_fc0 is in smart zone sz_host_fc0.

TASK [ds-role-san_CRUD : switch_fc | helpers | smartzone update | check result] **********************************************************************************************************************************************************
Tuesday 04 April 2023  13:42:03 +0200 (0:00:00.963)       0:00:07.870 ********* 
ok: [localhost] => {
    "_sz_find_output": {
        "changed": false,
        "commands": [],
        "failed": false,
        "messages": [
            "zone mode is already basic ,no change in zone mode configuration for vsan 1000",
            "smart-zoning is already set to enabled , no change in smart-zoning configuration for vsan 1000",
            "zone member 'host_fc0' of device type 'initiator' is not present in zone 'sz_host_fc0' in vsan 1000 hence nothing to remove"
        ]
    }
}

cc @srbharadwaj for MDS issue.

Did some more tests about this bug.

Using below playbook, it works:

- name: switch_fc | helpers | smartzone update | remove devalias to smartzone
  cisco.nxos.nxos_zone_zoneset:
    zone_zoneset_details:
    - mode: basic
      smart_zoning: true
      vsan: 1000
      zone:
      - members:
        - devtype: initiator
          pwwn: aa:aa:aa:aa:aa:aa:aa
          # Removal works only with wwpn. Not with devalias
          #device_alias: host_fc0
          remove: true
        name: sz_host_fc0

So the issue is that device_alias is not resolved to wwpn.

Removal of FC initiator can only be done by wwpn. Not with device alias.

This seems to be a bug as per the documentation of the Ansible module.

headline says "fc-alias" and comments say "device-alias" can you confirm which one is it?
If you can send the show tech zone vsan 1000 from the switch that would be helpful

headline says "fc-alias" and comments say "device-alias" can you confirm which one is it? If you can send the show tech zone vsan 1000 from the switch that would be helpful

This is FC initiator device alias which cannot be removed from smart zone.
The FC wwpn has to be referenced to remove the initiator from smart zone.

I cannot share the output of the command.
This is proprietary data.

@colinet which ever member type was used for zone member addition, the same needs to be used for deletion, if pwwn was used during creation then pwwn needs to be used during deletion, in your case using pwwn worked, because during zone member creation pwwn was used.
here is an example

switch(config)# sh zone vsan 1
zone name z64g vsan 1
  pwwn 21:00:f4:c7:aa:0c:a7:bf [hba_64g_ini_190]
  pwwn 21:00:f4:c7:aa:0c:a7:cc [hba_64g_tar_188]
switch(config)# 

in the above case only member type pwwn can be used for zone member deletion and not device alias

@colinet which ever member type was used for zone member addition, the same needs to be used for deletion, if pwwn was used during creation then pwwn needs to be used during deletion, in your case using pwwn worked, because during zone member creation pwwn was used. here is an example

switch(config)# sh zone vsan 1
zone name z64g vsan 1
  pwwn 21:00:f4:c7:aa:0c:a7:bf [hba_64g_ini_190]
  pwwn 21:00:f4:c7:aa:0c:a7:cc [hba_64g_tar_188]
switch(config)# 

in the above case only member type pwwn can be used for zone member deletion and not device alias

My observation is that:

  • we use device alias to populate zone members.
  • we have to use pwwn to remove these same members.

The play to add and remove is:

- name: switch_fc | helpers | smartzone update | add or delete devalias to smartzone
  cisco.nxos.nxos_zone_zoneset:
    zone_zoneset_details:
    - mode: basic
      smart_zoning: true
      vsan: "{{ _smartzone_update_vsan_id }}"
      zone:
      - members:
        - devtype: initiator
          pwwn: "{{ _smartzone_update_wwpn if (_smartzone_update_devalias_remove is defined and _smartzone_update_devalias_remove|bool) else omit }}"
          device_alias: "{{ omit if (_smartzone_update_devalias_remove is defined and _smartzone_update_devalias_remove|bool) else _smartzone_update_devalias_name }}"
          remove: "{{ _smartzone_update_devalias_remove |default(omit) }}"
        name: "{{ _smartzone_update_smartzone_name }}"
      zoneset:
      - action: activate
        members:
        - name: "{{ _smartzone_update_smartzone_name }}"
        name: "{{ _smartzone_update_zoneset_name }}"

The switch between add and remove is controlled with : _smartzone_update_devalias_remove