Alan Pevec
2008-Nov-07 01:27 UTC
[Ovirt-devel] [PATCH ovirt-node] Creates a standalone mode entry point script.
From: Darryl L. Pierce <dpierce at redhat.com> [REPOST] split into separate patch per -config component, ws cleanup This patch includes booting to firstboot/standalone mode The script will execute only when the node is booted without the support of a server suite. If it determines that the node is running in standalone mode, it will then kick over to a node setup script. This iteration defines the general flow for the standalone mode's firstboot use case. When the node boots and determines it's in standalone mode, it goes through the following steps: 1. Prompt for an administrator password 2. Prompt the user to configure disk storage 3. Prompt the user to configure networking 4. Prompt the user to configure logging The node then continues to boot normally. Signed-off-by: Darryl L. Pierce <dpierce at redhat.com> --- Makefile.am | 6 ++++ ovirt-node.spec.in | 15 ++++++++++- scripts/ovirt-config-logging | 1 + scripts/ovirt-config-networking | 1 + scripts/ovirt-config-password | 1 + scripts/ovirt-config-setup | 23 ++++++++++++++++ scripts/ovirt-config-storage | 1 + scripts/ovirt-functions | 5 +++ scripts/ovirt-standalone-mode | 55 +++++++++++++++++++++++++++++++++++++++ 9 files changed, 107 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-standalone-mode diff --git a/Makefile.am b/Makefile.am index 4ba0bca..0005ac9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -27,10 +27,16 @@ 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-functions \ scripts/ovirt-post \ scripts/ovirt-process-config \ + scripts/ovirt-standalone-mode \ logrotate/ovirt-logrotate \ logrotate/ovirt-logrotate.conf diff --git a/ovirt-node.spec.in b/ovirt-node.spec.in index d029c57..10a544b 100644 --- a/ovirt-node.spec.in +++ b/ovirt-node.spec.in @@ -88,17 +88,22 @@ cd - %{__install} -p -m0755 scripts/ovirt-awake %{buildroot}%{_sbindir} %{__install} -p -m0755 scripts/ovirt-process-config %{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 ovirt-identify-node/ovirt-identify-node %{buildroot}%{_sbindir} %{__install} -p -m0755 ovirt-listen-awake/ovirt-listen-awake %{buildroot}%{_sbindir} %{__install} -Dp -m0755 ovirt-listen-awake/ovirt-listen-awake.init %{buildroot}%{_initrddir}/ovirt-listen-awake %{__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 %{buildroot}%{_initrddir} %{__install} -p -m0755 scripts/ovirt-post %{buildroot}%{_initrddir} +%{__install} -p -m0755 scripts/ovirt-standalone-mode %{buildroot}%{_initrddir} %{__install} -p -m0644 scripts/collectd %{buildroot}%{_sysconfdir}/chkconfig.d %{__install} -p -m0644 scripts/collectd.conf.in %{buildroot}%{_sysconfdir} @@ -125,6 +130,7 @@ cd - /sbin/chkconfig --add ovirt-early /sbin/chkconfig --add ovirt /sbin/chkconfig --add ovirt-post +/sbin/chkconfig --add ovirt-standalone-mode # this is ugly; we need collectd to start *after* libvirtd, so we own the # /etc/chkconfig.d/collectd file, and then have to re-define collectd here /sbin/chkconfig --add collectd @@ -136,6 +142,7 @@ if [ "$1" = 0 ] ; then /sbin/chkconfig --del ovirt /sbin/chkconfig --del ovirt-post /sbin/chkconfig --del ovirt-listen-awake + /sbin/chkconfig --del ovirt-standalone-mode fi %post selinux @@ -159,6 +166,11 @@ 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 @@ -168,6 +180,7 @@ fi %{_initrddir}/ovirt %{_initrddir}/ovirt-post %{_initrddir}/ovirt-listen-awake +%{_initrddir}/ovirt-standalone-mode %config %{_sysconfdir}/logrotate.d/ovirt-logrotate.conf %config %{_sysconfdir}/cron.hourly/ovirt-logrotate %defattr(-,root,root,0644) diff --git a/scripts/ovirt-config-logging b/scripts/ovirt-config-logging new file mode 100755 index 0000000..8b13789 --- /dev/null +++ b/scripts/ovirt-config-logging @@ -0,0 +1 @@ + diff --git a/scripts/ovirt-config-networking b/scripts/ovirt-config-networking new file mode 100755 index 0000000..8b13789 --- /dev/null +++ b/scripts/ovirt-config-networking @@ -0,0 +1 @@ + diff --git a/scripts/ovirt-config-password b/scripts/ovirt-config-password new file mode 100755 index 0000000..8b13789 --- /dev/null +++ b/scripts/ovirt-config-password @@ -0,0 +1 @@ + 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..8b13789 --- /dev/null +++ b/scripts/ovirt-config-storage @@ -0,0 +1 @@ + diff --git a/scripts/ovirt-functions b/scripts/ovirt-functions index e251eac..53e9f62 100644 --- a/scripts/ovirt-functions +++ b/scripts/ovirt-functions @@ -7,6 +7,11 @@ OVIRT_LABEL=OVIRT OVIRT_BACKUP_DIR=/var/lib/ovirt-backup +is_standalone() +{ + return 0 +} + find_srv() { local dnsreply diff --git a/scripts/ovirt-standalone-mode b/scripts/ovirt-standalone-mode new file mode 100755 index 0000000..fed697a --- /dev/null +++ b/scripts/ovirt-standalone-mode @@ -0,0 +1,55 @@ +#!/bin/bash +# +# ovirt-standalone-mode Starts the node in standalone mode. +# +# chkconfig: 2345 99 01 +# description: ovirt-early services +# +# 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) + #is_standalone + #if [ $? -ne 0 ]; then + # exit 0 + #fi + + printf "Starting ovirt-standalone-mode: " + + { + start + } + + test $? == 0 && success || failure + echo + ;; + + *) + echo "Usage: ovirt-early {start}" + exit 2 +esac -- 1.5.6.5
Alan Pevec
2008-Nov-07 01:27 UTC
[Ovirt-devel] [PATCH ovirt-node] standalone mode - configure networking
From: Darryl L. Pierce <dpierce at redhat.com> --- scripts/ovirt-config-networking | 97 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 97 insertions(+), 0 deletions(-) diff --git a/scripts/ovirt-config-networking b/scripts/ovirt-config-networking index 8b13789..705521b 100755 --- a/scripts/ovirt-config-networking +++ b/scripts/ovirt-config-networking @@ -1 +1,98 @@ +#!/bin/bash +# +# Iterates over the list of network devices on the node and prompts the user +# to configure each. +CONFIG_FILE_ROOT="/file/etc/sysconfig/network-scripts/ifcfg" + +function configure_interface +{ + NIC=$1 + FILENAME="/var/tmp/augtool-$NIC" + + printf "\nCONFIGURE INTERFACE: $NIC\n\n" + + THIS_ROOT="$CONFIG_FILE_ROOT-$NIC" + CONFIG="rm $THIS_ROOT\nset $THIS_ROOT/DEVICE $NIC" + + # Is this NIC shared? + while true; do + printf "Is $NIC a shared interface? (Y/N) " + read + case $REPLY in + Y|y) CONFIG="$CONFIG\nset $THIS_ROOT/TYPE bridge"; break ;; + N|n) bridge="N"; break ;; + esac + done + + # how do you want to configure this device? (dhcp, static IP) + while true; do + printf "Does $NIC use dynamic addressing? (Y/N) " + read + case $REPLY in + Y|y) CONFIG="$CONFIG\nset $THIS_ROOT/BOOTPROTO dhcp"; break ;; + N|n) + printf "\tIP Address: "; read; IPADDR=$REPLY + printf "\t Netmask: "; read; NETMASK=$REPLY + printf "\t Broadcast: "; read; BROADCAST=$REPLY + printf "\t Gateway: "; read; GATEWAY=$REPLY + + printf "\nIP Address: $IPADDR\nNetmask: $NETMASK\nBroadcast: $BROADCAST\nGateway: $GATEWAY\n" + printf "Is this correct? (Y/N) " + read + case $REPLY in + Y|y) + CONFIG="$CONFIG\nset $THIS_ROOT/IPADDR $IPADDR" + CONFIG="$CONFIG\nset $THIS_ROOT/BROADCAST $BROADCAST" + CONFIG="$CONFIG\nset $THIS_ROOT/NETMASK $NETMASK" + break + ;; + esac + ;; + esac + done + + if [ "$bridge" == "N" ]; then + printf "Is $NIC bridged? (Y/N) " + read + case $REPLY in + Y|y) + printf "What is the bridge name? " + read + CONFIG="$CONFIG\n set $THIS_ROOT/BRIDGE $REPLY" + ;; + esac + fi + + CONFIG="$CONFIG\nset $THIS_ROOT/ONBOOT yes" + printf "$CONFIG\n" > $FILENAME + + echo +} + +# TODO the menu doesn't redisplay unless you hit enter -- needs fixing +# get the list of network cards on this machine +NICS=$(hal-device | awk '/net.interface/ { + match($0, "= '"'"'(.*)'"'"' ", nic); printf("%s ", nic[1]); }') + +# Append a quit option +NICS="$NICS Quit" + +PS3="Please select a network interface to configure:" +select NIC in $NICS +do + case "$NIC" in + "Quit") + break + ;; + + *) + configure_interface $NIC + ;; + esac +done + +# Merge together all generated files and run augtool + +cat /var/tmp/augtool-* > /var/tmp/config-augtool +augtool < /var/tmp/config-augtool -- 1.5.6.5
Alan Pevec
2008-Nov-07 01:27 UTC
[Ovirt-devel] [PATCH ovirt-node] standalone mode - configure local storage (DESTRUCTIVE)
From: Darryl L. Pierce <dpierce at redhat.com> --- scripts/ovirt-config-storage | 112 ++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 112 insertions(+), 0 deletions(-) diff --git a/scripts/ovirt-config-storage b/scripts/ovirt-config-storage index 8b13789..91d50de 100755 --- a/scripts/ovirt-config-storage +++ b/scripts/ovirt-config-storage @@ -1 +1,113 @@ +#!/bin/bash +# +# All sizes are in gigabytes +DRIVE=$(sfdisk -s | awk '/\/dev\/([sh]da)/ { match($0, "^(.*):.*", data); printf data[1] }') +BOOT_SIZE=1 +INSTALL_SIZE=10 +CONFIG_SIZE=5 +LOGGING_SIZE=2 + +MEM_SIZE=$(cat /proc/meminfo | awk '/MemTotal/ { print $2 }') +MEM_SIZE=$(( $MEM_SIZE / ( 1024 ** 2) )) +SWAP_SIZE=$(($MEM_SIZE * 2 + 1)) + +function do_configure +{ + read -p "Swap partition size (Currently ${SWAP_SIZE})? " + if [[ $REPLY =~ ^[0-9]+$ ]] && [[ $REPLY -gt 0 ]]; then + SWAP_SIZE=$REPLY + else + printf "Swap value is invalid.\n" + return + fi + + read -p "Boot partition size (Currently ${SWAP_SIZE})? " + if [[ $REPLY =~ ^[0-9]+$ ]] && [[ $REPLY -gt 0 ]]; then + BOOT_SIZE=$REPLY + else + printf "Boot value is invalid.\n" + return + fi + +} + +function do_review +{ + printf "\n" + printf "The local disk will be repartitioned as follows:\n" + printf "================================================\n" + printf " Physical Hard Disk: ${DRIVE}\n" + printf " Boot partition size: ${BOOT_SIZE} GB\n" + printf " Swap partition size: ${SWAP_SIZE} GB\n" + printf " Installation partition size: ${INSTALL_SIZE} GB\n" + printf " Configuration partition size: ${CONFIG_SIZE} GB\n" + printf " Logging partition size: ${LOGGING_SIZE} GB\n" + printf "\n" +} + +function do_partitioning +{ + while true; do + printf "\n" + printf "!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!\n" + printf "!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!\n" + printf "!!WARNING!! !!WARNING!!\n" + printf "!!WARNING!! !!WARNING!!\n" + printf "!!WARNING!! If you proceed this will destroy all data on your local system, and !!WARNING!!\n" + printf "!!WARNING!! your hard disk will be irreversably reconfiguration. !!WARNING!!\n" + printf "!!WARNING!! !!WARNING!!\n" + printf "!!WARNING!! !!WARNING!!\n" + printf "!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!\n" + printf "!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!WARNING!!\n" + printf "\n" + printf "\tContinue? (Y/n) " + read + case $REPLY in + Y|y) + { + dd if=/dev/zero of=/dev/sda bs=1K count=1 + blockdev --rereadpt /dev/sda + # Boot partition + # /dev/sda1 = Boot partition + # /dev/sda2 = Swap partition + # /dev/sda4 = LVM + echo -e "n\np\n1\n\n+$(( $BOOT_SIZE * 1024))M\na\n1\n + n\np\n2\n\n+$(( $SWAP_SIZE * 1024))M\nt\n2\n82\n + n\np\n4\n\n\nt\n4\n8e\n + w\n" | fdisk $DRIVE + pvcreate /dev/sda4 + vgcreate /dev/VolGroup00 /dev/sda4 + + lvcreate --name Ovirt /dev/VolGroup00 --size ${INSTALL_SIZE}G + lvcreate --name Config /dev/VolGroup00 --size ${CONFIG_SIZE}G + lvcreate --name Logging /dev/VolGroup00 --size ${LOGGING_SIZE}G + + mkfs -t ext3 /dev/sda1 + mkfs -t ext3 /dev/VolGroup00/Ovirt + mkfs -t ext3 /dev/VolGroup00/Config + mkfs -t ext3 /dev/VolGroup00/Logging + + } > partition.log + break ;; + N|n) return ;; + esac + done +} + +while true; do + OPTIONS="Configure Review Partition Quit" + PS3="Choose an option: " + + printf "\n" + + select OPTION in $OPTIONS + do + case "$OPTION" in + "Configure") do_configure ; break ;; + "Review") do_review ; break ;; + "Partition") do_partitioning ; break ;; + "Quit") exit ;; + esac + done +done -- 1.5.6.5
Alan Pevec
2008-Nov-07 01:27 UTC
[Ovirt-devel] [PATCH ovirt-node] RSyslog configuration for standalone mode.
From: Bryan Kearney <bkearney at redhat.com> It looks for a DNS service locator record by default, and lets the user override if desired --- scripts/ovirt-config-logging | 124 ++++++++++++++++++++++++++++++++++++++++++ scripts/ovirt-config-setup | 2 + 2 files changed, 126 insertions(+), 0 deletions(-) diff --git a/scripts/ovirt-config-logging b/scripts/ovirt-config-logging index 8b13789..1d9c877 100755 --- a/scripts/ovirt-config-logging +++ b/scripts/ovirt-config-logging @@ -1 +1,125 @@ +#!/bin/bash +# +# Configures the rsyslog daemon. +RSYSLOG_FILE="/etc/rsyslog.conf" + +# Creates the rsyslog file based on the following inputs +# $1 ipaddress of remote syslog server +# $2 port of remote syslog server +# $3 protocol (tcp or udp) +function ovirt_rsyslog { + +DELIM="" + +if [[ "$3" = "tcp" ]]; then + DELIM="@@" +else + DELIM="@" +fi + +cat > $RSYSLOG_FILE << EOF +#ovirt rsyslog config file + +#### MODULES #### +\$ModLoad imuxsock.so # provides support for local system logging (e.g. via logger command) +\$ModLoad imklog.so # provides kernel logging support (previously done by rklogd) + +#### GLOBAL DIRECTIVES #### +# Use default timestamp format +\$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat + +#### RULES #### +# Log anything (except mail) of level info or higher. +# Don't log private authentication messages! +*.info;mail.none;authpriv.none;cron.none /var/log/messages + +# The authpriv file has restricted access. +authpriv.* /var/log/secure + +# Log all the mail messages in one place. +mail.* -/var/log/maillog + +# Log cron stuff +cron.* /var/log/cron + +# Everybody gets emergency messages +*.emerg * + +# Save news errors of level crit and higher in a special file. +uucp,news.crit /var/log/spooler + +# Save boot messages also to boot.log +local7.* /var/log/boot.log + +\$WorkDirectory /var/spppl/rsyslog +\$ActionQueueFileName ovirtNode +\$ActionQueueMaxDiskSpace 10m +\$ActionQueueSaveOnShutdown on +\$ActionQueueType LinkedList +\$ActionResumeRetryCount -1 +*.* $DELIM$1:$2 +EOF + +/sbin/service rsyslog restart +} + +function prompt_user { + while true ; do + printf "\nWhat is the IP address or server name for the syslog server? " + read + SYSLOG_SERVER_IP=$REPLY + printf "\nWhat port does the syslog daemon run on? " + read + if [[ "$REPLY" =~ '^[0-9.]+$' ]]; then + SYSLOG_SERVER_PORT=$REPLY + NICS="$NICS Quit" + + PROTOCOLS="tcp udp" + PS3="Please select a the protocol to use: " + select SYSLOG_SERVER_PROTOCOL in $PROTOCOLS; + do + case $SYSLOG_SERVER_PROTOCOL in + "tcp") + break ;; + "udp") + break;; + esac + done + + printf "\nConfirm send all log messages to server '$SYSLOG_SERVER_IP' on port '$SYSLOG_SERVER_PORT' using protocol '$SYSLOG_SERVER_PROTOCOL' (Y/N)" + read + case $REPLY in + Y|y) + ovirt_rsyslog $SYSLOG_SERVER_IP $SYSLOG_SERVER_PORT $SYSLOG_SERVER_PROTOCOL + break + ;; + N|n) + printf "\nDiscarding settings" + break + ;; + esac + else + printf "\nInvalid port number" + fi + done + +} + +# check if we were called to attempt to default +# to remote logging +if [[ "$1" = "default" ]] ; then + printf "\nAttempting to locate remote syslog server..." + DEFAULT_SERVER=$(host -N 3 -t srv _syslog._udp | rev | awk '/VRS/ {print $1}' | cut -d. -f2- | rev) + DEFAULT_PORT=$(host -N 3 -t srv _syslog._udp | rev | awk '/VRS/ {print $2}' | cut -d. -f2- | rev) + if [[ "$DEFAULT_PORT" != "" ]] && [[ "$DEFAULT_SERVER" != "" ]] ; then + printf "found! Useing server '$DEFAULT_SERVER'.\n" + ovirt_rsyslog $DEFAULT_SERVER $DEFAULT_PORT "udp" + else + printf "not found!\n" + fi +else + prompt_user +fi + +exit 0 diff --git a/scripts/ovirt-config-setup b/scripts/ovirt-config-setup index 8408d14..5850aa8 100755 --- a/scripts/ovirt-config-setup +++ b/scripts/ovirt-config-setup @@ -2,6 +2,8 @@ # # Entry point for configuring an oVirt node when running in standalone mode. +#Attempt to default the syslog setting +ovirt-config-logging "default" while true; do PS3="Please select an option: " # TODO should we make this optional, based on whether the password was already set? -- 1.5.6.5