From 6e2b97427bfa7cfe3d61e88fc71625e86bfd66ab Mon Sep 17 00:00:00 2001 From: Rene Moser <mail@renemoser.net> Date: Sun, 6 Sep 2015 01:42:56 +0200 Subject: [PATCH 1/4] cloudstack: cs_account: fix error handing on state=absent --- cloud/cloudstack/cs_account.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloud/cloudstack/cs_account.py b/cloud/cloudstack/cs_account.py index 052354c581e..e96d8e12638 100644 --- a/cloud/cloudstack/cs_account.py +++ b/cloud/cloudstack/cs_account.py @@ -326,7 +326,7 @@ class AnsibleCloudStackAccount(AnsibleCloudStack): if not self.module.check_mode: res = self.cs.deleteAccount(id=account['id']) - if 'errortext' in account: + if 'errortext' in res: self.module.fail_json(msg="Failed: '%s'" % res['errortext']) poll_async = self.module.params.get('poll_async') From e5fdbc25a2b10c7cea8354b9a1977817e1382ef2 Mon Sep 17 00:00:00 2001 From: Bret Martin <bret_martin@h3biomedicine.com> Date: Sun, 6 Sep 2015 22:00:02 -0400 Subject: [PATCH 2/4] Only wait for ENI attachment at creation when instance_id is specified --- cloud/amazon/ec2_eni.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cloud/amazon/ec2_eni.py b/cloud/amazon/ec2_eni.py index 9e878e7d558..4d08aeb26d0 100644 --- a/cloud/amazon/ec2_eni.py +++ b/cloud/amazon/ec2_eni.py @@ -213,9 +213,9 @@ def create_eni(connection, module): except BotoServerError as ex: eni.delete() raise + # Wait to allow creation / attachment to finish + wait_for_eni(eni, "attached") changed = True - # Wait to allow creation / attachment to finish - wait_for_eni(eni, "attached") eni.update() except BotoServerError as e: From c7f7698fdc4f7c796300532b2dcd58607f3ed8a6 Mon Sep 17 00:00:00 2001 From: baba <yasuyuki.baba@gmail.com> Date: Mon, 7 Sep 2015 15:40:52 +0900 Subject: [PATCH 3/4] Fix missing parameter in typetalk module --- notification/typetalk.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/notification/typetalk.py b/notification/typetalk.py index 4f6ee28130b..8a2dad3d6a2 100644 --- a/notification/typetalk.py +++ b/notification/typetalk.py @@ -72,14 +72,14 @@ def do_request(module, url, params, headers=None): raise exc return r -def get_access_token(client_id, client_secret): +def get_access_token(module, client_id, client_secret): params = { 'client_id': client_id, 'client_secret': client_secret, 'grant_type': 'client_credentials', 'scope': 'topic.post' } - res = do_request('https://typetalk.in/oauth2/access_token', params) + res = do_request(module, 'https://typetalk.in/oauth2/access_token', params) return json.load(res)['access_token'] @@ -88,7 +88,7 @@ def send_message(module, client_id, client_secret, topic, msg): send message to typetalk """ try: - access_token = get_access_token(client_id, client_secret) + access_token = get_access_token(module, client_id, client_secret) url = 'https://typetalk.in/api/v1/topics/%d' % topic headers = { 'Authorization': 'Bearer %s' % access_token, From 356e867721568eab2ca4248251daeb8c4820a1c3 Mon Sep 17 00:00:00 2001 From: Peter Sprygada <psprygada@ansible.com> Date: Tue, 8 Sep 2015 10:50:13 -0400 Subject: [PATCH 4/4] adds missing serialize_instance function --- cloud/vmware/vca_nat.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/cloud/vmware/vca_nat.py b/cloud/vmware/vca_nat.py index c948605ce48..d34a52b6c75 100644 --- a/cloud/vmware/vca_nat.py +++ b/cloud/vmware/vca_nat.py @@ -61,7 +61,7 @@ options: - The type of service we are authenticating against required: false default: vca - choices: [ "vca", "vchs", "vcd" ] + choices: [ "vca", "vchs", "vcd" ] state: description: - if the object should be added or removed @@ -108,7 +108,7 @@ EXAMPLES = ''' instance_id: 'b15ff1e5-1024-4f55-889f-ea0209726282' vdc_name: 'benz_ansible' state: 'present' - nat_rules: + nat_rules: - rule_type: SNAT original_ip: 192.168.2.10 translated_ip: 107.189.95.208 @@ -121,7 +121,7 @@ EXAMPLES = ''' instance_id: 'b15ff1e5-1024-4f55-889f-ea0209726282' vdc_name: 'benz_ansible' state: 'present' - nat_rules: + nat_rules: - rule_type: DNAT original_ip: 107.189.95.208 original_port: 22 @@ -145,6 +145,12 @@ LOGIN_HOST['vca'] = 'vca.vmware.com' LOGIN_HOST['vchs'] = 'vchs.vmware.com' VALID_RULE_KEYS = ['rule_type', 'original_ip', 'original_port', 'translated_ip', 'translated_port', 'protocol'] +def serialize_instances(instance_list): + instances = [] + for i in instance_list: + instances.append(dict(apiUrl=i['apiUrl'], instance_id=i['id'])) + return instances + def vca_login(module=None): service_type = module.params.get('service_type') username = module.params.get('username') @@ -216,7 +222,7 @@ def vca_login(module=None): if not vca.login(token=vca.token, org=org, org_url=vca.vcloud_session.org_url): module.fail_json(msg = "Failed to login to org", error=vca.response.content) return vca - + def validate_nat_rules(module=None, nat_rules=None): for rule in nat_rules: if not isinstance(rule, dict): @@ -301,7 +307,7 @@ def main(): if service_type == 'vcd': if not host: module.fail_json(msg="When service type is vcd host parameter is mandatory") - + vca = vca_login(module) vdc = vca.get_vdc(vdc_name) if not vdc: @@ -368,7 +374,7 @@ def main(): module.exit_json(changed=True, rules_added=mod_rules) - + # import module snippets from ansible.module_utils.basic import * if __name__ == '__main__':