Ovirt vms improve (#20882)

* cloud: ovirt: add function to get id by name

* cloud: ovirt: add instance type parameter

* cloud: ovirt: use param method instead of module.params

* cloud: ovirt: use 'and' at begging of next line

* cloud: ovirt: add description parameter to vms module

* cloud: ovirt: add comment parameter to vms module

* cloud: ovirt: add timezone parameter to vms module

* cloud: ovirt: add serial_policy parameter to vms module
This commit is contained in:
Ondra Machacek 2017-02-02 19:51:26 +01:00 committed by Ryan Brown
parent ee7f1cde0e
commit 4269b12c9d
3 changed files with 143 additions and 48 deletions

View file

@ -190,7 +190,7 @@ def get_link_name(connection, link):
return None
def equal(param1, param2):
def equal(param1, param2, ignore_case=False):
"""
Compare two parameters and return if they are equal.
This parameter doesn't run equal operation if first parameter is None.
@ -202,6 +202,8 @@ def equal(param1, param2):
:return: True if parameters are equal or first parameter is None, otherwise False
"""
if param1 is not None:
if ignore_case:
return param1.lower() == param2.lower()
return param1 == param2
return True
@ -271,6 +273,19 @@ def get_entity(service):
return entity
def get_id_by_name(service, name, raise_error=True, ignore_case=False):
"""
Search an entity ID by it's name.
"""
entity = search_by_name(service, name)
if entity is not None:
return entity.id
if raise_error:
raise Exception("Entity '%s' was not found." % name)
def wait(
service,
condition,