Skip to content

Commit 518f19b

Browse files
authored
cs_vlan_ip_range: implement pod argument (#20)
* cs_vlan_ip_range: implement pod argument * add changelog fragment
1 parent 9c09963 commit 518f19b

File tree

5 files changed

+21
-23
lines changed

5 files changed

+21
-23
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
minor_changes:
2+
- cs_vlan_ip_range - Added support to specify pod name (https://github.com/ngine-io/ansible-collection-cloudstack/pull/20)

plugins/module_utils/cloudstack.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,19 @@ def get_project(self, key=None):
367367
return self._get_by_key(key, self.project)
368368
self.fail_json(msg="project '%s' not found" % project)
369369

370+
def get_pod(self, key=None):
371+
pod_name = self.module.params.get('pod')
372+
if not pod_name:
373+
return None
374+
args = {
375+
'name': pod_name,
376+
'zoneid': self.get_zone(key='id'),
377+
}
378+
pods = self.query_api('listPods', **args)
379+
if pods:
380+
return self._get_by_key(key, pods['pod'][0])
381+
self.module.fail_json(msg="Pod %s not found" % pod_name)
382+
370383
def get_ip_address(self, key=None):
371384
if self.ip_address:
372385
return self._get_by_key(key, self.ip_address)

plugins/modules/cs_cluster.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -232,16 +232,6 @@ def _get_common_cluster_args(self):
232232
args['allocationstate'] = state.capitalize()
233233
return args
234234

235-
def get_pod(self, key=None):
236-
args = {
237-
'name': self.module.params.get('pod'),
238-
'zoneid': self.get_zone(key='id'),
239-
}
240-
pods = self.query_api('listPods', **args)
241-
if pods:
242-
return self._get_by_key(key, pods['pod'][0])
243-
self.module.fail_json(msg="Pod %s not found in zone %s" % (self.module.params.get('pod'), self.get_zone(key='name')))
244-
245235
def get_cluster(self):
246236
if not self.cluster:
247237
args = {}

plugins/modules/cs_host.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -381,19 +381,6 @@ def __init__(self, module):
381381
}
382382
self.host = None
383383

384-
def get_pod(self, key=None):
385-
pod_name = self.module.params.get('pod')
386-
if not pod_name:
387-
return None
388-
args = {
389-
'name': pod_name,
390-
'zoneid': self.get_zone(key='id'),
391-
}
392-
pods = self.query_api('listPods', **args)
393-
if pods:
394-
return self._get_by_key(key, pods['pod'][0])
395-
self.module.fail_json(msg="Pod %s not found" % pod_name)
396-
397384
def get_cluster(self, key=None):
398385
cluster_name = self.module.params.get('cluster')
399386
if not cluster_name:

plugins/modules/cs_vlan_ip_range.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@
7373
- The ID or VID of the network.
7474
- If not specified, will be defaulted to the vlan of the network.
7575
type: str
76+
pod:
77+
description:
78+
- Name of the pod.
79+
type: str
7680
state:
7781
description:
7882
- State of the network ip range.
@@ -312,6 +316,7 @@ def create_vlan_ip_range(self):
312316
'networkid': self.get_network(key='id'),
313317
'forvirtualnetwork': self.module.params.get('for_virtual_network'),
314318
'forsystemvms': self.module.params.get('for_system_vms'),
319+
'podid': self.get_pod(key='id'),
315320
}
316321
if self.module.params.get('physical_network'):
317322
args['physicalnetworkid'] = self.get_physical_network(key='id')
@@ -358,6 +363,7 @@ def main():
358363
domain=dict(type='str'),
359364
account=dict(type='str'),
360365
project=dict(type='str'),
366+
pod=dict(type='str'),
361367
for_virtual_network=dict(type='bool', default=False),
362368
for_system_vms=dict(type='bool', default=False),
363369
))

0 commit comments

Comments
 (0)