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

[Bug] Error when updating size_gb using the int filter in module ntnx_vms #400

Closed
arnofear opened this issue Sep 25, 2023 · 2 comments
Closed
Assignees
Labels
1.9.1 Bug fixes & Improvements bug Something isn't working

Comments

@arnofear
Copy link

Describe the bug
When updating the 'size_gb' value of a VM disk using the int filter, the Playbook fail.
However, if we update the value of another attribute like 'memory_gb' (also of integer type), it works !

To Reproduce
Steps to reproduce the behavior:

  1. ansible-playbook vm-update-disk.yml

  2. Playbook vm-update-disk.yml:

---
- name: Update VM
  hosts: localhost
  gather_facts: false
  collections:
    - nutanix.ncp
  vars:
    default_disk_size_gb: 100

  module_defaults:
    group/nutanix.ncp.ntnx:
      nutanix_host: '1.2.3.4'
      nutanix_username: 'my_username'
      nutanix_password: 'my_password'
      validate_certs: false

  tasks:
  - debug:
      msg: "default_disk_size_gb={{ default_disk_size_gb }} type_debug={{ default_disk_size_gb | type_debug }}"

  - name: Set my_disk_size_gb
    set_fact:
      my_disk_size_gb: "{{ default_disk_size_gb + 100 }}"

  - debug:
      msg: "my_disk_size_gb={{ my_disk_size_gb }} type_debug={{ my_disk_size_gb | type_debug }}"

  - debug:
      msg: "my_disk_size_gb={{ my_disk_size_gb }} type_debug + int_filter={{ my_disk_size_gb | int | type_debug }}"

  - name: Update VM disk size
    nutanix.ncp.ntnx_vms:
      vm_uuid: 910745e1-a417-4e07-8094-618fbf3783a3
      disks:
        - type: "DISK"
          uuid: 6ef7edde-e951-4e8b-8e64-470a4d913c09
          size_gb: "{{ my_disk_size_gb | int }}"

Stack trace

PLAY [Update VM] ***************************************************************************************************************************************************************************************************************************

TASK [debug] *******************************************************************************************************************************************************************************************************************************
ok: [localhost] => 
  msg: default_disk_size_gb=100 type_debug=int

TASK [Set my_disk_size_gb] *****************************************************************************************************************************************************************************************************************
ok: [localhost]

TASK [debug] *******************************************************************************************************************************************************************************************************************************
ok: [localhost] => 
  msg: my_disk_size_gb=200 type_debug=str

TASK [debug] *******************************************************************************************************************************************************************************************************************************
ok: [localhost] => 
  msg: my_disk_size_gb=200 type_debug + int_filter=int

