From 8e854d7eb8c5d98efed34c27cc55cac49d77d7f9 Mon Sep 17 00:00:00 2001 From: Devananda van der Veen Date: Tue, 18 Mar 2014 11:22:37 -0700 Subject: [PATCH] Correct version.py and update current version string Correct the version string in setup.cfg for Icehouse. Make ironic/version.py use PBR instead of the stale code that was there. Make ironic/common/config.py properly set the version string so that all CLI commands output it when "--version" is passed. Remove openstack.common.version module which is no longer present in oslo-incubator. Closes-bug: #1294389 Change-Id: I9a7bfe5fc1b79934cf2467d6f8a6c16f41205dbf --- doc/source/conf.py | 4 +- ironic/common/config.py | 2 +- ironic/common/service.py | 5 +- ironic/openstack/common/version.py | 94 ------------------------------ ironic/version.py | 31 +--------- openstack-common.conf | 1 - setup.cfg | 2 +- 7 files changed, 8 insertions(+), 131 deletions(-) delete mode 100644 ironic/openstack/common/version.py diff --git a/doc/source/conf.py b/doc/source/conf.py index 029c6660e9..0b1f388206 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -39,9 +39,9 @@ copyright = u'OpenStack Foundation' # The short X.Y version. from ironic import version as ironic_version # The full version, including alpha/beta/rc tags. -release = ironic_version.version_string_with_vcs() +release = ironic_version.version_info.release_string() # The short X.Y version. -version = ironic_version.canonical_version_string() +version = ironic_version.version_info.version_string() # A list of ignored prefixes for module index sorting. modindex_common_prefix = ['ironic.'] diff --git a/ironic/common/config.py b/ironic/common/config.py index f0a395fc68..863c15f834 100644 --- a/ironic/common/config.py +++ b/ironic/common/config.py @@ -25,5 +25,5 @@ def parse_args(argv, default_config_files=None): rpc.set_defaults(control_exchange='ironic') cfg.CONF(argv[1:], project='ironic', - version=version.version_string(), + version=version.version_info.release_string(), default_config_files=default_config_files) diff --git a/ironic/common/service.py b/ironic/common/service.py index dba16926a0..b8a83c7dd6 100644 --- a/ironic/common/service.py +++ b/ironic/common/service.py @@ -20,10 +20,10 @@ import socket from oslo.config import cfg +from ironic.common import config from ironic.openstack.common import context from ironic.openstack.common import log from ironic.openstack.common import periodic_task -from ironic.openstack.common import rpc from ironic.openstack.common.rpc import service as rpc_service @@ -54,7 +54,7 @@ class PeriodicService(rpc_service.Service, periodic_task.PeriodicTasks): def prepare_service(argv=[]): - rpc.set_defaults(control_exchange='ironic') + config.parse_args(argv) cfg.set_defaults(log.log_opts, default_log_levels=['amqplib=WARN', 'qpid.messaging=INFO', @@ -65,5 +65,4 @@ def prepare_service(argv=[]): 'iso8601=WARN', 'paramiko=WARN', ]) - cfg.CONF(argv[1:], project='ironic') log.setup('ironic') diff --git a/ironic/openstack/common/version.py b/ironic/openstack/common/version.py deleted file mode 100644 index edc049f4e0..0000000000 --- a/ironic/openstack/common/version.py +++ /dev/null @@ -1,94 +0,0 @@ - -# Copyright 2012 OpenStack Foundation -# Copyright 2012-2013 Hewlett-Packard Development Company, L.P. -# -# 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. - -""" -Utilities for consuming the version from pkg_resources. -""" - -import pkg_resources - - -class VersionInfo(object): - - def __init__(self, package): - """Object that understands versioning for a package - :param package: name of the python package, such as glance, or - python-glanceclient - """ - self.package = package - self.release = None - self.version = None - self._cached_version = None - - def __str__(self): - """Make the VersionInfo object behave like a string.""" - return self.version_string() - - def __repr__(self): - """Include the name.""" - return "VersionInfo(%s:%s)" % (self.package, self.version_string()) - - def _get_version_from_pkg_resources(self): - """Get the version of the package from the pkg_resources record - associated with the package.""" - try: - requirement = pkg_resources.Requirement.parse(self.package) - provider = pkg_resources.get_provider(requirement) - return provider.version - except pkg_resources.DistributionNotFound: - # The most likely cause for this is running tests in a tree - # produced from a tarball where the package itself has not been - # installed into anything. Revert to setup-time logic. - from ironic.openstack.common import setup - return setup.get_version(self.package) - - def release_string(self): - """Return the full version of the package including suffixes indicating - VCS status. - """ - if self.release is None: - self.release = self._get_version_from_pkg_resources() - - return self.release - - def version_string(self): - """Return the short version minus any alpha/beta tags.""" - if self.version is None: - parts = [] - for part in self.release_string().split('.'): - if part[0].isdigit(): - parts.append(part) - else: - break - self.version = ".".join(parts) - - return self.version - - # Compatibility functions - canonical_version_string = version_string - version_string_with_vcs = release_string - - def cached_version_string(self, prefix=""): - """Generate an object which will expand in a string context to - the results of version_string(). We do this so that don't - call into pkg_resources every time we start up a program when - passing version information into the CONF constructor, but - rather only do the calculation when and if a version is requested - """ - if not self._cached_version: - self._cached_version = "%s%s" % (prefix, - self.version_string()) - return self._cached_version diff --git a/ironic/version.py b/ironic/version.py index 6dd2b95a93..1cb8773363 100644 --- a/ironic/version.py +++ b/ironic/version.py @@ -13,33 +13,6 @@ # License for the specific language governing permissions and limitations # under the License. -try: - from ironic.vcsversion import version_info -except ImportError: - version_info = {'branch_nick': u'LOCALBRANCH', - 'revision_id': 'LOCALREVISION', - 'revno': 0} +import pbr.version -IRONIC_VERSION = ['2013', '1'] -YEAR, COUNT = IRONIC_VERSION - -FINAL = False # This becomes true at Release Candidate time - - -def canonical_version_string(): - return '.'.join([YEAR, COUNT]) - - -def version_string(): - if FINAL: - return canonical_version_string() - else: - return '%s-dev' % (canonical_version_string(),) - - -def vcs_version_string(): - return "%s:%s" % (version_info['branch_nick'], version_info['revision_id']) - - -def version_string_with_vcs(): - return "%s-%s" % (canonical_version_string(), vcs_version_string()) +version_info = pbr.version.VersionInfo('ironic') diff --git a/openstack-common.conf b/openstack-common.conf index b6837cda6b..1c445e5e15 100644 --- a/openstack-common.conf +++ b/openstack-common.conf @@ -31,7 +31,6 @@ module=setup module=strutils module=timeutils module=test -module=version # The base module to hold the copy of openstack.common base=ironic diff --git a/setup.cfg b/setup.cfg index 80f821cbff..a2889beb2a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = ironic -version = 2013.2 +version = 2014.1 summary = OpenStack Bare Metal Provisioning description-file = README.rst