def main_setup(args): project = args.project # Project print('project validation') if not project_exists(project): print('The project_id passed does not exists') sys.exit(4) apis_dm_name = '-'.join(['apis', args.project]) if not deployment_exists(project, apis_dm_name): apis_template = os.path.join(helpers.BASE_DIR, 'dm', 'apis.py') cmd = [ 'gcloud', 'deployment-manager', 'deployments', 'create', apis_dm_name, '--template', apis_template, '--properties', ",".join(['concurrent_api_activation:' + str(False)]), '--project', project ] run_command(cmd) # CF Bucket cf_bucket_name = args.cf_bucket_name or 'bucket-cf-' + args.project print('cloud function bucket creation.') cf_bucket_status = bucket_status(cf_bucket_name) if 'NotFound' == cf_bucket_status: bucket_template = os.path.join(helpers.BASE_DIR, 'dm', 'bucket.py') cmd = [ 'gcloud', 'deployment-manager', 'deployments', 'create', '-'.join([ 'bucket', project, datetime.utcnow().strftime('%Y%m%d%H%M%S') ]), '--template', bucket_template, '--properties', ",".join([ 'region:' + scape_to_os(args.region), 'bucketname:' + cf_bucket_name, ]), '--project', project ] run_command(cmd) # Application (cloud functions and topics) print('application creation.') infra_dm_name = '-'.join(['infra', args.project]) if not deployment_exists(project, infra_dm_name): zip_and_store_cf('transformer', 'transformer.zip', 'gs://' + cf_bucket_name, args.organization_id, args.api_key) zip_and_store_cf('logger', 'logger.zip', 'gs://' + cf_bucket_name, args.organization_id, args.api_key) infra_template = os.path.join(helpers.BASE_DIR, 'dm', 'infra.py') cmd = [ 'gcloud', 'deployment-manager', 'deployments', 'create', infra_dm_name, '--template', infra_template, '--properties', ",".join([ 'region:' + scape_to_os(args.region), 'cfbucket:' + cf_bucket_name, ]), '--project', project ] run_command(cmd)
def validate_arguments(args): if not project_exists(args.project): print(('Project {} not found. Please check if id is correct or if you ' 'have been granted access to it.'.format(args.project))) sys.exit(2) cscc_api_client_file = os.path.join(helpers.BASE_DIR, 'function', 'transformer', 'accounts', 'cscc_api_client.json') if not has_file(cscc_api_client_file): print( 'CSCC api client file does not exist.\nPlease place a valid file ' 'at {}'.format(cscc_api_client_file)) sys.exit(4)
def validate_arguments(args): if not project_exists(args.creator_project_name): print('The creator project {} does not exist'.format(args.creator_project_name)) sys.exit(2) creator_sa_file = args.creator_sa_file if creator_sa_file and not os.path.isfile(creator_sa_file): print('The service account file path passed is not valid: "{}".'.format(creator_sa_file)) sys.exit(4) publisher_sa_file = args.publisher_sa_file if publisher_sa_file and not os.path.isfile(publisher_sa_file): print('The service account file path passed is not valid: "{}".'.format(publisher_sa_file)) sys.exit(4)
def create_project(project_id, organization_id, billing_account_id): if project_exists(project_id): print('Project {} already exists.'.format(project_id)) if not project_has_billing(project_id): print('Billing already enabled.') else: link_billing(billing_account_id, project_id) else: print('creating project {}.'.format(project_id)) cmd = [ 'gcloud', 'projects', 'create', project_id, '--organization', organization_id ] run_command(cmd) link_billing(billing_account_id, project_id)
def validate_arguments(args): if not has_file(args.key_file): print('Key File Does not Exist.\nPlease inform a file.') sys.exit(1) if not project_exists(args.connector_project): print(('Project {} not found. Please check if id is correct or if you ' 'have been granted access to it.'.format(args.connector_project))) sys.exit(2) connector_sa_file = args.connector_sa_file if connector_sa_file and not os.path.isfile(connector_sa_file): print('The service account file path passed is not valid: "{}".'.format( connector_sa_file)) sys.exit(4)
def validate_arguments(args): if not project_exists(args.notifier_project): print(('Project {} not found. Please check if id is correct or if you ' 'have been granted access to it.'.format(args.notifier_project))) sys.exit(2)
def validate_arguments(args): if not project_exists(args.project_id): print('project {} does not exist. Aborting script execution.'.format( args.project_id)) sys.exit(1)
def __validate_project(project): if not project_exists(project): click.echo( ('Project {} not found. Please check if id is correct or if ' 'you have been granted access to it.'.format(project))) sys.exit(2)