cloudstack: cs_securitygroup_rule: fix result was not always what expected
This commit is contained in:
parent
185cb8757d
commit
5de249aaf9
1 changed files with 23 additions and 24 deletions
|
@ -327,7 +327,10 @@ class AnsibleCloudStackSecurityGroupRule(AnsibleCloudStack):
|
||||||
poll_async = self.module.params.get('poll_async')
|
poll_async = self.module.params.get('poll_async')
|
||||||
if res and poll_async:
|
if res and poll_async:
|
||||||
security_group = self._poll_job(res, 'securitygroup')
|
security_group = self._poll_job(res, 'securitygroup')
|
||||||
return security_group
|
key = sg_type + "rule" # ingressrule / egressrule
|
||||||
|
if key in security_group:
|
||||||
|
rule = security_group[key][0]
|
||||||
|
return rule
|
||||||
|
|
||||||
|
|
||||||
def remove_rule(self):
|
def remove_rule(self):
|
||||||
|
@ -355,34 +358,30 @@ class AnsibleCloudStackSecurityGroupRule(AnsibleCloudStack):
|
||||||
poll_async = self.module.params.get('poll_async')
|
poll_async = self.module.params.get('poll_async')
|
||||||
if res and poll_async:
|
if res and poll_async:
|
||||||
res = self._poll_job(res, 'securitygroup')
|
res = self._poll_job(res, 'securitygroup')
|
||||||
return security_group
|
return rule
|
||||||
|
|
||||||
|
|
||||||
def get_result(self, security_group_rule):
|
def get_result(self, security_group_rule):
|
||||||
type = self.module.params.get('type')
|
|
||||||
|
|
||||||
key = 'ingressrule'
|
self.result['type'] = self.module.params.get('type')
|
||||||
if type == 'egress':
|
|
||||||
key = 'egressrule'
|
|
||||||
|
|
||||||
self.result['type'] = type
|
|
||||||
self.result['security_group'] = self.module.params.get('security_group')
|
self.result['security_group'] = self.module.params.get('security_group')
|
||||||
|
|
||||||
if key in security_group_rule and security_group_rule[key]:
|
if security_group_rule:
|
||||||
if 'securitygroupname' in security_group_rule[key][0]:
|
rule = security_group_rule
|
||||||
self.result['user_security_group'] = security_group_rule[key][0]['securitygroupname']
|
if 'securitygroupname' in rule:
|
||||||
if 'cidr' in security_group_rule[key][0]:
|
self.result['user_security_group'] = rule['securitygroupname']
|
||||||
self.result['cidr'] = security_group_rule[key][0]['cidr']
|
if 'cidr' in rule:
|
||||||
if 'protocol' in security_group_rule[key][0]:
|
self.result['cidr'] = rule['cidr']
|
||||||
self.result['protocol'] = security_group_rule[key][0]['protocol']
|
if 'protocol' in rule:
|
||||||
if 'startport' in security_group_rule[key][0]:
|
self.result['protocol'] = rule['protocol']
|
||||||
self.result['start_port'] = security_group_rule[key][0]['startport']
|
if 'startport' in rule:
|
||||||
if 'endport' in security_group_rule[key][0]:
|
self.result['start_port'] = rule['startport']
|
||||||
self.result['end_port'] = security_group_rule[key][0]['endport']
|
if 'endport' in rule:
|
||||||
if 'icmpcode' in security_group_rule[key][0]:
|
self.result['end_port'] = rule['endport']
|
||||||
self.result['icmp_code'] = security_group_rule[key][0]['icmpcode']
|
if 'icmpcode' in rule:
|
||||||
if 'icmptype' in security_group_rule[key][0]:
|
self.result['icmp_code'] = rule['icmpcode']
|
||||||
self.result['icmp_type'] = security_group_rule[key][0]['icmptype']
|
if 'icmptype' in rule:
|
||||||
|
self.result['icmp_type'] = rule['icmptype']
|
||||||
return self.result
|
return self.result
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue