Update to latest oslo-version code.
In prep for tag-based versioning, update to latest oslo-version code. Change-Id: Ic5046006919e20247481fa1ddbde2dfd456b188a
This commit is contained in:
@@ -226,10 +226,7 @@ class VersionCommands(object):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def list(self):
|
def list(self):
|
||||||
print(
|
print(version.version_string())
|
||||||
_("%(version)s (%(vcs)s)") %
|
|
||||||
{'version': version.version_string(),
|
|
||||||
'vcs': version.version_string_with_vcs()})
|
|
||||||
|
|
||||||
def __call__(self):
|
def __call__(self):
|
||||||
self.list()
|
self.list()
|
||||||
@@ -723,9 +720,8 @@ def main():
|
|||||||
FLAGS.register_cli_opt(category_opt)
|
FLAGS.register_cli_opt(category_opt)
|
||||||
script_name = sys.argv[0]
|
script_name = sys.argv[0]
|
||||||
if len(sys.argv) < 2:
|
if len(sys.argv) < 2:
|
||||||
print _("\nOpenStack Cinder version: %(version)s (%(vcs)s)\n") %\
|
print(_("\nOpenStack Cinder version: %(version)s\n") %
|
||||||
{'version': version.version_string(),
|
{'version': version.version_string()})
|
||||||
'vcs': version.version_string_with_vcs()}
|
|
||||||
print script_name + " category action [<args>]"
|
print script_name + " category action [<args>]"
|
||||||
print _("Available categories:")
|
print _("Available categories:")
|
||||||
for category in CATEGORIES:
|
for category in CATEGORIES:
|
||||||
|
|||||||
86
cinder/openstack/common/version.py
Normal file
86
cinder/openstack/common/version.py
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
|
||||||
|
# Copyright 2012 OpenStack LLC
|
||||||
|
# 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 _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 with
|
||||||
|
# produced from a tarball where the package itself has not been
|
||||||
|
# installed into anything. Check for a PKG-INFO file.
|
||||||
|
from cinder.openstack.common import setup
|
||||||
|
return setup.get_version_from_pkg_info(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
|
||||||
@@ -152,9 +152,9 @@ class Service(object):
|
|||||||
self.timers = []
|
self.timers = []
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
vcs_string = version.version_string_with_vcs()
|
version_string = version.version_string()
|
||||||
LOG.audit(_('Starting %(topic)s node (version %(vcs_string)s)'),
|
LOG.audit(_('Starting %(topic)s node (version %(version_string)s)'),
|
||||||
{'topic': self.topic, 'vcs_string': vcs_string})
|
{'topic': self.topic, 'version_string': version_string})
|
||||||
self.manager.init_host()
|
self.manager.init_host()
|
||||||
self.model_disconnected = False
|
self.model_disconnected = False
|
||||||
ctxt = context.get_admin_context()
|
ctxt = context.get_admin_context()
|
||||||
|
|||||||
@@ -1,59 +0,0 @@
|
|||||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
|
||||||
|
|
||||||
# Copyright 2011 Ken Pepple
|
|
||||||
#
|
|
||||||
# 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 cinder import test
|
|
||||||
from cinder import version
|
|
||||||
|
|
||||||
|
|
||||||
class VersionTestCase(test.TestCase):
|
|
||||||
"""Test cases for Versions code."""
|
|
||||||
def setUp(self):
|
|
||||||
"""Setup test with unchanging values."""
|
|
||||||
super(VersionTestCase, self).setUp()
|
|
||||||
self.version = version
|
|
||||||
self.version.FINAL = False
|
|
||||||
self.version.CINDER_VERSION = ['2012', '10']
|
|
||||||
self.version.YEAR, self.version.COUNT = self.version.CINDER_VERSION
|
|
||||||
self.version.version_info = {'branch_nick': u'LOCALBRANCH',
|
|
||||||
'revision_id': 'LOCALREVISION',
|
|
||||||
'revno': 0}
|
|
||||||
|
|
||||||
def test_version_string_is_good(self):
|
|
||||||
"""Ensure version string works."""
|
|
||||||
self.assertEqual("2012.10-dev", self.version.version_string())
|
|
||||||
|
|
||||||
def test_canonical_version_string_is_good(self):
|
|
||||||
"""Ensure canonical version works."""
|
|
||||||
self.assertEqual("2012.10", self.version.canonical_version_string())
|
|
||||||
|
|
||||||
def test_final_version_strings_are_identical(self):
|
|
||||||
"""Ensure final version strings match only at release."""
|
|
||||||
self.assertNotEqual(self.version.canonical_version_string(),
|
|
||||||
self.version.version_string())
|
|
||||||
self.version.FINAL = True
|
|
||||||
self.assertEqual(self.version.canonical_version_string(),
|
|
||||||
self.version.version_string())
|
|
||||||
|
|
||||||
def test_vcs_version_string_is_good(self):
|
|
||||||
"""Ensure uninstalled code generates local."""
|
|
||||||
self.assertEqual("LOCALBRANCH:LOCALREVISION",
|
|
||||||
self.version.vcs_version_string())
|
|
||||||
|
|
||||||
def test_version_string_with_vcs_is_good(self):
|
|
||||||
"""Ensure uninstalled code get version string."""
|
|
||||||
self.assertEqual("2012.10-LOCALBRANCH:LOCALREVISION",
|
|
||||||
self.version.version_string_with_vcs())
|
|
||||||
@@ -14,25 +14,12 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
CINDER_VERSION = ['2013', '1', None]
|
from cinder.openstack.common import version as common_version
|
||||||
YEAR, COUNT, REVISION = CINDER_VERSION
|
|
||||||
FINAL = False # This becomes true at Release Candidate time
|
|
||||||
|
|
||||||
|
CINDER_VENDOR = "OpenStack Foundation"
|
||||||
|
CINDER_PRODUCT = "OpenStack Cinder"
|
||||||
|
CINDER_PACKAGE = None # OS distro package version suffix
|
||||||
|
|
||||||
def canonical_version_string():
|
loaded = False
|
||||||
return '.'.join(filter(None, CINDER_VERSION))
|
version_info = common_version.VersionInfo('cinder')
|
||||||
|
version_string = version_info.version_string
|
||||||
|
|
||||||
def version_string():
|
|
||||||
if FINAL:
|
|
||||||
return canonical_version_string()
|
|
||||||
else:
|
|
||||||
return '%s-dev' % (canonical_version_string(),)
|
|
||||||
|
|
||||||
|
|
||||||
def vcs_version_string():
|
|
||||||
return 'LOCALBRANCH:LOCALREVISION'
|
|
||||||
|
|
||||||
|
|
||||||
def version_string_with_vcs():
|
|
||||||
return '%s-%s' % (canonical_version_string(), vcs_version_string())
|
|
||||||
|
|||||||
@@ -71,12 +71,11 @@ copyright = u'2010-present, OpenStack, LLC'
|
|||||||
# |version| and |release|, also used in various other places throughout the
|
# |version| and |release|, also used in various other places throughout the
|
||||||
# built documents.
|
# built documents.
|
||||||
#
|
#
|
||||||
from cinder import version as cinder_version
|
from cinder.version import version_info
|
||||||
#import cinder.version
|
|
||||||
# The full version, including alpha/beta/rc tags.
|
# The full version, including alpha/beta/rc tags.
|
||||||
release = cinder_version.version_string()
|
release = version_info.release_string()
|
||||||
# The short X.Y version.
|
# The short X.Y version.
|
||||||
version = cinder_version.canonical_version_string()
|
version = version_info.version_string()
|
||||||
|
|
||||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||||
# for a list of supported languages.
|
# for a list of supported languages.
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
[DEFAULT]
|
[DEFAULT]
|
||||||
|
|
||||||
# The list of modules to copy from openstack-common
|
# The list of modules to copy from openstack-common
|
||||||
modules=cfg,exception,excutils,gettextutils,importutils,iniparser,jsonutils,local,rootwrap,rpc,timeutils,log,setup,notifier,context,network_utils,policy,uuidutils,lockutils,fileutils,gettextutils,scheduler,scheduler.filters,scheduler.weights,install_venv_common,flakes
|
modules=cfg,exception,excutils,gettextutils,importutils,iniparser,jsonutils,local,rootwrap,rpc,timeutils,log,setup,notifier,context,network_utils,policy,uuidutils,lockutils,fileutils,gettextutils,scheduler,scheduler.filters,scheduler.weights,install_venv_common,flakes,version
|
||||||
|
|
||||||
# The base module to hold the copy of openstack.common
|
# The base module to hold the copy of openstack.common
|
||||||
base=cinder
|
base=cinder
|
||||||
|
|||||||
6
setup.py
6
setup.py
@@ -19,9 +19,9 @@
|
|||||||
import setuptools
|
import setuptools
|
||||||
|
|
||||||
from cinder.openstack.common import setup as common_setup
|
from cinder.openstack.common import setup as common_setup
|
||||||
from cinder import version
|
|
||||||
|
|
||||||
requires = common_setup.parse_requirements()
|
requires = common_setup.parse_requirements()
|
||||||
|
project = 'cinder'
|
||||||
|
|
||||||
filters = [
|
filters = [
|
||||||
"AvailabilityZoneFilter = "
|
"AvailabilityZoneFilter = "
|
||||||
@@ -41,8 +41,8 @@ weights = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
setuptools.setup(
|
setuptools.setup(
|
||||||
name='cinder',
|
name=project,
|
||||||
version=version.canonical_version_string(),
|
version=common_setup.get_version(project, '2013.1'),
|
||||||
description='block storage service',
|
description='block storage service',
|
||||||
author='OpenStack',
|
author='OpenStack',
|
||||||
author_email='cinder@lists.launchpad.net',
|
author_email='cinder@lists.launchpad.net',
|
||||||
|
|||||||
Reference in New Issue
Block a user