Merge "Replace latest with explicit version"
This commit is contained in:
commit
7c6b39eeba
|
@ -19,7 +19,6 @@ import re
|
||||||
from oslo_utils import strutils
|
from oslo_utils import strutils
|
||||||
|
|
||||||
from watcherclient._i18n import _
|
from watcherclient._i18n import _
|
||||||
from watcherclient.common import httpclient
|
|
||||||
from watcherclient import exceptions
|
from watcherclient import exceptions
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
@ -27,6 +26,7 @@ if not LOG.handlers:
|
||||||
LOG.addHandler(logging.StreamHandler())
|
LOG.addHandler(logging.StreamHandler())
|
||||||
|
|
||||||
|
|
||||||
|
MINOR_1_START_END_TIMING = '1.1'
|
||||||
HEADER_NAME = "OpenStack-API-Version"
|
HEADER_NAME = "OpenStack-API-Version"
|
||||||
# key is a deprecated version and value is an alternative version.
|
# key is a deprecated version and value is an alternative version.
|
||||||
DEPRECATED_VERSIONS = {}
|
DEPRECATED_VERSIONS = {}
|
||||||
|
@ -41,7 +41,7 @@ def allow_start_end_audit_time(requested_version):
|
||||||
audits.
|
audits.
|
||||||
"""
|
"""
|
||||||
return (APIVersion(requested_version) >=
|
return (APIVersion(requested_version) >=
|
||||||
APIVersion(httpclient.MINOR_1_START_END_TIMING))
|
APIVersion(MINOR_1_START_END_TIMING))
|
||||||
|
|
||||||
|
|
||||||
class APIVersion(object):
|
class APIVersion(object):
|
||||||
|
|
|
@ -34,6 +34,7 @@ from six.moves import http_client
|
||||||
import six.moves.urllib.parse as urlparse
|
import six.moves.urllib.parse as urlparse
|
||||||
|
|
||||||
from watcherclient._i18n import _
|
from watcherclient._i18n import _
|
||||||
|
from watcherclient.common import api_versioning
|
||||||
from watcherclient import exceptions
|
from watcherclient import exceptions
|
||||||
|
|
||||||
|
|
||||||
|
@ -43,7 +44,6 @@ from watcherclient import exceptions
|
||||||
# http://specs.openstack.org/openstack/watcher-specs/specs/kilo/api-microversions.html # noqa
|
# http://specs.openstack.org/openstack/watcher-specs/specs/kilo/api-microversions.html # noqa
|
||||||
# for full details.
|
# for full details.
|
||||||
DEFAULT_VER = 'latest'
|
DEFAULT_VER = 'latest'
|
||||||
MINOR_1_START_END_TIMING = '1.1'
|
|
||||||
LAST_KNOWN_API_VERSION = 1
|
LAST_KNOWN_API_VERSION = 1
|
||||||
LATEST_VERSION = '1.{}'.format(LAST_KNOWN_API_VERSION)
|
LATEST_VERSION = '1.{}'.format(LAST_KNOWN_API_VERSION)
|
||||||
|
|
||||||
|
@ -298,9 +298,14 @@ class HTTPClient(VersionNegotiationMixin):
|
||||||
kwargs['headers'] = copy.deepcopy(kwargs.get('headers', {}))
|
kwargs['headers'] = copy.deepcopy(kwargs.get('headers', {}))
|
||||||
kwargs['headers'].setdefault('User-Agent', USER_AGENT)
|
kwargs['headers'].setdefault('User-Agent', USER_AGENT)
|
||||||
if self.os_infra_optim_api_version:
|
if self.os_infra_optim_api_version:
|
||||||
|
api_version = api_versioning.get_api_version(
|
||||||
|
self.os_infra_optim_api_version)
|
||||||
|
if api_version.is_latest():
|
||||||
|
api_version = api_versioning.get_api_version(
|
||||||
|
LATEST_VERSION)
|
||||||
kwargs['headers'].setdefault(
|
kwargs['headers'].setdefault(
|
||||||
'OpenStack-API-Version',
|
'OpenStack-API-Version',
|
||||||
' '.join(['infra-optim', self.os_infra_optim_api_version]))
|
' '.join(['infra-optim', api_version.get_string()]))
|
||||||
if self.auth_token:
|
if self.auth_token:
|
||||||
kwargs['headers'].setdefault('X-Auth-Token', self.auth_token)
|
kwargs['headers'].setdefault('X-Auth-Token', self.auth_token)
|
||||||
|
|
||||||
|
@ -508,10 +513,15 @@ class SessionClient(VersionNegotiationMixin, adapter.LegacyJsonAdapter):
|
||||||
)
|
)
|
||||||
|
|
||||||
if getattr(self, 'os_infra_optim_api_version', None):
|
if getattr(self, 'os_infra_optim_api_version', None):
|
||||||
|
api_version = api_versioning.get_api_version(
|
||||||
|
self.os_infra_optim_api_version)
|
||||||
|
if api_version.is_latest():
|
||||||
|
api_version = api_versioning.get_api_version(
|
||||||
|
LATEST_VERSION)
|
||||||
kwargs['headers'].setdefault(
|
kwargs['headers'].setdefault(
|
||||||
'OpenStack-API-Version',
|
'OpenStack-API-Version',
|
||||||
' '.join(['infra-optim',
|
' '.join(['infra-optim',
|
||||||
self.os_infra_optim_api_version]))
|
api_version.get_string()]))
|
||||||
|
|
||||||
endpoint_filter = kwargs.setdefault('endpoint_filter', {})
|
endpoint_filter = kwargs.setdefault('endpoint_filter', {})
|
||||||
endpoint_filter.setdefault('interface', self.interface)
|
endpoint_filter.setdefault('interface', self.interface)
|
||||||
|
|
Loading…
Reference in New Issue