Skip to content

Commit

Permalink
Fix improper handling of machine_type in ovirt inventory (ansible#16251)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nijinashok authored and mscherer committed Oct 23, 2016
1 parent 77868a4 commit 1f3d82d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion contrib/inventory/ovirt.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def node_to_dict(self, inst):
'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(),
Expand All @@ -230,6 +230,11 @@ def get_tags(inst):
"""
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 """
Expand Down

0 comments on commit 1f3d82d

Please sign in to comment.