Example #1
0
def test_create_quota():
    try:
        sdk_quota.create_quota("jenkins", cpus=4.0, mem=4000)
        quotas = sdk_quota.list_quotas()

        present = False
        for quota in quotas['infos']:
            if quota['role'] == "jenkins":
                present = True
                break

        assert present, "There was no quota present for the jenkins role"

    finally:
        sdk_quota.remove_quota("jenkins")

        quotas = sdk_quota.list_quotas()
        if 'infos' in quotas:
            for quota in quotas['infos']:
                assert quota['role'] != "jenkins"
Example #2
0
def _setup_quota(role, cpus):
    current_quotas = sdk_quota.list_quotas()
    if "infos" not in current_quotas:
        _set_quota(role, cpus)
        return

    match = False
    for quota in current_quotas["infos"]:
        if quota["role"] == role:
            match = True
            break

    if match:
        sdk_quota.remove_quota(role)
    _set_quota(role, cpus)