Avi credentials added sub-options (#57531)

* Split Avi Credentials into two parts - secrets and login_info

* Fixed indentation issue

* Removed trailing whitespaces

* Added sub-options to avi credentials

* Added sub-options to avi credentials

* Updated argument specs to use fallback instead of getting defaults from environment variable
This commit is contained in:
Chaitanya Deshpande 2019-06-12 21:49:29 +05:30 committed by Nathaniel Case
parent 5ac3661176
commit 6d21cebd7d
2 changed files with 58 additions and 4 deletions

View file

@ -10,6 +10,7 @@ import re
import logging
import sys
from copy import deepcopy
from ansible.module_utils.basic import env_fallback
try:
from ansible.module_utils.network.avi.avi_api import (
@ -544,13 +545,28 @@ def avi_common_argument_spec():
Returns common arguments for all Avi modules
:return: dict
"""
credentials_spec = dict(
controller=dict(fallback=(env_fallback, ['AVI_CONTROLLER'])),
username=dict(fallback=(env_fallback, ['AVI_USERNAME'])),
password=dict(fallback=(env_fallback, ['AVI_PASSWORD']), no_log=True),
api_version=dict(default='16.4.4', type='str'),
tenant=dict(default='admin'),
tenant_uuid=dict(default='', type='str'),
port=dict(type='int'),
timeout=dict(default=300, type='int'),
token=dict(default='', type='str', no_log=True),
session_id=dict(default='', type='str', no_log=True),
csrftoken=dict(default='', type='str', no_log=True)
)
return dict(
controller=dict(default=os.environ.get('AVI_CONTROLLER', '')),
username=dict(default=os.environ.get('AVI_USERNAME', '')),
password=dict(default=os.environ.get('AVI_PASSWORD', ''), no_log=True),
controller=dict(fallback=(env_fallback, ['AVI_CONTROLLER'])),
username=dict(fallback=(env_fallback, ['AVI_USERNAME'])),
password=dict(fallback=(env_fallback, ['AVI_PASSWORD']), no_log=True),
tenant=dict(default='admin'),
tenant_uuid=dict(default=''),
api_version=dict(default='16.4.4', type='str'),
avi_credentials=dict(default=None, no_log=True, type='dict'),
avi_credentials=dict(default=None, type='dict',
options=credentials_spec),
api_context=dict(type='dict'),
avi_disable_session_cache_as_fact=dict(default=False, type='bool'))

View file

@ -43,6 +43,43 @@ options:
avi_credentials:
description:
- Avi Credentials dictionary which can be used in lieu of enumerating Avi Controller login details.
suboptions:
controller:
description:
- Avi controller IP or SQDN
username:
description:
- Avi controller username
password:
description:
- Avi controller password
api_version:
description:
- Avi controller version
default: 16.4.4
tenant:
description:
- Avi controller tenant
default: admin
tenant_uuid:
description:
- Avi controller tenant UUID
port:
description:
- Avi controller port
token:
description:
- Avi controller API token
timeout:
description:
- Avi controller request timeout
default: 300
session_id:
description:
- Avi controller API session id to reuse existing session with csrftoken
csrftoken:
description:
- Avi controller API csrftoken to reuse existing session with session id
type: dict
version_added: "2.5"
api_context:
@ -56,6 +93,7 @@ options:
- It disables avi session information to be cached as a fact.
type: bool
version_added: "2.6"
notes:
- For more information on using Ansible to manage Avi Network devices see U(https://www.ansible.com/ansible-avi-networks).
'''