[node-patches] Change in ovirt-node[master]: cleanup: remove old unncessary bash scripts replaced by pyth...
jboggs at redhat.com
jboggs at redhat.com
Wed Oct 17 01:51:58 UTC 2012
Joey Boggs has uploaded a new change for review.
Change subject: cleanup: remove old unncessary bash scripts replaced by python ones
......................................................................
cleanup: remove old unncessary bash scripts replaced by python ones
Change-Id: I6560b1a51f6417eafbef0a24067710ed77ea1a00
Signed-off-by: Joey Boggs <jboggs at redhat.com>
---
M ovirt-node.spec.in
M scripts/Makefile.am
D scripts/ovirt-config-collectd
D scripts/ovirt-config-hostname
D scripts/ovirt-config-iscsi
D scripts/ovirt-config-kdump
D scripts/ovirt-config-logging
D scripts/ovirt-config-networking
D scripts/ovirt-config-rhn
D scripts/ovirt-config-view-logs
D scripts/ovirt-process-config
11 files changed, 0 insertions(+), 1,706 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/16/8616/1
diff --git a/ovirt-node.spec.in b/ovirt-node.spec.in
index 73a1955..5b643e5 100644
--- a/ovirt-node.spec.in
+++ b/ovirt-node.spec.in
@@ -290,18 +290,9 @@
%{dracutdir}/91ovirtnode/ovirt-cleanup.sh
%{_sysconfdir}/dracut.conf.d/ovirt-dracut.conf
%{_libexecdir}/ovirt-auto-install
-%{_libexecdir}/ovirt-config-hostname
-%{_libexecdir}/ovirt-config-iscsi
-%{_libexecdir}/ovirt-config-kdump
-%{_libexecdir}/ovirt-config-logging
-%{_libexecdir}/ovirt-config-networking
%{_libexecdir}/ovirt-config-password
-%{_libexecdir}/ovirt-config-rhn
-%{_libexecdir}/ovirt-config-storage
%{_libexecdir}/ovirt-config-uninstall
-%{_libexecdir}/ovirt-config-view-logs
%{_libexecdir}/ovirt-functions
-%{_libexecdir}/ovirt-process-config
%{_libexecdir}/ovirt-rpmquery
%{_libexecdir}/ovirt-config-installer
%{_libexecdir}/ovirt-config-setup
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index 154f5ad..8f50349 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -26,18 +26,9 @@
unpersist
dist_libexec_SCRIPTS = \
- ovirt-config-hostname \
- ovirt-config-iscsi \
- ovirt-config-kdump \
- ovirt-config-logging \
- ovirt-config-networking \
- ovirt-config-rhn \
ovirt-config-password \
- ovirt-config-storage \
ovirt-config-uninstall \
- ovirt-config-view-logs \
ovirt-functions \
- ovirt-process-config \
ovirt-rpmquery \
ovirt-init-functions.sh \
ovirt-config-installer.py \
diff --git a/scripts/ovirt-config-collectd b/scripts/ovirt-config-collectd
deleted file mode 100755
index af0770c..0000000
--- a/scripts/ovirt-config-collectd
+++ /dev/null
@@ -1,114 +0,0 @@
-#!/bin/bash
-#
-# Configures the collectd daemon.
-# Source functions library
-. /etc/init.d/functions
-. /usr/libexec/ovirt-functions
-
-trap '__st=$?; stop_log; exit $__st' 0
-trap 'exit $?' 1 2 13 15
-
-collectd_conf="/etc/collectd.conf"
-
-# Creates the collectd file based on the following inputs
-# $1 ipaddress of remote collectd server
-# $2 port of remote collectd server
-# TODO implement and use Augeas lens
-ovirt_collectd() {
- local collectd_server=$1
- local collectd_port=$2
-
- start_log
- if [ -f $collectd_conf.in ]; then
- sed -e "s/@COLLECTD_SERVER@/$collectd_server/" \
- -e "s/@COLLECTD_PORT@/$collectd_port/" $collectd_conf.in \
- > $collectd_conf
- if [ $? -ne 0 ]; then
- echo "Failed to write $collectd_conf"; return 1
- fi
- fi
-
- chkconfig collectd on
- service collectd restart
- stop_log
-}
-
-prompt_user() {
- while true ; do
- collectd_server_ip=""
- collectd_server_port=""
-
- read -p "Please enter the IP address for the collectd server: "
- if [ -n "$REPLY" ]; then
- collectd_server_ip=$REPLY
- while true; do
- read -p "Please enter the collectd port used: "
- r=$REPLY
- if [ -n "$r" ]; then
- if [[ $r =~ ^[0-9]+$ ]] && [[ $r -gt 0 ]]; then
- collectd_server_port=$REPLY
- break
- else
- printf "Invalid port.\n"
- fi
- fi
- done
- else
- printf "\nDisabling remote collectd.\n"
- fi
-
- printf "\n"
- printf "\nCollectd will be configured as follows:"
- printf "\n======================================"
- if [ -n "$collectd_server_ip" ]; then
- printf "\n Remote Server: $collectd_server_ip"
- printf "\n Remote Port: $collectd_server_port"
- fi
- printf "\n"
- printf "\n"
- while true; do
- ask_yes_or_no "Is this correct ([Y]es/[N]o/[A]bort)?" true true
- rc=$?
- case $rc in
- 0)
- printf "\nSaving configuration.\n"
- if [[ -n "$collectd_server_ip" ]] &&
- [[ -n "$collectd_server_port" ]]; then
- ovirt_collectd $collectd_server_ip \
- $collectd_server_port
- fi
- return
- ;;
-
- 1)
- printf "\nRestarting collectd configuration.\n"
- break
- ;;
- 2)
- printf "\nAborting collectd configuration.\n"
- return
- ;;
- esac
- done
- done
-}
-
-# AUTO for auto-install
-if [ "$1" = "AUTO" ]; then
- if [ -z "$OVIRT_COLLECTD_SERVER" -o -z "$OVIRT_COLLECTD_PORT" ]; then
- printf "\nAttempting to locate remote collectd server..."
- find_srv collectd udp
- if [ -n "$SRV_HOST" -a -n "$SRV_PORT" ]; then
- printf "found! Using collectd server '$SRV_HOST:$SRV_PORT'.\n"
- ovirt_collectd $SRV_HOST $SRV_PORT
- else
- printf "not found!\n"
- fi
- else
- printf "\nUsing default collectd server '$OVIRT_COLLECTD_SERVER:$OVIRT_COLLECTD_PORT'.\n"
- ovirt_collectd $OVIRT_COLLECTD_SERVER $OVIRT_COLLECTD_PORT
- fi
-else
- printf "\n\n Collectd Configuration\n\n"
- prompt_user
-fi
diff --git a/scripts/ovirt-config-hostname b/scripts/ovirt-config-hostname
deleted file mode 100755
index e302e3b..0000000
--- a/scripts/ovirt-config-hostname
+++ /dev/null
@@ -1,107 +0,0 @@
-#!/bin/bash
-#
-# Configures the hostname file based on kernel cmdline or user prompt
-# Source functions library
-. /etc/init.d/functions
-. /usr/libexec/ovirt-functions
-
-trap '__st=$?; stop_log; exit $__st' 0
-trap 'exit $?' 1 2 13 15
-
-warn() { printf '%s\n' "$*" >&2; }
-
-if ! is_local_storage_configured; then
- warn "Local storage must be configured prior to setting the hostname."
- exit 99
-fi
-
-HOSTNAME_FILE="/etc/sysconfig/network"
-
-function set_hostname {
- start_log
- augtool <<EOF
-set /files$HOSTNAME_FILE/HOSTNAME "$1"
-EOF
- rc=$?
- if [ $rc = 0 ]; then
- /bin/hostname "$1"
- rc=$?
- if [ $rc -eq 0 ]; then /usr/sbin/persist $HOSTNAME_FILE; fi
- fi
- stop_log
- return $rc
-}
-
-function remove_hostname {
- start_log
- augtool <<EOF
-rm /files$HOSTNAME_FILE/HOSTNAME
-EOF
- rc=$?
- stop_log
- return $rc
-}
-
-is_valid_hostname () {
- local host=${1}
- local result=1
- if [[ $host =~ ^([a-zA-Z0-9._-]+)$ ]]; then
- result=$?
- fi
- return $result
-}
-
-function prompt_user {
- rc=0
- while true; do
- printf "\n"
- read -p "What is the hostname for this node? "
-
- if [ -n "$REPLY" ]; then
- if ! is_valid_hostname "$REPLY"; then
- printf "\nInvalid Hostname\n"
- continue
- fi
- if set_hostname $REPLY; then
- printf "\nHostname has been set\n"
- else
- printf "\nSetting hostname failed\n"
- rc=1
- fi
- else
- printf "\n"
- ask_yes_or_no "Blank out the hostnames ([Y]es/[N]o)?"
- case $? in
- 0)
- if remove_hostname; then
- printf "\nHostname was removed.\n"
- else
- printf "\nRemoving hostname failed\n"
- rc=1
- fi
- ;;
- 1)
- printf "\nNo changes made.\n"
- ;;
- esac
- fi
- break
- done
- return $rc
-}
-
-# AUTO for auto-install
-if [ "$1" = "AUTO" ]; then
- if [ -n "$OVIRT_HOSTNAME" ]; then
- if set_hostname $OVIRT_HOSTNAME; then
- printf "\nHostname has been set\n"
- else
- printf "\nSetting hostname failed\n"
- fi
- else
- printf "\nHostname not provided. Skipping.\n"
- fi
-else
- printf "\n\n Hostname Configuration\n\n"
- prompt_user
-fi
diff --git a/scripts/ovirt-config-iscsi b/scripts/ovirt-config-iscsi
deleted file mode 100755
index eeaf8b0..0000000
--- a/scripts/ovirt-config-iscsi
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/bin/bash
-#
-# Configures the hostname file based on kernel cmdline or user prompt
-# Source functions library
-. /etc/init.d/functions
-. /usr/libexec/ovirt-functions
-
-trap '__st=$?; stop_log; exit $__st' 0
-trap 'exit $?' 1 2 13 15
-
-warn() { printf '%s\n' "$*" >&2; }
-
-if ! is_local_storage_configured; then
- warn "Local storage must be configured prior to setting the iSCSI Initiator Name."
- exit 99
-fi
-
-INITIATOR_FILE="/etc/iscsi/initiatorname.iscsi"
-
-function prompt_user {
- printf "\n"
- printf "Enter iSCSI Initiator Name (If blank one will be automatically generated)\n"
- printf "Enter Q to quit\n"
- read REPLY
- if [[ $REPLY == "q" || $REPLY == "Q" ]]; then
- printf "Aborting due to user request"
- return
- fi
-
- set_initiator $REPLY
-}
-
-function set_initiator {
- if [ -z "$1" ]; then
- INITIATOR_NAME=$(iscsi-iname)
- else
- INITIATOR_NAME=$1
- fi
-
- echo "InitiatorName=$INITIATOR_NAME" > $INITIATOR_FILE
- ovirt_store_config $INITIATOR_FILE
- rc=$?
- if [ $rc = 0 ]; then
- printf "Initiator name set as: $INITIATOR_NAME\n"
- else
- printf "Setting initiator name failed\n"
- fi
-}
-
-# AUTO for auto-install
-if [ "$1" = "AUTO" ]; then
- set_initiator $OVIRT_ISCSI_NAME
-else
- printf "\n\n iSCSI Initiator Configuration\n\n"
- prompt_user
-fi
diff --git a/scripts/ovirt-config-kdump b/scripts/ovirt-config-kdump
deleted file mode 100755
index f26863c..0000000
--- a/scripts/ovirt-config-kdump
+++ /dev/null
@@ -1,109 +0,0 @@
-#!/bin/bash
-#
-# Configure kdump
-# Source functions library
-. /etc/init.d/functions
-. /usr/libexec/ovirt-functions
-
-trap '__st=$?; stop_log; exit $__st' 0
-trap 'exit $?' 1 2 13 15
-
-warn() { printf '%s\n' "$*" >&2; }
-
-check() {
-if ! is_local_storage_configured; then
- warn "Configure local storage before configuring kdump."
- exit 99
-fi
-if ! network_up; then
- warn "Configure network before configuring kdump."
- exit 99
-fi
-}
-
-function write_kdump_config {
- cat > /etc/kdump.conf <<EOF
-default reboot
-net $1
-EOF
- ovirt_store_config /etc/kdump.conf
- return 0
-}
-
-function kdump_confirm {
-
- local server=$1
- local server_type=$2
-
- printf "\nkdump $server_type Configuration\n"
- printf "\n$server_type: $server \n\n"
- if ask_yes_or_no "Confirm these values ([Y]es/[N]o)?"; then
- write_kdump_config $server
- if [ $server_type = "SSH" ]; then
- # /dev/console is occupied by firstboot, need to make /dev/tty available
- rm -rf /dev/tty
- ln -s /dev/console /dev/tty
- service kdump propagate
- fi
- service kdump restart
- fi
-
-}
-
-function nfs_config {
- nfs_server=""
- printf "\n"
- read -p "Enter nfs server path (example.redhat.com:/var/crash): " -er
- test -z "$REPLY" && return 1
- nfs_server="$REPLY"
- kdump_confirm $nfs_server NFS
-}
-
-
-function ssh_config {
- ssh_login=""
- printf "\n"
- read -p "Enter ssh user/hostname (root at example.redhat.com): " -er
- test -z "$REPLY" && return 1
- ssh_login="$REPLY"
- kdump_confirm $ssh_login SSH
-}
-
-function restore_config {
- cat > /etc/kdump.conf <<\EOF
-default reboot
-ext4 /dev/HostVG/Data
-path /core
-EOF
- ovirt_store_config /etc/kdump.conf
- service kdump restart
-}
-
-NFS="Setup NFS Configuration"
-SSH="Setup SSH Configuration"
-RESTORE="Restore Default Configuration"
-QUIT="Return to the Hypervisor Configuration Menu"
-
-if [ "$1" = "AUTO" ]; then
- if [ -n "$OVIRT_KDUMP_NFS" ]; then
- write_kdump_config $OVIRT_KDUMP_NFS
- fi
-else
- check
- printf "\n\n kdump Configuration\n\n"
- while true; do
- PS3="Choose an option: "
- select option in "$NFS" "$SSH" "$RESTORE" "$QUIT"
- do
-
- case $option in
- $NFS) nfs_config; break;;
- $SSH) ssh_config; break;;
- $RESTORE) restore_config; break;;
- $QUIT) exit;;
- esac
- done
-
- printf "\n"
- done
-fi
diff --git a/scripts/ovirt-config-logging b/scripts/ovirt-config-logging
deleted file mode 100755
index e296ac4..0000000
--- a/scripts/ovirt-config-logging
+++ /dev/null
@@ -1,206 +0,0 @@
-#!/bin/bash
-#
-# Configures the rsyslog daemon.
-# Source functions library
-. /etc/init.d/functions
-. /usr/libexec/ovirt-functions
-
-trap '__st=$?; stop_log; exit $__st' 0
-trap 'exit $?' 1 2 13 15
-
-if ! is_local_storage_configured; then
- printf "Local storage must be configured prior to configuring the logging system.\n"
- exit 99
-fi
-
-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)
-# TODO implement and use Augeas lens
-function ovirt_rsyslog {
-
-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/spool/rsyslog
-\$ActionQueueFileName ovirtNode
-\$ActionQueueMaxDiskSpace 10m
-\$ActionQueueSaveOnShutdown on
-\$ActionQueueType LinkedList
-\$ActionResumeRetryCount -1
-*.* $DELIM$1:$2
-EOF
-
-start_log
-/sbin/service rsyslog restart
-stop_log
-}
-
-function is_numeric {
- printf "$1" | grep -q -E '^[0-9]+$'
-}
-
-function prompt_user {
- while true ; do
- max_log_size="1024"
- syslog_server_ip=""
- syslog_server_port=""
-
- while true; do
- printf "\n"
- read -p "What is the max size, in kilobytes, for local log files (def. ${max_log_size}k)? "
-
- if [ -n "$REPLY" ]; then
- r=$REPLY
- if [[ $r =~ ^[0-9]+$ ]] && [[ $r -gt 0 ]]; then
- max_log_size=$r
- printf "\nMaximum logging size will be ${max_log_size}k.\n"
- break
- else
- printf "\nInvalid input.\n"
- fi
- else
- printf "\nLeaving log size as ${max_log_size}k.\n"
- break
- fi
- done
-
- printf "\n"
- read -p "What is the IP address for the syslog server, hit Enter to skip? "
- if [ -n "$REPLY" ]; then
- syslog_server_ip=$REPLY
- while true; do
- read -p "Please enter the remote logging port used: "
- r=$REPLY
- if [ -n "$r" ]; then
- if [[ $r =~ ^[0-9]+$ ]] && [[ $r -gt 0 ]]; then
- syslog_server_port=$REPLY
- break
- else
- printf "Invalid port.\n"
- fi
- fi
- done
-
- printf "\n"
- while true; do
- read -p "Remote logging uses [t]cp or [u]dp? "
- r=$(echo $REPLY|tr '[[:lower:]]' '[[:upper:]]')
- if [ "$r" == "T" ]; then syslog_server_protocol="tcp"; break; fi
- if [ "$r" == "U" ]; then syslog_server_protocol="udp"; break; fi
- # else
- printf "Invalid input.\n"
- done
- else
- printf "\nDisabling remote logging.\n"
- fi
-
- printf "\n"
- printf "\nLogging will be configured as follows:"
- printf "\n======================================"
- printf "\n Max Logfile Size: $max_log_size"
- if [ -n "$syslog_server_ip" ]; then
- printf "\n Remote Server: $syslog_server_ip"
- printf "\n Remote Port: $syslog_server_port"
- printf "\n Logging Protocol: $syslog_server_protocol"
- fi
- printf "\n"
- printf "\n"
- while true; do
- ask_yes_or_no "Is this correct ([Y]es/[N]o/[A]bort)?" true true
- case $? in
- 0)
- printf "\nSaving configuration.\n"
- if [[ -n "$syslog_server_ip" ]] &&
- [[ -n "$syslog_server_port" ]] &&
- [[ -n "$syslog_server_protocol" ]]; then
- ovirt_rsyslog $syslog_server_ip \
- $syslog_server_port \
- $syslog_server_protocol
- fi
- sed -c -i -e "s/size.*/size ${max_log_size}k/" \
- /etc/logrotate.d/ovirt-node
- return
- ;;
- 1)
- printf "\nRestarting logging configuration.\n"
- break
- ;;
- 2)
- printf "\nAborting logging configuration.\n"
- return
- ;;
- esac
- done
- done
-}
-
-function ovirt_netconsole {
- augtool <<EOF
-set /files/etc/sysconfig/netconsole/SYSLOGADDR $OVIRT_NETCONSOLE_SERVER
-set /files/etc/sysconfig/netconsole/SYSLOGPORT $OVIRT_NETCONSOLE_PORT
-EOF
- ovirt_store_config /etc/sysconfig/netconsole
-}
-# AUTO for auto-install
-if [ "$1" = "AUTO" ]; then
- if [ -z "$OVIRT_SYSLOG_SERVER" -o -z "$OVIRT_SYSLOG_PORT" ]; then
- printf "\nAttempting to locate remote syslog server..."
- find_srv syslog udp
- if [ -n "$SRV_HOST" -a -n "$SRV_PORT" ]; then
- printf "found! Using syslog server '$SRV_HOST:$SRV_PORT'.\n"
- ovirt_rsyslog $SRV_HOST $SRV_PORT udp
- else
- printf "not found!\n"
- fi
- else
- printf "\nUsing default syslog server '$OVIRT_SYSLOG_SERVER:$OVIRT_SYSLOG_PORT'.\n"
- ovirt_rsyslog $OVIRT_SYSLOG_SERVER $OVIRT_SYSLOG_PORT udp
- fi
- if [ -n "$OVIRT_NETCONSOLE_SERVER" -a -n "$OVIRT_NETCONSOLE_PORT" ]; then
- printf "\nConfiguring netconsole server..."
- ovirt_netconsole
- fi
-else
- printf "\n\n Logging Configuration\n\n"
- prompt_user
-fi
diff --git a/scripts/ovirt-config-networking b/scripts/ovirt-config-networking
deleted file mode 100755
index 116159e..0000000
--- a/scripts/ovirt-config-networking
+++ /dev/null
@@ -1,622 +0,0 @@
-#!/bin/bash
-#
-# Iterates over the list of network devices on the node and prompts the user
-# to configure each.
-
-. /usr/libexec/ovirt-functions
-
-ME=$(basename "$0")
-warn() { printf '%s: %s\n' "$ME" "$*" >&2; }
-die() { warn "$*"; exit 1; }
-
-WORKDIR=$(mktemp -d) || exit 1
-
-# Remove $WORKDIR upon interrupt (and HUP, PIPE, TERM) and upon normal
-# termination, being careful not to change the exit status.
-trap '__st=$?; rm -rf "$WORKDIR"; stop_log; exit $__st' 0
-trap 'exit $?' 1 2 13 15
-
-IFCONFIG_FILE_ROOT="/files/etc/sysconfig/network-scripts/ifcfg"
-NTPCONF_FILE_ROOT="/files/etc/ntp"
-NTP_CONFIG_FILE="/etc/ntp.conf"
-NTPSERVERS=""
-CONFIGURED_NIC=""
-CONFIGURED_NICS=""
-VLAN_ID=""
-VL_ROOT=""
-
-if [[ -z "$ROOTDRIVE" && "$OVIRT_ISCSI_ENABLED" != "y" ]]; then
-# if local storage is not configured, then exit the script
- if [[ ! is_local_storage_configured && "$OVIRT_ISCSI_NETWORKING" != "y" ]] ; then
- printf "Local storage must be configured prior to configuring the management interface.\n\n"
- exit 99
- fi
-fi
-
-# $1 - the variable name to set
-# $2 - the input prompt
-function input_ipv4_address {
- local varname=$1
- local prompt=$2
-
- eval $varname=\"\"
-
- while true; do
- read -ep "${prompt}: "
-
- if [ -z "$REPLY" ]; then return; fi
-
- if is_valid_ipv4 $REPLY; then
- eval $varname=\"$REPLY\"
- return
- else
- printf "\nThe address $REPLY is not a valid IPv4 address.\n"
- fi
- done
-}
-
-# Checks that a network interface was already configured.
-function has_configured_interface
-{
- local show_message=${1-false}
-
- if [[ -n "${CONFIGURED_NIC}" ]]; then
- return 0
- else
- if $show_message; then
- printf "\nYou must configure a network interface first.\n\n"
- fi
- return 1
- fi
-}
-
-# Configures vlan for the node.
-# $1 - the nic
-# $2 - the network bridge name
-# $3 - the vlan id
-# $4 - the VL_ROOT variable
-# $5 - the VL_CONFIG variable
-# $6 - the IF_ROOT value
-# $7 - the vlan config filename variable
-# $8 - the NIC config filename
-function setup_vlan
-{
- local nic=$1
- local bridge=$2
- local vlan_id=$3
- local vlroot=$4
- local vlconfig=$5
- local ifroot=$6
- local vlfilename=$7
- local iffilename=$8
-
- eval $vlroot="${ifroot}.${vlan_id}"
- eval $vlconfig=\"rm \$${vlroot}\\nset \$${vlroot}/DEVICE ${nic}.${vlan_id}\"
- eval $vlconfig=\"\$${vlconfig}\\nset \$${vlroot}/BRIDGE ${bridge}\"
- eval $vlconfig=\"\$${vlconfig}\\nset \$${vlroot}/VLAN yes\"
- eval $vlfilename="${iffilename}.${vlan_id}"
-}
-
-function configure_interface
-{
- local NIC=$1
- local AUTO=$2
- if [[ "$AUTO" == "AUTO" &&
- -n "$OVIRT_IP_ADDRESS" ]]; then
- IPADDR=$OVIRT_IP_ADDRESS
- NETMASK=$OVIRT_IP_NETMASK
- GATEWAY=$OVIRT_IP_GATEWAY
- PREFIX=$OVIRT_IP_PREFIX
- fi
-
- if has_configured_interface; then
- printf "This will delete the current configuration for ${CONFIGURED_NIC}.\n"
- if ask_yes_or_no "Do you wish to continue ([Y]es/[N]o)?"; then
- printf "\nDeleting existing network configuration...\n"
- cp -a /etc/sysconfig/network-scripts/ifcfg-lo /etc/sysconfig/network-scripts/backup.lo
- remove_config /etc/sysconfig/network-scripts/ifcfg-*
- rm -rf /etc/sysconfig/network-scripts/ifcfg-*
- cp -a /etc/sysconfig/network-scripts/backup.lo /etc/sysconfig/network-scripts/ifcfg-lo
- else
- printf "\nAborting...\n"
- return
- fi
- fi
-
- rm -rf $WORKDIR/*
- CONFIGURED_NIC=$NIC
-
- local BRIDGE=br$NIC
- local IF_FILENAME="$WORKDIR/augtool-$NIC"
- local BR_FILENAME="$WORKDIR/augtool-$BRIDGE"
-
- printf "\nConfigure $BRIDGE for use by $NIC..\n\n"
-
- local IF_ROOT="$IFCONFIG_FILE_ROOT-$NIC"
- local IF_CONFIG="rm $IF_ROOT\nset $IF_ROOT/DEVICE $NIC"
-
- local BR_ROOT="$IFCONFIG_FILE_ROOT-$BRIDGE"
- local BR_CONFIG="rm $BR_ROOT\nset $BR_ROOT/DEVICE $BRIDGE"
-
- BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/TYPE Bridge"
- BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/PEERNTP yes"
- BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/DELAY 0"
- local BR_CONFIG_BASE=$BR_CONFIG
-
- if [ -z "$AUTO" ]; then
- while true; do
- local VL_CONFIG=""
-
- printf "\n"
- LINK=`ethtool $NIC| grep "Link detected"`:u
- [ -z "$LINK" ] && return
- if echo $LINK | grep -q "Link detected: yes" ; then
- NICSTATUS="ACTIVE"
- else
- NICSTATUS="INACTIVE"
- fi
- echo "NIC is: $NICSTATUS"
-
- if ask_yes_or_no "Help identify ${NIC} by blinking lights for 10 seconds ([Y]es/[N]o)?"; then
- ethtool --identify $NIC 10
- fi
-
- ask_yes_or_no "Include VLAN support ([Y]es/[N]o/[A]bort)? " true true
- case $? in
- 0)
- while true; do
- read -ep "What is the VLAN ID for this device (a=abort) "
- case $REPLY in
- A|a) CONFIGURED_NIC=""; return;;
- *)
- if [[ -n "$REPLY" ]] && [[ "$REPLY" =~ ^[0-9]{1,}$ ]]; then
- VLAN_ID=$REPLY
- setup_vlan $NIC $BRIDGE $VLAN_ID VL_ROOT VL_CONFIG $IF_ROOT VL_FILENAME $IF_FILENAME
- break
- fi
- ;;
- esac
- done
- ;;
- 1) IF_CONFIG="${IF_CONFIG}\nset ${IF_ROOT}/BRIDGE ${BRIDGE}" ;;
- 2)
- CONFIGURED_NIC=""
- VLAN_ID=""
- return;;
- esac
-
- while true; do
- read -ep "Enable IPv4 support ([S]tatic IP, [D]HCP, [N]o or [A]bort)? "
- case $REPLY in
- D|d)
- BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/BOOTPROTO dhcp"
- break
- ;;
- S|s)
- printf "\n"
- input_ipv4_address IPADDR "IP Address"
- input_ipv4_address NETMASK " Netmask"
- input_ipv4_address GATEWAY " Gateway"
-
- BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/BOOTPROTO none"
- BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPADDR $IPADDR"
- BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/NETMASK $NETMASK"
- if [ -n "${GATEWAY}" ]; then
- BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/GATEWAY $GATEWAY"
- fi
- break
- ;;
- A|a)
- CONFIGURED_NIC=""
- VLAN_ID=""
- return
- ;;
- N|n)
- break
- ;;
-
- esac
- done
-
- printf "\n"
-
- while true; do
- read -ep "Enable IPv6 support ([S]tatic, [D]HCPv6, A[u]to, [N]o or [A]bort)? "
- case $REPLY in
- S|s)
- read -ep "IPv6 Address: "; IPADDR=$REPLY
- BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6INIT yes"
- BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6ADDR $IPADDR"
- break
- ;;
- D|d)
- BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6INIT yes"
- BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6AUTCONF no"
- BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6FORWARDING no"
- BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/DHCPV6C yes"
- break
- ;;
- U|u)
- BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6INIT yes"
- BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6FORWARDING no"
- BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6AUTOCONF yes"
- break
- ;;
- A|a)
- CONFIGURED_NIC=""
- VLAN_ID=""
- return
- ;;
- N|n)
- break
- ;;
-
- esac
- done
-
- printf "\n"
- ask_yes_or_no "Is this correct ([Y]es/[N]o/[A]bort)?" true true
- case $? in
- 0)
- IF_CONFIG="$IF_CONFIG\nset $IF_ROOT/ONBOOT yes"
- BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/ONBOOT yes"
- if [[ -n "$VLAN_ID" ]]; then
- VL_CONFIG="$VL_CONFIG\nset $VL_ROOT/ONBOOT yes"
- fi
- printf "$IF_CONFIG\n" > $IF_FILENAME
- printf "$BR_CONFIG\n" > $BR_FILENAME
- if [[ -n "$VLAN_ID" ]]; then
- printf "$VL_CONFIG\n" > $VL_FILENAME
- fi
- break
- ;;
- 1)
- BR_CONFIG=$BR_CONFIG_BASE
- ;;
- 2)
- CONFIGURED_NIC=""
- VLAN_ID=""
- return
- ;;
- esac
- done
- else
- if [ -n "$OVIRT_IPV6" ]; then
- case "$OVIRT_IPV6" in
- "auto")
- BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6INIT yes"
- BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6FORWARDING no"
- BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6_AUTOCONF yes"
- ;;
- "dhcp")
- BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6INIT yes"
- BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6_AUTOCONF no"
- BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6FORWARDING no"
- BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/DHCPV6C yes"
- ;;
- *)
- BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6INIT yes"
- BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6ADDR $OVIRT_IPV6"
- BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6_AUTOCONF no"
- BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6FORWARDING no"
- esac
- fi
-
- if [ -n "$OVIRT_VLAN" ]; then
- VLAN_ID=$OVIRT_VLAN
- setup_vlan $NIC $BRIDGE $VLAN_ID VL_ROOT VL_CONFIG $IF_ROOT VL_FILENAME $IF_FILENAME
- fi
-
- if [ -z "$OVIRT_IP_ADDRESS" ]; then
- if [ -z "$VL_CONFIG" ]; then
- IF_CONFIG="${IF_CONFIG}\nset ${IF_ROOT}/BRIDGE ${BRIDGE}"
- fi
- BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/BOOTPROTO dhcp"
- else
- if [ "$OVIRT_IP_ADDRESS" != "off" ]; then
- if [ -z "$VL_CONFIG" ]; then
- IF_CONFIG="${IF_CONFIG}\nset ${IF_ROOT}/BRIDGE ${BRIDGE}"
- fi
- BR_CONFIG="${BR_CONFIG}\nset ${BR_ROOT}/BOOTPROTO static"
- BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPADDR $OVIRT_IP_ADDRESS"
- if [ -n "$OVIRT_IP_NETMASK" ]; then
- BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/NETMASK $OVIRT_IP_NETMASK"
- fi
- if [ -n "$OVIRT_IP_GATEWAY" ]; then
- BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/GATEWAY $OVIRT_IP_GATEWAY"
- fi
- fi
- fi
-
- IF_CONFIG="$IF_CONFIG\nset $IF_ROOT/ONBOOT yes"
- BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/ONBOOT yes"
- if [ -n "${VL_CONFIG}" ]; then
- VL_CONFIG="$VL_CONFIG\nset $VL_ROOT/ONBOOT yes"
- fi
-
- printf "$IF_CONFIG\n" > $IF_FILENAME
- printf "$BR_CONFIG\n" > $BR_FILENAME
- if [ -n "$VL_CONFIG" ]; then
- printf "$VL_CONFIG\n" > $VL_FILENAME
- fi
- fi
-}
-
-function configure_dns
-{
- local DNS=$1
- local AUTO=$2
- if [[ "$AUTO" == "AUTO" &&
- -n "$OVIRT_DNS" ]]; then
- DNS=$OVIRT_DNS
- fi
-
- local IF_FILENAME="$WORKDIR/augtool-br${CONFIGURED_NIC}"
- local IF_ROOT="$IFCONFIG_FILE_ROOT-br${CONFIGURED_NIC}"
- local IF_CONFIG=
-
- if [ -z "$AUTO" ]; then
- if has_configured_interface true; then
- while true; do
- for dns in first second; do
- while true; do
- printf "\n"
- read -erp "Please enter the ${dns} DNS server (or ENTER to exit): "
- local ADDRESS=$(trim_whitespace $REPLY)
- if [[ -z "${ADDRESS}" ]]; then
- if [[ -z "${DNS}" ]]; then
- printf "\nAborted...\n"
- return
- else
- break
- fi
- fi
- if is_valid_ipv4 $ADDRESS; then
- if [[ -z "${DNS}" ]]; then
- DNS="${ADDRESS}"
- break
- elif [[ -n "${ADDRESS}" ]]; then
- if [[ ! $DNS =~ "${ADDRESS}" ]]; then
- DNS="${DNS}:${ADDRESS}"
- break
- else
- printf "${ADDRESS} is already defined as a DNS server.\n"
- fi
- fi
- else
- printf "${ADDRESS} is an invalid address.\n"
- fi
- done
- done
-
- printf "\n"
- ask_yes_or_no "Is this correct ([Y]es/[N]o/[A]bort)?" true true
- case $? in
- 0) break ;;
- 1) DNS="";;
- 2) return ;;
- esac
- done
- fi
- fi
-
- if [ -n "$DNS" ]; then
- DNS1=$(echo "$DNS" | awk -F\: '{print $1}')
- DNS2=$(echo "$DNS" | awk -F\: '{print $2}')
-
- test -n "$DNS1" && printf "set $IF_ROOT/DNS1 $DNS1\n" >> $IF_FILENAME
- test -n "$DNS2" && printf "set $IF_ROOT/DNS2 $DNS2\n" >> $IF_FILENAME
- fi
-}
-
-function configure_ntp
-{
- local AUTO=$2
- if [[ "$AUTO" == "AUTO" && -n "$OVIRT_NTP" ]]; then
- NTPSERVERS=$OVIRT_NTP
- else
- NTPSERVERS=""
- fi
-
- if [ -z "$AUTO" ]; then
- if has_configured_interface true; then
- while true; do
- read -rp "Enter an NTP server (hit return when finished): "
- local ADDRESS=$(trim_whitespace $REPLY)
-
- if [ -z "${ADDRESS}" ]; then break; fi
- if is_valid_ipv4 $ADDRESS; then
- if [[ ! $NTPSERVERS =~ $ADDRESS ]]; then
- NTPSERVERS="${NTPSERVERS}:${ADDRESS}"
- else
- printf "${ADDRESS} is already defined as an NTP server.\n"
- fi
- else
- printf "${ADDRESS} is an invalid address.\n"
- fi
- done
- fi
- fi
-}
-
-function save_ntp_configuration
-{
- local ntpconf="$WORKDIR/augtool-ntp"
- local ntproot="/files/etc/ntp.conf"
-
- printf "\
-rm ${ntproot}\n\
-set ${ntproot}/driftfile /var/lib/ntp/drift\n\
-set ${ntproot}/includefile /etc/ntp/crypto/pw\n\
-set ${ntproot}/keys /etc/ntp/keys\n\
-" > $ntpconf
-
- if [ -n "$NTPSERVERS" ]; then
- offset=1
- SERVERS=$(echo $NTPSERVERS | awk 'BEGIN{FS=":"}{for (i=1; i<=NF; i++) print $i}')
- for server in $SERVERS; do
- printf "set /files/etc/ntp.conf/server[${offset}] ${server}\n" >> $ntpconf
- offset=$(echo "$offset+1" | bc)
- done
- fi
-}
-
-function setup_menu
-{
- NICS=""
- nics=$(ls -bd /sys/class/net/*)
- for nic in $nics; do
- nic=$(basename $nic)
- address=$(systool -c net -d $nic -A address | awk '/address\ += "(.*)"/ { print $3; }')
- if [[ ! "$address" =~ '00:00:00:00' ]]; then
- NICS="$NICS $nic"
- fi
- done
-
- # Add virtio NICs that were possibly not detected by other means
- NICS="$(ifconfig -a | awk '/Ethernet/ {print $1}'|xargs)"
- NICS=$(echo $NICS | tr ' ' '\n' | sort -u | xargs)
-
- PS3="Please select an interface or configuration option: "
-}
-
-if [ "$1" == "AUTO" ]; then
- if [ -n "$OVIRT_BOOTIF" ]; then
- configure_interface "$OVIRT_BOOTIF" AUTO
- configure_dns "$OVIRT_DNS" AUTO
- configure_ntp "$OVIRT_NTP" AUTO
- else
- printf "No network interface specified. Unable to configure networking."
- exit 0
- fi
-else
- setup_menu
-
- while true; do
- printf "\n\nManagement Network Configuration\n\n" >&2
- printf "***** WARNING *****\n"
- printf "Configuring the network will destroy any existing networking\n"
- printf "configuration on this system.\n"
- printf "***** WARNING *****\n"
- printf "\nPhysical Networking Devices (*=PXE boot interface)\n"
- printf " %-10s %-12s %-18s\n" "Name" "Driver" "MAC"
- PHY_NICS=""
- for nic in $NICS; do
- driver=$(basename $(readlink /sys/class/net/$nic/device/driver) 2>/dev/null)
- mac=$(cat /sys/class/net/$nic/address)
- if [ "$nic" = "$OVIRT_BOOTIF" ]; then
- pxe="*"
- else
- pxe=" "
- fi
- if [ -n "$driver" ]; then
- PHY_NICS="$PHY_NICS $nic"
- printf "%s%-10s %-12s %-18s\n" "$pxe" "$nic" "$driver" "$mac"
- fi
- done
-
- DNS="DNS"
- NTP="NTP"
- Abort="Abort"
- Save="Save And Return To Menu"
- select NIC in $PHY_NICS "$DNS" "$NTP" "$Abort" "$Save"
- do
- printf "\n"
- case "$NIC" in
- "$DNS") configure_dns "$OVIRT_DNS"; break ;;
- "$NTP") configure_ntp "$OVIRT_NTP"; break ;;
- "$Abort") rm -f "${WORKDIR}"/augtool-*; exit 99;;
- "$Save")
- save_ntp_configuration
- break 2;;
- *)
- if [[ -n "${NIC}" ]] && [[ "${NICS}" =~ "${NIC}" ]]; then
- configure_interface $NIC $IFACE_NUMBER
- else
- printf "\nInvalid option selected.\n"
- fi
- break
- ;;
- esac
- done
- done
-fi
-
-start_log
-net_configured=0
-if ls "$WORKDIR"/augtool-* > /dev/null 2>&1 ; then
- log "Configuring network"
-
- # delete existing scripts
- for vlan in /proc/net/vlan/*; do
- if [[ ! "${vlan}" =~ config ]]; then
- vlan=$(echo $vlan|awk -F "/" {'print $5'})
- vconfig rem $vlan
- fi
- done
-
- for script in /etc/sysconfig/network-scripts/ifcfg-*; do
- if [[ ! "${script}" =~ ifcfg-lo ]]; then
- ovirt_safe_delete_config $script
- fi
- done
-
- config="$WORKDIR"/config-augtool
- cat "$WORKDIR"/augtool-* > $config
- echo "set /files/etc/sysconfig/network/NETWORKING yes" >> $config
- CONFIGURED_NICS="$CONFIGURED_NIC br$CONFIGURED_NIC"
- if [ -n "${VLAN_ID}" ]; then
- CONFIGURED_NICS="$CONFIGURED_NICS $CONFIGURED_NIC.$VLAN_ID"
- fi
- # preserve current MAC mappings for *all physical* network interfaces
- # to avoid dev$RANDOM rhbz#489927
- for nic in $(ls -d /sys/class/net/*/device|cut -d/ -f5) ; do
- mac=$(cat /sys/class/net/$nic/address)
- if [ -n "$nic" -a -n "$mac" ]; then
- if_root="$IFCONFIG_FILE_ROOT-$nic"
- printf "\nset $if_root/DEVICE $nic" >> $config
- # store the hwaddr field in both, physical and vlan ifcfg if vlan is used
- if [ -n "${VLAN_ID}" -a "$nic" = "${CONFIGURED_NIC}" ]; then
- printf "\nset $if_root/HWADDR $mac" >> $config
- printf "\n" >> $config
- if_root="${VL_ROOT}"
- fi
- if [ ${CONFIGURED_NIC} != $nic ]; then
- printf "\nset $if_root/ONBOOT no" >> $config
- CONFIGURED_NICS="$CONFIGURED_NICS $nic"
- fi
- printf "\nset $if_root/HWADDR $mac" >> $config
- printf "\n" >> $config
- fi
- done
- cp $config /tmp/augconfig
- augtool $config
- if [ $? = 0 ]; then
- log "Network configured successfully"
- net_configured=1
- for nic in $CONFIGURED_NICS; do
- ovirt_store_config /etc/sysconfig/network-scripts/ifcfg-$nic
- done
- ovirt_store_config $NTP_CONFIG_FILE
- else
- log "Error configuring network, see $OVIRT_LOGFILE"
- stop_log
- exit 1
- fi
-fi
-stop_log
-
-if [ "$net_configured" = 1 ]; then
- service network stop > /dev/null 2>&1
- # XXX eth assumed in breth
- for i in `brctl show | grep breth | awk '{print $1}'`
- do
- ifconfig $i down
- brctl delbr $i
- done
- service network start 2> /dev/null
- if [ $NTPSERVERS ]; then
- log "Testing NTP Configuration"
- test_ntp_configuration
- fi
-fi
diff --git a/scripts/ovirt-config-rhn b/scripts/ovirt-config-rhn
deleted file mode 100644
index ff14f6c..0000000
--- a/scripts/ovirt-config-rhn
+++ /dev/null
@@ -1,337 +0,0 @@
-#!/bin/bash
-#
-# Register system to RHN
-# Source functions library
-. /etc/init.d/functions
-. /usr/libexec/ovirt-functions
-
-trap '__st=$?; stop_log; exit $__st' 0
-trap 'exit $?' 1 2 13 15
-
-warn() { printf '%s\n' "$*" >&2; }
-
-check() {
-if ! is_local_storage_configured; then
- warn "Configure local storage before registering to RHN."
- exit 99
-fi
-if ! network_up; then
- warn "Configure network before registering to RHN."
- exit 99
-fi
-}
-
-# Usage: rhnreg_ks ARGS
-# $1 - serverUrl
-# $2 - CaCert
-# $3 - activationkey
-# $4 - username
-# $5 - password
-# $6 - profilename
-function run_rhnreg {
-
- local serverUrl=$1
- local CaCert=$2
- local activationkey=$3
- local userName=$4
- local passWord=$5
- local profileName=$6
- local proxyuser=$7
- local proxypass=$8
- local proxyhost=$9
-
- # have to run with novirtinfo b/c vdsm is not running before
- # rhevm registration
- # after reboot, rhn-virtualization daemon should refresh virtinfo
- extra_args="--novirtinfo --norhnsd --nopackages --force"
- args=""
-
- # Get CaCert location
- if [ -n "$serverUrl" ]; then
- args="$args --serverUrl $serverUrl/XMLRPC"
- if [ -z "$CaCert" ]; then
- CaCert="$serverUrl/pub/RHN-ORG-TRUSTED-SSL-CERT"
- fi
- cert=$(echo $CaCert | awk -F/ '{print $NF}')
- location="/etc/sysconfig/rhn/$cert"
- log "Downloading Satellite CA cert....."
- log "From: $CaCert To: $location"
- wget -q -r -nd --no-check-certificate --timeout=30 --tries=3 -O "$location" "$CaCert"
- if [ -s "${location}" ]; then
- args="${args} --sslCACert $location"
- ovirt_store_config $location
- else
- log "Error Downloading Satellite CA cert!"
- return 1
- fi
- else
- serverUrl="https://xmlrpc.rhn.redhat.com/XMLRPC"
- location="/usr/share/rhn/RHNS-CA-CERT"
- args="${args} --serverUrl $serverUrl --sslCACert $location"
- fi
-
- if [ -n "$activationkey" ]; then
- args="${args} --activationkey $activationkey"
- elif [ -n "$userName" ]; then
- args="${args} --username $userName"
- if [ -n "$passWord" ]; then
- args="${args} --password $passWord"
- fi
- else
- # skip RHN registration when neither activationkey
- # nor username/password is supplied
- # return success for AUTO w/o rhn_* parameters
- return 0
- fi
-
- if [ -n "$profileName" ]; then
- args="${args} --profilename $profileName"
- fi
-
- if [ -n "$proxyhost" ]; then
- args="${args} --proxy=$proxyhost"
- if [ -n "$proxyuser" ]; then
- args="${args} --proxyUser=$proxyuser"
- if [ -n "$proxypass" ]; then
- args="${args} --proxyPassword=$proxypass"
- fi
- fi
- fi
-
- if [ -n "$extra_args" ]; then
- args="${args} $extra_args"
- fi
-
- log "Registering to RHN account....."
-
- unmount_config /etc/sysconfig/rhn/systemid
- unmount_config /etc/sysconfig/rhn/up2date
- # regenerate up2date config
- rm -rf /etc/sysconfig/rhn/up2date
- if rhnreg_ks $args; then
- ovirt_store_config \
- /etc/sysconfig/rhn/up2date \
- /etc/sysconfig/rhn/systemid
- log "System "$profileName" sucessfuly registered "$serverUrl""
- return 0
- else
- log "Error registering to RHN account!"
- return 1
- fi
-}
-
-function run_rhsm {
-
- local serverUrl=$1
- local CaCert=$2
- local activationkey=$3
- local userName=$4
- local passWord=$5
- local profileName=$6
- local proxyuser=$7
- local proxypass=$8
- local proxyhost=$9
-
- extra_args="--force --autosubscribe"
- args=""
-
- if [ -n "$activationkey" ]; then
- args="${args} --activationkey=$activationkey"
- elif [ -n "$userName" ]; then
- args="${args} --username=$userName"
- if [ -n "$passWord" ]; then
- args="${args} --password=$passWord"
- fi
- else
- # skip RHSM registration when neither activationkey
- # nor username/password is supplied
- # return success for AUTO w/o rhn_* parameters
- return 0
- fi
-
- if [ -n "$serverUrl" ]; then
- eval $(serverUrl=$serverUrl python -c "
-import os
-u=os.getenv('serverUrl')
-if u.count('://') == 1:
- (proto, u) = u.split('://')
-else:
- proto = ''
-if u.count(':') == 1:
- (u, port) = u.split(':')
-elif proto == 'http':
- port = 80
-elif proto == 'https':
- port = 443
-else:
- port = 0
-host = u.split('/')[0]
-print 'host=%s' % host
-print 'port=%s' % port
-")
- if [ -z "$port" -o "$port" == "0" ]; then
- port=443
- fi
- cert=$(echo $CaCert | awk -F/ '{print $NF}')
- location="/etc/rhsm/ca/$cert"
- log "Downloading CA cert....."
- log "From: $CaCert To: $location"
- wget -r -nd --no-check-certificate --timeout=30 --tries=3 -O "$location" "$CaCert"
- if [ -s "${location}" ]; then
- subscription-manager config --rhsm.repo_ca_cert $location
- ovirt_store_config $location
- else
- log "Error Downloading Satellite CA cert!"
- return 1
- fi
- else
- host="subscription.rhn.redhat.com"
- port="443"
- fi
- if subscription-manager config --server.hostname=$host --server.port=$port; then
- ovirt_store_config /etc/rhsm/rhsm.conf
- fi
-
- if [ -n "$profileName" ]; then
- args="${args} --name=$profileName"
- fi
-
- if [ -n "$proxyhost" ]; then
- args="${args} --proxy=$proxyhost"
- if [ -n "$proxyuser" ]; then
- args="${args} --proxyuser=$proxyuser"
- if [ -n "$proxypass" ]; then
- args="${args} --proxypassword=$proxypass"
- fi
- fi
- fi
-
- if [ -n "$extra_args" ]; then
- args="${args} $extra_args"
- fi
-
- log "Registering to RHN account....."
-
- unmount_config /etc/pki/consumer/*pem
- unmount_config /var/lib/rhsm/cache/installed_products.json /var/lib/rhsm/facts/facts.json
- rm -rf /var/lib/rhsm/cache/installed_products.json /var/lib/rhsm/facts/facts.json
- args="subscription-manager register ${args}"
- # cant rely on return code in RHEVH's case
- eval $args
- subscription-manager identity $>/dev/null
- rc=$?
- if [ $rc -eq 0 ]; then
- ovirt_store_config \
- /etc/pki/consumer/*pem \
- /var/lib/rhsm/cache/installed_products.json \
- /var/lib/rhsm/facts/facts.json
- log "System "$profileName" successfully registered "$serverUrl""
- return 0
- else
- log "Error registering to RHN account!"
- return 1
- fi
-}
-
-# Prompts the user for a single username, password combo
-function prompt_user {
- servertype="$1"
- serverurl=""
- cacert=""
- username=""
- password=""
- profilename=""
- proxyhost=""
- proxyuser=""
- proxypass=""
-
- if [ "$servertype" = "SAT" ]; then
- printf "\n"
- read -p "Enter URL of RHN Satellite (ie. https://satellite.example.com): " -er
- test -z "$REPLY" && return 1
- serverurl=$REPLY
-
- default=$serverurl/pub/RHN-ORG-TRUSTED-SSL-CERT
- printf "\n"
- read -p "Enter location of satellite cert ($default): " -er
- #test -z "$REPLY" && REPLY=$default
- cacert=$REPLY
- elif [ "$servertype" = "SAM" ]; then
- printf "\n"
- read -p "Enter URL of Subscription Asset Manager (ie. https://subscription.rhn.redhat.com): " -er
- serverurl=$REPLY
- if [ -n "$serverurl" ]; then
- default=$serverurl/pub/RHN-ORG-TRUSTED-SSL-CERT
- printf "\n"
- read -p "Enter location of Subscription Asset Manager Cert ($default): " -er
- cacert=$REPLY
- fi
- fi
-
- printf "\n"
- read -p "Enter RHN account username: " -er
- test -z "$REPLY" && return 1
- username=$REPLY
-
-
- printf "\n"
- read -p "Enter password for RHN account: " -esr
- test -z "$REPLY" && return 1
- password=$REPLY
-
-
- printf "\n"
- read -p "Enter profile name for this system (optional): " -er
- profilename=$REPLY
-
- printf "\n"
- read -p "Enter HTTP proxy in host:port format, e.g. proxy.example.com:3128 (leave blank if not required): " -er
- if [ -n "$REPLY" ]; then
- proxyhost=$REPLY
-
- printf "\n"
- read -p "Enter proxy username (leave blank if not required): " -er
- proxyuser=$REPLY
-
- printf "\n"
- read -p "Enter proxy password (leave blank if not required): " -esr
- proxypass=$REPLY
- fi
-
- if [ "$servertype" = "SAM" ]; then
- run_rhsm "$serverurl" "$cacert" "" "$username" "$password" "$profilename" "$proxyuser" "$proxypass" "$proxyhost"
- else
- run_rhnreg "$serverurl" "$cacert" "" "$username" "$password" "$profilename" "$proxyuser" "$proxypass" "$proxyhost"
- fi
-}
-
-HOSTED="Register to public RHN"
-SATELLITE="Register to RHN Satellite"
-SAM="Register to Subscription Asset Manager"
-QUIT="Return to the Hypervisor Configuration Menu"
-
-if [ "$1" = "AUTO" ]; then
- if [ "$OVIRT_RHN_TYPE" = "sam" ]; then
- run_rhsm "${OVIRT_RHN_URL}" "${OVIRT_RHN_CA_CERT}" "${OVIRT_RHN_ACTIVATIONKEY}" "${OVIRT_RHN_USERNAME}" "${OVIRT_RHN_PASSWORD}" "${OVIRT_RHN_PROFILE}" "${OVIRT_RHN_PROXY}" "${OVIRT_RHN_PROXYUSER}" "${OVIRT_RHN_PROXYPASSWORD}"
- else
- run_rhnreg "${OVIRT_RHN_URL}" "${OVIRT_RHN_CA_CERT}" "${OVIRT_RHN_ACTIVATIONKEY}" "${OVIRT_RHN_USERNAME}" "${OVIRT_RHN_PASSWORD}" "${OVIRT_RHN_PROFILE}" "${OVIRT_RHN_PROXY}" "${OVIRT_RHN_PROXYUSER}" "${OVIRT_RHN_PROXYPASSWORD}"
- fi
- exit $?
-else
- check
- while true; do
- PS3="Choose an option: "
- select option in "$HOSTED" "$SATELLITE" "$SAM" "$QUIT"
- do
-
- case $option in
- $HOSTED) prompt_user; break;;
- $SATELLITE) prompt_user "SAT"; break;;
- $SAM) prompt_user "SAM"; break;;
- $QUIT) exit;;
- esac
- done
-
- printf "\n"
- done
-fi
diff --git a/scripts/ovirt-config-view-logs b/scripts/ovirt-config-view-logs
deleted file mode 100755
index 2faa92e..0000000
--- a/scripts/ovirt-config-view-logs
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/bin/bash
-#
-
-. /usr/libexec/ovirt-functions
-
-ME=$(basename "$0")
-warn() { printf '%s: %s\n' "$ME" "$*" >&2; }
-die() { warn "$*"; exit 1; }
-
-trap '__st=$?; stop_log; exit $__st' 0
-trap 'exit $?' 1 2 13 15
-
-RETURN_TO_MENU="Return To Menu"
-
-OPTIONS[${#OPTIONS[*]}]="/var/log/ovirt.log"
-OPTIONS[${#OPTIONS[*]}]="/var/log/messages"
-OPTIONS[${#OPTIONS[*]}]="/var/log/secure"
-OPTIONS[${#OPTIONS[*]}]="$RETURN_TO_MENU"
-
-while true; do
- printf "\nPlease select a log file to view.\n\n"
- PS3="Please select a log to view: "
- select OPTION in "${OPTIONS[@]}"
- do
- case $OPTION in
- "$RETURN_TO_MENU") exit 0;;
- "") break;;
- *)
- if [ -s "$OPTION" ]; then
- clear
- less -R "$OPTION"
- printf "\n\n"
- else
- printf "$OPTION is empty\n\n"
- fi
- ;;
- esac
- done
-done
diff --git a/scripts/ovirt-process-config b/scripts/ovirt-process-config
deleted file mode 100755
index ddb068a..0000000
--- a/scripts/ovirt-process-config
+++ /dev/null
@@ -1,98 +0,0 @@
-#!/bin/bash
-#
-# Takes as input a reference to an encoded configuration file
-# and produces from that a kernel module file and a network
-# configuration file. It then restarts the networking service
-# and saves the configuration files.
-
-. /usr/libexec/ovirt-functions
-
-ME=$(basename "$0")
-warn() { printf '%s: %s\n' "$ME" "$*" >&2; }
-die() { warn "$*"; exit 1; }
-
-try_h() { printf "Try \`$ME -h' for more information.\n" >&2; exit 1;}
-try_help() { printf "Usage: \`$ME [config] [module output] [config output]\n" >&2; exit 1;}
-
-case $# in
- 0|1|2) warn "too few arguments"; try_help;;
- 3) ;;
- *) warn "too many arguments"; try_help;;
-esac
-
-CONFIG=$1
-OVIRT_KERNEL_MODULE_FILE=$2
-OVIRT_CONFIG_OUTPUT_FILE=$3
-
-modconf=$(awk '/^[ \t]*bonding=.+/ {
- match($0, "^[ \t]*bonding=(.+)", data)
- printf "data[2] = %s\n", data[2]
-
- if (match("[^[:alnum:]=_ at -]", data[2]) >= 0) {
- printf "invalid bonding alias: \"%s\"\n", data[2];
- exit 1;
- }
-
- alias=data[2]
-
- printf("install %s bonding", alias)
- }' $CONFIG)
-
-echo "$modconf" > $OVIRT_KERNEL_MODULE_FILE
-
-networking=$(awk '/^[ \t]*ifcfg=/ {
- match($0, "^[ \t]*ifcfg=(.*)", data)
- split(data[1], ifcfg, "|")
-
- mac = ifcfg[1]
- iface = ifcfg[2]
- ifcfg_dir = "/files/etc/sysconfig/network-scripts"
-
- printf("rm %s/ifcfg-%s\n", ifcfg_dir, iface)
- printf("set %s/ifcfg-%s/DEVICE %s\n", ifcfg_dir, iface, iface)
-
- for (line in ifcfg) {
- if(line > 2) {
- match(ifcfg[line], "(^[^=]+)=(.*)", values)
- field=values[1]
- value=values[2]
-
- if(length(field) == 0) {
- print "Missing field name."
- exit 1
- }
-
- if(length(value) == 0) {
- print "Missing field value."
- exit 2
- }
-
- printf("set %s/ifcfg-%s/%s %s\n", ifcfg_dir, iface, field, value)
- }
- }
-
-}' $CONFIG)
-
-SUCCESS=$?
-
-if [ $SUCCESS != 0 ]; then
- case $SUCCESS in
- 1) error="missing field name";;
- 2) error="missing field value";;
- esac
-
- die "Bad data received: ${error}"
-fi
-
-echo "$networking" > $OVIRT_CONFIG_OUTPUT_FILE
-
-if [ -f $OVIRT_CONFIG_OUTPUT_FILE ]; then
- augtool $OVIRT_CONFIG_OUTPUT_FILE \
- && RESULT=0 || RESULT=1
- # FIXME do not store ifcfg-lo
- if ls /etc/sysconfig/network-scripts/ifcfg* >/dev/null 2>/dev/null; then
- ovirt_store_config /etc/sysconfig/network-scripts/ifcfg*
- fi
-fi
-
-exit $RESULT
--
To view, visit http://gerrit.ovirt.org/8616
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I6560b1a51f6417eafbef0a24067710ed77ea1a00
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Joey Boggs <jboggs at redhat.com>
More information about the node-patches
mailing list