From: Peter Iannucci Date: Fri, 13 Feb 2009 04:26:48 +0000 (-0500) Subject: Clean-up suggestions from price. Whitespace fixes. X-Git-Tag: 0.3.3^0 X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/invirt-remote.git/commitdiff_plain/7339891c2377d09611ba01b2f2496ae3aa151329 Clean-up suggestions from price. Whitespace fixes. svn path=/trunk/packages/invirt-remote/; revision=2107 --- diff --git a/debian/changelog b/debian/changelog index cbd414b..c346af3 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,9 @@ invirt-remote (0.3.3) unstable; urgency=low * added remctl web availability to calculate memory available to new VMs + * removed remctl web info - -- Peter A. Iannucci Thu, 12 Feb 2009 23:10:31 -0500 + -- Peter A. Iannucci Thu, 12 Feb 2009 23:26:24 -0500 invirt-remote (0.3.2) unstable; urgency=low diff --git a/host/usr/sbin/invirt-availability b/host/usr/sbin/invirt-availability index 2afd5ea..93ef381 100644 --- a/host/usr/sbin/invirt-availability +++ b/host/usr/sbin/invirt-availability @@ -13,19 +13,23 @@ def parseUnits(s): return int(num) * {'kb':1, 'mb':1024}[unit.lower()] def main(argv): + """ + Calculate the amount of memory available for new VMs + The numbers returned by xm info and xm info -c are in MB + The numbers in /proc/xen/balloon have nice units + All math is done in kilobytes for consistency + Output is in MB + """ p = Popen(['/usr/sbin/xm', 'info'], stdout=PIPE) output = p.communicate()[0] if p.returncode != 0: raise RuntimeError("Command '%s' returned non-zero exit status %d" - % ('invirt-availability', p.returncode)) + % ('/usr/sbin/xm info', p.returncode)) xminfo = yaml.load(output, yaml.CSafeLoader) - # In kilobytes free_memory = int(xminfo['free_memory']) * 1024 - f = open('/proc/xen/balloon', 'r') - ballooninfo = yaml.load(f.read()) - f.close() + ballooninfo = yaml.load(open('/proc/xen/balloon', 'r').read()) currentallocation = parseUnits(ballooninfo['Current allocation']) minimumtarget = parseUnits(ballooninfo['Minimum target']) @@ -33,7 +37,7 @@ def main(argv): output = p.communicate()[0] if p.returncode != 0: raise RuntimeError("Command '%s' returned non-zero exit status %d" - % ('invirt-availability', p.returncode)) + % ('/usr/sbin/xm info -c', p.returncode)) xminfoc = yaml.load(output, yaml.CSafeLoader) # In kilobytes diff --git a/host/usr/sbin/invirt-remote b/host/usr/sbin/invirt-remote index 948d0f0..931ec4e 100755 --- a/host/usr/sbin/invirt-remote +++ b/host/usr/sbin/invirt-remote @@ -11,17 +11,14 @@ case "$TYPE" in control) # $SERVICE is hostname COMMAND=/usr/sbin/invirt-vmcontrol - ;; + ;; web) case "$SERVICE" in lvcreate|lvremove|lvrename|lvresize) COMMAND=/usr/sbin/invirt-lvm - ;; + ;; listvms) COMMAND=/usr/sbin/invirt-listvms - ;; - info) - COMMAND=/usr/sbin/xm ;; availability) COMMAND=/usr/sbin/invirt-availability @@ -34,7 +31,7 @@ case "$TYPE" in exit 34 ;; esac - ;; + ;; *) echo "ERROR: invalid command" exit 34