Skip to content

Commit d76fa7c

Browse files
authored
remove deprecated default zone (#62)
1 parent 36465d4 commit d76fa7c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+160
-65
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.idea
2+
tests/output
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
breaking_changes:
2+
- default zone deprecation - The `zone` param default value, across multiple modules, has been deprecated due to unreliable API (https://github.com/ngine-io/ansible-collection-cloudstack/pull/62).

plugins/module_utils/cloudstack.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -476,16 +476,12 @@ def get_zone(self, key=None):
476476
if not zones:
477477
self.fail_json(msg="No zones available. Please create a zone first")
478478

479-
# use the first zone if no zone param given
479+
# this check is theoretically not required, as module argument specification should take care of it
480+
# however, due to deprecated default zone is left behind just in case non obvious callers.
481+
# Some modules benefit form the check anyway like those where zone if effectively optional like
482+
# template registration (local/cross zone) or configuration (zone or global)
480483
if not zone:
481-
self.module.deprecate(
482-
msg="Using first zone as default is deprecated because of unreliable API, zone needs to be defined.",
483-
version="2.0.0",
484-
collection_name="ngine_io.cloudstack"
485-
)
486-
self.zone = zones['zone'][0]
487-
self.result['zone'] = self.zone['name']
488-
return self._get_by_key(key, self.zone)
484+
self.fail_json(msg="Zone is required due to unreliable API.")
489485

490486
if zones:
491487
for z in zones['zone']:

plugins/modules/cs_cluster.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
zone:
2626
description:
2727
- Name of the zone in which the cluster belongs to.
28-
- If not set, default zone is used.
2928
type: str
29+
required: true
3030
pod:
3131
description:
3232
- Name of the pod in which the cluster belongs to.
@@ -332,7 +332,7 @@ def main():
332332
argument_spec = cs_argument_spec()
333333
argument_spec.update(dict(
334334
name=dict(required=True),
335-
zone=dict(),
335+
zone=dict(required=True),
336336
pod=dict(),
337337
cluster_type=dict(choices=['CloudManaged', 'ExternalManaged']),
338338
hypervisor=dict(),

plugins/modules/cs_configuration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def _get_common_configuration_args(self):
165165
return args
166166

167167
def get_zone(self, key=None):
168-
# make sure we do net use the default zone
168+
# zone is optional as it means that the configuration is aimed at a global setting.
169169
zone = self.module.params.get('zone')
170170
if zone:
171171
return super(AnsibleCloudStackConfiguration, self).get_zone(key=key)

plugins/modules/cs_firewall.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@
9090
zone:
9191
description:
9292
- Name of the zone in which the virtual machine is in.
93-
- If not set, default zone is used.
9493
type: str
94+
required: true
9595
poll_async:
9696
description:
9797
- Poll async jobs until job has finished.
@@ -112,12 +112,14 @@
112112
- name: Allow inbound port 80/tcp from 1.2.3.4 to 4.3.2.1
113113
ngine_io.cloudstack.cs_firewall:
114114
ip_address: 4.3.2.1
115+
zone: zone01
115116
port: 80
116117
cidr: 1.2.3.4/32
117118
118119
- name: Allow inbound tcp/udp port 53 to 4.3.2.1
119120
ngine_io.cloudstack.cs_firewall:
120121
ip_address: 4.3.2.1
122+
zone: zone01
121123
port: 53
122124
protocol: '{{ item }}'
123125
with_items:
@@ -127,6 +129,7 @@
127129
- name: Ensure firewall rule is removed
128130
ngine_io.cloudstack.cs_firewall:
129131
ip_address: 4.3.2.1
132+
zone: zone01
130133
start_port: 8000
131134
end_port: 8888
132135
cidr: 17.0.0.0/8
@@ -135,12 +138,14 @@
135138
- name: Allow all outbound traffic
136139
ngine_io.cloudstack.cs_firewall:
137140
network: my_network
141+
zone: zone01
138142
type: egress
139143
protocol: all
140144
141145
- name: Allow only HTTP outbound traffic for an IP
142146
ngine_io.cloudstack.cs_firewall:
143147
network: my_network
148+
zone: zone01
144149
type: egress
145150
port: 80
146151
cidr: 10.101.1.20
@@ -395,7 +400,7 @@ def main():
395400
start_port=dict(type='int', aliases=['port']),
396401
end_port=dict(type='int'),
397402
state=dict(choices=['present', 'absent'], default='present'),
398-
zone=dict(),
403+
zone=dict(required=True),
399404
domain=dict(),
400405
account=dict(),
401406
project=dict(),

plugins/modules/cs_host.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@
7474
zone:
7575
description:
7676
- Name of the zone in which the host should be deployed.
77-
- If not set, default zone is used.
7877
type: str
78+
required: true
7979
extends_documentation_fragment:
8080
- ngine_io.cloudstack.cloudstack
8181
'''
@@ -580,7 +580,7 @@ def main():
580580
pod=dict(),
581581
cluster=dict(),
582582
host_tags=dict(type='list', elements='str', aliases=['host_tag']),
583-
zone=dict(),
583+
zone=dict(required=True),
584584
state=dict(choices=['present', 'absent'], default='present'),
585585
))
586586

plugins/modules/cs_instance.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@
150150
zone:
151151
description:
152152
- Name of the zone in which the instance should be deployed.
153-
- If not set, default zone is used.
154153
type: str
154+
required: true
155155
ssh_key:
156156
description:
157157
- Name of the SSH key to be deployed on the new instance.
@@ -218,6 +218,7 @@
218218
- name: for changing a running instance, use the 'force' parameter
219219
ngine_io.cloudstack.cs_instance:
220220
name: web-vm-1
221+
zone: zone01
221222
display_name: web-vm-01.example.com
222223
iso: Linux Debian 7 64-bit
223224
service_offering: 2cpu_2gb
@@ -227,6 +228,7 @@
227228
- name: create or update a instance on Exoscale's public cloud using display_name.
228229
ngine_io.cloudstack.cs_instance:
229230
display_name: web-vm-1
231+
zone: zone01
230232
template: Linux Debian 7 64-bit
231233
service_offering: Tiny
232234
@@ -243,6 +245,7 @@
243245
- name: create an instance with multiple interfaces specifying the IP addresses
244246
ngine_io.cloudstack.cs_instance:
245247
name: web-vm-1
248+
zone: zone01
246249
template: Linux Debian 7 64-bit
247250
service_offering: Tiny
248251
ip_to_networks:
@@ -254,16 +257,19 @@
254257
- name: ensure an instance is stopped
255258
ngine_io.cloudstack.cs_instance:
256259
name: web-vm-1
260+
zone: zone01
257261
state: stopped
258262
259263
- name: ensure an instance is running
260264
ngine_io.cloudstack.cs_instance:
261265
name: web-vm-1
266+
zone: zone01
262267
state: started
263268
264269
- name: remove an instance
265270
ngine_io.cloudstack.cs_instance:
266271
name: web-vm-1
272+
zone: zone01
267273
state: absent
268274
'''
269275

@@ -1035,7 +1041,7 @@ def main():
10351041
account=dict(),
10361042
project=dict(),
10371043
user_data=dict(),
1038-
zone=dict(),
1044+
zone=dict(required=True),
10391045
ssh_key=dict(),
10401046
force=dict(type='bool', default=False),
10411047
tags=dict(type='list', elements='dict', aliases=['tag']),

plugins/modules/cs_instance_nic.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@
5454
zone:
5555
description:
5656
- Name of the zone in which the instance is deployed in.
57-
- If not set, default zone is used.
5857
type: str
58+
required: true
5959
state:
6060
description:
6161
- State of the nic.
@@ -76,18 +76,21 @@
7676
ngine_io.cloudstack.cs_instance_nic:
7777
vm: privnet
7878
network: privNetForBasicZone
79+
zone: zone01
7980
8081
- name: Ensure IP address on a nic
8182
ngine_io.cloudstack.cs_instance_nic:
8283
vm: privnet
8384
ip_address: 10.10.11.32
8485
network: privNetForBasicZone
86+
zone: zone01
8587
8688
- name: Remove a secondary nic
8789
ngine_io.cloudstack.cs_instance_nic:
8890
vm: privnet
8991
state: absent
9092
network: privNetForBasicZone
93+
zone: zone01
9194
'''
9295

9396
RETURN = '''
@@ -258,7 +261,7 @@ def main():
258261
domain=dict(),
259262
account=dict(),
260263
project=dict(),
261-
zone=dict(),
264+
zone=dict(required=True),
262265
poll_async=dict(type='bool', default=True),
263266
))
264267

plugins/modules/cs_instance_nic_secondaryip.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@
5353
zone:
5454
description:
5555
- Name of the zone in which the instance is deployed in.
56-
- If not set, default zone is used.
5756
type: str
57+
required: true
5858
state:
5959
description:
6060
- State of the ipaddress.
@@ -75,16 +75,19 @@
7575
- name: Assign a specific IP to the default NIC of the VM
7676
ngine_io.cloudstack.cs_instance_nic_secondaryip:
7777
vm: customer_xy
78+
zone: zone01
7879
vm_guest_ip: 10.10.10.10
7980
8081
# Note: If vm_guest_ip is not set, you will get a new IP address on every run.
8182
- name: Assign an IP to the default NIC of the VM
8283
ngine_io.cloudstack.cs_instance_nic_secondaryip:
8384
vm: customer_xy
85+
zone: zone01
8486
8587
- name: Remove a specific IP from the default NIC
8688
ngine_io.cloudstack.cs_instance_nic_secondaryip:
8789
vm: customer_xy
90+
zone: zone01
8891
vm_guest_ip: 10.10.10.10
8992
state: absent
9093
'''
@@ -238,7 +241,7 @@ def main():
238241
domain=dict(),
239242
account=dict(),
240243
project=dict(),
241-
zone=dict(),
244+
zone=dict(required=True),
242245
poll_async=dict(type='bool', default=True),
243246
))
244247

0 commit comments

Comments
 (0)