Hello simon​ ,
Thank you for the answer.
From the ansible point of view, I had the context value. The issue is still present.
fatal: [localhost]: FAILED! => {
"changed": false,
"invocation": {
"module_args": {
"access": "root-squash",
"account": null,
"actions": null,
"anongid": null,
"anonuid": null,
"api_token": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"at": null,
"atime": true,
"before_rule": null,
"change": null,
"client": "10.0.1.0/24",
"context": "myfbname",
"default_retention": null,
"desc": "",
"destroy_snapshots": false,
"disable_warnings": false,
"effect": "allow",
"enabled": true,
"every": null,
"fb_url": "fb_ipv4",
"fileid_32bit": false,
"filesystem": null,
"force_delete": false,
"full_control": null,
"ignore_enforcement": true,
"interfaces": null,
"keep_for": null,
"max_retention": null,
"min_retention": null,
"name": "test_nfs_export",
"object_resources": null,
"permission": "rw",
"policy_type": "nfs",
"principal": null,
"read": null,
"rename": null,
"replica_link": null,
"retention_lock": null,
"rule": null,
"s3_delimiters": null,
"s3_prefixes": null,
"secure": true,
"security": [
"sys",
"krb5"
],
"smb_encryption": "optional",
"source_ips": null,
"state": "present",
"target": null,
"target_rule": null,
"timezone": null,
"user": null
}
},
"msg": "Failed to get NFS export policy rules for test_nfs_export. Error: Unexpected error."
}
The context seems to be correctly set.
The usage of the function :
blade.get_nfs_export_policies_rules(
policy_names=["test_nfs_export"],
filter="client='" + '10.0.1.0/24' + "'",
context_names=["myfbname"])
{'errors': [{'context': None, 'message': 'Unexpected error.'}],
'headers': None,
'status_code': 500}
I've implemented a very ugly patch as a temporary solution to my issue. I am not sure this is a good approach.
diff --git a/plugins/modules/purefb_policy.py b/plugins/modules/purefb_policy.py
index edfcba8..67a4368 100644
--- a/plugins/modules/purefb_policy.py
+++ b/plugins/modules/purefb_policy.py
@@ -2341,13 +2341,14 @@ def update_nfs_policy(module, blade):
policy_names=[module.params["name"]],
filter="client='" + module.params["client"] + "'",
context_names=[module.params["context"]],
+ names=[module.params["name"]]
)
else:
current_policy_rule = blade.get_nfs_export_policies_rules(
policy_names=[module.params["name"]],
filter="client='" + module.params["client"] + "'",
)
- if current_policy_rule.status_code != 200:
+ if current_policy_rule.status_code != 200 and current_policy_rule.status_code != 400:
module.fail_json(
msg="Failed to get NFS export policy rules for {0}. Error: {1}".format(
module.params["name"],
@@ -2355,8 +2356,9 @@ def update_nfs_policy(module, blade):
)
)
elif (
- current_policy_rule.status_code == 200
- and current_policy_rule.total_item_count == 0
+ (current_policy_rule.status_code == 200
+ and current_policy_rule.total_item_count == 0)
+ or (current_policy_rule.status_code == 400 and current_policy_rule.errors[0].message == "NFS export policy rule does not exist.")
):
rule = NfsExportPolicyRule(
client=module.params["client"],
Thank you for your time.
Best.
Matth