Skip to content

Commit

Permalink
OpenStack: add custom parameters for the client
Browse files Browse the repository at this point in the history
* The instantiation of the novaclient Client might require additional
  parameters based on the specific OpenStack installation, like for
  example a region_name.
* Add a generic 'client_params' section to the configuration to
  allow to set arbitrary additional parameters that will be passed to
  the novalicent's Client.

Bug: T201881
Change-Id: I972b6b7326ddac2e01e39d7053e938bd33bd4ae8
  • Loading branch information
volans- committed Aug 14, 2018
1 parent 0a0a00a commit 65fe744
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cumin/backends/openstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,13 @@ def _get_nova_client(config, project):
novaclient.client.Client: the novaclient Client instance, already authenticated.
"""
params = config.get('client_params', {})
return nova_client.Client(
config.get('nova_api_version', '2'),
session=_get_keystone_session(config, project),
endpoint_type='public',
timeout=config.get('timeout', 10))
timeout=config.get('timeout', 10),
**params)


class OpenStackQuery(BaseQuery):
Expand Down
3 changes: 3 additions & 0 deletions doc/examples/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ openstack:
domain_suffix: openstack.local # OpenStack managed domain, to be added to all hostnames
nova_api_version: 2.12
timeout: 2 # Used for both Keystone and Nova API calls
# Additional parameters to set when instantiating the novaclient Client
client_params:
region_name: region1
# Default query parameters. The ones set by default anyway are: status: ACTIVE and vm_state: ACTIVE [optional]
query_params:
project: project_name # Parameter name: parameter value
Expand Down

0 comments on commit 65fe744

Please sign in to comment.