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

ovirt_quota, cluster cpu limit won't cast string to int (unable to use variables) #40

Closed
SLoeuillet opened this issue May 11, 2020 · 0 comments · Fixed by #44
Closed

Comments

@SLoeuillet
Copy link

SUMMARY
Can't set cluster level quotas with ansible 2.9.7 and ovirtsdk 4.3.4 against RHV 4.3.9

ISSUE TYPE
Bug Report
COMPONENT NAME
ovirt_quota

ANSIBLE VERSION
'''
ansible 2.9.7
config file = None
configured module search path = ['/home/OAD/sloeuillet/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/OAD/sloeuillet/venv/lib/python3.6/site-packages/ansible
executable location = /home/OAD/sloeuillet/venv/bin/ansible
python version = 3.6.9 (default, Sep 11 2019, 16:40:19) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]
'''

CONFIGURATION
''''''

OS / ENVIRONMENT
'''RHEL 7.8 to RHV-M 4.3.9 (based on RHEL 7.8)
Python 3.6
Ansible 2.9.7
ovirt-sdk-python 4.4.3'''

STEPS TO REPRODUCE
'''- name: create quotas
ovirt_quota:
auth: "{{ ovirt_auth }}"
data_center: "{{ rhv_datacenter }}"
name: "{{ quota.key }}"
state: "{{ quota.value.state | default('present') }}"

clusters:

  • name: "{{ quota.value.cluster }}"
    memory: "{{ quota.value.mem | default(-1) }}"
    cpu: "{{ quota.value.cpu | int | default(-1) }}"
    with_dict: "{{ rhv_quota }}"
    loop_control:
    loop_var: quota
    '''

'''yaml
rhv_quota:
test_cpu_10pct:
cluster: PDCLQAT
cpu: 10
memory: 20.0
'''

EXPECTED RESULTS
Should set CPU limit for cluster to 10

ACTUAL RESULTS
As it is a quoted "{{var}}", it gives a string to the module, but ovirtsdk expects an INT.
As no explicit cast, it screams that it wants an integer value.

285 limit=otypes.QuotaClusterLimit(
286 memory_limit=float(cluster.get('memory')),
287 vcpu_limit=cluster.get('cpu'),

As you see, it casts the memory parameter into a float but it doesn't do any cast on cpu parameter
When running ansible, it gives that error :

''' File "/tmp/ansible_ovirt_quota_payload_XlaYEj/ansible_ovirt_quota_payload.zip/ansible/modules/cloud/ovirt/ovirt_quota.py", line 290, in main
File "/usr/lib64/python2.7/site-packages/ovirtsdk4/services.py", line 20025, in add
return self._internal_add(limit, headers, query, wait)
File "/usr/lib64/python2.7/site-packages/ovirtsdk4/service.py", line 222, in _internal_add
request.body = writer.Writer.write(object, indent=True)
File "/usr/lib64/python2.7/site-packages/ovirtsdk4/writer.py", line 189, in write
writer(obj, cursor, root)
File "/usr/lib64/python2.7/site-packages/ovirtsdk4/writers.py", line 7376, in write_one
Writer.write_integer(writer, 'vcpu_limit', obj.vcpu_limit)
File "/usr/lib64/python2.7/site-packages/ovirtsdk4/writer.py", line 77, in write_integer
return writer.write_element(name, Writer.render_integer(value))
File "/usr/lib64/python2.7/site-packages/ovirtsdk4/writer.py", line 69, in render_integer
raise TypeError('The 'value' parameter must be an integer')
TypeError: The 'value' parameter must be an integer
'''
In python bindings, this parameter uses Writer.write_decimal/Reader.read_decimal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant