Raise an exception in v2.client for direct_use
The direct use of novaclient.v2.client.Client was deprecated long time ago (2.29.0 release of novaclient, which relates to Liberty release of OpenStack). It is time to move from warning message to an exception. It will allow us to change novaclient.v2.client.Client interface and keep compatible stuff to novaclient.client.Client. Change-Id: I6e6c6eebcf7992d553a2f85f57b8c2ede0cc8311 Related-Bug: #1493576
This commit is contained in:
parent
d6ca9e2d74
commit
84f4e1e10c
@ -17,7 +17,8 @@ import logging
|
|||||||
|
|
||||||
from novaclient import api_versions
|
from novaclient import api_versions
|
||||||
from novaclient import client
|
from novaclient import client
|
||||||
from novaclient.i18n import _LW
|
from novaclient import exceptions
|
||||||
|
from novaclient.i18n import _LE
|
||||||
from novaclient.v2 import agents
|
from novaclient.v2 import agents
|
||||||
from novaclient.v2 import aggregates
|
from novaclient.v2 import aggregates
|
||||||
from novaclient.v2 import availability_zones
|
from novaclient.v2 import availability_zones
|
||||||
@ -101,18 +102,18 @@ class Client(object):
|
|||||||
:param str session: Session
|
:param str session: Session
|
||||||
:param str auth: Auth
|
:param str auth: Auth
|
||||||
:param api_version: Compute API version
|
:param api_version: Compute API version
|
||||||
:param direct_use: Direct use
|
:param direct_use: Inner variable of novaclient. Do not use it outside
|
||||||
|
novaclient. It's restricted.
|
||||||
:param logger: Logger
|
:param logger: Logger
|
||||||
:type api_version: novaclient.api_versions.APIVersion
|
:type api_version: novaclient.api_versions.APIVersion
|
||||||
"""
|
"""
|
||||||
if direct_use:
|
if direct_use:
|
||||||
import warnings
|
raise exceptions.Forbidden(
|
||||||
|
403, _LE("'novaclient.v2.client.Client' is not designed to be "
|
||||||
warnings.warn(
|
"initialized directly. It is inner class of "
|
||||||
_LW("'novaclient.v2.client.Client' is not designed to be "
|
"novaclient. You should use "
|
||||||
"initialized directly. It is inner class of novaclient. "
|
"'novaclient.client.Client' instead. Related lp "
|
||||||
"Please, use 'novaclient.client.Client' instead. "
|
"bug-report: 1493576"))
|
||||||
"Related lp bug-report: 1493576"))
|
|
||||||
|
|
||||||
# FIXME(comstud): Rename the api_key argument above when we
|
# FIXME(comstud): Rename the api_key argument above when we
|
||||||
# know it's not being used as keyword argument
|
# know it's not being used as keyword argument
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
upgrade:
|
||||||
|
- novaclient.v2.client.Client raises an exception in case of direct usage
|
||||||
|
instead of warning message. novaclient.client.Client is a primary
|
||||||
|
interface to initialize the python client for Nova.
|
Loading…
Reference in New Issue
Block a user