X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/invirt-remote.git/blobdiff_plain/e1b9196f42941a70ad972951214eec684290f9f8..9b2c6cb76b2935133c0c1ed1626d077614b460ec:/server/usr/sbin/invirt-remote-create?ds=sidebyside diff --git a/server/usr/sbin/invirt-remote-create b/server/usr/sbin/invirt-remote-create index 3ec70a5..3bffba2 100755 --- a/server/usr/sbin/invirt-remote-create +++ b/server/usr/sbin/invirt-remote-create @@ -23,7 +23,7 @@ def maxMemory(owner, xmlist): active_machines = [m for m in machines if m.name in xmlist] mem_usage = sum([x.memory for x in active_machines]) - return min(quota_single, quota_total-mem_usage) + return min(quota_single, quota_total - mem_usage) def choose_host(): # Query each of the hosts. @@ -37,7 +37,9 @@ def main(argv): operation = argv[1] machine_name = argv[2] args = argv[3:] - + + invirt.database.connect() + if operation == 'install': options = dict(arg.split('=', 1) for arg in args) valid_keys = set(('mirror', 'dist', 'arch', 'imagesize', 'noinstall')) @@ -62,7 +64,6 @@ def main(argv): return 1 if operation == "create": - invirt.database.connect() machine = invirt.database.Machine.query().filter_by(name=machine_name).first() owner = machine.owner @@ -70,7 +71,7 @@ def main(argv): max_memory = maxMemory(owner, vms.keys()) if vm_memory > max_memory: - print >>sys.stderr, "owner %s requested %d MB of memory for vm %s; %d MB allowed" % (owner, vm_memory, machine_name, max_memory) + print >>sys.stderr, "owner %s requested %d MiB of memory for vm %s; %d MiB allowed" % (owner, vm_memory, machine_name, max_memory) return 1 host = choose_host()