From: Peter Iannucci Date: Sat, 14 Feb 2009 23:13:55 +0000 (-0500) Subject: Modified invirt-availability and invirt-vmcontrol to stat /etc/invirt/nocreate. X-Git-Tag: 0.3.4~1 X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/invirt-remote.git/commitdiff_plain/91cf1fc24419d0492c890daaa70febb8ab89e1cc Modified invirt-availability and invirt-vmcontrol to stat /etc/invirt/nocreate. svn path=/trunk/packages/invirt-remote/; revision=2113 --- diff --git a/debian/changelog b/debian/changelog index c346af3..53994ea 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +invirt-remote (0.3.4) unstable; urgency=low + + * modified host/usr/sbin/invirt-availability and invirt-vmcontrol to stat + /etc/invirt/nocreate; if it exists, they advertise zero free memory and + refuse to create VMs + + -- Peter A. Iannucci Sat, 14 Feb 2009 18:10:54 -0500 + invirt-remote (0.3.3) unstable; urgency=low * added remctl web availability to calculate memory available to new VMs diff --git a/host/usr/sbin/invirt-availability b/host/usr/sbin/invirt-availability index 93ef381..0122a8d 100644 --- a/host/usr/sbin/invirt-availability +++ b/host/usr/sbin/invirt-availability @@ -19,7 +19,16 @@ def main(argv): The numbers in /proc/xen/balloon have nice units All math is done in kilobytes for consistency Output is in MB + + Bail if /etc/invirt/nocreate exists """ + try: + os.stat('/etc/invirt/nocreate') + print 0 + return 0 + except OSError: + pass + p = Popen(['/usr/sbin/xm', 'info'], stdout=PIPE) output = p.communicate()[0] if p.returncode != 0: diff --git a/host/usr/sbin/invirt-vmcontrol b/host/usr/sbin/invirt-vmcontrol index 70bff12..66f5ca6 100755 --- a/host/usr/sbin/invirt-vmcontrol +++ b/host/usr/sbin/invirt-vmcontrol @@ -22,6 +22,9 @@ case "$ACTION" in ;; install|create) shift; shift; + if [ -f "/etc/invirt/nocreate" ]; then + echo "Host $HOSTNAME is currently refusing VM creation." && exit 2 + fi xm list "$MACHINE" >/dev/null 2>/dev/null && echo "$MACHINE already exists" && exit 1 if [ "$ACTION" = "install" ]; then xm create invirt-database machine_name="$ORIGMACHINE" installer_options="$(printf '%q ' "$@")"