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:
Andrey Kurilin 2016-06-22 16:35:21 +03:00
parent d6ca9e2d74
commit 84f4e1e10c
2 changed files with 15 additions and 9 deletions

View File

@ -17,7 +17,8 @@ import logging
from novaclient import api_versions
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 aggregates
from novaclient.v2 import availability_zones
@ -101,18 +102,18 @@ class Client(object):
:param str session: Session
:param str auth: Auth
: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
:type api_version: novaclient.api_versions.APIVersion
"""
if direct_use:
import warnings
warnings.warn(
_LW("'novaclient.v2.client.Client' is not designed to be "
"initialized directly. It is inner class of novaclient. "
"Please, use 'novaclient.client.Client' instead. "
"Related lp bug-report: 1493576"))
raise exceptions.Forbidden(
403, _LE("'novaclient.v2.client.Client' is not designed to be "
"initialized directly. It is inner class of "
"novaclient. You should use "
"'novaclient.client.Client' instead. Related lp "
"bug-report: 1493576"))
# FIXME(comstud): Rename the api_key argument above when we
# know it's not being used as keyword argument

View File

@ -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.