mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 22:33:25 +00:00
Remove the f5-sdk from more bigiq modules (#47721)
This commit is contained in:
@@ -60,7 +60,8 @@ f5_provider_spec = {
|
||||
default='rest'
|
||||
),
|
||||
'timeout': dict(type='int'),
|
||||
'auth_provider': dict()
|
||||
'auth_provider': dict(),
|
||||
'proxy_to': dict(),
|
||||
}
|
||||
|
||||
f5_argument_spec = {
|
||||
@@ -70,27 +71,22 @@ f5_argument_spec = {
|
||||
f5_top_spec = {
|
||||
'server': dict(
|
||||
removed_in_version=2.9,
|
||||
fallback=(env_fallback, ['F5_SERVER'])
|
||||
),
|
||||
'user': dict(
|
||||
removed_in_version=2.9,
|
||||
fallback=(env_fallback, ['F5_USER', 'ANSIBLE_NET_USERNAME'])
|
||||
),
|
||||
'password': dict(
|
||||
removed_in_version=2.9,
|
||||
no_log=True,
|
||||
aliases=['pass', 'pwd'],
|
||||
fallback=(env_fallback, ['F5_PASSWORD', 'ANSIBLE_NET_PASSWORD'])
|
||||
),
|
||||
'validate_certs': dict(
|
||||
removed_in_version=2.9,
|
||||
type='bool',
|
||||
fallback=(env_fallback, ['F5_VALIDATE_CERTS'])
|
||||
),
|
||||
'server_port': dict(
|
||||
removed_in_version=2.9,
|
||||
type='int',
|
||||
fallback=(env_fallback, ['F5_SERVER_PORT'])
|
||||
),
|
||||
'transport': dict(
|
||||
removed_in_version=2.9,
|
||||
@@ -135,7 +131,7 @@ def fqdn_name(partition, value):
|
||||
return fq_name(partition, value)
|
||||
|
||||
|
||||
def fq_name(partition, value):
|
||||
def fq_name(partition, value, sub_path=''):
|
||||
"""Returns a 'Fully Qualified' name
|
||||
|
||||
A BIG-IP expects most names of resources to be in a fully-qualified
|
||||
@@ -167,16 +163,29 @@ def fq_name(partition, value):
|
||||
value (string): The name that you want to attach a partition to.
|
||||
This value will be returned unchanged if it has a partition
|
||||
attached to it already.
|
||||
sub_path (string): The sub path element. If defined the sub_path
|
||||
will be inserted between partition and value.
|
||||
This will also work on FQ names.
|
||||
Returns:
|
||||
string: The fully qualified name, given the input parameters.
|
||||
"""
|
||||
if value is not None:
|
||||
if value is not None and sub_path == '':
|
||||
try:
|
||||
int(value)
|
||||
return '/{0}/{1}'.format(partition, value)
|
||||
except (ValueError, TypeError):
|
||||
if not value.startswith('/'):
|
||||
return '/{0}/{1}'.format(partition, value)
|
||||
if value is not None and sub_path != '':
|
||||
try:
|
||||
int(value)
|
||||
return '/{0}/{1}/{2}'.format(partition, sub_path, value)
|
||||
except (ValueError, TypeError):
|
||||
if value.startswith('/'):
|
||||
dummy, partition, name = value.split('/')
|
||||
return '/{0}/{1}/{2}'.format(partition, sub_path, name)
|
||||
if not value.startswith('/'):
|
||||
return '/{0}/{1}/{2}'.format(partition, sub_path, value)
|
||||
return value
|
||||
|
||||
|
||||
@@ -211,8 +220,8 @@ def run_commands(module, commands, check_rc=True):
|
||||
|
||||
|
||||
def flatten_boolean(value):
|
||||
truthy = list(BOOLEANS_TRUE) + ['enabled']
|
||||
falsey = list(BOOLEANS_FALSE) + ['disabled']
|
||||
truthy = list(BOOLEANS_TRUE) + ['enabled', 'True']
|
||||
falsey = list(BOOLEANS_FALSE) + ['disabled', 'False']
|
||||
if value is None:
|
||||
return None
|
||||
elif value in truthy:
|
||||
@@ -222,6 +231,7 @@ def flatten_boolean(value):
|
||||
|
||||
|
||||
def cleanup_tokens(client=None):
|
||||
# TODO(Remove this. No longer needed with iControlRestSession destructor)
|
||||
if client is None:
|
||||
return
|
||||
try:
|
||||
@@ -394,12 +404,14 @@ def is_ansible_debug(module):
|
||||
|
||||
|
||||
def fail_json(module, ex, client=None):
|
||||
# TODO(Remove this. No longer needed with iControlRestSession destructor)
|
||||
if is_ansible_debug(module) and client:
|
||||
module.fail_json(msg=str(ex), __f5debug__=client.api.debug_output)
|
||||
module.fail_json(msg=str(ex))
|
||||
|
||||
|
||||
def exit_json(module, results, client=None):
|
||||
# TODO(Remove this. No longer needed with iControlRestSession destructor)
|
||||
if is_ansible_debug(module) and client:
|
||||
results['__f5debug__'] = client.api.debug_output
|
||||
module.exit_json(**results)
|
||||
@@ -532,7 +544,9 @@ class F5BaseClient(object):
|
||||
|
||||
def merge_provider_params(self):
|
||||
result = dict()
|
||||
provider = self.params.get('provider', {})
|
||||
provider = self.params.get('provider', None)
|
||||
if not provider:
|
||||
provider = {}
|
||||
|
||||
self.merge_provider_server_param(result, provider)
|
||||
self.merge_provider_server_port_param(result, provider)
|
||||
@@ -540,6 +554,7 @@ class F5BaseClient(object):
|
||||
self.merge_provider_auth_provider_param(result, provider)
|
||||
self.merge_provider_user_param(result, provider)
|
||||
self.merge_provider_password_param(result, provider)
|
||||
self.merge_proxy_to_param(result, provider)
|
||||
|
||||
return result
|
||||
|
||||
@@ -626,6 +641,12 @@ class F5BaseClient(object):
|
||||
else:
|
||||
result['password'] = None
|
||||
|
||||
def merge_proxy_to_param(self, result, provider):
|
||||
if self.validate_params('proxy_to', provider):
|
||||
result['proxy_to'] = provider['proxy_to']
|
||||
else:
|
||||
result['proxy_to'] = None
|
||||
|
||||
|
||||
class AnsibleF5Parameters(object):
|
||||
def __init__(self, *args, **kwargs):
|
||||
@@ -644,6 +665,16 @@ class AnsibleF5Parameters(object):
|
||||
if params:
|
||||
self._params.update(params)
|
||||
for k, v in iteritems(params):
|
||||
# Adding this here because ``username`` is a connection parameter
|
||||
# and in cases where it is also an API parameter, we run the risk
|
||||
# of overriding the specified parameter with the connection parameter.
|
||||
#
|
||||
# Since this is a problem, and since "username" is never a valid
|
||||
# parameter outside its usage in connection params (where we do not
|
||||
# use the ApiParameter or ModuleParameters classes) it is safe to
|
||||
# skip over it if it is provided.
|
||||
if k == 'password':
|
||||
continue
|
||||
if self.api_map is not None and k in self.api_map:
|
||||
map_key = self.api_map[k]
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user