vmware-archive / ansible-module-vcloud-director

ansible-module-vcloud-director
Other
111 stars 86 forks source link

Creating an Org Admin raises a pyvcloud error #208

Closed surfer190 closed 2 years ago

surfer190 commented 2 years ago

Describe the bug

When using vcd_user to create a user on api_version 34.0 a error is raised:

pyvcloud.vcd.exceptions.InternalServerException: Status code: 500/INTERNAL_SERVER_ERROR, [ 221bc474-62a0-4d5a-92f7-4861c7788cce ] UUID string too large (request id: 221bc474-62a0-4d5a-92f7-4861c7788cce)

When using api_version 36.0 this is the error:

TypeError: Value of unknown type: <class 'pyvcloud.vcd.exceptions.BadRequestException'>, Status code: 400/BAD_REQUEST, [ 82c08004-0d3f-49cc-80be-0fe40e7e41e3 ] HTTP 400 Bad Request
 - cvc-complex-type.2.4.a: Invalid content was found starting with element '{\"http://www.vmware.com/vcloud/v1.5\":IsAlertEnabled}'. One of '{\"http://www.vmware.com/vcloud/v1.5\":NameInSource, \"http://www.vmware.com/vcloud/v1.5\":IsExternal, \"http://www.vmware.com/vcloud/v1.5\":ProviderType, \"http://www.vmware.com/vcloud/v1.5\":IsGroupRole, \"http://www.vmware.com/vcloud/v1.5\":StoredVmQuota, \"http://www.vmware.com/vcloud/v1.5\":DeployedVmQuota, \"http://www.vmware.com/vcloud/v1.5\":Role, \"http://www.vmware.com/vcloud/v1.5\":Password, \"http://www.vmware.com/vcloud/v1.5\":GroupReferences}' is expected. (request id: 82c08004-0d3f-49cc-80be-0fe40e7e41e3)

Reproduction steps

1. Create a org

    - name: create org
      vcd_org:
        org_name: "{{ org_name }}"
        full_name: "{{ full_name }}"
        is_enabled: "true"
        state: "present"

2. Create a org admin user:

    - name: Create org admin
      vcd_user:
        org_name: "{{ org_name }}"
        username: "admin"
        userpassword: "{{ user_password }}"
        role_name: "Organization Administrator"
        full_username: "Administrator"
        description: "{{ full_name }} Administrator"
        email: "{{ user_email }}"
        is_enabled: "true"
        state: "present"
        is_external: "false"

3. Run the playbook
...

Expected behavior

Expect the org admin to be created correctly.

Additional context

VMware Cloud Director version: 10.3.2

Full Traceback on 36.0:

