Alan Pevec
2008-Nov-12 18:28 UTC
[Ovirt-devel] [PATCH node] additional oVirt Node boot parameters for standalone mode
These are used as the default values by ovirt-config-* scripts
If all required values are supplied, automatic configuration can be performed.
local partition sizes in GB
ovirt_vol=BOOT_GB:SWAP_GB:INSTALL_GB:CONFIG_GB:LOGGING_GB
force oVirt Node standalone mode
ovirt_standalone
static network configuration
pxelinux format:
ip=<client-ip>:<boot-server-ip>:<gw-ip>:<netmask>
anaconda format: ip=<client-ip> netmask=<netmask>
gateway=<gw-ip>
ipv6=dhcp|auto
default syslog server
syslog=server[:port]
Signed-off-by: Alan Pevec <apevec at redhat.com>
---
scripts/ovirt | 3 +
scripts/ovirt-early | 135 ++++++++++++++++++++++++++++++++++++++--------
scripts/ovirt-functions | 19 +++++++
scripts/ovirt-post | 3 +
4 files changed, 136 insertions(+), 24 deletions(-)
diff --git a/scripts/ovirt b/scripts/ovirt
index 3c120a0..81733a5 100644
--- a/scripts/ovirt
+++ b/scripts/ovirt
@@ -33,6 +33,9 @@ start() {
fi
umount $ovirt && rmdir $ovirt
+ if is_standalone; then
+ exit 0
+ fi
find_srv ipa tcp
if [ -n "$SRV_HOST" -a -n "$SRV_PORT" ]; then
krb5_conf=/etc/krb5.conf
diff --git a/scripts/ovirt-early b/scripts/ovirt-early
index 1a14220..394fce5 100755
--- a/scripts/ovirt-early
+++ b/scripts/ovirt-early
@@ -104,10 +104,11 @@ find_disk() {
return 1
}
-# local_install $local_os $target
-# local_os - 1=install LiveOS and boot loader
-# 0=initialize oVirt partition only
-# target - target disk to hold the oVirt partition
+# TODO move to ovirt-config-storage
+# local_install $local_boot $local_disk $bootparams
+# local_boot - 1=install LiveOS and boot loader
+# 0=initialize oVirt partition only
+# local_disk - local disk to hold the oVirt partition
# =usb|scsi[:serial#]
# bootparams - extra boot parameters like console #
@@ -118,8 +119,8 @@ find_disk() {
# /LiveOS - oVirt Node compressed livecd image
local_install() {
- local local_os=$1
- local target=$2
+ local local_boot=$1
+ local local_disk=$2
local bootparams=$3
local disk
local part
@@ -140,7 +141,7 @@ local_install() {
if [ "$ovirt_disk" = "$ovirt_part" ]; then
ovirt_disk fi
- if [ -z "$target" ]; then
+ if [ -z "$local_disk" ]; then
if [ -z "$ovirt_disk" ]; then
return 1
fi
@@ -149,7 +150,7 @@ local_install() {
disk=$ovirt_disk
part=$ovirt_part
else
- case "$target" in
+ case "$local_disk" in
=)
# empty ovirt_init, use current live image device
mode=update
@@ -158,12 +159,12 @@ local_install() {
;;
=scsi*)
bus=scsi
- serial=${target#=scsi:}
+ serial=${local_disk#=scsi:}
mode=install
;;
=usb*)
bus=usb
- serial=${target#=usb:}
+ serial=${local_disk#=usb:}
mode=install
;;
*)
@@ -177,12 +178,12 @@ local_install() {
disk=$(find_disk $bus $serial $live_disk)
rc=$?
if [ $rc -ne 0 ]; then
- echo "target disk '$target' not available"
+ echo "local disk '$local_disk' not available"
return 1
fi
if [ -n "$ovirt_disk" ]; then
if [ "$disk" = "$ovirt_disk" ]; then
- # target disk contains oVirt partition, select it for update
+ # local disk contains oVirt partition, select it for update
# TODO force reinstall option
mode=update
part=$ovirt_part
@@ -219,7 +220,7 @@ local_install() {
fi
ovirt=$(mktemp -d)
if [ "$part" = "$live_part" ]; then
- # ovirt_init w/o specified target
+ # ovirt_init w/o local disk specified
# setup /config on live disk, if writeable
# TODO mlabel/e2label (check fs2 type or just blindly try?)
mount -r $part $ovirt && mount -o remount,rw $ovirt \
@@ -236,7 +237,7 @@ local_install() {
fi
mount $part $ovirt
if [ $? -ne 0 ]; then
- echo "target mount failed"
+ echo "local disk mount failed"
umount $live && rmdir $live
rmdir $ovirt
return 1
@@ -249,7 +250,7 @@ local_install() {
|| echo "config copy failed"
fi
- if [ $local_os = 0 ]; then
+ if [ $local_boot = 0 ]; then
# config update only, cleanup and continue booting
umount $ovirt && rmdir $ovirt
umount $live && rmdir $live
@@ -314,7 +315,14 @@ start() {
# oVirt boot parameters
# BOOTIF=<MAC> (appended by pxelinux)
# ovirt_init=usb|scsi[:serial#]
+ # ovirt_vol=BOOT_GB:SWAP_GB:INSTALL_GB:CONFIG_GB:LOGGING_GB
# ovirt_local_boot
+ # ovirt_standalone
+ # pxelinux format:
ip=<client-ip>:<boot-server-ip>:<gw-ip>:<netmask>
+ # anaconda format: ip=<client-ip> netmask=<netmask>
gateway=<gw-ip>
+ # ipv6=dhcp|auto
+ # syslog=server[:port]
+ # TBD logrotate maxsize
# BOOTIF=<MAC> (appended by pxelinux)
# network boot interface is assumed to be on management network where
@@ -329,11 +337,38 @@ start() {
# serial# - select exact disk using serial number, as reported by
# udev ID_SERIAL
# e.g. ovirt_init=usb:Generic_STORAGE_DEVICE_0000145418-0:0
- target+ ovirt_init+
+ # ovirt_vol=BOOT_GB:SWAP_GB:INSTALL_GB:CONFIG_GB:LOGGING_GB
+ # local partition sizes in GB
+ ovirt_vol_boot+ ovirt_vol_install+ ovirt_vol_config+
ovirt_vol_logging
# ovirt_local_boot
# install/update oVirt Node image on the local installation target disk
- local_os=0
+ ovirt_local_boot=0
+
+ # ovirt_standalone
+ # force oVirt Node standalone mode
+ ovirt_standalone=0
+
+ # pxelinux format:
ip=<client-ip>:<boot-server-ip>:<gw-ip>:<netmask>
+ # anaconda format: ip=<client-ip> netmask=<netmask>
gateway=<gw-ip>
+ # ipv6=dhcp|auto
+ # static network configuration
+ ip_address+ ip_gateway+ ip_netmask+ netmask+ gateway+ ipv6+
+ # syslog=server[:port]
+ # default syslog server
+ syslog_server+ syslog_port
# save boot parameters like console= for local disk boot menu
bootparams@@ -345,31 +380,82 @@ start() {
bootif=$(grep -il $(echo $i|sed 's/-/:/g')
/sys/class/net/eth*/address|rev|cut -d/ -f2|rev)
;;
ovirt_init*)
- target=${i#ovirt_init}
- if [ -z "$target" ]; then
- target='='
+ ovirt_init=${i#ovirt_init}
+ if [ -z "$ovirt_init" ]; then
+ ovirt_init='='
fi
;;
+ ovirt_vol=*)
+ i=${i#ovirt_vol=}
+ eval $(printf $i|awk -F: '{print "ovirt_vol_boot="$1;
print "ovirt_vol_install="$2; print "ovirt_vol_config="$3;
print "ovirt_vol_logging="$4;}')
+ ;;
ovirt_local_boot*)
- local_os=1
+ ovirt_local_boot=1
+ ;;
+ ovirt_standalone*)
+ ovirt_standalone=1
+ ;;
+ ip=*)
+ i=${i#ip=}
+ eval $(printf $i|awk -F: '{print "ip_address="$1;
print "ip_gateway="$3; print "ip_netmask="$4}')
+ ;;
+ netmask=*)
+ netmask=${i#netmask=}
+ ;;
+ gateway=*)
+ gateway=${i#gateway=}
+ ;;
+ ipv6=*)
+ ipv6=${i#ipv6=}
+ ;;
+ syslog=*)
+ i=${i#syslog=}
+ eval $(printf $i|awk -F: '{print "syslog_server="$1;
print "syslog_port="$2;}')
;;
console=*)
bootparams="$bootparams $i"
;;
esac
done
+ # save boot parameters as defaults for ovirt-config-*
+ if [ -z "$ip_netmask" ]; then
+ ip_netmask=$netmask
+ fi
+ if [ -z "$ip_gateway" ]; then
+ ip_gateway=$gateway
+ fi
+ cat > $OVIRT_DEFAULTS <<EOF
+# configuration defaults from oVirt Node boot parameters
+OVIRT_BOOTIF=$bootif
+OVIRT_INIT=$ovirt_init
+OVIRT_VOL_BOOT=$ovirt_vol_boot
+OVIRT_VOL_INSTALL=$ovirt_vol_install
+OVIRT_VOL_CONFIG=$ovirt_vol_config
+OVIRT_VOL_LOGGING=$ovirt_vol_logging
+OVIRT_LOCAL_BOOT=$ovirt_local_boot
+OVIRT_STANDALONE=$ovirt_standalone
+OVIRT_IP_ADDRESS=$ip_address
+OVIRT_IP_NETMASK=$ip_netmask
+OVIRT_IP_GATEWAY=$ip_gateway
+OVIRT_IPV6=$ipv6
+OVIRT_SYSLOG_SERVER=$syslog_server
+OVIRT_SYSLOG_PORT=$syslog_port
+EOF
set -x
- local_install "$local_os" "$target"
"$bootparams"
+ local_install "$ovirt_local_boot" "$ovirt_init"
"$bootparams"
set +x
- configure_from_network $bootif
+ if [ $ovirt_standalone = 0 ]; then
+ configure_from_network $bootif
+ fi
+# BEGIN - move to ovirt-config-storage
# find all of the partitions on the system
# get the system pagesize
PAGESIZE=`getconf PAGESIZE`
- # look first at raw partitions
+ # look first at raw partitions XXX disk/by-id or HAL? (for cciss)
BLOCKDEVS=`ls /dev/sd? /dev/hd? 2>/dev/null`
# now LVM partitions
@@ -389,6 +475,7 @@ start() {
swapon $device
fi
done
+# END - move to ovirt-config-storage
}
case "$1" in
diff --git a/scripts/ovirt-functions b/scripts/ovirt-functions
index f6818ba..bdb0629 100644
--- a/scripts/ovirt-functions
+++ b/scripts/ovirt-functions
@@ -4,9 +4,28 @@ OVIRT_LOGFILE=/var/log/ovirt.log
# label of the oVirt partition
OVIRT_LABEL=OVIRT
+# configuration defaults
+OVIRT_DEFAULTS=/etc/sysconfig/ovirt
+if [ -f $OVIRT_DEFAULTS ]; then
+ . $OVIRT_DEFAULTS
+fi
+# fallback defaults when sysconfig is empty
+OVIRT_STANDALONE=${OVIRT_STANDALONE:-0}
OVIRT_BACKUP_DIR=/var/lib/ovirt-backup
+# is_managed
+# return 1 if oVirt Node is running in standalone mode
+# return 0 if oVirt Node is managed by the oVirt Server
+is_managed() {
+ return $OVIRT_STANDALONE
+}
+
+# is_standalone = not is_managed
+is_standalone() {
+ if is_managed; then return 1; else return 0; fi
+}
+
# find_srv SERVICE PROTO
#
# reads DNS SRV record
diff --git a/scripts/ovirt-post b/scripts/ovirt-post
index 046a2c0..06506b7 100644
--- a/scripts/ovirt-post
+++ b/scripts/ovirt-post
@@ -17,6 +17,9 @@ start() {
/etc/libvirt/krb5.tab \
/etc/ssh/ssh_host*_key*
+ if is_standalone; then
+ exit 0
+ fi
find_srv identify tcp
if [ -n "$SRV_HOST" -a -n "$SRV_PORT" ]; then
ovirt-identify-node -s $SRV_HOST -p $SRV_PORT
--
1.5.6.5
Alan Pevec
2008-Nov-12 18:28 UTC
[Ovirt-devel] [PATCH node] Added a script that runs during first boot for the node.
From: Darryl L. Pierce <dpierce at redhat.com>
Each configuration function is stubbed out. The functions are:
* configure logging
* configure networking
* configure password
* configure storage
Signed-off-by: Darryl L. Pierce <dpierce at redhat.com>
---
Makefile.am | 6 ++++
ovirt-node.spec.in | 15 ++++++++++-
scripts/ovirt-config-logging | 2 +
scripts/ovirt-config-networking | 2 +
scripts/ovirt-config-password | 2 +
scripts/ovirt-config-setup | 23 ++++++++++++++++
scripts/ovirt-config-storage | 2 +
scripts/ovirt-firstboot | 55 +++++++++++++++++++++++++++++++++++++++
8 files changed, 106 insertions(+), 1 deletions(-)
create mode 100755 scripts/ovirt-config-logging
create mode 100755 scripts/ovirt-config-networking
create mode 100755 scripts/ovirt-config-password
create mode 100755 scripts/ovirt-config-setup
create mode 100755 scripts/ovirt-config-storage
create mode 100755 scripts/ovirt-firstboot
diff --git a/Makefile.am b/Makefile.am
index 4ba0bca..ea49b43 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -27,7 +27,13 @@ EXTRA_DIST = \
scripts/collectd.conf.in \
scripts/ovirt \
scripts/ovirt-awake \
+ scripts/ovirt-config-logging \
+ scripts/ovirt-config-networking \
+ scripts/ovirt-config-password \
+ scripts/ovirt-config-setup \
+ scripts/ovirt-config-storage \
scripts/ovirt-early \
+ scripts/ovirt-firstboot \
scripts/ovirt-functions \
scripts/ovirt-post \
scripts/ovirt-process-config \
diff --git a/ovirt-node.spec.in b/ovirt-node.spec.in
index d029c57..2a01b7c 100644
--- a/ovirt-node.spec.in
+++ b/ovirt-node.spec.in
@@ -87,6 +87,11 @@ cd -
%{__install} -d -m0755 %{buildroot}%{_sysconfdir}/logrotate.d
%{__install} -p -m0755 scripts/ovirt-awake %{buildroot}%{_sbindir}
+%{__install} -p -m0755 scripts/ovirt-config-logging %{buildroot}%{_sbindir}
+%{__install} -p -m0755 scripts/ovirt-config-networking %{buildroot}%{_sbindir}
+%{__install} -p -m0755 scripts/ovirt-config-password %{buildroot}%{_sbindir}
+%{__install} -p -m0755 scripts/ovirt-config-setup %{buildroot}%{_sbindir}
+%{__install} -p -m0755 scripts/ovirt-config-storage %{buildroot}%{_sbindir}
%{__install} -p -m0755 scripts/ovirt-process-config %{buildroot}%{_sbindir}
%{__install} -p -m0755 ovirt-identify-node/ovirt-identify-node
%{buildroot}%{_sbindir}
%{__install} -p -m0755 ovirt-listen-awake/ovirt-listen-awake
%{buildroot}%{_sbindir}
@@ -94,9 +99,9 @@ cd -
%{__install} -Dp -m0755 ovirt-listen-awake/ovirt-install-node
%{buildroot}%{_sbindir}
%{__install} -Dp -m0755 ovirt-listen-awake/ovirt-uninstall-node
%{buildroot}%{_sbindir}
-
%{__install} -p -m0644 scripts/ovirt-functions %{buildroot}%{_initrddir}
%{__install} -p -m0755 scripts/ovirt-early %{buildroot}%{_initrddir}
+%{__install} -p -m0755 scripts/ovirt-firstboot %{buildroot}%{_initrddir}
%{__install} -p -m0755 scripts/ovirt %{buildroot}%{_initrddir}
%{__install} -p -m0755 scripts/ovirt-post %{buildroot}%{_initrddir}
@@ -123,6 +128,7 @@ cd -
%post
/sbin/chkconfig --add ovirt-early
+/sbin/chkconfig --add ovirt-firstboot
/sbin/chkconfig --add ovirt
/sbin/chkconfig --add ovirt-post
# this is ugly; we need collectd to start *after* libvirtd, so we own the
@@ -133,6 +139,7 @@ cd -
%preun
if [ "$1" = 0 ] ; then
/sbin/chkconfig --del ovirt-early
+ /sbin/chkconfig --del ovirt-firstboot
/sbin/chkconfig --del ovirt
/sbin/chkconfig --del ovirt-post
/sbin/chkconfig --del ovirt-listen-awake
@@ -159,12 +166,18 @@ fi
%files
%defattr(-,root,root,0755)
%{_sbindir}/ovirt-awake
+%{_sbindir}/ovirt-config-logging
+%{_sbindir}/ovirt-config-networking
+%{_sbindir}/ovirt-config-password
+%{_sbindir}/ovirt-config-setup
+%{_sbindir}/ovirt-config-storage
%{_sbindir}/ovirt-process-config
%{_sbindir}/ovirt-identify-node
%{_sbindir}/ovirt-listen-awake
%{_sbindir}/ovirt-install-node
%{_sbindir}/ovirt-uninstall-node
%{_initrddir}/ovirt-early
+%{_initrddir}/ovirt-firstboot
%{_initrddir}/ovirt
%{_initrddir}/ovirt-post
%{_initrddir}/ovirt-listen-awake
diff --git a/scripts/ovirt-config-logging b/scripts/ovirt-config-logging
new file mode 100755
index 0000000..c856ef1
--- /dev/null
+++ b/scripts/ovirt-config-logging
@@ -0,0 +1,2 @@
+#!/bin/bash
+#
diff --git a/scripts/ovirt-config-networking b/scripts/ovirt-config-networking
new file mode 100755
index 0000000..c856ef1
--- /dev/null
+++ b/scripts/ovirt-config-networking
@@ -0,0 +1,2 @@
+#!/bin/bash
+#
diff --git a/scripts/ovirt-config-password b/scripts/ovirt-config-password
new file mode 100755
index 0000000..c856ef1
--- /dev/null
+++ b/scripts/ovirt-config-password
@@ -0,0 +1,2 @@
+#!/bin/bash
+#
diff --git a/scripts/ovirt-config-setup b/scripts/ovirt-config-setup
new file mode 100755
index 0000000..8408d14
--- /dev/null
+++ b/scripts/ovirt-config-setup
@@ -0,0 +1,23 @@
+#!/bin/bash
+#
+# Entry point for configuring an oVirt node when running in standalone mode.
+
+while true; do
+ PS3="Please select an option: "
+ # TODO should we make this optional, based on whether the password was
already set?
+ PASSWORD_OPTION="Password"
+ OPTIONS="Networking Storage Logging ${PASSWORD_OPTION} Quit"
+
+ select OPTION in $OPTIONS
+ do
+ printf "\n"
+
+ case "$OPTION" in
+ "Networking") ovirt-config-networking ; break ;;
+ "Storage") ovirt-config-storage ; break ;;
+ "Logging") ovirt-config-logging ; break ;;
+ "Password") ovirt-config-password ; break ;;
+ "Quit") exit 0 ;;
+ esac
+ done
+done
diff --git a/scripts/ovirt-config-storage b/scripts/ovirt-config-storage
new file mode 100755
index 0000000..c856ef1
--- /dev/null
+++ b/scripts/ovirt-config-storage
@@ -0,0 +1,2 @@
+#!/bin/bash
+#
diff --git a/scripts/ovirt-firstboot b/scripts/ovirt-firstboot
new file mode 100755
index 0000000..82d9e48
--- /dev/null
+++ b/scripts/ovirt-firstboot
@@ -0,0 +1,55 @@
+#!/bin/bash
+#
+# ovirt-firstboot Puts the node into configuration mode.
+#
+# chkconfig: 2345 99 01
+# description: ovirt-firstboot node configuration script
+#
+# Copyright (C) 2008 Red Hat, Inc.
+# Written by Darryl L. Pierce <dpierce at redhat.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA. A copy of the GNU General Public License is
+# also available at http://www.gnu.org/copyleft/gpl.html.
+
+## Source functions library
+. /etc/init.d/functions
+. /etc/init.d/ovirt-functions
+
+start ()
+{
+ ovirt-config-setup
+}
+
+case "$1" in
+ start)
+ if is_managed; then
+ exit 0
+ fi
+
+ printf "Starting ovirt-firstboot: "
+
+ {
+ start
+ }
+
+ test $? == 0 && success || failure
+ echo
+ ;;
+
+ *)
+ echo "Usage: ovirt-firstboot {start}"
+ exit 2
+esac
+
--
1.5.6.5
Darryl Pierce
2008-Nov-12 19:51 UTC
[Ovirt-devel] [PATCH node] additional oVirt Node boot parameters for standalone mode
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Alan Pevec wrote:> These are used as the default values by ovirt-config-* scripts > If all required values are supplied, automatic configuration can be performed. > > local partition sizes in GB > ovirt_vol=BOOT_GB:SWAP_GB:INSTALL_GB:CONFIG_GB:LOGGING_GB > > force oVirt Node standalone mode > ovirt_standalone > > static network configuration > pxelinux format: ip=<client-ip>:<boot-server-ip>:<gw-ip>:<netmask> > anaconda format: ip=<client-ip> netmask=<netmask> gateway=<gw-ip> > ipv6=dhcp|auto > > default syslog server > syslog=server[:port] > > Signed-off-by: Alan Pevec <apevec at redhat.com> > ---ACK. - -- Darryl L. Pierce <dpierce at redhat.com> : GPG KEYID: 6C4E7F1B -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org iEYEARECAAYFAkkbM8UACgkQjaT4DmxOfxtZUACgz633wstRNUd+j6n7ipihDeFh UFIAnj9bQ9lPfIG1qgs/zwowHI5mOipj =spcV -----END PGP SIGNATURE----- -------------- next part -------------- A non-text attachment was scrubbed... Name: dpierce.vcf Type: text/x-vcard Size: 319 bytes Desc: not available URL: <http://listman.redhat.com/archives/ovirt-devel/attachments/20081112/4e8fb43b/attachment.vcf>