Mercurial > repos > shellac > guppy_basecaller
comparison env/bin/kill_instance @ 0:26e78fe6e8c4 draft
"planemo upload commit c699937486c35866861690329de38ec1a5d9f783"
| author | shellac |
|---|---|
| date | Sat, 02 May 2020 07:14:21 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:26e78fe6e8c4 |
|---|---|
| 1 #!/Users/pldms/Development/Projects/2020/david-matthews-galaxy/guppy_basecaller/env/bin/python3 | |
| 2 | |
| 3 import sys | |
| 4 from optparse import OptionParser | |
| 5 | |
| 6 import boto | |
| 7 from boto.ec2 import regions | |
| 8 | |
| 9 | |
| 10 | |
| 11 def kill_instance(region, ids): | |
| 12 """Kill an instances given it's instance IDs""" | |
| 13 # Connect the region | |
| 14 ec2 = boto.connect_ec2(region=region) | |
| 15 for instance_id in ids: | |
| 16 print("Stopping instance: %s" % instance_id) | |
| 17 ec2.terminate_instances([instance_id]) | |
| 18 | |
| 19 | |
| 20 if __name__ == "__main__": | |
| 21 parser = OptionParser(usage="kill_instance [-r] id [id ...]") | |
| 22 parser.add_option("-r", "--region", help="Region (default us-east-1)", dest="region", default="us-east-1") | |
| 23 (options, args) = parser.parse_args() | |
| 24 if not args: | |
| 25 parser.print_help() | |
| 26 sys.exit(1) | |
| 27 for r in regions(): | |
| 28 if r.name == options.region: | |
| 29 region = r | |
| 30 break | |
| 31 else: | |
| 32 print("Region %s not found." % options.region) | |
| 33 sys.exit(1) | |
| 34 | |
| 35 kill_instance(region, args) |
