예제 #1
0
def main(args):
    logging.basicConfig(level=getattr(logging, args.log))
    utils.GCLOUD_OPTIONS = utils.GcloudOptions(dry_run=args.dry_run,
                                               gcloud_bin=args.gcloud_bin)

    # Read and parse the project configuration YAML file.
    all_projects = utils.resolve_env_vars(
        utils.read_yaml_file(args.project_yaml))
    if not all_projects:
        logging.error('Error loading project YAML.')
        return

    logging.info('Validating project YAML against schema.')
    try:
        utils.validate_config_yaml(all_projects)
    except jsonschema.exceptions.ValidationError as e:
        logging.error('Error in YAML config: %s', e)
        return

    overall = all_projects['overall']
    audit_logs_project = all_projects.get('audit_logs_project')

    projects = []
    # Always deploy the remote audit logs project first (if present).
    if audit_logs_project:
        projects.append(
            ProjectConfig(overall=overall,
                          project=audit_logs_project,
                          audit_logs_project=None))

    for project_config in all_projects.get('projects', []):
        projects.append(
            ProjectConfig(overall=overall,
                          project=project_config,
                          audit_logs_project=audit_logs_project))

    # If resuming setup from a particular project, skip to that project.
    if args.resume_from_project:
        while (projects and
               projects[0].project['project_id'] != args.resume_from_project):
            skipped = projects.pop(0)
            logging.info('Skipping project %s', skipped.project['project_id'])
        if not projects:
            logging.error('Project not found: %s', args.resume_from_project)

    if projects:
        starting_step = max(1, args.resume_from_step)
        for config in projects:
            logging.info('Setting up project %s', config.project['project_id'])
            if not setup_new_project(config, starting_step):
                # Don't attempt to deploy additional projects if one project failed.
                return
            starting_step = 1
    else:
        logging.error('No projects to deploy.')
예제 #2
0
def main(args):
    logging.basicConfig(level=getattr(logging, args.log))
    utils.GCLOUD_OPTIONS = utils.GcloudOptions(dry_run=args.dry_run,
                                               gcloud_bin=args.gcloud_bin)

    # Read and parse the project configuration YAML file.
    config = utils.ReadYamlFile(args.project_yaml)
    starting_step = max(1, args.resume_from_step)

    if config:
        SetupNewProject(config, starting_step)
예제 #3
0
def main(args):
    logging.basicConfig(level=getattr(logging, args.log))
    utils.GCLOUD_OPTIONS = utils.GcloudOptions(dry_run=args.dry_run,
                                               gcloud_bin=args.gcloud_bin)

    # Read and parse the project configuration YAML file.
    all_projects = utils.ReadYamlFile(args.project_yaml)

    overall = all_projects['overall']
    audit_logs_project = all_projects.get('audit_logs_project')

    projects = []
    # Always deploy the remote audit logs project first (if present).
    if audit_logs_project:
        projects.append(
            ProjectConfig(overall=overall,
                          project=audit_logs_project,
                          audit_logs_project=None))

    for project_config in all_projects.get('projects', []):
        projects.append(
            ProjectConfig(overall=overall,
                          project=project_config,
                          audit_logs_project=audit_logs_project))

    # If resuming setup from a particular project, skip to that project.
    if args.resume_from_project:
        while (projects and
               projects[0].project['project_id'] != args.resume_from_project):
            skipped = projects.pop(0)
            logging.info('Skipping project %s', skipped.project['project_id'])
        if not projects:
            logging.error('Project not found: %s', args.resume_from_project)

    if projects:
        starting_step = max(1, args.resume_from_step)
        for config in projects:
            logging.info('Setting up project %s', config.project['project_id'])
            SetupNewProject(config, starting_step)
            starting_step = 1
    else:
        logging.error('No projects to deploy.')