Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vmware_host_vmhba_facts and vmware_host_vmhba_info truncate WWN of FC HBA #63045

Closed
Jon-Rausch opened this issue Oct 2, 2019 · 15 comments · Fixed by #66692
Closed

vmware_host_vmhba_facts and vmware_host_vmhba_info truncate WWN of FC HBA #63045

Jon-Rausch opened this issue Oct 2, 2019 · 15 comments · Fixed by #66692
Labels
affects_2.8 This issue/PR affects Ansible v2.8 bug This issue/PR relates to a bug. cloud deprecated This issue/PR relates to a deprecated module. has_pr This issue has an associated PR. module This issue/PR relates to a module. needs_info This issue requires further information. Please answer any outstanding questions. support:community This issue/PR relates to code supported by the Ansible community. vmware VMware community

Comments

@Jon-Rausch
Copy link

Jon-Rausch commented Oct 2, 2019

SUMMARY

vmware_host_vmhba_facts module returns the decimal formatted WWN/WWPN of the FiberChannel HBA, but truncates the last digit, making it impossible to convert to hex or determine the real HBA WWPN for zoning/mapping. even the help text of the module on the https://docs.ansible.com/ansible/latest/modules/vmware_host_vmhba_facts_module.html site displays the truncated value that is useless.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

vmware_host_vmhba_facts and vmware_host_vmhba_info modules

ANSIBLE VERSION
ansible --version
ansible 2.8.4
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.5 (default, Aug  7 2019, 00:51:29) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
CONFIGURATION
#ansible-config dump --only-changed
#
OS / ENVIRONMENT

VMware ESXi, 6.7.0
VMWare ESXi, 6.5.0
QLogic 57840 10/20 Gigabit Ethernet Adapter "driver": "qfle3f",
CentOS7
ansible 2.8
ansible 2.10

STEPS TO REPRODUCE

gather HBA data from ESX servers using the vmware_host_vmhba_info or vmware_host_vmhba_facts modules. The output of the port_wwn and node_wwn are returned in decimal format with colon separation and truncated by one character. For Example, 11:53:10:06:16:15:36:94:72 should be 11:53:10:06:16:15:36:94:725. The colons are not needed since this is a decimal value, which may also be a module problem. They are even truncated in the example help text of the module (576496321590239521)!!! , showing this hasn't been tested properly since the beginning of module creation and has been a bug since inception! This same bug is present on the newest version of the module in ansbile 2.10 currently in development as well.

    - name: Gather vmware host HBA facts from vCenter
      vmware_host_vmhba_info:
        cluster_name: '{{ cluster }}'
        username: '{{ vcenter_username }}'
        password: '{{ vcenter_password }}'
        hostname: '{{ vcenter_hostname }}'
        validate_certs: no
      register: host_facts
      delegate_to: localhost
EXPECTED RESULTS

Expected the decimal number representation of the WWN returned by vmware to be returned in full so that it could be converted to HEX and to the actual WWPN/WWN for zoning/mapping/etc. port_wwn value should return enough digits to display the fiberchannel wwn in full.

ACTUAL RESULTS

The decimal formatted number is returned with a truncated last digit, making the value invalid and it cannot be converted to HEX format.


