package_version.py 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. # NOTE: versions outside those specified are mapped to least/greatest
  9. openshift_to_ovs_version = {
  10. (3, 4): "2.4",
  11. (3, 5): ["2.6", "2.7"],
  12. (3, 6): ["2.6", "2.7", "2.8", "2.9"],
  13. (3, 7): ["2.6", "2.7", "2.8", "2.9"],
  14. (3, 8): ["2.6", "2.7", "2.8", "2.9"],
  15. (3, 9): ["2.6", "2.7", "2.8", "2.9"],
  16. (3, 10): ["2.6", "2.7", "2.8", "2.9"],
  17. }
  18. def is_active(self):
  19. """Skip hosts that do not have package requirements."""
  20. group_names = self.get_var("group_names", default=[])
  21. master_or_node = 'oo_masters_to_config' in group_names or 'oo_nodes_to_config' in group_names
  22. return super(PackageVersion, self).is_active() and master_or_node
  23. def run(self):
  24. rpm_prefix = self.get_var("openshift_service_type")
  25. if self._templar is not None:
  26. rpm_prefix = self._templar.template(rpm_prefix)
  27. openshift_release = self.get_var("openshift_release", default='')
  28. deployment_type = self.get_var("openshift_deployment_type")
  29. check_multi_minor_release = deployment_type in ['openshift-enterprise']
  30. args = {
  31. "package_mgr": self.get_var("ansible_pkg_mgr"),
  32. "package_list": [
  33. {
  34. "name": "openvswitch",
  35. "version": self.get_required_ovs_version(),
  36. "check_multi": False,
  37. },
  38. {
  39. "name": "{}".format(rpm_prefix),
  40. "version": openshift_release,
  41. "check_multi": check_multi_minor_release,
  42. },
  43. {
  44. "name": "{}-master".format(rpm_prefix),
  45. "version": openshift_release,
  46. "check_multi": check_multi_minor_release,
  47. },
  48. {
  49. "name": "{}-node".format(rpm_prefix),
  50. "version": openshift_release,
  51. "check_multi": check_multi_minor_release,
  52. },
  53. ],
  54. }
  55. return self.execute_module_with_retries("aos_version", args)
  56. def get_required_ovs_version(self):
  57. """Return the correct Open vSwitch version(s) for the current OpenShift version."""
  58. return self.get_required_version("Open vSwitch", self.openshift_to_ovs_version)