Skip to content

Commit

Permalink
ACI: Move to 'host' parameter instead of 'hostname' (#35161)
Browse files Browse the repository at this point in the history
* ACI: Move to 'host' parameter instead of 'hostname'

* Update host parameter in documentation fragment too
  • Loading branch information
dagwieers committed Jan 22, 2018
1 parent cf1f7b5 commit d600485
Show file tree
Hide file tree
Showing 56 changed files with 197 additions and 198 deletions.
18 changes: 9 additions & 9 deletions lib/ansible/module_utils/network/aci/aci.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@

def aci_argument_spec():
return dict(
hostname=dict(type='str', required=True, aliases=['host']),
host=dict(type='str', required=True, aliases=['hostname']),
port=dict(type='int', required=False),
username=dict(type='str', default='admin', aliases=['user']),
password=dict(type='str', no_log=True),
Expand Down Expand Up @@ -216,9 +216,9 @@ def login(self):

# 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
url = '%(protocol)s://%(host)s:%(port)s/api/aaaLogin.json' % self.params
else:
url = '%(protocol)s://%(hostname)s/api/aaaLogin.json' % self.params
url = '%(protocol)s://%(host)s/api/aaaLogin.json' % self.params
payload = {'aaaUser': {'attributes': {'name': self.params['username'], 'pwd': self.params['password']}}}
resp, auth = fetch_url(self.module, url,
data=json.dumps(payload),
Expand Down Expand Up @@ -281,9 +281,9 @@ def request(self, path, payload=None):
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('/')
self.result['url'] = '%(protocol)s://%(host)s:%(port)s/' % self.params + path.lstrip('/')
else:
self.result['url'] = '%(protocol)s://%(hostname)s/' % self.params + path.lstrip('/')
self.result['url'] = '%(protocol)s://%(host)s/' % self.params + path.lstrip('/')

# Sign and encode request as to APIC's wishes
if self.params['private_key'] is not None:
Expand Down Expand Up @@ -319,9 +319,9 @@ def query(self, path):
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('/')
self.result['url'] = '%(protocol)s://%(host)s:%(port)s/' % self.params + path.lstrip('/')
else:
self.result['url'] = '%(protocol)s://%(hostname)s/' % self.params + path.lstrip('/')
self.result['url'] = '%(protocol)s://%(host)s/' % self.params + path.lstrip('/')

# Sign and encode request as to APIC's wishes
if self.params['private_key'] is not None:
Expand Down Expand Up @@ -395,9 +395,9 @@ def construct_url(self, root_class, subclass_1=None, subclass_2=None, subclass_3

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)
self.result['url'] = '{0}://{1}:{2}/{3}'.format(self.module.params['protocol'], self.module.params['host'], self.module.params['port'], path)
else:
self.result['url'] = '{0}://{1}/{2}'.format(self.module.params['protocol'], self.module.params['hostname'], path)
self.result['url'] = '{0}://{1}/{2}'.format(self.module.params['protocol'], self.module.params['host'], path)
self.result['filter_string'] = filter_string

def _construct_url_1(self, obj, child_includes):
Expand Down
8 changes: 4 additions & 4 deletions lib/ansible/modules/network/aci/aci_aaa_user_certificate.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
EXAMPLES = r'''
- name: Add a certificate to user
aci_aaa_user_certificate:
hostname: apic
host: apic
username: admin
password: SomeSecretPassword
user: admin
Expand All @@ -64,7 +64,7 @@
- name: Remove a certificate of a user
aci_aaa_user_certificate:
hostname: apic
host: apic
username: admin
password: SomeSecretPassword
user: admin
Expand All @@ -73,7 +73,7 @@
- name: Query a certificate of a user
aci_aaa_user_certificate:
hostname: apic
host: apic
username: admin
password: SomeSecretPassword
user: admin
Expand All @@ -82,7 +82,7 @@
- name: Query all certificates of a user
aci_aaa_user_certificate:
hostname: apic
host: apic
username: admin
password: SomeSecretPassword
user: admin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
EXAMPLES = r'''
- name: Associate an Interface Access Port Selector to an Interface Policy Leaf Profile with a Policy Group
aci_access_port_to_interface_policy_leaf_profile:
hostname: apic
host: apic
username: admin
password: SomeSecretPassword
leaf_interface_profile: leafintprfname
Expand All @@ -86,7 +86,7 @@
- name: Associate an interface access port selector to an Interface Policy Leaf Profile (w/o policy group) (check if this works)
aci_access_port_to_interface_policy_leaf_profile:
hostname: apic
host: apic
username: admin
password: SomeSecretPassword
leaf_interface_profile: leafintprfname
Expand All @@ -98,7 +98,7 @@
- name: Remove an interface access port selector associated with an Interface Policy Leaf Profile
aci_access_port_to_interface_policy_leaf_profile:
hostname: apic
host: apic
username: admin
password: SomeSecretPassword
leaf_interface_profile: leafintprfname
Expand All @@ -107,7 +107,7 @@
- name: Query Specific access_port_selector under given leaf_interface_profile
aci_access_port_to_interface_policy_leaf_profile:
hostname: apic
host: apic
username: admin
password: SomeSecretPassword
leaf_interface_profile: leafintprfname
Expand Down
8 changes: 4 additions & 4 deletions lib/ansible/modules/network/aci/aci_aep.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
EXAMPLES = r'''
- name: Add a new AEP
aci_aep:
hostname: apic
host: apic
username: admin
password: SomeSecretPassword
aep: ACI-AEP
Expand All @@ -64,23 +64,23 @@
- name: Remove an existing AEP
aci_aep:
hostname: apic
host: apic
username: admin
password: SomeSecretPassword
aep: ACI-AEP
state: absent
- name: Query an AEP
aci_aep:
hostname: apic
host: apic
username: admin
password: SomeSecretPassword
aep: ACI-AEP
state: query
- name: Query all AEPs
aci_aep:
hostname: apic
host: apic
username: admin
password: SomeSecretPassword
state: query
Expand Down
8 changes: 4 additions & 4 deletions lib/ansible/modules/network/aci/aci_ap.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
EXAMPLES = r'''
- name: Add a new AP
aci_ap:
hostname: apic
host: apic
username: admin
password: SomeSecretPassword
tenant: production
Expand All @@ -62,7 +62,7 @@
- name: Remove an AP
aci_ap:
hostname: apic
host: apic
username: admin
password: SomeSecretPassword
tenant: production
Expand All @@ -71,7 +71,7 @@
- name: Query an AP
aci_ap:
hostname: apic
host: apic
username: admin
password: SomeSecretPassword
tenant: production
Expand All @@ -80,7 +80,7 @@
- name: Query all APs
aci_ap:
hostname: apic
host: apic
username: admin
password: SomeSecretPassword
state: query
Expand Down
18 changes: 9 additions & 9 deletions lib/ansible/modules/network/aci/aci_bd_subnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,22 +112,22 @@
EXAMPLES = r'''
- name: create a tenant
aci_tenant:
hostname: apic
host: apic
username: admin
password: SomeSecretPassword
tenant: production
- name: create a bridge domain
aci_bd:
hostname: apic
host: apic
username: admin
password: SomeSecretPassword
tenant: production
bd: database
- name: create a subnet
aci_bd_subnet:
hostname: apic
host: apic
username: admin
password: SomeSecretPassword
tenant: production
Expand All @@ -137,7 +137,7 @@
- name: create a subnet with options
aci_bd_subnet:
hostname: apic
host: apic
username: admin
password: SomeSecretPassword
tenant: production
Expand All @@ -152,7 +152,7 @@
- name: update a subnets scope to private and shared
aci_bd_subnet:
hostname: apic
host: apic
username: admin
password: SomeSecretPassword
tenant: production
Expand All @@ -163,14 +163,14 @@
- name: get all subnets
aci_bd_subnet:
hostname: apic
host: apic
username: admin
password: SomeSecretPassword
state: query
- name: get all subnets of specific gateway in specified tenant
aci_bd_subnet:
hostname: apic
host: apic
username: admin
password: SomeSecretPassword
state: query
Expand All @@ -180,7 +180,7 @@
- name: get specific subnet
aci_bd_subnet:
hostname: apic
host: apic
username: admin
password: SomeSecretPassword
state: query
Expand All @@ -191,7 +191,7 @@
- name: delete a subnet
aci_bd_subnet:
hostname: apic
host: apic
username: admin
password: SomeSecretPassword
state: absent
Expand Down
12 changes: 6 additions & 6 deletions lib/ansible/modules/network/aci/aci_config_rollback.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,23 +76,23 @@
---
- name: Create a Snapshot
aci_config_snapshot:
hostname: apic
host: apic
username: admin
password: SomeSecretPassword
state: present
export_policy: config_backup
- name: Query Existing Snapshots
aci_config_snapshot:
hostname: apic
host: apic
username: admin
password: SomeSecretPassword
state: query
export_policy: config_backup
- name: Compare Snapshot Files
aci_config_rollback:
hostname: apic
host: apic
username: admin
password: SomeSecretPassword
state: preview
Expand All @@ -103,7 +103,7 @@
- name: Rollback Configuration
aci_config_rollback:
hostname: apic
host: apic
username: admin
password: SomeSecretPassword
state: rollback
Expand All @@ -113,7 +113,7 @@
- name: Rollback Configuration
aci_config_rollback:
hostname: apic
host: apic
username: admin
password: SomeSecretPassword
state: rollback
Expand Down Expand Up @@ -225,7 +225,7 @@ def main():
aci.post_config()

elif state == 'preview':
aci.result['url'] = '%(protocol)s://%(hostname)s/mqapi2/snapshots.diff.xml' % module.params
aci.result['url'] = '%(protocol)s://%(host)s/mqapi2/snapshots.diff.xml' % module.params
aci.result['filter_string'] = (
'?s1dn=uni/backupst/snapshots-[uni/fabric/configexp-%(export_policy)s]/snapshot-%(snapshot)s&'
's2dn=uni/backupst/snapshots-[uni/fabric/configexp-%(compare_export_policy)s]/snapshot-%(compare_snapshot)s'
Expand Down
8 changes: 4 additions & 4 deletions lib/ansible/modules/network/aci/aci_config_snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
EXAMPLES = r'''
- name: Create a Snapshot
aci_config_snapshot:
hostname: apic
host: apic
username: admin
password: SomeSecretPassword
state: present
Expand All @@ -79,22 +79,22 @@
- name: Query all Snapshots
aci_config_snapshot:
hostname: apic
host: apic
username: admin
password: SomeSecretPassword
state: query
- name: Query Snapshots associated with a particular Export Policy
aci_config_snapshot:
hostname: apic
host: apic
username: admin
password: SomeSecretPassword
state: query
export_policy: config_backup
- name: Delete a Snapshot
aci_config_snapshot:
hostname: apic
host: apic
username: admin
password: SomeSecretPassword
state: absent
Expand Down
2 changes: 1 addition & 1 deletion lib/ansible/modules/network/aci/aci_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
# FIXME: Add more, better examples
EXAMPLES = r'''
- aci_contract:
hostname: '{{ inventory_hostname }}'
host: '{{ inventory_hostname }}'
username: '{{ username }}'
password: '{{ password }}'
contract: '{{ contract }}'
Expand Down
Loading

0 comments on commit d600485

Please sign in to comment.