Skip to content

Commit 66c3b39

Browse files
committed
Fix DNS module - missing parameters
1 parent 6050b18 commit 66c3b39

8 files changed

+38
-29
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ The Pure Storage FlashBlade collection consists of the latest versions of the Fl
1616
- Pure Storage FlashBlade system running Purity//FB 2.1.2 or later
1717
- some modules require higher versions of Purity//FB
1818
- purity-fb >=v1.12.2
19-
- py-pure-client >=v1.27.0
19+
- py-pure-client >=v1.67.2
2020
- python >=3.9
2121
- netaddr
2222
- datetime
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
bugfixes:
2+
- purefb_dns - Fixed multiple issues for data DNS configuration
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
bugfixes:
2+
- purefb_s3user - Fixed typo in imported keys code
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
bugfixes:
2+
- purefb_bucket_access - Fixed typo in CORS rule definition
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
bugfixes:
2+
- purefb_bucket - Fixed issue with default retention parameter

plugins/modules/.purefb_fs.py.swp

16 KB
Binary file not shown.

plugins/modules/purefb_dns.py

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@
5252
- A virtual network interface (vip)
5353
- The network interfaces must have a I(service) value of I(data)
5454
type: str
55+
service:
56+
description:
57+
- The service utilizing the DNS configuration.
58+
- Only aplicable when creating a new DNS configuration.
59+
type: str
60+
choices: [ management, data ]
61+
default: data
5562
extends_documentation_fragment:
5663
- purestorage.flashblade.purestorage.fb
5764
"""
@@ -88,7 +95,7 @@
8895

8996
HAS_PURESTORAGE = True
9097
try:
91-
from pypureclient.flashblade import Dns, DnsPatch, DnsPost, ReferenceNoId
98+
from pypureclient.flashblade import Dns, DnsPatch, DnsPost, Reference
9299
except ImportError:
93100
HAS_PURESTORAGE = False
94101

@@ -169,30 +176,28 @@ def update_multi_dns(module, blade):
169176
if module.params["domain"] and current_dns.domain != module.params["domain"]:
170177
new_dns.domain = module.params["domain"]
171178
changed = True
172-
if module.params["service"] and current_dns.services != [module.params["service"]]:
173-
module.fail_json(msg="Changing service type is not permitted")
174179
if module.params["nameservers"] and sorted(current_dns.nameservers) != sorted(
175180
module.params["nameservers"]
176181
):
177182
new_dns.nameservers = module.params["nameservers"]
178183
changed = True
179184
if (module.params["source"] or module.params["source"] == "") and getattr(
180-
current_dns.source, "name", ""
185+
current_dns.sources[0], "name", ""
181186
) != module.params["source"]:
182-
new_dns.source.name = module.params["source"]
187+
new_dns.sources[0].name = module.params["source"]
183188
changed = True
184189
if changed and not module.check_mode:
185190
res = blade.patch_dns(
186191
names=[module.params["name"]],
187192
dns=Dns(
188193
domain=new_dns.domain,
189194
nameservers=new_dns.nameservers,
190-
source=ReferenceNoId(module.params["source"]),
195+
sources=[Reference(name=module.params["source"])],
191196
),
192197
)
193198
if res.status_code != 200:
194199
module.fail_json(
195-
msg="Update to DNS service {0} failed. Error: {1}".format(
200+
msg="Update to DNS configuration {0} failed. Error: {1}".format(
196201
module.params["name"], res.errors[0].message
197202
)
198203
)
@@ -203,16 +208,7 @@ def delete_multi_dns(module, blade):
203208
"""Delete a DNS configuration"""
204209
changed = True
205210
if module.params["name"] == "management":
206-
res = blade.patch_dns(
207-
names=[module.params["name"]],
208-
dns=DnsPatch(domain="", nameservers=[]),
209-
)
210-
if res.status_code != 200:
211-
module.fail_json(
212-
msg="Management DNS configuration not deleted. Error: {0}".format(
213-
res.errors[0].message
214-
)
215-
)
211+
module.fail_json(msg="Management DNS configuration cannot be deleted")
216212
else:
217213
if not module.check_mode:
218214
res = blade.delete_dns(names=[module.params["name"]])
@@ -229,15 +225,15 @@ def create_multi_dns(module, blade):
229225
"""Create a DNS configuration"""
230226
changed = True
231227
if not module.check_mode:
232-
if module.params["service"] == "file":
228+
if module.params["service"] == "data":
233229
if module.params["source"]:
234230
res = blade.post_dns(
235231
names=[module.params["name"]],
236232
dns=DnsPost(
237233
services=[module.params["service"]],
238234
domain=module.params["domain"],
239235
nameservers=module.params["nameservers"],
240-
source=ReferenceNoId(module.params["source"].lower()),
236+
sources=[Reference(name=module.params["source"].lower())],
241237
),
242238
)
243239
else:
@@ -250,11 +246,13 @@ def create_multi_dns(module, blade):
250246
),
251247
)
252248
else:
253-
res = blade.create_dns(
249+
res = blade.post_dns(
254250
names=[module.params["name"]],
255-
services=[module.params["service"]],
256-
domain=module.params["domain"],
257-
nameservers=module.params["nameservers"],
251+
dns=DnsPost(
252+
services=[module.params["service"]],
253+
domain=module.params["domain"],
254+
nameservers=module.params["nameservers"],
255+
),
258256
)
259257
if res.status_code != 200:
260258
module.fail_json(
@@ -276,6 +274,7 @@ def main():
276274
domain=dict(type="str"),
277275
source=dict(type="str"),
278276
nameservers=dict(type="list", elements="str"),
277+
service=dict(type="str", choices=["management", "data"], default="data"),
279278
)
280279
)
281280

@@ -293,16 +292,18 @@ def main():
293292
for config in range(0, len(configs)):
294293
if configs[config].name == module.params["name"]:
295294
exists = True
296-
if module.params["name"] != "management" and not exists:
297-
module.warn("Overriding configuration name to management")
298-
module.params["name"] = "management"
299295
if module.params["source"] and not _get_source(module, blade):
300296
module.fail_json(
301297
msg="Specified VIP {0} does not exist.".format(module.params["source"])
302298
)
303299
if state == "present" and exists:
304300
update_multi_dns(module, blade)
305301
elif state == "present" and not exists:
302+
if not module.params["nameservers"] and not module.params["domain"]:
303+
module.fail_json(
304+
msg="DNS configuration must have at least one domain "
305+
"or nameserver defined."
306+
)
306307
create_multi_dns(module, blade)
307308
elif exists and state == "absent":
308309
delete_multi_dns(module, blade)
@@ -314,7 +315,8 @@ def main():
314315
elif state == "present":
315316
if not module.params["domain"] or not module.params["nameservers"]:
316317
module.fail_json(
317-
msg="`domain` and `nameservers` are required for DNS configuration"
318+
msg="DNS configuration must have at least one domain "
319+
"or nameserver defined."
318320
)
319321
create_dns(module, blade)
320322
else:

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@ datetime
33
pycountry
44
pytz
55
purity-fb
6-
py-pure-client
76
urllib3

0 commit comments

Comments
 (0)