summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCoprDistGit <infra@openeuler.org>2025-02-14 06:41:17 +0000
committerCoprDistGit <infra@openeuler.org>2025-02-14 06:41:17 +0000
commitf218c22f9c55aa723f02491622b71b91187f0b6b (patch)
treeb59feb31b599077d501bc52e2d7c543c8a248422
parent39352f18ea3d446503b2b77e21f3457f5420cf9d (diff)
automatic import of resalloc
-rw-r--r--.gitignore1
-rw-r--r--cron.hourly3
-rw-r--r--logrotate15
-rwxr-xr-xmerge-hook-logs17
-rw-r--r--resalloc.service16
-rw-r--r--resalloc.spec212
-rw-r--r--sources1
7 files changed, 265 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index e69de29..7a34d37 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1 @@
+/resalloc-4.9.tar.gz
diff --git a/cron.hourly b/cron.hourly
new file mode 100644
index 0000000..0ef168e
--- /dev/null
+++ b/cron.hourly
@@ -0,0 +1,3 @@
+#! /bin/sh
+
+runuser -c '/usr/libexec/resalloc-merge-hook-logs' - resalloc
diff --git a/logrotate b/logrotate
new file mode 100644
index 0000000..f1ff9a3
--- /dev/null
+++ b/logrotate
@@ -0,0 +1,15 @@
+compress
+
+/var/log/resallocserver/main.log {
+ missingok
+ notifempty
+ rotate 4
+ weekly
+ copytruncate
+}
+
+/var/log/resallocserver/hooks.log {
+ missingok
+ rotate 7
+ daily
+}
diff --git a/merge-hook-logs b/merge-hook-logs
new file mode 100755
index 0000000..348527a
--- /dev/null
+++ b/merge-hook-logs
@@ -0,0 +1,17 @@
+#! /bin/sh
+
+export PATH=/usr/bin
+
+hooks_log=/var/log/resallocserver/hooks.log
+
+find /var/log/resallocserver/hooks -type f -mmin +60 \
+ | sort | \
+while read -r file; do
+ {
+ echo "=== $file ==="
+ cat "$file"
+ echo
+ echo
+ } >> "$hooks_log"
+ rm "$file"
+done
diff --git a/resalloc.service b/resalloc.service
new file mode 100644
index 0000000..e29ae38
--- /dev/null
+++ b/resalloc.service
@@ -0,0 +1,16 @@
+[Unit]
+Description=Resource allocator server
+After=network.target
+
+[Service]
+Type=simple
+Restart=always
+RestartSec=5
+User=resalloc
+Group=resalloc
+
+Environment=CONFIG_DIR=/etc/resallocserver
+ExecStart=/usr/bin/resalloc-server
+
+[Install]
+WantedBy=multi-user.target
diff --git a/resalloc.spec b/resalloc.spec
new file mode 100644
index 0000000..936171e
--- /dev/null
+++ b/resalloc.spec
@@ -0,0 +1,212 @@
+%global srcname resalloc
+
+%global sysuser resalloc
+%global sysgroup %sysuser
+%global _logdir %_var/log/%{name}server
+%global _homedir %_sharedstatedir/%{name}server
+
+%global sum Resource allocator for expensive resources
+%global desc \
+The resalloc project aims to help with taking care of dynamically \
+allocated resources, for example ephemeral virtual machines used for \
+the purposes of CI/CD tasks.
+
+
+Name: %srcname
+Summary: %sum - client tooling
+Version: 4.9
+Release: 1
+License: GPL-2.0-or-later
+URL: https://github.com/praiskup/resalloc
+BuildArch: noarch
+
+BuildRequires: make
+BuildRequires: postgresql-server
+
+
+BuildRequires: python3-alembic
+BuildRequires: python3-argparse-manpage
+BuildRequires: python3-devel
+BuildRequires: python3-psycopg2
+BuildRequires: python3-pytest
+BuildRequires: python3-pytest-cov
+BuildRequires: python3-setuptools
+BuildRequires: python3-six
+BuildRequires: python3-sqlalchemy
+BuildRequires: python3-pyyaml
+
+Requires: python3-%srcname = %version-%release
+
+Source0: https://github.com/praiskup/%name/releases/download/v%version/%name-%version.tar.gz
+Source1: resalloc.service
+Source2: logrotate
+Source3: merge-hook-logs
+Source4: cron.hourly
+
+%description
+%desc
+
+The %name package provides the client-side tooling.
+
+
+%package server
+Summary: %sum - server part
+
+Requires: crontabs
+Requires: logrotate
+Requires: python3-%srcname = %version-%release
+Requires: python3-alembic
+Requires: python3-six
+Requires: python3-sqlalchemy
+Requires: python3-yaml
+
+Requires(pre): /usr/sbin/useradd
+%description server
+%desc
+
+The %name-server package provides the resalloc server, and
+some tooling for resalloc administrators.
+
+%package webui
+Summary: %sum - webui part
+
+Requires: python3-%srcname = %version-%release
+Requires: %name-server
+Requires: python3-flask
+Recommends: %name-selinux
+
+%description webui
+%desc
+
+The %name-webui package provides the resalloc webui,
+it shows page with information about resalloc resources.
+
+%package -n python3-%srcname
+Summary: %sum - Python 3 client library
+%{?python_provide:%python_provide python3-%srcname}
+%description -n python3-%srcname
+%desc
+
+The python3-%name package provides Python 3 client library for talking
+to the resalloc server.
+
+
+%package selinux
+Summary: SELinux module for %{name}
+Requires: %name-webui = %version-%release
+# Requires(post): policycoreutils-python
+BuildRequires: selinux-policy-devel
+%{?selinux_requires}
+
+%description selinux
+%desc
+
+%post selinux
+semanage fcontext -a -t httpd_sys_script_exec_t \
+ %_var/www/cgi-%{name} 2>/dev/null || :
+restorecon -R %_var/www/cgi-%{name} || :
+
+
+%prep
+%autosetup -p1 -n %name-%version
+
+
+%build
+%py3_build
+
+
+%install
+%py3_install
+install -d -m 755 %buildroot%_datadir/%{name}webui
+cp -r %{name}webui/templates %buildroot%_datadir/%{name}webui/
+cp -r %{name}webui/static %buildroot%_datadir/%{name}webui/
+
+install -d -m 755 %buildroot%_var/www/
+install -p -m 755 %{name}webui/cgi-resalloc %buildroot%_var/www/cgi-%{name}
+
+mkdir -p %buildroot%_unitdir
+mkdir -p %buildroot%_logdir
+install -p -m 644 %SOURCE1 %buildroot%_unitdir
+install -d -m 700 %buildroot%_homedir
+install -d -m 700 %buildroot%_sysconfdir/logrotate.d
+install -p -m 644 %SOURCE2 %buildroot%_sysconfdir/logrotate.d/resalloc-server
+install -p -m 644 man/resalloc-server.1 %buildroot%_mandir/man1
+install -d -m 755 %buildroot/%_libexecdir
+install -p -m 755 %SOURCE3 %buildroot/%_libexecdir/%name-merge-hook-logs
+install -d %buildroot%_sysconfdir/cron.hourly
+install -p -m 755 %SOURCE4 %buildroot%_sysconfdir/cron.hourly/resalloc
+
+# for now EUR call mock by root user, just skip check
+# need re-enable check when builder run as non-root user
+#%check
+#make check TEST_PYTHONS="python3"
+
+
+# Simplify "alembic upgrade head" actions.
+ln -s "%{python3_sitelib}/%{name}server" %buildroot%_homedir/project
+
+
+%pre server
+user=%sysuser
+group=%sysgroup
+getent group "$user" >/dev/null || groupadd -r "$group"
+getent passwd "$user" >/dev/null || \
+useradd -r -g "$group" -G "$group" -s /bin/bash \
+ -c "resalloc server's user" "$user" \
+ -d "%_homedir"
+
+
+%post server
+%systemd_post resalloc.service
+
+%postun server
+%systemd_postun_with_restart resalloc.service
+
+
+%global doc_files NEWS README
+
+%files
+%doc %doc_files
+%license COPYING
+%{_bindir}/%{name}
+%_mandir/man1/%{name}.1*
+
+
+%files -n python3-%srcname
+%doc %doc_files
+%license COPYING
+%{python3_sitelib}/%{name}
+%{python3_sitelib}/%{name}-*.egg-info
+
+
+%files server
+%doc %doc_files
+%license COPYING
+%{python3_sitelib}/%{name}server
+%{_bindir}/%{name}-server
+%{_bindir}/%{name}-maint
+%{_bindir}/%{name}-check-vm-ip
+%attr(0750, %sysuser, %sysgroup) %dir %{_sysconfdir}/%{name}server
+%config(noreplace) %{_sysconfdir}/%{name}server/*
+%_unitdir/resalloc.service
+%attr(0700, %sysuser, %sysgroup) %dir %_logdir
+%_mandir/man1/%{name}-maint.1*
+%_mandir/man1/%{name}-server.1*
+%attr(0700, %sysuser, %sysgroup) %_homedir
+%config %_sysconfdir/logrotate.d/resalloc-server
+%_libexecdir/resalloc-merge-hook-logs
+%config %attr(0755, root, root) %{_sysconfdir}/cron.hourly/resalloc
+
+%files webui
+%doc %doc_files
+%license COPYING
+%{python3_sitelib}/%{name}webui/
+%_datadir/%{name}webui/
+%_var/www/cgi-%{name}
+
+%files selinux
+
+
+%changelog
+* Tue Mar 21 2023 lichaoran <pkwarcraft@hotmail.comm> - 4.91
+- init package
diff --git a/sources b/sources
new file mode 100644
index 0000000..b43d7ac
--- /dev/null
+++ b/sources
@@ -0,0 +1 @@
+085994083ea5845f40e8ebfdd975c60b resalloc-4.9.tar.gz