package_version.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. """Check that available RPM packages match the required versions."""
  2. from openshift_checks import OpenShiftCheck
  3. from openshift_checks.mixins import NotContainerizedMixin
  4. class PackageVersion(NotContainerizedMixin, OpenShiftCheck):
  5. """Check that available RPM packages match the required versions."""
  6. name = "package_version"
  7. tags = ["preflight"]
  8. def is_active(self):
  9. """Skip hosts that do not have package requirements."""
  10. group_names = self.get_var("group_names", default=[])
  11. master_or_node = 'oo_masters_to_config' in group_names or 'oo_nodes_to_config' in group_names
  12. return super(PackageVersion, self).is_active() and master_or_node
  13. def run(self):
  14. rpm_prefix = self.get_var("openshift_service_type")
  15. if self._templar is not None:
  16. rpm_prefix = self._templar.template(rpm_prefix)
  17. openshift_release = self.get_var("openshift_release", default='')
  18. deployment_type = self.get_var("openshift_deployment_type")
  19. check_multi_minor_release = deployment_type in ['openshift-enterprise']
  20. args = {
  21. "package_mgr": self.get_var("ansible_pkg_mgr"),
  22. "package_list": [
  23. {
  24. "name": "{}".format(rpm_prefix),
  25. "version": openshift_release,
  26. "check_multi": check_multi_minor_release,
  27. },
  28. {
  29. "name": "{}-master".format(rpm_prefix),
  30. "version": openshift_release,
  31. "check_multi": check_multi_minor_release,
  32. },
  33. {
  34. "name": "{}-node".format(rpm_prefix),
  35. "version": openshift_release,
  36. "check_multi": check_multi_minor_release,
  37. },
  38. ],
  39. }
  40. return self.execute_module_with_retries("aos_version", args)