mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-23 10:51:24 -07:00
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:
parent
ee7f1cde0e
commit
4269b12c9d
3 changed files with 143 additions and 48 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue