Standardize app configs

Fixed versioning and adjusted some build files
to bring them as close to a standard as possible.

- Removed centos files
- Added version tracking via GITREVCOUNT
- Fixed mismatch in plugin name, set to python3-k8sapp-<app>
- Standardized plugin debian files (rules, *.install)
- Plugin wheels saved to /plugin instead of /plugin/<app>

Test Plan:
PASS - Build-pkgs -a
PASS - Build-image
PASS - Install, bootstrap, unlock
PASS - app tarball contains wheel file
PASS - wheel versioning updated properly

Story: 2010542
Task: 47178

Signed-off-by: Leonardo Fagundes Luz Serrano <Leonardo.FagundesLuzSerrano@windriver.com>
Change-Id: Ie78d5685b973a30bc253068968b46833952c112b
This commit is contained in:
Leonardo Fagundes Luz Serrano 2022-12-21 06:47:09 -03:00
parent e8b3436b1d
commit bae091977c
54 changed files with 54 additions and 309 deletions

View File

@ -26,11 +26,11 @@
- starlingx/update
- starlingx/utilities
files:
- python-k8sapp-snmp/k8sapp_snmp/*
- python3-k8sapp-snmp/k8sapp_snmp/*
vars:
tox_envlist: py39
python_version: 3.9
tox_extra_args: -c python-k8sapp-snmp/k8sapp_snmp/tox.ini
tox_extra_args: -c python3-k8sapp-snmp/k8sapp_snmp/tox.ini
- job:
name: stx-snmp-armada-app-upload-git-mirror
parent: upload-git-mirror
@ -56,10 +56,10 @@
- starlingx/update
- starlingx/utilities
files:
- python-k8sapp-snmp/*
- python3-k8sapp-snmp/*
vars:
tox_envlist: pylint
tox_extra_args: -c python-k8sapp-snmp/k8sapp_snmp/tox.ini
tox_extra_args: -c python3-k8sapp-snmp/k8sapp_snmp/tox.ini
- secret:
name: stx-snmp-armada-app-github-secret

View File

@ -1 +0,0 @@
flock

View File

@ -1 +0,0 @@
stx-snmp-helm

View File

@ -1,2 +0,0 @@
stx-snmp-helm
python-k8sapp-snmp

View File

@ -1,2 +0,0 @@
stx-snmp-helm
python-k8sapp-snmp

View File

@ -1 +0,0 @@
stx-snmp-helm

View File

@ -1,2 +1,2 @@
python-k8sapp-snmp
python3-k8sapp-snmp
stx-snmp-helm

View File

@ -1,3 +0,0 @@
SRC_DIR="k8sapp_snmp"
TIS_PATCH_VER=PKG_GITREVCOUNT

View File

@ -1,52 +0,0 @@
%global app_name snmp
%global pypi_name k8sapp-snmp
%global sname k8sapp_snmp
Name: python-%{pypi_name}
Version: 1.0
Release: %{tis_patch_ver}%{?_tis_dist}
Summary: StarlingX sysinv extensions: Snmp
License: Apache-2.0
Source0: %{name}-%{version}.tar.gz
BuildArch: noarch
BuildRequires: python-setuptools
BuildRequires: python-pbr
BuildRequires: python2-pip
BuildRequires: python2-wheel
%description
StarlingX sysinv extensions: SNMP K8S app
%prep
%setup
# Remove bundled egg-info
rm -rf %{pypi_name}.egg-info
%build
export PBR_VERSION=%{version}
%{__python2} setup.py build
%py2_build_wheel
%install
export PBR_VERSION=%{version}.%{tis_patch_ver}
export SKIP_PIP_INSTALL=1
%{__python2} setup.py install --skip-build --root %{buildroot}
mkdir -p ${RPM_BUILD_ROOT}/plugins/%{app_name}
install -m 644 dist/*.whl ${RPM_BUILD_ROOT}/plugins/%{app_name}/
%files
%{python2_sitelib}/%{sname}
%{python2_sitelib}/%{sname}-*.egg-info
%package wheels
Summary: %{name} wheels
%description wheels
Contains python wheels for %{name}
%files wheels
/plugins/*

View File

@ -1,2 +0,0 @@
usr/lib/python3/dist-packages/k8sapp_snmp-1.0.0.egg-info/*
usr/lib/python3/dist-packages/k8sapp_snmp/*

View File

@ -1,26 +0,0 @@
#!/usr/bin/make -f
# export DH_VERBOSE = 1
export APP_NAME=snmp
export PBR_VERSION=1.0.0
export PYBUILD_NAME=k8sapp-snmp
export ROOT=$(CURDIR)/debian/tmp
export SKIP_PIP_INSTALL=1
%:
dh $@ --with=python3 --buildsystem=pybuild
override_dh_auto_build:
python3 setup.py build
override_dh_auto_install:
python3 setup.py install --install-layout=deb --skip-build --root $(ROOT)
python3 setup.py bdist_wheel \
--universal \
-d $(ROOT)/plugins/$(APP_NAME)
ifeq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS)))
override_dh_auto_test:
# (tbogue) FIXME
PYTHONDIR=$(CURDIR) stestr run || true
endif

View File

@ -1,7 +0,0 @@
---
debname: python3-k8sapp-snmp
debver: 1.0-1
src_path: k8sapp_snmp
revision:
dist: $STX_DIST
PKG_GITREVCOUNT: true

View File

@ -0,0 +1 @@
plugins/*.whl

View File

@ -0,0 +1 @@
usr/lib/python3/dist-packages/k8sapp_*

View File

@ -0,0 +1,33 @@
#!/usr/bin/make -f
# export DH_VERBOSE = 1
export APP_NAME = snmp
export PYBUILD_NAME = k8sapp-snmp
export DEB_VERSION = $(shell dpkg-parsechangelog | egrep '^Version:' | cut -f 2 -d ' ')
export MAJOR = $(shell echo $(DEB_VERSION) | cut -f 1 -d '-')
export MINOR_PATCH = $(shell echo $(DEB_VERSION) | cut -f 4 -d '.')
export PBR_VERSION = $(MAJOR).$(MINOR_PATCH)
export ROOT = $(CURDIR)/debian/tmp
export SKIP_PIP_INSTALL = 1
%:
dh $@ --with=python3 --buildsystem=pybuild
override_dh_auto_install:
env | sort
python3 setup.py install \
--install-layout=deb \
--root $(ROOT)
python3 setup.py bdist_wheel \
--universal \
-d $(ROOT)/plugins
override_dh_python3:
dh_python3 --shebang=/usr/bin/python3
override_dh_auto_test:
PYTHONDIR=$(CURDIR) stestr run

View File

@ -0,0 +1,9 @@
---
debname: python3-k8sapp-snmp
debver: 1.0-1
src_path: k8sapp_snmp
revision:
dist: $STX_DIST
GITREVCOUNT:
SRC_DIR: ${MY_REPO}/stx/snmp-armada-app
BASE_SRCREV: be277c83a95fecc4f029e7af8844ba9de1f630fb

View File

@ -41,5 +41,5 @@ systemconfig.armada.manifest_ops =
systemconfig.app_lifecycle =
snmp = k8sapp_snmp.lifecycle.lifecycle_snmp:SnmpAppLifecycleOperator
[wheel]
[bdist_wheel]
universal = 1

View File

@ -1,7 +0,0 @@
SRC_DIR="stx-snmp-helm"
TAR_NAME=helm-charts-snmp-0-1-0
VERSION=1.0.0
TAR="$TAR_NAME.tar.gz"
TIS_PATCH_VER=PKG_GITREVCOUNT

View File

@ -1,4 +0,0 @@
BUILDER=docker
LABEL=stx-fm-subagent
DOCKER_CONTEXT=../docker/stx-fm-subagent
DOCKER_FILE=../docker/stx-fm-subagent/Dockerfile.centos

View File

@ -1,4 +0,0 @@
BUILDER=docker
LABEL=stx-fm-trap-subagent
DOCKER_CONTEXT=../docker/stx-fm-trap-subagent
DOCKER_FILE=../docker/stx-fm-trap-subagent/Dockerfile.centos

View File

@ -1,4 +0,0 @@
BUILDER=docker
LABEL=stx-snmp
DOCKER_CONTEXT=../docker/stx-snmp
DOCKER_FILE=../docker/stx-snmp/Dockerfile.centos

View File

@ -1,82 +0,0 @@
# Application tunables (maps to metadata)
%global app_name snmp
%global helm_repo stx-platform
# Install location
%global app_folder /usr/local/share/applications/helm
# Build variables
%global helm_folder /usr/lib/helm
%global toolkit_version 0.1.0
Summary: StarlingX SNMP FluxCD Helm Charts
Name: stx-snmp-helm
Version: 1.0
Release: %{tis_patch_ver}%{?_tis_dist}
License: Apache-2.0
Group: base
Packager: Wind River <info@windriver.com>
URL: unknown
Source0: helm-charts-snmp-0-1-0.tar.gz
BuildArch: noarch
BuildRequires: helm
BuildRequires: python-k8sapp-snmp
BuildRequires: python-k8sapp-snmp-wheels
%description
StarlingX SNMP Helm Charts
%prep
%setup -n helm-charts-snmp-0-1-0-1.0.0
%build
cd helm-charts
make
# switch back to source root
cd -
# Create a chart tarball compliant with sysinv kube-app.py
%define app_staging %{_builddir}/staging
%define app_tarball_fluxcd %{app_name}-%{version}-%{tis_patch_ver}.tgz
# Setup staging
mkdir -p %{app_staging}
cp files/metadata.yaml %{app_staging}
mkdir -p %{app_staging}/charts
cp helm-charts/*.tgz %{app_staging}/charts
# Populate metadata
sed -i 's/@APP_NAME@/%{app_name}/g' %{app_staging}/metadata.yaml
sed -i 's/@APP_VERSION@/%{version}-%{tis_patch_ver}/g' %{app_staging}/metadata.yaml
sed -i 's/@HELM_REPO@/%{helm_repo}/g' %{app_staging}/metadata.yaml
# Copy the plugins: installed in the buildroot
mkdir -p %{app_staging}/plugins
cp /plugins/%{app_name}/*.whl %{app_staging}/plugins
cp -R fluxcd-manifests %{app_staging}/
# calculate checksum of all files in app_staging
cd %{app_staging}
find . -type f ! -name '*.md5' -print0 | xargs -0 md5sum > checksum.md5
# package fluxcd app
tar -zcf %{_builddir}/%{app_tarball_fluxcd} -C %{app_staging}/ .
# switch back to source root
cd -
# Cleanup staging
rm -fr %{app_staging}
%install
install -d -m 755 %{buildroot}/%{app_folder}
install -p -D -m 755 %{_builddir}/%{app_tarball_fluxcd} %{buildroot}/%{app_folder}
%files
%defattr(-,root,root,-)
%{app_folder}/%{app_tarball_fluxcd}

View File

@ -44,7 +44,7 @@ override_dh_auto_build:
# Copy the plugins: installed in the buildroot
mkdir -p $(STAGING_FLUXCD)/plugins
cp /plugins/$(APP_NAME)/*.whl $(STAGING_FLUXCD)/plugins
cp /plugins/*.whl $(STAGING_FLUXCD)/plugins
# Create the app package.
cd $(STAGING_FLUXCD) && find . -type f ! -name '*.md5' -print0 | xargs -0 md5sum > checksum.md5

View File

@ -4,4 +4,6 @@ debver: 1.0-1
src_path: stx-snmp-helm
revision:
dist: $STX_DIST
PKG_GITREVCOUNT: true
GITREVCOUNT:
SRC_DIR: ${MY_REPO}/stx/snmp-armada-app
BASE_SRCREV: be277c83a95fecc4f029e7af8844ba9de1f630fb

View File

@ -1,44 +0,0 @@
ARG BASE
FROM ${BASE} AS stx
RUN yum -y update
RUN yum -y install\
fm-common \
fm-common-dev
FROM centos:7 AS base
RUN yum -y install\
net-snmp \
net-snmp-utils \
python3-setuptools \
libpython2.7 \
python3-devel \
postgresql
WORKDIR /home/sub-agent
COPY --from=stx /usr/lib64/libfmcommon.so.1.0 /usr/lib64/
RUN ln -s /usr/lib64/libfmcommon.so.1.0 /usr/lib64/libfmcommon.so
RUN ln -s /usr/lib64/libfmcommon.so.1.0 /usr/lib64/libfmcommon.so.1
FROM base AS builder
RUN yum -y install\
net-snmp-libs \
net-snmp-devel\
gcc \
make \
uuid
RUN ln -s /usr/lib64/libuuid.so.1.3.0 /usr/lib64/libuuid.so
COPY Makefile .
COPY ./src/* ./src/
COPY --from=stx /usr/include/fmDbAPI.h /usr/include/
COPY --from=stx /usr/include/fmAPI.h /usr/include/
ENV LIB_DIR=/usr/lib64/
RUN make
FROM base AS deployment-env
COPY --from=builder /home/sub-agent/snmpSubAgent .
COPY bootstrap.sh .
RUN chmod 755 bootstrap.sh
ENTRYPOINT ["./bootstrap.sh"]

View File

@ -1,27 +0,0 @@
FROM centos:8 AS builder
RUN sed -i -e 's%^mirrorlist=%#mirrorlist=%' -e 's%^#baseurl=http://mirror%baseurl=https://vault%' /etc/yum.repos.d/*repo
RUN yum -y update && yum upgrade
RUN yum -y install\
net-snmp-libs \
net-snmp-devel \
make
RUN dnf -y --enablerepo=powertools install json-c-devel
WORKDIR /home/trapagent
COPY src/* ./src/
COPY Makefile .
RUN make
FROM centos:8
RUN sed -i -e 's%^mirrorlist=%#mirrorlist=%' -e 's%^#baseurl=http://mirror%baseurl=https://vault%' /etc/yum.repos.d/*repo
RUN yum -y update && yum upgrade
RUN yum -y install\
net-snmp \
net-snmp-utils
WORKDIR /home/trapagent
COPY --from=builder /home/trapagent/wrsAlarmMIB .
COPY bootstrap.sh .
RUN chmod 755 ./bootstrap.sh
ENTRYPOINT ["./bootstrap.sh"]

View File

@ -1,31 +0,0 @@
FROM centos:8 AS builder
RUN sed -i -e 's%^mirrorlist=%#mirrorlist=%' -e 's%^#baseurl=http://mirror%baseurl=https://vault%' /etc/yum.repos.d/*repo
RUN yum -y update
RUN yum -y upgrade
RUN yum -y install \
net-snmp-libs \
net-snmp-devel \
libuuid\
gcc\
make
RUN ln -s /usr/lib64/libuuid.so.1.3.0 /usr/lib64/libuuid.so
WORKDIR /home
COPY ./src/* /home/src/
WORKDIR /home/src/
RUN make -f Makefile
FROM centos:8
RUN sed -i -e 's%^mirrorlist=%#mirrorlist=%' -e 's%^#baseurl=http://mirror%baseurl=https://vault%' /etc/yum.repos.d/*repo
RUN yum -y update
RUN yum -y upgrade
RUN yum -y install\
net-snmp \
net-snmp-utils \
net-snmp-libs
COPY ./mibs/* /usr/share/snmp/mibs/
COPY --from=builder /home/src/libsnmpAuditPlugin.so /usr/lib64/
EXPOSE 161/udp
EXPOSE 162/udp
EXPOSE 705/tcp
CMD /usr/sbin/snmpd $OPTIONDEBUG -f