Skip to content

Commit 07f5784

Browse files
Merge branch 'stable' into update-250206
2 parents 4c03fa9 + 9ed3823 commit 07f5784

File tree

7 files changed

+106
-12
lines changed

7 files changed

+106
-12
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ dist
88
*.egg-info
99
pandoc-*-amd64.deb
1010
pandoc-*-windows-x86_64.msi
11+
pandoc-*-x86_64-macOS.pkg
1112
README.rst
1213

1314
# Environments
@@ -16,4 +17,4 @@ venv/
1617

1718
# Other
1819
kubectl.exe
19-
/build
20+
/build

CONTRIBUTING.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,15 @@ Manually run the pre-commit hooks against all files
3838
```bash
3939
pre-commit run -a
4040
```
41+
42+
Building locally
43+
-------------------------------------------------------------------------------
44+
Clone the python-devops repository locally. From the top level directory, run
45+
```
46+
make install build
47+
```
48+
49+
NOTE: if building on MacOS you will need to first install pandoc:
50+
```
51+
brew install pandoc
52+
```

setup.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ def get_version(rel_path):
5555
description='Python for Maximo Application Suite Dev/Ops',
5656
long_description=long_description,
5757
install_requires=[
58-
'pyyaml', # MIT License
59-
'openshift', # Apache Software License
60-
'kubernetes', # Apache Software License
61-
'kubeconfig', # BSD License
62-
'jinja2', # BSD License
63-
'jinja2-base64-filters' # MIT License
58+
'pyyaml', # MIT License
59+
'openshift', # Apache Software License
60+
'kubernetes', # Apache Software License
61+
'kubeconfig', # BSD License
62+
'jinja2', # BSD License
63+
'jinja2-base64-filters' # MIT License
6464
],
6565
extras_require={
6666
'dev': [

src/mas/devops/ocp.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,22 @@ def connect(server: str, token: str, skipVerify: bool = False) -> bool:
6161
return True
6262

6363

64+
def getNamespace(dynClient: DynamicClient, namespace: str) -> dict:
65+
"""
66+
Get a namespace
67+
"""
68+
namespaceAPI = dynClient.resources.get(api_version="v1", kind="Namespace")
69+
70+
try:
71+
ns = namespaceAPI.get(name=namespace)
72+
logger.debug(f"Namespace {namespace} exists")
73+
return ns
74+
except NotFoundError:
75+
logger.debug(f"Namespace {namespace} does not exist")
76+
77+
return {}
78+
79+
6480
def createNamespace(dynClient: DynamicClient, namespace: str) -> bool:
6581
"""
6682
Create a namespace if it does not exist

src/mas/devops/sls.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# *****************************************************************************
2+
# Copyright (c) 2025 IBM Corporation and other Contributors.
3+
#
4+
# All rights reserved. This program and the accompanying materials
5+
# are made available under the terms of the Eclipse Public License v1.0
6+
# which accompanies this distribution, and is available at
7+
# http://www.eclipse.org/legal/epl-v10.html
8+
#
9+
# *****************************************************************************
10+
11+
import logging
12+
from openshift.dynamic import DynamicClient
13+
from openshift.dynamic.exceptions import NotFoundError, ResourceNotFoundError, UnauthorizedError
14+
15+
logger = logging.getLogger(__name__)
16+
17+
18+
def listSLSInstances(dynClient: DynamicClient) -> list:
19+
"""
20+
Get a list of SLS instances on the cluster
21+
"""
22+
try:
23+
slsAPI = dynClient.resources.get(api_version="sls.ibm.com/v1", kind="LicenseService")
24+
return slsAPI.get().to_dict()['items']
25+
except NotFoundError:
26+
logger.info("There are no SLS instances installed on this cluster")
27+
return []
28+
except ResourceNotFoundError:
29+
logger.info("LicenseService CRD not found on cluster")
30+
return []
31+
except UnauthorizedError:
32+
logger.error("Error: Unable to verify SLS instances due to failed authorization: {e}")
33+
return []
34+
35+
36+
def findSLSByNamespace(namespace: str, instances: list = None, dynClient: DynamicClient = None):
37+
if not instances and not dynClient:
38+
return False
39+
40+
if not instances and dynClient:
41+
instances = listSLSInstances(dynClient)
42+
43+
for instance in instances:
44+
if namespace in instance['metadata']['namespace']:
45+
return True
46+
return False

src/mas/devops/tekton.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def preparePipelinesNamespace(dynClient: DynamicClient, instanceId: str = None,
148148
sleep(15)
149149

150150

151-
def prepareInstallSecrets(dynClient: DynamicClient, instanceId: str, slsLicenseFile: str, additionalConfigs: dict = None, certs: str = None, podTemplates: str = None) -> None:
151+
def prepareInstallSecrets(dynClient: DynamicClient, instanceId: str, slsLicenseFile: str = None, additionalConfigs: dict = None, certs: str = None, podTemplates: str = None) -> None:
152152
namespace = f"mas-{instanceId}-pipelines"
153153
secretsAPI = dynClient.resources.get(api_version="v1", kind="Secret")
154154

@@ -178,10 +178,16 @@ def prepareInstallSecrets(dynClient: DynamicClient, instanceId: str, slsLicenseF
178178
except NotFoundError:
179179
pass
180180

181-
# TODO: Convert this to using secretsAPI.create()
182-
result = kubectl.run(subcmd_args=['-n', namespace, 'create', 'secret', 'generic', 'pipeline-sls-entitlement', '--from-file', slsLicenseFile])
183-
for line in result.split("\n"):
184-
logger.debug(line)
181+
if slsLicenseFile is None:
182+
slsLicenseFile = {
183+
"apiVersion": "v1",
184+
"kind": "Secret",
185+
"type": "Opaque",
186+
"metadata": {
187+
"name": "pipeline-sls-entitlement"
188+
}
189+
}
190+
secretsAPI.create(body=slsLicenseFile, namespace=namespace)
185191

186192
# 3. Secret/pipeline-certificates
187193
# -------------------------------------------------------------------------

src/mas/devops/templates/pipelinerun-install.yml.j2

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,14 +278,22 @@ spec:
278278
value: "{{ cpd_install_openscale }}"
279279
- name: cpd_install_cognos
280280
value: "{{ cpd_install_cognos }}"
281+
- name: cpd_install_ws
282+
value: "{{ cpd_install_ws }}"
283+
- name: cpd_install_wml
284+
value: "{{ cpd_install_wml }}"
285+
- name: cpd_install_ae
286+
value: "{{ cpd_install_ae }}"
281287
{%- endif %}
282288

283289
# Dependencies - SLS
284290
# -------------------------------------------------------------------------
285291
- name: sls_channel
286292
value: '3.x'
293+
{%- if sls_entitlement_file is defined and sls_entitlement_file != "" %}
287294
- name: sls_entitlement_file
288295
value: "{{ sls_entitlement_file }}"
296+
{%- endif %}
289297
{%- if sls_namespace is defined and sls_namespace != "" %}
290298
- name: sls_namespace
291299
value: "{{ sls_namespace }}"
@@ -298,6 +306,11 @@ spec:
298306
- name: sls_mongodb_cfg_file
299307
value: "{{ sls_mongodb_cfg_file }}"
300308
{%- endif %}
309+
{%- if sls_action is defined and sls_action != "" %}
310+
- name: sls_action
311+
value: "{{ sls_action }}"
312+
{%- endif %}
313+
301314

302315
# Dependencies - UDS/DRO (Required)
303316
# -------------------------------------------------------------------------

0 commit comments

Comments
 (0)