cloudstack: use get_or_fallback() from cloudstack utils

This commit is contained in:
Rene Moser 2015-07-19 15:09:49 +02:00 committed by Matt Clay
commit 1f25377ce9
6 changed files with 14 additions and 59 deletions

View file

@ -215,18 +215,12 @@ class AnsibleCloudStackFirewall(AnsibleCloudStack):
self.firewall_rule = None
def get_end_port(self):
if self.module.params.get('end_port'):
return self.module.params.get('end_port')
return self.module.params.get('start_port')
def get_firewall_rule(self):
if not self.firewall_rule:
cidr = self.module.params.get('cidr')
protocol = self.module.params.get('protocol')
start_port = self.module.params.get('start_port')
end_port = self.get_end_port()
end_port = self.get_or_fallback('end_port', 'start_port')
icmp_code = self.module.params.get('icmp_code')
icmp_type = self.module.params.get('icmp_type')
fw_type = self.module.params.get('type')
@ -327,7 +321,7 @@ class AnsibleCloudStackFirewall(AnsibleCloudStack):
args['cidrlist'] = self.module.params.get('cidr')
args['protocol'] = self.module.params.get('protocol')
args['startport'] = self.module.params.get('start_port')
args['endport'] = self.get_end_port()
args['endport'] = self.get_or_fallback('end_port', 'start_port')
args['icmptype'] = self.module.params.get('icmp_type')
args['icmpcode'] = self.module.params.get('icmp_code')