Add a component that tracks global requirements
There is a separate repository that stores the whole set of package requrements of various OpenStack components. So it makes sense to add such component-helper to anvil. Change-Id: Id32af1262c881c1bf5e0cbe4f13ce543b95747c9
This commit is contained in:
parent
83a9d4eb38
commit
c031bb0cfa
@ -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)
|
||||
|
@ -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)
|
||||
|
28
anvil/components/global_requirements.py
Normal file
28
anvil/components/global_requirements.py
Normal file
@ -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'),
|
||||
]
|
@ -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",
|
||||
|
4
conf/components/global-requirements.yaml
Normal file
4
conf/components/global-requirements.yaml
Normal file
@ -0,0 +1,4 @@
|
||||
# Settings for component global_requirements
|
||||
---
|
||||
|
||||
...
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
7
conf/personas/requirements.yaml
Normal file
7
conf/personas/requirements.yaml
Normal file
@ -0,0 +1,7 @@
|
||||
---
|
||||
components:
|
||||
- general
|
||||
- global-requirements
|
||||
supports:
|
||||
- rhel
|
||||
...
|
Loading…
Reference in New Issue
Block a user