Skip to content

Commit d8acae6

Browse files
Don't start s snapshot if there is already pending
1 parent 1dd4684 commit d8acae6

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

shotty/shotty.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ def filter_instances(project):
1515
instances = ec2.instances.all()
1616

1717
return instances
18+
def has_pending_snapshot(volume):
19+
snapshots = list(volume.snapshots.all())
20+
return snapshots and snapshots[0].state == 'pending'
21+
1822

1923
@click.group()
2024
def cli():
@@ -91,6 +95,9 @@ def create_snapshots(project):
9195
i.wait_until_stopped()
9296

9397
for v in i.volumes.all():
98+
if has_pending_snapshot(v):
99+
print(" Skipping {0}, snapshot already in progress".format(v.id))
100+
continue
94101
print(" Creating snapshot of {0}".format(v.id))
95102
v.create_snapshot(Description="Created by snapshotanalyzer 2020")
96103

0 commit comments

Comments
 (0)