← Back to team overview

orchestra team mailing list archive

[Merge] lp:~jtv/orchestra/odev-restart into lp:~orchestra/orchestra/odev

 

Jeroen T. Vermeulen has proposed merging lp:~jtv/orchestra/odev-restart into lp:~orchestra/orchestra/odev.

Requested reviews:
  Scott Moser (smoser)

For more details, see:
https://code.launchpad.net/~jtv/orchestra/odev-restart/+merge/91050

This should make it easier to restart a previously initialized odev environment without re-creating it, or editing the HOWTO.  It reduces the steps in the script by moving the details into scripts in ./bin/ so that they're easier to run manually after, say, a reboot.

Actually, two other things change here:

1. Automated help for setting up your ssh keys in the virtual cobbler instance.  The HOWTO prompts you for a Launchpad user name to import keys from, but alternatively you can jam your ~/.ssh/id_*.pub into the cobbler server's ~/.ssh/authorized_keys.

2. The script now waits for the cobbler server's ssh server to come up before continuing.  Hopefully this will prove a bit more reliable that the fixed-length sleep I inserted earlier!

Alas, the virsh-listener isn't quite working for me yet.  The "range" argument (left unchanged from the original here) seems to preclude connections from the host system.  Was it meant to be run on the virtual cobbler server?
-- 
https://code.launchpad.net/~jtv/orchestra/odev-restart/+merge/91050
Your team orchestra is subscribed to branch lp:~orchestra/orchestra/odev.
=== modified file 'HOWTO'
--- HOWTO	2012-01-30 18:25:17 +0000
+++ HOWTO	2012-02-01 11:05:29 +0000
@@ -2,75 +2,50 @@
 #
 # This file documents how to get odev running on your system.  But it's also
 # a script; you may find that you can just run it and get a working setup.
-#
-## install some dependencies
-pkgs=""
-pkgs="$pkgs genisoimage coreutils" # for cloud-init's 'make-iso'
-pkgs="$pkgs python-libvirt libvirt-bin" # for libvirt interaction
-pkgs="$pkgs socat" # for libvirt-> cobbler
-pkgs="$pkgs python-cheetah" # for setup.py
-
-sudo apt-get update -qq || /bin/true
-sudo apt-get install -y $pkgs </dev/null
-
-## add your user to libvirtd group
-sudo adduser $USER libvirtd
-sudo adduser $USER kvm # this is really only necessary for zimmer-build
-
-##
-## NOTE: you have to log out and log back in for this to take affect
-##
-
-## build a zimmer image by following readme in zimmer-build
-cd zimmer-build
+
+## System-level setup.  This needs to be done only once.
+./bin/system-setup
+
+# The user may need to log out at this point.
+echo "Ctrl-C if you want to log out now.  Otherwise, press <enter>."
+read
+
+## Build a zimmer image in this branch.
+pushd zimmer-build
 ./build zimmer-disk0.img
-cd ..
-
-## create libvirt xml files for nodes, zimmer, network
-./setup.py libvirt-setup
-
-## start odev-net network
-virsh -c qemu:///system net-start odev-net
-
-## create zimmer disk image qcow backing against pristine version
-qemu-img create -f qcow2 -b zimmer-build/zimmer-disk0.img zimmer-disk0.img
-
-## start zimmer instance / orchestra server
-virsh -c qemu:///system start zimmer
-
+popd
+
+## Get zimmer and cobbler running.
+./bin/start-odev
+
+cobblerlogin=ubuntu@192.168.123.2
 cat <<EOF
-Starting orchestra server.
-You can now ssh ubuntu@192.168.123.2 (password: passw0rd).
-If you do that, you may run 'ssh-import-id' to import your ssh key.
-
-Access the cobbler UI on http://192.168.123.2/cobbler_web
-and log in with 'cobbler:xcobbler'.
+While we're waiting for the server to come up, let's set up ssh login to
+the cobbler server at $cobblerlogin.
+
+Please enter your Launchpad login name to import your ssh keys from Launchpad,
+or an asterisk ("*") to import your local public ssh keys.  Enter nothing to
+skip this step.
+
+(If the server prompts you for a password, the default is "passw0rd")
 EOF
-
-## Give the server some time to start up.
-sleep 20
-echo
+read keyowner
+./bin/authorize-ssh $cobblerlogin $keywowner
 
 ## populate the nodes into the cobbler server
 ./setup.py cobbler-setup
 
-## * libvirt from the cobbler system:
-##   after 'cobbler-setup' above is done, the cobbler system will know about
-##   all the nodes and it will believe it can control them via the 'virsh'
-##   power module.  It is configured
-##   to talk to qemu+tcp://192.168.123.1:65001/system .  In order to allow
-##   that to be valid we have to make libvirt listen on that port/interface.
-##   This can be done moderately securely with 'socat'.  Below, we tell socat
-##   to forward tcp connections on 192.168.123.1:65001 to the libvirt unix
-##   socket .  It restricts connections to zimmer's IP address.
-
-socat -d -d \
-     TCP4-LISTEN:65001,bind=192.168.123.1,range=192.168.123.2/32,fork \
-     UNIX-CONNECT:/var/run/libvirt/libvirt-sock
-
-##  You can verify this is working by powering a sytem on from the web-ui or
-##  the following on the cobbler server:
-##  zimmmer$ virsh -c qemu+tcp://192.168.123.1:65001/system
+cat <<EOF
+Starting virsh listener.
+
+You can verify this is working by powering a sytem on from the web-ui or
+the following on the cobbler server:
+zimmmer$ virsh -c qemu+tcp://192.168.123.1:65001/system
+EOF
+
+## Listen for libvirt requests.
+./bin/virsh-listener
+
 
 ## at this point you may want to modify zimmer to provide a proxy
 ##  other than itself to things installing from it (LP: #914202).

