The cinder.openstack.common.versionutils Module

Helpers for comparing version strings.

exception DeprecatedConfig(msg)

Bases: exceptions.Exception

message = u'Fatal call to deprecated config: %(msg)s'
class deprecated(as_of, in_favor_of=None, remove_in=2, what=None)

Bases: object

A decorator to mark callables as deprecated.

This decorator logs a deprecation message when the callable it decorates is used. The message will include the release where the callable was deprecated, the release where it may be removed and possibly an optional replacement.

Examples:

  1. Specifying the required deprecated release
>>> @deprecated(as_of=deprecated.ICEHOUSE)
... def a(): pass
  1. Specifying a replacement:
>>> @deprecated(as_of=deprecated.ICEHOUSE, in_favor_of='f()')
... def b(): pass
  1. Specifying the release where the functionality may be removed:
>>> @deprecated(as_of=deprecated.ICEHOUSE, remove_in=+1)
... def c(): pass

4. Specifying the deprecated functionality will not be removed: >>> @deprecated(as_of=deprecated.ICEHOUSE, remove_in=0) ... def d(): pass

5. Specifying a replacement, deprecated functionality will not be removed: >>> @deprecated(as_of=deprecated.ICEHOUSE, in_favor_of=’f()’, remove_in=0) ... def e(): pass

BEXAR = 'B'
FOLSOM = 'F'
GRIZZLY = 'G'
HAVANA = 'H'
ICEHOUSE = 'I'
JUNO = 'J'
KILO = 'K'
LIBERTY = 'L'
is_compatible(requested_version, current_version, same_major=True)

Determine whether requested_version is satisfied by current_version; in other words, current_version is >= requested_version.

Parameters:
  • requested_version – version to check for compatibility
  • current_version – version to check against
  • same_major – if True, the major version must be identical between requested_version and current_version. This is used when a major-version difference indicates incompatibility between the two versions. Since this is the common-case in practice, the default is True.
Returns:

True if compatible, False if not

list_opts()

Entry point for oslo.config-generator.

report_deprecated_feature(logger, msg, *args, **kwargs)

Call this function when a deprecated feature is used.

If the system is configured for fatal deprecations then the message is logged at the ‘critical’ level and DeprecatedConfig will be raised.

Otherwise, the message will be logged (once) at the ‘warn’ level.

Raises:DeprecatedConfig if the system is configured for fatal deprecations.

Previous topic

The cinder.openstack.common.threadgroup Module

Next topic

The cinder.policy Module

This Page