diff options
author | Monty Taylor <mordred@inaugust.com> | 2017-04-02 11:22:34 -0500 |
---|---|---|
committer | Monty Taylor <mordred@inaugust.com> | 2017-04-18 03:51:04 -0500 |
commit | 64b28d42eda595a6fb4ee8b46d93cd61e612aae1 (patch) | |
tree | 192722a9ca41056b98b85b6916309f4fb6173516 /os_client_config/__init__.py | |
parent | 451ec8daadfb6702841878cac1a8d4e6012b838d (diff) | |
download | os-client-config-64b28d42eda595a6fb4ee8b46d93cd61e612aae1.tar.gz |
Add ability to pass in user_agent
keystoneauth supports adding a user_agent info to the Session and
Adapter via app_name. Allow users to add app_name/app_name and versions as
desired. Also, add os-client-config into additional_user_agent.
As an example, once this is landed and plumbed through shade,
nodepool will set app_name='nodepool' and we'll have:
User-Agent: nodepool/0.4.0 os-client-config/1.26.1 shade/1.19.1
keystoneauth1/2.18.0 python-requests/2.13.0 CPython/2.7.12
Change-Id: I1eb4dbd2587dcbe297b5c060c3c34b68ef51ef5e
Diffstat (limited to 'os_client_config/__init__.py')
-rw-r--r-- | os_client_config/__init__.py | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/os_client_config/__init__.py b/os_client_config/__init__.py index a36a130..1f1266c 100644 --- a/os_client_config/__init__.py +++ b/os_client_config/__init__.py @@ -23,9 +23,14 @@ from os_client_config.config import OpenStackConfig # noqa __version__ = pbr.version.VersionInfo('os_client_config').version_string() -def get_config(service_key=None, options=None, **kwargs): +def get_config( + service_key=None, options=None, + app_name=None, app_version=None, + **kwargs): load_yaml_config = kwargs.pop('load_yaml_config', True) - config = OpenStackConfig(load_yaml_config=load_yaml_config) + config = OpenStackConfig( + load_yaml_config=load_yaml_config, + app_name=app_name, app_version=app_version) if options: config.register_argparse_arguments(options, sys.argv, service_key) parsed_options = options.parse_known_args(sys.argv) @@ -35,7 +40,10 @@ def get_config(service_key=None, options=None, **kwargs): return config.get_one_cloud(options=parsed_options, **kwargs) -def make_rest_client(service_key, options=None, **kwargs): +def make_rest_client( + service_key, options=None, + app_name=None, app_version=None, + **kwargs): """Simple wrapper function. It has almost no features. This will get you a raw requests Session Adapter that is mounted @@ -48,7 +56,10 @@ def make_rest_client(service_key, options=None, **kwargs): get_session_client on it. This function is to make it easy to poke at OpenStack REST APIs with a properly configured keystone session. """ - cloud = get_config(service_key=service_key, options=options, **kwargs) + cloud = get_config( + service_key=service_key, options=options, + app_name=app_name, app_version=app_version, + **kwargs) return cloud.get_session_client(service_key) # Backwards compat - simple_client was a terrible name simple_client = make_rest_client |