From a771a9d72cee8a4167ab7b3453591f6682352425 Mon Sep 17 00:00:00 2001 From: Nadav Goldin Date: Mon, 26 Sep 2016 11:06:26 +0300 Subject: [PATCH] Auto-generate lago.conf in RPM spec file This will install the auto-generated lago.conf inside /etc/lago/lago.conf, all commented-out. --- etc/lago.d/lago.conf | 13 ------------- lago.spec.in | 41 ++++++++++++++++++++++++++++++++--------- lago/plugins/vm.py | 1 + setup.cfg | 1 - 4 files changed, 33 insertions(+), 23 deletions(-) delete mode 100644 etc/lago.d/lago.conf diff --git a/etc/lago.d/lago.conf b/etc/lago.d/lago.conf deleted file mode 100644 index eceb7666..00000000 --- a/etc/lago.d/lago.conf +++ /dev/null @@ -1,13 +0,0 @@ -[lago] -default_root_password = 123456 -default_vm_provider = local-libvirt -default_vm_type = default -libvirt_url = qemu:///system -log_level = debug -ssh_timeout = 10 -ssh_tries = 100 -template_repos = /var/lib/lago/repos -template_store = /var/lib/lago/store -lease_dir = /var/lib/lago/subnets -libvirt_username = -libvirt_password = diff --git a/lago.spec.in b/lago.spec.in index 7f516515..ddc0eb7d 100644 --- a/lago.spec.in +++ b/lago.spec.in @@ -19,17 +19,20 @@ Deploy and tear down environments of several virtual machines %setup -q -n %{name}-%{version} %build -LAGO_VERSION=%{version} %{__python} setup.py build +LAGO_VERSION=%{version} %{py2_build} %install -LAGO_VERSION=%{version} %{__python} setup.py install --root $RPM_BUILD_ROOT -cd "$RPM_BUILD_DIR" - -install -d "$RPM_BUILD_ROOT"/var/lib/lago/subnets -install -d "$RPM_BUILD_ROOT"/var/lib/lago/store -install -d "$RPM_BUILD_ROOT"/var/lib/lago/repos +LAGO_VERSION=%{version} %{py2_install} +install -d -m 755 %{buildroot}/%{_sysconfdir}/lago +PYTHONPATH="$PYTHONPATH:%{buildroot}/%{python_sitelib}"\ + %{buildroot}/usr/bin/lago --ignore-warnings generate-config > "%{buildroot}/%{_sysconfdir}/lago/lago.conf" +sed -i 's/^\([^#]\)\(.*\)/#\0/' "%{buildroot}/%{_sysconfdir}/lago/lago.conf" + +install -d %{buildroot}/var/lib/lago/subnets +install -d %{buildroot}/var/lib/lago/store +install -d %{buildroot}/var/lib/lago/repos # this is for python-lago-ovirt -install -d "$RPM_BUILD_ROOT"/var/lib/lago/reposync +install -d %{buildroot}/var/lib/lago/reposync %files @@ -39,6 +42,23 @@ Summary: Library to perform lago operations BuildArch: noarch BuildRequires: python2-devel BuildRequires: python-pbr +BuildRequires: python-stevedore +BuildRequires: python-setuptools +BuildRequires: python-magic +BuildRequires: python-lockfile +BuildRequires: python-yaml +BuildRequires: pyxdg +BuildRequires: python-xmltodict +BuildRequires: python-lxml +BuildRequires: libvirt-python +BuildRequires: python-enum +BuildRequires: python-scp +%if 0%{?fedora} >= 24 +BuildRequires: python2-configparser +%else +BuildRequires: python-configparser +%endif + %if 0%{?fedora} >= 23 BuildRequires: python2-dulwich %else @@ -88,12 +108,13 @@ Requires: sudo %{_bindir}/lagocli %{_bindir}/lago %attr(0775, root, root) %{_sysconfdir}/sudoers.d/* -%config(noreplace) %{_sysconfdir}/lago.d/lago.conf +%config(noreplace) %{_sysconfdir}/lago/lago.conf %dir %attr(2775, root, lago) /var/lib/lago/ %dir %attr(2775, root, lago) /var/lib/lago/subnets/ %dir %attr(2775, root, lago) /var/lib/lago/store/ %dir %attr(2775, root, lago) /var/lib/lago/repos/ + %pre -n python-%{name} if [[ "$1" -eq 1 ]]; then groupadd lago @@ -104,6 +125,7 @@ if [[ "$1" -eq 0 ]]; then groupdel lago fi + ###################### lago-ovirt package %package -n %{name}-ovirt Summary: oVirt extension for lagocli @@ -147,6 +169,7 @@ if which firewall-cmd &>/dev/null; then firewall-cmd --reload fi + %preun -n python-%{name}-ovirt if which firewall-cmd &>/dev/null; then firewall-cmd --permanent --zone=public --remove-service=ovirtlago diff --git a/lago/plugins/vm.py b/lago/plugins/vm.py index 7ab9ca0e..ddc6bc18 100644 --- a/lago/plugins/vm.py +++ b/lago/plugins/vm.py @@ -38,6 +38,7 @@ from .. import (utils, log_utils, plugins, ssh, ) from lago.config import config + LOGGER = logging.getLogger(__name__) LogTask = functools.partial(log_utils.LogTask, logger=LOGGER) diff --git a/setup.cfg b/setup.cfg index 3845952a..2df85155 100644 --- a/setup.cfg +++ b/setup.cfg @@ -15,7 +15,6 @@ packages = ovirtlago data_files = # core lago - /etc/lago.d = etc/lago.d/* /etc/sudoers.d/ = etc/sudo/lago /etc/polkit-1/localauthority/50-local.d = etc/polkit/* # ovirt lago plugin