本文整理汇总了Python中apache.aurora.client.api.AuroraClientAPI.get_quota方法的典型用法代码示例。如果您正苦于以下问题:Python AuroraClientAPI.get_quota方法的具体用法?Python AuroraClientAPI.get_quota怎么用?Python AuroraClientAPI.get_quota使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类apache.aurora.client.api.AuroraClientAPI
的用法示例。
在下文中一共展示了AuroraClientAPI.get_quota方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: increase_quota
# 需要导入模块: from apache.aurora.client.api import AuroraClientAPI [as 别名]
# 或者: from apache.aurora.client.api.AuroraClientAPI import get_quota [as 别名]
def increase_quota(cluster, role, cpu_str, ram_str, disk_str):
"""usage: increase_quota cluster role cpu ram[unit] disk[unit]
Increases the amount of production quota allocated to a user.
"""
cpu = float(cpu_str)
ram = parse_data(ram_str)
disk = parse_data(disk_str)
options = app.get_options()
client = AuroraClientAPI(CLUSTERS[cluster], options.verbosity == "verbose")
resp = client.get_quota(role)
quota = resp.result.getQuotaResult.quota
log.info(
"Current quota for %s:\n\tCPU\t%s\n\tRAM\t%s MB\n\tDisk\t%s MB"
% (role, quota.numCpus, quota.ramMb, quota.diskMb)
)
new_cpu = float(cpu + quota.numCpus)
new_ram = int((ram + Amount(quota.ramMb, Data.MB)).as_(Data.MB))
new_disk = int((disk + Amount(quota.diskMb, Data.MB)).as_(Data.MB))
log.info(
"Attempting to update quota for %s to\n\tCPU\t%s\n\tRAM\t%s MB\n\tDisk\t%s MB"
% (role, new_cpu, new_ram, new_disk)
)
resp = client.set_quota(role, new_cpu, new_ram, new_disk)
check_and_log_response(resp)