Ejemplo n.º 1
0
def _update_deployment_manager(project, name, path):
    """Update deployment manager settings."""
    config_dir = environment.get_config_directory()
    config_path = os.path.join(config_dir, path)
    if not os.path.exists(config_path):
        return

    gcloud = common.Gcloud(project)
    try:
        gcloud.run(
            "deployment-manager",
            "deployments",
            "update",
            name,
            "--config=" + config_path,
        )
    except common.GcloudError:
        # Create deployment if it does not exist.
        gcloud.run(
            "deployment-manager",
            "deployments",
            "create",
            name,
            "--config=" + config_path,
        )
Ejemplo n.º 2
0
def _update_alerts(project):
    """Update pubsub topics."""
    if not local_config.ProjectConfig().get('monitoring.enabled'):
        return

    alerts_path = os.path.join(environment.get_config_directory(),
                               'monitoring', 'alerts.yaml')
    with _preprocess_alerts(alerts_path) as processed_alerts_path:
        _update_deployment_manager(project, 'alerts', processed_alerts_path)
Ejemplo n.º 3
0
def _update_redis(project):
    """Update redis instance."""
    _update_deployment_manager(
        project, 'redis',
        os.path.join(environment.get_config_directory(), 'redis',
                     'instance.yaml'))

    region = appengine.region(project)
    return_code, _ = common.execute(
        'gcloud compute networks vpc-access connectors describe '
        'connector --region={region} '
        '--project={project}'.format(project=project, region=region),
        exit_on_error=False)

    if return_code:
        # Does not exist.
        common.execute('gcloud compute networks vpc-access connectors create '
                       'connector --network=default --region={region} '
                       '--range=10.8.0.0/28 '
                       '--project={project}'.format(project=project,
                                                    region=region))
Ejemplo n.º 4
0
def _update_bigquery(project):
    """Update bigquery datasets and tables."""
    _update_deployment_manager(
        project, 'bigquery',
        os.path.join(environment.get_config_directory(), 'bigquery',
                     'datasets.yaml'))
Ejemplo n.º 5
0
def _update_pubsub_queues(project):
    """Update pubsub queues."""
    _update_deployment_manager(
        project, 'pubsub',
        os.path.join(environment.get_config_directory(), 'pubsub',
                     'queues.yaml'))