mas-cli 5.1.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of mas-cli might be problematic. Click here for more details.

Files changed (114) hide show
  1. mas/cli/__init__.py +11 -0
  2. mas/cli/aiservice/install/__init__.py +11 -0
  3. mas/cli/aiservice/install/app.py +894 -0
  4. mas/cli/aiservice/install/argBuilder.py +180 -0
  5. mas/cli/aiservice/install/argParser.py +507 -0
  6. mas/cli/aiservice/install/params.py +100 -0
  7. mas/cli/aiservice/install/summarizer.py +134 -0
  8. mas/cli/cli.py +432 -0
  9. mas/cli/displayMixins.py +132 -0
  10. mas/cli/gencfg.py +113 -0
  11. mas/cli/install/__init__.py +11 -0
  12. mas/cli/install/app.py +1316 -0
  13. mas/cli/install/argBuilder.py +465 -0
  14. mas/cli/install/argParser.py +1176 -0
  15. mas/cli/install/catalogs.py +27 -0
  16. mas/cli/install/params.py +172 -0
  17. mas/cli/install/settings/__init__.py +23 -0
  18. mas/cli/install/settings/additionalConfigs.py +227 -0
  19. mas/cli/install/settings/db2Settings.py +252 -0
  20. mas/cli/install/settings/kafkaSettings.py +103 -0
  21. mas/cli/install/settings/manageSettings.py +273 -0
  22. mas/cli/install/settings/mongodbSettings.py +46 -0
  23. mas/cli/install/settings/turbonomicSettings.py +29 -0
  24. mas/cli/install/summarizer.py +398 -0
  25. mas/cli/templates/facilities-configs.yml.j2 +25 -0
  26. mas/cli/templates/ibm-mas-tekton.yaml +49772 -0
  27. mas/cli/templates/jdbccfg.yml.j2 +52 -0
  28. mas/cli/templates/pod-templates/best-effort/ibm-data-dictionary-assetdatadictionary.yml +26 -0
  29. mas/cli/templates/pod-templates/best-effort/ibm-mas-bascfg.yml +56 -0
  30. mas/cli/templates/pod-templates/best-effort/ibm-mas-coreidp.yml +21 -0
  31. mas/cli/templates/pod-templates/best-effort/ibm-mas-iot-actions.yml +28 -0
  32. mas/cli/templates/pod-templates/best-effort/ibm-mas-iot-auth.yml +32 -0
  33. mas/cli/templates/pod-templates/best-effort/ibm-mas-iot-datapower.yml +12 -0
  34. mas/cli/templates/pod-templates/best-effort/ibm-mas-iot-devops.yml +14 -0
  35. mas/cli/templates/pod-templates/best-effort/ibm-mas-iot-dm.yml +22 -0
  36. mas/cli/templates/pod-templates/best-effort/ibm-mas-iot-dsc.yml +40 -0
  37. mas/cli/templates/pod-templates/best-effort/ibm-mas-iot-edgeconfig.yml +10 -0
  38. mas/cli/templates/pod-templates/best-effort/ibm-mas-iot-fpl.yml +24 -0
  39. mas/cli/templates/pod-templates/best-effort/ibm-mas-iot-guardian.yml +20 -0
  40. mas/cli/templates/pod-templates/best-effort/ibm-mas-iot-iot.yml +10 -0
  41. mas/cli/templates/pod-templates/best-effort/ibm-mas-iot-mbgx.yml +18 -0
  42. mas/cli/templates/pod-templates/best-effort/ibm-mas-iot-mfgx.yml +14 -0
  43. mas/cli/templates/pod-templates/best-effort/ibm-mas-iot-monitor.yml +18 -0
  44. mas/cli/templates/pod-templates/best-effort/ibm-mas-iot-orgmgmt.yml +48 -0
  45. mas/cli/templates/pod-templates/best-effort/ibm-mas-iot-provision.yml +28 -0
  46. mas/cli/templates/pod-templates/best-effort/ibm-mas-iot-registry.yml +26 -0
  47. mas/cli/templates/pod-templates/best-effort/ibm-mas-iot-state.yml +40 -0
  48. mas/cli/templates/pod-templates/best-effort/ibm-mas-iot-webui.yml +22 -0
  49. mas/cli/templates/pod-templates/best-effort/ibm-mas-manage-healthextaccelerator.yml +13 -0
  50. mas/cli/templates/pod-templates/best-effort/ibm-mas-manage-healthextworkspace.yml +10 -0
  51. mas/cli/templates/pod-templates/best-effort/ibm-mas-manage-imagestitching.yml +10 -0
  52. mas/cli/templates/pod-templates/best-effort/ibm-mas-manage-manageaccelerators.yml +10 -0
  53. mas/cli/templates/pod-templates/best-effort/ibm-mas-manage-manageapp.yml +46 -0
  54. mas/cli/templates/pod-templates/best-effort/ibm-mas-manage-manageworkspace.yml +48 -0
  55. mas/cli/templates/pod-templates/best-effort/ibm-mas-manage-slackproxy.yml +10 -0
  56. mas/cli/templates/pod-templates/best-effort/ibm-mas-pushnotificationcfg.yml +13 -0
  57. mas/cli/templates/pod-templates/best-effort/ibm-mas-scimcfg.yml +14 -0
  58. mas/cli/templates/pod-templates/best-effort/ibm-mas-slscfg.yml +10 -0
  59. mas/cli/templates/pod-templates/best-effort/ibm-mas-smtpcfg.yml +10 -0
  60. mas/cli/templates/pod-templates/best-effort/ibm-mas-suite.yml +136 -0
  61. mas/cli/templates/pod-templates/best-effort/ibm-mas-visualinspection.yml +34 -0
  62. mas/cli/templates/pod-templates/best-effort/ibm-sls-licenseservice.yml +10 -0
  63. mas/cli/templates/pod-templates/guaranteed/ibm-data-dictionary-assetdatadictionary.yml +56 -0
  64. mas/cli/templates/pod-templates/guaranteed/ibm-mas-bascfg.yml +140 -0
  65. mas/cli/templates/pod-templates/guaranteed/ibm-mas-coreidp.yml +45 -0
  66. mas/cli/templates/pod-templates/guaranteed/ibm-mas-iot-actions.yml +70 -0
  67. mas/cli/templates/pod-templates/guaranteed/ibm-mas-iot-auth.yml +80 -0
  68. mas/cli/templates/pod-templates/guaranteed/ibm-mas-iot-datapower.yml +24 -0
  69. mas/cli/templates/pod-templates/guaranteed/ibm-mas-iot-devops.yml +26 -0
  70. mas/cli/templates/pod-templates/guaranteed/ibm-mas-iot-dm.yml +52 -0
  71. mas/cli/templates/pod-templates/guaranteed/ibm-mas-iot-dsc.yml +106 -0
  72. mas/cli/templates/pod-templates/guaranteed/ibm-mas-iot-edgeconfig.yml +16 -0
  73. mas/cli/templates/pod-templates/guaranteed/ibm-mas-iot-fpl.yml +62 -0
  74. mas/cli/templates/pod-templates/guaranteed/ibm-mas-iot-guardian.yml +44 -0
  75. mas/cli/templates/pod-templates/guaranteed/ibm-mas-iot-iot.yml +16 -0
  76. mas/cli/templates/pod-templates/guaranteed/ibm-mas-iot-mbgx.yml +42 -0
  77. mas/cli/templates/pod-templates/guaranteed/ibm-mas-iot-mfgx.yml +32 -0
  78. mas/cli/templates/pod-templates/guaranteed/ibm-mas-iot-monitor.yml +42 -0
  79. mas/cli/templates/pod-templates/guaranteed/ibm-mas-iot-orgmgmt.yml +126 -0
  80. mas/cli/templates/pod-templates/guaranteed/ibm-mas-iot-provision.yml +70 -0
  81. mas/cli/templates/pod-templates/guaranteed/ibm-mas-iot-registry.yml +62 -0
  82. mas/cli/templates/pod-templates/guaranteed/ibm-mas-iot-state.yml +106 -0
  83. mas/cli/templates/pod-templates/guaranteed/ibm-mas-iot-webui.yml +52 -0
  84. mas/cli/templates/pod-templates/guaranteed/ibm-mas-manage-healthextaccelerator.yml +28 -0
  85. mas/cli/templates/pod-templates/guaranteed/ibm-mas-manage-healthextworkspace.yml +18 -0
  86. mas/cli/templates/pod-templates/guaranteed/ibm-mas-manage-imagestitching.yml +16 -0
  87. mas/cli/templates/pod-templates/guaranteed/ibm-mas-manage-manageaccelerators.yml +16 -0
  88. mas/cli/templates/pod-templates/guaranteed/ibm-mas-manage-manageapp.yml +106 -0
  89. mas/cli/templates/pod-templates/guaranteed/ibm-mas-manage-manageworkspace.yml +126 -0
  90. mas/cli/templates/pod-templates/guaranteed/ibm-mas-manage-slackproxy.yml +16 -0
  91. mas/cli/templates/pod-templates/guaranteed/ibm-mas-pushnotificationcfg.yml +25 -0
  92. mas/cli/templates/pod-templates/guaranteed/ibm-mas-scimcfg.yml +26 -0
  93. mas/cli/templates/pod-templates/guaranteed/ibm-mas-slscfg.yml +16 -0
  94. mas/cli/templates/pod-templates/guaranteed/ibm-mas-smtpcfg.yml +16 -0
  95. mas/cli/templates/pod-templates/guaranteed/ibm-mas-suite.yml +340 -0
  96. mas/cli/templates/pod-templates/guaranteed/ibm-mas-visualinspection.yml +76 -0
  97. mas/cli/templates/pod-templates/guaranteed/ibm-sls-licenseservice.yml +16 -0
  98. mas/cli/templates/suite_mongocfg.yml.j2 +55 -0
  99. mas/cli/uninstall/__init__.py +11 -0
  100. mas/cli/uninstall/app.py +197 -0
  101. mas/cli/uninstall/argParser.py +115 -0
  102. mas/cli/update/__init__.py +11 -0
  103. mas/cli/update/app.py +673 -0
  104. mas/cli/update/argParser.py +156 -0
  105. mas/cli/upgrade/__init__.py +11 -0
  106. mas/cli/upgrade/app.py +164 -0
  107. mas/cli/upgrade/argParser.py +68 -0
  108. mas/cli/upgrade/settings/__init__.py +19 -0
  109. mas/cli/validators.py +151 -0
  110. mas_cli-5.1.4.data/scripts/mas-cli +87 -0
  111. mas_cli-5.1.4.dist-info/METADATA +73 -0
  112. mas_cli-5.1.4.dist-info/RECORD +114 -0
  113. mas_cli-5.1.4.dist-info/WHEEL +5 -0
  114. mas_cli-5.1.4.dist-info/top_level.txt +1 -0
