Skip to content

Commit

Permalink
Clean up logics for OpenShift
Browse files Browse the repository at this point in the history
  • Loading branch information
mershad-manesh committed Aug 16, 2023
1 parent 170f3a9 commit 4d72d20
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 17 deletions.
34 changes: 21 additions & 13 deletions horizon/scripts/onms-core-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
# KAFKA_SASL_PASSWORD
# KAFKA_SASL_USERNAME
# KAFKA_SECURITY_PROTOCOL
# OPENSHIFT_ENVIRONMENT
# OPENNMS_ADMIN_PASS
# OPENNMS_DATABASE_CONNECTION_MAXPOOL
# OPENNMS_DBNAME
Expand Down Expand Up @@ -77,19 +78,26 @@ OPENNMS_DATABASE_CONNECTION_MAXPOOL=${OPENNMS_DATABASE_CONNECTION_MAXPOOL-50}
KAFKA_SASL_MECHANISM=${KAFKA_SASL_MECHANISM-PLAIN}
KAFKA_SECURITY_PROTOCOL=${KAFKA_SECURITY_PROTOCOL-SASL_PLAINTEXT}

# See if we can get the OpenNMS package name and version from the package manager
if command -v rpm >/dev/null 2>&1; then
PKG=$(rpm -qa | egrep '(meridian|opennms)-core')
VERSION=$(rpm -q --queryformat '%{VERSION}' $PKG)
elif command -v dpkg-query >/dev/null 2>&1; then
if PKG=$(dpkg-query -f '${Package}\n' -W | grep -Fx -e opennms-common -e meridian-common); then
VERSION=$(dpkg-query -f '${Version}\n' -W "${PKG}")
else
PKG="unknown"
fi
else
PKG="unknown"
fi

if [[ $OPENSHIFT_ENVIRONMENT ]];then
echo "Running on OpenShift environment!"
PKG=$(unzip -q -c "/opt/opennms/lib/opennms_install.jar" installer.properties | grep "install.package.name" | cut -d '=' -f 2)
VERSION=$(tail -1 "/opt/opennms/jetty-webapps/opennms/WEB-INF/version.properties" | cut -d '=' -f 2)
#else
## See if we can get the OpenNMS package name and version from the package manager
#if command -v rpm >/dev/null 2>&1; then
# PKG=$(rpm -qa | egrep '(meridian|opennms)-core')
# VERSION=$(rpm -q --queryformat '%{VERSION}' $PKG)
#elif command -v dpkg-query >/dev/null 2>&1; then
# if PKG=$(dpkg-query -f '${Package}\n' -W | grep -Fx -e opennms-common -e meridian-common); then
# VERSION=$(dpkg-query -f '${Version}\n' -W "${PKG}")
# else
# PKG="unknown"
# fi
#else
# PKG="unknown"
#fi
fi

if [[ "${PKG}" == "unknown" ]]; then
if [[ ! -e jetty-webapps/opennms/WEB-INF/version.properties ]]; then
Expand Down
1 change: 1 addition & 0 deletions horizon/templates/app-settings.configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ data:
ENABLE_CORTEX: {{ ((.Values.core).configuration).enableCortex | quote }}
ENABLE_TSS_DUAL_WRITE: {{ ((.Values.core).configuration).enableTssDualWrite | quote }}
ENABLE_GRAFANA: {{ if gt ((.Values.grafana).replicaCount|int) 0 }}"true"{{ else }}"false"{{ end }}
OPENSHIFT_ENVIRONMENT: {{ include "onOpenShift" . | quote }}
OPENNMS_INSTANCE_ID: {{ .Release.Name | quote }}
OPENNMS_SERVER: {{ printf "onms-core.%s.svc" .Release.Name | quote }}
OPENNMS_DBNAME: {{ printf "%s_opennms" .Release.Name | quote }}
Expand Down
4 changes: 3 additions & 1 deletion horizon/templates/opennms-core.route.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if eq (include "omOpenShift" .) "true" }}
kind: Route
apiVersion: route.openshift.io/v1
metadata:
Expand Down Expand Up @@ -31,4 +32,5 @@ status:
status: 'True'
#lastTransitionTime: '2023-08-10T14:16:19Z'
wildcardPolicy: None
routerCanonicalHostname: router-default.apps-crc.testing
routerCanonicalHostname: router-default.apps-crc.testing
{{- end }}
2 changes: 1 addition & 1 deletion horizon/templates/opennms-core.sa.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if include "onOpenShift" . }}
{{- if eq (include "omOpenShift" .) "true" }}
apiVersion: v1
kind: ServiceAccount
metadata:
Expand Down
2 changes: 1 addition & 1 deletion horizon/templates/opennms-core.scc.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if include "onOpenShift" . }}
{{- if eq (include "omOpenShift" .) "true" }}
---
kind: SecurityContextConstraints
metadata:
Expand Down
3 changes: 2 additions & 1 deletion horizon/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
"",
"32.0.0",
"32.0.1",
"32.0.2"
"32.0.2",
"bleeding"
]
}
}
Expand Down

0 comments on commit 4d72d20

Please sign in to comment.