mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 03:11:24 -07:00
Add a new CloudStack module - cs_traffic_type (#54451)
* Add get_physical_network to AnsibleCloudStack * Add new module cs_traffic_type
This commit is contained in:
parent
601d20117d
commit
43514e9d93
6 changed files with 649 additions and 0 deletions
|
@ -302,6 +302,24 @@ class AnsibleCloudStack:
|
|||
self._vpc_networks_ids.append(n['id'])
|
||||
return network_id in self._vpc_networks_ids
|
||||
|
||||
def get_physical_network(self, key=None):
|
||||
if self.physical_network:
|
||||
return self._get_by_key(key, self.physical_network)
|
||||
physical_network = self.module.params.get('physical_network')
|
||||
args = {
|
||||
'zoneid': self.get_zone(key='id')
|
||||
}
|
||||
physical_networks = self.query_api('listPhysicalNetworks', **args)
|
||||
if not physical_networks:
|
||||
self.fail_json(msg="No physical networks available.")
|
||||
|
||||
for net in physical_networks['physicalnetwork']:
|
||||
if physical_network in [net['name'], net['id']]:
|
||||
self.physical_network = net
|
||||
self.result['physical_network'] = net['name']
|
||||
return self._get_by_key(key, self.physical_network)
|
||||
self.fail_json(msg="Physical Network '%s' not found" % physical_network)
|
||||
|
||||
def get_network(self, key=None):
|
||||
"""Return a network dictionary or the value of given key of."""
|
||||
if self.network:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue