ansible-collections / community.vmware

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

Number of virtual devices exceeds the maximum for a given controller while changing adapter settings for a VM #283

Open Akasurde opened 4 years ago

Akasurde commented 4 years ago

From @srivaa31 on Jul 08, 2020 11:40

SUMMARY

pyVmomi.VmomiSupport.TooManyDevices exception while configuring four adapter settings on the target VM

ISSUE TYPE
COMPONENT NAME

vmware_guest_network

ANSIBLE VERSION
ansible 2.9.4
  config file = /var/lib/jenkins/workspace/Ansible_QA/Automation/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.6/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.6.8 (default, Nov 21 2019, 19:31:34) [GCC 8.3.1 20190507 (Red Hat 8.3.1-4)]
CONFIGURATION
DEFAULT_PRIVATE_KEY_FILE(/var/lib/jenkins/workspace/Ansible_QA/Automation/ansible.cfg) = /root/.ssh/id_rsa
DEFAULT_REMOTE_USER(/var/lib/jenkins/workspace/Ansible_QA/Automation/ansible.cfg) = root
DISPLAY_SKIPPED_HOSTS(/var/lib/jenkins/workspace/Ansible_QA/Automation/ansible.cfg) = False
HOST_KEY_CHECKING(/var/lib/jenkins/workspace/Ansible_QA/Automation/ansible.cfg) = False
INTERPRETER_PYTHON(/var/lib/jenkins/workspace/Ansible_QA/Automation/ansible.cfg) = auto
OS / ENVIRONMENT

esxi: 6.7 OS: CentOS Linux release 8.1.1911 (Core)

STEPS TO REPRODUCE
- name: Changing network adapter for enabling data IP interface viz. vlan151 vlan152, vlan153, vlan154 respectively
  vmware_guest_network:
    datacenter: "{{ source_datacenter_name}}"
    hostname: "{{ vmware_server }}"
    username: "{{ vmware_user  }}"
    password: "{{ vmware_pass }}"
    folder: /
    cluster: "{{ cluster_name }}"
    validate_certs: no
    name: test_automation_vm3
    networks:
      - name: "VLAN_152_Data1"
        device_type: vmxnet3
        label: "Network adapter 2"
        connected: True
        state: new
      - name: "VLAN_160_Data2"
        device_type: vmxnet3
        label: "Network adapter 3"
        state: new
        connected: True
      - name: "VLAN_152_Data3"
        device_type: vmxnet3
        label: "Network adapter 4"
        state: new
        connected: True
      - name: "VLAN_160_Data4"
        device_type: vmxnet3
        label: "Network adapter 5"
        state: new
        connected: True
  delegate_to: localhost
  register: netwrok_info
EXPECTED RESULTS

Expected to attach the correct adapters from the VLAN port group on the VM

