From f0a89d5bdf6e96d870247cdd023a4d9e78794745 Mon Sep 17 00:00:00 2001 From: James Laska Date: Wed, 12 Mar 2014 19:28:57 -0400 Subject: [PATCH] Correct test integration ec2 cleanup script --- test/integration/cleanup_ec2.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/test/integration/cleanup_ec2.py b/test/integration/cleanup_ec2.py index 08d54751aaf..0e974c2089e 100644 --- a/test/integration/cleanup_ec2.py +++ b/test/integration/cleanup_ec2.py @@ -15,12 +15,14 @@ def delete_aws_resources(get_func, attr, opts): for item in get_func(): val = getattr(item, attr) 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): - while not assumeyes: - assumeyes = raw_input(prompt) - obj.delete() +def prompt_and_delete(item, prompt, assumeyes): + if not assumeyes: + assumeyes = raw_input(prompt).lower() == 'y' + assert hasattr(item, 'delete'), "Class <%s> has no delete attribute" % item.__class__ + if assumeyes: + item.delete() def parse_args(): # Load details from credentials.yml