Skip to content

Commit e965812

Browse files
committed
Had it update the lastFileRead structure if the old format is found to enable backwords compatibility.
1 parent d993b05 commit e965812

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

Monitoring/ingest_nas_audit_logs_into_cloudwatch/ingest_audit_log.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,10 @@
1212
# system that doesn't have the specified volume.
1313
#
1414
# It assumes:
15-
# - That there is only one data vserver per FSxN file system and that it
16-
# is named 'fsx'.
1715
# - That the administrator username is 'fsxadmin'.
1816
# - That the audit log files will be named in the following format:
19-
# audit_fsx_D2024-09-24-T13-00-03_0000000000.xml
20-
# Where 'fsx' is the vserver name.
17+
# audit_vserver_D2024-09-24-T13-00-03_0000000000.xml
18+
# Where 'vserver' is the vserver name.
2119
#
2220
################################################################################
2321
#
@@ -54,6 +52,14 @@
5452
# all FSxNs.
5553
#volumeName = "audit_logs"
5654
#
55+
# The name of the vserver that holds the audit logs. Assumed to be the same on
56+
# all FSxNs.
57+
# *NOTE*:The program has been updated to loop on all the vservers within an FSxN
58+
# filesystem and not just the one set here. This variable is now used
59+
# so it can update the lastFireRead stats file to conform to the new format
60+
# that includes the vserver as part of the structure.
61+
#vserverName = "fsx"
62+
#
5763
# The CloudWatch log group to store the audit logs in.
5864
#logGroupName = "/fsx/audit_logs"
5965

@@ -261,6 +267,9 @@ def checkConfig():
261267
config[item] = os.environ.get(item)
262268
if config[item] == None:
263269
raise Exception(f"{item} is not set.")
270+
#
271+
# To be backwards compatible, load the vserverName.
272+
config['vserverName'] = vserverName if 'vserverName' in globals() else os.environ.get('vserverName') # pylint: disable=E0602
264273

265274
################################################################################
266275
# This is the main function that checks that everything is configured correctly
@@ -325,6 +334,11 @@ def lambda_handler(event, context): # pylint: disable=W0613
325334
for fsxn in fsxNs:
326335
fsId = fsxn.split('.')[1]
327336
#
337+
# Since the format of the lastReadFile sttucture has changed, we need to update it.
338+
if lastFileRead.get(fsxn) is not None and config['vserverName'] is not None:
339+
if type(lastFileRead[fsxn]) is float: # Old format
340+
lastFileRead[fsxn] = {config['vserverName']: lastFileRead[fsxn]} # New format
341+
#
328342
# Get the password
329343
password = secrets.get(fsId)
330344
if password == None:

0 commit comments

Comments
 (0)