Modified invirt-availability and invirt-vmcontrol to stat /etc/invirt/nocreate.
authorPeter Iannucci <iannucci@mit.edu>
Sat, 14 Feb 2009 23:13:55 +0000 (18:13 -0500)
committerPeter Iannucci <iannucci@mit.edu>
Sat, 14 Feb 2009 23:13:55 +0000 (18:13 -0500)
svn path=/trunk/packages/invirt-remote/; revision=2113

debian/changelog
host/usr/sbin/invirt-availability
host/usr/sbin/invirt-vmcontrol

index c346af3..53994ea 100644 (file)
@@ -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 <iannucci@mit.edu>  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
index 93ef381..0122a8d 100644 (file)
@@ -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:
index 70bff12..66f5ca6 100755 (executable)
@@ -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 ' "$@")"