variants.py 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. # TODO: Temporarily disabled due to importing old code into openshift-ansible
  2. # repo. We will work on these over time.
  3. # pylint: disable=bad-continuation,missing-docstring,no-self-use,invalid-name,too-few-public-methods
  4. """
  5. Defines the supported variants and versions the installer supports, and metadata
  6. required to run Ansible correctly.
  7. This module needs to be updated for each major release to allow the new version
  8. to be specified by the user, and to point the generic variants to the latest
  9. version.
  10. """
  11. import logging
  12. installer_log = logging.getLogger('installer')
  13. class Version(object):
  14. def __init__(self, name, ansible_key, subtype=''):
  15. self.name = name # i.e. 3.0, 3.1
  16. self.ansible_key = ansible_key
  17. self.subtype = subtype
  18. class Variant(object):
  19. def __init__(self, name, description, versions):
  20. # Supported variant name:
  21. self.name = name
  22. # Friendly name for the variant:
  23. self.description = description
  24. self.versions = versions
  25. def latest_version(self):
  26. return self.versions[0]
  27. # WARNING: Keep the versions ordered, most recent first:
  28. OSE = Variant('openshift-enterprise', 'OpenShift Container Platform', [
  29. Version('3.6', 'openshift-enterprise'),
  30. ])
  31. REG = Variant('openshift-enterprise', 'Registry', [
  32. Version('3.6', 'openshift-enterprise', 'registry'),
  33. ])
  34. origin = Variant('origin', 'OpenShift Origin', [
  35. Version('3.6', 'origin'),
  36. ])
  37. LEGACY = Variant('openshift-enterprise', 'OpenShift Container Platform', [
  38. Version('3.5', 'openshift-enterprise'),
  39. Version('3.4', 'openshift-enterprise'),
  40. Version('3.3', 'openshift-enterprise'),
  41. Version('3.2', 'openshift-enterprise'),
  42. Version('3.1', 'openshift-enterprise'),
  43. Version('3.0', 'openshift-enterprise'),
  44. ])
  45. # Ordered list of variants we can install, first is the default.
  46. SUPPORTED_VARIANTS = (OSE, REG, origin, LEGACY)
  47. DISPLAY_VARIANTS = (OSE, REG,)
  48. def find_variant(name, version=None):
  49. """
  50. Locate the variant object for the variant given in config file, and
  51. the correct version to use for it.
  52. Return (None, None) if we can't find a match.
  53. """
  54. prod = None
  55. for prod in SUPPORTED_VARIANTS:
  56. if prod.name == name:
  57. if version is None:
  58. return (prod, prod.latest_version())
  59. for v in prod.versions:
  60. if v.name == version:
  61. return (prod, v)
  62. return (None, None)
  63. def get_variant_version_combos():
  64. combos = []
  65. for variant in DISPLAY_VARIANTS:
  66. for ver in variant.versions:
  67. combos.append((variant, ver))
  68. return combos