Merge "Default action_classes to a known group"

This commit is contained in:
Jenkins 2014-09-09 22:36:31 +00:00 committed by Gerrit Code Review
commit b7719ce924
3 changed files with 64 additions and 132 deletions

View File

@ -31,6 +31,19 @@ from anvil import utils
from anvil.utils import OrderedDict
LOG = logging.getLogger(__name__)
BASE_ENTRYPOINTS = {
'coverage': 'anvil.components.base_testing:EmptyTestingComponent',
'install': 'anvil.components.pkglist:Installer',
'running': 'anvil.components.base_runtime:EmptyRuntime',
'test': 'anvil.components.base_testing:EmptyTestingComponent',
'uninstall': 'anvil.components.base_install:PkgUninstallComponent',
}
BASE_PYTHON_ENTRYPOINTS = dict(BASE_ENTRYPOINTS)
BASE_PYTHON_ENTRYPOINTS.update({
'coverage': 'anvil.components.base_testing:PythonTestingComponent',
'install': 'anvil.components.base_install:PythonInstallComponent',
'test': 'anvil.components.base_testing:PythonTestingComponent',
})
class PhaseFunctors(object):
@ -111,6 +124,11 @@ class Action(object):
"""
raise NotImplementedError()
def _make_default_entry_points(self, component_name, component_options):
if component_options.get('python_entrypoints'):
return BASE_PYTHON_ENTRYPOINTS.copy()
return BASE_ENTRYPOINTS.copy()
def _order_components(self, components):
"""Returns the components in the order they should be processed.
"""
@ -158,7 +176,8 @@ class Action(object):
# right set of siblings....
sibling_instances = {}
for c in wanted_components:
d_component = self.distro.extract_component(c, self.lookup_name)
d_component = self.distro.extract_component(
c, self.lookup_name, default_entry_point_creator=self._make_default_entry_points)
LOG.debug("Constructing component %r (%s)", c, d_component.entry_point)
d_subsystems = d_component.options.pop('subsystems', {})
sibling_params = {}

View File

@ -23,6 +23,8 @@ import platform
import re
import shlex
import six
from anvil import exceptions as excp
from anvil import importer
from anvil import log as logging
@ -106,19 +108,30 @@ class Distro(object):
"""Return a dependency handler that will work for this distro."""
return importer.import_entry_point(self._dependency_handler["name"])
def extract_component(self, name, action):
def extract_component(self, name, action, default_entry_point_creator=None):
"""Return the class + component info to use for doing the action w/the component."""
try:
# Use a copy instead of the original since we will be
# modifying this dictionary which may not be wanted for future
# usages of this dictionary (so keep the original clean)...
component_info = copy.deepcopy(self._components[name])
action_classes = component_info.pop('action_classes')
except KeyError:
component_info = {}
action_classes = component_info.pop('action_classes', {})
if default_entry_point_creator is not None:
default_action_classes = default_entry_point_creator(name,
copy.deepcopy(component_info))
if default_action_classes:
for (an_action, entry_point) in six.iteritems(default_action_classes):
if an_action not in action_classes:
action_classes[an_action] = entry_point
try:
entry_point = action_classes.pop(action)
except KeyError:
raise RuntimeError('No entrypoint configured/generated for'
' %r %r for distribution %r' % (action, name, self.name))
else:
return Component(entry_point, component_info, action_classes)
except (KeyError, ValueError):
raise RuntimeError('No class configured to %r %r on %r' %
(action, name, self.name))
def _match_distros(distros):

View File

@ -80,19 +80,12 @@ commands:
stop: service rabbitmq-server stop
components:
ceilometer-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
python_entrypoints: True
cinder:
python_entrypoints: True
action_classes:
install: anvil.components.cinder:CinderInstaller
running: anvil.components.base_runtime:OpenStackRuntime
test: anvil.components.base_testing:PythonTestingComponent
coverage: anvil.components.base_testing:PythonTestingComponent
uninstall: anvil.components.base_install:PkgUninstallComponent
daemon_to_package:
all: openstack-cinder
volume: openstack-cinder
@ -101,28 +94,17 @@ components:
pips:
- name: hp3parclient
cinder-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
python_entrypoints: True
db:
action_classes:
install: anvil.distros.rhel:DBInstaller
running: anvil.components.db:DBRuntime
coverage: anvil.components.base_testing:EmptyTestingComponent
test: anvil.components.base_testing:EmptyTestingComponent
uninstall: anvil.components.db:DBUninstaller
packages:
- name: mysql
- name: mysql-server
general:
action_classes:
install: anvil.components.pkglist:Installer
running: anvil.components.base_runtime:EmptyRuntime
test: anvil.components.base_testing:EmptyTestingComponent
coverage: anvil.components.base_testing:EmptyTestingComponent
uninstall: anvil.components.pkglist:Uninstaller
build-requires:
# Build time dependencies
@ -165,12 +147,12 @@ components:
version: ">=1.3.0"
- name: "coverage"
glance:
python_entrypoints: True
action_classes:
install: anvil.components.glance:GlanceInstaller
running: anvil.components.glance:GlanceRuntime
coverage: anvil.components.glance:GlanceTester
test: anvil.components.glance:GlanceTester
uninstall: anvil.components.base_install:PkgUninstallComponent
pips:
# pip setup and download of xattr>=0.7 seems to have problems find cffi
# so lets just use an restrict the upper bound until this is fixed upstream
@ -182,35 +164,22 @@ components:
registry: openstack-glance
scrubber: openstack-glance
glance-client:
python_entrypoints: True
action_classes:
install: anvil.components.base_install:PythonInstallComponent
running: anvil.components.base_runtime:EmptyRuntime
test: anvil.components.glance_client:GlanceClientTester
coverage: anvil.components.glance_client:GlanceClientTester
uninstall: anvil.components.base_install:PkgUninstallComponent
heat-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
python_entrypoints: True
horizon:
python_entrypoints: True
action_classes:
install: anvil.components.base_install:PythonInstallComponent
running: anvil.components.horizon:HorizonRuntime
test: anvil.components.base_testing:PythonTestingComponent
coverage: anvil.components.base_testing:PythonTestingComponent
uninstall: anvil.components.base_install:PkgUninstallComponent
packages:
- name: openstack-dashboard
django-openstack-auth:
action_classes:
install: anvil.components.base_install:PythonInstallComponent
running: anvil.components.base_runtime:EmptyRuntime
test: anvil.components.base_testing:EmptyTestingComponent
uninstall: anvil.components.base_install:PkgUninstallComponent
python_entrypoints: True
keystone:
python_entrypoints: True
action_classes:
install: anvil.components.keystone:KeystoneInstaller
running: anvil.components.keystone:KeystoneRuntime
@ -220,25 +189,14 @@ components:
daemon_to_package:
all: openstack-keystone
keystone-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
python_entrypoints: True
neutron-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
python_entrypoints: True
nova:
python_entrypoints: True
action_classes:
install: anvil.components.nova:NovaInstaller
running: anvil.components.nova:NovaRuntime
test: anvil.components.base_testing:PythonTestingComponent
coverage: anvil.components.base_testing:PythonTestingComponent
uninstall: anvil.components.nova:NovaUninstaller
pips:
# This seems to be a core dependency for a 'cas' tool
@ -262,68 +220,35 @@ components:
spicehtml5proxy: openstack-nova-console
xvpvncproxy: openstack-nova-console
nova-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
python_entrypoints: True
novnc:
action_classes:
install: anvil.components.base_install:PythonInstallComponent
running: anvil.components.base_runtime:EmptyRuntime
test: anvil.components.base_testing:EmptyTestingComponent
coverage: anvil.components.base_testing:EmptyTestingComponent
uninstall: anvil.components.base_install:PkgUninstallComponent
python_entrypoints: True
openstack-client:
python_entrypoints: True
action_classes:
install: anvil.components.openstack_client:OpenStackClientInstaller
running: anvil.components.base_runtime:EmptyRuntime
test: anvil.components.openstack_client:OpenStackClientTester
coverage: anvil.components.openstack_client:OpenStackClientTester
uninstall: anvil.components.base_install:PkgUninstallComponent
openvswitch:
action_classes:
install: anvil.components.openvswitch:OpenvswitchInstaller
running: anvil.components.openvswitch:OpenvswitchRuntime
test: anvil.components.base_testing:EmptyTestingComponent
uninstall: anvil.components.openvswitch:OpenvswitchUninstaller
packages:
- name: openvswitch
oslo-config:
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
python_entrypoints: True
oslo-incubator:
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
python_entrypoints: True
pycadf:
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
python_entrypoints: True
oslo-messaging:
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
python_entrypoints: True
neutron:
python_entrypoints: True
action_classes:
install: anvil.components.neutron:NeutronInstaller
running: anvil.components.neutron:NeutronRuntime
test: anvil.components.base_testing:PythonTestingComponent
coverage: anvil.components.base_testing:PythonTestingComponent
uninstall: anvil.components.neutron:NeutronUninstaller
daemon_to_package:
dhcp-agent: openstack-neutron
@ -337,7 +262,6 @@ components:
qpid:
action_classes:
install: anvil.components.qpid:QpidInstaller
test: anvil.components.base_testing:EmptyTestingComponent
uninstall: anvil.components.qpid:QpidUninstaller
running: anvil.components.qpid:QpidRuntime
packages:
@ -361,8 +285,6 @@ components:
action_classes:
install: anvil.components.rabbit:RabbitInstaller
running: anvil.distros.rhel:RabbitRuntime
test: anvil.components.base_testing:EmptyTestingComponent
coverage: anvil.components.base_testing:EmptyTestingComponent
uninstall: anvil.components.rabbit:RabbitUninstaller
packages:
- name: rabbitmq-server
@ -380,50 +302,28 @@ components:
- 'off'
ignore_failure: true
swift-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
python_entrypoints: True
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
python_entrypoints: True
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
python_entrypoints: True
heat:
python_entrypoints: True
action_classes:
install: anvil.components.heat:HeatInstaller
running: anvil.components.base_runtime:EmptyRuntime
test: anvil.components.base_testing:EmptyTestingComponent
uninstall: anvil.components.base_install:PkgUninstallComponent
daemon_to_package:
api: openstack-heat-api
api-cfn: openstack-heat-api-cfn
api-cloudwatch: openstack-heat-api-cloudwatch
engine: openstack-heat-engine
global-requirements:
python_entrypoints: True
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:
python_entrypoints: True
action_classes:
install: anvil.components.ceilometer:CeilometerInstaller
running: anvil.components.base_runtime:EmptyRuntime
test: anvil.components.base_testing:EmptyTestingComponent
uninstall: anvil.components.base_install:PkgUninstallComponent
daemon_to_package:
api: openstack-ceilometer-api
central: openstack-ceilometer-central