Skip to content

Commit e320885

Browse files
committed
Made it not throw exceptions when it isn't configured correctly.
1 parent 2c96bbd commit e320885

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

Management-Utilities/auto_set_fsxn_auto_grow/set_fsxn_volume_auto_grow.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#
3030
# Create a table of secret names and keys for the username and password for
3131
# each of the FSxIds. In the example below, it shows using the same
32-
# secret for four differnt FSxIds, but you can set it up to use
32+
# secret for four different FSxIds, but you can set it up to use
3333
# a different secret and/or keys for the username and password for each
3434
# of the FSxId.
3535
secretsTable = [
@@ -66,7 +66,7 @@
6666
# Set the minimum shirtk size for the volume in terms of the percentage of the provisioned size.
6767
minShrinkSizePercentage = 100
6868
#
69-
# Set the iime to wait for a volume to get created. This Lambda function will
69+
# Set the time to wait for a volume to get created. This Lambda function will
7070
# loop waiting for the volume to be created on the ONTAP side so it can set
7171
# the auto size parameters. It will wait up to the number of seconds specified
7272
# below before giving up. NOTE: You must set the timeout of this function
@@ -154,7 +154,9 @@ def lambda_handler(event, context):
154154

155155
if 'secretsTable' not in globals():
156156
if 'dynamodbRegion' not in globals() or 'dynamodbSecretsTableName' not in globals():
157-
raise Exception('Error, you must either define the secretsTable array at the top of this script, or define dynamodbRegion and dynamodbSecretsTableName.')
157+
message = 'Error, you must either define the secretsTable array at the top of this script, or define dynamodbRegion and dynamodbSecretsTableName.'
158+
logger.critcal(message)
159+
raise Exception(message)
158160

159161
table = dynamodbClient.Table(dynamodbSecretsTableName) # pylint: disable=E0602
160162

@@ -170,7 +172,8 @@ def lambda_handler(event, context):
170172
if fsxId == "" or regionName == "" or volumeId == "" or volumeName == "" or volumeARN == "":
171173
message = "Couldn't obtain the fsxId, region, volume name, volume ID or volume ARN from the CloudWatch evevnt."
172174
logger.critcal(message)
173-
raise Exception(message)
175+
# raise Exception(message)
176+
return
174177

175178
logger.debug(f'Data from CloudWatch event: FSxID={fsxId}, Region={regionName}, VolumeName={volumeName}, volumeId={volumeId}.')
176179
#
@@ -179,7 +182,8 @@ def lambda_handler(event, context):
179182
if username == "" or password == "":
180183
message = f'No credentials for FSxN ID: {fsxId}.'
181184
logger.critical(message)
182-
raise Exception(message)
185+
# raise Exception(message)
186+
return
183187
#
184188
# Build a header that is used for all the ONTAP API requests.
185189
auth = urllib3.make_headers(basic_auth=f'{username}:{password}')
@@ -192,14 +196,16 @@ def lambda_handler(event, context):
192196
if fsxnIp == "":
193197
message = f"Can't find management IP for FSxN file system with an ID of '{fsxId}'."
194198
logger.critical(message)
195-
raise Exception(message)
199+
# raise Exception(message)
200+
return
196201
#
197202
# Get the volume UUID and volume size based on the volume ID.
198203
volumeData = getVolumeData(fsxClient, volumeId, volumeARN)
199204
if volumeData == None:
200205
message=f'Failed to get volume information for volumeID: {volumeId}.'
201206
logger.critical(message)
202-
raise Exception(message)
207+
# raise Exception(message)
208+
return
203209
volumeUUID = volumeData["OntapConfiguration"]["UUID"]
204210
volumeSizeInMegabytes = volumeData["OntapConfiguration"]["SizeInMegabytes"]
205211
#

0 commit comments

Comments
 (0)