ovs_version.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. """
  2. Ansible module for determining if an installed version of Open vSwitch is incompatible with the
  3. currently installed version of OpenShift.
  4. """
  5. from openshift_checks import OpenShiftCheck
  6. from openshift_checks.mixins import NotContainerizedMixin
  7. class OvsVersion(NotContainerizedMixin, OpenShiftCheck):
  8. """Check that packages in a package_list are installed on the host
  9. and are the correct version as determined by an OpenShift installation.
  10. """
  11. name = "ovs_version"
  12. tags = ["health"]
  13. openshift_to_ovs_version = {
  14. (3, 4): "2.4",
  15. (3, 5): ["2.6", "2.7"],
  16. (3, 6): ["2.6", "2.7", "2.8"],
  17. (3, 7): ["2.6", "2.7", "2.8"],
  18. }
  19. def is_active(self):
  20. """Skip hosts that do not have package requirements."""
  21. group_names = self.get_var("group_names", default=[])
  22. master_or_node = 'oo_masters_to_config' in group_names or 'oo_nodes_to_config' in group_names
  23. return super(OvsVersion, self).is_active() and master_or_node
  24. def run(self):
  25. args = {
  26. "package_list": [
  27. {
  28. "name": "openvswitch",
  29. "version": self.get_required_ovs_version(),
  30. },
  31. ],
  32. }
  33. return self.execute_module("rpm_version", args)
  34. def get_required_ovs_version(self):
  35. """Return the correct Open vSwitch version(s) for the current OpenShift version."""
  36. return self.get_required_version("Open vSwitch", self.openshift_to_ovs_version)