def make_policies(limits): policies = {} for (name, member_capacity, project_capacity) in limits: try: member_capacity = units.parse(member_capacity) project_capacity = units.parse(project_capacity) except units.ParseError: m = "Please specify capacity as a decimal integer" raise CommandError(m) policies[name] = {"member_capacity": member_capacity, "project_capacity": project_capacity} return policies
def parse_with_unit(value): try: return units.parse(value) except units.ParseError: raise CommandError("Failed to parse value, should be an integer, " "possibly followed by a unit, or 'inf'.")
def _parse_max_members(s): try: return units.parse(s) except units.ParseError: raise faults.BadRequest("Invalid max_members")