Mercurial > repos > shellac > sam_consensus_v3
annotate env/bin/bundle_image @ 0:4f3585e2f14b draft default tip
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
| author | shellac | 
|---|---|
| date | Mon, 22 Mar 2021 18:12:50 +0000 | 
| parents | |
| children | 
| rev | line source | 
|---|---|
| 
0
 
4f3585e2f14b
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
 
shellac 
parents:  
diff
changeset
 | 
1 #!/Users/cmdms/OneDrive-UOB/Development/Projects/2021/sam-consensus-v3/env/bin/python3 | 
| 
 
4f3585e2f14b
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
 
shellac 
parents:  
diff
changeset
 | 
2 from boto.manage.server import Server | 
| 
 
4f3585e2f14b
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
 
shellac 
parents:  
diff
changeset
 | 
3 if __name__ == "__main__": | 
| 
 
4f3585e2f14b
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
 
shellac 
parents:  
diff
changeset
 | 
4 from optparse import OptionParser | 
| 
 
4f3585e2f14b
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
 
shellac 
parents:  
diff
changeset
 | 
5 parser = OptionParser(version="%prog 1.0", usage="Usage: %prog [options] instance-id [instance-id-2]") | 
| 
 
4f3585e2f14b
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
 
shellac 
parents:  
diff
changeset
 | 
6 | 
| 
 
4f3585e2f14b
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
 
shellac 
parents:  
diff
changeset
 | 
7 # Commands | 
| 
 
4f3585e2f14b
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
 
shellac 
parents:  
diff
changeset
 | 
8 parser.add_option("-b", "--bucket", help="Destination Bucket", dest="bucket", default=None) | 
| 
 
4f3585e2f14b
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
 
shellac 
parents:  
diff
changeset
 | 
9 parser.add_option("-p", "--prefix", help="AMI Prefix", dest="prefix", default=None) | 
| 
 
4f3585e2f14b
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
 
shellac 
parents:  
diff
changeset
 | 
10 parser.add_option("-k", "--key", help="Private Key File", dest="key_file", default=None) | 
| 
 
4f3585e2f14b
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
 
shellac 
parents:  
diff
changeset
 | 
11 parser.add_option("-c", "--cert", help="Public Certificate File", dest="cert_file", default=None) | 
| 
 
4f3585e2f14b
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
 
shellac 
parents:  
diff
changeset
 | 
12 parser.add_option("-s", "--size", help="AMI Size", dest="size", default=None) | 
| 
 
4f3585e2f14b
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
 
shellac 
parents:  
diff
changeset
 | 
13 parser.add_option("-i", "--ssh-key", help="SSH Keyfile", dest="ssh_key", default=None) | 
| 
 
4f3585e2f14b
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
 
shellac 
parents:  
diff
changeset
 | 
14 parser.add_option("-u", "--user-name", help="SSH Username", dest="uname", default="root") | 
| 
 
4f3585e2f14b
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
 
shellac 
parents:  
diff
changeset
 | 
15 parser.add_option("-n", "--name", help="Name of Image", dest="name") | 
| 
 
4f3585e2f14b
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
 
shellac 
parents:  
diff
changeset
 | 
16 (options, args) = parser.parse_args() | 
| 
 
4f3585e2f14b
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
 
shellac 
parents:  
diff
changeset
 | 
17 | 
| 
 
4f3585e2f14b
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
 
shellac 
parents:  
diff
changeset
 | 
18 for instance_id in args: | 
| 
 
4f3585e2f14b
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
 
shellac 
parents:  
diff
changeset
 | 
19 try: | 
| 
 
4f3585e2f14b
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
 
shellac 
parents:  
diff
changeset
 | 
20 s = Server.find(instance_id=instance_id).next() | 
| 
 
4f3585e2f14b
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
 
shellac 
parents:  
diff
changeset
 | 
21 print "Found old server object" | 
| 
 
4f3585e2f14b
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
 
shellac 
parents:  
diff
changeset
 | 
22 except StopIteration: | 
| 
 
4f3585e2f14b
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
 
shellac 
parents:  
diff
changeset
 | 
23 print "New Server Object Created" | 
| 
 
4f3585e2f14b
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
 
shellac 
parents:  
diff
changeset
 | 
24 s = Server.create_from_instance_id(instance_id, options.name) | 
| 
 
4f3585e2f14b
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
 
shellac 
parents:  
diff
changeset
 | 
25 assert(s.hostname is not None) | 
| 
 
4f3585e2f14b
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
 
shellac 
parents:  
diff
changeset
 | 
26 b = s.get_bundler(uname=options.uname) | 
| 
 
4f3585e2f14b
"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
 
shellac 
parents:  
diff
changeset
 | 
27 b.bundle(bucket=options.bucket,prefix=options.prefix,key_file=options.key_file,cert_file=options.cert_file,size=int(options.size),ssh_key=options.ssh_key) | 
