From: Evan Broder Date: Sun, 7 Dec 2008 15:21:31 +0000 (-0500) Subject: Merge invirt-console-server into invirt-console (LP: #305681) X-Git-Tag: 0.2.0^0 X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/invirt-console.git/commitdiff_plain/ea990341e40f67e1998fed6a1e6a8455782db73c?hp=0831546bfd6cbfa9ec41f6e82b28d9a84fcf1cec Merge invirt-console-server into invirt-console (LP: #305681) svn path=/trunk/packages/invirt-console/; revision=1815 --- diff --git a/debian/changelog b/debian/changelog index 262bc4b..0d439ce 100644 --- a/debian/changelog +++ b/debian/changelog @@ -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 Sun, 07 Dec 2008 10:10:36 -0500 + -- Evan Broder Sun, 07 Dec 2008 10:17:06 -0500 invirt-console-server (0.1.3) unstable; urgency=low diff --git a/debian/control b/debian/control index b4767da..4969f5c 100644 --- a/debian/control +++ b/debian/control @@ -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 index 0000000..2135f98 --- /dev/null +++ b/debian/invirt-console-host.cron.d @@ -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 index 0000000..5d19df7 --- /dev/null +++ b/debian/invirt-console-host.init @@ -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 index 0000000..260c50b --- /dev/null +++ b/debian/invirt-console-host.install @@ -0,0 +1 @@ +host/* . diff --git a/debian/invirt-console-host.postinst b/debian/invirt-console-host.postinst new file mode 100755 index 0000000..9f4b5a8 --- /dev/null +++ b/debian/invirt-console-host.postinst @@ -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: +# * `configure' +# * `abort-upgrade' +# * `abort-remove' `in-favour' +# +# * `abort-remove' +# * `abort-deconfigure' `in-favour' +# `removing' +# +# 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 <&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 index 0000000..9d0b178 --- /dev/null +++ b/debian/invirt-console-host.prerm @@ -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: +# * `remove' +# * `upgrade' +# * `failed-upgrade' +# * `remove' `in-favour' +# * `deconfigure' `in-favour' +# `removing' +# +# 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 diff --git a/debian/rules b/debian/rules index 47cbab2..b1b8d2b 100755 --- a/debian/rules +++ b/debian/rules @@ -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 index 0000000..1b92380 --- /dev/null +++ b/host/etc/conserver/conserver.cf.invirt @@ -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 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 index 0000000..94c3f94 --- /dev/null +++ b/host/etc/conserver/invirt-genconfig.cf.mako @@ -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 index 0000000..9081b3b --- /dev/null +++ b/host/etc/conserver/server.conf.invirt @@ -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 index 0000000..9a7fd3c --- /dev/null +++ b/host/usr/sbin/invirt-update-conserver @@ -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])