@@ -0,0 +1,132 @@
1
+ # *****************************************************************************
2
+ # Copyright (c) 2024 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
+ from os import getenv
12
+ from prompt_toolkit import prompt, print_formatted_text, HTML, PromptSession
13
+ from prompt_toolkit.completion import WordCompleter
14
+ from prompt_toolkit.validation import Validator
15
+
16
+ from .validators import YesNoValidator, FileExistsValidator, DirectoryExistsValidator
17
+
18
+ import logging
19
+ logger = logging.getLogger(__name__)
20
+
21
+ H1COLOR = "SkyBlue"
22
+ H2COLOR = "SkyBlue"
23
+ DESCRIPTIONCOLOR = "LightSlateGrey"
24
+ SUMMARYCOLOR = "SkyBlue"
25
+ UNDEFINEDPARAMCOLOR = "LightSlateGrey"
26
+ PROMPTCOLOR = "Yellow"
27
+
28
+
29
+ class PrintMixin():
30
+ def printTitle(self, message):
31
+ print_formatted_text(HTML(f"<b><u>{message.replace(' & ', ' &amp; ')}</u></b>"))
32
+
33
+ def printH1(self, message):
34
+ self.h1count += 1
35
+ self.h2count = 0
36
+ print()
37
+ print_formatted_text(HTML(f"<u><{H1COLOR}>{self.h1count}) {message.replace(' & ', ' &amp; ')}</{H1COLOR}></u>"))
38
+
39
+ def printH2(self, message):
40
+ self.h2count += 1
41
+ print()
42
+ print_formatted_text(HTML(f"<u><{H2COLOR}>{self.h1count}.{self.h2count}) {message.replace(' & ', ' &amp; ')}</{H2COLOR}></u>"))
43
+
44
+ def printDescription(self, content: list) -> None:
45
+ content[0] = f"<{DESCRIPTIONCOLOR}>{content[0]}"
46
+ content[len(content) - 1] = f"{content[len(content) - 1]}</{DESCRIPTIONCOLOR}>"
47
+ print_formatted_text(HTML("\n".join(content)))
48
+
49
+ def printHighlight(self, message: str) -> None:
50
+ if isinstance(message, list):
51
+ message = "\n".join(message)
52
+
53
+ print_formatted_text(HTML(f"<MediumTurquoise>{message.replace(' & ', ' &amp; ')}</MediumTurquoise>"))
54
+
55
+ def printWarning(self, message):
56
+ print_formatted_text(HTML(f"<Red>Warning: {message.replace(' & ', ' &amp; ')}</Red>"))
57
+
58
+ def printSummary(self, title: str, value: str) -> None:
59
+ titleLength = len(title)
60
+ message = f"{title} {'.' * (40 - titleLength)} {value}"
61
+ print_formatted_text(HTML(f" <{SUMMARYCOLOR}>{message.replace(' & ', ' &amp; ')}</{SUMMARYCOLOR}>"))
62
+
63
+ def printParamSummary(self, message: str, param: str) -> None:
64
+ if self.getParam(param) is None:
65
+ self.printSummary(message, f"<{UNDEFINEDPARAMCOLOR}>Undefined</{UNDEFINEDPARAMCOLOR}>")
66
+ elif self.getParam(param) == "":
67
+ self.printSummary(message, f"<{UNDEFINEDPARAMCOLOR}>Default</{UNDEFINEDPARAMCOLOR}>")
68
+ else:
69
+ self.printSummary(message, self.getParam(param))
70
+
71
+
72
+ def masPromptYesOrNo(message):
73
+ return HTML(f"<{PROMPTCOLOR}>{message.replace(' & ', ' &amp; ')}? [y/n]</{PROMPTCOLOR}> ")
74
+
75
+
76
+ def masPromptValue(message):
77
+ return HTML(f"<{PROMPTCOLOR}>{message.replace(' & ', ' &amp; ')}</{PROMPTCOLOR}> ")
78
+
79
+
80
+ class PromptMixin():
81
+ def yesOrNo(self, message: str, param: str = None) -> bool:
82
+ response = prompt(masPromptYesOrNo(message), validator=YesNoValidator(), validate_while_typing=False)
83
+ responseAsBool = response.lower() in ["y", "yes"]
84
+
85
+ if param is not None:
86
+ self.params[param] = "true" if responseAsBool else "false"
87
+ return responseAsBool
88
+
89
+ def promptForString(self, message: str, param: str = None, default: str = "", isPassword: bool = False, validator: Validator = None, completer: WordCompleter = None) -> str:
90
+ if param is not None and default == "":
91
+ default = getenv(param.upper(), default="")
92
+
93
+ if completer is not None:
94
+ promptSession = PromptSession()
95
+ response = promptSession.prompt(masPromptValue(message), is_password=isPassword, default=default, completer=completer, validator=validator, validate_while_typing=False, pre_run=promptSession.default_buffer.start_completion)
96
+ else:
97
+ response = prompt(masPromptValue(message), is_password=isPassword, default=default, completer=completer, validator=validator, validate_while_typing=False)
98
+
99
+ if param is not None:
100
+ self.params[param] = response
101
+ return response
102
+
103
+ def promptForInt(self, message: str, param: str = None, default: int = None) -> int:
104
+ if param is not None and default is None:
105
+ default = getenv(param.upper(), default=None)
106
+
107
+ if default is None:
108
+ response = int(prompt(masPromptValue(message)))
109
+ else:
110
+ response = int(prompt(masPromptValue(message), default=str(default)))
111
+ if param is not None:
112
+ self.params[param] = str(response)
113
+ return response
114
+
115
+ def promptForListSelect(self, message: str, options: list, param: str = None, default: int = None) -> str:
116
+ selection = self.promptForInt(message=message, default=default)
117
+ # List indices are 0 origin, so we need to subtract 1 from the selection made to arrive at the correct value
118
+ self.setParam(param, options[selection - 1])
119
+
120
+ def promptForFile(self, message: str, mustExist: bool = True, default: str = "", envVar: str = "") -> None:
121
+ if default == "" and envVar != "":
122
+ default = getenv(envVar, "")
123
+ if mustExist:
124
+ return prompt(masPromptValue(message), validator=FileExistsValidator(), validate_while_typing=False, default=default)
125
+ else:
126
+ return prompt(masPromptValue(message), default=default)
127
+
128
+ def promptForDir(self, message: str, mustExist: bool = True, default: str = "") -> None:
129
+ if mustExist:
130
+ return prompt(masPromptValue(message), validator=DirectoryExistsValidator(), validate_while_typing=False, default=default)
131
+ else:
132
+ return prompt(masPromptValue(message), default=default)
mas/cli/gencfg.py ADDED
@@ -0,0 +1,113 @@
1
+ # *****************************************************************************
2
+ # Copyright (c) 2024 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
+ from os import path
12
+ from jinja2 import Template
13
+ from base64 import b64encode
14
+ from json import loads
15
+
16
+
17
+ class ConfigGeneratorMixin():
18
+ def generateJDBCCfg(self, instanceId: str, scope: str, destination: str, appId: str = "", workspaceId: str = "") -> None:
19
+ templateFile = path.join(self.templatesDir, "jdbccfg.yml.j2")
20
+ with open(templateFile) as tFile:
21
+ template = Template(tFile.read())
22
+
23
+ if scope == "workspace-application":
24
+ assert appId != ""
25
+ assert workspaceId != ""
26
+
27
+ name = self.promptForString("Configuration Display Name")
28
+ url = self.promptForString("JDBC Connection String")
29
+
30
+ username = self.promptForString("JDBC Username")
31
+ password = self.promptForString("JDBC Password", isPassword=True)
32
+
33
+ sslEnabled = self.yesOrNo("Enable SSL Connection")
34
+
35
+ if sslEnabled:
36
+ sslCertFile = self.promptForFile("Path to certificate file")
37
+ with open(sslCertFile) as cFile:
38
+ certLocalFileContent = cFile.read()
39
+ else:
40
+ certLocalFileContent = ""
41
+
42
+ cfg = template.render(
43
+ scope=scope,
44
+
45
+ mas_instance_id=instanceId,
46
+ mas_workspace_id=workspaceId,
47
+ mas_application_id=appId,
48
+
49
+ cfg_display_name=name,
50
+
51
+ jdbc_url=url,
52
+ jdbc_username=username,
53
+ jdbc_password=password,
54
+
55
+ jdbc_ssl_enabled=sslEnabled,
56
+ jdbc_cert_local_file_content=certLocalFileContent
57
+ )
58
+
59
+ with open(destination, 'w') as f:
60
+ f.write(cfg)
61
+ f.write('\n')
62
+
63
+ def generateMongoCfg(self, instanceId: str, destination: str) -> None:
64
+ templateFile = path.join(self.templatesDir, "suite_mongocfg.yml.j2")
65
+
66
+ with open(templateFile) as tFile:
67
+ template = Template(tFile.read())
68
+
69
+ name = self.promptForString("Configuration Display Name")
70
+ hosts = self.promptForString("MongoDb Hosts (comma-separated list)")
71
+
72
+ username = self.promptForString("MongoDb Username")
73
+ password = self.promptForString("MongoDb Password", isPassword=True)
74
+ encoded_username = b64encode(username.encode('ascii')).decode("ascii")
75
+ encoded_password = b64encode(password.encode('ascii')).decode("ascii")
76
+ sslCertFile = self.promptForFile("Path to certificate file")
77
+ with open(sslCertFile) as cFile:
78
+ certLocalFileContent = cFile.read()
79
+
80
+ cfg = template.render(
81
+ mas_instance_id=instanceId,
82
+ cfg_display_name=name,
83
+ mongodb_hosts=hosts,
84
+ mongodb_admin_username=encoded_username,
85
+ mongodb_admin_password=encoded_password,
86
+ mongodb_ca_pem_local_file=certLocalFileContent
87
+ )
88
+
89
+ with open(destination, 'w') as f:
90
+ f.write(cfg)
91
+ f.write('\n')
92
+
93
+ def generateFacilitiesCfg(self, destination: str) -> None:
94
+ templateFile = path.join(self.templatesDir, "facilities-configs.yml.j2")
95
+
96
+ with open(templateFile) as tFile:
97
+ template = Template(tFile.read())
98
+
99
+ dwfagents = self.getParam("mas_ws_facilities_dwfagents")
100
+ maxconnpoolsize = self.getParam("mas_ws_facilities_db_maxconnpoolsize")
101
+ userfiles_size = self.getParam("mas_ws_facilities_storage_userfiles_size")
102
+ log_size = self.getParam("mas_ws_facilities_storage_log_size")
103
+ cfg = template.render(
104
+ mas_instance_id=self.getParam("mas_instance_id"),
105
+ mas_ws_facilities_storage_log_size=log_size if log_size != "" else 30,
106
+ mas_ws_facilities_storage_userfiles_size=userfiles_size if userfiles_size != "" else 50,
107
+ mas_ws_facilities_db_maxconnpoolsize=maxconnpoolsize if maxconnpoolsize != "" else 200,
108
+ mas_ws_facilities_dwfagents=loads(dwfagents) if dwfagents != '' else ''
109
+ )
110
+
111
+ with open(destination, 'w') as f:
112
+ f.write(cfg)
113
+ f.write('\n')
@@ -0,0 +1,11 @@
1
+ # *****************************************************************************
2
+ # Copyright (c) 2024 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
+ from ..cli import BaseApp # noqa: F401