From 7d1308b0d86da958fa1709c346f7123c8de2054f Mon Sep 17 00:00:00 2001 From: Michele Zuccala Date: Fri, 11 Aug 2017 15:31:20 +0200 Subject: [PATCH] [cloud] ovirt: add headers param to auth (#27881) * Add filter param to ovirt module auth * Update docs to include new filter param * Fix broken YAML * Replace filter param with headers --- lib/ansible/module_utils/ovirt.py | 1 + lib/ansible/modules/cloud/ovirt/ovirt_auth.py | 14 ++++++++++++++ lib/ansible/utils/module_docs_fragments/ovirt.py | 1 + .../utils/module_docs_fragments/ovirt_facts.py | 1 + 4 files changed, 17 insertions(+) diff --git a/lib/ansible/module_utils/ovirt.py b/lib/ansible/module_utils/ovirt.py index 588150b53a..3e001c0d16 100644 --- a/lib/ansible/module_utils/ovirt.py +++ b/lib/ansible/module_utils/ovirt.py @@ -143,6 +143,7 @@ def create_connection(auth): insecure=auth.get('insecure', False), token=auth.get('token', None), kerberos=auth.get('kerberos', None), + headers=auth.get('headers', None), ) diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_auth.py b/lib/ansible/modules/cloud/ovirt/ovirt_auth.py index d2074671c2..875d574fb3 100644 --- a/lib/ansible/modules/cloud/ovirt/ovirt_auth.py +++ b/lib/ansible/modules/cloud/ovirt/ovirt_auth.py @@ -84,6 +84,13 @@ options: description: - "A boolean flag indicating if Kerberos authentication should be used instead of the default basic authentication." + + headers: + required: False + description: + - "A dictionary of HTTP headers to be added to each API call." + version_added: "2.4" + requirements: - python >= 2.7 - ovirt-engine-sdk-python >= 4.0.0 @@ -168,6 +175,10 @@ ovirt_auth: returned: success type: bool sample: False + headers: + description: Dictionary of HTTP headers to be added to each API call. + returned: success + type: dict ''' import traceback @@ -192,6 +203,7 @@ def main(): timeout=dict(required=False, type='int', default=0), compress=dict(required=False, type='bool', default=True), kerberos=dict(required=False, type='bool', default=False), + headers=dict(required=False, type='dict'), state=dict(default='present', choices=['present', 'absent']), ovirt_auth=dict(required=None, type='dict'), ), @@ -218,6 +230,7 @@ def main(): timeout=params.get('timeout'), compress=params.get('compress'), kerberos=params.get('kerberos'), + headers=params.get('headers'), token=params.get('token'), ) try: @@ -233,6 +246,7 @@ def main(): timeout=params.get('timeout'), compress=params.get('compress'), kerberos=params.get('kerberos'), + headers=params.get('headers'), ) if state == 'present' else dict() ) ) diff --git a/lib/ansible/utils/module_docs_fragments/ovirt.py b/lib/ansible/utils/module_docs_fragments/ovirt.py index 8eefbedf63..b9e9b6c91f 100644 --- a/lib/ansible/utils/module_docs_fragments/ovirt.py +++ b/lib/ansible/utils/module_docs_fragments/ovirt.py @@ -56,6 +56,7 @@ options: CA certificate store is used. Default value is set by I(OVIRT_CAFILE) environment variable." - "C(kerberos) - A boolean flag indicating if Kerberos authentication should be used instead of the default basic authentication." + - "C(headers) - Dictionary of HTTP headers to be added to each API call." timeout: description: - "The amount of time in seconds the module should wait for the instance to diff --git a/lib/ansible/utils/module_docs_fragments/ovirt_facts.py b/lib/ansible/utils/module_docs_fragments/ovirt_facts.py index 36a3da0745..6ce3ae9e15 100644 --- a/lib/ansible/utils/module_docs_fragments/ovirt_facts.py +++ b/lib/ansible/utils/module_docs_fragments/ovirt_facts.py @@ -53,6 +53,7 @@ options: CA certificate store is used. Default value is set by I(OVIRT_CAFILE) environment variable." - "C(kerberos) - A boolean flag indicating if Kerberos authentication should be used instead of the default basic authentication." + - "C(headers) - Dictionary of HTTP headers to be added to each API call." requirements: - python >= 2.7 - ovirt-engine-sdk-python >= 4.0.0