mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
cloudstack, cs_firewall: fix network not found error in return results (#2006)
Only a small issue in results. In case of type is ingress, we rely on ip address, but in results we also return the network. Resolving the ip address works without zone params. If the ip address is not located in the default zone and zone param is not set, the network won't be found because default zone was used for the network query listing. However since network param is not used for type ingress we skip the return of the network in results.
This commit is contained in:
parent
d7e8dd22df
commit
5197654437
1 changed files with 8 additions and 5 deletions
|
@ -227,6 +227,7 @@ class AnsibleCloudStackFirewall(AnsibleCloudStack):
|
||||||
'icmptype': 'icmp_type',
|
'icmptype': 'icmp_type',
|
||||||
}
|
}
|
||||||
self.firewall_rule = None
|
self.firewall_rule = None
|
||||||
|
self.network = None
|
||||||
|
|
||||||
|
|
||||||
def get_firewall_rule(self):
|
def get_firewall_rule(self):
|
||||||
|
@ -302,10 +303,11 @@ class AnsibleCloudStackFirewall(AnsibleCloudStack):
|
||||||
return cidr == rule['cidrlist']
|
return cidr == rule['cidrlist']
|
||||||
|
|
||||||
|
|
||||||
def get_network(self, key=None, network=None):
|
def get_network(self, key=None):
|
||||||
if not network:
|
if self.network:
|
||||||
network = self.module.params.get('network')
|
return self._get_by_key(key, self.network)
|
||||||
|
|
||||||
|
network = self.module.params.get('network')
|
||||||
if not network:
|
if not network:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -321,6 +323,7 @@ class AnsibleCloudStackFirewall(AnsibleCloudStack):
|
||||||
|
|
||||||
for n in networks['network']:
|
for n in networks['network']:
|
||||||
if network in [ n['displaytext'], n['name'], n['id'] ]:
|
if network in [ n['displaytext'], n['name'], n['id'] ]:
|
||||||
|
self.network = n
|
||||||
return self._get_by_key(key, n)
|
return self._get_by_key(key, n)
|
||||||
break
|
break
|
||||||
self.module.fail_json(msg="Network '%s' not found" % network)
|
self.module.fail_json(msg="Network '%s' not found" % network)
|
||||||
|
@ -385,8 +388,8 @@ class AnsibleCloudStackFirewall(AnsibleCloudStack):
|
||||||
super(AnsibleCloudStackFirewall, self).get_result(firewall_rule)
|
super(AnsibleCloudStackFirewall, self).get_result(firewall_rule)
|
||||||
if firewall_rule:
|
if firewall_rule:
|
||||||
self.result['type'] = self.module.params.get('type')
|
self.result['type'] = self.module.params.get('type')
|
||||||
if 'networkid' in firewall_rule:
|
if self.result['type'] == 'egress':
|
||||||
self.result['network'] = self.get_network(key='displaytext', network=firewall_rule['networkid'])
|
self.result['network'] = self.get_network(key='displaytext')
|
||||||
return self.result
|
return self.result
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue