Merge invirt-console-server into invirt-console (LP: #305681) 0.2.0
authorEvan Broder <broder@mit.edu>
Sun, 7 Dec 2008 15:21:31 +0000 (10:21 -0500)
committerEvan Broder <broder@mit.edu>
Sun, 7 Dec 2008 15:21:31 +0000 (10:21 -0500)
svn path=/trunk/packages/invirt-console/; revision=1815

13 files changed:
debian/changelog
debian/control
debian/invirt-console-host.cron.d [new file with mode: 0644]
debian/invirt-console-host.init [new file with mode: 0755]
debian/invirt-console-host.install [new file with mode: 0644]
debian/invirt-console-host.postinst [new file with mode: 0755]
debian/invirt-console-host.prerm [new file with mode: 0755]
debian/rules
host/etc/conserver/conserver.cf.invirt [new file with mode: 0644]
host/etc/conserver/invirt-consoles.cf [new file with mode: 0644]
host/etc/conserver/invirt-genconfig.cf.mako [new file with mode: 0644]
host/etc/conserver/server.conf.invirt [new file with mode: 0644]
host/usr/sbin/invirt-update-conserver [new file with mode: 0755]

index 262bc4b..0d439ce 100644 (file)
@@ -2,8 +2,9 @@ invirt-console (0.2.0) unstable; urgency=low
 
   * Rename source package in preparation for merging invirt-console-server
     with invirt-console-host
+  * Merge invirt-console-host into invirt-console (LP: #305681)
 
- -- Evan Broder <broder@mit.edu>  Sun, 07 Dec 2008 10:10:36 -0500
+ -- Evan Broder <broder@mit.edu>  Sun, 07 Dec 2008 10:17:06 -0500
 
 invirt-console-server (0.1.3) unstable; urgency=low
 
index b4767da..4969f5c 100644 (file)
@@ -15,3 +15,11 @@ Depends: invirt-base, ${shlibs:Depends}, ${misc:Depends},
  invirt-database, remctl-server, debathena-ssh-server-config
 Description: Invirt serial-console proxy server
  This is the software for the serial-console proxy server.
+
+Package: invirt-console-host
+Architecture: all
+Provides: ${diverted-files}
+Conflicts: ${diverted-files}
+Depends: ${shlibs:Depends}, ${misc:Depends}, conserver-server, remctl-client, invirt-base, cron
+Description: SIPB Xen serial console server server
+  This configures the VMM for the server-side of the console server
diff --git a/debian/invirt-console-host.cron.d b/debian/invirt-console-host.cron.d
new file mode 100644 (file)
index 0000000..2135f98
--- /dev/null
@@ -0,0 +1,8 @@
+#
+# cron-jobs for invirt-console-host
+# Refresh the list of active VM consoles
+#
+
+MAILTO=root
+
+*/5 * * * * root python /usr/sbin/invirt-update-conserver
diff --git a/debian/invirt-console-host.init b/debian/invirt-console-host.init
new file mode 100755 (executable)
index 0000000..5d19df7
--- /dev/null
@@ -0,0 +1,19 @@
+#! /bin/bash
+### BEGIN INIT INFO
+# Provides:          invirt-console-host
+# Required-Start:    $local_fs $remote_fs
+# Required-Stop:     $local_fs $remote_fs
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: conserver config from invirt-config for Invirt host
+# Description:       
+### END INIT INFO
+
+PACKAGE=invirt-console-host
+PARENTPACKAGE=conserver-server
+GEN_FILES=/etc/conserver/invirt-genconfig.cf
+
+dpkg -s "$PACKAGE" >/dev/null 2>/dev/null || exit 0
+
+. /lib/init/config-init.sh
+config_init $1
diff --git a/debian/invirt-console-host.install b/debian/invirt-console-host.install
new file mode 100644 (file)
index 0000000..260c50b
--- /dev/null
@@ -0,0 +1 @@
+host/* .
diff --git a/debian/invirt-console-host.postinst b/debian/invirt-console-host.postinst
new file mode 100755 (executable)
index 0000000..9f4b5a8
--- /dev/null
@@ -0,0 +1,47 @@
+#!/bin/sh
+# postinst script for invirt-console-host
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <postinst> `configure' <most-recently-configured-version>
+#        * <old-postinst> `abort-upgrade' <new version>
+#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
+#          <new-version>
+#        * <postinst> `abort-remove'
+#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
+#          <failed-install-package> <version> `removing'
+#          <conflicting-package> <version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+
+case "$1" in
+    configure)
+        # Clean up the old sudoers line before we add it back
+        perl -i.bak -ne 's%^### (BEGIN|END) invirt-console-host\s*$%%m && ($skip = ($1 eq "BEGIN")); print unless $skip;' /etc/sudoers
+        
+        cat >>/etc/sudoers <<EOF
+### BEGIN invirt-console-host
+conservr ALL=(ALL) NOPASSWD: /usr/sbin/xm console d_*
+### END invirt-console-host
+EOF
+    ;;
+
+    abort-upgrade|abort-remove|abort-deconfigure)
+    ;;
+
+    *)
+        echo "postinst called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
diff --git a/debian/invirt-console-host.prerm b/debian/invirt-console-host.prerm
new file mode 100755 (executable)
index 0000000..9d0b178
--- /dev/null
@@ -0,0 +1,39 @@
+#!/bin/sh
+# prerm script for invirt-console-host
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <prerm> `remove'
+#        * <old-prerm> `upgrade' <new-version>
+#        * <new-prerm> `failed-upgrade' <old-version>
+#        * <conflictor's-prerm> `remove' `in-favour' <package> <new-version>
+#        * <deconfigured's-prerm> `deconfigure' `in-favour'
+#          <package-being-installed> <version> `removing'
+#          <conflicting-package> <version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+
+case "$1" in
+    remove|upgrade|deconfigure)
+        perl -i.bak -ne 's%^### (BEGIN|END) invirt-console-host\s*$%%m && ($skip = ($1 eq "BEGIN")); print unless $skip;' /etc/sudoers
+    ;;
+
+    failed-upgrade)
+    ;;
+
+    *)
+        echo "prerm called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
index 47cbab2..b1b8d2b 100755 (executable)
@@ -16,6 +16,9 @@ endif
 DEB_DIVERT_FILES_invirt-console-server += \
        /etc/conserver/conserver.cf.invirt \
        /etc/motd.invirt
+DEB_DIVERT_FILES_invirt-console-host += \
+       /etc/conserver/conserver.cf.invirt \
+       /etc/conserver/server.conf.invirt
 
 include /usr/share/cdbs/1/rules/debhelper.mk
 include /usr/share/cdbs/1/rules/config-package.mk
diff --git a/host/etc/conserver/conserver.cf.invirt b/host/etc/conserver/conserver.cf.invirt
new file mode 100644 (file)
index 0000000..1b92380
--- /dev/null
@@ -0,0 +1,25 @@
+config * {
+       sslrequired yes;
+}
+
+# If no consoles are defined, as is the case when the host first boots
+# up, conserver will quit. This keeps it running.
+#
+# Should someone create a VM called dummy-console, their VM will
+# shadow over this one.
+console dummy-console {
+        master localhost;
+        type noop;
+}
+
+default * {
+       logfile /var/log/conserver/&.log;
+       timestamp "1lab";
+       rw *;
+       type exec;
+       exec sudo xm console d_f;
+       execsubst f=cs;
+}
+
+#include /etc/conserver/invirt-genconfig.cf
+#include /etc/conserver/invirt-consoles.cf
diff --git a/host/etc/conserver/invirt-consoles.cf b/host/etc/conserver/invirt-consoles.cf
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/host/etc/conserver/invirt-genconfig.cf.mako b/host/etc/conserver/invirt-genconfig.cf.mako
new file mode 100644 (file)
index 0000000..94c3f94
--- /dev/null
@@ -0,0 +1,6 @@
+<% from invirt.config import structs as cfg %>\
+access * {
+       trusted 127.0.0.1;
+       trusted ${cfg.console.ip};
+       limited *;
+}
diff --git a/host/etc/conserver/server.conf.invirt b/host/etc/conserver/server.conf.invirt
new file mode 100644 (file)
index 0000000..9081b3b
--- /dev/null
@@ -0,0 +1,2 @@
+OPTS='-p 3109  '
+ASROOT=
diff --git a/host/usr/sbin/invirt-update-conserver b/host/usr/sbin/invirt-update-conserver
new file mode 100755 (executable)
index 0000000..9a7fd3c
--- /dev/null
@@ -0,0 +1,32 @@
+#!/usr/bin/python
+
+import subprocess
+import os
+import socket
+from invirt.config import structs as config
+
+def live_vms():
+    p = subprocess.Popen(['/usr/sbin/xm', 'list'], stdout=subprocess.PIPE)
+    p.wait()
+    output = p.stdout.read()
+    vms = [x.split()[0][2:] for x in output.splitlines() if x.startswith('d_')]
+    return vms
+
+def reload_conserver():
+    p = subprocess.Popen(['/usr/sbin/invoke-rc.d', 'conserver-server', 'reload'], stdout=subprocess.PIPE)
+    p.wait()
+
+if __name__ == '__main__':
+    hostname = socket.getfqdn().lower()
+    realm = config.authn[0].realm
+    principal = 'host/'+hostname+'@'+realm
+    conftext = '\n'.join('console %s { master %s; }' % (vm, hostname)
+                         for vm in live_vms())
+    f = open('/etc/conserver/invirt-consoles.cf', 'w')
+    f.write(conftext)
+    f.close()
+    reload_conserver()
+    subprocess.call(['/usr/bin/kinit', '-k', '-t', '/etc/krb5.keytab',
+                     principal])
+    subprocess.call(['/usr/bin/remctl', config.console.hostname,
+                     'console', 'update', conftext])