diff --git a/novaclient/v2/client.py b/novaclient/v2/client.py index c202b754e..f5dee15dc 100644 --- a/novaclient/v2/client.py +++ b/novaclient/v2/client.py @@ -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 diff --git a/releasenotes/notes/restrict-direct-use-of-v2client-c8e1ee2afefec5a1.yaml b/releasenotes/notes/restrict-direct-use-of-v2client-c8e1ee2afefec5a1.yaml new file mode 100644 index 000000000..0e90cc810 --- /dev/null +++ b/releasenotes/notes/restrict-direct-use-of-v2client-c8e1ee2afefec5a1.yaml @@ -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.