TASK [Update VM disk size] *****************************************************************************************************************************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: TypeError: '>=' not supported between instances of 'str' and 'int'
fatal: [localhost]: FAILED! => changed=false 
  module_stderr: |-
    Traceback (most recent call last):
      File "/home/my-user/.ansible/tmp/ansible-tmp-1695631123.1564648-281844-166705858546536/AnsiballZ_ntnx_vms.py", line 107, in <module>
        _ansiballz_main()
      File "/home/my-user/.ansible/tmp/ansible-tmp-1695631123.1564648-281844-166705858546536/AnsiballZ_ntnx_vms.py", line 99, in _ansiballz_main
        invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
      File "/home/my-user/.ansible/tmp/ansible-tmp-1695631123.1564648-281844-166705858546536/AnsiballZ_ntnx_vms.py", line 47, in invoke_module
        runpy.run_module(mod_name='ansible_collections.nutanix.ncp.plugins.modules.ntnx_vms', init_globals=dict(_module_fqn='ansible_collections.nutanix.ncp.plugins.modules.ntnx_vms', _modlib_path=modlib_path),
      File "<frozen runpy>", line 226, in run_module
      File "<frozen runpy>", line 98, in _run_module_code
      File "<frozen runpy>", line 88, in _run_code
      File "/tmp/ansible_nutanix.ncp.ntnx_vms_payload___pe35ll/ansible_nutanix.ncp.ntnx_vms_payload.zip/ansible_collections/nutanix/ncp/plugins/modules/ntnx_vms.py", line 1003, in <module>
      File "/tmp/ansible_nutanix.ncp.ntnx_vms_payload___pe35ll/ansible_nutanix.ncp.ntnx_vms_payload.zip/ansible_collections/nutanix/ncp/plugins/modules/ntnx_vms.py", line 999, in main
      File "/tmp/ansible_nutanix.ncp.ntnx_vms_payload___pe35ll/ansible_nutanix.ncp.ntnx_vms_payload.zip/ansible_collections/nutanix/ncp/plugins/modules/ntnx_vms.py", line 991, in run_module
      File "/tmp/ansible_nutanix.ncp.ntnx_vms_payload___pe35ll/ansible_nutanix.ncp.ntnx_vms_payload.zip/ansible_collections/nutanix/ncp/plugins/modules/ntnx_vms.py", line 862, in update_vm
      File "/tmp/ansible_nutanix.ncp.ntnx_vms_payload___pe35ll/ansible_nutanix.ncp.ntnx_vms_payload.zip/ansible_collections/nutanix/ncp/plugins/module_utils/entity.py", line 226, in get_spec
      File "/tmp/ansible_nutanix.ncp.ntnx_vms_payload___pe35ll/ansible_nutanix.ncp.ntnx_vms_payload.zip/ansible_collections/nutanix/ncp/plugins/module_utils/prism/vms.py", line 335, in _build_spec_disks
      File "/tmp/ansible_nutanix.ncp.ntnx_vms_payload___pe35ll/ansible_nutanix.ncp.ntnx_vms_payload.zip/ansible_collections/nutanix/ncp/plugins/module_utils/prism/vms.py", line 496, in _update_disk
      File "/tmp/ansible_nutanix.ncp.ntnx_vms_payload___pe35ll/ansible_nutanix.ncp.ntnx_vms_payload.zip/ansible_collections/nutanix/ncp/plugins/module_utils/prism/vms.py", line 431, in _generate_disk_spec
    TypeError: '>=' not supported between instances of 'str' and 'int'
  module_stdout: ''
  msg: |-
    MODULE FAILURE
    See stdout/stderr for the exact error
  rc: 1

PLAY RECAP *********************************************************************************************************************************************************************************************************************************
localhost                  : ok=4    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

Expected behavior
Success playbook when updating the 'size_gb' value of a VM disk using the int filter.

Additional context

Nutanix Version pc.2022.6.0.5
NCC Version: 4.6.3.1
LCM Version: 2.6.2

Debian 12
pipx installation
ansible community version 8.4.0
ansible-core 2.15.4

collection nutanix.ncp version 1.8.0 (tested with version 1.9.0 too)

ansible-doc nutanix.ncp.ntnx_vms

...
- disks
...
        - size_gb
            The Disk Size in GB.
            This option is applicable for only DISK type above.
            default: null
            type: int
...
- memory_gb
        Memory size in GB
        default: null
        type: int

Thanks

@arnofear arnofear added the bug Something isn't working label Sep 25, 2023
@bhati-pradeep bhati-pradeep added the 1.9.1 Bug fixes & Improvements label Sep 26, 2023
@bhati-pradeep
Copy link
Collaborator

@Gevorg-Khachatryan-97 Please check this

Gevorg-Khachatryan-97 pushed a commit that referenced this issue Sep 26, 2023
Gevorg-Khachatryan-97 pushed a commit that referenced this issue Sep 28, 2023
bhati-pradeep pushed a commit that referenced this issue Oct 30, 2023
* fix issue #400

* fix issue #400

---------

Co-authored-by: Gevorg-Khachatryaan <Gevorg1050.1>
premkarat pushed a commit that referenced this issue Nov 9, 2023
* example fix (#420)

Co-authored-by: Gevorg-Khachatryaan <Gevorg1050.1>

* Add cluster URL to response only when there is cluster creation (#402)

* Create cluster url when it is required

* Minor fix

* fiql string in filtering (#423)

* fiql string in filtering

* fix

* Add Tests

* example for filter string

---------

Co-authored-by: Gevorg-Khachatryaan <Gevorg1050.1>
Co-authored-by: Alaa Bishtawi <[email protected]>

* Bug/issue#383 (#411)

* Fix Jekyll Build

* fix

* Fix #391 and #418 (#419)

* Create cluster url when it is required

* Minor fix

* Change api url for fetching time machine using name to get complete info same as uuid

* Add attribute in clone modules in ndb for creation or refresh using latestSnapshot

* Minor typo fix

* Minor typo fix

* functionality to update owner of vms (#412)

* functionality to update owner of vm

* sanity fix

* add test

---------

Co-authored-by: Gevorg-Khachatryaan <Gevorg1050.1>
Co-authored-by: Alaa Bishtawi <[email protected]>

* example for vms inventory (#410)

Co-authored-by: Gevorg-Khachatryaan <Gevorg1050.1>

* fix for custom filter and examples (#417)

* fix for custom filter and examples

* black fix

* sanity fix

* Add test

---------

Co-authored-by: Gevorg-Khachatryaan <Gevorg1050.1>
Co-authored-by: Alaa Bishtawi <[email protected]>

* example for vms inventory  (#426)

* example for vms inventory

* ansible cfg

* Move cfg to inventory example folder

* Minor name changes

* Minor fix

---------

Co-authored-by: Gevorg-Khachatryaan <Gevorg1050.1>
Co-authored-by: Pradeepsingh Bhati <[email protected]>

* Add support for PC Categories (#405)

Co-authored-by: Gianluca Salvo <[email protected]>

* Bug/issue#400 (#403)

* fix issue #400

* fix issue #400

---------

Co-authored-by: Gevorg-Khachatryaan <Gevorg1050.1>

* example for VMs with guest customization file which injects variables from the playbook (#396)

Co-authored-by: Gevorg-Khachatryaan <Gevorg1050.1>

* Fix: Syntax Errors in Create App Security Rule Ex (#394)

* functionality to handle issue when size of new disk is absent (#393)

Co-authored-by: Gevorg-Khachatryaan <Gevorg1050.1>

* example fix (#392)

Co-authored-by: Gevorg-Khachatryaan <Gevorg1050.1>

* sanity fix

* fix for issue#360 (#408)

* fix for issue#360

* fix

---------

Co-authored-by: Gevorg-Khachatryaan <Gevorg1050.1>

* improve clone examples (#407)

* imporve clone examples

* Fix Examples

* sanity fix

* disbale tests

* Enhance Acp Tests

* fix disks issue when size gb is not given for clone image disks

* Set release version 1.9.1

* enable image tests

* enable foundation sanity test

* Minor foundation test fix

* Enable pc tests

* Enable karbon and foundation sanity

* disables tests

* enables tests

* enable pc tests

* add tests for clones with latest snapshot. And enable clones and NDB database sanity tests

* skip protection rules tests

* Add random naming for acp test with user reference

* Bug/191 fix database sanity test (#430)

* Revert "Bug/issue#383 (#411)"

This reverts commit d1a0016.

* Fix Properties map

* Skip jelkyll check on database sanity test build issue

---------

Co-authored-by: Pradeepsingh Bhati <[email protected]>

* fix ntnx_database_sanity

* Add Contributaiong (#431)

* Add Contributaiong

* enhance contributaion

* fix readme

* Add comments to sample var files for simplicity

* Minor typo

---------

Co-authored-by: Pradeepsingh Bhati <[email protected]>

* Release Notes and changelog changes

* Minor typo fix

* remove unrequired file

* Minor release bug list change due to non cherry picks

---------

Co-authored-by: Gevorg Khachatryan <[email protected]>
Co-authored-by: Alaa Bishtawi <[email protected]>
Co-authored-by: Gianluca Salvo <[email protected]>
Co-authored-by: Gianluca Salvo <[email protected]>
Co-authored-by: Nathaniel Roberts <[email protected]>
@bhati-pradeep
Copy link
Collaborator

Fixed in release v1.9.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.9.1 Bug fixes & Improvements bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants