Skip to content

Commit 596f58d

Browse files
committed
[minor] Additional OCP metadata
1 parent 0ab0147 commit 596f58d

2 files changed

Lines changed: 147 additions & 0 deletions

File tree

src/mas/devops/data/__init__.py

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,92 @@ def getNewestCatalogTag(arch="amd64") -> str | None:
9090
return None
9191
else:
9292
return catalogs[-1]
93+
94+
95+
def getOCPLifecycleData() -> dict | None:
96+
"""
97+
Load OpenShift Container Platform lifecycle data.
98+
99+
This function reads the OCP lifecycle YAML file containing General Availability dates,
100+
Standard Support end dates, and Extended Update Support (EUS) end dates for various
101+
OCP versions.
102+
103+
Returns:
104+
dict: The OCP lifecycle data dictionary with version information.
105+
Returns None if the ocp.yaml file doesn't exist.
106+
107+
Example:
108+
>>> data = getOCPLifecycleData()
109+
>>> if data:
110+
... versions = data.get('ocp_versions', {})
111+
... ocp_416 = versions.get('4.16', {})
112+
... print(ocp_416.get('ga_date'))
113+
'June 27, 2024'
114+
"""
115+
moduleFile = path.abspath(__file__)
116+
modulePath = path.dirname(moduleFile)
117+
ocpFileName = "ocp.yaml"
118+
119+
pathToOCP = path.join(modulePath, ocpFileName)
120+
if not path.exists(pathToOCP):
121+
return None
122+
123+
with open(pathToOCP) as stream:
124+
return yaml.safe_load(stream)
125+
126+
127+
def getOCPVersion(version: str) -> dict | None:
128+
"""
129+
Get lifecycle information for a specific OCP version.
130+
131+
This function retrieves the General Availability date, Standard Support end date,
132+
and Extended Update Support (EUS) end date for a specific OpenShift version.
133+
134+
Args:
135+
version (str): The OCP version (e.g., "4.16", "4.17").
136+
137+
Returns:
138+
dict: Dictionary containing 'ga_date', 'standard_support', and 'extended_support'.
139+
Returns None if the version is not found or OCP data doesn't exist.
140+
141+
Example:
142+
>>> version_info = getOCPVersion("4.16")
143+
>>> if version_info:
144+
... print(f"GA: {version_info['ga_date']}")
145+
... print(f"Standard Support: {version_info['standard_support']}")
146+
... print(f"Extended Support: {version_info['extended_support']}")
147+
GA: June 27, 2024
148+
Standard Support: December 27, 2025
149+
Extended Support: June 27, 2027
150+
"""
151+
ocp_data = getOCPLifecycleData()
152+
if not ocp_data:
153+
return None
154+
155+
ocp_versions = ocp_data.get("ocp_versions", {})
156+
return ocp_versions.get(version)
157+
158+
159+
def listOCPVersions() -> list:
160+
"""
161+
List all OCP versions with lifecycle data available.
162+
163+
This function returns a sorted list of all OpenShift Container Platform versions
164+
that have lifecycle information defined.
165+
166+
Returns:
167+
list: Sorted list of OCP version strings (e.g., ["4.12", "4.13", "4.14", ...]).
168+
Returns empty list if OCP data doesn't exist.
169+
170+
Example:
171+
>>> versions = listOCPVersions()
172+
>>> print(versions)
173+
['4.12', '4.13', '4.14', '4.15', '4.16', '4.17', '4.18', '4.19']
174+
"""
175+
ocp_data = getOCPLifecycleData()
176+
if not ocp_data:
177+
return []
178+
179+
ocp_versions = ocp_data.get("ocp_versions", {})
180+
# Sort versions numerically (4.12, 4.13, etc.)
181+
return sorted(ocp_versions.keys(), key=lambda v: [int(x) for x in v.split(".")])

src/mas/devops/data/ocp.yaml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
# OpenShift Container Platform Lifecycle Data
3+
# -----------------------------------------------------------------------------
4+
# This file contains the lifecycle information for OpenShift Container Platform
5+
# versions, including General Availability dates, Standard Support end dates,
6+
# and Extended Update Support (EUS) end dates.
7+
#
8+
# Data source: Red Hat OpenShift Container Platform Life Cycle Policy
9+
# https://access.redhat.com/support/policy/updates/openshift/
10+
11+
ocp_versions:
12+
"4.19":
13+
ga_date: "June 17, 2025"
14+
standard_support: "December 17, 2026"
15+
extended_support: "N/A"
16+
17+
"4.18":
18+
ga_date: "February 25, 2025"
19+
standard_support: "GA of 4.19 + 3 Months"
20+
extended_support: "August 25, 2026"
21+
22+
"4.17":
23+
ga_date: "October 1, 2024"
24+
standard_support: "May 25, 2025"
25+
extended_support: "April 1, 2026"
26+
27+
"4.16":
28+
ga_date: "June 27, 2024"
29+
standard_support: "December 27, 2025"
30+
extended_support: "June 27, 2027"
31+
32+
"4.15":
33+
ga_date: "February 27, 2024"
34+
standard_support: "August 27, 2025"
35+
extended_support: "N/A"
36+
37+
"4.14":
38+
ga_date: "October 31, 2023"
39+
standard_support: "May 1, 2025"
40+
extended_support: "October 31, 2026"
41+
42+
"4.13":
43+
ga_date: "May 17, 2023"
44+
standard_support: "November 17, 2024"
45+
extended_support: "N/A"
46+
47+
"4.12":
48+
ga_date: "January 17, 2023"
49+
standard_support: "July 17, 2024"
50+
extended_support: "January 17, 2025"
51+
52+
# Notes:
53+
# - Standard Support: 18 months from GA date
54+
# - Extended Support (EUS): Additional 6 months available for purchase
55+
# - EUS is included with Premium subscriptions
56+
# - Not all versions have EUS available
57+
58+
# Made with Bob

0 commit comments

Comments
 (0)