Skip to content

Commit

Permalink
[minor] Capture cp4d and components versions (#872)
Browse files Browse the repository at this point in the history
  • Loading branch information
creyesibm authored Apr 4, 2024
1 parent ecc72f6 commit fbd7d74
Showing 1 changed file with 89 additions and 1 deletion.
90 changes: 89 additions & 1 deletion image/cli/app-root/src/finalizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,81 @@ def getKafkaVersion(namespace):
print(f"Unable to determine kafka version: {e}")
return "unknown"

# Get cp4d components versions
# -------------------------------------------------------------------------
def getcp4dCompsVersions():

# Get Analytics Engine Version
# -------------------------------------------------------------------------
try:
crs = dynClient.resources.get(api_version="ae.cpd.ibm.com/v1", kind="AnalyticsEngine")
cr = crs.get(name="analyticsengine-sample", namespace="ibm-cpd")
if cr.status and cr.status.versions.reconciled:
setObject[f"target.AnalyticsEngineVersion"] = cr.status.versions.reconciled
else:
print(f"Unable to determine Analytics Engine version: status.versions.reconciled unavailable")
except Exception as e:
print(f"Unable to determine Analytics Engine version: {e}")

# Get Watson Studio Version
# -------------------------------------------------------------------------
try:
crs = dynClient.resources.get(api_version="ws.cpd.ibm.com/v1beta1", kind="WS")
cr = crs.get(name="ws-cr", namespace="ibm-cpd")
if cr.status and cr.status.versions.reconciled:
setObject[f"target.WatsonStudioVersion"] = cr.status.versions.reconciled
else:
print(f"Unable to determine Watson Studion version: status.versions.reconciled unavailable")
except Exception as e:
print(f"Unable to determine Watson Studio version: {e}")

# Get Watson Discovery Version
# -------------------------------------------------------------------------
try:
crs = dynClient.resources.get(api_version="discovery.watson.ibm.com/v1", kind="WatsonDiscovery")
cr = crs.get(name="wd", namespace="ibm-cpd")
if cr.status and cr.status.versions.reconciled:
setObject[f"target.WatsonDiscoveryVersion"] = cr.status.versions.reconciled
else:
print(f"Unable to determine Watson Discovery version: status.versions.reconciled unavailable")
except Exception as e:
print(f"Unable to determine Watson Discovery version: {e}")

# Get Watson OpenScale Version
# -------------------------------------------------------------------------
try:
crs = dynClient.resources.get(api_version="wos.cpd.ibm.com/v1", kind="WOService")
cr = crs.get(name="openscale-defaultinstance", namespace="ibm-cpd")
if cr.status and cr.status.versions.reconciled:
setObject[f"target.WOServiceVersion"] = cr.status.versions.reconciled
else:
print(f"Unable to determine Watson OpenScale version: status.versions.reconciled unavailable")
except Exception as e:
print(f"Unable to determine Watson OpenScale version: {e}")

# Get SPSS Modeler Version
# -------------------------------------------------------------------------
try:
crs = dynClient.resources.get(api_version="spssmodeler.cpd.ibm.com/v1", kind="Spss")
cr = crs.get(name="spssmodeler", namespace="ibm-cpd")
if cr.status and cr.status.version:
setObject[f"target.SpssVersion"] = cr.status.version
else:
print(f"Unable to determine SPSS Modeler version: status.version unavailable")
except Exception as e:
print(f"Unable to determine SPSS Modeler version: {e}")

# Get Cognos Analytics Version
# -------------------------------------------------------------------------
try:
crs = dynClient.resources.get(api_version="ca.cpd.ibm.com/v1", kind="CAService")
cr = crs.get(name="ca-addon-cr", namespace="ibm-cpd")
if cr.status and cr.status.versions.reconciled:
setObject[f"target.CAServiceVersion"] = cr.status.versions.reconciled
else:
print(f"Unable to determine Cognos Analytics version: status.versions.reconciled unavailable")
except Exception as e:
print(f"Unable to determine Cognos Analytics version: {e}")

# Script start
# -----------------------------------------------------------------------------
Expand Down Expand Up @@ -356,12 +431,25 @@ def getKafkaVersion(namespace):
cr = crs.get(name=f"sls", namespace="ibm-sls")
if cr.status and cr.status.versions:
slsVersion = cr.status.versions.reconciled
print(slsVersion)
setObject[f"target.slsVersion"] = slsVersion
else:
print(f"Unable to determine SLS version: status.versions unavailable")
except Exception as e:
print(f"Unable to determine SLS version: {e}")

# Lookup CP4D version
# -------------------------------------------------------------------------
try:
crs = dynClient.resources.get(api_version="wml.cpd.ibm.com/v1beta1", kind="WmlBase")
cr = crs.get(name=f"wml-cr", namespace="ibm-cpd")
if cr.status and cr.status.versions:
cp4dVersion = cr.status.versions.reconciled
setObject[f"target.cp4dVersion"] = cp4dVersion
getcp4dCompsVersions()
else:
print(f"Unable to determine CP4D version: status.versions unavailable")
except Exception as e:
print(f"Unable to determine CP4D version: {e}")

# Connect to mongoDb
# -------------------------------------------------------------------------
Expand Down

0 comments on commit fbd7d74

Please sign in to comment.