def simulation_wall(simulation):
    """" context manager to print simulate mode message """
    simulation_mode_disclaimer(simulation)
    try:
        with log_exception():
            yield
    finally:
        simulation_mode_disclaimer(simulation)
def service_account_wall():
    """" context manager to print simulate mode message """
    use_service_account_disclaimer()
    try:
        with log_exception():
            yield
    finally:
        use_service_account_disclaimer()
Exemplo n.º 3
0
def create_external_address(dns_project_id, compute_region, name):
    with log_exception():
        LOGGER.info("Creating external region %s, project %s", compute_region,
                    dns_project_id)
        cmd = [
            'gcloud', 'compute', 'addresses', 'create', name, '--region',
            compute_region, '--project', dns_project_id
        ]
        run_command(cmd)
Exemplo n.º 4
0
def download_certs_file(dns_project_id, compute_zone, main_domain):
    with log_exception():
        path = os.getcwd()
        cmd = [
            "gcloud", "compute", "scp", "--project", dns_project_id, "--zone",
            compute_zone, "ssl-certificate-gen:~/certs.zip",
            "certs-{}.zip".format(main_domain)
        ]
        run_command(cmd)
        return "Your file is in: {}/certs-{}.zip".format(path, main_domain)
Exemplo n.º 5
0
def gcs_acl_role(user_mail, role, path):
    """Temporary bucket ACL context"""
    LOGGER.debug('Adding ACL role to %s...', user_mail)
    cmd = [
        'gsutil', 'acl', 'ch', '-u', user_mail + role, path
    ]
    run_command(cmd)

    with log_exception():
        yield

    LOGGER.debug('Removing acl given for %s...', user_mail)
    cmd = [
        'gsutil', 'acl', 'ch', '-d', user_mail, path
    ]
    run_command(cmd)
Exemplo n.º 6
0
def execute_docker_file_remotely(filename, dns_project_id, compute_zone):
    with log_exception():
        LOGGER.info("Sending docker_creation_file to docker")
        cmd = [
            "gcloud", "compute", "scp", "--project", dns_project_id, "--zone",
            compute_zone, "docker_creation_file.sh",
            "ssl-certificate-gen:{}".format(filename)
        ]
        run_command(cmd)
        LOGGER.info("Executing file")
        cmd = [
            "gcloud", "compute", "ssh", '"ssl-certificate-gen"', "--project",
            dns_project_id, "--zone", compute_zone, "--command",
            "'. docker_creation_file.sh'"
        ]
        run_command(cmd)