ACI: Introduce port parameter (#35168)
* ACI: Introduce port parameter * Add port parameter to documentation
This commit is contained in:
parent
46e53f90a7
commit
39aad91c5c
2 changed files with 24 additions and 4 deletions
|
@ -64,6 +64,7 @@ except ImportError:
|
|||
def aci_argument_spec():
|
||||
return dict(
|
||||
hostname=dict(type='str', required=True, aliases=['host']),
|
||||
port=dict(type='int', required=False),
|
||||
username=dict(type='str', default='admin', aliases=['user']),
|
||||
password=dict(type='str', no_log=True),
|
||||
private_key=dict(type='path', aliases=['cert_key']), # Beware, this is not the same as client_key !
|
||||
|
@ -214,6 +215,9 @@ class ACIModule(object):
|
|||
''' Log in to APIC '''
|
||||
|
||||
# Perform login request
|
||||
if 'port' in self.params and self.params['port'] is not None:
|
||||
url = '%(protocol)s://%(hostname)s:%(port)s/api/aaaLogin.json' % self.params
|
||||
else:
|
||||
url = '%(protocol)s://%(hostname)s/api/aaaLogin.json' % self.params
|
||||
payload = {'aaaUser': {'attributes': {'name': self.params['username'], 'pwd': self.params['password']}}}
|
||||
resp, auth = fetch_url(self.module, url,
|
||||
|
@ -275,6 +279,10 @@ class ACIModule(object):
|
|||
# Ensure method is set (only do this once)
|
||||
self.define_method()
|
||||
self.result['path'] = path
|
||||
|
||||
if 'port' in self.params and self.params['port'] is not None:
|
||||
self.result['url'] = '%(protocol)s://%(hostname)s:%(port)s/' % self.params + path.lstrip('/')
|
||||
else:
|
||||
self.result['url'] = '%(protocol)s://%(hostname)s/' % self.params + path.lstrip('/')
|
||||
|
||||
# Sign and encode request as to APIC's wishes
|
||||
|
@ -309,6 +317,10 @@ class ACIModule(object):
|
|||
|
||||
# Ensure method is set
|
||||
self.result['path'] = path
|
||||
|
||||
if 'port' in self.params and self.params['port'] is not None:
|
||||
self.result['url'] = '%(protocol)s://%(hostname)s:%(port)s/' % self.params + path.lstrip('/')
|
||||
else:
|
||||
self.result['url'] = '%(protocol)s://%(hostname)s/' % self.params + path.lstrip('/')
|
||||
|
||||
# Sign and encode request as to APIC's wishes
|
||||
|
@ -382,6 +394,9 @@ class ACIModule(object):
|
|||
path, filter_string = self._construct_url_1(root_class, child_includes)
|
||||
|
||||
self.result['path'] = path
|
||||
if 'port' in self.params and self.params['port'] is not None:
|
||||
self.result['url'] = '{0}://{1}:{2}/{3}'.format(self.module.params['protocol'], self.module.params['hostname'], self.module.params['port'], path)
|
||||
else:
|
||||
self.result['url'] = '{0}://{1}/{2}'.format(self.module.params['protocol'], self.module.params['hostname'], path)
|
||||
self.result['filter_string'] = filter_string
|
||||
|
||||
|
|
|
@ -28,6 +28,11 @@ options:
|
|||
- IP Address or hostname of APIC resolvable by Ansible control host.
|
||||
required: yes
|
||||
aliases: [ host ]
|
||||
port:
|
||||
description:
|
||||
- Port number to be used for REST connection.
|
||||
default: 443 (for https) and 80 (for http)
|
||||
type: int
|
||||
username:
|
||||
description:
|
||||
- The username to use for authentication.
|
||||
|
|
Loading…
Reference in a new issue