summaryrefslogtreecommitdiffstats
path: root/ansible_collections/purestorage/flasharray/plugins/modules
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-26 06:22:20 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-26 06:22:20 +0000
commit18bd2207b6c1977e99a93673a7be099e23f0f547 (patch)
tree40fd9e5913462a88be6ba24be6953383c5b39874 /ansible_collections/purestorage/flasharray/plugins/modules
parentReleasing progress-linux version 10.0.1+dfsg-1~progress7.99u1. (diff)
downloadansible-18bd2207b6c1977e99a93673a7be099e23f0f547.tar.xz
ansible-18bd2207b6c1977e99a93673a7be099e23f0f547.zip
Merging upstream version 10.1.0+dfsg.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ansible_collections/purestorage/flasharray/plugins/modules')
-rw-r--r--ansible_collections/purestorage/flasharray/plugins/modules/purefa_info.py2
-rw-r--r--ansible_collections/purestorage/flasharray/plugins/modules/purefa_network.py27
-rw-r--r--ansible_collections/purestorage/flasharray/plugins/modules/purefa_policy.py109
3 files changed, 73 insertions, 65 deletions
diff --git a/ansible_collections/purestorage/flasharray/plugins/modules/purefa_info.py b/ansible_collections/purestorage/flasharray/plugins/modules/purefa_info.py
index cc2c92fdc..ca6e73dfe 100644
--- a/ansible_collections/purestorage/flasharray/plugins/modules/purefa_info.py
+++ b/ansible_collections/purestorage/flasharray/plugins/modules/purefa_info.py
@@ -1800,7 +1800,7 @@ def generate_del_pgroups_dict(module, array):
return pgroups_info
-def generate_pgroups_dict(module, array, performance):
+def generate_pgroups_dict(module, array):
pgroups_info = {}
api_version = array._list_available_rest_versions()
pgroups = array.list_pgroups()
diff --git a/ansible_collections/purestorage/flasharray/plugins/modules/purefa_network.py b/ansible_collections/purestorage/flasharray/plugins/modules/purefa_network.py
index c296707d0..97a510504 100644
--- a/ansible_collections/purestorage/flasharray/plugins/modules/purefa_network.py
+++ b/ansible_collections/purestorage/flasharray/plugins/modules/purefa_network.py
@@ -319,6 +319,8 @@ def update_interface(module, array, interface):
"services": sorted(interface["services"]),
"slaves": sorted(interface["slaves"]),
}
+ if not current_state["address"]:
+ current_state["address"] = "0.0.0.0"
array6 = get_array(module)
subinterfaces = sorted(current_state["slaves"])
if module.params["subinterfaces"]:
@@ -339,19 +341,19 @@ def update_interface(module, array, interface):
enabled = current_state["enabled"]
if not current_state["gateway"]:
try:
- if valid_ipv4(interface["address"]):
+ if valid_ipv4(current_state["address"]):
current_state["gateway"] = None
- elif valid_ipv6(interface["address"]):
+ elif valid_ipv6(current_state["address"]):
current_state["gateway"] = None
except AttributeError:
current_state["gateway"] = None
if not module.params["servicelist"]:
- services = sorted(interface["services"])
+ services = current_state["services"]
else:
services = sorted(module.params["servicelist"])
if not module.params["address"]:
- address = interface["address"]
- netmask = interface["netmask"]
+ address = current_state["address"]
+ netmask = current_state["netmask"]
else:
if module.params["gateway"] and module.params["gateway"] not in [
"0.0.0.0",
@@ -359,7 +361,7 @@ def update_interface(module, array, interface):
]:
if module.params["gateway"] not in IPNetwork(module.params["address"]):
module.fail_json(msg="Gateway and subnet are not compatible.")
- if not module.params["gateway"] and interface["gateway"] not in [
+ if not module.params["gateway"] and current_state["gateway"] not in [
None,
IPNetwork(module.params["address"]),
]:
@@ -368,7 +370,7 @@ def update_interface(module, array, interface):
if address in ["0.0.0.0", "::"]:
address = None
if not module.params["mtu"]:
- mtu = interface["mtu"]
+ mtu = current_state["mtu"]
else:
if not 1280 <= module.params["mtu"] <= 9216:
module.fail_json(
@@ -379,6 +381,8 @@ def update_interface(module, array, interface):
else:
mtu = module.params["mtu"]
if module.params["address"]:
+ if not address:
+ address = "0.0.0.0"
if valid_ipv4(address):
netmask = str(IPNetwork(module.params["address"]).netmask)
else:
@@ -386,9 +390,9 @@ def update_interface(module, array, interface):
if netmask in ["0.0.0.0", "0"]:
netmask = None
else:
- netmask = interface["netmask"]
+ netmask = current_state["netmask"]
if not module.params["gateway"]:
- gateway = interface["gateway"]
+ gateway = current_state["gateway"]
elif module.params["gateway"] in ["0.0.0.0", "::"]:
gateway = None
elif valid_ipv4(address):
@@ -427,7 +431,7 @@ def update_interface(module, array, interface):
changed = True
if (
module.params["servicelist"]
- and sorted(module.params["servicelist"]) != interface["services"]
+ and sorted(module.params["servicelist"]) != current_state["services"]
):
api_version = array._list_available_rest_versions()
if FC_ENABLE_API in api_version:
@@ -450,7 +454,8 @@ def update_interface(module, array, interface):
"Servicelist not updated as pypureclient module is required"
)
if (
- "management" in interface["services"] or "app" in interface["services"]
+ "management" in current_state["services"]
+ or "app" in current_state["services"]
) and address in ["0.0.0.0/0", "::/0"]:
module.fail_json(
msg="Removing IP address from a management or app port is not supported"
diff --git a/ansible_collections/purestorage/flasharray/plugins/modules/purefa_policy.py b/ansible_collections/purestorage/flasharray/plugins/modules/purefa_policy.py
index 7247d376f..636a77c50 100644
--- a/ansible_collections/purestorage/flasharray/plugins/modules/purefa_policy.py
+++ b/ansible_collections/purestorage/flasharray/plugins/modules/purefa_policy.py
@@ -1416,64 +1416,67 @@ def update_policy(module, array, api_version, all_squash):
).items
)
if rules:
- rule_name = ""
for rule in range(0, len(rules)):
- if rules[rule].client_name == module.params["snap_client_name"]:
- rule_name = rules[rule].name
- break
- if not rule_name:
- if module.params["snap_keep_for"] < module.params["snap_every"]:
+ if (
+ rules[rule].client_name == module.params["snap_client_name"]
+ and int(rules[rule].every / 60000)
+ == module.params["snap_every"]
+ and int(rules[rule].keep_for / 60000)
+ == module.params["snap_keep_for"]
+ ):
+ module.exit_json(changed=False)
+ if module.params["snap_keep_for"] < module.params["snap_every"]:
+ module.fail_json(
+ msg="Retention period (snap_keep_for) cannot be less than snapshot interval (snap_every)."
+ )
+ if module.params["snap_at"]:
+ if not module.params["snap_every"] % 1440 == 0:
module.fail_json(
- msg="Retention period (snap_keep_for) cannot be less than snapshot interval (snap_every)."
+ msg="snap_at time can only be set if snap_every is multiple of 1440"
+ )
+ if suffix_enabled:
+ rules = flasharray.PolicyrulesnapshotpostRules(
+ at=convert_to_millisecs(module.params["snap_at"]),
+ client_name=module.params["snap_client_name"],
+ every=module.params["snap_every"] * 60000,
+ keep_for=module.params["snap_keep_for"] * 60000,
+ suffix=module.params["snap_suffix"],
)
- if module.params["snap_at"]:
- if not module.params["snap_every"] % 1440 == 0:
- module.fail_json(
- msg="snap_at time can only be set if snap_every is multiple of 1440"
- )
- if suffix_enabled:
- rules = flasharray.PolicyrulesnapshotpostRules(
- at=convert_to_millisecs(module.params["snap_at"]),
- client_name=module.params["snap_client_name"],
- every=module.params["snap_every"] * 60000,
- keep_for=module.params["snap_keep_for"] * 60000,
- suffix=module.params["snap_suffix"],
- )
- else:
- rules = flasharray.PolicyrulesnapshotpostRules(
- at=convert_to_millisecs(module.params["snap_at"]),
- client_name=module.params["snap_client_name"],
- every=module.params["snap_every"] * 60000,
- keep_for=module.params["snap_keep_for"] * 60000,
- )
else:
- if suffix_enabled:
- rules = flasharray.PolicyrulesnapshotpostRules(
- client_name=module.params["snap_client_name"],
- every=module.params["snap_every"] * 60000,
- keep_for=module.params["snap_keep_for"] * 60000,
- suffix=module.params["snap_suffix"],
- )
- else:
- rules = flasharray.PolicyrulesnapshotpostRules(
- client_name=module.params["snap_client_name"],
- every=module.params["snap_every"] * 60000,
- keep_for=module.params["snap_keep_for"] * 60000,
- )
- rule = flasharray.PolicyRuleSnapshotPost(rules=[rules])
- changed_rule = True
- if not module.check_mode:
- rule_created = array.post_policies_snapshot_rules(
- policy_names=[module.params["name"]], rules=rule
- )
- if rule_created.status_code != 200:
- err_no = len(rule_created.errors) - 1
- module.fail_json(
- msg="Failed to create new rule for Snapshot policy {0}. Error: {1}".format(
- module.params["name"],
- rule_created.errors[err_no].message,
- )
+ rules = flasharray.PolicyrulesnapshotpostRules(
+ at=convert_to_millisecs(module.params["snap_at"]),
+ client_name=module.params["snap_client_name"],
+ every=module.params["snap_every"] * 60000,
+ keep_for=module.params["snap_keep_for"] * 60000,
+ )
+ else:
+ if suffix_enabled:
+ rules = flasharray.PolicyrulesnapshotpostRules(
+ client_name=module.params["snap_client_name"],
+ every=module.params["snap_every"] * 60000,
+ keep_for=module.params["snap_keep_for"] * 60000,
+ suffix=module.params["snap_suffix"],
+ )
+ else:
+ rules = flasharray.PolicyrulesnapshotpostRules(
+ client_name=module.params["snap_client_name"],
+ every=module.params["snap_every"] * 60000,
+ keep_for=module.params["snap_keep_for"] * 60000,
+ )
+ rule = flasharray.PolicyRuleSnapshotPost(rules=[rules])
+ changed_rule = True
+ if not module.check_mode:
+ rule_created = array.post_policies_snapshot_rules(
+ policy_names=[module.params["name"]], rules=rule
+ )
+ if rule_created.status_code != 200:
+ err_no = len(rule_created.errors) - 1
+ module.fail_json(
+ msg="Failed to create new rule for Snapshot policy {0}. Error: {1}".format(
+ module.params["name"],
+ rule_created.errors[err_no].message,
)
+ )
else:
if module.params["snap_keep_for"] < module.params["snap_every"]:
module.fail_json(