Пример #1
0
def get_default_interactive_config(service, cluster, soa_dir, load_deployments=False):
    default_job_config = {
        'cpus': 4,
        'mem': 10240,
        'disk': 1024
    }

    try:
        job_config = load_adhoc_job_config(service=service, instance='interactive', cluster=cluster, soa_dir=soa_dir)
    except NoConfigurationForServiceError:
        job_config = AdhocJobConfig(
            service=service,
            instance='interactive',
            cluster=cluster,
            config_dict={},
            branch_dict={},
        )
    except NoDeploymentsAvailable:
        job_config = load_adhoc_job_config(
            service=service, instance='interactive', cluster=cluster, soa_dir=soa_dir, load_deployments=False)

    if not job_config.branch_dict and load_deployments:
        deployments_json = load_v2_deployments_json(service, soa_dir=soa_dir)
        deploy_group = prompt_pick_one(deployments_json['deployments'].keys(), choosing='deploy group')
        job_config.config_dict['deploy_group'] = deploy_group
        job_config.branch_dict['docker_image'] = deployments_json.get_docker_image_for_deploy_group(deploy_group)

    for key, value in default_job_config.items():
        job_config.config_dict.setdefault(key, value)

    return job_config
Пример #2
0
def get_default_interactive_config(
    service: str,
    cluster: str,
    soa_dir: str,
    load_deployments: bool = False,
) -> AdhocJobConfig:
    default_job_config = {
        'cpus': 4,
        'mem': 10240,
        'disk': 1024,
    }

    try:
        job_config = load_adhoc_job_config(service=service,
                                           instance='interactive',
                                           cluster=cluster,
                                           soa_dir=soa_dir)
    except NoConfigurationForServiceError:
        job_config = AdhocJobConfig(
            service=service,
            instance='interactive',
            cluster=cluster,
            config_dict={},
            branch_dict=None,
            soa_dir=soa_dir,
        )
    except NoDeploymentsAvailable:
        job_config = load_adhoc_job_config(
            service=service,
            instance='interactive',
            cluster=cluster,
            soa_dir=soa_dir,
            load_deployments=False,
        )

    if not job_config.branch_dict and load_deployments:
        deployments_json = load_v2_deployments_json(service, soa_dir=soa_dir)
        deploy_group = prompt_pick_one(
            deployments_json.get_deploy_groups(),
            choosing='deploy group',
        )
        job_config.config_dict['deploy_group'] = deploy_group
        job_config.branch_dict = {
            'docker_image':
            deployments_json.get_docker_image_for_deploy_group(deploy_group),
            'git_sha':
            deployments_json.get_git_sha_for_deploy_group(deploy_group),
            'force_bounce':
            None,
            'desired_state':
            'start',
        }

    for key, value in default_job_config.items():
        job_config.config_dict.setdefault(key, value)

    return job_config
def get_default_interactive_config(
        service: str,
        cluster: str,
        soa_dir: str,
        load_deployments: bool = False) -> AdhocJobConfig:
    default_job_config = {"cpus": 4, "mem": 10240, "disk": 1024}

    try:
        job_config = load_adhoc_job_config(service=service,
                                           instance="interactive",
                                           cluster=cluster,
                                           soa_dir=soa_dir)
    except NoConfigurationForServiceError:
        job_config = AdhocJobConfig(
            service=service,
            instance="interactive",
            cluster=cluster,
            config_dict={},
            branch_dict=None,
            soa_dir=soa_dir,
        )
    except NoDeploymentsAvailable:
        job_config = load_adhoc_job_config(
            service=service,
            instance="interactive",
            cluster=cluster,
            soa_dir=soa_dir,
            load_deployments=False,
        )

    if not job_config.branch_dict and load_deployments:
        deployments_json = load_v2_deployments_json(service, soa_dir=soa_dir)
        deploy_group = prompt_pick_one(deployments_json.get_deploy_groups(),
                                       choosing="deploy group")
        job_config.config_dict["deploy_group"] = deploy_group
        job_config.branch_dict = {
            "docker_image":
            deployments_json.get_docker_image_for_deploy_group(deploy_group),
            "git_sha":
            deployments_json.get_git_sha_for_deploy_group(deploy_group),
            "force_bounce":
            None,
            "desired_state":
            "start",
        }

    for key, value in default_job_config.items():
        job_config.config_dict.setdefault(key, value)

    return job_config
Пример #4
0
def get_default_interactive_config(service, cluster, soa_dir, load_deployments=False):
    default_job_config = {
        'cpus': 4,
        'mem': 10240,
        'disk': 1024
    }

    try:
        job_config = load_adhoc_job_config(service=service, instance='interactive', cluster=cluster, soa_dir=soa_dir)
    except NoConfigurationForServiceError:
        job_config = AdhocJobConfig(
            service=service,
            instance='interactive',
            cluster=cluster,
            config_dict={},
            branch_dict={},
        )
    except NoDeploymentsAvailable:
        job_config = load_adhoc_job_config(
            service=service, instance='interactive', cluster=cluster, soa_dir=soa_dir, load_deployments=False)

    if not job_config.branch_dict and load_deployments:
        deployments_json = load_v2_deployments_json(service, soa_dir=soa_dir)
        deploy_group = prompt_pick_one(
            (
                deployment.encode('utf-8')
                for deployment in deployments_json['deployments'].keys()
            ),
            choosing='deploy group',
        )
        job_config.config_dict['deploy_group'] = deploy_group
        job_config.branch_dict['docker_image'] = deployments_json.get_docker_image_for_deploy_group(deploy_group)

    for key, value in default_job_config.items():
        job_config.config_dict.setdefault(key, value)

    return job_config
Пример #5
0
def get_default_interactive_config(service, cluster, soa_dir, load_deployments=False):
    default_job_config = {"cpus": 4, "mem": 10240, "disk": 1024}

    try:
        job_config = load_adhoc_job_config(service=service, instance="interactive", cluster=cluster, soa_dir=soa_dir)
    except NoConfigurationForServiceError:
        job_config = AdhocJobConfig(
            service=service, instance="interactive", cluster=cluster, config_dict={}, branch_dict={}
        )
    except NoDeploymentsAvailable:
        job_config = load_adhoc_job_config(
            service=service, instance="interactive", cluster=cluster, soa_dir=soa_dir, load_deployments=False
        )

    if not job_config.branch_dict and load_deployments:
        deployments_json = load_v2_deployments_json(service, soa_dir=soa_dir)
        deploy_group = prompt_pick_one(deployments_json["deployments"].keys(), choosing="deploy group")
        job_config.config_dict["deploy_group"] = deploy_group
        job_config.branch_dict["docker_image"] = deployments_json.get_docker_image_for_deploy_group(deploy_group)

    for key, value in default_job_config.items():
        job_config.config_dict.setdefault(key, value)

    return job_config