Skip to content
This repository has been archived by the owner on Jul 28, 2021. It is now read-only.

Commit

Permalink
Merge pull request #18 from rackerlabs/parse_configs
Browse files Browse the repository at this point in the history
Test parse configs before saving
  • Loading branch information
TheSeubert authored Feb 13, 2017
2 parents a7c8e6e + 048e0bd commit 1f88083
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions ebs_snapper/dynamo.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ def store_configuration(installed_region, object_id, aws_account_id, configurati
dynamodb = boto3.resource('dynamodb', region_name=installed_region)
table = dynamodb.Table('ebs_snapshot_configuration')

# be sure they parse correctly before we go saving them
utils.parse_snapshot_settings(configuration)

response = table.put_item(
Item={
'aws_account_id': aws_account_id,
Expand Down
9 changes: 7 additions & 2 deletions ebs_snapper/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,13 @@ def parse_snapshot_settings(snapshot_settings):
if k not in snapshot_settings['snapshot']:
raise Exception('missing required snapshot setting {}'.format(k))

retention_seconds = timeparse(snapshot_settings['snapshot']['retention'])
retention = timedelta(seconds=retention_seconds)
ret_s = snapshot_settings['snapshot']['retention']
retention = timeparse('7 days')
try:
retention_seconds = timeparse(ret_s)
retention = timedelta(seconds=retention_seconds)
except:
raise Exception('Could not parse snapshot retention value', ret_s)

f_expr = snapshot_settings['snapshot']['frequency']
if is_timedelta_expression(f_expr):
Expand Down

0 comments on commit 1f88083

Please sign in to comment.