diff options
author | Rodolfo Carvalho <rhcarvalho@gmail.com> | 2017-02-06 13:53:38 +0100 |
---|---|---|
committer | Rodolfo Carvalho <rhcarvalho@gmail.com> | 2017-02-10 19:49:01 +0100 |
commit | c24b9acb9d04f9613dcc7423791d09f83ef03670 (patch) | |
tree | e30620215de9d7e7bea0377b89769210bec079c8 | |
parent | f502b09c103b5d8681854b7ab6a3c9655311f73b (diff) | |
download | openshift-c24b9acb9d04f9613dcc7423791d09f83ef03670.tar.gz openshift-c24b9acb9d04f9613dcc7423791d09f83ef03670.tar.bz2 openshift-c24b9acb9d04f9613dcc7423791d09f83ef03670.tar.xz openshift-c24b9acb9d04f9613dcc7423791d09f83ef03670.zip |
Do not hard code package names
-rwxr-xr-x | roles/openshift_health_checker/library/aos_version.py | 18 | ||||
-rw-r--r-- | roles/openshift_health_checker/openshift_checks/package_version.py | 13 |
2 files changed, 17 insertions, 14 deletions
diff --git a/roles/openshift_health_checker/library/aos_version.py b/roles/openshift_health_checker/library/aos_version.py index 37c8b483c..13b7d310b 100755 --- a/roles/openshift_health_checker/library/aos_version.py +++ b/roles/openshift_health_checker/library/aos_version.py @@ -14,10 +14,11 @@ import yum # pylint: disable=import-error from ansible.module_utils.basic import AnsibleModule -def main(): # pylint: disable=missing-docstring +def main(): # pylint: disable=missing-docstring,too-many-branches module = AnsibleModule( argument_spec=dict( - version=dict(required=True) + prefix=dict(required=True), # atomic-openshift, origin, ... + version=dict(required=True), ), supports_check_mode=True ) @@ -25,19 +26,24 @@ def main(): # pylint: disable=missing-docstring def bail(error): # pylint: disable=missing-docstring module.fail_json(msg=error) + rpm_prefix = module.params['prefix'] + + if not rpm_prefix: + bail("prefix must not be empty") + yb = yum.YumBase() # pylint: disable=invalid-name # search for package versions available for aos pkgs expected_pkgs = [ - 'atomic-openshift', - 'atomic-openshift-master', - 'atomic-openshift-node', + rpm_prefix, + rpm_prefix + '-master', + rpm_prefix + '-node', ] try: pkgs = yb.pkgSack.returnPackages(patterns=expected_pkgs) except yum.Errors.PackageSackError as e: # pylint: disable=invalid-name # you only hit this if *none* of the packages are available - bail('Unable to find any atomic-openshift packages. \nCheck your subscription and repo settings. \n%s' % e) + bail('Unable to find any OpenShift packages.\nCheck your subscription and repo settings.\n%s' % e) # determine what level of precision we're expecting for the version expected_version = module.params['version'] diff --git a/roles/openshift_health_checker/openshift_checks/package_version.py b/roles/openshift_health_checker/openshift_checks/package_version.py index b31b4d401..7fa09cbfd 100644 --- a/roles/openshift_health_checker/openshift_checks/package_version.py +++ b/roles/openshift_health_checker/openshift_checks/package_version.py @@ -9,15 +9,12 @@ class PackageVersion(NotContainerized, OpenShiftCheck): name = "package_version" tags = ["preflight"] - @classmethod - def is_active(cls, task_vars): - return ( - super(PackageVersion, cls).is_active(task_vars) - and task_vars.get("deployment_type") == "openshift-enterprise" - ) - def run(self, tmp, task_vars): + rpm_prefix = get_var(task_vars, "openshift", "common", "service_type") openshift_release = get_var(task_vars, "openshift_release") - args = {"version": openshift_release} + args = { + "prefix": rpm_prefix, + "version": openshift_release, + } return self.module_executor("aos_version", args, tmp, task_vars) |