From 559b008fd86bb7d8491dd4664e4c9164aec8b5a4 Mon Sep 17 00:00:00 2001 From: Marc Wrobel Date: Sat, 28 Oct 2023 15:06:34 +0200 Subject: [PATCH] [nutanix] Add automation (#165) Nutanix products versions are retreived from https://portal.nutanix.com/api/v1. --- src/nutanix.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/nutanix.py diff --git a/src/nutanix.py b/src/nutanix.py new file mode 100644 index 00000000..a0a69bc3 --- /dev/null +++ b/src/nutanix.py @@ -0,0 +1,40 @@ +import json +from common import endoflife + +"""Fetch Nutanix products versions with their dates from https://portal.nutanix.com/api/v1. +""" + +PRODUCTS = { + 'nutanix-aos': 'NOS', + 'nutanix-files': 'FILES', + 'nutanix-prism': 'PC', +} + +BASE_URL = "https://portal.nutanix.com/api/v1/eol/find?type=" + + +def fetch_releases(product_code): + releases = {} + url = BASE_URL + product_code + print(url) + response = endoflife.fetch_url(url) + data = json.loads(response) + + for version_data in data["contents"]: + if 'GENERAL_AVAILABILITY' in version_data: + version = version_data["version"] + date = version_data["GENERAL_AVAILABILITY"].split("T")[0] + releases[version] = date + print(f"{version}: {date}") + + return releases + + +for product_name, product_code in PRODUCTS.items(): + print(f"::group::{product_name}") + all_releases = fetch_releases(product_code) + endoflife.write_releases(product_name, dict( + # sort by date then version (desc) + sorted(all_releases.items(), key=lambda x: (x[1], x[0]), reverse=True) + )) + print("::endgroup::")