diff --git a/anvil/components/base.py b/anvil/components/base.py index 26e917ad..a1c267ec 100644 --- a/anvil/components/base.py +++ b/anvil/components/base.py @@ -16,10 +16,14 @@ from anvil import exceptions as excp from anvil import log as logging +from anvil import patcher +from anvil import settings from anvil import shell as sh +from anvil import trace as tr from anvil import type_utils as tu from anvil import utils +from anvil.components.configurators import base as conf LOG = logging.getLogger(__name__) @@ -124,3 +128,35 @@ class Component(object): except KeyError: names.add("openstack-%s-%s" % (self.name, key)) return names + + +class BasicComponent(Component): + def __init__(self, *args, **kargs): + super(BasicComponent, self).__init__(*args, **kargs) + trace_fn = tr.trace_filename(self.get_option('trace_dir'), 'created') + self.tracewriter = tr.TraceWriter(trace_fn, break_if_there=False) + self.configurator = conf.Configurator(self) + + def download(self): + return [] + + def list_patches(self, section): + what_patches = self.get_option('patches', section) + if not what_patches: + what_patches = [sh.joinpths(settings.CONFIG_DIR, 'patches', + self.name, section)] + canon_what_patches = [] + for path in what_patches: + if sh.isdir(path): + patches = sorted(fn for fn in sh.listdir(path, files_only=True) + if fn.endswith('patch')) + canon_what_patches.extend(patches) + elif sh.isfile(path): + canon_what_patches.append(path) + return canon_what_patches + + def patch(self, section): + canon_what_patches = self.list_patches(section) + if canon_what_patches: + target_dir = self.get_option('app_dir') + patcher.apply_patches(canon_what_patches, target_dir) diff --git a/anvil/components/base_install.py b/anvil/components/base_install.py index 0b387b7e..136c81b5 100644 --- a/anvil/components/base_install.py +++ b/anvil/components/base_install.py @@ -15,70 +15,16 @@ from anvil.components import base from anvil import downloader as down from anvil import log as logging -from anvil import patcher -from anvil import settings from anvil import shell as sh from anvil import trace as tr from anvil import utils from anvil.packaging.helpers import pip_helper -from anvil.components.configurators import base as conf - LOG = logging.getLogger(__name__) -class PkgInstallComponent(base.Component): - def __init__(self, *args, **kargs): - super(PkgInstallComponent, self).__init__(*args, **kargs) - trace_fn = tr.trace_filename(self.get_option('trace_dir'), 'created') - self.tracewriter = tr.TraceWriter(trace_fn, break_if_there=False) - self.configurator = conf.Configurator(self) - - def download(self): - return [] - - def list_patches(self, section): - what_patches = self.get_option('patches', section) - if not what_patches: - what_patches = [sh.joinpths(settings.CONFIG_DIR, 'patches', - self.name, section)] - canon_what_patches = [] - for path in what_patches: - if sh.isdir(path): - patches = sorted(fn for fn in sh.listdir(path, files_only=True) - if fn.endswith('patch')) - canon_what_patches.extend(patches) - elif sh.isfile(path): - canon_what_patches.append(path) - return canon_what_patches - - def patch(self, section): - canon_what_patches = self.list_patches(section) - if canon_what_patches: - target_dir = self.get_option('app_dir') - patcher.apply_patches(canon_what_patches, target_dir) - - def config_params(self, config_fn): - mp = dict(self.params) - if config_fn: - mp['CONFIG_FN'] = config_fn - return mp - - @property - def packages(self): - return self.extended_packages() - - def extended_packages(self): - pkg_list = self.get_option('packages', default_value=[]) - if not pkg_list: - pkg_list = [] - for name, values in self.subsystems.items(): - if 'packages' in values: - LOG.debug("Extending package list with packages for subsystem: %r", name) - pkg_list.extend(values.get('packages')) - return pkg_list - +class InstallableMixin(base.Component): def pre_install(self): pkgs = self.packages for p in pkgs: @@ -124,10 +70,24 @@ class PkgInstallComponent(base.Component): self.cfg_dir, uid, gid, e) return files + @property + def packages(self): + return self.extended_packages() -class PythonInstallComponent(PkgInstallComponent): + def extended_packages(self): + pkg_list = self.get_option('packages', default_value=[]) + if not pkg_list: + pkg_list = [] + for name, values in self.subsystems.items(): + if 'packages' in values: + LOG.debug("Extending package list with packages for subsystem: %r", name) + pkg_list.extend(values.get('packages')) + return pkg_list + + +class PythonComponent(base.BasicComponent): def __init__(self, *args, **kargs): - PkgInstallComponent.__init__(self, *args, **kargs) + super(PythonComponent, self).__init__(*args, **kargs) app_dir = self.get_option('app_dir') tools_dir = sh.joinpths(app_dir, 'tools') self.requires_files = [ @@ -140,6 +100,12 @@ class PythonInstallComponent(PkgInstallComponent): ] self._origins_fn = kargs['origins_fn'] + def config_params(self, config_fn): + mp = dict(self.params) + if config_fn: + mp['CONFIG_FN'] = config_fn + return mp + def download(self): """Download sources needed to build the component, if any.""" target_dir = self.get_option('app_dir') @@ -171,6 +137,14 @@ class PythonInstallComponent(PkgInstallComponent): return egg_info +class PkgInstallComponent(base.BasicComponent, InstallableMixin): + pass + + +class PythonInstallComponent(PythonComponent, InstallableMixin): + pass + + class PkgUninstallComponent(base.Component): def __init__(self, *args, **kargs): super(PkgUninstallComponent, self).__init__(*args, **kargs) diff --git a/anvil/components/global_requirements.py b/anvil/components/global_requirements.py new file mode 100644 index 00000000..4da57a9e --- /dev/null +++ b/anvil/components/global_requirements.py @@ -0,0 +1,28 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright (C) 2014 Yahoo! Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from anvil import shell as sh + +from anvil.components import base_install as base + + +class GlobalRequirements(base.PythonComponent): + def __init__(self, *args, **kargs): + super(GlobalRequirements, self).__init__(*args, **kargs) + app_dir = self.get_option('app_dir') + self.requires_files = [ + sh.joinpths(app_dir, 'global-requirements.txt'), + ] diff --git a/anvil/packaging/helpers/py2rpm_helper.py b/anvil/packaging/helpers/py2rpm_helper.py index 4cba3123..f7a2d430 100644 --- a/anvil/packaging/helpers/py2rpm_helper.py +++ b/anvil/packaging/helpers/py2rpm_helper.py @@ -46,10 +46,11 @@ class Helper(object): "--rpm-base", self._rpmbuild_dir ] - cmdline += [ - "--epoch-map" - ] + ["%s==%s" % (key, value) - for key, value in self._epoch_map.iteritems()] + if self._epoch_map: + cmdline += [ + "--epoch-map" + ] + ["%s==%s" % (key, value) + for key, value in self._epoch_map.iteritems()] if self._package_map: cmdline += [ "--package-map", diff --git a/conf/components/global-requirements.yaml b/conf/components/global-requirements.yaml new file mode 100644 index 00000000..592a8287 --- /dev/null +++ b/conf/components/global-requirements.yaml @@ -0,0 +1,4 @@ +# Settings for component global_requirements +--- + +... diff --git a/conf/distros/rhel.yaml b/conf/distros/rhel.yaml index 7cb3414d..bac98628 100644 --- a/conf/distros/rhel.yaml +++ b/conf/distros/rhel.yaml @@ -23,6 +23,7 @@ dependency_handler: sqlalchemy-migrate: python-migrate qpid-python: python-qpid # Why is this one backwards :-/ PyYAML: PyYAML + pyzmq: python-zmq arch_dependent: - selenium - xattr @@ -407,6 +408,13 @@ components: api-cfn: openstack-heat-api-cfn api-cloudwatch: openstack-heat-api-cloudwatch engine: openstack-heat-engine + global-requirements: + action_classes: + install: anvil.components.global_requirements:GlobalRequirements + running: anvil.components.base_runtime:EmptyRuntime + test: anvil.components.base_testing:PythonTestingComponent + coverage: anvil.components.base_testing:PythonTestingComponent + uninstall: anvil.components.base_install:PkgUninstallComponent ceilometer: pip: - name: wsme diff --git a/conf/origins/havana-git.yaml b/conf/origins/havana-git.yaml index 1aa5ccce..201c66aa 100644 --- a/conf/origins/havana-git.yaml +++ b/conf/origins/havana-git.yaml @@ -19,6 +19,9 @@ glance-client: glance: repo: git://github.com/openstack/glance.git branch: stable/havana +global-requirements: + repo: git://github.com/openstack/requirements.git + branch: stable/havana heat-client: repo: git://github.com/openstack/python-heatclient.git tag: 0.2.5 diff --git a/conf/origins/master.yaml b/conf/origins/master.yaml index 53a3e17f..9d984782 100644 --- a/conf/origins/master.yaml +++ b/conf/origins/master.yaml @@ -19,6 +19,9 @@ glance-client: glance: repo: git://github.com/openstack/glance.git branch: master +global-requirements: + repo: git://github.com/openstack/requirements.git + branch: master heat-client: repo: git://github.com/openstack/python-heatclient.git branch: master diff --git a/conf/personas/requirements.yaml b/conf/personas/requirements.yaml new file mode 100644 index 00000000..7a62e230 --- /dev/null +++ b/conf/personas/requirements.yaml @@ -0,0 +1,7 @@ +--- +components: +- general +- global-requirements +supports: +- rhel +...