Traceback (most recent call last):
  File \"/tmp/ansible_vcd_user_payload_0m_jiiwj/ansible_vcd_user_payload.zip/ansible/modules/vcd_user.py\", line 301, in main
  File \"/tmp/ansible_vcd_user_payload_0m_jiiwj/ansible_vcd_user_payload.zip/ansible/modules/vcd_user.py\", line 202, in manage_states
  File \"/tmp/ansible_vcd_user_payload_0m_jiiwj/ansible_vcd_user_payload.zip/ansible/modules/vcd_user.py\", line 238, in create
  File \"/usr/local/lib/python3.8/site-packages/pyvcloud/vcd/org.py\", line 1129, in get_role_record
    role_record = self.list_roles(('name', role_name))
  File \"/usr/local/lib/python3.8/site-packages/pyvcloud/vcd/org.py\", line 1164, in list_roles
    for r in list(query.execute()):
  File \"/usr/local/lib/python3.8/site-packages/pyvcloud/vcd/client.py\", line 1837, in execute
    return self._iterator(self._client.get_resource(query_uri))
  File \"/usr/local/lib/python3.8/site-packages/pyvcloud/vcd/client.py\", line 1436, in get_resource
    return self._do_request(
  File \"/usr/local/lib/python3.8/site-packages/pyvcloud/vcd/client.py\", line 1167, in _do_request
    self._response_code_to_exception(
  File \"/usr/local/lib/python3.8/site-packages/pyvcloud/vcd/client.py\", line 1206, in _response_code_to_exception
    raise InternalServerException(sc, request_id, objectify_response)
pyvcloud.vcd.exceptions.InternalServerException: Status code: 500/INTERNAL_SERVER_ERROR, [ 221bc474-62a0-4d5a-92f7-4861c7788cce ] UUID string too large (request id: 221bc474-62a0-4d5a-92f7-4861c7788cce)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File \"/root/.ansible/tmp/ansible-tmp-1645522428.3598812-291-70156602024405/AnsiballZ_vcd_user.py\", line 100, in <module>
    _ansiballz_main()
  File \"/root/.ansible/tmp/ansible-tmp-1645522428.3598812-291-70156602024405/AnsiballZ_vcd_user.py\", line 92, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File \"/root/.ansible/tmp/ansible-tmp-1645522428.3598812-291-70156602024405/AnsiballZ_vcd_user.py\", line 40, in invoke_module
    runpy.run_module(mod_name='ansible.modules.vcd_user', init_globals=dict(_module_fqn='ansible.modules.vcd_user', _modlib_path=modlib_path),
  File \"/usr/lib64/python3.8/runpy.py\", line 207, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File \"/usr/lib64/python3.8/runpy.py\", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File \"/usr/lib64/python3.8/runpy.py\", line 87, in _run_code
    exec(code, run_globals)
  File \"/tmp/ansible_vcd_user_payload_0m_jiiwj/ansible_vcd_user_payload.zip/ansible/modules/vcd_user.py\", line 313, in <module>
  File \"/tmp/ansible_vcd_user_payload_0m_jiiwj/ansible_vcd_user_payload.zip/ansible/modules/vcd_user.py\", line 307, in main
  File \"/tmp/ansible_vcd_user_payload_0m_jiiwj/ansible_vcd_user_payload.zip/ansible/module_utils/basic.py\", line 1517, in fail_json
  File \"/tmp/ansible_vcd_user_payload_0m_jiiwj/ansible_vcd_user_payload.zip/ansible/module_utils/basic.py\", line 1490, in _return_formatted
  File \"/tmp/ansible_vcd_user_payload_0m_jiiwj/ansible_vcd_user_payload.zip/ansible/module_utils/common/parameters.py\", line 889, in remove_values
  File \"/tmp/ansible_vcd_user_payload_0m_jiiwj/ansible_vcd_user_payload.zip/ansible/module_utils/common/parameters.py\", line 461, in _remove_values_conditions
TypeError: Value of unknown type: <class 'pyvcloud.vcd.exceptions.InternalServerException'>, Status code: 500/INTERNAL_SERVER_ERROR, [ 221bc474-62a0-4d5a-92f7-4861c7788cce ] UUID string too large (request id: 221bc474-62a0-4d5a-92f7-4861c7788cce)

Full Traceback on 34.0:

Traceback (most recent call last):
  File \"/tmp/ansible_vcd_user_payload_edutudtj/ansible_vcd_user_payload.zip/ansible/modules/vcd_user.py\", line 242, in create
  File \"/usr/local/lib/python3.8/site-packages/pyvcloud/vcd/org.py\", line 1024, in get_user
    raise EntityNotFoundException(
pyvcloud.vcd.exceptions.EntityNotFoundException: User 'admin' does not exist.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File \"/tmp/ansible_vcd_user_payload_edutudtj/ansible_vcd_user_payload.zip/ansible/modules/vcd_user.py\", line 301, in main
  File \"/tmp/ansible_vcd_user_payload_edutudtj/ansible_vcd_user_payload.zip/ansible/modules/vcd_user.py\", line 202, in manage_states
  File \"/tmp/ansible_vcd_user_payload_edutudtj/ansible_vcd_user_payload.zip/ansible/modules/vcd_user.py\", line 244, in create
  File \"/usr/local/lib/python3.8/site-packages/pyvcloud/vcd/org.py\", line 980, in create_user
    return self.client.post_linked_resource(
  File \"/usr/local/lib/python3.8/site-packages/pyvcloud/vcd/client.py\", line 1424, in post_linked_resource
    return self.post_resource(
  File \"/usr/local/lib/python3.8/site-packages/pyvcloud/vcd/client.py\", line 1404, in post_resource
    return self._do_request(
  File \"/usr/local/lib/python3.8/site-packages/pyvcloud/vcd/client.py\", line 1167, in _do_request
    self._response_code_to_exception(
  File \"/usr/local/lib/python3.8/site-packages/pyvcloud/vcd/client.py\", line 1174, in _response_code_to_exception
    raise BadRequestException(sc, request_id, objectify_response)
pyvcloud.vcd.exceptions.BadRequestException: Status code: 400/BAD_REQUEST, [ 82c08004-0d3f-49cc-80be-0fe40e7e41e3 ] HTTP 400 Bad Request
 - cvc-complex-type.2.4.a: Invalid content was found starting with element '{\"http://www.vmware.com/vcloud/v1.5\":IsAlertEnabled}'. One of '{\"http://www.vmware.com/vcloud/v1.5\":NameInSource, \"http://www.vmware.com/vcloud/v1.5\":IsExternal, \"http://www.vmware.com/vcloud/v1.5\":ProviderType, \"http://www.vmware.com/vcloud/v1.5\":IsGroupRole, \"http://www.vmware.com/vcloud/v1.5\":StoredVmQuota, \"http://www.vmware.com/vcloud/v1.5\":DeployedVmQuota, \"http://www.vmware.com/vcloud/v1.5\":Role, \"http://www.vmware.com/vcloud/v1.5\":Password, \"http://www.vmware.com/vcloud/v1.5\":GroupReferences}' is expected. (request id: 82c08004-0d3f-49cc-80be-0fe40e7e41e3)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File \"/root/.ansible/tmp/ansible-tmp-1645520906.0328522-285-14826360671800/AnsiballZ_vcd_user.py\", line 100, in <module>
    _ansiballz_main()
  File \"/root/.ansible/tmp/ansible-tmp-1645520906.0328522-285-14826360671800/AnsiballZ_vcd_user.py\", line 92, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File \"/root/.ansible/tmp/ansible-tmp-1645520906.0328522-285-14826360671800/AnsiballZ_vcd_user.py\", line 40, in invoke_module
    runpy.run_module(mod_name='ansible.modules.vcd_user', init_globals=dict(_module_fqn='ansible.modules.vcd_user', _modlib_path=modlib_path),
  File \"/usr/lib64/python3.8/runpy.py\", line 207, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File \"/usr/lib64/python3.8/runpy.py\", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File \"/usr/lib64/python3.8/runpy.py\", line 87, in _run_code
    exec(code, run_globals)
  File \"/tmp/ansible_vcd_user_payload_edutudtj/ansible_vcd_user_payload.zip/ansible/modules/vcd_user.py\", line 313, in <module>
  File \"/tmp/ansible_vcd_user_payload_edutudtj/ansible_vcd_user_payload.zip/ansible/modules/vcd_user.py\", line 307, in main
  File \"/tmp/ansible_vcd_user_payload_edutudtj/ansible_vcd_user_payload.zip/ansible/module_utils/basic.py\", line 1517, in fail_json
  File \"/tmp/ansible_vcd_user_payload_edutudtj/ansible_vcd_user_payload.zip/ansible/module_utils/basic.py\", line 1490, in _return_formatted
  File \"/tmp/ansible_vcd_user_payload_edutudtj/ansible_vcd_user_payload.zip/ansible/module_utils/common/parameters.py\", line 889, in remove_values
  File \"/tmp/ansible_vcd_user_payload_edutudtj/ansible_vcd_user_payload.zip/ansible/module_utils/common/parameters.py\", line 461, in _remove_values_conditions
TypeError: Value of unknown type: <class 'pyvcloud.vcd.exceptions.BadRequestException'>, Status code: 400/BAD_REQUEST, [ 82c08004-0d3f-49cc-80be-0fe40e7e41e3 ] HTTP 400 Bad Request
 - cvc-complex-type.2.4.a: Invalid content was found starting with element '{\"http://www.vmware.com/vcloud/v1.5\":IsAlertEnabled}'. One of '{\"http://www.vmware.com/vcloud/v1.5\":NameInSource, \"http://www.vmware.com/vcloud/v1.5\":IsExternal, \"http://www.vmware.com/vcloud/v1.5\":ProviderType, \"http://www.vmware.com/vcloud/v1.5\":IsGroupRole, \"http://www.vmware.com/vcloud/v1.5\":StoredVmQuota, \"http://www.vmware.com/vcloud/v1.5\":DeployedVmQuota, \"http://www.vmware.com/vcloud/v1.5\":Role, \"http://www.vmware.com/vcloud/v1.5\":Password, \"http://www.vmware.com/vcloud/v1.5\":GroupReferences}' is expected. (request id: 82c08004-0d3f-49cc-80be-0fe40e7e41e3)
surfer190 commented 2 years ago

I did not include the pyvcloud version I was using:

It was 21.1.0 and after moving to pyvcloud==23.0.3 it was no longer an issue.