variants.py 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. class Version(object):
  12. def __init__(self, name, ansible_key):
  13. self.name = name # i.e. 3.0, 3.1
  14. self.ansible_key = ansible_key
  15. class Variant(object):
  16. def __init__(self, name, description, versions):
  17. # Supported variant name:
  18. self.name = name
  19. # Friendly name for the variant:
  20. self.description = description
  21. self.versions = versions
  22. def latest_version(self):
  23. return self.versions[0]
  24. # WARNING: Keep the versions ordered, most recent first:
  25. OSE = Variant('openshift-enterprise', 'OpenShift Enterprise',
  26. [
  27. Version('3.2', 'openshift-enterprise'),
  28. Version('3.1', 'openshift-enterprise'),
  29. Version('3.0', 'enterprise')
  30. ]
  31. )
  32. AEP = Variant('atomic-enterprise', 'Atomic Enterprise Platform',
  33. [
  34. Version('3.2', 'atomic-enterprise'),
  35. Version('3.1', 'atomic-enterprise')
  36. ]
  37. )
  38. origin = Variant('origin', 'OpenShift Origin',
  39. [
  40. Version('1.2', 'origin'),
  41. ]
  42. )
  43. # Ordered list of variants we can install, first is the default.
  44. SUPPORTED_VARIANTS = (OSE, AEP, origin)
  45. DISPLAY_VARIANTS = (OSE, AEP)
  46. def find_variant(name, version=None):
  47. """
  48. Locate the variant object for the variant given in config file, and
  49. the correct version to use for it.
  50. Return (None, None) if we can't find a match.
  51. """
  52. prod = None
  53. for prod in SUPPORTED_VARIANTS:
  54. if prod.name == name:
  55. if version is None:
  56. return (prod, prod.latest_version())
  57. for v in prod.versions:
  58. if v.name == version:
  59. return (prod, v)
  60. return (None, None)
  61. def get_variant_version_combos():
  62. combos = []
  63. for variant in DISPLAY_VARIANTS:
  64. for ver in variant.versions:
  65. combos.append((variant, ver))
  66. return combos