ansible-collections / community.vmware

Ansible Collection for VMware
GNU General Public License v3.0
349 stars 336 forks source link

vmware_guest_network parsing problem with `|` in network names #657

Open grazioli-nc opened 3 years ago

grazioli-nc commented 3 years ago
SUMMARY

Network names with | inside will be parsed incorrectly with vmware_guest_network and pyvmomi 7.0.1. \ The network name A|B|C for example will be parsed to A|7CB|7CC (seen in the *.vmx file of the vm under ethernet0.networkName). \ The described behavior does not occur with pyvmomi 7.0.

ISSUE TYPE
COMPONENT NAME

vmware_guest_network

ANSIBLE VERSION
ansible 2.9.5
  config file = None
  configured module search path = [u'/home/%username%/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python2.7/dist-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 2.7.17 (default, Nov  7 2019, 10:07:09) [GCC 7.4.0]
CONFIGURATION
OS / ENVIRONMENT
STEPS TO REPRODUCE

Try to add a network with a | inside the name like bellow.

---
- name: vmware_guest_network test
  hosts: localhost
  gather_facts: no
  tasks:
    - name: set network
      vmware_guest_network:
        hostname: hostname
        username: username
        password: password
        validate_certs: no
        name: vm-name
        networks:
          - name: A|B|C
            state: new
            device_type: vmxnet3
            connected: yes
            start_connected: yes
      delegate_to: localhost
EXPECTED RESULTS

The *.vmx shows the correct configuration.

ethernet0.virtualDev = "vmxnet3"
ethernet0.dvs.switchId = "10 0e 0e 67 de ce 68 64-5b 7c 4e 5f 1f 09 10 90"
ethernet0.dvs.portId = "1686"
ethernet0.dvs.portgroupId = "dvportgroup-2924"
ethernet0.dvs.connectionId = "1876388225"
ethernet0.addressType = "vpx"
ethernet0.generatedAddress = "00:20:56:8a:10:c9"
ethernet0.uptCompatibility = "TRUE"
ethernet0.present = "TRUE"
ACTUAL RESULTS

The | in the name will be parsed incorrectly and the *.vmx shows the following output.

ethernet0.virtualDev = "vmxnet3"
ethernet0.networkName = "A|7CB|7CC"
ethernet0.addressType = "vpx"
ethernet0.generatedAddress = "00:20:56:8a:10:c9"
ethernet0.uptCompatibility = "TRUE"
ethernet0.present = "TRUE"
ansibullbot commented 3 years ago

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

ansibullbot commented 3 years ago

cc @Akasurde @Tomorrow9 @goneri @lparkes @pgbidkar @warthog9 click here for bot help

sky-joker commented 3 years ago

Thank you @grazioli-nc for reporting this issue.
I confirmed that manual operation also occurs the same issue on VCSA 6.7/7.0.

ethernet0.networkName = "A|7CB|7CC"

So, I think that the issue is for VCSA, not the module.
Unfortunately, I didn't understand why the pyvmomi 7.0.0 run correctly.
(The pyvmomi 7.0.0 also occurred the same issue in my environment)

sky-joker commented 3 years ago

By the way, a port group in vSwitch is given preference if the same port group name exists in vSwitch and vDS.