diff options
author | Nijin Ashok <nashok@redhat.com> | 2016-10-23 05:44:09 +0530 |
---|---|---|
committer | Michael Scherer <misc@zarb.org> | 2016-10-23 02:15:22 +0200 |
commit | e97a00de9ef4c323f664415e6f7b95ff46e176ea (patch) | |
tree | 205865b0e3f8ff0e637363631e0b1a2081dde386 /contrib | |
parent | f5240d29539ca7a4d88a3475ecad9d049eeafe69 (diff) | |
download | ansible-e97a00de9ef4c323f664415e6f7b95ff46e176ea.tar.gz |
Fix improper handling of machine_type in ovirt inventory (#16251)
Currently the machine_type will not work if the instance type is set in ovirt. In that case, inst.get_instance_type will be an object and will fails while converting to json. This only work if the instance type is not set in ovirt where inst.get_instance_type is a Null value. The current change make sure that correct "instance type" is passed when instance is set in ovirt and Null when it's not set in ovirt.
(cherry picked from commit 1f3d82dd1809a1d4ba430786a75dccc6b3736ca6)
Diffstat (limited to 'contrib')
-rwxr-xr-x | contrib/inventory/ovirt.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/contrib/inventory/ovirt.py b/contrib/inventory/ovirt.py index f406704ed6..7f505d9826 100755 --- a/contrib/inventory/ovirt.py +++ b/contrib/inventory/ovirt.py @@ -211,7 +211,7 @@ class OVirtInventory(object): 'ovirt_uuid': inst.get_id(), 'ovirt_id': inst.get_id(), 'ovirt_image': inst.get_os().get_type(), - 'ovirt_machine_type': inst.get_instance_type(), + 'ovirt_machine_type': self.get_machine_type(inst), 'ovirt_ips': ips, 'ovirt_name': inst.get_name(), 'ovirt_description': inst.get_description(), @@ -230,6 +230,11 @@ class OVirtInventory(object): """ return [x.get_name() for x in inst.get_tags().list()] + def get_machine_type(self,inst): + inst_type = inst.get_instance_type() + if inst_type: + return self.driver.instancetypes.get(id=inst_type.id).name + # noinspection PyBroadException,PyUnusedLocal def get_instance(self, instance_name): """Gets details about a specific instance """ |