You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
1.6 KiB

4 years ago
  1. #!/home/alpcentaur/ProjektA/PrototypeWebApp/venv/bin/python3.5
  2. from boto.manage.server import Server
  3. if __name__ == "__main__":
  4. from optparse import OptionParser
  5. parser = OptionParser(version="%prog 1.0", usage="Usage: %prog [options] instance-id [instance-id-2]")
  6. # Commands
  7. parser.add_option("-b", "--bucket", help="Destination Bucket", dest="bucket", default=None)
  8. parser.add_option("-p", "--prefix", help="AMI Prefix", dest="prefix", default=None)
  9. parser.add_option("-k", "--key", help="Private Key File", dest="key_file", default=None)
  10. parser.add_option("-c", "--cert", help="Public Certificate File", dest="cert_file", default=None)
  11. parser.add_option("-s", "--size", help="AMI Size", dest="size", default=None)
  12. parser.add_option("-i", "--ssh-key", help="SSH Keyfile", dest="ssh_key", default=None)
  13. parser.add_option("-u", "--user-name", help="SSH Username", dest="uname", default="root")
  14. parser.add_option("-n", "--name", help="Name of Image", dest="name")
  15. (options, args) = parser.parse_args()
  16. for instance_id in args:
  17. try:
  18. s = Server.find(instance_id=instance_id).next()
  19. print "Found old server object"
  20. except StopIteration:
  21. print "New Server Object Created"
  22. s = Server.create_from_instance_id(instance_id, options.name)
  23. assert(s.hostname is not None)
  24. b = s.get_bundler(uname=options.uname)
  25. 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)