diff --git a/doc/source/api.rst b/doc/source/api.rst index 3166ddf62..450d66d99 100644 --- a/doc/source/api.rst +++ b/doc/source/api.rst @@ -38,6 +38,21 @@ parameter. Similarly, if your cloud uses keystone v3 and you have a DOMAIN_NAME or DOMAIN_ID, provide it as `user_domain_(name|id)` and if you are using a PROJECT_NAME also provide the domain information as `project_domain_(name|id)`. +novaclient adds 'python-novaclient' and its version to the user-agent string +that keystoneauth produces. If you are creating an application using novaclient +and want to register a name and version in the user-agent string, pass those +to the Session:: + + >>> sess = session.Session( + ... auth=auth, app_name'nodepool', app_version'1.2.3') + +If you are making a library that consumes novaclient but is not an end-user +application, you can append a (name, version) tuple to the session's +`additional_user_agent` property:: + + >>> sess = session.Session(auth=auth) + >>> sess.additional_user_agent.append(('shade', '1.2.3')) + For more information on this keystoneauth API, see `Using Sessions`_. .. _Using Sessions: http://docs.openstack.org/developer/keystoneauth/using-sessions.html diff --git a/novaclient/client.py b/novaclient/client.py index 09ca56474..be2fad874 100644 --- a/novaclient/client.py +++ b/novaclient/client.py @@ -33,6 +33,7 @@ import pkg_resources osprofiler_profiler = importutils.try_import("osprofiler.profiler") osprofiler_web = importutils.try_import("osprofiler.web") +import novaclient from novaclient import api_versions from novaclient import exceptions from novaclient import extension as ext @@ -48,6 +49,9 @@ extensions_ignored_name = ["__init__"] class SessionClient(adapter.LegacyJsonAdapter): + client_name = 'python-novaclient' + client_version = novaclient.__version__ + def __init__(self, *args, **kwargs): self.times = [] self.timings = kwargs.pop('timings', False) diff --git a/releasenotes/notes/add-user-agent-string-db77210dfd3ec671.yaml b/releasenotes/notes/add-user-agent-string-db77210dfd3ec671.yaml new file mode 100644 index 000000000..0e1eeb0f5 --- /dev/null +++ b/releasenotes/notes/add-user-agent-string-db77210dfd3ec671.yaml @@ -0,0 +1,6 @@ +--- +features: + - novaclient now adds information about itself to the keystoneauth + user-agent. Adding information about wrapping libraries or consuming + applications can be found at + https://docs.openstack.org/developer/python-novaclient/api.html