Skip to content

Commit d9d5a38

Browse files
authored
Merge branch 'stable' into cli1511
2 parents 9381a55 + e3efd37 commit d9d5a38

18 files changed

Lines changed: 4182 additions & 9 deletions

README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,55 @@ updateTektonDefinitions(pipelinesNamespace, "/mascli/templates/ibm-mas-tekton.ya
3737
pipelineURL = launchUpgradePipeline(self.dynamicClient, instanceId)
3838
print(pipelineURL)
3939
```
40+
41+
mas-devops-create-initial-users
42+
---------------------------------------------
43+
44+
45+
Add to /etc/hosts
46+
```
47+
127.0.0.1 tgk01-masdev.mas-tgk01-manage.svc.cluster.local
48+
127.0.0.1 coreapi.mas-tgk01-core.svc.cluster.local
49+
127.0.0.1 admin-dashboard.mas-tgk01-core.svc.cluster.local
50+
```
51+
52+
```bash
53+
SM_AWS_REGION=""
54+
SM_AWS_ACCESS_KEY_ID=""
55+
SM_AWS_SECRET_ACCESS_KEY=""
56+
57+
aws configure set default.region ${SM_AWS_REGION}
58+
aws configure set aws_access_key_id ${SM_AWS_ACCESS_KEY_ID}
59+
aws configure set aws_secret_access_key ${SM_AWS_SECRET_ACCESS_KEY}
60+
61+
62+
oc login --token=sha256~xxx --server=https://xxx:6443
63+
64+
oc port-forward service/admin-dashboard 8445:443 -n mas-tgk01-core
65+
oc port-forward service/coreapi 8444:443 -n mas-tgk01-core
66+
oc port-forward service/tgk01-masdev 8443:443 -n mas-tgk01-manage
67+
68+
mas-devops-create-initial-users-for-saas \
69+
--mas-instance-id tgk01 \
70+
--mas-workspace-id masdev \
71+
--log-level INFO \
72+
--initial-users-secret-name "aws-dev/noble4/tgk01/initial_users" \
73+
--manage-api-port 8443 \
74+
--coreapi-port 8444 \
75+
--admin-dashboard-port 8445
76+
77+
78+
mas-devops-create-initial-users-for-saas \
79+
--mas-instance-id tgk01 \
80+
--mas-workspace-id masdev \
81+
--log-level INFO \
82+
--initial-users-yaml-file /home/tom/workspaces/notes/mascore3423/example-users-single.yaml \
83+
--manage-api-port 8443 \
84+
--coreapi-port 8444 \
85+
--admin-dashboard-port 8445
86+
```
87+
88+
Example of initial_users secret:
89+
```json
90+
{"john.smith1@example.com":"primary,john1,smith1","john.smith2@example.com":"primary,john2,smith2","john.smith3@example.com":"secondary,john3,smith3"}
91+
```
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
#!/usr/bin/env python3
2+
3+
# *****************************************************************************
4+
# Copyright (c) 2025 IBM Corporation and other Contributors.
5+
#
6+
# All rights reserved. This program and the accompanying materials
7+
# are made available under the terms of the Eclipse Public License v1.0
8+
# which accompanies this distribution, and is available at
9+
# http://www.eclipse.org/legal/epl-v10.html
10+
#
11+
# *****************************************************************************
12+
13+
from kubernetes import client, config
14+
from kubernetes.config.config_exception import ConfigException
15+
import argparse
16+
import logging
17+
import urllib3
18+
urllib3.disable_warnings()
19+
import yaml
20+
import json
21+
import sys
22+
23+
import boto3
24+
from botocore.exceptions import ClientError
25+
26+
from mas.devops.users import MASUserUtils
27+
28+
29+
30+
if __name__ == "__main__":
31+
parser = argparse.ArgumentParser()
32+
33+
# Primary Options
34+
parser.add_argument("--mas-instance-id", required=True)
35+
parser.add_argument("--mas-workspace-id", required=True)
36+
parser.add_argument("--log-level", required=False, choices=["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"], default="INFO")
37+
parser.add_argument("--coreapi-port", required=False, default=443)
38+
parser.add_argument("--admin-dashboard-port", required=False, default=443)
39+
parser.add_argument("--manage-api-port", required=False, default=443)
40+
41+
42+
group = parser.add_mutually_exclusive_group(required=True)
43+
group.add_argument("--initial-users-yaml-file")
44+
group.add_argument("--initial-users-secret-name")
45+
46+
args, unknown = parser.parse_known_args()
47+
48+
log_level = getattr(logging, args.log_level)
49+
50+
logger = logging.getLogger()
51+
logger.setLevel(log_level)
52+
53+
ch = logging.StreamHandler()
54+
ch.setLevel(log_level)
55+
chFormatter = logging.Formatter(
56+
"%(asctime)-25s %(name)-50s [%(threadName)s] %(levelname)-8s %(message)s"
57+
)
58+
ch.setFormatter(chFormatter)
59+
logger.addHandler(ch)
60+
61+
mas_instance_id = args.mas_instance_id
62+
mas_workspace_id = args.mas_workspace_id
63+
initial_users_yaml_file = args.initial_users_yaml_file
64+
initial_users_secret_name = args.initial_users_secret_name
65+
coreapi_port = args.coreapi_port
66+
admin_dashboard_port = args.admin_dashboard_port
67+
manage_api_port = args.manage_api_port
68+
69+
70+
logger.info("Configuration:")
71+
logger.info("--------------")
72+
logger.info(f"mas_instance_id: {mas_instance_id}")
73+
logger.info(f"mas_workspace_id: {mas_workspace_id}")
74+
logger.info(f"initial_users_yaml_file: {initial_users_yaml_file}")
75+
logger.info(f"initial_users_secret_name: {initial_users_secret_name}")
76+
logger.info(f"log_level: {log_level}")
77+
logger.info(f"coreapi_port: {coreapi_port}")
78+
logger.info(f"admin_dashboard_port: {admin_dashboard_port}")
79+
logger.info(f"manage_api_port: {manage_api_port}")
80+
logger.info("")
81+
82+
try:
83+
# Try to load in-cluster configuration
84+
config.load_incluster_config()
85+
logger.debug("Loaded in-cluster configuration")
86+
except ConfigException:
87+
# If that fails, fall back to kubeconfig file
88+
config.load_kube_config()
89+
logger.debug("Loaded kubeconfig file")
90+
91+
92+
user_utils = MASUserUtils(mas_instance_id, mas_workspace_id, client.api_client.ApiClient(), coreapi_port=coreapi_port, admin_dashboard_port=admin_dashboard_port, manage_api_port=manage_api_port)
93+
94+
if initial_users_secret_name is not None:
95+
96+
logger.info(f"Loading initial_users configuration from secret {initial_users_secret_name}")
97+
98+
session = boto3.session.Session()
99+
aws_sm_client = session.client(
100+
service_name='secretsmanager',
101+
)
102+
try:
103+
initial_users_secret = aws_sm_client.get_secret_value( # pragma: allowlist secret
104+
SecretId=initial_users_secret_name
105+
)
106+
except ClientError as e:
107+
if e.response['Error']['Code'] == 'ResourceNotFoundException':
108+
logger.info(f"Secret {initial_users_secret_name} was not found, nothing to do, exiting now.")
109+
sys.exit(0)
110+
111+
raise Exception(f"Failed to fetch secret {initial_users_secret_name}: {str(e)}")
112+
113+
secret_json = json.loads(initial_users_secret['SecretString'])
114+
initial_users = user_utils.parse_initial_users_from_aws_secret_json(secret_json)
115+
elif initial_users_yaml_file is not None:
116+
with open(initial_users_yaml_file, 'r') as file:
117+
initial_users = yaml.safe_load(file)
118+
else:
119+
raise Exception("Something unexpected happened")
120+
121+
122+
result = user_utils.create_initial_users_for_saas(initial_users)
123+
124+
# if user details were sourced from an AWS SM secret, remove the completed entries from the secret
125+
# so we don't try and resync them the next time round (and potentially undo an update made by a customer)
126+
if initial_users_secret_name is not None:
127+
has_updates = False
128+
for completed_user in result["completed"]:
129+
logger.info(f"Removing synced user {completed_user['email']} from {initial_users_secret_name} secret")
130+
secret_json.pop(completed_user["email"])
131+
has_updates = True
132+
133+
if has_updates:
134+
logger.info(f"Updating secret {initial_users_secret_name}")
135+
try:
136+
aws_sm_client.update_secret( # pragma: allowlist secret
137+
SecretId=initial_users_secret_name,
138+
SecretString=json.dumps(secret_json)
139+
)
140+
except ClientError as e:
141+
raise Exception(f"Failed to update secret {initial_users_secret_name}: {str(e)}")
142+
143+
144+
if len(result["failed"]) > 0:
145+
failed_user_ids = list(map(lambda u : u["email"], result["failed"]))
146+
raise Exception(f"Sync failed for the following user IDs {failed_user_ids}")

setup.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,17 @@ def get_version(rel_path):
6060
'kubernetes', # Apache Software License
6161
'kubeconfig', # BSD License
6262
'jinja2', # BSD License
63-
'jinja2-base64-filters' # MIT License
63+
'jinja2-base64-filters', # MIT License
64+
'semver', # BSD License
65+
'boto3' # Apache Software License
6466
],
6567
extras_require={
6668
'dev': [
67-
'build', # MIT License
68-
'flake8', # MIT License
69-
'pytest', # MIT License
70-
'pytest-mock' # MIT License
69+
'build', # MIT License
70+
'flake8', # MIT License
71+
'pytest', # MIT License
72+
'pytest-mock', # MIT License
73+
'requests-mock' # Apache Software License
7174
]
7275
},
7376
classifiers=[
@@ -85,6 +88,7 @@ def get_version(rel_path):
8588
],
8689
scripts=[
8790
'bin/mas-devops-db2-validate-config',
91+
'bin/mas-devops-create-initial-users-for-saas',
8892
'bin/mas-devops-saas-job-cleaner'
8993
]
9094
)

src/mas/devops/data/catalogs/v9-250403-amd64.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ mas_visualinspection_version:
7777
9.0.x: 9.0.8 # updated
7878
8.10.x: 8.8.4 # No Update
7979
8.11.x: 8.9.11 # updated
80-
80+
8181
# Extra Images for UDS
8282
# ------------------------------------------------------------------------------
8383
uds_extras_version: 1.5.0
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
---
2+
# Case bundle configuration for IBM Maximo Operator Catalog 250501
3+
# -----------------------------------------------------------------------------
4+
# In the future this won't be necessary as we'll be able to mirror from the
5+
# catalog itself, but not everything in the catalog supports this yet (including MAS)
6+
# so we need to use the CASE bundle mirror process still.
7+
8+
catalog_digest: sha256:152bb3a71e029d2215a14816ac928bc28054d85d6123a3813c9679fd7eb91650
9+
10+
# Dependencies
11+
# -----------------------------------------------------------------------------
12+
ibm_licensing_version: 4.2.12 # Operator version 4.2.11 (https://github.com/IBM/cloud-pak/tree/master/repo/case/ibm-licensing)
13+
common_svcs_version: 4.7.0 # check once why we have 4.3.0 in all previous versions since so long it's 4.3.0 # Operator version 4.3.1 (https://github.com/IBM/cloud-pak/tree/master/repo/case/ibm-cp-common-services)
14+
common_svcs_version_2: 4.8.0
15+
common_svcs_version_1: 4.3.0 #+20240702.100000 # common_svcs is a mess
16+
17+
cp4d_platform_version: 5.0.0 #+20240716.101015 # Operator version 5.0.0 (https://github.com/IBM/cloud-pak/tree/master/repo/case/ibm-cp-datacore/4.0.0%2B20231213.115030)
18+
19+
ibm_zen_version: 6.0.1+20240708.121250.32 # For CPD5 ibm-zen has to be explicitily mirrored
20+
21+
db2u_version: 6.0.1+20240704.142950.9960 # Operator version 110509.0.2 to find the version 6.0.1, search CASE_VERSION in db2u, catalog.yaml into ibm-maximo-operator-catalog (https://github.com/IBM/cloud-pak/tree/master/repo/case/ibm-db2uoperator)
22+
events_version: 5.0.1 # Operator version 5.0.1 (https://github.com/IBM/cloud-pak/tree/master/repo/case/ibm-events-operator)
23+
uds_version: 2.0.12 # Operator version 2.0.12 # sticking to 2.0.12 version # Please do Not Change
24+
sls_version: 3.11.1 # No update # Operator version 3.10.0 (https://github.ibm.com/maximoappsuite/ibm-sls/releases)
25+
tsm_version: 1.6.2 # No update # Operator version 1.5.4 (https://github.ibm.com/maximoappsuite/ibm-truststore-mgr/releases)
26+
dd_version: 1.1.18 # Updated # Operator version 1.1.14 (https://github.ibm.com/maximoappsuite/ibm-data-dictionary/releases)
27+
appconnect_version: 6.2.0 # Operator version 6.2.0 # sticking to 6.2.0 version # Please do Not Change
28+
wsl_version: 9.0.0 # Operator version 9.0.0
29+
wml_version: 9.0.0 # Operator version 5.0.0
30+
# ccs_build: +20240528.144404.460 # ibm-ccs from version 9.0.0 requires the build version
31+
# datarefinery_build: +20240517.202103.146
32+
spark_version: 9.0.0 # Operator version 5.0.0
33+
cognos_version: 25.0.0 # Operator version 25.0.0
34+
couchdb_version: 1.0.13 # Operator version 2.2.1 (This is required for Assist 9.0, https://github.com/IBM/cloud-pak/blob/master/repo/case/ibm-couchdb/index.yaml)
35+
elasticsearch_version: 1.1.2570 # Operator version 1.1.2470
36+
37+
38+
# Maximo Application Suite
39+
# -----------------------------------------------------------------------------
40+
mas_core_version:
41+
9.1.x-feature: 9.1.0-pre.stable_9718 # Updated
42+
9.0.x: 9.0.11 # Updated
43+
8.10.x: 8.10.25 # Updated
44+
8.11.x: 8.11.22 # Updated
45+
mas_assist_version:
46+
9.0.x: 9.0.5 # Updated
47+
8.10.x: 8.7.8 # No Update
48+
8.11.x: 8.8.7 # No Update
49+
mas_hputilities_version:
50+
9.0.x: "" # Not Supported
51+
8.10.x: 8.6.7 # tbc
52+
8.11.x: "" # Not Supported
53+
mas_iot_version:
54+
9.0.x: 9.0.8 # Updated
55+
8.10.x: 8.7.22 # Updated
56+
8.11.x: 8.8.18 # Updated
57+
mas_manage_version:
58+
9.1.x-feature: 9.1.0-pre.stable_10993 # Updated
59+
9.0.x: 9.0.13 # Updated
60+
8.10.x: 8.6.26 # Updated
61+
8.11.x: 8.7.20 # Updated
62+
mas_monitor_version:
63+
9.0.x: 9.0.9 # Updated
64+
8.10.x: 8.10.19 # Updated
65+
8.11.x: 8.11.17 # Updated
66+
mas_optimizer_version:
67+
9.1.x-feature: 9.1.0-pre.stable_1943 # Updated
68+
9.0.x: 9.0.10 # Updated
69+
8.10.x: 8.4.17 # Updated
70+
8.11.x: 8.5.16 # Updated
71+
mas_predict_version:
72+
9.0.x: 9.0.7 # Updated
73+
8.10.x: 8.8.8 # Updated
74+
8.11.x: 8.9.10 # Updated
75+
mas_visualinspection_version:
76+
9.1.x-feature: 9.1.0-pre.stable_2405 # Updated
77+
9.0.x: 9.0.9 # Updated
78+
8.10.x: 8.8.4 # No Update
79+
8.11.x: 8.9.12 # Updated
80+
81+
# Extra Images for UDS
82+
# ------------------------------------------------------------------------------
83+
uds_extras_version: 1.5.0
84+
85+
# Extra Images for Mongo
86+
# ------------------------------------------------------------------------------
87+
mongo_extras_version_default: 7.0.12
88+
89+
# Variables used to mirror additional mongo image versions
90+
mongo_extras_version_4: 4.4.21
91+
mongo_extras_version_5: 5.0.23
92+
mongo_extras_version_6: 6.0.12
93+
mongo_extras_version_7: 7.0.12
94+
95+
# Extra Images for Db2u
96+
# ------------------------------------------------------------------------------
97+
db2u_extras_version: 1.0.6 # No Update
98+
db2u_filter: db2
99+
100+
# Extra Images for IBM Watson Discovery
101+
# ------------------------------------------------------------------------------
102+
#wd_extras_version: 1.0.4
103+
104+
# Extra Images for Amlen
105+
# ------------------------------------------------------------------------------
106+
amlen_extras_version: 1.1.2
107+
108+
# Default Cloud Pak for Data version
109+
# ------------------------------------------------------------------------------
110+
cpd_product_version_default: 5.0.0
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
# Case bundle configuration for IBM Maximo Operator Catalog 250501
3+
# -----------------------------------------------------------------------------
4+
# In the future this won't be necessary as we'll be able to mirror from the
5+
# catalog itself, but not everything in the catalog supports this yet (including MAS)
6+
# so we need to use the CASE bundle mirror process still.
7+
8+
catalog_digest: sha256:9d0437b2e7391fb4e28ba42294c442fea5d157bd1699d7d7a415dd7a5a27a6f9
9+
10+
uds_version: 2.0.12 # Operator version 2.0.12 # sticking to 2.0.12 version # Please do Not Change
11+
sls_version: 3.11.1 # tbc # Operator version 3.10.0 (https://github.ibm.com/maximoappsuite/ibm-sls/releases)
12+
tsm_version: 1.6.2 # No Update # Operator version 1.5.4 (https://github.ibm.com/maximoappsuite/ibm-truststore-mgr/releases)
13+
14+
15+
# Maximo Application Suite
16+
# -----------------------------------------------------------------------------
17+
mas_core_version:
18+
9.1.x-feature: 9.1.0-pre.stable_9718 # tbc
19+
9.0.x: 9.0.11 # tbc
20+
8.10.x: "" # Not Supported
21+
8.11.x: "" # Not Supported
22+
mas_manage_version:
23+
9.1.x-feature: 9.1.0-pre.stable_10993 # tbc
24+
9.0.x: 9.0.13 # tbc
25+
8.10.x: "" # Not Supported
26+
8.11.x: "" # Not Supported
27+
28+
# Extra Images for UDS
29+
# ------------------------------------------------------------------------------
30+
uds_extras_version: 1.5.0
31+
32+
# Extra Images for Mongo
33+
# ------------------------------------------------------------------------------
34+
mongo_extras_version_default: 7.0.12
35+
36+
# Variables used to mirror additional mongo image versions
37+
mongo_extras_version_4: 4.4.21
38+
mongo_extras_version_5: 5.0.23
39+
mongo_extras_version_6: 6.0.12
40+
mongo_extras_version_7: 7.0.12

0 commit comments

Comments
 (0)