diff options
| author | Dmitry Tantsur <dtantsur@protonmail.com> | 2020-02-10 11:02:09 +0100 |
|---|---|---|
| committer | Dmitry Tantsur <dtantsur@protonmail.com> | 2020-02-10 12:58:54 +0000 |
| commit | 1220d7685723b8235135d2d02c11008c7f7fb18a (patch) | |
| tree | 8afca1ba7d1bf4aeaf2a7a4025ab36c16db093de /ironicclient/v1/client.py | |
| parent | 8188c01489f63b5fd10702ebccbd742b62488d6e (diff) | |
| download | python-ironicclient-train-em.tar.gz | |
Provide a clear error message when using client.Client without a sessiontrain-em3.1.2stable/train
Currently we fail with _construct_http_client() takes at least 1 argument.
This change provides a proper TypeError and updates documentation to make
it clear where a session is required. Also provided are explicit unit
tests on passing a session via various means.
Change-Id: I96073dc80d225a9b88fdc12bb058c0145aca623b
(cherry picked from commit e8914a7ef9eb582441a7067f2663e19209f32822)
Diffstat (limited to 'ironicclient/v1/client.py')
| -rw-r--r-- | ironicclient/v1/client.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/ironicclient/v1/client.py b/ironicclient/v1/client.py index cf729d9..254185e 100644 --- a/ironicclient/v1/client.py +++ b/ironicclient/v1/client.py @@ -44,6 +44,11 @@ class Client(object): def __init__(self, endpoint_override=None, *args, **kwargs): """Initialize a new client for the Ironic v1 API.""" + if not args and not kwargs.get('session'): + raise TypeError("A session is required for creating a client, " + "use ironicclient.client.get_client to create " + "it automatically") + allow_downgrade = kwargs.pop('allow_api_version_downgrade', False) if kwargs.get('os_ironic_api_version'): # TODO(TheJulia): We should sanity check os_ironic_api_version |
