From 3581a05fbb08620db464ebd10bb92108afca7f26 Mon Sep 17 00:00:00 2001 From: Rawa Resul Date: Sun, 12 Jan 2025 19:28:06 +0000 Subject: [PATCH 01/19] [patch] Add sls.py --- src/mas/devops/ocp.py | 16 ++++++++++++++++ src/mas/devops/sls.py | 25 +++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 src/mas/devops/sls.py diff --git a/src/mas/devops/ocp.py b/src/mas/devops/ocp.py index f195ccb6..890fdc3f 100644 --- a/src/mas/devops/ocp.py +++ b/src/mas/devops/ocp.py @@ -61,6 +61,22 @@ def connect(server: str, token: str, skipVerify: bool = False) -> bool: return True +def getNamespace(dynClient: DynamicClient, namespace: str) -> dict: + """ + Get a namespace + """ + namespaceAPI = dynClient.resources.get(api_version="v1", kind="Namespace") + namespace = {} + + try: + namespace = namespaceAPI.get(name=namespace) + logger.debug(f"Namespace {namespace} exists") + except NotFoundError: + logger.debug(f"Namespace {namespace} does not exist") + + return namespace + + def createNamespace(dynClient: DynamicClient, namespace: str) -> bool: """ Create a namespace if it does not exist diff --git a/src/mas/devops/sls.py b/src/mas/devops/sls.py new file mode 100644 index 00000000..688559c0 --- /dev/null +++ b/src/mas/devops/sls.py @@ -0,0 +1,25 @@ +import logging +from openshift.dynamic import DynamicClient + +logger = logging.getLogger(__name__) + +def listSLSInstances(dynClient: DynamicClient) -> list: + """ + Get a list of SLS instances on the cluster + """ + slsAPI = dynClient.resources.get(api_version="sls.ibm.com/v1", kind="LicenseService") + + licenseservices = slsAPI.get().to_dict()['items'] + + numSLS = len(licenseservices) + + if numSLS == 1: + logger.info(f"There is 1 SLS instance installed on this cluster:") + logger.info(f" * {licenseservices[0]['metadata']['name']} ({{licenseservices[0]['metadata']['namespace']}}) v{licenseservices[0]['status']['versions']['reconciled']}") + elif numSLS > 0: + logger.info(f"There are {numSLS} SLS instances installed on this cluster:") + for licenseservice in licenseservices: + logger.info(f" * {licenseservice['metadata']['name']} ({{licenseservice['metadata']['namespace']}}) v{licenseservice['status']['versions']['reconciled']}") + else: + logger.info("There are no SLS instances installed on this cluster") + return licenseservices From a250a716bd30c538f12a9ccacd8a80b19a8431a4 Mon Sep 17 00:00:00 2001 From: Rawa Resul Date: Sun, 12 Jan 2025 19:44:07 +0000 Subject: [PATCH 02/19] [patch] linting fixes --- src/mas/devops/sls.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mas/devops/sls.py b/src/mas/devops/sls.py index 688559c0..88bc3a51 100644 --- a/src/mas/devops/sls.py +++ b/src/mas/devops/sls.py @@ -3,6 +3,7 @@ logger = logging.getLogger(__name__) + def listSLSInstances(dynClient: DynamicClient) -> list: """ Get a list of SLS instances on the cluster @@ -14,7 +15,7 @@ def listSLSInstances(dynClient: DynamicClient) -> list: numSLS = len(licenseservices) if numSLS == 1: - logger.info(f"There is 1 SLS instance installed on this cluster:") + logger.info("There is 1 SLS instance installed on this cluster:") logger.info(f" * {licenseservices[0]['metadata']['name']} ({{licenseservices[0]['metadata']['namespace']}}) v{licenseservices[0]['status']['versions']['reconciled']}") elif numSLS > 0: logger.info(f"There are {numSLS} SLS instances installed on this cluster:") From 4043d733d7c339d243f945d0651d68b31a04899d Mon Sep 17 00:00:00 2001 From: Rawa Resul Date: Sun, 12 Jan 2025 20:40:26 +0000 Subject: [PATCH 03/19] [patch] Update pipelinerun-install.yml.j2 --- .../templates/pipelinerun-install.yml.j2 | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/mas/devops/templates/pipelinerun-install.yml.j2 b/src/mas/devops/templates/pipelinerun-install.yml.j2 index 4ad87f44..43b98fd9 100644 --- a/src/mas/devops/templates/pipelinerun-install.yml.j2 +++ b/src/mas/devops/templates/pipelinerun-install.yml.j2 @@ -284,8 +284,10 @@ spec: # ------------------------------------------------------------------------- - name: sls_channel value: '3.x' +{%- if sls_entitlement_file is defined and sls_entitlement_file != "" %} - name: sls_entitlement_file value: "{{ sls_entitlement_file }}" +{%- endif %} {%- if sls_namespace is defined and sls_namespace != "" %} - name: sls_namespace value: "{{ sls_namespace }}" @@ -298,6 +300,23 @@ spec: - name: sls_mongodb_cfg_file value: "{{ sls_mongodb_cfg_file }}" {%- endif %} +{%- if sls_tls_crt_local_file_path is defined and sls_tls_crt_local_file_path != "" %} + - name: sls_tls_crt_local_file_path + value: "{{ sls_tls_crt_local_file_path }}" +{%- endif %} +{%- if sls_registration_key is defined and sls_registration_key != "" %} + - name: sls_registration_key + value: "{{ sls_registration_key }}" +{%- endif %} +{%- if sls_url is defined and sls_url != "" %} + - name: sls_url + value: "{{ sls_url }}" +{%- endif %} +{%- if sls_action is defined and sls_action != "" %} + - name: sls_action + value: "{{ sls_action }}" +{%- endif %} + # Dependencies - UDS/DRO (Required) # ------------------------------------------------------------------------- From 0830980e6d6c6d62a6b4d5447a5915ffd546a732 Mon Sep 17 00:00:00 2001 From: Rawa Resul Date: Sun, 12 Jan 2025 22:11:12 +0000 Subject: [PATCH 04/19] [patch] Switch to sls_tls_crt_local_file_base64_path --- src/mas/devops/templates/pipelinerun-install.yml.j2 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mas/devops/templates/pipelinerun-install.yml.j2 b/src/mas/devops/templates/pipelinerun-install.yml.j2 index 43b98fd9..336c88e7 100644 --- a/src/mas/devops/templates/pipelinerun-install.yml.j2 +++ b/src/mas/devops/templates/pipelinerun-install.yml.j2 @@ -300,9 +300,9 @@ spec: - name: sls_mongodb_cfg_file value: "{{ sls_mongodb_cfg_file }}" {%- endif %} -{%- if sls_tls_crt_local_file_path is defined and sls_tls_crt_local_file_path != "" %} - - name: sls_tls_crt_local_file_path - value: "{{ sls_tls_crt_local_file_path }}" +{%- if sls_tls_crt_local_file_base64_path is defined and sls_tls_crt_local_file_base64_path != "" %} + - name: sls_tls_crt_local_file_base64_path + value: "{{ sls_tls_crt_local_file_base64_path }}" {%- endif %} {%- if sls_registration_key is defined and sls_registration_key != "" %} - name: sls_registration_key From 003a07840e7def1267e8226f67e9e32ece369759 Mon Sep 17 00:00:00 2001 From: Rawa Resul Date: Sun, 12 Jan 2025 22:58:01 +0000 Subject: [PATCH 05/19] [patch] Fix bug in getNamespace --- src/mas/devops/ocp.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mas/devops/ocp.py b/src/mas/devops/ocp.py index 890fdc3f..fb717773 100644 --- a/src/mas/devops/ocp.py +++ b/src/mas/devops/ocp.py @@ -66,15 +66,15 @@ def getNamespace(dynClient: DynamicClient, namespace: str) -> dict: Get a namespace """ namespaceAPI = dynClient.resources.get(api_version="v1", kind="Namespace") - namespace = {} try: - namespace = namespaceAPI.get(name=namespace) + ns = namespaceAPI.get(name=namespace) logger.debug(f"Namespace {namespace} exists") + return ns except NotFoundError: logger.debug(f"Namespace {namespace} does not exist") - return namespace + return {} def createNamespace(dynClient: DynamicClient, namespace: str) -> bool: From 6533d69c8a114bec5eb832a5f2c2d52fe62120cb Mon Sep 17 00:00:00 2001 From: Rawa Resul Date: Mon, 13 Jan 2025 16:59:21 +0000 Subject: [PATCH 06/19] [patch] Fix bug in listSLSInstances --- setup.py | 13 +++++++------ src/mas/devops/sls.py | 35 +++++++++++++++++++++-------------- 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/setup.py b/setup.py index 2ec5bc08..e5e51ffe 100644 --- a/setup.py +++ b/setup.py @@ -55,12 +55,13 @@ def get_version(rel_path): description='Python for Maximo Application Suite Dev/Ops', long_description=long_description, install_requires=[ - 'pyyaml', # MIT License - 'openshift', # Apache Software License - 'kubernetes', # Apache Software License - 'kubeconfig', # BSD License - 'jinja2', # BSD License - 'jinja2-base64-filters' # MIT License + 'pyyaml', # MIT License + 'openshift', # Apache Software License + 'kubernetes', # Apache Software License + 'kubeconfig', # BSD License + 'jinja2', # BSD License + 'jinja2-base64-filters', # MIT License + # 'requests' # Apache Software License ], extras_require={ 'dev': [ diff --git a/src/mas/devops/sls.py b/src/mas/devops/sls.py index 88bc3a51..3d1637dd 100644 --- a/src/mas/devops/sls.py +++ b/src/mas/devops/sls.py @@ -1,5 +1,7 @@ import logging +# import requests from openshift.dynamic import DynamicClient +from openshift.dynamic.exceptions import NotFoundError, ResourceNotFoundError, UnauthorizedError logger = logging.getLogger(__name__) @@ -8,19 +10,24 @@ def listSLSInstances(dynClient: DynamicClient) -> list: """ Get a list of SLS instances on the cluster """ - slsAPI = dynClient.resources.get(api_version="sls.ibm.com/v1", kind="LicenseService") - - licenseservices = slsAPI.get().to_dict()['items'] + try: + slsAPI = dynClient.resources.get(api_version="sls.ibm.com/v1", kind="LicenseService") + return slsAPI.get().to_dict()['items'] + except NotFoundError: + logger.info("There are no SLS instances installed on this cluster") + return [] + except ResourceNotFoundError: + # The LicenseService CRD has not even been installed in the cluster + return [] + except UnauthorizedError: + logger.error("Error: Unable to verify SLS instance(s) due to failed authorization: {e}") + return [] - numSLS = len(licenseservices) - if numSLS == 1: - logger.info("There is 1 SLS instance installed on this cluster:") - logger.info(f" * {licenseservices[0]['metadata']['name']} ({{licenseservices[0]['metadata']['namespace']}}) v{licenseservices[0]['status']['versions']['reconciled']}") - elif numSLS > 0: - logger.info(f"There are {numSLS} SLS instances installed on this cluster:") - for licenseservice in licenseservices: - logger.info(f" * {licenseservice['metadata']['name']} ({{licenseservice['metadata']['namespace']}}) v{licenseservice['status']['versions']['reconciled']}") - else: - logger.info("There are no SLS instances installed on this cluster") - return licenseservices +# def verifySLSConnection(sls_url: str, server_ca: str) -> bool: +# logger.info("Checking SLS connection") +# response = requests.get(f"{sls_url}api/probes/readiness", verify=server_ca) +# if response.status_code == 200: +# return True +# return False +# # response.raise_for_status() From e2cab244a9195abfcbaa072996da179114612fe8 Mon Sep 17 00:00:00 2001 From: Rawa Resul Date: Mon, 13 Jan 2025 20:10:14 +0000 Subject: [PATCH 07/19] [patch] Improve logging --- src/mas/devops/sls.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mas/devops/sls.py b/src/mas/devops/sls.py index 3d1637dd..2abf13ab 100644 --- a/src/mas/devops/sls.py +++ b/src/mas/devops/sls.py @@ -17,10 +17,10 @@ def listSLSInstances(dynClient: DynamicClient) -> list: logger.info("There are no SLS instances installed on this cluster") return [] except ResourceNotFoundError: - # The LicenseService CRD has not even been installed in the cluster + logger.info("LicenseService CRD not found on cluster") return [] except UnauthorizedError: - logger.error("Error: Unable to verify SLS instance(s) due to failed authorization: {e}") + logger.error("Error: Unable to verify SLS instances due to failed authorization: {e}") return [] From 3a4e0795df2321ca7bc402f11eff8c5afee6fea7 Mon Sep 17 00:00:00 2001 From: Rawa Resul Date: Tue, 14 Jan 2025 14:21:25 +0000 Subject: [PATCH 08/19] [patch] Add verify sls connection function --- setup.py | 2 +- src/mas/devops/sls.py | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/setup.py b/setup.py index e5e51ffe..4aa85a77 100644 --- a/setup.py +++ b/setup.py @@ -61,7 +61,7 @@ def get_version(rel_path): 'kubeconfig', # BSD License 'jinja2', # BSD License 'jinja2-base64-filters', # MIT License - # 'requests' # Apache Software License + 'requests' # Apache Software License ], extras_require={ 'dev': [ diff --git a/src/mas/devops/sls.py b/src/mas/devops/sls.py index 2abf13ab..84159d3b 100644 --- a/src/mas/devops/sls.py +++ b/src/mas/devops/sls.py @@ -1,5 +1,5 @@ import logging -# import requests +import requests from openshift.dynamic import DynamicClient from openshift.dynamic.exceptions import NotFoundError, ResourceNotFoundError, UnauthorizedError @@ -24,10 +24,9 @@ def listSLSInstances(dynClient: DynamicClient) -> list: return [] -# def verifySLSConnection(sls_url: str, server_ca: str) -> bool: -# logger.info("Checking SLS connection") -# response = requests.get(f"{sls_url}api/probes/readiness", verify=server_ca) -# if response.status_code == 200: -# return True -# return False -# # response.raise_for_status() +def verifySLSConnection(sls_url: str, server_ca: str) -> bool: + logger.info("Checking SLS connection") + response = requests.get(f"{sls_url}api/probes/readiness", verify=server_ca) + if response.status_code == 200: + return True + return False From 49f0d03bc118e03602369a5f509112a0690f37f3 Mon Sep 17 00:00:00 2001 From: Rawa Resul Date: Tue, 14 Jan 2025 14:29:17 +0000 Subject: [PATCH 09/19] [patch] autopep8 fix --- src/mas/devops/sls.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mas/devops/sls.py b/src/mas/devops/sls.py index 84159d3b..afbbb90e 100644 --- a/src/mas/devops/sls.py +++ b/src/mas/devops/sls.py @@ -28,5 +28,5 @@ def verifySLSConnection(sls_url: str, server_ca: str) -> bool: logger.info("Checking SLS connection") response = requests.get(f"{sls_url}api/probes/readiness", verify=server_ca) if response.status_code == 200: - return True + return True return False From a1fd983ff52ab63e7d9af10fd1e577863e2f766b Mon Sep 17 00:00:00 2001 From: Rawa Resul Date: Tue, 14 Jan 2025 14:30:04 +0000 Subject: [PATCH 10/19] [patch] Fix sls url --- src/mas/devops/sls.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mas/devops/sls.py b/src/mas/devops/sls.py index afbbb90e..55998d2e 100644 --- a/src/mas/devops/sls.py +++ b/src/mas/devops/sls.py @@ -26,7 +26,7 @@ def listSLSInstances(dynClient: DynamicClient) -> list: def verifySLSConnection(sls_url: str, server_ca: str) -> bool: logger.info("Checking SLS connection") - response = requests.get(f"{sls_url}api/probes/readiness", verify=server_ca) + response = requests.get(f"{sls_url}/api/probes/readiness", verify=server_ca) if response.status_code == 200: return True return False From 624a25839b9c3ec877f17f7a653c50e1dcae0a9f Mon Sep 17 00:00:00 2001 From: Rawa Resul Date: Tue, 14 Jan 2025 15:47:18 +0000 Subject: [PATCH 11/19] [patch] Make slsLicenseFile optional --- .gitignore | 3 ++- src/mas/devops/tekton.py | 21 ++++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index e815b7f8..ed45b735 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ dist *.egg-info pandoc-*-amd64.deb pandoc-*-windows-x86_64.msi +pandoc-*-x86_64-macOS.pkg README.rst # Environments @@ -16,4 +17,4 @@ venv/ # Other kubectl.exe -/build +/build diff --git a/src/mas/devops/tekton.py b/src/mas/devops/tekton.py index 8a84dd15..c261de75 100644 --- a/src/mas/devops/tekton.py +++ b/src/mas/devops/tekton.py @@ -148,7 +148,7 @@ def preparePipelinesNamespace(dynClient: DynamicClient, instanceId: str = None, sleep(15) -def prepareInstallSecrets(dynClient: DynamicClient, instanceId: str, slsLicenseFile: str, additionalConfigs: dict = None, certs: str = None, podTemplates: str = None) -> None: +def prepareInstallSecrets(dynClient: DynamicClient, instanceId: str, slsLicenseFile: str = None, additionalConfigs: dict = None, certs: str = None, podTemplates: str = None) -> None: namespace = f"mas-{instanceId}-pipelines" secretsAPI = dynClient.resources.get(api_version="v1", kind="Secret") @@ -178,10 +178,21 @@ def prepareInstallSecrets(dynClient: DynamicClient, instanceId: str, slsLicenseF except NotFoundError: pass - # TODO: Convert this to using secretsAPI.create() - result = kubectl.run(subcmd_args=['-n', namespace, 'create', 'secret', 'generic', 'pipeline-sls-entitlement', '--from-file', slsLicenseFile]) - for line in result.split("\n"): - logger.debug(line) + if slsLicenseFile is None: + slsLicenseFile = { + "apiVersion": "v1", + "kind": "Secret", + "type": "Opaque", + "metadata": { + "name": "pipeline-sls-entitlement" + } + } + secretsAPI.create(body=slsLicenseFile, namespace=namespace) + else: + # TODO: Convert this to using secretsAPI.create() + result = kubectl.run(subcmd_args=['-n', namespace, 'create', 'secret', 'generic', 'pipeline-sls-entitlement', '--from-file', slsLicenseFile]) + for line in result.split("\n"): + logger.debug(line) # 3. Secret/pipeline-certificates # ------------------------------------------------------------------------- From 02f03cbaa83102e9b8af4c55321976299fa1314d Mon Sep 17 00:00:00 2001 From: Rawa Resul Date: Tue, 14 Jan 2025 16:19:07 +0000 Subject: [PATCH 12/19] [patch] Fix slsLicenseFile --- src/mas/devops/tekton.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/mas/devops/tekton.py b/src/mas/devops/tekton.py index c261de75..ed371301 100644 --- a/src/mas/devops/tekton.py +++ b/src/mas/devops/tekton.py @@ -187,12 +187,7 @@ def prepareInstallSecrets(dynClient: DynamicClient, instanceId: str, slsLicenseF "name": "pipeline-sls-entitlement" } } - secretsAPI.create(body=slsLicenseFile, namespace=namespace) - else: - # TODO: Convert this to using secretsAPI.create() - result = kubectl.run(subcmd_args=['-n', namespace, 'create', 'secret', 'generic', 'pipeline-sls-entitlement', '--from-file', slsLicenseFile]) - for line in result.split("\n"): - logger.debug(line) + secretsAPI.create(body=slsLicenseFile, namespace=namespace) # 3. Secret/pipeline-certificates # ------------------------------------------------------------------------- From 7321c7add2f961beb17abd84345fd0c70c4ad333 Mon Sep 17 00:00:00 2001 From: Rawa Resul Date: Thu, 16 Jan 2025 01:04:51 +0000 Subject: [PATCH 13/19] [patch] Remove b64 var --- src/mas/devops/templates/pipelinerun-install.yml.j2 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mas/devops/templates/pipelinerun-install.yml.j2 b/src/mas/devops/templates/pipelinerun-install.yml.j2 index 336c88e7..43b98fd9 100644 --- a/src/mas/devops/templates/pipelinerun-install.yml.j2 +++ b/src/mas/devops/templates/pipelinerun-install.yml.j2 @@ -300,9 +300,9 @@ spec: - name: sls_mongodb_cfg_file value: "{{ sls_mongodb_cfg_file }}" {%- endif %} -{%- if sls_tls_crt_local_file_base64_path is defined and sls_tls_crt_local_file_base64_path != "" %} - - name: sls_tls_crt_local_file_base64_path - value: "{{ sls_tls_crt_local_file_base64_path }}" +{%- if sls_tls_crt_local_file_path is defined and sls_tls_crt_local_file_path != "" %} + - name: sls_tls_crt_local_file_path + value: "{{ sls_tls_crt_local_file_path }}" {%- endif %} {%- if sls_registration_key is defined and sls_registration_key != "" %} - name: sls_registration_key From c0ea92f92b203014eadf0d5522a883218b7578c6 Mon Sep 17 00:00:00 2001 From: Rawa Resul Date: Thu, 16 Jan 2025 17:04:10 +0000 Subject: [PATCH 14/19] [patch] Add findSLSByNamespace function --- src/mas/devops/sls.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/mas/devops/sls.py b/src/mas/devops/sls.py index 55998d2e..e02c17b0 100644 --- a/src/mas/devops/sls.py +++ b/src/mas/devops/sls.py @@ -24,6 +24,18 @@ def listSLSInstances(dynClient: DynamicClient) -> list: return [] +def findSLSByNamespace(namespace: str, instances: list = None, dynClient: DynamicClient = None): + if not instances and not dynClient: + return False + + if not instances and dynClient: + instances = listSLSInstances(dynClient) + + for instance in instances: + if namespace in instance['metadata']['namespace']: + return True + return False + def verifySLSConnection(sls_url: str, server_ca: str) -> bool: logger.info("Checking SLS connection") response = requests.get(f"{sls_url}/api/probes/readiness", verify=server_ca) From a3340d50498f1b6a89a96968adf0985f403ea9fc Mon Sep 17 00:00:00 2001 From: Rawa Resul Date: Thu, 16 Jan 2025 17:10:59 +0000 Subject: [PATCH 15/19] [patch] Fix autopep8 issue --- src/mas/devops/sls.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mas/devops/sls.py b/src/mas/devops/sls.py index e02c17b0..4dcdd0f7 100644 --- a/src/mas/devops/sls.py +++ b/src/mas/devops/sls.py @@ -32,8 +32,8 @@ def findSLSByNamespace(namespace: str, instances: list = None, dynClient: Dynami instances = listSLSInstances(dynClient) for instance in instances: - if namespace in instance['metadata']['namespace']: - return True + if namespace in instance['metadata']['namespace']: + return True return False def verifySLSConnection(sls_url: str, server_ca: str) -> bool: From 0b688f0ebb1942450049825cdd676a934ce5acd3 Mon Sep 17 00:00:00 2001 From: Rawa Resul Date: Thu, 16 Jan 2025 17:12:18 +0000 Subject: [PATCH 16/19] [patch] Add new line --- src/mas/devops/sls.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mas/devops/sls.py b/src/mas/devops/sls.py index 4dcdd0f7..e388ab10 100644 --- a/src/mas/devops/sls.py +++ b/src/mas/devops/sls.py @@ -36,6 +36,7 @@ def findSLSByNamespace(namespace: str, instances: list = None, dynClient: Dynami return True return False + def verifySLSConnection(sls_url: str, server_ca: str) -> bool: logger.info("Checking SLS connection") response = requests.get(f"{sls_url}/api/probes/readiness", verify=server_ca) From 520a4e0c9c0eab97b94a8f6414c501b17e29d21a Mon Sep 17 00:00:00 2001 From: Rawa Resul Date: Tue, 21 Jan 2025 14:13:24 +0000 Subject: [PATCH 17/19] [patch] Cleanup --- src/mas/devops/templates/pipelinerun-install.yml.j2 | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/mas/devops/templates/pipelinerun-install.yml.j2 b/src/mas/devops/templates/pipelinerun-install.yml.j2 index 43b98fd9..324a45c1 100644 --- a/src/mas/devops/templates/pipelinerun-install.yml.j2 +++ b/src/mas/devops/templates/pipelinerun-install.yml.j2 @@ -300,18 +300,6 @@ spec: - name: sls_mongodb_cfg_file value: "{{ sls_mongodb_cfg_file }}" {%- endif %} -{%- if sls_tls_crt_local_file_path is defined and sls_tls_crt_local_file_path != "" %} - - name: sls_tls_crt_local_file_path - value: "{{ sls_tls_crt_local_file_path }}" -{%- endif %} -{%- if sls_registration_key is defined and sls_registration_key != "" %} - - name: sls_registration_key - value: "{{ sls_registration_key }}" -{%- endif %} -{%- if sls_url is defined and sls_url != "" %} - - name: sls_url - value: "{{ sls_url }}" -{%- endif %} {%- if sls_action is defined and sls_action != "" %} - name: sls_action value: "{{ sls_action }}" From 69626a5fbd2886dd51ac0a7fb2fe7853f289cc85 Mon Sep 17 00:00:00 2001 From: Rawa Resul Date: Tue, 21 Jan 2025 14:18:53 +0000 Subject: [PATCH 18/19] [patch] Further cleanup --- setup.py | 13 ++++++------- src/mas/devops/sls.py | 9 --------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/setup.py b/setup.py index 4aa85a77..a0643b2f 100644 --- a/setup.py +++ b/setup.py @@ -55,13 +55,12 @@ def get_version(rel_path): description='Python for Maximo Application Suite Dev/Ops', long_description=long_description, install_requires=[ - 'pyyaml', # MIT License - 'openshift', # Apache Software License - 'kubernetes', # Apache Software License - 'kubeconfig', # BSD License - 'jinja2', # BSD License - 'jinja2-base64-filters', # MIT License - 'requests' # Apache Software License + 'pyyaml', # MIT License + 'openshift', # Apache Software License + 'kubernetes', # Apache Software License + 'kubeconfig', # BSD License + 'jinja2', # BSD License + 'jinja2-base64-filters' # MIT License ], extras_require={ 'dev': [ diff --git a/src/mas/devops/sls.py b/src/mas/devops/sls.py index e388ab10..cd664116 100644 --- a/src/mas/devops/sls.py +++ b/src/mas/devops/sls.py @@ -1,5 +1,4 @@ import logging -import requests from openshift.dynamic import DynamicClient from openshift.dynamic.exceptions import NotFoundError, ResourceNotFoundError, UnauthorizedError @@ -35,11 +34,3 @@ def findSLSByNamespace(namespace: str, instances: list = None, dynClient: Dynami if namespace in instance['metadata']['namespace']: return True return False - - -def verifySLSConnection(sls_url: str, server_ca: str) -> bool: - logger.info("Checking SLS connection") - response = requests.get(f"{sls_url}/api/probes/readiness", verify=server_ca) - if response.status_code == 200: - return True - return False From c34ae0ff0cdf8b0e81313a476737e885c21cd408 Mon Sep 17 00:00:00 2001 From: Rawa Resul Date: Thu, 30 Jan 2025 14:57:04 +0000 Subject: [PATCH 19/19] [patch] Add copyright to sls.py --- src/mas/devops/sls.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/mas/devops/sls.py b/src/mas/devops/sls.py index cd664116..1aabc115 100644 --- a/src/mas/devops/sls.py +++ b/src/mas/devops/sls.py @@ -1,3 +1,13 @@ +# ***************************************************************************** +# Copyright (c) 2025 IBM Corporation and other Contributors. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# ***************************************************************************** + import logging from openshift.dynamic import DynamicClient from openshift.dynamic.exceptions import NotFoundError, ResourceNotFoundError, UnauthorizedError