summaryrefslogtreecommitdiff
path: root/lib/ansible/modules/cloud/cloudstack
diff options
context:
space:
mode:
authorRené Moser <mail@renemoser.net>2018-09-22 13:40:40 +0200
committerGitHub <noreply@github.com>2018-09-22 13:40:40 +0200
commit83ec4184701f77d4de68d0c52946fd80a13fbe0a (patch)
tree926de8e284648e61f5bdf5dcf670b6af88a824f4 /lib/ansible/modules/cloud/cloudstack
parentc123b4e7ef6efe8d9ea777ae542e8995b6bd1ffd (diff)
downloadansible-83ec4184701f77d4de68d0c52946fd80a13fbe0a.tar.gz
cs_loadbalancer_rule_member: fix error handling (#46012)
* make use of query_api * fix sanity
Diffstat (limited to 'lib/ansible/modules/cloud/cloudstack')
-rw-r--r--lib/ansible/modules/cloud/cloudstack/cs_loadbalancer_rule_member.py40
1 files changed, 16 insertions, 24 deletions
diff --git a/lib/ansible/modules/cloud/cloudstack/cs_loadbalancer_rule_member.py b/lib/ansible/modules/cloud/cloudstack/cs_loadbalancer_rule_member.py
index b19ad2021e..ccbacbc9fe 100644
--- a/lib/ansible/modules/cloud/cloudstack/cs_loadbalancer_rule_member.py
+++ b/lib/ansible/modules/cloud/cloudstack/cs_loadbalancer_rule_member.py
@@ -1,23 +1,9 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
-# (c) 2015, Darren Worrall <darren@iweb.co.uk>
-# (c) 2015, René Moser <mail@renemoser.net>
-#
-# This file is part of Ansible
-#
-# Ansible is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# Ansible is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+# Copyright (c) 2015, Darren Worrall <darren@iweb.co.uk>
+# Copyright (c) 2015, René Moser <mail@renemoser.net>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['stableinterface'],
@@ -67,20 +53,25 @@ options:
description:
- Name of the zone in which the rule should be located.
- If not set, default zone is used.
+ poll_async:
+ description:
+ - Poll async jobs until job has finished.
+ type: bool
+ default: yes
extends_documentation_fragment: cloudstack
'''
EXAMPLES = '''
-# Add VMs to an existing load balancer
-- local_action:
+- name: Add VMs to an existing load balancer
+ local_action:
module: cs_loadbalancer_rule_member
name: balance_http
vms:
- web01
- web02
-# Remove a VM from an existing load balancer
-- local_action:
+- name: Remove a VM from an existing load balancer
+ local_action:
module: cs_loadbalancer_rule_member
name: balance_http
vms:
@@ -259,10 +250,10 @@ class AnsibleCloudStackLBRuleMember(AnsibleCloudStack):
wanted_names = self.module.params.get('vms')
if operation == 'add':
- cs_func = self.cs.assignToLoadBalancerRule
+ cs_func = 'assignToLoadBalancerRule'
to_change = set(wanted_names) - set(existing.keys())
else:
- cs_func = self.cs.removeFromLoadBalancerRule
+ cs_func = 'removeFromLoadBalancerRule'
to_change = set(wanted_names) & set(existing.keys())
if not to_change:
@@ -284,7 +275,8 @@ class AnsibleCloudStackLBRuleMember(AnsibleCloudStack):
self.result['changed'] = True
if to_change_ids and not self.module.check_mode:
- res = cs_func(
+ res = self.query_api(
+ cs_func,
id=rule['id'],
virtualmachineids=to_change_ids,
)