예제 #1
0
def docean_start():
    """
    Start the DigitalOcean server. Restored from backup if exists
    """
    if not os.path.exists('private/gmailarchive_rsa.pub'):
        digio.create_ssh_key()

    # Make sure SSH KEY is there
    ssh_key_id = digio.ssh_key_id()
    if not ssh_key_id:
        print _yellow("\nPlease go to the DigitalOcean " + \
                "website and make sure you have"),
        print _yellow("an SSH key with the following:\n")
        print _green("name: \n") + digio.ssh_key_name
        print _green("\nvalue: \n") + digio.public_key()
        fabric.utils.abort("SSH keys")

    droplet = digio.droplet()

    # Need to boot a droplet
    if droplet is None:
        # check for backup
            # restore
        print _green("Creating droplet...")
        droplet = digio.create_droplet(ssh_key=ssh_key_id)
        print _green("Created server with id: %s" % (droplet['id']))

    # Wait for droplet to boot or restore
    while droplet['status'] == 'new':
        print _yellow("Droplet status is '%s' waiting for boot..." % \
                (droplet['status']))
        time.sleep(10)
        droplet = digio.droplet(droplet['id'])
예제 #2
0
def docean():
    """
    Set the environment to work with DigitalOcean
    """
    droplet = digio.droplet()
    if not droplet:
        fabric.utils.abort("Droplet is not running. Start it with docean_start task")

    env.key_filename = 'private/gmailarchive_rsa'
    env.hosts = [droplet['ip_address']]
    env.user = '******'
    env.disable_known_hosts = True