ovirt_vm: Fix issue in setting the custom_compatibility_version to NULL

Currently there is no way to reset the custom_compatibility_version to
NULL. If we provide a empty string('') to custom_compatibility_version,
it will fail with error "IndexError: list index out of range" at _get_minor
function.

To reset the custom_compatibility_version, we have to pass None value to
types.Version. The PR fixes the same.
This commit is contained in:
Nijin Ashok
2018-10-21 12:54:10 +05:30
committed by Toshio Kuratomi
parent a0f58fa2ef
commit bc741eb2a0
2 changed files with 10 additions and 5 deletions

View File

@@ -790,14 +790,14 @@ class BaseModule(object):
return entity
def _get_major(self, full_version):
if full_version is None:
if full_version is None or full_version == "":
return None
if isinstance(full_version, otypes.Version):
return int(full_version.major)
return int(full_version.split('.')[0])
def _get_minor(self, full_version):
if full_version is None:
if full_version is None or full_version == "":
return None
if isinstance(full_version, otypes.Version):
return int(full_version.minor)