Exemple #1
0
def start_httpd(config, id):
    login_user = config.get("login_user")
    key_path = os.path.join(os.path.expanduser(static.KEY_DIR), config.get("key_name") + static.KEY_EXTENSION)
    instance = get_instance(config, id)
    print instance
    cmd = boto.manage.cmdshell.sshclient_from_instance(instance, key_path, user_name=login_user)
    aws_utils.run_pty(cmd, commands.START_HTTPD)
Exemple #2
0
def deploy_app_at_instance(config, instance):
    """Deploy an app to EC2 instance. Thread-safe.
       Before invoking the method, job and config archives are to be created.
    """
    logger = logging.getLogger(__name__)
    job_archive_file = static.JOB_BASE_NAME + "." + static.ARCHIVE_FORMAT
    config_archive_file = static.RC_BASE_NAME + "." + static.ARCHIVE_FORMAT
    key_path = os.path.join(os.path.expanduser(static.KEY_DIR), config.get("key_name") + static.KEY_EXTENSION)
    login_user = config.get("login_user")
    local_job_path = config.get_home_dir() + "aws/" + job_archive_file
    remote_job_path = "/home/%s/.deploy/job/%s" % (login_user, job_archive_file)
    local_config_path = config.get_home_dir() + "aws/" + config_archive_file
    remote_config_path = "/home/%s/.deploy/config/%s" % (login_user, config_archive_file)

    cmd = boto.manage.cmdshell.sshclient_from_instance(instance, key_path, user_name=login_user)
    aws_utils.run_command(cmd, commands.PRE_DEPLOYMENT)
    logger.info("(%s) Pre-deployment maintenance tasks completed" % instance.id)

    cmd.put_file(local_job_path, remote_job_path)
    cmd.put_file(local_config_path, remote_config_path)
    logger.info("Updating the server and deploying the application")
    aws_utils.run_pty(cmd, commands.DEPLOYMENT % (config_archive_file, login_user, login_user))
    logger.info("(%s) Deployment maintenance task completed." % instance.id)
    logger.info("App deployed at instance %s. Public DNS: %s" % (instance.id, instance.public_dns_name))