Skip to content

Commit f2d5706

Browse files
committed
Enhance NFS correlation logic to include FQDN and account-based matching; update condition for ANF IP addresses in configuration checks
1 parent 8ddf10d commit f2d5706

File tree

2 files changed

+51
-6
lines changed

2 files changed

+51
-6
lines changed

src/module_utils/filesystem_collector.py

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,27 @@ def _parse_filesystem_data(
112112
for nfs_share in afs_storage_data:
113113
storage_account_name = nfs_share.get("Pool", "")
114114
share_address = nfs_share.get("NFSAddress", "")
115-
if (
115+
ip_match = (
116116
":" in share_address and share_address.split(":")[0] == nfs_address
117-
) or storage_account_name in nfs_address:
117+
)
118+
fqdn_match = (
119+
storage_account_name and storage_account_name in nfs_address
120+
)
121+
ip_to_account_match = False
122+
try:
123+
ipaddress.ip_address(nfs_address)
124+
except Exception as ex:
125+
self.parent.log(
126+
logging.DEBUG,
127+
f"NFS address {nfs_address} is not a valid IP: {ex}",
128+
)
129+
if ":" in nfs_source and "/" in nfs_source:
130+
mount_path = nfs_source.split(":", 1)[1]
131+
ip_to_account_match = (
132+
storage_account_name
133+
and ("/" + storage_account_name + "/") in mount_path
134+
)
135+
if ip_match or fqdn_match or ip_to_account_match:
118136
filesystem_entry["max_mbps"] = nfs_share.get("ThroughputMibps", 0)
119137
filesystem_entry["max_iops"] = nfs_share.get("IOPS", 0)
120138
filesystem_entry["nfs_type"] = "AFS"
@@ -472,16 +490,43 @@ def gather_all_filesystem_info(
472490
if not matched:
473491
for nfs_share in afs_storage_data:
474492
share_address = nfs_share.get("NFSAddress", "")
475-
if (
493+
storage_account_name = nfs_share.get("Pool", "")
494+
ip_match = (
476495
":" in share_address
477496
and share_address.split(":")[0] == nfs_address
478-
):
497+
)
498+
fqdn_match = (
499+
storage_account_name and storage_account_name in nfs_address
500+
)
501+
ip_to_account_match = False
502+
try:
503+
ipaddress.ip_address(nfs_address)
504+
if ":" in source and "/" in source:
505+
mount_path = source.split(":", 1)[1]
506+
share_path = (
507+
share_address.split(":", 1)[1]
508+
if ":" in share_address
509+
else ""
510+
)
511+
ip_to_account_match = (
512+
storage_account_name
513+
and ("/" + storage_account_name + "/") in mount_path
514+
)
515+
except ValueError:
516+
pass
517+
518+
if ip_match or fqdn_match or ip_to_account_match:
479519
max_mbps = nfs_share.get("ThroughputMibps", 0)
480520
max_iops = nfs_share.get("IOPS", 0)
521+
match_type = (
522+
"IP"
523+
if ip_match
524+
else ("FQDN" if fqdn_match else "IP→Account")
525+
)
481526
self.parent.log(
482527
logging.INFO,
483528
f"Correlated NFS {target} with "
484-
+ f"AFS: MBPS={max_mbps}, IOPS={max_iops}",
529+
+ f"AFS ({match_type}): MBPS={max_mbps}, IOPS={max_iops}, Account={storage_account_name}",
485530
)
486531
break
487532

src/roles/configuration_checks/tasks/disks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@
204204
- has_nfs_mounts | bool
205205
- ANF_account_rg is defined
206206
- ANF_account_name is defined
207-
- anf_ip_addresses is defined
207+
- (anf_ip_addresses is defined and anf_ip_addresses | length > 0) or (NFS_provider is defined and 'ANF' in NFS_provider)
208208
register: anf_storage_metadata_results
209209
delegate_to: localhost
210210
ansible.builtin.shell:

0 commit comments

Comments
 (0)