=== added directory 'bin'
=== added file 'bin/authorize-ssh'
--- bin/authorize-ssh	1970-01-01 00:00:00 +0000
+++ bin/authorize-ssh	2012-02-01 11:05:29 +0000
@@ -0,0 +1,39 @@
+#! /bin/bash -e
+#
+# Wait for the virtual cobbler instance's ssh server to start up, and set up
+# passwordless login if desired.
+#
+# Usage:
+#   authorize-ssh <cobbler-ssh-login> <key-owner>
+#
+# Where:
+#  * cobbler-ssh-login is an ssh user/hostname, e.g. ubuntu@192.168.123.2
+#  * key-owner is a Launchpad login name, or * to use local keys, or nothing.
+#
+# If a Launchpad login name is given, import the associated ssh keys into the
+# cobbler instance.  If key-owner is an asterisk, import the local public ssh
+# keys from ~/.ssh/id_*.pub
+
+cobblerlogin=$1
+keyowner=$2
+
+if test -z "$keyowner"
+then
+	echo "Not setting up ssh keys."
+	echo "I'll still test a login to Cobbler though."
+	inputfiles=/dev/null
+	remotecmd="uptime"
+elif test "$keyowner" = "*"
+then
+	inputfiles=`ls ~/.ssh/id_*.pub`
+	echo "Copying public key(s): $inputfiles"
+	remotecmd="tee .ssh/authorized_keys"
+else
+	inputfiles=/dev/null
+	remotecmd="ssh-import-id $keyowner"
+fi
+
+while ! cat $inputfiles | ssh $cobblerlogin -o StrictHostKeyChecking=no $remotecmd
+do
+	sleep 5
+done

=== added file 'bin/start-odev'
--- bin/start-odev	1970-01-01 00:00:00 +0000
+++ bin/start-odev	2012-02-01 11:05:29 +0000
@@ -0,0 +1,26 @@
+#! /bin/bash -e
+#
+# Get zimmer and cobbler running, assuming that zimmer has already been set up.
+
+## create libvirt xml files for nodes, zimmer, network
+./setup.py libvirt-setup
+
+## start odev-net network
+virsh -c qemu:///system net-start odev-net
+
+## create zimmer disk image qcow backing against pristine version
+qemu-img create -f qcow2 -b zimmer-build/zimmer-disk0.img zimmer-disk0.img
+
+## start zimmer instance / orchestra server
+virsh -c qemu:///system start zimmer
+
+cat <<EOF
+Starting orchestra server.
+You can now ssh ubuntu@192.168.123.2 (password: passw0rd).
+If you do that, you may run 'ssh-import-id' to import your ssh key.
+
+Access the cobbler UI on http://192.168.123.2/cobbler_web
+and log in with 'cobbler:xcobbler'.
+EOF
+
+

=== added file 'bin/system-setup'
--- bin/system-setup	1970-01-01 00:00:00 +0000
+++ bin/system-setup	2012-02-01 11:05:29 +0000
@@ -0,0 +1,27 @@
+#! /bin/bash -e
+#
+# System-wide setup for odev.  This requires sudo.
+
+## install some dependencies
+pkgs=""
+pkgs="$pkgs genisoimage coreutils" # for cloud-init's 'make-iso'
+pkgs="$pkgs python-libvirt libvirt-bin" # for libvirt interaction
+pkgs="$pkgs socat" # for libvirt-> cobbler
+pkgs="$pkgs python-cheetah" # for setup.py
+
+sudo apt-get update -qq || /bin/true
+sudo apt-get install -y $pkgs </dev/null
+
+## add your user to libvirtd group
+sudo adduser $USER libvirtd
+sudo adduser $USER kvm # this is really only necessary for zimmer-build
+
+cat <<EOF
+Done.
+
+The script just added you to the system's libvirtd and kvm groups if you
+weren't already in them.
+
+If you were not previously in the libvirtd and kvm groups, log out now and
+log back in again to make the changes take effect.
+EOF

=== added file 'bin/virsh-listener'
--- bin/virsh-listener	1970-01-01 00:00:00 +0000
+++ bin/virsh-listener	2012-02-01 11:05:29 +0000
@@ -0,0 +1,18 @@
+#! /bin/bash -e
+
+## * libvirt from the cobbler system:
+##   after 'cobbler-setup' above is done, the cobbler system will know about
+##   all the nodes and it will believe it can control them via the 'virsh'
+##   power module.  It is configured
+##   to talk to qemu+tcp://192.168.123.1:65001/system .  In order to allow
+##   that to be valid we have to make libvirt listen on that port/interface.
+##   This can be done moderately securely with 'socat'.  Below, we tell socat
+##   to forward tcp connections on 192.168.123.1:65001 to the libvirt unix
+##   socket .  It restricts connections to zimmer's IP address.
+
+sock="/var/run/libvirt/libvirt-sock"
+
+echo "Listening for libvirt requests on $sock."
+socat -d -d \
+     TCP4-LISTEN:65001,bind=192.168.123.1,range=192.168.123.2/32,fork \
+     UNIX-CONNECT:$sock


Follow ups