- machines = getMachinesByOwner(user, machine)
- disk_usage = sum([sum([y.size for y in x.disks])
- for x in machines if x != machine])
+ """Return the maximum disk that a machine can reach.
+
+ If machine is None, the maximum disk for a new machine. Otherwise,
+ return the maximum that a given machine can be changed to.
+ """
+ if machine is not None:
+ machine_id = machine.machine_id
+ else:
+ machine_id = None
+ disk_usage = Disk.query().filter_by(Disk.c.machine_id != machine_id,
+ owner=user).sum(Disk.c.size) or 0