mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 03:41:25 -07:00
[test_ec2*] cloud integration test updates
To support parallel cloud test execution, create and provide a random string to cloud integration tests. The variable 'resource_prefix' can be used in cloud roles and during resource cleanup to safely create/destroy cloud-based resources. Additional changes include: * The roles test_ec2_key and test_ec2_group were updated to use to {{resource_prefix}}. * Additionally, the Makefile was updated to set resource_prefix to a random string. The Makefile will also use 'resource_prefix' during cloud_cleanup. * All test_ec2* roles were updated to add 'setup_ec2' as a role dependency.
This commit is contained in:
parent
d1753046e0
commit
07dd02c25a
14 changed files with 42 additions and 31 deletions
|
@ -15,7 +15,7 @@ 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(item, "Delete object with %s=%s? [y/n]: " % (attr, val), opts.assumeyes)
|
||||
prompt_and_delete(item, "Delete matching %s? [y/n]: " % (item,), opts.assumeyes)
|
||||
|
||||
def prompt_and_delete(item, prompt, assumeyes):
|
||||
if not assumeyes:
|
||||
|
@ -23,6 +23,7 @@ def prompt_and_delete(item, prompt, assumeyes):
|
|||
assert hasattr(item, 'delete'), "Class <%s> has no delete attribute" % item.__class__
|
||||
if assumeyes:
|
||||
item.delete()
|
||||
print ("Deleted %s" % item)
|
||||
|
||||
def parse_args():
|
||||
# Load details from credentials.yml
|
||||
|
@ -74,8 +75,11 @@ if __name__ == '__main__':
|
|||
aws = boto.connect_ec2(aws_access_key_id=opts.ec2_access_key,
|
||||
aws_secret_access_key=opts.ec2_secret_key)
|
||||
|
||||
# Delete matching keys
|
||||
delete_aws_resources(aws.get_all_key_pairs, 'name', opts)
|
||||
try:
|
||||
# Delete matching keys
|
||||
delete_aws_resources(aws.get_all_key_pairs, 'name', opts)
|
||||
|
||||
# Delete matching groups
|
||||
delete_aws_resources(aws.get_all_security_groups, 'name', opts)
|
||||
# Delete matching groups
|
||||
delete_aws_resources(aws.get_all_security_groups, 'name', opts)
|
||||
except KeyboardInterrupt, e:
|
||||
print "\nExiting on user command."
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue