Merge "Remove hard-coding of package/component names"

This commit is contained in:
Jenkins 2014-02-04 03:17:23 +00:00 committed by Gerrit Code Review
commit 83a9d4eb38
9 changed files with 78 additions and 92 deletions

View File

@ -30,32 +30,6 @@ 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 = frozenset([
"ceilometer",
"cinder",
"glance",
"heat",
"horizon",
"keystone",
"neutron",
"nova",
"oslo.config",
"oslo.messaging",
"python-cinderclient",
"python-glanceclient",
"python-keystoneclient",
"python-neutronclient",
"python-novaclient",
"python-swiftclient",
"python-troveclient",
"swift",
"trove",
])
SKIP_PACKAGE_NAMES = []
class InstallHelper(object):
"""Run pre and post install for a single package."""
@ -218,16 +192,18 @@ class DependencyHandler(object):
extra_pips = extra_pips or []
cmdline = [
self.multipip_executable,
"--skip-requirements-regex",
"python.*client",
"--pip",
self.pip_executable
"--pip", self.pip_executable,
]
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)
ignore_pip_names = set(self.python_names)
more_ignores = self.distro.get_dependency_config('ignore_pip_names',
quiet=True)
if more_ignores:
ignore_pip_names.update([str(n) for n in more_ignores])
if ignore_pip_names:
cmdline.extend(["--ignore-package"])
cmdline.extend(ignore_pip_names)
stdout, stderr = sh.execute(cmdline, check_exit_code=False)
self.pips_to_install = list(utils.splitlines_not_empty(stdout))

View File

@ -61,28 +61,6 @@ 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",
"keystone": "Identity",
"cinder": "Volume",
"neutron": "Networking",
}
SERVER_NAMES = [
"ceilometer",
"cinder",
"glance",
"heat",
"keystone",
"neutron",
"nova",
"trove",
]
TRANSLATION_NAMES = {
'horizon': "python-django-horizon",
}
YUM_REPO_DIR = "/etc/yum.repos.d/"
SRC_REPOS = {
'anvil': 'anvil-source',
@ -519,56 +497,65 @@ class YumDependencyHandler(base.DependencyHandler):
sh.gzip(archive_name)
sh.unlink(archive_name)
@staticmethod
def _is_client(instance_name, egg_name):
for i in [instance_name, egg_name]:
if i and i.endswith("client"):
return True
return False
def _get_template_and_rpm_name(self, instance):
template_name = None
def _find_template_and_rpm_name(self, instance, build_name):
search_names = [
[
build_name,
"%s.spec" % build_name,
],
]
try:
egg_name = instance.egg_info['name']
if self._is_client(instance.name, egg_name):
rpm_name = egg_name
template_name = "python-commonclient.spec"
elif instance.name in self.SERVER_NAMES:
rpm_name = "openstack-%s" % (egg_name)
else:
rpm_name = self.TRANSLATION_NAMES.get(instance.name)
if any(s.endswith("client") for s in (instance.name, egg_name, build_name)):
search_names.extend([
[
egg_name,
"python-commonclient.spec",
],
])
search_names.extend([
[
"openstack-%s" % (egg_name),
"openstack-%s.spec" % (egg_name),
],
[
egg_name,
"%s.spec" % (egg_name),
],
])
except AttributeError:
rpm_name = instance.name
template_name = "%s.spec" % rpm_name
return (rpm_name, template_name)
pass
# Return the first that exists (if any from this list)
for (rpm_name, template_name) in search_names:
spec_filename = sh.joinpths(settings.TEMPLATE_DIR,
self.SPEC_TEMPLATE_DIR, template_name)
if sh.isfile(spec_filename):
return (rpm_name, template_name)
return (None, None)
def _build_openstack_package(self, instance):
params = self._package_parameters(instance)
patches = instance.list_patches("package")
params['patches'] = [sh.basename(fn) for fn in patches]
(rpm_name, template_name) = self._get_template_and_rpm_name(instance)
build_name = instance.get_option('build_name', default_value=instance.name)
(rpm_name, template_name) = self._find_template_and_rpm_name(instance, build_name)
try:
egg_name = instance.egg_info['name']
params["version"] = instance.egg_info["version"]
if self._is_client(instance.name, egg_name):
if any(s.endswith("client") for s in (instance.name, egg_name, build_name)):
client_name = utils.strip_prefix_suffix(egg_name, "python-", "client")
if not client_name:
msg = "Bad client package name %s" % (egg_name)
raise excp.PackageException(msg)
params["clientname"] = client_name
params["apiname"] = self.API_NAMES.get(client_name,
client_name.title())
params["apiname"] = instance.get_option('api_name',
default_value=client_name.title())
except AttributeError:
spec_filename = None
if template_name:
spec_filename = sh.joinpths(settings.TEMPLATE_DIR,
self.SPEC_TEMPLATE_DIR,
template_name)
if not spec_filename or not sh.isfile(spec_filename):
rpm_name = None
if rpm_name:
if not template_name:
template_name = "%s.spec" % rpm_name
pass
if all((rpm_name, template_name)):
spec_filename = self._write_spec_file(instance, rpm_name,
template_name, params)
self._build_from_spec(instance, spec_filename, patches)

View File

@ -6,4 +6,8 @@ api_host: "$(auto:ip)"
api_port: 8776
protocol: http
# Used for associating the client package with a human understandable
# name in its package description (not a code-name, like cinder).
api_name: "Volume"
...

View File

@ -29,4 +29,8 @@ image_cache_dir: "/usr/share/anvil/glance/images"
# Used by install section in the specfile (conflicts with the client binary...)
remove_file: "/bin/rm -rf %{buildroot}/usr/bin/glance"
# Used for associating the client package with a human understandable
# name in its package description (not a code-name, like glance).
api_name: "Image"
...

View File

@ -1,4 +1,7 @@
# Settings for component horizon
---
# Instead of naming this components package horizon, it will be named this instead
build_name: "python-django-horizon"
...

View File

@ -11,6 +11,10 @@ service_host: "$(auto:ip)"
service_port: 5000
service_proto: http
# Used for associating the client package with a human understandable
# name in its package description (not a code-name, like keystone).
api_name: "Identity"
# Test exclusions...
#
# TODO(harlowja) these should probably be bugs...

View File

@ -6,6 +6,10 @@ api_host: "$(auto:ip)"
api_port: 9696
protocol: http
# Used for associating the client package with a human understandable
# name in its package description (not a code-name, like neutron).
api_name: "Networking"
core_plugin: openvswitch
use_namespaces: True

View File

@ -117,6 +117,10 @@ vncserver_listen: 127.0.0.1
vncserver_proxyclient_address: ""
xvpvncproxy_url: "http://$(auto:ip):6081/console"
# Used for associating the client package with a human understandable
# name in its package description (not a code-name, like nova).
api_name: "Compute"
# Test exclusions...
#
# TODO(harlowja) these should probably be bugs...

View File

@ -24,9 +24,9 @@ dependency_handler:
qpid-python: python-qpid # Why is this one backwards :-/
PyYAML: PyYAML
arch_dependent:
- selenium
- xattr
- PuLP
- selenium
- xattr
- PuLP
commands:
service:
restart: service $NAME restart