Remove the requirement on either endpoint_override or os_ironic_api_version
It makes zero sense from a caller's perspective. We only use it for efficient caching of API versions, which can safely be bypassed. Change-Id: I00508d36ec1679cdcc9c9d1ec744d818dee74e0b
This commit is contained in:
parent
5a9964b176
commit
c3e490800a
@ -14,7 +14,6 @@ import mock
|
||||
|
||||
from ironicclient.common import filecache
|
||||
from ironicclient.common import http
|
||||
from ironicclient import exc
|
||||
from ironicclient.tests.unit import utils
|
||||
from ironicclient.v1 import client
|
||||
|
||||
@ -89,10 +88,11 @@ class ClientTest(utils.BaseTestCase):
|
||||
api_version_select_state='default')
|
||||
|
||||
def test_client_cache_version_no_endpoint_as_arg(self, http_client_mock):
|
||||
self.assertRaises(exc.EndpointException,
|
||||
client.Client,
|
||||
session='fake_session',
|
||||
insecure=True)
|
||||
client.Client(session='fake_session', insecure=True)
|
||||
http_client_mock.assert_called_once_with(
|
||||
session='fake_session', insecure=True,
|
||||
os_ironic_api_version=client.DEFAULT_VER,
|
||||
api_version_select_state='default')
|
||||
|
||||
def test_client_initialized_managers(self, http_client_mock):
|
||||
cl = client.Client('http://ironic:6385', token='safe_token',
|
||||
|
@ -18,8 +18,6 @@ import logging
|
||||
from ironicclient.common import filecache
|
||||
from ironicclient.common import http
|
||||
from ironicclient.common.http import DEFAULT_VER
|
||||
from ironicclient.common.i18n import _
|
||||
from ironicclient import exc
|
||||
from ironicclient.v1 import allocation
|
||||
from ironicclient.v1 import chassis
|
||||
from ironicclient.v1 import conductor
|
||||
@ -66,23 +64,26 @@ class Client(object):
|
||||
else:
|
||||
kwargs['api_version_select_state'] = "user"
|
||||
else:
|
||||
if not endpoint_override:
|
||||
raise exc.EndpointException(
|
||||
_("Must provide 'endpoint_override' if "
|
||||
"'os_ironic_api_version' isn't specified"))
|
||||
|
||||
# If the user didn't specify a version, use a cached version if
|
||||
# one has been stored
|
||||
host, netport = http.get_server(endpoint_override)
|
||||
saved_version = filecache.retrieve_data(host=host, port=netport)
|
||||
if saved_version:
|
||||
kwargs['api_version_select_state'] = "cached"
|
||||
kwargs['os_ironic_api_version'] = saved_version
|
||||
if endpoint_override:
|
||||
# If the user didn't specify a version, use a cached version if
|
||||
# one has been stored
|
||||
host, netport = http.get_server(endpoint_override)
|
||||
saved_version = filecache.retrieve_data(host=host,
|
||||
port=netport)
|
||||
if saved_version:
|
||||
kwargs['api_version_select_state'] = "cached"
|
||||
kwargs['os_ironic_api_version'] = saved_version
|
||||
else:
|
||||
kwargs['api_version_select_state'] = "default"
|
||||
kwargs['os_ironic_api_version'] = DEFAULT_VER
|
||||
else:
|
||||
LOG.debug('Cannot use cached API version since endpoint '
|
||||
'override is not provided. Will negotiate again.')
|
||||
kwargs['api_version_select_state'] = "default"
|
||||
kwargs['os_ironic_api_version'] = DEFAULT_VER
|
||||
|
||||
kwargs['endpoint_override'] = endpoint_override
|
||||
if endpoint_override:
|
||||
kwargs['endpoint_override'] = endpoint_override
|
||||
self.http_client = http._construct_http_client(*args, **kwargs)
|
||||
|
||||
self.chassis = chassis.ChassisManager(self.http_client)
|
||||
|
@ -0,0 +1,6 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
Removes the requirement on passing either ``endpoint_override`` or
|
||||
``os_ironic_api_version`` to ``get_client``. This is only required for
|
||||
efficient caching of API versions and shouldn't be a hard requirement.
|
Loading…
Reference in New Issue
Block a user