Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Have cs_host search both name and ipaddress fields when fetching the … #25628

Merged
merged 1 commit into from Jun 13, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 8 additions & 6 deletions lib/ansible/modules/cloud/cloudstack/cs_host.py
Expand Up @@ -36,7 +36,7 @@
description:
- Name of the host.
required: true
aliases: [ 'url' ]
aliases: [ 'url', 'ip_address' ]
username:
description:
- Username for the host.
Expand Down Expand Up @@ -428,13 +428,15 @@ def get_allocation_state(self):

def get_host(self):
host = None
name = self.module.params.get('name')
args = {
'zoneid': self.get_zone(key='id'),
'name': self.module.params.get('name'),
}
hosts = self.cs.listHosts(**args)
if hosts:
host = hosts['host'][0]
res = self.cs.listHosts(**args)
if res:
for h in res['host']:
if name in [h['ipaddress'], h['name']]:
host = h
return host

def present_host(self):
Expand Down Expand Up @@ -506,7 +508,7 @@ def absent_host(self):
def main():
argument_spec = cs_argument_spec()
argument_spec.update(dict(
name=dict(required=True, aliases=['url']),
name=dict(required=True, aliases=['url', 'ip_address']),
password=dict(default=None, no_log=True),
username=dict(default=None),
hypervisor=dict(choices=CS_HYPERVISORS, default=None),
Expand Down