On Monday 08 October 2012 11:41 AM, Rose, Charles wrote: > On Tuesday 25 September 2012 02:03 PM, SourceForge.net wrote: >> Feature Requests item #3571445, was opened at 2012-09-25 01:33 >> Message generated for change (Tracker Item Submitted) made by charles_rose >> You can respond by visiting: >> https://sourceforge.net/tracker/?func=detail&atid=610553&aid=3571445&group_id=95200 >> >> Please note that this message will contain a full copy of the comment thread, >> including the initial issue submission, for this request, >> not just the latest update. >> Category: None >> Group: None >> Status: Open >> Priority: 5 >> Private: No >> Submitted By: Charles Rose (charles_rose) >> Assigned to: Nobody/Anonymous (nobody) >> Summary: Exchange OS Name Hostname BMC URL during startup >> >> Initial Comment: >> A startup script that can do these: >> >> 1. Set OS Name, Version, System Hostname in BMC >> 2. Get BMC URL/IP address from BMC >> >> Would benefit: >> 1. users who would like to fetch hostname/OS Name/Version. >> 2. launch web-interface to BMC where supported with "xdg-open $BMC_URL" >> 3. Use the BMC_IP for other purposes like >> 3a. snmp proxy from host to BMC when BMC agent present. >> 3b. expose BMC IP/URL via other systems management interfaces (like >> wsman). >> >> ---------------------------------------------------------------------- >> > > Hello, > > Request feedback on this proposal that will help users who would like certain > pieces of OS > information set during system start-up. > > Here is the start-up script that implements this proposal: > > http://sourceforge.net/tracker/?func=detail&aid=3571446&group_id=95200&atid=610552
Including patch in-line for convenience. diff -Nru ipmitool-1_8_12.orig/contrib/Makefile.am ipmitool-1_8_12/contrib/Makefile.am --- ipmitool-1_8_12.orig/contrib/Makefile.am 2008-07-11 05:03:13.000000000 +0530 +++ ipmitool-1_8_12/contrib/Makefile.am 2012-09-25 13:45:46.658900613 +0530 @@ -34,6 +34,7 @@ EXTRA_DIST = README \ bmclanconf ipmi.init.basic ipmi.init.redhat \ + exchange-bmc-os-info.init.redhat \ ipmievd.init.redhat ipmievd.init.suse ipmievd.init.debian \ collect_data.sh create_rrds.sh create_webpage_compact.sh create_webpage.sh diff -Nru ipmitool-1_8_12.orig/contrib/exchange-bmc-os-info.init.redhat ipmitool-1_8_12/contrib/exchange-bmc-os-info.init.redhat --- ipmitool-1_8_12.orig/contrib/exchange-bmc-os-info.init.redhat 1970-01-01 05:30:00.000000000 +0530 +++ ipmitool-1_8_12/contrib/exchange-bmc-os-info.init.redhat 2012-09-25 13:43:32.173463731 +0530 @@ -0,0 +1,245 @@ +#!/bin/sh +############################################################################# +# +# exchange-bmc-os-info: Set OS and BMC (Baseboard Management Controller) +# parameters during system startup. +# +# Authors: Charles Rose <charles_r...@dell.com> +# Jordan Hargrave <jordan_hargr...@dell.com> +# +# Description: Script to set OS information in the BMC; fetch BMC IP/URL +# and set in the OS for use by other scripts/user. +# +# BMC IP and URL are made available in /run/bmc-info +# +# Example to launch BMC web-interface: +# # . /run/bmc-info +# # xdg-open $BMC_URL +# +# See here for details: +# https://fedoraproject.org/wiki/Features/AgentFreeManagement +# +############################################################################# +# +# chkconfig: 345 99 00 +# description: Set OS name, hostname in BMC; make BMC IP/URL available in OS +# processname: exchange-bmc-os-info +# config: /etc/sysconfig/exchange-bmc-os-info +# +### BEGIN INIT INFO +# Provides: exchange-bmc-os-info +# Required-Start: ipmi +# Default-Start: 3 4 5 +# Default-Stop: 0 1 2 6 +# + +CONFIGFILE=/etc/sysconfig/exchange-bmc-os-info +IPMI_TOOL=/usr/bin/ipmitool + +############################################################################# +# GLOBALS +############################################################################# + +# BMC Manufacturer ID +DELL="674" +#OTHER_OEM="123" + +BMC_INFO=/run/bmc-info +# Defaults for ${CONFIGFILE} +SET_OS_INFO="no" +RESET_OS_INFO="yes" +SET_BMC_INFO="no" + +# IPMI commands +IPMI_SET_SYSINFO="${IPMI_TOOL} mc setsysinfo" +IPMI_GET_SYSINFO="${IPMI_TOOL} mc getsysinfo" +############################################################################# + +SCRIPT_NAME=$(basename $0) +# source config +[ -r ${CONFIGFILE} ] && . ${CONFIGFILE} + +RETVAL=0 + +bmc_exists () +{ + # We should be able to execute ipmi commands + [ -x "${IPMI_TOOL}" ] && \ + BMC_VENDOR=$(${IPMI_TOOL} mc info 2>/dev/null | \ + sed -n "s#^Manufacturer ID.*: ##p") + if [ -z "${BMC_VENDOR}" ]; then + # we assume ipmitool failed + return 1 + fi +} +############################################################################# + +get_os_info() +{ + OS_HOSTNAME=$(hostname) + KERNEL_VERSION=$(uname -r -m) + + if [ -e /etc/lsb-release ] ; then + . /etc/lsb-release + NAME=${DISTRIB_ID} + VERSION="${DISTRIB_RELEASE} ${DISTRIB_CODENAME}" + fi + + # we prefer systemd's /etc/os-release over other sources + [ -e /etc/os-release ] && . /etc/os-release + + OS_NAME=${NAME} + OS_VERSION="${VERSION} kernel ${KERNEL_VERSION}" +} + +set_os_version() +{ + # OS Version setting is not standard yet + # we need per vendor oem commands + case "${BMC_VENDOR}" in + ${DELL}) ${IPMI_SET_SYSINFO} delloem_os_version \ + "${OS_VERSION}" > /dev/null 2>&1 + return $? + ;; + *) return 1 + ;; + esac +} + +set_os_info () +{ + # Set and reset OS info in the BMC + if [ "$1" = "reset" ]; then + OS_NAME="" + OS_HOSTNAME="" + OS_VERSION="" + fi + + ${IPMI_SET_SYSINFO} os_name ${OS_NAME} >/dev/null 2>&1 \ + || RETVAL=3 + ${IPMI_SET_SYSINFO} primary_os_name ${OS_NAME} >/dev/null 2>&1 \ + || RETVAL=3 + ${IPMI_SET_SYSINFO} system_name ${OS_HOSTNAME} >/dev/null 2>&1 \ + || RETVAL=3 + set_os_version || RETVAL=3 +} + +############################################################################# +get_bmc_url() +{ + # BMC URL is not standard yet + # we need per vendor oem commands + case "$BMC_VENDOR" in + $DELL) ${IPMI_GET_SYSINFO} delloem_url > /dev/null 2>&1 + ;; + *) echo ;; + esac +} + +get_bmc_info() +{ + # Get BMC_IPv4 and BMC_URL from BMC + BMC_IPv4=$(${IPMI_TOOL} lan print 1 2>/dev/null \ + | sed -n "s#^IP Address .*: ##p") + if [ -z "${BMC_IPv4}" -o "${BMC_IPv4}" = "0.0.0.0" ]; then + BMC_IPv4="" + RETVAL=4 + else + # URL makes sense only if there is an IP + BMC_URL=$(get_bmc_url) + [ -z "${BMC_URL}" ] && BMC_URL="https://${BMC_IPv4}:443" + fi +} + +set_bmc_info() +{ + touch ${BMC_INFO} && chmod 600 ${BMC_INFO} && \ + { + echo "BMC_IPv4=${BMC_IPv4}" + echo "BMC_URL=${BMC_URL}" + } > ${BMC_INFO} || \ + RETVAL=4 +} + +unset_bmc_info() +{ + [ -f ${BMC_INFO} ] && rm -f ${BMC_INFO} \ + > /dev/null 2>&1 +} + +############################################################################# +start() +{ + if bmc_exists; then + [ "${SET_OS_INFO}" = "yes" ] && \ + get_os_info && set_os_info + + if [ "${SET_BMC_INFO}" = "yes" ]; then + get_bmc_info + if [ ${RETVAL} -eq 0 ]; then + set_bmc_info + fi + fi + else + RETVAL=2 + fi +} + +############################################################################# +stop() +{ + if bmc_exists; then + # reset OS info while system reboots + # aids with debugging OS boot-up issues + if [ "${RESET_OS_INFO}" = "yes" ]; then + set_os_info reset + fi + unset_bmc_info + else + RETVAL=2 + fi +} + +############################################################################# +status() +{ + echo -n $"${SCRIPT_NAME}: " + if [ -r ${BMC_INFO} ]; then + echo $(grep "BMC_URL" ${BMC_INFO} 2>/dev/null) + else + echo $"BMC info not available" + fi + RETVAL=0 +} + +############################################################################# +usage () +{ + echo $"Usage: $0 {start|stop|restart|reload|status}" 1>&2 + RETVAL=1 +} + +############################################################################# +# MAIN +############################################################################# +case "$1" in + start) start ;; + stop) stop ;; + restart) start ;; + reload) start ;; + status) status ;; + *) usage ;; +esac + +case "$RETVAL" in + 2) echo $"${SCRIPT_NAME}: failed to communicate with BMC" 1>&2 ;; + 3) echo $"${SCRIPT_NAME}: failed to set OS information in BMC" 1>&2 ;; + 4) echo $"${SCRIPT_NAME}: failed to get BMC information" 1>&2 ;; + *) ;; +esac + +exit ${RETVAL} + +############################################################################# +# end of file +############################################################################# > >> You can respond by visiting: >> https://sourceforge.net/tracker/?func=detail&atid=610553&aid=3571445&group_id=95200 >> > > -- > Charles Rose > Linux Engineering > Dell Inc. > ------------------------------------------------------------------------------ Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev _______________________________________________ Ipmitool-devel mailing list Ipmitool-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ipmitool-devel