TASK [Gather vmware host HBA facts from vCenter] *************************************************************************************************************************************************************************************
task path: /root/hbagather.yml:24
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: root
<localhost> EXEC /bin/sh -c 'echo ~root && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp/ansible-tmp-1570019424.92-77457880685052 `" && echo ansible-tmp-1570019424.92-77457880685052="` echo /root/.ansible/tmp/ansible-tmp-1570019424.92-77457880685052 `" ) && sleep 0'
Using module file /usr/lib/python2.7/site-packages/ansible/modules/cloud/vmware/vmware_host_vmhba_info.py
<localhost> PUT /root/.ansible/tmp/ansible-local-776496XYTxD/tmpPFZa23 TO /root/.ansible/tmp/ansible-tmp-1570019424.92-77457880685052/AnsiballZ_vmware_host_vmhba_info.py
<localhost> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1570019424.92-77457880685052/ /root/.ansible/tmp/ansible-tmp-1570019424.92-77457880685052/AnsiballZ_vmware_host_vmhba_info.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python2 /root/.ansible/tmp/ansible-tmp-1570019424.92-77457880685052/AnsiballZ_vmware_host_vmhba_info.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1570019424.92-77457880685052/ > /dev/null 2>&1 && sleep 0'
ok: [localhost -> localhost] => {
    "changed": false,
    "hosts_vmhbas_info": {
        "hostname.example.com": {
            "vmhba_details": [
                {
                    "adapter": "HPE Smart Array P220i",
                    "bus": 34,
                    "device": "vmhba0",
                    "driver": "nhpsa",
                    "location": "0000:22:00.0",
                    "model": "Smart Array P220i",
                    "node_wwn": "50:01:43:80:32:53:90:a0",
                    "status": "unknown",
                    "type": "SAS"
                },
                {
                    "adapter": "Broadcom Corporation QLogic 57840 10/20 Gigabit Ethernet Adapter",
                    "bus": 2,
                    "device": "vmhba32",
                    "driver": "bnx2fc",
                    "location": "0000:02:00.2",
                    "model": "QLogic 57840 10/20 Gigabit Ethernet Adapter",
                    "node_wwn": "11:53:10:06:16:15:36:94:72",
                    "port_type": "unknown",
                    "port_wwn": "11:53:10:06:16:15:36:94:72",
                    "speed": 0,
                    "status": "online",
                    "type": "FibreChannelOverEthernetHba"
                },
                {
                    "adapter": "Broadcom Corporation QLogic 57840 10/20 Gigabit Ethernet Adapter",
                    "bus": 2,
                    "device": "vmhba33",
                    "driver": "bnx2fc",
                    "location": "0000:02:00.3",
                    "model": "QLogic 57840 10/20 Gigabit Ethernet Adapter",
                    "node_wwn": "11:53:04:10:85:47:50:56:04",
                    "port_type": "unknown",
                    "port_wwn": "23:05:96:25:90:08:19:03:01",
                    "speed": 0,
                    "status": "unknown",
                    "type": "FibreChannelOverEthernetHba"
                },
                {
                    "adapter": "Broadcom Corporation QLogic 57840 10/20 Gigabit Ethernet Adapter",
                    "bus": 33,
                    "device": "vmhba34",
                    "driver": "bnx2fc",
                    "location": "0000:21:00.2",
                    "model": "QLogic 57840 10/20 Gigabit Ethernet Adapter",
                    "node_wwn": "11:53:04:10:85:47:50:57:39",
                    "port_type": "unknown",
                    "port_wwn": "23:05:96:25:90:08:19:04:36",
                    "speed": 0,
                    "status": "unknown",
                    "type": "FibreChannelOverEthernetHba"
                },
                {
                    "adapter": "Broadcom Corporation QLogic 57840 10/20 Gigabit Ethernet Adapter",
                    "bus": 33,
                    "device": "vmhba35",
                    "driver": "bnx2fc",
                    "location": "0000:21:00.3",
                    "model": "QLogic 57840 10/20 Gigabit Ethernet Adapter",
                    "node_wwn": "11:53:10:06:16:15:36:94:72",
                    "port_type": "unknown",
                    "port_wwn": "11:53:10:06:16:15:36:94:72",
                    "speed": 0,
                    "status": "online",
                    "type": "FibreChannelOverEthernetHba"
                }
            ]
        },
@ansibot
Copy link
Contributor

ansibot commented Oct 2, 2019

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibot
Copy link
Contributor

ansibot commented Oct 2, 2019

@ansibot
Copy link
Contributor

ansibot commented Oct 2, 2019

@Jon-Rausch, just so you are aware we have a dedicated Working Group for vmware.
You can find other people interested in this in #ansible-vmware on Freenode IRC
For more information about communities, meetings and agendas see https://github.com/ansible/community

click here for bot help

@ansibot ansibot added affects_2.8 This issue/PR affects Ansible v2.8 bug This issue/PR relates to a bug. cloud deprecated This issue/PR relates to a deprecated module. module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. support:community This issue/PR relates to code supported by the Ansible community. vmware VMware community labels Oct 2, 2019
@Jon-Rausch
Copy link
Author

Bug is in the code that adds colons and number formatting in the module. If I remove the self.format_number I get the original decimal notation without truncation. Below is the offending code:

try:
hba_info['node_wwn'] = self.format_number(hba.portWorldWideName)
except AttributeError:
pass

@staticmethod
def format_number(number):
    """Format number"""
    string = str(number)
    return ':'.join(a + b for a, b in zip(string[::2], string[1::2]))

I

@Jon-Rausch
Copy link
Author

The code could be fixed by converting the number to HEX in the initial pull of hba.portWorldWideName and stripping out the leading 0x and trailing L associated with the conversion, before sending it to the format_number. Below is the code modification that should be done in the module:

try:
hba_info['port_wwn'] = self.format_number(hex(hba.portWorldWideName).lstrip("0x").rstrip("L"))
except AttributeError:
pass

@Jon-Rausch
Copy link
Author

That same code change should be done for the "node_wwn" values as well

@Akasurde
Copy link
Member

Akasurde commented Oct 9, 2019

@Jon-Rausch Thanks for the debugging and providing this useful insights.

@ansibot ansibot removed the needs_triage Needs a first human triage before being processed. label Oct 9, 2019
@Jon-Rausch
Copy link
Author

The Ansible bot incorrectly marked this as depreciated version and ansible version 2.8. It's actually in the current module version vmware_host_vmhba_info and an active bug still in version 2.10.

@Jon-Rausch
Copy link
Author

Found that the node WWN information for SAS onboard controllers is in hex format already and fails on an attempted conversion with a typeerror. Edited the code below to attempt a conversion and to run the formatting (adding ":") if the conversion to hex fails due to a typeerror. The portWWN was never in hex from the FiberChannel controllers, so it didn't require this check. Still waiting on someone with more programming experience to fix and update this module, which has never returned any correct WWPN data since it was created.
updated code follows:

               try:
                    hba_info['node_wwn'] = self.format_number(hex(hba.nodeWorldWideName).lstrip("0x").rstrip("L"))
                except TypeError
                    hba_info['node_wwn'] = self.format_number(hba.nodeWorldWideName)
                except AttributeError:
                    pass
                try:
                    hba_info['port_wwn'] = self.format_number(hex(hba.portWorldWideName).lstrip("0x").rstrip("L"))
                except AttributeError:
                    pass

@Akasurde
Copy link
Member

@sky-joker Can you please help here since I don't have hardware for FC HBA? Thanks.

@sky-joker
Copy link
Contributor

sky-joker commented Jan 19, 2020

@Akasurde, The same phenomenon was reproduced in my lab environment.
I will try to check for a solution to this cause.

The following is the result of got node_wwn and port_wwn without using vmware_host_vmhba_info module.(using self-made script)

         (vim.host.FibreChannelHba) {
            dynamicType = <unset>,
            dynamicProperty = (vmodl.DynamicProperty) [],
            key = 'key-vim.host.FibreChannelHba-vmhba2',
            device = 'vmhba2',
            bus = 4,
            status = 'offline',
            model = 'ISP2532-based 8Gb Fibre Channel to PCI Express HBA',
            driver = 'qlnativefc',
            pci = '0000:04:00.0',
            portWorldWideName = 2377900762152798554,
            nodeWorldWideName = 2305843168114870618,
            portType = 'unknown',
            speed = 0
         },
         (vim.host.FibreChannelHba) {
            dynamicType = <unset>,
            dynamicProperty = (vmodl.DynamicProperty) [],
            key = 'key-vim.host.FibreChannelHba-vmhba3',
            device = 'vmhba3',
            bus = 4,
            status = 'offline',
            model = 'ISP2532-based 8Gb Fibre Channel to PCI Express HBA',
            driver = 'qlnativefc',
            pci = '0000:04:00.1',
            portWorldWideName = 2377900762152798555,
            nodeWorldWideName = 2305843168114870619,
            portType = 'unknown',
            speed = 0
         },

The following is the result of got node_wwn and port_wwn using vmware_host_vmhba_info module.

                    {
                        "adapter": "QLogic Corp ISP2532-based 8Gb Fibre Channel to PCI Express HBA",
                        "bus": 4,
                        "device": "vmhba2",
                        "driver": "qlnativefc",
                        "location": "0000:04:00.0",
                        "model": "ISP2532-based 8Gb Fibre Channel to PCI Express HBA",
                        "node_wwn": "23:05:84:31:68:11:48:70:61",
                        "port_type": "unknown",
                        "port_wwn": "23:77:90:07:62:15:27:98:55",
                        "speed": 0,
                        "status": "offline",
                        "type": "Fibre Channel"
                    },
                    {
                        "adapter": "QLogic Corp ISP2532-based 8Gb Fibre Channel to PCI Express HBA",
                        "bus": 4,
                        "device": "vmhba3",
                        "driver": "qlnativefc",
                        "location": "0000:04:00.1",
                        "model": "ISP2532-based 8Gb Fibre Channel to PCI Express HBA",
                        "node_wwn": "23:05:84:31:68:11:48:70:61",
                        "port_type": "unknown",
                        "port_wwn": "23:77:90:07:62:15:27:98:55",
                        "speed": 0,
                        "status": "offline",
                        "type": "Fibre Channel"
                    },

@Akasurde
Copy link
Member

@sky-joker Thanks for taking a look into this.

@Akasurde
Copy link
Member

resolved_by_pr #66692

@Akasurde
Copy link
Member

@Jon-Rausch, Could you please check PR #66692 and let us know if it works for you ?

Please check How to test a PR for more help.

Thanks.

needs_info

@ansibot ansibot added has_pr This issue has an associated PR. needs_info This issue requires further information. Please answer any outstanding questions. labels Jan 22, 2020
sky-joker added a commit to sky-joker/ansible that referenced this issue Jan 22, 2020
sky-joker added a commit to sky-joker/ansible that referenced this issue Jan 22, 2020
@cultcom
Copy link

cultcom commented Jan 23, 2020

This looks a lot better now.

@ansible ansible locked and limited conversation to collaborators Feb 25, 2020
ruozeng-w pushed a commit to ruozeng-w/ansible that referenced this issue Apr 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.8 This issue/PR affects Ansible v2.8 bug This issue/PR relates to a bug. cloud deprecated This issue/PR relates to a deprecated module. has_pr This issue has an associated PR. module This issue/PR relates to a module. needs_info This issue requires further information. Please answer any outstanding questions. support:community This issue/PR relates to code supported by the Ansible community. vmware VMware community
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants