oVirt / ovirt-ansible-collection

Ansible collection with official oVirt modules and roles
72 stars 90 forks source link

ovirt_quota : can't set cluster level quotas because it can't decide if global or cluster quotas #41

Open SLoeuillet opened 4 years ago

SLoeuillet commented 4 years ago

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

mnecas commented 4 years ago

Hi @SLoeuillet, thank you for the issue! The #40 is easy fix and have prepared patch. But this issue looks like API issue, have already pinged proper engineers. Will inform you on the progress.

mnecas commented 4 years ago

created follow up issue on Bugzilla https://bugzilla.redhat.com/show_bug.cgi?id=1834771