Correct test integration ec2 cleanup script
This commit is contained in:
parent
e753b39eae
commit
9cc4be2683
1 changed files with 7 additions and 5 deletions
|
@ -15,12 +15,14 @@ def delete_aws_resources(get_func, attr, opts):
|
||||||
for item in get_func():
|
for item in get_func():
|
||||||
val = getattr(item, attr)
|
val = getattr(item, attr)
|
||||||
if re.search(opts.match_re, val):
|
if re.search(opts.match_re, val):
|
||||||
prompt_and_delete("Delete object with %s=%s? [y/n]: " % (attr, val), opts.assumeyes)
|
prompt_and_delete(item, "Delete object with %s=%s? [y/n]: " % (attr, val), opts.assumeyes)
|
||||||
|
|
||||||
def prompt_and_delete(prompt, assumeyes):
|
def prompt_and_delete(item, prompt, assumeyes):
|
||||||
while not assumeyes:
|
if not assumeyes:
|
||||||
assumeyes = raw_input(prompt)
|
assumeyes = raw_input(prompt).lower() == 'y'
|
||||||
obj.delete()
|
assert hasattr(item, 'delete'), "Class <%s> has no delete attribute" % item.__class__
|
||||||
|
if assumeyes:
|
||||||
|
item.delete()
|
||||||
|
|
||||||
def parse_args():
|
def parse_args():
|
||||||
# Load details from credentials.yml
|
# Load details from credentials.yml
|
||||||
|
|
Loading…
Reference in a new issue