ACTUAL RESULTS
TASK [io_test : Changing network adapter for enabling data IP interface viz. vlan151 vlan152, vlan153, vlan154 respectively] ***************************************************
fatal: [127.0.0.1 -> localhost]: FAILED! => {"changed": false, "module_stderr": "pyVmomi.VmomiSupport.TooManyDevices: (vim.fault.TooManyDevices) {\n   dynamicType = <unset>,\n   dynamicProperty = (vmodl.DynamicProperty) [],\n   msg = 'Number of virtual devices exceeds the maximum for a given controller.',\n   faultCause = <unset>,\n   faultMessage = (vmodl.LocalizableMessage) [],\n   property = <unset>\n}\n\nThe above exception was the direct cause of the following exception:\n\nTraceback (most recent call last):\n  File \"/root/.ansible/tmp/ansible-tmp-1594207975.0291607-81343907565645/AnsiballZ_vmware_guest_network.py\", line 102, in <module>\n    _ansiballz_main()\n  File \"/root/.ansible/tmp/ansible-tmp-1594207975.0291607-81343907565645/AnsiballZ_vmware_guest_network.py\", line 94, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/root/.ansible/tmp/ansible-tmp-1594207975.0291607-81343907565645/AnsiballZ_vmware_guest_network.py\", line 40, in invoke_module\n    runpy.run_module(mod_name='ansible.modules.cloud.vmware.vmware_guest_network', init_globals=None, run_name='__main__', alter_sys=True)\n  File \"/usr/lib64/python3.6/runpy.py\", line 205, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/lib64/python3.6/runpy.py\", line 96, in _run_module_code\n    mod_name, mod_spec, pkg_name, script_name)\n  File \"/usr/lib64/python3.6/runpy.py\", line 85, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_vmware_guest_network_payload_3fagnfrv/ansible_vmware_guest_network_payload.zip/ansible/modules/cloud/vmware/vmware_guest_network.py\", line 486, in <module>\n  File \"/tmp/ansible_vmware_guest_network_payload_3fagnfrv/ansible_vmware_guest_network_payload.zip/ansible/modules/cloud/vmware/vmware_guest_network.py\", line 478, in main\n  File \"/tmp/ansible_vmware_guest_network_payload_3fagnfrv/ansible_vmware_guest_network_payload.zip/ansible/modules/cloud/vmware/vmware_guest_network.py\", line 434, in reconfigure_vm_network\n  File \"/tmp/ansible_vmware_guest_network_payload_3fagnfrv/ansible_vmware_guest_network_payload.zip/ansible/module_utils/vmware.py\", line 82, in wait_for_task\n  File \"<string>\", line 3, in raise_from\nansible.module_utils.vmware.TaskError: ('Number of virtual devices exceeds the maximum for a given controller.', None)\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

Copied from original issue: ansible/ansible#70520

srivaa31 commented 4 years ago

The OVF through which these test vms are being cloned already has 10 network adapters. Before proceeding to re-test , I deleted 5 unused adapters namely (Network adapter 6 to Network adapter 10) in vsphere

With above change , I am able to see that vmware_guest_network module is being run without previous exception message.

The problem now is that it creates two more interface namely Network adapter 6 and Network adapter 7 in disconnected state and adapters 2 through 5 are acquiring some "name" :"DVSwitch: 50 1d e1 31 38 0b 5e f2-ae 19 27 ba 65 88 34 ec" inspite of that fact this was passed in script as "VLAN_152_Data1"

ok: [127.0.0.1] => {
    "network_info": {
        "changed": true,
        "failed": false,
        "network_data": {
            "0": {
                "allow_guest_ctl": true,
                "connected": true,
                "device_type": "VMXNET3",
                "label": "Network adapter 1",
                "mac_addr": "00:50:56:9d:74:a1",
                "name": "DVSwitch: 50 1d e1 31 38 0b 5e f2-ae 19 27 ba 65 88 34 ec",
                "start_connected": true,
                "unit_number": 7,
                "wake_onlan": true
            },
            "1": {
                "allow_guest_ctl": true,
                "connected": true,
                "device_type": "VMXNET3",
                "label": "Network adapter 2",
                "mac_addr": "00:50:56:9d:1c:32",
                "name": "DVSwitch: 50 1d f9 96 a3 b3 43 db-ab 78 b1 53 5b 4c 59 5d",
                "start_connected": true,
                "unit_number": 8,
                "wake_onlan": true
            },
            "2": {
                "allow_guest_ctl": true,
                "connected": true,
                "device_type": "VMXNET3",
                "label": "Network adapter 3",
                "mac_addr": "00:50:56:9d:da:22",
                "name": "DVSwitch: 50 1d f9 96 a3 b3 43 db-ab 78 b1 53 5b 4c 59 5d",
                "start_connected": true,
                "unit_number": 9,
                "wake_onlan": true
            },
            "3": {
                "allow_guest_ctl": true,
                "connected": true,
                "device_type": "VMXNET3",
                "label": "Network adapter 4",
                "mac_addr": "00:50:56:9d:c4:1e",
                "name": "DVSwitch: 50 1d f9 96 a3 b3 43 db-ab 78 b1 53 5b 4c 59 5d",
                "start_connected": true,
                "unit_number": 10,
                "wake_onlan": true
            },
            "4": {
                "allow_guest_ctl": true,
                "connected": true,
                "device_type": "VMXNET3",
                "label": "Network adapter 5",
                "mac_addr": "00:50:56:9d:91:e3",
                "name": "DVSwitch: 50 1d f9 96 a3 b3 43 db-ab 78 b1 53 5b 4c 59 5d",
                "start_connected": true,
                "unit_number": 11,
                "wake_onlan": true
            },
            "5": {
                "allow_guest_ctl": true,
                "connected": false,
                "device_type": "VMXNET3",
                "label": "Network adapter 6",
                "mac_addr": "00:50:56:9d:af:5c",
                "name": "VLAN_152_Data1",
                "start_connected": true,
                "unit_number": 12,
                "wake_onlan": true
            },
            "6": {
                "allow_guest_ctl": true,
                "connected": false,
                "device_type": "VMXNET3",
                "label": "Network adapter 7",
                "mac_addr": "00:50:56:9d:ce:3f",
                "name": "VLAN_160_Data2",
                "start_connected": true,
                "unit_number": 13,
                "wake_onlan": true
            }
        }
    }
}
srivaa31 commented 4 years ago

I have figured out workaround through a powershell script which does the adapter settings for VM network interface temporarily. However ,I expected ansible to work seamlessly in the given scenario.

ansibullbot commented 4 years ago

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