def create_quota(
    role_name: str,
    quota: typing.Dict
):
    """
    Create quota for the specified role.
    """
    existing_quotas = sdk_cmd.get_json_output("spark quota list --json", print_output=False)

    # remove existing quotas matching name
    if role_name in [x['role'] for x in existing_quotas.get('infos', [])]:
        rc, _, _ = sdk_cmd.run_raw_cli("spark quota remove {}".format(role_name))
        assert rc == 0, "Error removing quota"


    cmd_list = ["spark", "quota", "create"]
    for r in ["cpus", "mem", "gpus", ]:
        if r in quota:
            cmd_list.extend(["-{}".format(r[0]), quota[r],])

    cmd_list.append(role_name)

    # create quota
    log.info("Creating quota for %s: %s", role_name, quota)
    cmd = " ".join(str(c) for c in cmd_list)
    rc, _, _ = sdk_cmd.run_raw_cli(cmd)
    assert rc == 0, "Error creating quota"
 def app_running():
     cmd = 'marathon app show {}'.format(app_name)
     log.info('Running %s', cmd)
     app = sdk_cmd.get_json_output(cmd)
     return is_app_running(app)
Exemple #3
0
 def _wait_for_app_running(app_name: str) -> bool:
     cmd = 'marathon app show {}'.format(app_name)
     log.info('Running %s', cmd)
     app = sdk_cmd.get_json_output(cmd)
     return is_app_running(app)