mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 03:41:25 -07:00
Fix a bug that caused exception on XenServer 7.1 with Cummulative Update (#52303)
- xenserver module_util: fixed a bug in gather_vm_params function where an exception was generated if XenServer product_version_text_short parameter contained non numeric characters, e.g. "7.1 CU1" on XenServer version 7.1 with Cummulative Update 1. Code was changed to use product_version parameter instead which is all numeric. - xenserver module_util: get_xenserver_version function is changed to return a list of integers for major, minor and update version instead of list of strings. - xenserver module_util: unit tests are updated according to changes. - xenserver module_util: removed unused imports.
This commit is contained in:
parent
409345ee97
commit
922af44d7d
3 changed files with 13 additions and 9 deletions
|
@ -17,9 +17,6 @@ try:
|
|||
except ImportError:
|
||||
pass
|
||||
|
||||
from ansible.module_utils._text import to_text
|
||||
from ansible.module_utils.urls import fetch_url
|
||||
from ansible.module_utils.six import integer_types, iteritems, string_types
|
||||
from ansible.module_utils.basic import env_fallback
|
||||
from ansible.module_utils.ansible_release import __version__ as ANSIBLE_VERSION
|
||||
|
||||
|
@ -408,7 +405,7 @@ def gather_vm_params(module, vm_ref):
|
|||
# Detect customization agent.
|
||||
xenserver_version = get_xenserver_version(module)
|
||||
|
||||
if (int(xenserver_version[0]) >= 7 and int(xenserver_version[1]) >= 0 and vm_params.get('guest_metrics') and
|
||||
if (xenserver_version[0] >= 7 and xenserver_version[1] >= 0 and vm_params.get('guest_metrics') and
|
||||
"feature-static-ip-setting" in vm_params['guest_metrics']['other']):
|
||||
vm_params['customization_agent'] = "native"
|
||||
else:
|
||||
|
@ -756,12 +753,19 @@ def get_xenserver_version(module):
|
|||
module: Reference to Ansible module object.
|
||||
|
||||
Returns:
|
||||
list: Element [0] is major version. Element [1] i minor version.
|
||||
list: Element [0] is major version. Element [1] is minor version.
|
||||
Element [2] is update number.
|
||||
"""
|
||||
xapi_session = XAPI.connect(module)
|
||||
|
||||
host_ref = xapi_session.xenapi.session.get_this_host(xapi_session._session)
|
||||
return xapi_session.xenapi.host.get_software_version(host_ref)['product_version_text_short'].split('.')
|
||||
|
||||
try:
|
||||
xenserver_version = [int(version_number) for version_number in xapi_session.xenapi.host.get_software_version(host_ref)['product_version'].split('.')]
|
||||
except ValueError:
|
||||
xenserver_version = [0, 0, 0]
|
||||
|
||||
return xenserver_version
|
||||
|
||||
|
||||
class XAPI(object):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue