diff --git a/python-k8sapp-snmp/k8sapp_snmp/k8sapp_snmp/helm/snmp.py b/python-k8sapp-snmp/k8sapp_snmp/k8sapp_snmp/helm/snmp.py index d042168..e6e141b 100644 --- a/python-k8sapp-snmp/k8sapp_snmp/k8sapp_snmp/helm/snmp.py +++ b/python-k8sapp-snmp/k8sapp_snmp/k8sapp_snmp/helm/snmp.py @@ -1,10 +1,11 @@ # -# Copyright (c) 2020-2021 Wind River Systems, Inc. +# Copyright (c) 2020-2022 Wind River Systems, Inc. # # SPDX-License-Identifier: Apache-2.0 # import keyring +import sys from k8sapp_snmp.common import constants as app_constants from os import uname @@ -17,7 +18,8 @@ from sysinv.db import api from sysinv.helm import base from sysinv.helm import common - +PY2 = sys.version_info[0] == 2 +PY3 = sys.version_info[0] == 3 class SnmpHelm(base.BaseHelm): """Class to encapsulate helm operations for the SNMP chart""" @@ -59,7 +61,14 @@ class SnmpHelm(base.BaseHelm): # get_password() returns in unicode format, which leads to YAML # that Armada doesn't like. Converting to UTF-8 is safe because # we generated the password originally. - return password.encode('utf8', 'strict') + # Update Debian: in Python3, using encode produces error connection + # to database. + ret_password = '' + if PY2: + ret_password = password.encode('utf8', 'strict') + if PY3: + ret_password = password + return ret_password def _get_database_connection(self): host_url = self._format_url_address(self._get_management_address()) diff --git a/stx-snmp-helm/debian/deb_folder/rules b/stx-snmp-helm/debian/deb_folder/rules index e485b9c..631ded4 100755 --- a/stx-snmp-helm/debian/deb_folder/rules +++ b/stx-snmp-helm/debian/deb_folder/rules @@ -10,38 +10,82 @@ export MINOR_PATCH = $(shell echo $(DEB_VERSION) | cut -f 2 -d '.') export APP_NAME = snmp export APP_VERSION = $(MAJOR).$(MINOR_PATCH) -export APP_TARBALL = $(APP_NAME)-$(APP_VERSION).tgz +export APP_TARBALL_ARMADA = $(APP_NAME)-armada-$(APP_VERSION).tgz +export APP_TARBALL_FLUXCD = $(APP_NAME)-$(APP_VERSION).tgz export HELM_REPO = stx-platform -export STAGING = staging +export STAGING_ARMADA = staging-armada +export STAGING_FLUXCD = staging-fluxcd %: dh $@ override_dh_auto_build: + + ############ + # COMMON # + ############ # Create the TGZ file. cd helm-charts && make + + ############ + # ARMADA # + ############ # Setup the staging directory. - mkdir -p $(STAGING) - cp files/metadata.yaml $(STAGING) - cp manifests/*.yaml $(STAGING) - mkdir -p $(STAGING)/charts - cp helm-charts/*.tgz $(STAGING)/charts + mkdir -p $(STAGING_ARMADA) + cp files/metadata.yaml $(STAGING_ARMADA) + cp manifests/*.yaml $(STAGING_ARMADA) + mkdir -p $(STAGING_ARMADA)/charts + cp helm-charts/*.tgz $(STAGING_ARMADA)/charts + # Populate metadata. - sed -i 's/@APP_NAME@/$(APP_NAME)/g' $(STAGING)/metadata.yaml - sed -i 's/@APP_VERSION@/$(APP_VERSION)/g' $(STAGING)/metadata.yaml - sed -i 's/@HELM_REPO@/$(HELM_REPO)/g' $(STAGING)/metadata.yaml + cd $(STAGING_ARMADA) + sed -i 's/@APP_NAME@/$(APP_NAME)/g' $(STAGING_ARMADA)/metadata.yaml + sed -i 's/@APP_VERSION@/$(APP_VERSION)/g' $(STAGING_ARMADA)/metadata.yaml + sed -i 's/@HELM_REPO@/$(HELM_REPO)/g' $(STAGING_ARMADA)/metadata.yaml + # Copy the plugins: installed in the buildroot - mkdir -p $(STAGING)/plugins - cp /plugins/$(APP_NAME)/*.whl $(STAGING)/plugins + mkdir -p $(STAGING_ARMADA)/plugins + cp /plugins/$(APP_NAME)/*.whl $(STAGING_ARMADA)/plugins + # Create the app package. - cd $(STAGING) && find . -type f ! -name '*.md5' -print0 | xargs -0 md5sum > checksum.md5 - tar cfz $(APP_TARBALL) -C $(STAGING)/ . + cd $(STAGING_ARMADA) && find . -type f ! -name '*.md5' -print0 | xargs -0 md5sum > checksum.md5 + tar cfz $(APP_TARBALL_ARMADA) -C $(STAGING_ARMADA)/ . + # Cleanup staging. - rm -rf $(STAGING) + rm -rf $(STAGING_ARMADA) + + ############ + # FLUXCD # + ############ + + # Setup the staging directory for fluxcd package. + mkdir -p $(STAGING_FLUXCD) + cp files/metadata.yaml $(STAGING_FLUXCD) + cp -R fluxcd-manifests $(STAGING_FLUXCD) + mkdir -p $(STAGING_FLUXCD)/charts + cp helm-charts/*.tgz $(STAGING_FLUXCD)/charts + + # Populate metadata. + cd $(STAGING_FLUXCD) + sed -i 's/@APP_NAME@/$(APP_NAME)/g' $(STAGING_FLUXCD)/metadata.yaml + sed -i 's/@APP_VERSION@/$(APP_VERSION)/g' $(STAGING_FLUXCD)/metadata.yaml + sed -i 's/@HELM_REPO@/$(HELM_REPO)/g' $(STAGING_FLUXCD)/metadata.yaml + + # Copy the plugins: installed in the buildroot + mkdir -p $(STAGING_FLUXCD)/plugins + cp /plugins/$(APP_NAME)/*.whl $(STAGING_FLUXCD)/plugins + + # Create the app package. + cd $(STAGING_FLUXCD) && find . -type f ! -name '*.md5' -print0 | xargs -0 md5sum > checksum.md5 + tar cfz $(APP_TARBALL_FLUXCD) -C $(STAGING_FLUXCD)/ . + + # Cleanup staging. + rm -rf $(STAGING_FLUXCD) override_dh_auto_install: # Install the app tar file. install -d -m 755 $(APP_FOLDER) - install -p -D -m 755 $(APP_TARBALL) $(APP_FOLDER) + install -p -D -m 755 $(APP_TARBALL_ARMADA) $(APP_FOLDER) + install -p -D -m 755 $(APP_TARBALL_FLUXCD) $(APP_FOLDER) override_dh_usrlocal: