From 0a5989ec8053885e8406f018c73d58674062c8dc Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Fri, 2 Aug 2013 17:12:33 -0700 Subject: [PATCH] See if we can get trove to package itself. Change-Id: I653fcee0725896d588115db354cd69ca4ab2b342 --- anvil/packaging/base.py | 13 +- anvil/packaging/yum.py | 4 +- conf/components/trove-client.yaml | 7 + conf/components/trove.yaml | 7 + conf/distros/rhel.yaml | 14 ++ conf/personas/in-a-box/basic-trove.yaml | 57 ++++++ .../packaging/specs/openstack-trove.spec | 186 ++++++++++++++++++ 7 files changed, 284 insertions(+), 4 deletions(-) create mode 100644 conf/components/trove-client.yaml create mode 100644 conf/components/trove.yaml create mode 100644 conf/personas/in-a-box/basic-trove.yaml create mode 100644 conf/templates/packaging/specs/openstack-trove.spec diff --git a/anvil/packaging/base.py b/anvil/packaging/base.py index 8ed2fff0..e6024b22 100644 --- a/anvil/packaging/base.py +++ b/anvil/packaging/base.py @@ -28,6 +28,9 @@ from anvil import utils LOG = logging.getLogger(__name__) +# TODO(harlowja): get rid of static lists in code files for these names +# which we should be able to take in via configuration or other automatic +# process OPENSTACK_PACKAGES = set([ "cinder", "glance", @@ -35,15 +38,18 @@ OPENSTACK_PACKAGES = set([ "keystone", "nova", "oslo.config", - "quantum", - "swift", "python-cinderclient", "python-glanceclient", "python-keystoneclient", - "python-novaclient", "python-neutronclient", + "python-novaclient", "python-swiftclient", + "python-troveclient", + "quantum", + "swift", + "trove", ]) +SKIP_PACKAGE_NAMES = [] class InstallHelper(object): @@ -208,6 +214,7 @@ class DependencyHandler(object): cmdline = cmdline + extra_pips + ["-r"] + requires_files cmdline.extend(["--ignore-package"]) cmdline.extend(OPENSTACK_PACKAGES) + cmdline.extend(SKIP_PACKAGE_NAMES) cmdline.extend(self.python_names) output = sh.execute(cmdline, check_exit_code=False) diff --git a/anvil/packaging/yum.py b/anvil/packaging/yum.py index 8c1cca46..d3fce817 100644 --- a/anvil/packaging/yum.py +++ b/anvil/packaging/yum.py @@ -62,6 +62,8 @@ class YumInstallHelper(base.InstallHelper): class YumDependencyHandler(base.DependencyHandler): OPENSTACK_EPOCH = 2 SPEC_TEMPLATE_DIR = "packaging/specs" + # TODO(harlowja): get rid of these static lists/mappings from code and move + # them to configuration (or elsewhere). API_NAMES = { "nova": "Compute", "glance": "Image", @@ -69,7 +71,7 @@ class YumDependencyHandler(base.DependencyHandler): "cinder": "Volume", "quantum": "Networking", } - SERVER_NAMES = ["nova", "glance", "keystone", "quantum", "cinder"] + SERVER_NAMES = ["nova", "glance", "keystone", "quantum", "cinder", "trove"] TRANSLATION_NAMES = { 'horizon': "python-django-horizon", } diff --git a/conf/components/trove-client.yaml b/conf/components/trove-client.yaml new file mode 100644 index 00000000..555f02ce --- /dev/null +++ b/conf/components/trove-client.yaml @@ -0,0 +1,7 @@ +# Settings for component trove-client +--- + +# Where we download this from... +get_from: "git://github.com/openstack/python-troveclient.git?branch=master" + +... diff --git a/conf/components/trove.yaml b/conf/components/trove.yaml new file mode 100644 index 00000000..207f4209 --- /dev/null +++ b/conf/components/trove.yaml @@ -0,0 +1,7 @@ +# Settings for component trove +--- + +# Where we download this from... +get_from: "git://github.com/openstack/trove.git?branch=master" + +... diff --git a/conf/distros/rhel.yaml b/conf/distros/rhel.yaml index a58736e0..a1652afe 100644 --- a/conf/distros/rhel.yaml +++ b/conf/distros/rhel.yaml @@ -313,6 +313,20 @@ components: test: anvil.components.base_testing:PythonTestingComponent coverage: anvil.components.base_testing:PythonTestingComponent uninstall: anvil.components.base_install:PkgUninstallComponent + trove: + action_classes: + install: anvil.components.base_install:PythonInstallComponent + running: anvil.components.base_runtime:EmptyRuntime + test: anvil.components.base_testing:PythonTestingComponent + coverage: anvil.components.base_testing:PythonTestingComponent + uninstall: anvil.components.base_install:PkgUninstallComponent + trove-client: + action_classes: + install: anvil.components.base_install:PythonInstallComponent + running: anvil.components.base_runtime:EmptyRuntime + test: anvil.components.base_testing:PythonTestingComponent + coverage: anvil.components.base_testing:PythonTestingComponent + uninstall: anvil.components.base_install:PkgUninstallComponent openvswitch: action_classes: install: anvil.components.base_install:PkgInstallComponent diff --git a/conf/personas/in-a-box/basic-trove.yaml b/conf/personas/in-a-box/basic-trove.yaml new file mode 100644 index 00000000..351d5e58 --- /dev/null +++ b/conf/personas/in-a-box/basic-trove.yaml @@ -0,0 +1,57 @@ +--- +components: +# Order matters here! +- general +- db +- rabbit-mq +- oslo-config +- keystone +# Client used by many components +- keystone-client +- glance +- cinder +# Clients used by nova (+ others) +- glance-client +- cinder-client +- neutron-client +- nova +- nova-client +- trove +- trove-client +options: + nova: + db-sync: true + do-network-init: true + mq-type: "rabbit" + enable-cells: false + enable-spice: false + local-conductor: false + glance: + db-sync: true + load-images: true + keystone: + db-sync: true + do-init: true + enable-pki: false + cinder: + db-sync: true +subsystems: + glance: + - api + - registry + keystone: + - all + nova: + - api + - cert + - compute + - conductor + - network + - scheduler + cinder: + - api + - scheduler + - volume +supports: +- rhel +... diff --git a/conf/templates/packaging/specs/openstack-trove.spec b/conf/templates/packaging/specs/openstack-trove.spec new file mode 100644 index 00000000..794ab6fd --- /dev/null +++ b/conf/templates/packaging/specs/openstack-trove.spec @@ -0,0 +1,186 @@ +#encoding UTF-8 +# Based on spec by: +# * Andrey Brindeyev +# * Alessio Ababilov + +%global python_name trove +%global daemon_prefix openstack-trove +%global os_version $version + +%if ! (0%{?fedora} > 12 || 0%{?rhel} > 5) +%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")} +%endif + +Name: openstack-trove +Epoch: $epoch +Version: %{os_version}$version_suffix +Release: $release%{?dist} +Url: http://www.openstack.org +Summary: Database as a Service +License: Apache 2.0 +Vendor: Openstack Foundation +Group: Applications/System + +Source0: %{python_name}-%{os_version}.tar.gz +Source1: openstack-trove-server.init +Source2: openstack-trove-api.init + +#for $idx, $fn in enumerate($patches) +Patch$idx: $fn +#end for + +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release} + +BuildArch: noarch +BuildRequires: python-devel +BuildRequires: python-setuptools + +%if ! 0%{?usr_only} +Requires(post): chkconfig +Requires(postun): initscripts +Requires(preun): chkconfig +Requires(pre): shadow-utils +%endif +Requires: python-trove = %{epoch}:%{version}-%{release} + +%description +Trove is Database as a Service for OpenStack. + +This package contains the Trove daemon. + + +%if 0%{?with_doc} + +%package doc +Summary: Documentation for %{name} +Group: Documentation +Requires: %{name} = %{epoch}:%{version}-%{release} + +%description doc +Trove is Database as a Service for OpenStack. + +This package contains documentation for Trove. + +%endif + + +%package -n python-trove +Summary: Trove Python libraries +Group: Development/Languages/Python + +#for $i in $requires +Requires: ${i} +#end for + +%description -n python-trove +Trove is Database as a Service for OpenStack. + +This package contains the Trove Python library. + +%prep +%setup -q -n %{python_name}-%{os_version} +#for $idx, $fn in enumerate($patches) +%patch$idx -p1 +#end for +#raw + +%build +python setup.py build + + +%install +%__rm -rf %{buildroot} + +%if 0%{?with_doc} +export PYTHONPATH="$PWD:$PYTHONPATH" + +pushd doc +sphinx-build -b html source build/html +popd + +# Fix hidden-file-or-dir warnings +rm -fr doc/build/html/.doctrees doc/build/html/.buildinfo +%endif + +python setup.py install --prefix=%{_prefix} --root=%{buildroot} + +%if ! 0%{?usr_only} + +# Install config files +install -d -m 755 %{buildroot}%{_sysconfdir}/trove +install -p -D -m 640 etc/trove/api-paste.ini %{buildroot}%{_sysconfdir}/trove/ +install -p -D -m 640 etc/trove/trove.conf.sample %{buildroot}%{_sysconfdir}/trove/ +install -p -D -m 640 etc/trove/trove-guestagent.conf.sample %{buildroot}%{_sysconfdir}/trove/ +install -p -D -m 640 etc/trove/trove-taskmanager.conf.sample %{buildroot}%{_sysconfdir}/trove/ + +install -d -m 755 %{buildroot}%{_sharedstatedir}/trove +install -d -m 755 %{buildroot}%{_localstatedir}/log/trove +install -d -m 755 %{buildroot}%{_localstatedir}/run/trove + +# Initscripts +install -p -D -m 755 %{SOURCE1} %{buildroot}%{_initrddir}/%{daemon_prefix}-api +install -p -D -m 755 %{SOURCE1} %{buildroot}%{_initrddir}/%{daemon_prefix}-server +%endif + +%__rm -rf %{buildroot}%{py_sitelib}/{doc,tools} + + +%clean +%__rm -rf %{buildroot} + + +%if ! 0%{?usr_only} +%pre +getent group trove >/dev/null || groupadd -r trove +getent passwd trove >/dev/null || \ +useradd -r -g trove -d %{_sharedstatedir}/trove -s /sbin/nologin \ +-c "OpenStack Trove Daemons" trove +exit 0 + + +%preun +if [ $1 = 0 ] ; then + /sbin/service %{daemon_prefix}-api stop &>/dev/null + /sbin/chkconfig --del %{daemon_prefix}-api + /sbin/service %{daemon_prefix}-server stop &>/dev/null + /sbin/chkconfig --del %{daemon_prefix}-server + exit 0 +fi + +%postun +if [ $1 -ge 1 ] ; then + # Package upgrade, not uninstall + /sbin/service %{daemon_prefix}-api condrestart &>/dev/null + /sbin/service %{daemon_prefix}-server condrestart &>/dev/null + exit 0 +fi +%endif + + +%files +%defattr(-,root,root,-) +%doc README* LICENSE* ChangeLog AUTHORS +%{_usr}/bin/* + +%if ! 0%{?usr_only} +%config(noreplace) %{_sysconfdir}/trove +%dir %attr(0755, trove, nobody) %{_sharedstatedir}/trove +%dir %attr(0755, trove, nobody) %{_localstatedir}/log/trove +%dir %attr(0755, trove, nobody) %{_localstatedir}/run/trove +%{_initrddir}/* +%endif + +%if 0%{?with_doc} +%files doc +%defattr(-,root,root,-) +%doc doc +%endif + +%files -n python-trove +%defattr(-,root,root,-) +%doc LICENSE +%{python_sitelib}/* + + +%changelog +#endraw