cloudstack: cs_firewall: get_network moved to utils, cleanup (#2293)

reviewable/pr18780/r1
René Moser 9 years ago
parent 5a7a9a0a30
commit 039005bfaa

@ -310,32 +310,6 @@ class AnsibleCloudStackFirewall(AnsibleCloudStack):
return cidr == rule['cidrlist'] return cidr == rule['cidrlist']
def get_network(self, key=None):
if self.network:
return self._get_by_key(key, self.network)
network = self.module.params.get('network')
if not network:
return None
args = {}
args['account'] = self.get_account('name')
args['domainid'] = self.get_domain('id')
args['projectid'] = self.get_project('id')
args['zoneid'] = self.get_zone('id')
networks = self.cs.listNetworks(**args)
if not networks:
self.module.fail_json(msg="No networks available")
for n in networks['network']:
if network in [ n['displaytext'], n['name'], n['id'] ]:
self.network = n
return self._get_by_key(key, n)
break
self.module.fail_json(msg="Network '%s' not found" % network)
def create_firewall_rule(self): def create_firewall_rule(self):
firewall_rule = self.get_firewall_rule() firewall_rule = self.get_firewall_rule()
if not firewall_rule: if not firewall_rule:

Loading…
Cancel
Save