Skip to content

Commit

Permalink
[patch] Fix SLS flow again
Browse files Browse the repository at this point in the history
  • Loading branch information
Rawa Resul committed Jan 24, 2025
1 parent bd53ef2 commit 3d4ecff
Showing 1 changed file with 21 additions and 22 deletions.
43 changes: 21 additions & 22 deletions python/src/mas/cli/install/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

from mas.devops.ocp import createNamespace, getStorageClasses
from mas.devops.mas import getCurrentCatalog, getDefaultStorageClasses
from mas.devops.sls import listSLSInstances, findSLSByNamespace
from mas.devops.sls import findSLSByNamespace
from mas.devops.data import getCatalog
from mas.devops.tekton import (
installOpenShiftPipelines,
Expand Down Expand Up @@ -261,6 +261,7 @@ def configSLS(self) -> None:
]
)

self.slsMode = 1
self.slsLicenseFileLocal = None

if self.showAdvancedOptions:
Expand All @@ -271,32 +272,27 @@ def configSLS(self) -> None:
" 2. Install MAS with Dedicated License (AppPoints)",
]
)
slsMode = self.promptForInt("SLS Mode", default=1)
self.slsMode = self.promptForInt("SLS Mode", default=1)

if slsMode == 1:
if self.slsMode == 1:
self.setParam("sls_namespace", "ibm-sls")
elif slsMode == 2:
if not self.getParam("sls_namespace"):
self.setParam("sls_namespace", f"mas-{self.getParam('mas_instance_id')}-sls")
elif self.slsMode == 2:
pass
# We may not have mas_instance_id yet and will need to set sls_namespace within configMAS()
else:
self.fatalError(f"Invalid selection: {slsMode}")

sls_namespace = "ibm-sls" if not self.getParam("sls_namespace") else self.getParam("sls_namespace")
existingSLSInstances = listSLSInstances(self.dynamicClient)
numSLSInstances = len(existingSLSInstances)
self.fatalError(f"Invalid selection: {self.slsMode}")

if numSLSInstances > 0:
if findSLSByNamespace(sls_namespace, instances=existingSLSInstances):
if not (self.slsMode == 2 and not self.getParam("mas_instance_id")):
sls_namespace = "ibm-sls" if not self.getParam("sls_namespace") else self.getParam("sls_namespace")
if findSLSByNamespace(sls_namespace, dynClient=self.dynamicClient):
print_formatted_text(HTML(f"<MediumSeaGreen>SLS auto-detected: {sls_namespace}</MediumSeaGreen>"))
print()
if self.yesOrNo("Upload/Replace the license file"):
self.slsLicenseFileLocal = self.promptForFile("License file", mustExist=True, envVar="SLS_LICENSE_FILE_LOCAL")
self.setParam("sls_action", "install")
else:
self.setParam("sls_action", "gencfg")
else:
self.slsLicenseFileLocal = self.promptForFile("License file", mustExist=True, envVar="SLS_LICENSE_FILE_LOCAL")
self.setParam("sls_action", "install")
if not self.yesOrNo("Upload/Replace the license file"):
self.setParam("sls_action", "gencfg")
return

self.slsLicenseFileLocal = self.promptForFile("License file", mustExist=True, envVar="SLS_LICENSE_FILE_LOCAL")
self.setParam("sls_action", "install")

@logMethodCall
def configDRO(self) -> None:
Expand Down Expand Up @@ -425,6 +421,9 @@ def configMAS(self):
])
self.promptForString("Workspace name", "mas_workspace_name", validator=WorkspaceNameFormatValidator())

if self.slsMode == 2 and not self.getParam("sls_namespace"):
self.setParam("sls_namespace", f"mas-{self.getParam('mas_instance_id')}-sls")

self.configOperationMode()
self.configCATrust()
self.configDNSAndCerts()
Expand Down Expand Up @@ -991,7 +990,7 @@ def nonInteractiveMode(self) -> None:

# License file is only optional for existing SLS instance
if self.slsLicenseFileLocal is None:
if findSLSByNamespace(self.getParam("sls_namespace"), dynClient= self.dynamicClient):
if findSLSByNamespace(self.getParam("sls_namespace"), dynClient=self.dynamicClient):
self.setParam("sls_action", "gencfg")
else:
self.fatalError(f"--license-file must be set for new SLS install")
Expand Down

0 comments on commit 3d4ecff

Please sign in to comment.