From 8207f11ae8c8269ae1c3c1fc71b1df9cc1508ad5 Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Tue, 7 Jun 2016 15:55:24 +0800 Subject: [PATCH 001/106] [xCAT Jenkins Email Report] xCAT Jenkins Log Analyzer with email report --- .../xcat/tools/jenkins/testreport/email.sh | 398 +++++++++++++ .../tools/jenkins/testreport/send-report.sh | 333 +++++++++++ .../jenkins/testreport/xCATjkLogAnalyzer.sql | 545 ++++++++++++++++++ .../jenkins/testreport/xcatjk-log2sql.sh | 459 +++++++++++++++ .../testreport/xcatjk-scanlogs-last3days.sh | 33 ++ .../xcatjk-scanlogs-redo-everything.sh | 43 ++ .../jenkins/testreport/xcatjk-scanlogs.sh | 249 ++++++++ 7 files changed, 2060 insertions(+) create mode 100644 xCAT-server/share/xcat/tools/jenkins/testreport/email.sh create mode 100755 xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh create mode 100644 xCAT-server/share/xcat/tools/jenkins/testreport/xCATjkLogAnalyzer.sql create mode 100755 xCAT-server/share/xcat/tools/jenkins/testreport/xcatjk-log2sql.sh create mode 100755 xCAT-server/share/xcat/tools/jenkins/testreport/xcatjk-scanlogs-last3days.sh create mode 100755 xCAT-server/share/xcat/tools/jenkins/testreport/xcatjk-scanlogs-redo-everything.sh create mode 100755 xCAT-server/share/xcat/tools/jenkins/testreport/xcatjk-scanlogs.sh diff --git a/xCAT-server/share/xcat/tools/jenkins/testreport/email.sh b/xCAT-server/share/xcat/tools/jenkins/testreport/email.sh new file mode 100644 index 000000000..9c4d9c9d1 --- /dev/null +++ b/xCAT-server/share/xcat/tools/jenkins/testreport/email.sh @@ -0,0 +1,398 @@ +#!/bin/bash + +# +# Author: GONG Jie +# Create: 2016-05-27 +# Update: 2016-06-07 +# Version: 0.99 +# +# EXAMPLE +# #!/bin/bash +# +# source /path/to/email.sh +# +# Email report +# +# $report_setTo bob@example.org +# $report_setTo charlie@example.org +# $report_setTo Dave dave@example.org +# $report_setCc trent@example.org +# $report_setBcc eve@example.org +# $report_setFrom Alice alice@example.org +# $report_setSubject "A Sample Email Report" +# +# $report_setText <<-EOF +# Blah blah blah... +# EOF +# +# $report_addAttachmentFile /path/to/doc/document-a4.pdf +# $report_addAttachmentFile /path/to/doc/onepage-a4.pdf +# +# $report_send +# +# SEE ALSO +# RFC 2045, RFC 2046, RFC 2047, RFC 2822, RFC 5322, RFC 5321 +# + +function Email() +{ + local base="${FUNCNAME}" + local this="$1" + + ! type base64 >/dev/null 2>&1 && + echo "${c}: command not found" >&2 && + return 1 + + declare -g base64_encode=base64 + + [[ "$(base64 --help)" =~ GNU ]] && + declare -g base64_encode="base64 -w 0" + + declare -g ${this}_mailTo="" + declare -g ${this}_mailCc="" + declare -g ${this}_mailBcc="" + declare -g ${this}_mailFrom="" + declare -g ${this}_mailReplyTo="" + declare -g ${this}_mailSubject="" + declare -g -a ${this}_mailAttachmentContentTypes + declare -g -a ${this}_mailAttachmentMessages + declare -g -a ${this}_mailAttachmentNames + + eval "${this}_mailAttachmentContentTypes=()" + eval "${this}_mailAttachmentMessages=()" + eval "${this}_mailAttachmentNames=()" + + local method + + for method in $(compgen -A function "${base}_") + do + declare -g ${method/#$base\_/$this\_}="${method} ${this}" + done +} + +function Email_setTo() +{ + local base="${FUNCNAME%%_*}" + local this="$1" + local inName="" + [ -n "$3" ] && inName="$2" && shift + local inAddress="$2" + + local mailTo="${this}_mailTo" + + # The format of Email address, + # see RFC 5322, sections 3.2.3 and 3.4.1, and RFC 5321 + + [[ "${inAddress}" =~ ^[0-9A-Za-z._%+-]+@([0-9A-Za-z][0-9A-Za-z-]+\.)+[A-Za-z]{2,3}$ ]] || + return 1 + [ -n "${!mailTo}" ] && declare -g ${mailTo}+=","$'\n'" " + [ -n "${inName}" ] && + declare -g ${mailTo}+="=?UTF-8?B?$(echo -n "${inName}" | + ${base64_encode})?="$'\n'" <${inAddress}>" || + declare -g ${mailTo}+="${inAddress}" + + return 0 +} + +function Email_setCc() +{ + local base="${FUNCNAME%%_*}" + local this="$1" + local inName="" + [ -n "$3" ] && inName="$2" && shift + local inAddress="$2" + + local mailCc="${this}_mailCc" + + [[ "${inAddress}" =~ ^[0-9A-Za-z._%+-]+@([0-9A-Za-z][0-9A-Za-z-]+\.)+[A-Za-z]{2,3}$ ]] || + return 1 + [ -n "${!mailCc}" ] && declare -g ${mailCc}+=","$'\n'" " + [ -n "${inName}" ] && + declare -g ${mailCc}+="=?UTF-8?B?$(echo -n "${inName}" | + ${base64_encode})?="$'\n'" <${inAddress}>" || + declare -g ${mailCc}+="${inAddress}" + + return 0 +} + +function Email_setBcc() +{ + local base="${FUNCNAME%%_*}" + local this="$1" + local inName="" + [ -n "$3" ] && inName="$2" && shift + local inAddress="$2" + + local mailBcc="${this}_mailBcc" + + [[ "${inAddress}" =~ ^[0-9A-Za-z._%+-]+@([0-9A-Za-z][0-9A-Za-z-]+\.)+[A-Za-z]{2,3}$ ]] || + return 1 + [ -n "${!mailBcc}" ] && declare -g ${mailBcc}+=","$'\n'" " + [ -n "${inName}" ] && + declare -g ${mailBcc}+="=?UTF-8?B?$(echo -n "${inName}" | + ${base64_encode})?="$'\n'" <${inAddress}>" || + declare -g ${mailBcc}+="${inAddress}" + + return 0 +} + +function Email_setFrom() +{ + local base="${FUNCNAME%%_*}" + local this="$1" + local inName="" + [ -n "$3" ] && inName="$2" && shift + local inAddress="$2" + + local mailFrom="${this}_mailFrom" + + [[ "${inAddress}" =~ ^[0-9A-Za-z._%+-]+@([0-9A-Za-z][0-9A-Za-z-]+\.)+[A-Za-z]{2,3}$ ]] || + return 1 + [ -n "${inName}" ] && + declare -g ${mailFrom}="=?UTF-8?B?$(echo -n "${inName}" | + ${base64_encode})?="$'\n'" <${inAddress}>" || + declare -g ${mailFrom}="${inAddress}" + + return 0 +} + +function Email_setReplyTo() +{ + local base="${FUNCNAME%%_*}" + local this="$1" + local inName="" + [ -n "$3" ] && inName="$2" && shift + local inAddress="$2" + + local mailReplyTo="${this}_mailReplyTo" + + [[ "${inAddress}" =~ ^[0-9A-Za-z._%+-]+@([0-9A-Za-z][0-9A-Za-z-]+\.)+[A-Za-z]{2,3}$ ]] || + return 1 + [ -n "${inName}" ] && + declare -g ${mailReplyTo}="=?UTF-8?B?$(echo -n "${inName}" | + ${base64_encode})?="$'\n'" <${inAddress}>" || + declare -g ${mailReplyTo}="${inAddress}" + + return 0 +} + +function Email_setSubject() +{ + local base="${FUNCNAME%%_*}" + local this="$1" + local inSubject="$2" + + local mailSubject="${this}_mailSubject" + + local oLANG="${LANG}" + LANG=C + + [[ "${#inSubject}" -le 66 && "${inSubject}" =~ ^[0-9A-Za-z\ ._/=+-]+$ ]] && + declare -g ${mailSubject}="${inSubject}" && + return 0 + + # See RFC 5355 + + declare -g ${mailSubject}="=?UTF-8?B?" + + local c="" + local w="" + local -i limit=39 + + while : + do + read -n 1 + [[ -z "${REPLY}" || "${REPLY}" =~ [\x00-\x7f\xc0-\xff] ]] && + (( ${#w} + ${#c} > limit )) && + declare -g ${mailSubject}+="$(echo -n "${w}" | + ${base64_encode})?="$'\n'" =?UTF-8?B?" && + w="" && limit=45 + w+="${c}" && c="" + [ -n "${REPLY}" ] && c+="${REPLY}" || break + done < <(echo -n "${inSubject}") + declare -g ${mailSubject}+="$(echo -n "${w}" | ${base64_encode})?=" + + LANG="${oLANG}" + + return 0 +} + +function Email_setText() +{ + local base="${FUNCNAME%%_*}" + local this="$1" + + Email_addAttachment "${this}" "" "text/plain; charset=UTF-8" +} + +function Email_setHTML() +{ + local base="${FUNCNAME%%_*}" + local this="$1" + + Email_addAttachment "${this}" "" "text/html; charset=UTF-8" +} + +function Email_addAttachment() +{ + local base="${FUNCNAME%%_*}" + local this="$1" + local inName="$2" + local inContentType="$3" + local inMessage="" + + # 76 is a magic number, see RFC 2045 + + while read -n 76 + do + inMessage+="${REPLY}" + inMessage+=$'\n' + done < <(${base64_encode} && echo) + + local mailAttachmentContentTypes="${this}_mailAttachmentContentTypes" + local mailAttachmentMessages="${this}_mailAttachmentMessages" + local mailAttachmentNames="${this}_mailAttachmentNames" + + eval "${mailAttachmentContentTypes}+=(\"${inContentType}\")" + eval "${mailAttachmentMessages}+=(\"${inMessage}\")" + eval "${mailAttachmentNames}+=(\"${inName}\")" +} + +function Email_addAttachmentFile() +{ + local base="${FUNCNAME%%_*}" + local this="$1" + local inFileName="$2" + + [ -f "${inFileName}" ] || return 1 + [ -r "${inFileName}" ] || return 1 + + local inContentType="" + + # These are magic strings, see RFC 2046 + + case "${inFileName##*.}" in + "7z") inContentType="application/x-7z-compressed" ;; + "bz"|"bz2") + inContentType="application/x-bzip2" ;; + "bpg") inContentType="image/bpg" ;; + "cpio") inContentType="application/x-cpio" ;; + "gif") inContentType="image/gif" ;; + "gz") inContentType="application/x-gzip" ;; + "htm"|"html") + inContentType="text/html" ;; + "jpe"|"jpeg"|"jpg") + inContentType="image/jpeg" ;; + "png") inContentType="image/png" ;; + "rar") inContentType="application/x-rar-compressed" ;; + "tar") inContentType="application/x-tar" ;; + "txt") inContentType="text/plain" ;; + "xz") inContentType="application/x-xz" ;; + "zip") inContentType="application/x-zip-compressed" ;; + *) inContentType="application/octet-stream" ;; + esac + + Email_addAttachment "${this}" "${inFileName##*/}" "${inContentType}" <"${inFileName}" +} + +function Email_send() +{ + local base="${FUNCNAME%%_*}" + local this="$1" + + local mailTo="${this}_mailTo" + local mailCc="${this}_mailCc" + local mailBcc="${this}_mailBcc" + local mailFrom="${this}_mailFrom" + local mailReplyTo="${this}_mailReplyTo" + local mailSubject="${this}_mailSubject" + + # Sendmail is here, see Linux Standard Base Core Specification + # - Generic 5.0 Edition, section 17.2 + + local SENDMAIL="/usr/sbin/sendmail" + + ! type "${SENDMAIL}" >/dev/null 2>&1 && + echo "${SENDMAIL}: command not found" >&2 && + return 1 + + # Email headers, see RFC 2076 + + "${SENDMAIL}" -t -i <<-EOF + To: ${!mailTo} + Cc: ${!mailCc} + Bcc: ${!mailBcc} + From: ${!mailFrom} + Reply-To: ${!mailReplyTo} + Subject: ${!mailSubject} + X-Mailer: Flying Nimbus 0.0.1 + MIME-Version: 1.0 + $(Email_buildMultipart "${this}") + EOF +} + +function Email_buildMultipart() +{ + local base="${FUNCNAME%%_*}" + local this="$1" + + local mailAttachmentContentTypes="${this}_mailAttachmentContentTypes" + local mailAttachmentMessages="${this}_mailAttachmentMessages" + local mailAttachmentNames="${this}_mailAttachmentNames" + + local boundary="-=0xdeadbeef${RANDOM}${RANDOM}=-" + + # See RFC 2046, section 5.1.3 + + echo "Content-Type: multipart/mixed; boundary=0__${boundary}" + echo + echo "This is a message with multiple parts in MIME format." + echo "--0__${boundary}" + + local -i i + + # See RFC 2046, section 5.1.4 + + echo "Content-Type: multipart/alternative; boundary=1__${boundary}" + echo + echo -n "--1__${boundary}" + for (( i = 0; i < $(eval "echo \"\${#${mailAttachmentNames}[@]}\""); ++i )) + do + local mailAttachmentContentType="${mailAttachmentContentTypes}[${i}]" + local mailAttachmentMessage="${mailAttachmentMessages}[${i}]" + local mailAttachmentName="${mailAttachmentNames}[${i}]" + + [ -n "${!mailAttachmentName}" ] && continue + + echo + echo "Content-Type: ${!mailAttachmentContentType}" + echo "Content-Disposition: inline" + echo "Content-Transfer-Encoding: base64" + echo + echo "${!mailAttachmentMessage}" + echo + echo -n "--1__${boundary}" + done + echo "--" + echo -n "--0__${boundary}" + + for (( i = 0; i < $(eval "echo \"\${#${mailAttachmentNames}[@]}\""); ++i )) + do + local mailAttachmentContentType="${mailAttachmentContentTypes}[${i}]" + local mailAttachmentMessage="${mailAttachmentMessages}[${i}]" + local mailAttachmentName="${mailAttachmentNames}[${i}]" + + [ -z "${!mailAttachmentName}" ] && continue + + echo + echo "Content-Type: ${!mailAttachmentContentType}; name=\"${!mailAttachmentName}\"" + echo "Content-Disposition: attachment; filename=${!mailAttachmentName}" + echo "Content-Transfer-Encoding: base64" + echo + echo "${!mailAttachmentMessage}" + echo + echo -n "--0__${boundary}" + done + echo "--" +} +# End of file diff --git a/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh b/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh new file mode 100755 index 000000000..60e1ff1b7 --- /dev/null +++ b/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh @@ -0,0 +1,333 @@ +#!/bin/bash + +SCRIPT="$0" +! type readlink >/dev/null 2>&1 && + echo "Command \"readlink\" not found" >&2 && exit 1 +while [ -L "${SCRIPT}" ] +do + LINK="$(readlink "${SCRIPT}")" + if [ "/" = "${LINK:0:1}" ] + then + SCRIPT="${LINK}" + else + SCRIPT="${SCRIPT%/*}/${LINK}" + fi +done +BASE_DIR="${SCRIPT%/*}" + +! source "${BASE_DIR}/email.sh" >/dev/null 2>&1 && + echo "File \"${BASE_DIR}/email.sh\" not found" >&2 && exit 1 + +# The configuration part + +MYSQL_HOST="localhost" +MYSQL_USER="root" +MYSQL_PASS="password" +MYSQL_DB="xCATjkLogAnalyzer" + +# The main part + +for c in mysql tail sed grep +do + ! type "${c}" >/dev/null 2>&1 && + echo "Command \"${c}\" not found" >&2 && exit 1 +done + +Email report + +$report_setTo "Alice" alice@example.org + +$report_setFrom "xCATjk Mail Bot" root@localhost.localdomain + +DateTime="$(date -R)" + +MYSQL_COMMAND=("mysql" "-h" "${MYSQL_HOST}" -u "${MYSQL_USER}" -p"${MYSQL_PASS}" "${MYSQL_DB}") +Subject="$("${MYSQL_COMMAND[@]}" <<<"SELECT CONCAT('Passed: ', SUM(Passed), ' Failed: ', SUM(Failed), ' No run: ', SUM(\`No run\`)) AS Summary FROM LatestDailyReport;" | tail -n 1)" + +$report_setSubject "[xCATjk] ${Subject}" + +$report_setHTML <<-EOF + + + + + +xCATjk Test Report + + + + + + + +

xCATjk Test Report

xCAT Logo
+

+ + + + + + + + + + + +$( +LatestDailyReport="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT Title, Arch, OS, Duration, Passed, Failed, \`No run\`, Subtotal, \`Pass rate\` FROM LatestDailyReport;")" +oIFS="${IFS}" +IFS="|" +color="" +while read n title arch os duration passed failed no_run subtotal pass_rate n +do + [ "${color}" = "#e0e0e0" ] && color="#a0d0ff" || color="#e0e0e0" + echo "" + echo "" + echo "" + echo "" + echo "" + echo "" + echo "" + echo "" + echo "" + echo "" +done < <(grep -v -- ---- <<<"${LatestDailyReport}" | sed -e '1d' -e 's/ *| */|/g') +IFS="${oIFS}" + +LatestDailyReportSummary="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT SEC_TO_TIME(SUM(TIME_TO_SEC(Duration))) AS Duration, SUM(Passed), SUM(Failed), SUM(\`No run\`), SUM(Subtotal), IFNULL(CONCAT(ROUND(SUM(Passed) / (SUM(Passed) + SUM(Failed)) * 100, 2), '%'), 'N/A') AS \`Pass rate\` FROM LatestDailyReport;")" +oIFS="${IFS}" +IFS="|" +read n duration passed failed no_run total pass_rate n < <(grep -v -- ---- <<<"${LatestDailyReportSummary}" | sed -e '1d' -e 's/ *| */|/g') +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +IFS="${oIFS}" +) +
ArchOSDurationPassedFailedNo runSubtotalPass rate
${arch}${os}${duration}${passed}${failed}${no_run}${subtotal}${pass_rate}
Total-${duration}${passed}${failed}${no_run}${total}${pass_rate}
+
+

Failed Test Cases

+ + + + + + +$( +FailedTestCasesReport="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT Title, Arch, OS, \`Failed test cases\` FROM LatestDailyReport;")" +oIFS="${IFS}" +IFS="|" +color="" +while read n title arch os failed_test_cases n +do + [ "${color}" = "#e0e0e0" ] && color="#a0d0ff" || color="#e0e0e0" + [ "${color}" = "#e0e0e0" ] && color2="#f0f0f0" || color2="#d0e8ff" + echo "" + echo "" + echo "" + echo "" + echo "" +done < <(grep -v -- ---- <<<"${FailedTestCasesReport}" | sed -e '1d' -e 's/ *| */|/g') +) +
ArchOSFailed test cases
${arch}${os}${failed_test_cases}
+

Seven-day Look Back

+ + + + + + + + + + + +$( +SevenDayLookBack="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT Arch, OS, \`Test runs\`, Passed, Failed, \`No run\`, Subtotal, \`Pass rate\` FROM SevenDayLookBack;")" +oIFS="${IFS}" +IFS="|" +color="" +while read n arch os test_runs passed failed no_run subtotal pass_rate n +do + [ "${color}" = "#e0e0e0" ] && color="#a0d0ff" || color="#e0e0e0" + echo "" + echo "" + echo "" + echo "" + echo "" + echo "" + echo "" + echo "" + echo "" + echo "" +done < <(grep -v -- ---- <<<"${SevenDayLookBack}" | sed -e '1d' -e 's/ *| */|/g') +IFS="${oIFS}" + +SevenDayLookBackSummary="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT SUM(\`Test runs\`), SUM(Passed), SUM(Failed), SUM(\`No run\`), SUM(Subtotal), IFNULL(CONCAT(ROUND(SUM(Passed) / (SUM(Passed) + SUM(Failed)) * 100, 2), '%'), 'N/A') AS \`Pass rate\` FROM SevenDayLookBack;")" +oIFS="${IFS}" +IFS="|" +read n test_runs passed failed no_run total pass_rate n < <(grep -v -- ---- <<<"${SevenDayLookBackSummary}" | sed -e '1d' -e 's/ *| */|/g') +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +IFS="${oIFS}" +) +
ArchOSTest runsPassedFailedNo runSubtotalPass rate
${arch}${os}${test_runs}${passed}${failed}${no_run}${subtotal}${pass_rate}
Total-${test_runs}${passed}${failed}${no_run}${total}${pass_rate}
+

Thirty-day Look Back

+ + + + + + + + + + + +$( +ThirtyDayLookBack="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT Arch, OS, \`Test runs\`, Passed, Failed, \`No run\`, Subtotal, \`Pass rate\` FROM ThirtyDayLookBack;")" +oIFS="${IFS}" +IFS="|" +color="" +while read n arch os test_runs passed failed no_run subtotal pass_rate n +do + [ "${color}" = "#e0e0e0" ] && color="#a0d0ff" || color="#e0e0e0" + echo "" + echo "" + echo "" + echo "" + echo "" + echo "" + echo "" + echo "" + echo "" + echo "" +done < <(grep -v -- ---- <<<"${ThirtyDayLookBack}" | sed -e '1d' -e 's/ *| */|/g') +IFS="${oIFS}" + +ThirtyDayLookBackSummary="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT SUM(\`Test runs\`), SUM(Passed), SUM(Failed), SUM(\`No run\`), SUM(Subtotal), IFNULL(CONCAT(ROUND(SUM(Passed) / (SUM(Passed) + SUM(Failed)) * 100, 2), '%'), 'N/A') AS \`Pass rate\` FROM ThirtyDayLookBack;")" +oIFS="${IFS}" +IFS="|" +read n test_runs passed failed no_run total pass_rate n < <(grep -v -- ---- <<<"${ThirtyDayLookBackSummary}" | sed -e '1d' -e 's/ *| */|/g') +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +IFS="${oIFS}" +) +
ArchOSTest runsPassedFailedNo runSubtotalPass rate
${arch}${os}${test_runs}${passed}${failed}${no_run}${subtotal}${pass_rate}
Total-${test_runs}${passed}${failed}${no_run}${total}${pass_rate}
+

Ninety-day Look Back

+ + + + + + + + + + + +$( +NinetyDayLookBack="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT Arch, OS, \`Test runs\`, Passed, Failed, \`No run\`, Subtotal, \`Pass rate\` FROM NinetyDayLookBack;")" +oIFS="${IFS}" +IFS="|" +color="" +while read n arch os test_runs passed failed no_run subtotal pass_rate n +do + [ "${color}" = "#e0e0e0" ] && color="#a0d0ff" || color="#e0e0e0" + echo "" + echo "" + echo "" + echo "" + echo "" + echo "" + echo "" + echo "" + echo "" + echo "" +done < <(grep -v -- ---- <<<"${NinetyDayLookBack}" | sed -e '1d' -e 's/ *| */|/g') +IFS="${oIFS}" + +NinetyDayLookBackSummary="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT SUM(\`Test runs\`), SUM(Passed), SUM(Failed), SUM(\`No run\`), SUM(Subtotal), IFNULL(CONCAT(ROUND(SUM(Passed) / (SUM(Passed) + SUM(Failed)) * 100, 2), '%'), 'N/A') AS \`Pass rate\` FROM NinetyDayLookBack;")" +oIFS="${IFS}" +IFS="|" +read n test_runs passed failed no_run total pass_rate n < <(grep -v -- ---- <<<"${NinetyDayLookBackSummary}" | sed -e '1d' -e 's/ *| */|/g') +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +echo "" +IFS="${oIFS}" +) +
ArchOSTest runsPassedFailedNo runSubtotalPass rate
${arch}${os}${test_runs}${passed}${failed}${no_run}${subtotal}${pass_rate}
Total-${test_runs}${passed}${failed}${no_run}${total}${pass_rate}
+

Top 50 Failed Test Cases

+ + + + + + + + + +$( +Top50FailedTestCases="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT \`Test case\`, Arch, OS, \`Last seven days\`, \`Last thirty days\`, \`Last ninety days\` FROM FailedTestCasesTopList LIMIT 50;")" +oIFS="${IFS}" +IFS="|" +color="" +while read n test_case arch os last_seven_days last_thirty_days last_ninety_days n +do + [ "${color}" = "#e0e0e0" ] && color="#a0d0ff" || color="#e0e0e0" + [ "${color}" = "#e0e0e0" ] && color2="#f0f0f0" || color2="#d0e8ff" + echo "" + echo "" + echo "" + echo "" + echo "" + echo "" + echo "" + echo "" +done < <(grep -v -- ---- <<<"${Top50FailedTestCases}" | sed -e '1d' -e 's/ *| */|/g') +IFS="${oIFS}" +) +
Test caseArchOSLast 7 daysLast 30 daysLast 90 days
${test_case}${arch}${os}${last_seven_days}${last_thirty_days}${last_ninety_days}
+
+ + + + +

This email has been sent to you by xCATjk Mail Bot.
+This email was sent from a notification-only address that cannot accept incoming email. Please do not reply to this message. If you have received this email in error, please delete it.
+All the times shown in this test report are the local times of the testing environment.

+

${DateTime}

+ + +EOF + +$report_send diff --git a/xCAT-server/share/xcat/tools/jenkins/testreport/xCATjkLogAnalyzer.sql b/xCAT-server/share/xcat/tools/jenkins/testreport/xCATjkLogAnalyzer.sql new file mode 100644 index 000000000..d2f9a90d0 --- /dev/null +++ b/xCAT-server/share/xcat/tools/jenkins/testreport/xCATjkLogAnalyzer.sql @@ -0,0 +1,545 @@ +-- MySQL dump 10.14 Distrib 5.5.47-MariaDB, for Linux (ppc64) +-- +-- Host: localhost Database: xcatjkloganalyzer +-- ------------------------------------------------------ +-- Server version 5.5.47-MariaDB + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Table structure for table `ArchDict` +-- + +DROP TABLE IF EXISTS `ArchDict`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `ArchDict` ( + `ArchId` int(11) NOT NULL AUTO_INCREMENT, + `ArchName` varchar(255) NOT NULL, + PRIMARY KEY (`ArchId`), + UNIQUE KEY `ArchName` (`ArchName`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Temporary table structure for view `FailedTestCasesTopList` +-- + +DROP TABLE IF EXISTS `FailedTestCasesTopList`; +/*!50001 DROP VIEW IF EXISTS `FailedTestCasesTopList`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE TABLE `FailedTestCasesTopList` ( + `Test case` tinyint NOT NULL, + `Arch` tinyint NOT NULL, + `OS` tinyint NOT NULL, + `Last seven days` tinyint NOT NULL, + `Last thirty days` tinyint NOT NULL, + `Last ninety days` tinyint NOT NULL +) ENGINE=MyISAM */; +SET character_set_client = @saved_cs_client; + +-- +-- Temporary table structure for view `LatestDailyReport` +-- + +DROP TABLE IF EXISTS `LatestDailyReport`; +/*!50001 DROP VIEW IF EXISTS `LatestDailyReport`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE TABLE `LatestDailyReport` ( + `Title` tinyint NOT NULL, + `Arch` tinyint NOT NULL, + `OS` tinyint NOT NULL, + `Duration` tinyint NOT NULL, + `Passed` tinyint NOT NULL, + `Failed` tinyint NOT NULL, + `No run` tinyint NOT NULL, + `Subtotal` tinyint NOT NULL, + `Pass rate` tinyint NOT NULL, + `Failed test cases` tinyint NOT NULL +) ENGINE=MyISAM */; +SET character_set_client = @saved_cs_client; + +-- +-- Temporary table structure for view `NinetyDayFailed` +-- + +DROP TABLE IF EXISTS `NinetyDayFailed`; +/*!50001 DROP VIEW IF EXISTS `NinetyDayFailed`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE TABLE `NinetyDayFailed` ( + `TestCaseId` tinyint NOT NULL, + `ArchId` tinyint NOT NULL, + `OSId` tinyint NOT NULL, + `Failed` tinyint NOT NULL +) ENGINE=MyISAM */; +SET character_set_client = @saved_cs_client; + +-- +-- Temporary table structure for view `NinetyDayLookBack` +-- + +DROP TABLE IF EXISTS `NinetyDayLookBack`; +/*!50001 DROP VIEW IF EXISTS `NinetyDayLookBack`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE TABLE `NinetyDayLookBack` ( + `Arch` tinyint NOT NULL, + `OS` tinyint NOT NULL, + `Test runs` tinyint NOT NULL, + `Passed` tinyint NOT NULL, + `Failed` tinyint NOT NULL, + `No run` tinyint NOT NULL, + `Subtotal` tinyint NOT NULL, + `Pass rate` tinyint NOT NULL +) ENGINE=MyISAM */; +SET character_set_client = @saved_cs_client; + +-- +-- Temporary table structure for view `NinetyDayReport` +-- + +DROP TABLE IF EXISTS `NinetyDayReport`; +/*!50001 DROP VIEW IF EXISTS `NinetyDayReport`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE TABLE `NinetyDayReport` ( + `ArchId` tinyint NOT NULL, + `OSId` tinyint NOT NULL, + `Passed` tinyint NOT NULL, + `Failed` tinyint NOT NULL, + `No run` tinyint NOT NULL, + `Subtotal` tinyint NOT NULL +) ENGINE=MyISAM */; +SET character_set_client = @saved_cs_client; + +-- +-- Table structure for table `OSDict` +-- + +DROP TABLE IF EXISTS `OSDict`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `OSDict` ( + `OSId` int(11) NOT NULL AUTO_INCREMENT, + `OSName` varchar(255) NOT NULL, + PRIMARY KEY (`OSId`), + UNIQUE KEY `OSName` (`OSName`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `ResultDict` +-- + +DROP TABLE IF EXISTS `ResultDict`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `ResultDict` ( + `ResultId` int(11) NOT NULL AUTO_INCREMENT, + `ResultName` varchar(255) NOT NULL, + PRIMARY KEY (`ResultId`), + UNIQUE KEY `ResultName` (`ResultName`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Temporary table structure for view `SevenDayFailed` +-- + +DROP TABLE IF EXISTS `SevenDayFailed`; +/*!50001 DROP VIEW IF EXISTS `SevenDayFailed`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE TABLE `SevenDayFailed` ( + `TestCaseId` tinyint NOT NULL, + `ArchId` tinyint NOT NULL, + `OSId` tinyint NOT NULL, + `Failed` tinyint NOT NULL +) ENGINE=MyISAM */; +SET character_set_client = @saved_cs_client; + +-- +-- Temporary table structure for view `SevenDayLookBack` +-- + +DROP TABLE IF EXISTS `SevenDayLookBack`; +/*!50001 DROP VIEW IF EXISTS `SevenDayLookBack`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE TABLE `SevenDayLookBack` ( + `Arch` tinyint NOT NULL, + `OS` tinyint NOT NULL, + `Test runs` tinyint NOT NULL, + `Passed` tinyint NOT NULL, + `Failed` tinyint NOT NULL, + `No run` tinyint NOT NULL, + `Subtotal` tinyint NOT NULL, + `Pass rate` tinyint NOT NULL +) ENGINE=MyISAM */; +SET character_set_client = @saved_cs_client; + +-- +-- Temporary table structure for view `SevenDayReport` +-- + +DROP TABLE IF EXISTS `SevenDayReport`; +/*!50001 DROP VIEW IF EXISTS `SevenDayReport`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE TABLE `SevenDayReport` ( + `ArchId` tinyint NOT NULL, + `OSId` tinyint NOT NULL, + `Passed` tinyint NOT NULL, + `Failed` tinyint NOT NULL, + `No run` tinyint NOT NULL, + `Subtotal` tinyint NOT NULL +) ENGINE=MyISAM */; +SET character_set_client = @saved_cs_client; + +-- +-- Table structure for table `TestCase` +-- + +DROP TABLE IF EXISTS `TestCase`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `TestCase` ( + `TestCaseId` int(11) NOT NULL AUTO_INCREMENT, + `TestCaseName` varchar(255) NOT NULL, + `Memo` text NOT NULL, + PRIMARY KEY (`TestCaseId`), + UNIQUE KEY `TestCaseName` (`TestCaseName`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `TestResult` +-- + +DROP TABLE IF EXISTS `TestResult`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `TestResult` ( + `TestRunId` int(11) NOT NULL, + `TestCaseId` int(11) NOT NULL, + `ResultId` int(11) NOT NULL, + `DurationTime` int(11) NOT NULL, + PRIMARY KEY (`TestRunId`,`TestCaseId`), + KEY `Result` (`ResultId`), + KEY `TestCaseId` (`TestCaseId`), + CONSTRAINT `ResutId` FOREIGN KEY (`ResultId`) REFERENCES `ResultDict` (`ResultId`), + CONSTRAINT `TestCaseId` FOREIGN KEY (`TestCaseId`) REFERENCES `TestCase` (`TestCaseId`), + CONSTRAINT `TestRunId` FOREIGN KEY (`TestRunId`) REFERENCES `TestRun` (`TestRunId`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `TestRun` +-- + +DROP TABLE IF EXISTS `TestRun`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `TestRun` ( + `TestRunId` int(11) NOT NULL AUTO_INCREMENT, + `TestRunName` varchar(255) NOT NULL, + `StartTime` datetime NOT NULL, + `EndTime` datetime NOT NULL, + `ArchId` int(11) NOT NULL, + `OSId` int(11) NOT NULL, + `xCATgitCommit` varchar(255) NOT NULL, + `Memo` text NOT NULL, + PRIMARY KEY (`TestRunId`), + UNIQUE KEY `TestRunName` (`TestRunName`), + KEY `ArchId` (`ArchId`), + KEY `OSId` (`OSId`), + CONSTRAINT `ArchId` FOREIGN KEY (`ArchId`) REFERENCES `ArchDict` (`ArchId`), + CONSTRAINT `OSId` FOREIGN KEY (`OSId`) REFERENCES `OSDict` (`OSId`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Temporary table structure for view `ThirtyDayFailed` +-- + +DROP TABLE IF EXISTS `ThirtyDayFailed`; +/*!50001 DROP VIEW IF EXISTS `ThirtyDayFailed`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE TABLE `ThirtyDayFailed` ( + `TestCaseId` tinyint NOT NULL, + `ArchId` tinyint NOT NULL, + `OSId` tinyint NOT NULL, + `Failed` tinyint NOT NULL +) ENGINE=MyISAM */; +SET character_set_client = @saved_cs_client; + +-- +-- Temporary table structure for view `ThirtyDayLookBack` +-- + +DROP TABLE IF EXISTS `ThirtyDayLookBack`; +/*!50001 DROP VIEW IF EXISTS `ThirtyDayLookBack`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE TABLE `ThirtyDayLookBack` ( + `Arch` tinyint NOT NULL, + `OS` tinyint NOT NULL, + `Test runs` tinyint NOT NULL, + `Passed` tinyint NOT NULL, + `Failed` tinyint NOT NULL, + `No run` tinyint NOT NULL, + `Subtotal` tinyint NOT NULL, + `Pass rate` tinyint NOT NULL +) ENGINE=MyISAM */; +SET character_set_client = @saved_cs_client; + +-- +-- Temporary table structure for view `ThirtyDayReport` +-- + +DROP TABLE IF EXISTS `ThirtyDayReport`; +/*!50001 DROP VIEW IF EXISTS `ThirtyDayReport`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE TABLE `ThirtyDayReport` ( + `ArchId` tinyint NOT NULL, + `OSId` tinyint NOT NULL, + `Passed` tinyint NOT NULL, + `Failed` tinyint NOT NULL, + `No run` tinyint NOT NULL, + `Subtotal` tinyint NOT NULL +) ENGINE=MyISAM */; +SET character_set_client = @saved_cs_client; + +-- +-- Final view structure for view `FailedTestCasesTopList` +-- + +/*!50001 DROP TABLE IF EXISTS `FailedTestCasesTopList`*/; +/*!50001 DROP VIEW IF EXISTS `FailedTestCasesTopList`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50001 VIEW `FailedTestCasesTopList` AS select `TestCase`.`TestCaseName` AS `Test case`,`ArchDict`.`ArchName` AS `Arch`,`OSDict`.`OSName` AS `OS`,ifnull(`SevenDayFailed`.`Failed`,0) AS `Last seven days`,ifnull(`ThirtyDayFailed`.`Failed`,0) AS `Last thirty days`,`NinetyDayFailed`.`Failed` AS `Last ninety days` from (((((`NinetyDayFailed` left join `SevenDayFailed` on(((`NinetyDayFailed`.`TestCaseId` = `SevenDayFailed`.`TestCaseId`) and (`NinetyDayFailed`.`ArchId` = `SevenDayFailed`.`ArchId`) and (`NinetyDayFailed`.`OSId` = `SevenDayFailed`.`OSId`)))) left join `ThirtyDayFailed` on(((`NinetyDayFailed`.`TestCaseId` = `ThirtyDayFailed`.`TestCaseId`) and (`NinetyDayFailed`.`ArchId` = `ThirtyDayFailed`.`ArchId`) and (`NinetyDayFailed`.`OSId` = `ThirtyDayFailed`.`OSId`)))) left join `TestCase` on((`NinetyDayFailed`.`TestCaseId` = `TestCase`.`TestCaseId`))) left join `ArchDict` on((`NinetyDayFailed`.`ArchId` = `ArchDict`.`ArchId`))) left join `OSDict` on((`NinetyDayFailed`.`OSId` = `OSDict`.`OSId`))) order by ifnull(`SevenDayFailed`.`Failed`,0) desc,ifnull(`ThirtyDayFailed`.`Failed`,0) desc,`NinetyDayFailed`.`Failed` desc,`NinetyDayFailed`.`OSId` desc,`NinetyDayFailed`.`ArchId` desc */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + +-- +-- Final view structure for view `LatestDailyReport` +-- + +/*!50001 DROP TABLE IF EXISTS `LatestDailyReport`*/; +/*!50001 DROP VIEW IF EXISTS `LatestDailyReport`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50001 VIEW `LatestDailyReport` AS select `TestRun`.`TestRunName` AS `Title`,`ArchDict`.`ArchName` AS `Arch`,`OSDict`.`OSName` AS `OS`,timediff(`TestRun`.`EndTime`,`TestRun`.`StartTime`) AS `Duration`,(select count(0) from `TestResult` where ((`TestResult`.`TestRunId` = `TestRun`.`TestRunId`) and `TestResult`.`ResultId` in (select `ResultDict`.`ResultId` from `ResultDict` where (`ResultDict`.`ResultName` = 'Passed')))) AS `Passed`,(select count(0) from `TestResult` where ((`TestResult`.`TestRunId` = `TestRun`.`TestRunId`) and `TestResult`.`ResultId` in (select `ResultDict`.`ResultId` from `ResultDict` where (`ResultDict`.`ResultName` = 'Failed')))) AS `Failed`,(select count(0) from `TestResult` where ((`TestResult`.`TestRunId` = `TestRun`.`TestRunId`) and `TestResult`.`ResultId` in (select `ResultDict`.`ResultId` from `ResultDict` where (`ResultDict`.`ResultName` = 'No run')))) AS `No run`,(select count(0) from `TestResult` where (`TestResult`.`TestRunId` = `TestRun`.`TestRunId`)) AS `Subtotal`,ifnull(concat(round((((select count(0) from `TestResult` where ((`TestResult`.`TestRunId` = `TestRun`.`TestRunId`) and `TestResult`.`ResultId` in (select `ResultDict`.`ResultId` from `ResultDict` where (`ResultDict`.`ResultName` = 'Passed')))) / ((select count(0) from `TestResult` where ((`TestResult`.`TestRunId` = `TestRun`.`TestRunId`) and `TestResult`.`ResultId` in (select `ResultDict`.`ResultId` from `ResultDict` where (`ResultDict`.`ResultName` = 'Passed')))) + (select count(0) from `TestResult` where ((`TestResult`.`TestRunId` = `TestRun`.`TestRunId`) and `TestResult`.`ResultId` in (select `ResultDict`.`ResultId` from `ResultDict` where (`ResultDict`.`ResultName` = 'Failed')))))) * 100),2),'%'),'N/A') AS `Pass rate`,(select ifnull(group_concat(`TestCase`.`TestCaseName` separator ' '),'') from (`TestResult` left join `TestCase` on((`TestResult`.`TestCaseId` = `TestCase`.`TestCaseId`))) where ((`TestResult`.`TestRunId` = `TestRun`.`TestRunId`) and `TestResult`.`ResultId` in (select `ResultDict`.`ResultId` from `ResultDict` where (`ResultDict`.`ResultName` = 'Failed')))) AS `Failed test cases` from ((`TestRun` left join `ArchDict` on((`TestRun`.`ArchId` = `ArchDict`.`ArchId`))) left join `OSDict` on((`TestRun`.`OSId` = `OSDict`.`OSId`))) where `TestRun`.`TestRunId` in (select max(`TestRun`.`TestRunId`) AS `TestRunId` from `TestRun` where (`TestRun`.`StartTime` > (now() - interval 2 day)) group by `TestRun`.`ArchId`,`TestRun`.`OSId` order by max(`TestRun`.`TestRunId`)) */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + +-- +-- Final view structure for view `NinetyDayFailed` +-- + +/*!50001 DROP TABLE IF EXISTS `NinetyDayFailed`*/; +/*!50001 DROP VIEW IF EXISTS `NinetyDayFailed`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50001 VIEW `NinetyDayFailed` AS select `TestResult`.`TestCaseId` AS `TestCaseId`,`TestRun`.`ArchId` AS `ArchId`,`TestRun`.`OSId` AS `OSId`,count(0) AS `Failed` from (`TestResult` left join `TestRun` on((`TestResult`.`TestRunId` = `TestRun`.`TestRunId`))) where (`TestResult`.`TestRunId` in (select `TestRun`.`TestRunId` from `TestRun` where (`TestRun`.`StartTime` > (now() - interval 90 day))) and `TestResult`.`ResultId` in (select `ResultDict`.`ResultId` from `ResultDict` where (`ResultDict`.`ResultName` = 'Failed'))) group by `TestResult`.`TestCaseId`,`TestRun`.`ArchId`,`TestRun`.`OSId` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + +-- +-- Final view structure for view `NinetyDayLookBack` +-- + +/*!50001 DROP TABLE IF EXISTS `NinetyDayLookBack`*/; +/*!50001 DROP VIEW IF EXISTS `NinetyDayLookBack`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50001 VIEW `NinetyDayLookBack` AS select `ArchDict`.`ArchName` AS `Arch`,`OSDict`.`OSName` AS `OS`,count(0) AS `Test runs`,sum(`NinetyDayReport`.`Passed`) AS `Passed`,sum(`NinetyDayReport`.`Failed`) AS `Failed`,sum(`NinetyDayReport`.`No run`) AS `No run`,sum(`NinetyDayReport`.`Subtotal`) AS `Subtotal`,ifnull(concat(round(((sum(`NinetyDayReport`.`Passed`) / (sum(`NinetyDayReport`.`Passed`) + sum(`NinetyDayReport`.`Failed`))) * 100),2),'%'),'N/A') AS `Pass rate` from ((`NinetyDayReport` left join `ArchDict` on((`NinetyDayReport`.`ArchId` = `ArchDict`.`ArchId`))) left join `OSDict` on((`NinetyDayReport`.`OSId` = `OSDict`.`OSId`))) group by `NinetyDayReport`.`ArchId`,`NinetyDayReport`.`OSId` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + +-- +-- Final view structure for view `NinetyDayReport` +-- + +/*!50001 DROP TABLE IF EXISTS `NinetyDayReport`*/; +/*!50001 DROP VIEW IF EXISTS `NinetyDayReport`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50001 VIEW `NinetyDayReport` AS select `TestRun`.`ArchId` AS `ArchId`,`TestRun`.`OSId` AS `OSId`,(select count(0) from `TestResult` where ((`TestResult`.`TestRunId` = `TestRun`.`TestRunId`) and `TestResult`.`ResultId` in (select `ResultDict`.`ResultId` from `ResultDict` where (`ResultDict`.`ResultName` = 'Passed')))) AS `Passed`,(select count(0) from `TestResult` where ((`TestResult`.`TestRunId` = `TestRun`.`TestRunId`) and `TestResult`.`ResultId` in (select `ResultDict`.`ResultId` from `ResultDict` where (`ResultDict`.`ResultName` = 'Failed')))) AS `Failed`,(select count(0) from `TestResult` where ((`TestResult`.`TestRunId` = `TestRun`.`TestRunId`) and `TestResult`.`ResultId` in (select `ResultDict`.`ResultId` from `ResultDict` where (`ResultDict`.`ResultName` = 'No run')))) AS `No run`,(select count(0) from `TestResult` where (`TestResult`.`TestRunId` = `TestRun`.`TestRunId`)) AS `Subtotal` from `TestRun` where `TestRun`.`TestRunId` in (select `TestRun`.`TestRunId` from `TestRun` where (`TestRun`.`StartTime` > (now() - interval 90 day))) */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + +-- +-- Final view structure for view `SevenDayFailed` +-- + +/*!50001 DROP TABLE IF EXISTS `SevenDayFailed`*/; +/*!50001 DROP VIEW IF EXISTS `SevenDayFailed`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50001 VIEW `SevenDayFailed` AS select `TestResult`.`TestCaseId` AS `TestCaseId`,`TestRun`.`ArchId` AS `ArchId`,`TestRun`.`OSId` AS `OSId`,count(0) AS `Failed` from (`TestResult` left join `TestRun` on((`TestResult`.`TestRunId` = `TestRun`.`TestRunId`))) where (`TestResult`.`TestRunId` in (select `TestRun`.`TestRunId` from `TestRun` where (`TestRun`.`StartTime` > (now() - interval 7 day))) and `TestResult`.`ResultId` in (select `ResultDict`.`ResultId` from `ResultDict` where (`ResultDict`.`ResultName` = 'Failed'))) group by `TestResult`.`TestCaseId`,`TestRun`.`ArchId`,`TestRun`.`OSId` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + +-- +-- Final view structure for view `SevenDayLookBack` +-- + +/*!50001 DROP TABLE IF EXISTS `SevenDayLookBack`*/; +/*!50001 DROP VIEW IF EXISTS `SevenDayLookBack`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50001 VIEW `SevenDayLookBack` AS select `ArchDict`.`ArchName` AS `Arch`,`OSDict`.`OSName` AS `OS`,count(0) AS `Test runs`,sum(`SevenDayReport`.`Passed`) AS `Passed`,sum(`SevenDayReport`.`Failed`) AS `Failed`,sum(`SevenDayReport`.`No run`) AS `No run`,sum(`SevenDayReport`.`Subtotal`) AS `Subtotal`,ifnull(concat(round(((sum(`SevenDayReport`.`Passed`) / (sum(`SevenDayReport`.`Passed`) + sum(`SevenDayReport`.`Failed`))) * 100),2),'%'),'N/A') AS `Pass rate` from ((`SevenDayReport` left join `ArchDict` on((`SevenDayReport`.`ArchId` = `ArchDict`.`ArchId`))) left join `OSDict` on((`SevenDayReport`.`OSId` = `OSDict`.`OSId`))) group by `SevenDayReport`.`ArchId`,`SevenDayReport`.`OSId` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + +-- +-- Final view structure for view `SevenDayReport` +-- + +/*!50001 DROP TABLE IF EXISTS `SevenDayReport`*/; +/*!50001 DROP VIEW IF EXISTS `SevenDayReport`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50001 VIEW `SevenDayReport` AS select `TestRun`.`ArchId` AS `ArchId`,`TestRun`.`OSId` AS `OSId`,(select count(0) from `TestResult` where ((`TestResult`.`TestRunId` = `TestRun`.`TestRunId`) and `TestResult`.`ResultId` in (select `ResultDict`.`ResultId` from `ResultDict` where (`ResultDict`.`ResultName` = 'Passed')))) AS `Passed`,(select count(0) from `TestResult` where ((`TestResult`.`TestRunId` = `TestRun`.`TestRunId`) and `TestResult`.`ResultId` in (select `ResultDict`.`ResultId` from `ResultDict` where (`ResultDict`.`ResultName` = 'Failed')))) AS `Failed`,(select count(0) from `TestResult` where ((`TestResult`.`TestRunId` = `TestRun`.`TestRunId`) and `TestResult`.`ResultId` in (select `ResultDict`.`ResultId` from `ResultDict` where (`ResultDict`.`ResultName` = 'No run')))) AS `No run`,(select count(0) from `TestResult` where (`TestResult`.`TestRunId` = `TestRun`.`TestRunId`)) AS `Subtotal` from `TestRun` where `TestRun`.`TestRunId` in (select `TestRun`.`TestRunId` from `TestRun` where (`TestRun`.`StartTime` > (now() - interval 7 day))) */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + +-- +-- Final view structure for view `ThirtyDayFailed` +-- + +/*!50001 DROP TABLE IF EXISTS `ThirtyDayFailed`*/; +/*!50001 DROP VIEW IF EXISTS `ThirtyDayFailed`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50001 VIEW `ThirtyDayFailed` AS select `TestResult`.`TestCaseId` AS `TestCaseId`,`TestRun`.`ArchId` AS `ArchId`,`TestRun`.`OSId` AS `OSId`,count(0) AS `Failed` from (`TestResult` left join `TestRun` on((`TestResult`.`TestRunId` = `TestRun`.`TestRunId`))) where (`TestResult`.`TestRunId` in (select `TestRun`.`TestRunId` from `TestRun` where (`TestRun`.`StartTime` > (now() - interval 30 day))) and `TestResult`.`ResultId` in (select `ResultDict`.`ResultId` from `ResultDict` where (`ResultDict`.`ResultName` = 'Failed'))) group by `TestResult`.`TestCaseId`,`TestRun`.`ArchId`,`TestRun`.`OSId` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + +-- +-- Final view structure for view `ThirtyDayLookBack` +-- + +/*!50001 DROP TABLE IF EXISTS `ThirtyDayLookBack`*/; +/*!50001 DROP VIEW IF EXISTS `ThirtyDayLookBack`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50001 VIEW `ThirtyDayLookBack` AS select `ArchDict`.`ArchName` AS `Arch`,`OSDict`.`OSName` AS `OS`,count(0) AS `Test runs`,sum(`ThirtyDayReport`.`Passed`) AS `Passed`,sum(`ThirtyDayReport`.`Failed`) AS `Failed`,sum(`ThirtyDayReport`.`No run`) AS `No run`,sum(`ThirtyDayReport`.`Subtotal`) AS `Subtotal`,ifnull(concat(round(((sum(`ThirtyDayReport`.`Passed`) / (sum(`ThirtyDayReport`.`Passed`) + sum(`ThirtyDayReport`.`Failed`))) * 100),2),'%'),'N/A') AS `Pass rate` from ((`ThirtyDayReport` left join `ArchDict` on((`ThirtyDayReport`.`ArchId` = `ArchDict`.`ArchId`))) left join `OSDict` on((`ThirtyDayReport`.`OSId` = `OSDict`.`OSId`))) group by `ThirtyDayReport`.`ArchId`,`ThirtyDayReport`.`OSId` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + +-- +-- Final view structure for view `ThirtyDayReport` +-- + +/*!50001 DROP TABLE IF EXISTS `ThirtyDayReport`*/; +/*!50001 DROP VIEW IF EXISTS `ThirtyDayReport`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50001 VIEW `ThirtyDayReport` AS select `TestRun`.`ArchId` AS `ArchId`,`TestRun`.`OSId` AS `OSId`,(select count(0) from `TestResult` where ((`TestResult`.`TestRunId` = `TestRun`.`TestRunId`) and `TestResult`.`ResultId` in (select `ResultDict`.`ResultId` from `ResultDict` where (`ResultDict`.`ResultName` = 'Passed')))) AS `Passed`,(select count(0) from `TestResult` where ((`TestResult`.`TestRunId` = `TestRun`.`TestRunId`) and `TestResult`.`ResultId` in (select `ResultDict`.`ResultId` from `ResultDict` where (`ResultDict`.`ResultName` = 'Failed')))) AS `Failed`,(select count(0) from `TestResult` where ((`TestResult`.`TestRunId` = `TestRun`.`TestRunId`) and `TestResult`.`ResultId` in (select `ResultDict`.`ResultId` from `ResultDict` where (`ResultDict`.`ResultName` = 'No run')))) AS `No run`,(select count(0) from `TestResult` where (`TestResult`.`TestRunId` = `TestRun`.`TestRunId`)) AS `Subtotal` from `TestRun` where `TestRun`.`TestRunId` in (select `TestRun`.`TestRunId` from `TestRun` where (`TestRun`.`StartTime` > (now() - interval 30 day))) */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2016-06-07 1:14:01 diff --git a/xCAT-server/share/xcat/tools/jenkins/testreport/xcatjk-log2sql.sh b/xCAT-server/share/xcat/tools/jenkins/testreport/xcatjk-log2sql.sh new file mode 100755 index 000000000..1dc323efa --- /dev/null +++ b/xCAT-server/share/xcat/tools/jenkins/testreport/xcatjk-log2sql.sh @@ -0,0 +1,459 @@ +#!/bin/bash + +function usage() +{ + local script="${0##*/}" + + while read ; do echo "${REPLY}" ; done <<-EOF + Usage: ${script} [OPTIONS] DIRECTORY + + Options: + --help display this help and exit + + Examples: + + ${script} /xCATjk/log/ubuntu16.04-ppc64el/8 + EOF +} + +PATH="/usr/sbin:/usr/bin:/sbin:/bin" +export PATH + +# +# warn_if_bad Put out warning message(s) if $1 has bad RC. +# +# $1 0 (pass) or non-zero (fail). +# $2+ Remaining arguments printed only if the $1 is non-zero. +# +# Incoming $1 is returned unless it is 0 +# +function warn_if_bad() +{ + local -i rc="$1" + local script="${0##*/}" + + # Ignore if no problems + [ "${rc}" -eq "0" ] && return 0 + + # Broken + shift + echo "${script}: $@" >&2 + return "${rc}" +} + +# +# exit_if_bad Put out error message(s) if $1 has bad RC. +# +# $1 0 (pass) or non-zero (fail). +# $2+ Remaining arguments printed only if the $1 is non-zero. +# +# Exits with 1 unless $1 is 0 +# +function exit_if_bad() +{ + warn_if_bad "$@" || exit 1 + return 0 +} + +# +# check_root_or_exit +# +# Breaks the script if not running as root. +# +# If this returns 1, the invoker MUST abort the script. +# +# Returns 0 if running as root +# Returns 1 if not (and breaks the script) +# +function check_root_or_exit() +{ + [ "${UID}" -eq "0" ] + exit_if_bad "$?" "Must be run by UID=0. Actual UID=${UID}." + return 0 +} + +# +# check_executes Check for executable(s) +# +# Returns 0 if true. +# Returns 1 if not. +# +function check_executes() +{ + local cmd + local all_ok="yes" + for cmd in "$@" + do + if ! type "${cmd}" &>/dev/null + then + echo "Command \"${cmd}\" not found." >&2 + all_ok="no" + fi + done + [ "${all_ok}" = "yes" ] +} + +# +# check_exec_or_exit Check for required executables. +# +# Exits (not returns) if commands listed on command line do not exist. +# +# Returns 0 if true. +# Exits with 1 if not. +# +function check_exec_or_exit() +{ + check_executes "$@" + exit_if_bad "$?" "Above listed required command(s) not found." + return 0 +} + +TMP_DIR="" + +# +# internal_setup Script setup +# +# Returns 0 on success. +# Exits (not returns) with 1 on failure. +# +function internal_setup() +{ + shopt -s extglob + + # Trap exit for internal_cleanup function. + trap "internal_cleanup" EXIT + + check_exec_or_exit awk mktemp printf + + umask 0077 + + TMP_DIR="$(mktemp -d "/tmp/${0##*/}.XXXXXXXX" 2>/dev/null)" + [ -d "${TMP_DIR}" ] + exit_if_bad "$?" "Make temporary directory failed." + + custom_setup +} + +# +# internal_cleanup Script cleanup (reached via trap 0) +# +# Destory any temporarily facility created by internal_setup. +# +function internal_cleanup() +{ + custom_cleanup + + [ -d "${TMP_DIR}" ] && rm -rf "${TMP_DIR}" +} + +# +# custom_setup +# +function custom_setup() +{ + check_exec_or_exit awk sed tr date +} + +# +# custom_cleanup +# +function custom_cleanup() +{ + : +} + +# +# cleanup_n_exec Do the cleanup, then execute the command +# +# $1+ The command to execute +# +function cleanup_n_exec() +{ + internal_cleanup + + exec "$@" +} + +internal_setup + +# +# xcattestlog2sql +# +# $1 The name of the test run +# $2 Log file of xcattest +# +function xcattestlog2sql() +{ + local test_run_name="$1" + local logfile="$2" + + local test_case_name="" + local test_case_result="" + local duration="" + + [ -n "${test_run_name}" ] + warn_if_bad "$?" "test run has no name" || return 1 + + while read ; do echo "${REPLY}" ; done <<-EOF + -- + -- Test run has name '${test_run_name}' + -- + + EOF + + [ -f "${logfile}" ] + warn_if_bad "$?" "${logfile}: No such log file" || return 1 + + while read ; do echo "${REPLY}" ; done <<-EOF + -- + -- Analysis file '${logfile}' + -- + + EOF + + while read test_case_name test_case_result duration + do + while read ; do echo "${REPLY}" ; done <<-EOF + INSERT INTO TestCase (TestCaseId, TestCaseName) + SELECT * FROM (SELECT NULL, '${test_case_name}') AS tmp + WHERE NOT EXISTS ( + SELECT TestCaseId FROM TestCase WHERE TestCaseName = '${test_case_name}' + ) LIMIT 1; + + INSERT INTO ResultDict (ResultId, ResultName) + SELECT * FROM (SELECT NULL, '${test_case_result}') AS tmp + WHERE NOT EXISTS ( + SELECT ResultId FROM ResultDict WHERE ResultName = '${test_case_result}' + ) LIMIT 1; + + REPLACE INTO TestResult (TestRunId, TestCaseId, ResultId, DurationTime) + SELECT ( + SELECT TestRunId FROM TestRun WHERE TestRunName = '${test_run_name}' + ) AS TestRunId, ( + SELECT TestCaseId FROM TestCase WHERE TestCaseName = '${test_case_name}' + ) AS TestCaseId, ( + SELECT ResultId FROM ResultDict WHERE ResultName = '${test_case_result}' + ) AS ResultId, '${duration}'; + + EOF + done < <(tr -d '\r' <"${logfile}" | grep "^------END" | + sed -e 's/^.*END::\(.*\)::\([A-Za-z0-9]*\)::.*Duration::\(-*[0-9]*\) sec.*$/\1 \2 \3/') + + return 0 +} + +# +# xcattestbundle2sql +# +# $1 The name of the test run +# $2 Bundle file of xcattest +# +function xcattestbundle2sql() +{ + local test_run_name="$1" + local logfile="$2" + + local test_case_name="" + local test_case_result="No run" + + [ -n "${test_run_name}" ] + warn_if_bad "$?" "test run has no name" || return 1 + + while read ; do echo "${REPLY}" ; done <<-EOF + -- + -- Test run has name '${test_run_name}' + -- + + EOF + + [ -f "${logfile}" ] + warn_if_bad "$?" "${logfile}: No such log file" || return 1 + + while read ; do echo "${REPLY}" ; done <<-EOF + -- + -- Analysis file '${logfile}' + -- + + INSERT INTO ResultDict (ResultId, ResultName) + SELECT * FROM (SELECT NULL, '${test_case_result}') AS tmp + WHERE NOT EXISTS ( + SELECT ResultId FROM ResultDict WHERE ResultName = '${test_case_result}' + ) LIMIT 1; + + EOF + + while read test_case_name + do + # Need chomp ${test_case_name} + test_case_name=$(echo ${test_case_name}) + + while read ; do echo "${REPLY}" ; done <<-EOF + INSERT INTO TestCase (TestCaseId, TestCaseName) + SELECT * FROM (SELECT NULL, '${test_case_name}') AS tmp + WHERE NOT EXISTS ( + SELECT TestCaseId FROM TestCase WHERE TestCaseName = '${test_case_name}' + ) LIMIT 1; + + INSERT IGNORE INTO TestResult (TestRunId, TestCaseId, ResultId, DurationTime) + SELECT ( + SELECT TestRunId FROM TestRun WHERE TestRunName = '${test_run_name}' + ) AS TestRunId, ( + SELECT TestCaseId FROM TestCase WHERE TestCaseName = '${test_case_name}' + ) AS TestCaseId, ( + SELECT ResultId FROM ResultDict WHERE ResultName = '${test_case_result}' + ) AS ResultId, '0'; + + EOF + done < <(tr -d '\r' <"${logfile}") +} + +# +# jenkinsprojectlog2sql +# +# $1 Log file of jenkins project run +# +# When return 0, will set global shell variable TestRunName +# +function jenkinsprojectlog2sql() +{ + local logfile="$1" + local foo="" + + local test_run_name="" + local start_time="" + local end_time="" + local os="" + local arch="" + local xcat_git_commit="" + local memo="" + + [ -f "${logfile}" ] + warn_if_bad "$?" "${logfile}: No such log file" || return 1 + + while read ; do echo "${REPLY}" ; done <<-EOF + -- + -- Analysis file '${logfile}' + -- + + EOF + + test_run_name="$(tr -d '\r' <"${logfile}" | + awk '/project.*description/ { print $(NF - 1) }')" + [ -n "${test_run_name}" ] + warn_if_bad "$?" "${test_run_name}: fail to parse test run name" || return 1 + + foo="$(tr -d '\r' <"${logfile}" | head -n 1 | cut -d ' ' -f 1)" + [ "${#foo}" = 14 ] + warn_if_bad "$?" "${foo}: fail to parse test start time" || return 1 + start_time="${foo:0:4}-${foo:4:2}-${foo:6:2} ${foo:8:2}:${foo:10:2}:${foo:12:2}" + + foo="$(tr -d '\r' <"${logfile}" | tail -n 1 | cut -d ' ' -f 1)" + [ "${#foo}" = 14 ] + warn_if_bad "$?" "${foo}: fail to parse test end time" || return 1 + end_time="${foo:0:4}-${foo:4:2}-${foo:6:2} ${foo:8:2}:${foo:10:2}:${foo:12:2}" + + arch="$(tr -d '\r' <"${logfile}" | awk -F - '/project.*description/ { print $2 }')" + [ "${arch}" = "ppc64el" ] && arch="ppc64le" + [ -n "${arch}" ] + warn_if_bad "$?" "${arch}: fail to parse arch" || return 1 + + os="$(tr -d '\r' <"${logfile}" | awk '/os.*=>/ { print $NF }')" + [ -n "${os}" ] + warn_if_bad "$?" "${os}: fail to parse operating system" || return 1 + + memo="$(tr -d '\r' <"${logfile}" | grep -A 7 'project.*description' | cut -d ' ' -f 4-)" + + while read ; do echo "${REPLY}" ; done <<-EOF + INSERT INTO ArchDict (ArchId, ArchName) + SELECT * FROM (SELECT NULL, '${arch}') AS tmp + WHERE NOT EXISTS ( + SELECT ArchId FROM ArchDict WHERE ArchName = '${arch}' + ) LIMIT 1; + + INSERT INTO OSDict (OSId, OSName) + SELECT * FROM (SELECT NULL, '${os}') AS tmp + WHERE NOT EXISTS ( + SELECT OSId FROM OSDict WHERE OSName = '${os}' + ) LIMIT 1; + + INSERT IGNORE INTO TestRun + (TestRunId, TestRunName, StartTime, EndTime, ArchId, OSId, xCATgitCommit, Memo) + SELECT NULL, '${test_run_name}', '${start_time}', '${end_time}', ( + SELECT ArchId FROM ArchDict WHERE ArchName = '${arch}' + ) AS ArchId, ( + SELECT OSId FROM OSDict WHERE OSName = '${os}' + ) AS OSId, '${xcat_git_commit}', '${memo}'; + + EOF + + TestRunName="${test_run_name}" + + return 0 +} + +# Main + +declare VERSION="0.00.1" + +declare xCATjkLog_DIR="" +declare TestRunName="" + +declare JenkinsProjectLog="" +declare xCATTestLogs="" + +while [ "$#" -gt "0" ] +do + case "$1" in + "--help") + usage + exit 0 + ;; + *) + [ "$1" == "--" ] && shift + [ -z "${xCATjkLog_DIR}" ] + exit_if_bad "$?" "invalid predicate - $1" + xCATjkLog_DIR="$1" + ;; + esac + shift +done + +[ -z "${xCATjkLog_DIR}" ] && usage >&2 && exit 1 + +[ -d "${xCATjkLog_DIR}" ] +exit_if_bad "$?" "${xCATjkLog_DIR}: No such directory" + +# Check if the mail log is there. If it is not, exit directly +JenkinsMailLog="$(echo "${xCATjkLog_DIR}/mail."*)" +[ -f "${JenkinsMailLog}" ] +exit_if_bad "$?" "${JenkinsMailLog}: no such log file" + +while read ; do echo "${REPLY}" ; done </dev/null 2>&1 && + echo "Command \"readlink\" not found" >&2 && exit 1 +while [ -L "${SCRIPT}" ] +do + LINK="$(readlink "${SCRIPT}")" + if [ "/" = "${LINK:0:1}" ] + then + SCRIPT="${LINK}" + else + SCRIPT="${SCRIPT%/*}/${LINK}" + fi +done +BASE_DIR="${SCRIPT%/*}" + +xCATjkScanLogs="${BASE_DIR}/xcatjk-scanlogs.sh" +if [ ! -x "${xCATjkScanLogs}" ] +then + echo "Script ${xCATjkScanLogs} not found" >&2 + exit 1 +fi + +while read ; do echo "${REPLY}" ; done </dev/null 2>&1 && + echo "Command \"readlink\" not found" >&2 && exit 1 +while [ -L "${SCRIPT}" ] +do + LINK="$(readlink "${SCRIPT}")" + if [ "/" = "${LINK:0:1}" ] + then + SCRIPT="${LINK}" + else + SCRIPT="${SCRIPT%/*}/${LINK}" + fi +done +BASE_DIR="${SCRIPT%/*}" + +SQLofCreateTables="${BASE_DIR}/xCATjkLogAnalyzer.sql" +if [ ! -f "${SQLofCreateTables}" ] +then + echo "${SQLofCreateTables}: SQL file not found" >&2 + exit 1 +fi + + +xCATjkScanLogs="${BASE_DIR}/xcatjk-scanlogs.sh" +if [ ! -x "${xCATjkScanLogs}" ] +then + echo "Script ${xCATjkScanLogs} not found" >&2 + exit 1 +fi + +while read ; do echo "${REPLY}" ; done <&2 + return "${rc}" +} + +# +# exit_if_bad Put out error message(s) if $1 has bad RC. +# +# $1 0 (pass) or non-zero (fail). +# $2+ Remaining arguments printed only if the $1 is non-zero. +# +# Exits with 1 unless $1 is 0 +# +function exit_if_bad() +{ + warn_if_bad "$@" || exit 1 + return 0 +} + +# +# check_root_or_exit +# +# Breaks the script if not running as root. +# +# If this returns 1, the invoker MUST abort the script. +# +# Returns 0 if running as root +# Returns 1 if not (and breaks the script) +# +function check_root_or_exit() +{ + [ "${UID}" -eq "0" ] + exit_if_bad "$?" "Must be run by UID=0. Actual UID=${UID}." + return 0 +} + +# +# check_executes Check for executable(s) +# +# Returns 0 if true. +# Returns 1 if not. +# +function check_executes() +{ + local cmd + local all_ok="yes" + for cmd in "$@" + do + if ! type "${cmd}" &>/dev/null + then + echo "Command \"${cmd}\" not found." >&2 + all_ok="no" + fi + done + [ "${all_ok}" = "yes" ] +} + +# +# check_exec_or_exit Check for required executables. +# +# Exits (not returns) if commands listed on command line do not exist. +# +# Returns 0 if true. +# Exits with 1 if not. +# +function check_exec_or_exit() +{ + check_executes "$@" + exit_if_bad "$?" "Above listed required command(s) not found." + return 0 +} + +TMP_DIR="" + +# +# internal_setup Script setup +# +# Returns 0 on success. +# Exits (not returns) with 1 on failure. +# +function internal_setup() +{ + shopt -s extglob + + # Trap exit for internal_cleanup function. + trap "internal_cleanup" EXIT + + check_exec_or_exit awk mktemp printf + + umask 0077 + + TMP_DIR="$(mktemp -d "/tmp/${0##*/}.XXXXXXXX" 2>/dev/null)" + [ -d "${TMP_DIR}" ] + exit_if_bad "$?" "Make temporary directory failed." + + custom_setup +} + +# +# internal_cleanup Script cleanup (reached via trap 0) +# +# Destory any temporarily facility created by internal_setup. +# +function internal_cleanup() +{ + custom_cleanup + + [ -d "${TMP_DIR}" ] && rm -rf "${TMP_DIR}" +} + +# +# custom_setup +# +function custom_setup() +{ + check_exec_or_exit awk dirname +} + +# +# custom_cleanup +# +function custom_cleanup() +{ + : +} + +# +# cleanup_n_exec Do the cleanup, then execute the command +# +# $1+ The command to execute +# +function cleanup_n_exec() +{ + internal_cleanup + + exec "$@" +} + +internal_setup + +SCRIPT="$0" +! type readlink >/dev/null 2>&1 && + echo "Command \"readlink\" not found" >&2 && exit 1 +while [ -L "${SCRIPT}" ] +do + LINK="$(readlink "${SCRIPT}")" + if [ "/" = "${LINK:0:1}" ] + then + SCRIPT="${LINK}" + else + SCRIPT="${SCRIPT%/*}/${LINK}" + fi +done +BASE_DIR="${SCRIPT%/*}" + +xCATjkLog2SQL="${BASE_DIR}/xcatjk-log2sql.sh" +[ -x "${xCATjkLog2SQL}" ] +exit_if_bad "$?" "Script ${xCATjkLog2SQL} not found" + +declare VERSION="0.0.1" + +declare xCATjkLog_TOPDIR="" +declare -a FIND_ARGS=() + +while [ "$#" -gt "0" ] +do + case "$1" in + "--help") + usage + exit 0 + ;; + "--recent") + FIND_ARGS=(-mtime -3) + ;; + *) + [ "$1" == "--" ] && shift + [ -z "${xCATjkLog_TopDir}" ] + exit_if_bad "$?" "invalid predicate - $1" + xCATjkLog_TopDir="$1" + ;; + esac + shift +done + +[ -z "${xCATjkLog_TopDir}" ] && usage >&2 && exit 1 + +[ -d "${xCATjkLog_TopDir}" ] +exit_if_bad "$?" "${xCATjkLog_TopDir}: No such directory" + +while read ; do echo "${REPLY}" ; done < Date: Thu, 16 Jun 2016 11:15:45 +0800 Subject: [PATCH 002/106] [xCAT Jenkins Email Report] Change the subject line of the xCAT Jenkins mail test report --- .../share/xcat/tools/jenkins/testreport/send-report.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh b/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh index 60e1ff1b7..4012385ce 100755 --- a/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh +++ b/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh @@ -37,14 +37,14 @@ Email report $report_setTo "Alice" alice@example.org -$report_setFrom "xCATjk Mail Bot" root@localhost.localdomain +$report_setFrom "xCAT Jenkins Mail Bot" root@localhost.localdomain DateTime="$(date -R)" MYSQL_COMMAND=("mysql" "-h" "${MYSQL_HOST}" -u "${MYSQL_USER}" -p"${MYSQL_PASS}" "${MYSQL_DB}") Subject="$("${MYSQL_COMMAND[@]}" <<<"SELECT CONCAT('Passed: ', SUM(Passed), ' Failed: ', SUM(Failed), ' No run: ', SUM(\`No run\`)) AS Summary FROM LatestDailyReport;" | tail -n 1)" -$report_setSubject "[xCATjk] ${Subject}" +$report_setSubject "[xCAT Jenkins] ${Subject}" $report_setHTML <<-EOF From 7f45b7b551f2acdc55269e5fba25b73253925c9b Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Tue, 28 Jun 2016 05:50:34 -0400 Subject: [PATCH 003/106] [xCAT Jenkins Email Report] Change all the VARCHAR to VARCHAR BINARY for case sensitive string comparison --- .../jenkins/testreport/xCATjkLogAnalyzer.sql | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/xCAT-server/share/xcat/tools/jenkins/testreport/xCATjkLogAnalyzer.sql b/xCAT-server/share/xcat/tools/jenkins/testreport/xCATjkLogAnalyzer.sql index d2f9a90d0..8759427f8 100644 --- a/xCAT-server/share/xcat/tools/jenkins/testreport/xCATjkLogAnalyzer.sql +++ b/xCAT-server/share/xcat/tools/jenkins/testreport/xCATjkLogAnalyzer.sql @@ -1,6 +1,6 @@ -- MySQL dump 10.14 Distrib 5.5.47-MariaDB, for Linux (ppc64) -- --- Host: localhost Database: xcatjkloganalyzer +-- Host: localhost Database: xCATjkLogAnalyzer -- ------------------------------------------------------ -- Server version 5.5.47-MariaDB @@ -24,7 +24,7 @@ DROP TABLE IF EXISTS `ArchDict`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `ArchDict` ( `ArchId` int(11) NOT NULL AUTO_INCREMENT, - `ArchName` varchar(255) NOT NULL, + `ArchName` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, PRIMARY KEY (`ArchId`), UNIQUE KEY `ArchName` (`ArchName`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -133,7 +133,7 @@ DROP TABLE IF EXISTS `OSDict`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `OSDict` ( `OSId` int(11) NOT NULL AUTO_INCREMENT, - `OSName` varchar(255) NOT NULL, + `OSName` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, PRIMARY KEY (`OSId`), UNIQUE KEY `OSName` (`OSName`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -148,7 +148,7 @@ DROP TABLE IF EXISTS `ResultDict`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `ResultDict` ( `ResultId` int(11) NOT NULL AUTO_INCREMENT, - `ResultName` varchar(255) NOT NULL, + `ResultName` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, PRIMARY KEY (`ResultId`), UNIQUE KEY `ResultName` (`ResultName`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -217,7 +217,7 @@ DROP TABLE IF EXISTS `TestCase`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `TestCase` ( `TestCaseId` int(11) NOT NULL AUTO_INCREMENT, - `TestCaseName` varchar(255) NOT NULL, + `TestCaseName` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, `Memo` text NOT NULL, PRIMARY KEY (`TestCaseId`), UNIQUE KEY `TestCaseName` (`TestCaseName`) @@ -254,12 +254,12 @@ DROP TABLE IF EXISTS `TestRun`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `TestRun` ( `TestRunId` int(11) NOT NULL AUTO_INCREMENT, - `TestRunName` varchar(255) NOT NULL, + `TestRunName` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, `StartTime` datetime NOT NULL, `EndTime` datetime NOT NULL, `ArchId` int(11) NOT NULL, `OSId` int(11) NOT NULL, - `xCATgitCommit` varchar(255) NOT NULL, + `xCATgitCommit` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, `Memo` text NOT NULL, PRIMARY KEY (`TestRunId`), UNIQUE KEY `TestRunName` (`TestRunName`), @@ -542,4 +542,4 @@ SET character_set_client = @saved_cs_client; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2016-06-07 1:14:01 +-- Dump completed on 2016-06-29 4:52:47 From 20f186efa6fccf28d7715ce2055659e8045df3be Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Thu, 30 Jun 2016 15:23:02 +0800 Subject: [PATCH 004/106] [xCAT Jenkins Email Report] Order test results by OSName, then ArchName --- .../tools/jenkins/testreport/xCATjkLogAnalyzer.sql | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/xCAT-server/share/xcat/tools/jenkins/testreport/xCATjkLogAnalyzer.sql b/xCAT-server/share/xcat/tools/jenkins/testreport/xCATjkLogAnalyzer.sql index 8759427f8..215df71fa 100644 --- a/xCAT-server/share/xcat/tools/jenkins/testreport/xCATjkLogAnalyzer.sql +++ b/xCAT-server/share/xcat/tools/jenkins/testreport/xCATjkLogAnalyzer.sql @@ -338,7 +338,7 @@ SET character_set_client = @saved_cs_client; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `FailedTestCasesTopList` AS select `TestCase`.`TestCaseName` AS `Test case`,`ArchDict`.`ArchName` AS `Arch`,`OSDict`.`OSName` AS `OS`,ifnull(`SevenDayFailed`.`Failed`,0) AS `Last seven days`,ifnull(`ThirtyDayFailed`.`Failed`,0) AS `Last thirty days`,`NinetyDayFailed`.`Failed` AS `Last ninety days` from (((((`NinetyDayFailed` left join `SevenDayFailed` on(((`NinetyDayFailed`.`TestCaseId` = `SevenDayFailed`.`TestCaseId`) and (`NinetyDayFailed`.`ArchId` = `SevenDayFailed`.`ArchId`) and (`NinetyDayFailed`.`OSId` = `SevenDayFailed`.`OSId`)))) left join `ThirtyDayFailed` on(((`NinetyDayFailed`.`TestCaseId` = `ThirtyDayFailed`.`TestCaseId`) and (`NinetyDayFailed`.`ArchId` = `ThirtyDayFailed`.`ArchId`) and (`NinetyDayFailed`.`OSId` = `ThirtyDayFailed`.`OSId`)))) left join `TestCase` on((`NinetyDayFailed`.`TestCaseId` = `TestCase`.`TestCaseId`))) left join `ArchDict` on((`NinetyDayFailed`.`ArchId` = `ArchDict`.`ArchId`))) left join `OSDict` on((`NinetyDayFailed`.`OSId` = `OSDict`.`OSId`))) order by ifnull(`SevenDayFailed`.`Failed`,0) desc,ifnull(`ThirtyDayFailed`.`Failed`,0) desc,`NinetyDayFailed`.`Failed` desc,`NinetyDayFailed`.`OSId` desc,`NinetyDayFailed`.`ArchId` desc */; +/*!50001 VIEW `FailedTestCasesTopList` AS select `TestCase`.`TestCaseName` AS `Test case`,`ArchDict`.`ArchName` AS `Arch`,`OSDict`.`OSName` AS `OS`,ifnull(`SevenDayFailed`.`Failed`,0) AS `Last seven days`,ifnull(`ThirtyDayFailed`.`Failed`,0) AS `Last thirty days`,`NinetyDayFailed`.`Failed` AS `Last ninety days` from (((((`NinetyDayFailed` left join `SevenDayFailed` on(((`NinetyDayFailed`.`TestCaseId` = `SevenDayFailed`.`TestCaseId`) and (`NinetyDayFailed`.`ArchId` = `SevenDayFailed`.`ArchId`) and (`NinetyDayFailed`.`OSId` = `SevenDayFailed`.`OSId`)))) left join `ThirtyDayFailed` on(((`NinetyDayFailed`.`TestCaseId` = `ThirtyDayFailed`.`TestCaseId`) and (`NinetyDayFailed`.`ArchId` = `ThirtyDayFailed`.`ArchId`) and (`NinetyDayFailed`.`OSId` = `ThirtyDayFailed`.`OSId`)))) left join `TestCase` on((`NinetyDayFailed`.`TestCaseId` = `TestCase`.`TestCaseId`))) left join `ArchDict` on((`NinetyDayFailed`.`ArchId` = `ArchDict`.`ArchId`))) left join `OSDict` on((`NinetyDayFailed`.`OSId` = `OSDict`.`OSId`))) order by ifnull(`SevenDayFailed`.`Failed`,0) desc,ifnull(`ThirtyDayFailed`.`Failed`,0) desc,`NinetyDayFailed`.`Failed` desc,`NinetyDayFailed`.`OSId` desc,`NinetyDayFailed`.`ArchId` desc, `TestCase`.`TestCaseName` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -357,7 +357,7 @@ SET character_set_client = @saved_cs_client; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `LatestDailyReport` AS select `TestRun`.`TestRunName` AS `Title`,`ArchDict`.`ArchName` AS `Arch`,`OSDict`.`OSName` AS `OS`,timediff(`TestRun`.`EndTime`,`TestRun`.`StartTime`) AS `Duration`,(select count(0) from `TestResult` where ((`TestResult`.`TestRunId` = `TestRun`.`TestRunId`) and `TestResult`.`ResultId` in (select `ResultDict`.`ResultId` from `ResultDict` where (`ResultDict`.`ResultName` = 'Passed')))) AS `Passed`,(select count(0) from `TestResult` where ((`TestResult`.`TestRunId` = `TestRun`.`TestRunId`) and `TestResult`.`ResultId` in (select `ResultDict`.`ResultId` from `ResultDict` where (`ResultDict`.`ResultName` = 'Failed')))) AS `Failed`,(select count(0) from `TestResult` where ((`TestResult`.`TestRunId` = `TestRun`.`TestRunId`) and `TestResult`.`ResultId` in (select `ResultDict`.`ResultId` from `ResultDict` where (`ResultDict`.`ResultName` = 'No run')))) AS `No run`,(select count(0) from `TestResult` where (`TestResult`.`TestRunId` = `TestRun`.`TestRunId`)) AS `Subtotal`,ifnull(concat(round((((select count(0) from `TestResult` where ((`TestResult`.`TestRunId` = `TestRun`.`TestRunId`) and `TestResult`.`ResultId` in (select `ResultDict`.`ResultId` from `ResultDict` where (`ResultDict`.`ResultName` = 'Passed')))) / ((select count(0) from `TestResult` where ((`TestResult`.`TestRunId` = `TestRun`.`TestRunId`) and `TestResult`.`ResultId` in (select `ResultDict`.`ResultId` from `ResultDict` where (`ResultDict`.`ResultName` = 'Passed')))) + (select count(0) from `TestResult` where ((`TestResult`.`TestRunId` = `TestRun`.`TestRunId`) and `TestResult`.`ResultId` in (select `ResultDict`.`ResultId` from `ResultDict` where (`ResultDict`.`ResultName` = 'Failed')))))) * 100),2),'%'),'N/A') AS `Pass rate`,(select ifnull(group_concat(`TestCase`.`TestCaseName` separator ' '),'') from (`TestResult` left join `TestCase` on((`TestResult`.`TestCaseId` = `TestCase`.`TestCaseId`))) where ((`TestResult`.`TestRunId` = `TestRun`.`TestRunId`) and `TestResult`.`ResultId` in (select `ResultDict`.`ResultId` from `ResultDict` where (`ResultDict`.`ResultName` = 'Failed')))) AS `Failed test cases` from ((`TestRun` left join `ArchDict` on((`TestRun`.`ArchId` = `ArchDict`.`ArchId`))) left join `OSDict` on((`TestRun`.`OSId` = `OSDict`.`OSId`))) where `TestRun`.`TestRunId` in (select max(`TestRun`.`TestRunId`) AS `TestRunId` from `TestRun` where (`TestRun`.`StartTime` > (now() - interval 2 day)) group by `TestRun`.`ArchId`,`TestRun`.`OSId` order by max(`TestRun`.`TestRunId`)) */; +/*!50001 VIEW `LatestDailyReport` AS select `TestRun`.`TestRunName` AS `Title`,`ArchDict`.`ArchName` AS `Arch`,`OSDict`.`OSName` AS `OS`,timediff(`TestRun`.`EndTime`,`TestRun`.`StartTime`) AS `Duration`,(select count(0) from `TestResult` where ((`TestResult`.`TestRunId` = `TestRun`.`TestRunId`) and `TestResult`.`ResultId` in (select `ResultDict`.`ResultId` from `ResultDict` where (`ResultDict`.`ResultName` = 'Passed')))) AS `Passed`,(select count(0) from `TestResult` where ((`TestResult`.`TestRunId` = `TestRun`.`TestRunId`) and `TestResult`.`ResultId` in (select `ResultDict`.`ResultId` from `ResultDict` where (`ResultDict`.`ResultName` = 'Failed')))) AS `Failed`,(select count(0) from `TestResult` where ((`TestResult`.`TestRunId` = `TestRun`.`TestRunId`) and `TestResult`.`ResultId` in (select `ResultDict`.`ResultId` from `ResultDict` where (`ResultDict`.`ResultName` = 'No run')))) AS `No run`,(select count(0) from `TestResult` where (`TestResult`.`TestRunId` = `TestRun`.`TestRunId`)) AS `Subtotal`,ifnull(concat(round((((select count(0) from `TestResult` where ((`TestResult`.`TestRunId` = `TestRun`.`TestRunId`) and `TestResult`.`ResultId` in (select `ResultDict`.`ResultId` from `ResultDict` where (`ResultDict`.`ResultName` = 'Passed')))) / ((select count(0) from `TestResult` where ((`TestResult`.`TestRunId` = `TestRun`.`TestRunId`) and `TestResult`.`ResultId` in (select `ResultDict`.`ResultId` from `ResultDict` where (`ResultDict`.`ResultName` = 'Passed')))) + (select count(0) from `TestResult` where ((`TestResult`.`TestRunId` = `TestRun`.`TestRunId`) and `TestResult`.`ResultId` in (select `ResultDict`.`ResultId` from `ResultDict` where (`ResultDict`.`ResultName` = 'Failed')))))) * 100),2),'%'),'N/A') AS `Pass rate`,(select ifnull(group_concat(`TestCase`.`TestCaseName` separator ' '),'') from (`TestResult` left join `TestCase` on((`TestResult`.`TestCaseId` = `TestCase`.`TestCaseId`))) where ((`TestResult`.`TestRunId` = `TestRun`.`TestRunId`) and `TestResult`.`ResultId` in (select `ResultDict`.`ResultId` from `ResultDict` where (`ResultDict`.`ResultName` = 'Failed')))) AS `Failed test cases` from ((`TestRun` left join `ArchDict` on((`TestRun`.`ArchId` = `ArchDict`.`ArchId`))) left join `OSDict` on((`TestRun`.`OSId` = `OSDict`.`OSId`))) where `TestRun`.`TestRunId` in (select max(`TestRun`.`TestRunId`) AS `TestRunId` from `TestRun` where (`TestRun`.`StartTime` > (now() - interval 2 day)) group by `TestRun`.`ArchId`,`TestRun`.`OSId`) order by `OSDict`.`OSName`,`ArchDict`.`ArchName` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -395,7 +395,7 @@ SET character_set_client = @saved_cs_client; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `NinetyDayLookBack` AS select `ArchDict`.`ArchName` AS `Arch`,`OSDict`.`OSName` AS `OS`,count(0) AS `Test runs`,sum(`NinetyDayReport`.`Passed`) AS `Passed`,sum(`NinetyDayReport`.`Failed`) AS `Failed`,sum(`NinetyDayReport`.`No run`) AS `No run`,sum(`NinetyDayReport`.`Subtotal`) AS `Subtotal`,ifnull(concat(round(((sum(`NinetyDayReport`.`Passed`) / (sum(`NinetyDayReport`.`Passed`) + sum(`NinetyDayReport`.`Failed`))) * 100),2),'%'),'N/A') AS `Pass rate` from ((`NinetyDayReport` left join `ArchDict` on((`NinetyDayReport`.`ArchId` = `ArchDict`.`ArchId`))) left join `OSDict` on((`NinetyDayReport`.`OSId` = `OSDict`.`OSId`))) group by `NinetyDayReport`.`ArchId`,`NinetyDayReport`.`OSId` */; +/*!50001 VIEW `NinetyDayLookBack` AS select `ArchDict`.`ArchName` AS `Arch`,`OSDict`.`OSName` AS `OS`,count(0) AS `Test runs`,sum(`NinetyDayReport`.`Passed`) AS `Passed`,sum(`NinetyDayReport`.`Failed`) AS `Failed`,sum(`NinetyDayReport`.`No run`) AS `No run`,sum(`NinetyDayReport`.`Subtotal`) AS `Subtotal`,ifnull(concat(round(((sum(`NinetyDayReport`.`Passed`) / (sum(`NinetyDayReport`.`Passed`) + sum(`NinetyDayReport`.`Failed`))) * 100),2),'%'),'N/A') AS `Pass rate` from ((`NinetyDayReport` left join `ArchDict` on((`NinetyDayReport`.`ArchId` = `ArchDict`.`ArchId`))) left join `OSDict` on((`NinetyDayReport`.`OSId` = `OSDict`.`OSId`))) group by `NinetyDayReport`.`ArchId`,`NinetyDayReport`.`OSId` order by `OSDict`.`OSName`,`ArchDict`.`ArchName` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -452,7 +452,7 @@ SET character_set_client = @saved_cs_client; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `SevenDayLookBack` AS select `ArchDict`.`ArchName` AS `Arch`,`OSDict`.`OSName` AS `OS`,count(0) AS `Test runs`,sum(`SevenDayReport`.`Passed`) AS `Passed`,sum(`SevenDayReport`.`Failed`) AS `Failed`,sum(`SevenDayReport`.`No run`) AS `No run`,sum(`SevenDayReport`.`Subtotal`) AS `Subtotal`,ifnull(concat(round(((sum(`SevenDayReport`.`Passed`) / (sum(`SevenDayReport`.`Passed`) + sum(`SevenDayReport`.`Failed`))) * 100),2),'%'),'N/A') AS `Pass rate` from ((`SevenDayReport` left join `ArchDict` on((`SevenDayReport`.`ArchId` = `ArchDict`.`ArchId`))) left join `OSDict` on((`SevenDayReport`.`OSId` = `OSDict`.`OSId`))) group by `SevenDayReport`.`ArchId`,`SevenDayReport`.`OSId` */; +/*!50001 VIEW `SevenDayLookBack` AS select `ArchDict`.`ArchName` AS `Arch`,`OSDict`.`OSName` AS `OS`,count(0) AS `Test runs`,sum(`SevenDayReport`.`Passed`) AS `Passed`,sum(`SevenDayReport`.`Failed`) AS `Failed`,sum(`SevenDayReport`.`No run`) AS `No run`,sum(`SevenDayReport`.`Subtotal`) AS `Subtotal`,ifnull(concat(round(((sum(`SevenDayReport`.`Passed`) / (sum(`SevenDayReport`.`Passed`) + sum(`SevenDayReport`.`Failed`))) * 100),2),'%'),'N/A') AS `Pass rate` from ((`SevenDayReport` left join `ArchDict` on((`SevenDayReport`.`ArchId` = `ArchDict`.`ArchId`))) left join `OSDict` on((`SevenDayReport`.`OSId` = `OSDict`.`OSId`))) group by `SevenDayReport`.`ArchId`,`SevenDayReport`.`OSId` order by `OSDict`.`OSName`,`ArchDict`.`ArchName` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -509,7 +509,7 @@ SET character_set_client = @saved_cs_client; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `ThirtyDayLookBack` AS select `ArchDict`.`ArchName` AS `Arch`,`OSDict`.`OSName` AS `OS`,count(0) AS `Test runs`,sum(`ThirtyDayReport`.`Passed`) AS `Passed`,sum(`ThirtyDayReport`.`Failed`) AS `Failed`,sum(`ThirtyDayReport`.`No run`) AS `No run`,sum(`ThirtyDayReport`.`Subtotal`) AS `Subtotal`,ifnull(concat(round(((sum(`ThirtyDayReport`.`Passed`) / (sum(`ThirtyDayReport`.`Passed`) + sum(`ThirtyDayReport`.`Failed`))) * 100),2),'%'),'N/A') AS `Pass rate` from ((`ThirtyDayReport` left join `ArchDict` on((`ThirtyDayReport`.`ArchId` = `ArchDict`.`ArchId`))) left join `OSDict` on((`ThirtyDayReport`.`OSId` = `OSDict`.`OSId`))) group by `ThirtyDayReport`.`ArchId`,`ThirtyDayReport`.`OSId` */; +/*!50001 VIEW `ThirtyDayLookBack` AS select `ArchDict`.`ArchName` AS `Arch`,`OSDict`.`OSName` AS `OS`,count(0) AS `Test runs`,sum(`ThirtyDayReport`.`Passed`) AS `Passed`,sum(`ThirtyDayReport`.`Failed`) AS `Failed`,sum(`ThirtyDayReport`.`No run`) AS `No run`,sum(`ThirtyDayReport`.`Subtotal`) AS `Subtotal`,ifnull(concat(round(((sum(`ThirtyDayReport`.`Passed`) / (sum(`ThirtyDayReport`.`Passed`) + sum(`ThirtyDayReport`.`Failed`))) * 100),2),'%'),'N/A') AS `Pass rate` from ((`ThirtyDayReport` left join `ArchDict` on((`ThirtyDayReport`.`ArchId` = `ArchDict`.`ArchId`))) left join `OSDict` on((`ThirtyDayReport`.`OSId` = `OSDict`.`OSId`))) group by `ThirtyDayReport`.`ArchId`,`ThirtyDayReport`.`OSId` order by `OSDict`.`OSName`,`ArchDict`.`ArchName` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; From 38d00ce8d724c8c63e5275f7d5db55a9ae4a57ef Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Thu, 30 Jun 2016 16:50:42 +0800 Subject: [PATCH 005/106] [xCAT Jenkins Email Report] Add rank field to the `Top 50 Failed Test Cases' --- .../share/xcat/tools/jenkins/testreport/send-report.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh b/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh index 4012385ce..ae2d23624 100755 --- a/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh +++ b/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh @@ -289,6 +289,7 @@ IFS="${oIFS}"

Top 50 Failed Test Cases

+ @@ -297,15 +298,16 @@ IFS="${oIFS}" $( -Top50FailedTestCases="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT \`Test case\`, Arch, OS, \`Last seven days\`, \`Last thirty days\`, \`Last ninety days\` FROM FailedTestCasesTopList LIMIT 50;")" +Top50FailedTestCases="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT @rank := @rank + 1 AS Rank, \`Test case\`, Arch, OS, \`Last seven days\`, \`Last thirty days\`, \`Last ninety days\` FROM FailedTestCasesTopList, (SELECT @rank := 0) AS RANK LIMIT 50;")" oIFS="${IFS}" IFS="|" color="" -while read n test_case arch os last_seven_days last_thirty_days last_ninety_days n +while read n rank test_case arch os last_seven_days last_thirty_days last_ninety_days n do [ "${color}" = "#e0e0e0" ] && color="#a0d0ff" || color="#e0e0e0" [ "${color}" = "#e0e0e0" ] && color2="#f0f0f0" || color2="#d0e8ff" echo "" + echo "" echo "" echo "" echo "" From 329e64700efb2b79e713564e9564194ef99c1f2e Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Thu, 30 Jun 2016 16:54:41 +0800 Subject: [PATCH 006/106] [xCAT Jenkins Email Report] Rename xCATjk -> xCAT Jenkins --- .../share/xcat/tools/jenkins/testreport/send-report.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh b/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh index ae2d23624..61ea2ad61 100755 --- a/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh +++ b/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh @@ -37,7 +37,7 @@ Email report $report_setTo "Alice" alice@example.org -$report_setFrom "xCAT Jenkins Mail Bot" root@localhost.localdomain +$report_setFrom "xCAT Jenkins Mail Bot" root@localhost.localdomain DateTime="$(date -R)" @@ -52,12 +52,12 @@ $report_setHTML <<-EOF -xCATjk Test Report +xCAT Jenkins Test Report
Rank Test case Arch OSLast 90 days
${rank}${test_case}${arch}${os}
- +

xCATjk Test Report

xCAT Jenkins Test Report

xCAT Logo
@@ -322,7 +322,7 @@ IFS="${oIFS}"
- From aae45825c079ce7be15b9587cb5715be51ea53c2 Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Thu, 30 Jun 2016 17:40:04 +0800 Subject: [PATCH 007/106] [xCAT Jenkins Email Report] Change all the `read' to `read -r' in bash script --- .../xcat/tools/jenkins/testreport/email.sh | 4 +-- .../tools/jenkins/testreport/send-report.sh | 20 +++++++------- .../jenkins/testreport/xCATjkLogAnalyzer.sql | 2 +- .../jenkins/testreport/xcatjk-log2sql.sh | 26 +++++++++---------- .../testreport/xcatjk-scanlogs-last3days.sh | 2 +- .../xcatjk-scanlogs-redo-everything.sh | 4 +-- .../jenkins/testreport/xcatjk-scanlogs.sh | 6 ++--- 7 files changed, 32 insertions(+), 32 deletions(-) diff --git a/xCAT-server/share/xcat/tools/jenkins/testreport/email.sh b/xCAT-server/share/xcat/tools/jenkins/testreport/email.sh index 9c4d9c9d1..5a999f85a 100644 --- a/xCAT-server/share/xcat/tools/jenkins/testreport/email.sh +++ b/xCAT-server/share/xcat/tools/jenkins/testreport/email.sh @@ -201,7 +201,7 @@ function Email_setSubject() while : do - read -n 1 + read -r -n 1 [[ -z "${REPLY}" || "${REPLY}" =~ [\x00-\x7f\xc0-\xff] ]] && (( ${#w} + ${#c} > limit )) && declare -g ${mailSubject}+="$(echo -n "${w}" | @@ -243,7 +243,7 @@ function Email_addAttachment() # 76 is a magic number, see RFC 2045 - while read -n 76 + while read -r -n 76 do inMessage+="${REPLY}" inMessage+=$'\n' diff --git a/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh b/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh index 61ea2ad61..6e3b0b5af 100755 --- a/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh +++ b/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh @@ -78,7 +78,7 @@ LatestDailyReport="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT Title, Arch, OS, Durati oIFS="${IFS}" IFS="|" color="" -while read n title arch os duration passed failed no_run subtotal pass_rate n +while read -r n title arch os duration passed failed no_run subtotal pass_rate n do [ "${color}" = "#e0e0e0" ] && color="#a0d0ff" || color="#e0e0e0" echo "" @@ -97,7 +97,7 @@ IFS="${oIFS}" LatestDailyReportSummary="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT SEC_TO_TIME(SUM(TIME_TO_SEC(Duration))) AS Duration, SUM(Passed), SUM(Failed), SUM(\`No run\`), SUM(Subtotal), IFNULL(CONCAT(ROUND(SUM(Passed) / (SUM(Passed) + SUM(Failed)) * 100, 2), '%'), 'N/A') AS \`Pass rate\` FROM LatestDailyReport;")" oIFS="${IFS}" IFS="|" -read n duration passed failed no_run total pass_rate n < <(grep -v -- ---- <<<"${LatestDailyReportSummary}" | sed -e '1d' -e 's/ *| */|/g') +read -r n duration passed failed no_run total pass_rate n < <(grep -v -- ---- <<<"${LatestDailyReportSummary}" | sed -e '1d' -e 's/ *| */|/g') echo "" echo "" echo "" @@ -124,7 +124,7 @@ FailedTestCasesReport="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT Title, Arch, OS, \` oIFS="${IFS}" IFS="|" color="" -while read n title arch os failed_test_cases n +while read -r n title arch os failed_test_cases n do [ "${color}" = "#e0e0e0" ] && color="#a0d0ff" || color="#e0e0e0" [ "${color}" = "#e0e0e0" ] && color2="#f0f0f0" || color2="#d0e8ff" @@ -153,7 +153,7 @@ SevenDayLookBack="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT Arch, OS, \`Test runs\`, oIFS="${IFS}" IFS="|" color="" -while read n arch os test_runs passed failed no_run subtotal pass_rate n +while read -r n arch os test_runs passed failed no_run subtotal pass_rate n do [ "${color}" = "#e0e0e0" ] && color="#a0d0ff" || color="#e0e0e0" echo "" @@ -172,7 +172,7 @@ IFS="${oIFS}" SevenDayLookBackSummary="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT SUM(\`Test runs\`), SUM(Passed), SUM(Failed), SUM(\`No run\`), SUM(Subtotal), IFNULL(CONCAT(ROUND(SUM(Passed) / (SUM(Passed) + SUM(Failed)) * 100, 2), '%'), 'N/A') AS \`Pass rate\` FROM SevenDayLookBack;")" oIFS="${IFS}" IFS="|" -read n test_runs passed failed no_run total pass_rate n < <(grep -v -- ---- <<<"${SevenDayLookBackSummary}" | sed -e '1d' -e 's/ *| */|/g') +read -r n test_runs passed failed no_run total pass_rate n < <(grep -v -- ---- <<<"${SevenDayLookBackSummary}" | sed -e '1d' -e 's/ *| */|/g') echo "" echo "" echo "" @@ -203,7 +203,7 @@ ThirtyDayLookBack="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT Arch, OS, \`Test runs\` oIFS="${IFS}" IFS="|" color="" -while read n arch os test_runs passed failed no_run subtotal pass_rate n +while read -r n arch os test_runs passed failed no_run subtotal pass_rate n do [ "${color}" = "#e0e0e0" ] && color="#a0d0ff" || color="#e0e0e0" echo "" @@ -222,7 +222,7 @@ IFS="${oIFS}" ThirtyDayLookBackSummary="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT SUM(\`Test runs\`), SUM(Passed), SUM(Failed), SUM(\`No run\`), SUM(Subtotal), IFNULL(CONCAT(ROUND(SUM(Passed) / (SUM(Passed) + SUM(Failed)) * 100, 2), '%'), 'N/A') AS \`Pass rate\` FROM ThirtyDayLookBack;")" oIFS="${IFS}" IFS="|" -read n test_runs passed failed no_run total pass_rate n < <(grep -v -- ---- <<<"${ThirtyDayLookBackSummary}" | sed -e '1d' -e 's/ *| */|/g') +read -r n test_runs passed failed no_run total pass_rate n < <(grep -v -- ---- <<<"${ThirtyDayLookBackSummary}" | sed -e '1d' -e 's/ *| */|/g') echo "" echo "" echo "" @@ -253,7 +253,7 @@ NinetyDayLookBack="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT Arch, OS, \`Test runs\` oIFS="${IFS}" IFS="|" color="" -while read n arch os test_runs passed failed no_run subtotal pass_rate n +while read -r n arch os test_runs passed failed no_run subtotal pass_rate n do [ "${color}" = "#e0e0e0" ] && color="#a0d0ff" || color="#e0e0e0" echo "" @@ -272,7 +272,7 @@ IFS="${oIFS}" NinetyDayLookBackSummary="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT SUM(\`Test runs\`), SUM(Passed), SUM(Failed), SUM(\`No run\`), SUM(Subtotal), IFNULL(CONCAT(ROUND(SUM(Passed) / (SUM(Passed) + SUM(Failed)) * 100, 2), '%'), 'N/A') AS \`Pass rate\` FROM NinetyDayLookBack;")" oIFS="${IFS}" IFS="|" -read n test_runs passed failed no_run total pass_rate n < <(grep -v -- ---- <<<"${NinetyDayLookBackSummary}" | sed -e '1d' -e 's/ *| */|/g') +read -r n test_runs passed failed no_run total pass_rate n < <(grep -v -- ---- <<<"${NinetyDayLookBackSummary}" | sed -e '1d' -e 's/ *| */|/g') echo "" echo "" echo "" @@ -302,7 +302,7 @@ Top50FailedTestCases="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT @rank := @rank + 1 A oIFS="${IFS}" IFS="|" color="" -while read n rank test_case arch os last_seven_days last_thirty_days last_ninety_days n +while read -r n rank test_case arch os last_seven_days last_thirty_days last_ninety_days n do [ "${color}" = "#e0e0e0" ] && color="#a0d0ff" || color="#e0e0e0" [ "${color}" = "#e0e0e0" ] && color2="#f0f0f0" || color2="#d0e8ff" diff --git a/xCAT-server/share/xcat/tools/jenkins/testreport/xCATjkLogAnalyzer.sql b/xCAT-server/share/xcat/tools/jenkins/testreport/xCATjkLogAnalyzer.sql index 215df71fa..0c4ed1243 100644 --- a/xCAT-server/share/xcat/tools/jenkins/testreport/xCATjkLogAnalyzer.sql +++ b/xCAT-server/share/xcat/tools/jenkins/testreport/xCATjkLogAnalyzer.sql @@ -338,7 +338,7 @@ SET character_set_client = @saved_cs_client; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `FailedTestCasesTopList` AS select `TestCase`.`TestCaseName` AS `Test case`,`ArchDict`.`ArchName` AS `Arch`,`OSDict`.`OSName` AS `OS`,ifnull(`SevenDayFailed`.`Failed`,0) AS `Last seven days`,ifnull(`ThirtyDayFailed`.`Failed`,0) AS `Last thirty days`,`NinetyDayFailed`.`Failed` AS `Last ninety days` from (((((`NinetyDayFailed` left join `SevenDayFailed` on(((`NinetyDayFailed`.`TestCaseId` = `SevenDayFailed`.`TestCaseId`) and (`NinetyDayFailed`.`ArchId` = `SevenDayFailed`.`ArchId`) and (`NinetyDayFailed`.`OSId` = `SevenDayFailed`.`OSId`)))) left join `ThirtyDayFailed` on(((`NinetyDayFailed`.`TestCaseId` = `ThirtyDayFailed`.`TestCaseId`) and (`NinetyDayFailed`.`ArchId` = `ThirtyDayFailed`.`ArchId`) and (`NinetyDayFailed`.`OSId` = `ThirtyDayFailed`.`OSId`)))) left join `TestCase` on((`NinetyDayFailed`.`TestCaseId` = `TestCase`.`TestCaseId`))) left join `ArchDict` on((`NinetyDayFailed`.`ArchId` = `ArchDict`.`ArchId`))) left join `OSDict` on((`NinetyDayFailed`.`OSId` = `OSDict`.`OSId`))) order by ifnull(`SevenDayFailed`.`Failed`,0) desc,ifnull(`ThirtyDayFailed`.`Failed`,0) desc,`NinetyDayFailed`.`Failed` desc,`NinetyDayFailed`.`OSId` desc,`NinetyDayFailed`.`ArchId` desc, `TestCase`.`TestCaseName` */; +/*!50001 VIEW `FailedTestCasesTopList` AS select `TestCase`.`TestCaseName` AS `Test case`,`ArchDict`.`ArchName` AS `Arch`,`OSDict`.`OSName` AS `OS`,ifnull(`SevenDayFailed`.`Failed`,0) AS `Last seven days`,ifnull(`ThirtyDayFailed`.`Failed`,0) AS `Last thirty days`,`NinetyDayFailed`.`Failed` AS `Last ninety days` from (((((`NinetyDayFailed` left join `SevenDayFailed` on(((`NinetyDayFailed`.`TestCaseId` = `SevenDayFailed`.`TestCaseId`) and (`NinetyDayFailed`.`ArchId` = `SevenDayFailed`.`ArchId`) and (`NinetyDayFailed`.`OSId` = `SevenDayFailed`.`OSId`)))) left join `ThirtyDayFailed` on(((`NinetyDayFailed`.`TestCaseId` = `ThirtyDayFailed`.`TestCaseId`) and (`NinetyDayFailed`.`ArchId` = `ThirtyDayFailed`.`ArchId`) and (`NinetyDayFailed`.`OSId` = `ThirtyDayFailed`.`OSId`)))) left join `TestCase` on((`NinetyDayFailed`.`TestCaseId` = `TestCase`.`TestCaseId`))) left join `ArchDict` on((`NinetyDayFailed`.`ArchId` = `ArchDict`.`ArchId`))) left join `OSDict` on((`NinetyDayFailed`.`OSId` = `OSDict`.`OSId`))) order by ifnull(`SevenDayFailed`.`Failed`,0) desc,ifnull(`ThirtyDayFailed`.`Failed`,0) desc,`NinetyDayFailed`.`Failed` desc,`OSName`,`ArchName`,`TestCase`.`TestCaseName` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; diff --git a/xCAT-server/share/xcat/tools/jenkins/testreport/xcatjk-log2sql.sh b/xCAT-server/share/xcat/tools/jenkins/testreport/xcatjk-log2sql.sh index 1dc323efa..d3cff55e3 100755 --- a/xCAT-server/share/xcat/tools/jenkins/testreport/xcatjk-log2sql.sh +++ b/xCAT-server/share/xcat/tools/jenkins/testreport/xcatjk-log2sql.sh @@ -4,7 +4,7 @@ function usage() { local script="${0##*/}" - while read ; do echo "${REPLY}" ; done <<-EOF + while read -r ; do echo "${REPLY}" ; done <<-EOF Usage: ${script} [OPTIONS] DIRECTORY Options: @@ -194,7 +194,7 @@ function xcattestlog2sql() [ -n "${test_run_name}" ] warn_if_bad "$?" "test run has no name" || return 1 - while read ; do echo "${REPLY}" ; done <<-EOF + while read -r ; do echo "${REPLY}" ; done <<-EOF -- -- Test run has name '${test_run_name}' -- @@ -204,16 +204,16 @@ function xcattestlog2sql() [ -f "${logfile}" ] warn_if_bad "$?" "${logfile}: No such log file" || return 1 - while read ; do echo "${REPLY}" ; done <<-EOF + while read -r ; do echo "${REPLY}" ; done <<-EOF -- -- Analysis file '${logfile}' -- EOF - while read test_case_name test_case_result duration + while read -r test_case_name test_case_result duration do - while read ; do echo "${REPLY}" ; done <<-EOF + while read -r ; do echo "${REPLY}" ; done <<-EOF INSERT INTO TestCase (TestCaseId, TestCaseName) SELECT * FROM (SELECT NULL, '${test_case_name}') AS tmp WHERE NOT EXISTS ( @@ -259,7 +259,7 @@ function xcattestbundle2sql() [ -n "${test_run_name}" ] warn_if_bad "$?" "test run has no name" || return 1 - while read ; do echo "${REPLY}" ; done <<-EOF + while read -r ; do echo "${REPLY}" ; done <<-EOF -- -- Test run has name '${test_run_name}' -- @@ -269,7 +269,7 @@ function xcattestbundle2sql() [ -f "${logfile}" ] warn_if_bad "$?" "${logfile}: No such log file" || return 1 - while read ; do echo "${REPLY}" ; done <<-EOF + while read -r ; do echo "${REPLY}" ; done <<-EOF -- -- Analysis file '${logfile}' -- @@ -282,12 +282,12 @@ function xcattestbundle2sql() EOF - while read test_case_name + while read -r test_case_name do # Need chomp ${test_case_name} test_case_name=$(echo ${test_case_name}) - while read ; do echo "${REPLY}" ; done <<-EOF + while read -r ; do echo "${REPLY}" ; done <<-EOF INSERT INTO TestCase (TestCaseId, TestCaseName) SELECT * FROM (SELECT NULL, '${test_case_name}') AS tmp WHERE NOT EXISTS ( @@ -330,7 +330,7 @@ function jenkinsprojectlog2sql() [ -f "${logfile}" ] warn_if_bad "$?" "${logfile}: No such log file" || return 1 - while read ; do echo "${REPLY}" ; done <<-EOF + while read -r ; do echo "${REPLY}" ; done <<-EOF -- -- Analysis file '${logfile}' -- @@ -363,7 +363,7 @@ function jenkinsprojectlog2sql() memo="$(tr -d '\r' <"${logfile}" | grep -A 7 'project.*description' | cut -d ' ' -f 4-)" - while read ; do echo "${REPLY}" ; done <<-EOF + while read -r ; do echo "${REPLY}" ; done <<-EOF INSERT INTO ArchDict (ArchId, ArchName) SELECT * FROM (SELECT NULL, '${arch}') AS tmp WHERE NOT EXISTS ( @@ -428,7 +428,7 @@ JenkinsMailLog="$(echo "${xCATjkLog_DIR}/mail."*)" [ -f "${JenkinsMailLog}" ] exit_if_bad "$?" "${JenkinsMailLog}: no such log file" -while read ; do echo "${REPLY}" ; done < Date: Wed, 6 Jul 2016 15:41:10 +0800 Subject: [PATCH 008/106] [xCAT Jenkins Email Report] Fix the rank field of the `Top 50 Failed Test Cases' --- xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh b/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh index 6e3b0b5af..36d8e3686 100755 --- a/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh +++ b/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh @@ -298,7 +298,7 @@ IFS="${oIFS}" $( -Top50FailedTestCases="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT @rank := @rank + 1 AS Rank, \`Test case\`, Arch, OS, \`Last seven days\`, \`Last thirty days\`, \`Last ninety days\` FROM FailedTestCasesTopList, (SELECT @rank := 0) AS RANK LIMIT 50;")" +Top50FailedTestCases="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT @rank := @rank + 1 AS Rank, \`Test case\`, Arch, OS, \`Last seven days\`, \`Last thirty days\`, \`Last ninety days\` FROM (SELECT \`Test case\`, Arch, OS, \`Last seven days\`, \`Last thirty days\`, \`Last ninety days\` FROM FailedTestCasesTopList LIMIT 50) AS TopFifty, (SELECT @rank := 0) AS Rank;")" oIFS="${IFS}" IFS="|" color="" From 39375683ae5b31d927cc26c9186c613885dd48b2 Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Fri, 8 Jul 2016 00:04:18 +0800 Subject: [PATCH 009/106] [xCAT Jenkins Email Report] Create a MySQL database procedure for the mail report --- .../tools/jenkins/testreport/send-report.sh | 304 +------------ .../jenkins/testreport/xCATjkLogAnalyzer.sql | 417 +++++++++++++++++- 2 files changed, 421 insertions(+), 300 deletions(-) diff --git a/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh b/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh index 36d8e3686..0110776d9 100755 --- a/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh +++ b/xCAT-server/share/xcat/tools/jenkins/testreport/send-report.sh @@ -17,6 +17,8 @@ BASE_DIR="${SCRIPT%/*}" ! source "${BASE_DIR}/email.sh" >/dev/null 2>&1 && echo "File \"${BASE_DIR}/email.sh\" not found" >&2 && exit 1 +! type mysql >/dev/null 2>&1 && + echo "Command \"mysql\" not found" >&2 && exit 1 # The configuration part @@ -25,13 +27,9 @@ MYSQL_USER="root" MYSQL_PASS="password" MYSQL_DB="xCATjkLogAnalyzer" -# The main part +MYSQL_COMMAND=("mysql" -B -N -r -s "-h" "${MYSQL_HOST}" -u "${MYSQL_USER}" -p"${MYSQL_PASS}" "${MYSQL_DB}") -for c in mysql tail sed grep -do - ! type "${c}" >/dev/null 2>&1 && - echo "Command \"${c}\" not found" >&2 && exit 1 -done +# The main part Email report @@ -39,297 +37,7 @@ $report_setTo "Alice" alice@example.org $report_setFrom "xCAT Jenkins Mail Bot" root@localhost.localdomain -DateTime="$(date -R)" - -MYSQL_COMMAND=("mysql" "-h" "${MYSQL_HOST}" -u "${MYSQL_USER}" -p"${MYSQL_PASS}" "${MYSQL_DB}") -Subject="$("${MYSQL_COMMAND[@]}" <<<"SELECT CONCAT('Passed: ', SUM(Passed), ' Failed: ', SUM(Failed), ' No run: ', SUM(\`No run\`)) AS Summary FROM LatestDailyReport;" | tail -n 1)" - -$report_setSubject "[xCAT Jenkins] ${Subject}" - -$report_setHTML <<-EOF - - - - - -xCAT Jenkins Test Report - - -

This email has been sent to you by xCATjk Mail Bot.
+

This email has been sent to you by xCAT Jenkins Mail Bot.
This email was sent from a notification-only address that cannot accept incoming email. Please do not reply to this message. If you have received this email in error, please delete it.
All the times shown in this test report are the local times of the testing environment.

${DateTime}

Total-
Total-
Total-
Total-Last 90 days
- - - - -

xCAT Jenkins Test Report

xCAT Logo
-

- - - - - - - - - - - -$( -LatestDailyReport="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT Title, Arch, OS, Duration, Passed, Failed, \`No run\`, Subtotal, \`Pass rate\` FROM LatestDailyReport;")" -oIFS="${IFS}" -IFS="|" -color="" -while read -r n title arch os duration passed failed no_run subtotal pass_rate n -do - [ "${color}" = "#e0e0e0" ] && color="#a0d0ff" || color="#e0e0e0" - echo "" - echo "" - echo "" - echo "" - echo "" - echo "" - echo "" - echo "" - echo "" - echo "" -done < <(grep -v -- ---- <<<"${LatestDailyReport}" | sed -e '1d' -e 's/ *| */|/g') -IFS="${oIFS}" - -LatestDailyReportSummary="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT SEC_TO_TIME(SUM(TIME_TO_SEC(Duration))) AS Duration, SUM(Passed), SUM(Failed), SUM(\`No run\`), SUM(Subtotal), IFNULL(CONCAT(ROUND(SUM(Passed) / (SUM(Passed) + SUM(Failed)) * 100, 2), '%'), 'N/A') AS \`Pass rate\` FROM LatestDailyReport;")" -oIFS="${IFS}" -IFS="|" -read -r n duration passed failed no_run total pass_rate n < <(grep -v -- ---- <<<"${LatestDailyReportSummary}" | sed -e '1d' -e 's/ *| */|/g') -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -IFS="${oIFS}" -) -
ArchOSDurationPassedFailedNo runSubtotalPass rate
${arch}${os}${duration}${passed}${failed}${no_run}${subtotal}${pass_rate}
Total-${duration}${passed}${failed}${no_run}${total}${pass_rate}
-
-

Failed Test Cases

- - - - - - -$( -FailedTestCasesReport="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT Title, Arch, OS, \`Failed test cases\` FROM LatestDailyReport;")" -oIFS="${IFS}" -IFS="|" -color="" -while read -r n title arch os failed_test_cases n -do - [ "${color}" = "#e0e0e0" ] && color="#a0d0ff" || color="#e0e0e0" - [ "${color}" = "#e0e0e0" ] && color2="#f0f0f0" || color2="#d0e8ff" - echo "" - echo "" - echo "" - echo "" - echo "" -done < <(grep -v -- ---- <<<"${FailedTestCasesReport}" | sed -e '1d' -e 's/ *| */|/g') -) -
ArchOSFailed test cases
${arch}${os}${failed_test_cases}
-

Seven-day Look Back

- - - - - - - - - - - -$( -SevenDayLookBack="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT Arch, OS, \`Test runs\`, Passed, Failed, \`No run\`, Subtotal, \`Pass rate\` FROM SevenDayLookBack;")" -oIFS="${IFS}" -IFS="|" -color="" -while read -r n arch os test_runs passed failed no_run subtotal pass_rate n -do - [ "${color}" = "#e0e0e0" ] && color="#a0d0ff" || color="#e0e0e0" - echo "" - echo "" - echo "" - echo "" - echo "" - echo "" - echo "" - echo "" - echo "" - echo "" -done < <(grep -v -- ---- <<<"${SevenDayLookBack}" | sed -e '1d' -e 's/ *| */|/g') -IFS="${oIFS}" - -SevenDayLookBackSummary="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT SUM(\`Test runs\`), SUM(Passed), SUM(Failed), SUM(\`No run\`), SUM(Subtotal), IFNULL(CONCAT(ROUND(SUM(Passed) / (SUM(Passed) + SUM(Failed)) * 100, 2), '%'), 'N/A') AS \`Pass rate\` FROM SevenDayLookBack;")" -oIFS="${IFS}" -IFS="|" -read -r n test_runs passed failed no_run total pass_rate n < <(grep -v -- ---- <<<"${SevenDayLookBackSummary}" | sed -e '1d' -e 's/ *| */|/g') -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -IFS="${oIFS}" -) -
ArchOSTest runsPassedFailedNo runSubtotalPass rate
${arch}${os}${test_runs}${passed}${failed}${no_run}${subtotal}${pass_rate}
Total-${test_runs}${passed}${failed}${no_run}${total}${pass_rate}
-

Thirty-day Look Back

- - - - - - - - - - - -$( -ThirtyDayLookBack="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT Arch, OS, \`Test runs\`, Passed, Failed, \`No run\`, Subtotal, \`Pass rate\` FROM ThirtyDayLookBack;")" -oIFS="${IFS}" -IFS="|" -color="" -while read -r n arch os test_runs passed failed no_run subtotal pass_rate n -do - [ "${color}" = "#e0e0e0" ] && color="#a0d0ff" || color="#e0e0e0" - echo "" - echo "" - echo "" - echo "" - echo "" - echo "" - echo "" - echo "" - echo "" - echo "" -done < <(grep -v -- ---- <<<"${ThirtyDayLookBack}" | sed -e '1d' -e 's/ *| */|/g') -IFS="${oIFS}" - -ThirtyDayLookBackSummary="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT SUM(\`Test runs\`), SUM(Passed), SUM(Failed), SUM(\`No run\`), SUM(Subtotal), IFNULL(CONCAT(ROUND(SUM(Passed) / (SUM(Passed) + SUM(Failed)) * 100, 2), '%'), 'N/A') AS \`Pass rate\` FROM ThirtyDayLookBack;")" -oIFS="${IFS}" -IFS="|" -read -r n test_runs passed failed no_run total pass_rate n < <(grep -v -- ---- <<<"${ThirtyDayLookBackSummary}" | sed -e '1d' -e 's/ *| */|/g') -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -IFS="${oIFS}" -) -
ArchOSTest runsPassedFailedNo runSubtotalPass rate
${arch}${os}${test_runs}${passed}${failed}${no_run}${subtotal}${pass_rate}
Total-${test_runs}${passed}${failed}${no_run}${total}${pass_rate}
-

Ninety-day Look Back

- - - - - - - - - - - -$( -NinetyDayLookBack="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT Arch, OS, \`Test runs\`, Passed, Failed, \`No run\`, Subtotal, \`Pass rate\` FROM NinetyDayLookBack;")" -oIFS="${IFS}" -IFS="|" -color="" -while read -r n arch os test_runs passed failed no_run subtotal pass_rate n -do - [ "${color}" = "#e0e0e0" ] && color="#a0d0ff" || color="#e0e0e0" - echo "" - echo "" - echo "" - echo "" - echo "" - echo "" - echo "" - echo "" - echo "" - echo "" -done < <(grep -v -- ---- <<<"${NinetyDayLookBack}" | sed -e '1d' -e 's/ *| */|/g') -IFS="${oIFS}" - -NinetyDayLookBackSummary="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT SUM(\`Test runs\`), SUM(Passed), SUM(Failed), SUM(\`No run\`), SUM(Subtotal), IFNULL(CONCAT(ROUND(SUM(Passed) / (SUM(Passed) + SUM(Failed)) * 100, 2), '%'), 'N/A') AS \`Pass rate\` FROM NinetyDayLookBack;")" -oIFS="${IFS}" -IFS="|" -read -r n test_runs passed failed no_run total pass_rate n < <(grep -v -- ---- <<<"${NinetyDayLookBackSummary}" | sed -e '1d' -e 's/ *| */|/g') -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -echo "" -IFS="${oIFS}" -) -
ArchOSTest runsPassedFailedNo runSubtotalPass rate
${arch}${os}${test_runs}${passed}${failed}${no_run}${subtotal}${pass_rate}
Total-${test_runs}${passed}${failed}${no_run}${total}${pass_rate}
-

Top 50 Failed Test Cases

- - - - - - - - - - -$( -Top50FailedTestCases="$("${MYSQL_COMMAND[@]}" -t <<<"SELECT @rank := @rank + 1 AS Rank, \`Test case\`, Arch, OS, \`Last seven days\`, \`Last thirty days\`, \`Last ninety days\` FROM (SELECT \`Test case\`, Arch, OS, \`Last seven days\`, \`Last thirty days\`, \`Last ninety days\` FROM FailedTestCasesTopList LIMIT 50) AS TopFifty, (SELECT @rank := 0) AS Rank;")" -oIFS="${IFS}" -IFS="|" -color="" -while read -r n rank test_case arch os last_seven_days last_thirty_days last_ninety_days n -do - [ "${color}" = "#e0e0e0" ] && color="#a0d0ff" || color="#e0e0e0" - [ "${color}" = "#e0e0e0" ] && color2="#f0f0f0" || color2="#d0e8ff" - echo "" - echo "" - echo "" - echo "" - echo "" - echo "" - echo "" - echo "" - echo "" -done < <(grep -v -- ---- <<<"${Top50FailedTestCases}" | sed -e '1d' -e 's/ *| */|/g') -IFS="${oIFS}" -) -
RankTest caseArchOSLast 7 daysLast 30 daysLast 90 days
${rank}${test_case}${arch}${os}${last_seven_days}${last_thirty_days}${last_ninety_days}
-
- - - - -

This email has been sent to you by xCAT Jenkins Mail Bot.
-This email was sent from a notification-only address that cannot accept incoming email. Please do not reply to this message. If you have received this email in error, please delete it.
-All the times shown in this test report are the local times of the testing environment.

-

${DateTime}

- - -EOF +$report_setSubject "$("${MYSQL_COMMAND[@]}" <<<"SELECT * FROM LatestDailyMailReportSubject;")" +$report_setHTML < <("${MYSQL_COMMAND[@]}" <<<"CALL CreateLatestDailyMailReport;") $report_send diff --git a/xCAT-server/share/xcat/tools/jenkins/testreport/xCATjkLogAnalyzer.sql b/xCAT-server/share/xcat/tools/jenkins/testreport/xCATjkLogAnalyzer.sql index 0c4ed1243..93dd428b0 100644 --- a/xCAT-server/share/xcat/tools/jenkins/testreport/xCATjkLogAnalyzer.sql +++ b/xCAT-server/share/xcat/tools/jenkins/testreport/xCATjkLogAnalyzer.sql @@ -48,6 +48,19 @@ SET character_set_client = utf8; ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; +-- +-- Temporary table structure for view `LatestDailyMailReportSubject` +-- + +DROP TABLE IF EXISTS `LatestDailyMailReportSubject`; +/*!50001 DROP VIEW IF EXISTS `LatestDailyMailReportSubject`*/; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +/*!50001 CREATE TABLE `LatestDailyMailReportSubject` ( + `Subject` tinyint NOT NULL +) ENGINE=MyISAM */; +SET character_set_client = @saved_cs_client; + -- -- Temporary table structure for view `LatestDailyReport` -- @@ -324,6 +337,387 @@ SET character_set_client = utf8; ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; +-- +-- Dumping routines for database 'xCATjkLogAnalyzer' +-- +/*!50003 DROP PROCEDURE IF EXISTS `CreateLatestDailyMailReport` */; +/*!50003 SET @saved_cs_client = @@character_set_client */ ; +/*!50003 SET @saved_cs_results = @@character_set_results */ ; +/*!50003 SET @saved_col_connection = @@collation_connection */ ; +/*!50003 SET character_set_client = utf8 */ ; +/*!50003 SET character_set_results = utf8 */ ; +/*!50003 SET collation_connection = utf8_general_ci */ ; +/*!50003 SET @saved_sql_mode = @@sql_mode */ ; +/*!50003 SET sql_mode = '' */ ; +DELIMITER ;; +CREATE DEFINER=`root`@`localhost` PROCEDURE `CreateLatestDailyMailReport`() +BEGIN +SET group_concat_max_len := @@max_allowed_packet; +SELECT CONCAT( +'', "\n", +'', "\n", +'', "\n", +'', "\n", +'', "\n", +'xCAT Jenkins Test Report', "\n", +'', "\n", +'', "\n", +'', "\n", +'', "\n", +'', "\n", +'', "\n", +'', "\n", +'

xCAT Jenkins Test Report

xCAT Logo
', "\n", +'

', "\n", +'', "\n", +'', "\n", +'', "\n", +'', "\n", +'', "\n", +'', "\n", +'', "\n", +'', "\n", +'', "\n", +'', "\n", +'', "\n", +LatestDailyReportContents.HTML, +LatestDailyReportSummary.HTML, +'
ArchOSDurationPassedFailedNo runSubtotalPass rate
', "\n", +'
', "\n", +'

Failed Test Cases

', "\n", +'', "\n", +'', "\n", +'', "\n", +'', "\n", +'', "\n", +'', "\n", +FailedTestCasesReport.HTML, +'
ArchOSFailed test cases
', "\n", +'

Seven-day Look Back

', "\n", +'', "\n", +'', "\n", +'', "\n", +'', "\n", +'', "\n", +'', "\n", +'', "\n", +'', "\n", +'', "\n", +'', "\n", +'', "\n", +SevenDayLookBackContents.HTML, +SevenDayLookBackSummary.HTML, +'
ArchOSTest runsPassedFailedNo runSubtotalPass rate
', "\n", +'

Thirty-day Look Back

', "\n", +'', "\n", +'', "\n", +'', "\n", +'', "\n", +'', "\n", +'', "\n", +'', "\n", +'', "\n", +'', "\n", +'', "\n", +'', "\n", +ThirtyDayLookBackContents.HTML, +ThirtyDayLookBackSummary.HTML, +'
ArchOSTest runsPassedFailedNo runSubtotalPass rate
', "\n", +'

Ninety-day Look Back

', "\n", +'', "\n", +'', "\n", +'', "\n", +'', "\n", +'', "\n", +'', "\n", +'', "\n", +'', "\n", +'', "\n", +'', "\n", +'', "\n", +NinetyDayLookBackContents.HTML, +NinetyDayLookBackSummary.HTML, +'
ArchOSTest runsPassedFailedNo runSubtotalPass rate
', "\n", +'

Top 50 Failed Test Cases

', "\n", +'', "\n", +'', "\n", +'', "\n", +'', "\n", +'', "\n", +'', "\n", +'', "\n", +'', "\n", +'', "\n", +'', "\n", +TopFiftyFailedTestCases.HTML, +'
RankTest caseArchOSLast 7 daysLast 30 daysLast 90 days
', "\n", +'
', "\n", +'', "\n", +'', "\n", +'', "\n", +'', "\n", +'

This email has been sent to you by xCAT Jenkins Mail Bot.
', "\n", +'This email was sent from a notification-only address that cannot accept incoming email. Please do not reply to this message. If you have received this email in error, please delete it.
', "\n", +'All the times shown in this test report are the local times of the testing environment.

', "\n", +'

', +NOW(), ' ', REPLACE(CONCAT('+', TIME_FORMAT(TIMEDIFF(NOW(), UTC_TIMESTAMP), '%H%i')), '+-', '-'), +'

', "\n", +'', "\n", +'' +) AS HTML +FROM ( +SELECT GROUP_CONCAT(HTML SEPARATOR '') AS HTML +FROM ( +SELECT CONCAT( +'', "\n", +'', +Arch, '', "\n", +'', +OS, '', "\n" +'', +Duration, '', "\n", +'', +Passed, '', "\n", +'', +Failed, '', "\n", +'', +`No run`, '', "\n", +'', +Subtotal, '', "\n", +'', +`Pass rate`, '', "\n", +'', "\n" +) AS HTML +FROM LatestDailyReport, +( SELECT @color := '' ) AS tmp00 +) AS tmp10 +) AS LatestDailyReportContents, ( +SELECT CONCAT( +'', "\n", +'Total', "\n", +'-', "\n", +'', +SEC_TO_TIME(SUM(TIME_TO_SEC(Duration))), '', "\n" +'', +SUM(Passed), '', "\n", +'', +SUM(Failed), '', "\n", +'', +SUM(`No run`), '', "\n", +'', +SUM(Subtotal), '', "\n", +'', +IFNULL(CONCAT(ROUND(SUM(Passed) / (SUM(Passed) + SUM(Failed)) * 100, 2), '%'), 'N/A'), '', "\n", +'', "\n" +) AS HTML +FROM LatestDailyReport +) AS LatestDailyReportSummary, ( +SELECT GROUP_CONCAT(HTML SEPARATOR '') AS HTML +FROM ( +SELECT CONCAT( +'', "\n", +'', +Arch, '', "\n", +'', +OS, '', "\n", +'', +`Failed test cases`, '', "\n", +'' , "\n" +) AS HTML +FROM LatestDailyReport, +( SELECT @color := '' ) AS tmp00 +) AS tmp10 +) AS FailedTestCasesReport, ( +SELECT GROUP_CONCAT(HTML SEPARATOR '') AS HTML +FROM ( +SELECT CONCAT( +'', "\n", +'', +Arch, '', "\n", +'', +OS, '', "\n", +'', +`Test runs`, '', "\n", +'', +Passed, '', "\n", +'', +Failed, '', "\n", +'', +`No run`, '', "\n", +'', +Subtotal, '', "\n", +'', +`Pass rate`, '', "\n", +'', "\n" +) AS HTML +FROM SevenDayLookBack, +( SELECT @color := '' ) AS tmp00 +) AS tmp10 +) AS SevenDayLookBackContents, ( +SELECT CONCAT( +'', "\n", +'Total', "\n", +'-', "\n", +'', +SUM(`Test runs`), '', "\n", +'', +SUM(Passed), '', "\n", +'', +SUM(Failed), '', "\n", +'', +SUM(`No run`), '', "\n", +'', +SUM(Subtotal), '', "\n", +'', +IFNULL(CONCAT(ROUND(SUM(Passed) / (SUM(Passed) + SUM(Failed)) * 100, 2), '%'), 'N/A'), '', "\n", +'', "\n" +) AS HTML +FROM SevenDayLookBack +) AS SevenDayLookBackSummary, ( +SELECT GROUP_CONCAT(HTML SEPARATOR '') AS HTML +FROM ( +SELECT CONCAT( +'', "\n", +'', +Arch, '', "\n", +'', +OS, '', "\n", +'', +`Test runs`, '', "\n", +'', +Passed, '', "\n", +'', +Failed, '', "\n", +'', +`No run`, '', "\n", +'', +Subtotal, '', "\n", +'', +`Pass rate`, '', "\n", +'', "\n" +) AS HTML +FROM ThirtyDayLookBack, +( SELECT @color := '' ) AS tmp00 +) AS tmp10 +) AS ThirtyDayLookBackContents, ( +SELECT CONCAT( +'', "\n", +'Total', "\n", +'-', "\n", +'', +SUM(`Test runs`), '', "\n", +'', +SUM(Passed), '', "\n", +'', +SUM(Failed), '', "\n", +'', +SUM(`No run`), '', "\n", +'', +SUM(Subtotal), '', "\n", +'', +IFNULL(CONCAT(ROUND(SUM(Passed) / (SUM(Passed) + SUM(Failed)) * 100, 2), '%'), 'N/A'), '', "\n", +'', "\n" +) AS HTML +FROM ThirtyDayLookBack +) AS ThirtyDayLookBackSummary, ( +SELECT GROUP_CONCAT(HTML SEPARATOR '') AS HTML +FROM ( +SELECT CONCAT( +'', "\n", +'', +Arch, '', "\n", +'', +OS, '', "\n", +'', +`Test runs`, '', "\n", +'', +Passed, '', "\n", +'', +Failed, '', "\n", +'', +`No run`, '', "\n", +'', +Subtotal, '', "\n", +'', +`Pass rate`, '', "\n", +'', "\n" +) AS HTML +FROM NinetyDayLookBack, +( SELECT @color := '' ) AS tmp00 +) AS tmp10 +) AS NinetyDayLookBackContents, ( +SELECT CONCAT( +'', "\n", +'Total', "\n", +'-', "\n", +'', +SUM(`Test runs`), '', "\n", +'', +SUM(Passed), '', "\n", +'', +SUM(Failed), '', "\n", +'', +SUM(`No run`), '', "\n", +'', +SUM(Subtotal), '', "\n", +'', +IFNULL(CONCAT(ROUND(SUM(Passed) / (SUM(Passed) + SUM(Failed)) * 100, 2), '%'), 'N/A'), '', "\n", +'', "\n" +) AS HTML +FROM NinetyDayLookBack +) AS NinetyDayLookBackSummary, ( +SELECT GROUP_CONCAT(HTML SEPARATOR '') AS HTML +FROM ( +SELECT CONCAT( +'', "\n", +'', +@rank := @rank + 1, '', "\n", +'', +`Test case`, '', "\n", +'', +Arch, '', "\n", +'', +OS, '', "\n", +'', +`Last seven days`, '', "\n", +'', +`Last thirty days`, '', "\n", +'', +`Last ninety days`, '', "\n", +'', "\n" +) AS HTML FROM ( +SELECT `Test case`, Arch, OS, `Last seven days`, `Last thirty days`, `Last ninety days` +FROM FailedTestCasesTopList LIMIT 50 +) AS TopFifty, +( SELECT @color := '' ) AS tmp00, +( SELECT @rank := 0 ) AS tmp09 +) AS tmp10 +) AS TopFiftyFailedTestCases; +END ;; +DELIMITER ; +/*!50003 SET sql_mode = @saved_sql_mode */ ; +/*!50003 SET character_set_client = @saved_cs_client */ ; +/*!50003 SET character_set_results = @saved_cs_results */ ; +/*!50003 SET collation_connection = @saved_col_connection */ ; + -- -- Final view structure for view `FailedTestCasesTopList` -- @@ -338,7 +732,26 @@ SET character_set_client = @saved_cs_client; /*!50001 SET collation_connection = utf8_general_ci */; /*!50001 CREATE ALGORITHM=UNDEFINED */ /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ -/*!50001 VIEW `FailedTestCasesTopList` AS select `TestCase`.`TestCaseName` AS `Test case`,`ArchDict`.`ArchName` AS `Arch`,`OSDict`.`OSName` AS `OS`,ifnull(`SevenDayFailed`.`Failed`,0) AS `Last seven days`,ifnull(`ThirtyDayFailed`.`Failed`,0) AS `Last thirty days`,`NinetyDayFailed`.`Failed` AS `Last ninety days` from (((((`NinetyDayFailed` left join `SevenDayFailed` on(((`NinetyDayFailed`.`TestCaseId` = `SevenDayFailed`.`TestCaseId`) and (`NinetyDayFailed`.`ArchId` = `SevenDayFailed`.`ArchId`) and (`NinetyDayFailed`.`OSId` = `SevenDayFailed`.`OSId`)))) left join `ThirtyDayFailed` on(((`NinetyDayFailed`.`TestCaseId` = `ThirtyDayFailed`.`TestCaseId`) and (`NinetyDayFailed`.`ArchId` = `ThirtyDayFailed`.`ArchId`) and (`NinetyDayFailed`.`OSId` = `ThirtyDayFailed`.`OSId`)))) left join `TestCase` on((`NinetyDayFailed`.`TestCaseId` = `TestCase`.`TestCaseId`))) left join `ArchDict` on((`NinetyDayFailed`.`ArchId` = `ArchDict`.`ArchId`))) left join `OSDict` on((`NinetyDayFailed`.`OSId` = `OSDict`.`OSId`))) order by ifnull(`SevenDayFailed`.`Failed`,0) desc,ifnull(`ThirtyDayFailed`.`Failed`,0) desc,`NinetyDayFailed`.`Failed` desc,`OSName`,`ArchName`,`TestCase`.`TestCaseName` */; +/*!50001 VIEW `FailedTestCasesTopList` AS select `TestCase`.`TestCaseName` AS `Test case`,`ArchDict`.`ArchName` AS `Arch`,`OSDict`.`OSName` AS `OS`,ifnull(`SevenDayFailed`.`Failed`,0) AS `Last seven days`,ifnull(`ThirtyDayFailed`.`Failed`,0) AS `Last thirty days`,`NinetyDayFailed`.`Failed` AS `Last ninety days` from (((((`NinetyDayFailed` left join `SevenDayFailed` on(((`NinetyDayFailed`.`TestCaseId` = `SevenDayFailed`.`TestCaseId`) and (`NinetyDayFailed`.`ArchId` = `SevenDayFailed`.`ArchId`) and (`NinetyDayFailed`.`OSId` = `SevenDayFailed`.`OSId`)))) left join `ThirtyDayFailed` on(((`NinetyDayFailed`.`TestCaseId` = `ThirtyDayFailed`.`TestCaseId`) and (`NinetyDayFailed`.`ArchId` = `ThirtyDayFailed`.`ArchId`) and (`NinetyDayFailed`.`OSId` = `ThirtyDayFailed`.`OSId`)))) left join `TestCase` on((`NinetyDayFailed`.`TestCaseId` = `TestCase`.`TestCaseId`))) left join `ArchDict` on((`NinetyDayFailed`.`ArchId` = `ArchDict`.`ArchId`))) left join `OSDict` on((`NinetyDayFailed`.`OSId` = `OSDict`.`OSId`))) order by ifnull(`SevenDayFailed`.`Failed`,0) desc,ifnull(`ThirtyDayFailed`.`Failed`,0) desc,`NinetyDayFailed`.`Failed` desc,`OSDict`.`OSName`,`ArchDict`.`ArchName`,`TestCase`.`TestCaseName` */; +/*!50001 SET character_set_client = @saved_cs_client */; +/*!50001 SET character_set_results = @saved_cs_results */; +/*!50001 SET collation_connection = @saved_col_connection */; + +-- +-- Final view structure for view `LatestDailyMailReportSubject` +-- + +/*!50001 DROP TABLE IF EXISTS `LatestDailyMailReportSubject`*/; +/*!50001 DROP VIEW IF EXISTS `LatestDailyMailReportSubject`*/; +/*!50001 SET @saved_cs_client = @@character_set_client */; +/*!50001 SET @saved_cs_results = @@character_set_results */; +/*!50001 SET @saved_col_connection = @@collation_connection */; +/*!50001 SET character_set_client = utf8 */; +/*!50001 SET character_set_results = utf8 */; +/*!50001 SET collation_connection = utf8_general_ci */; +/*!50001 CREATE ALGORITHM=UNDEFINED */ +/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ +/*!50001 VIEW `LatestDailyMailReportSubject` AS select concat('[xCAT Jenkins] ','Passed: ',sum(`LatestDailyReport`.`Passed`),' Failed: ',sum(`LatestDailyReport`.`Failed`),' No run: ',sum(`LatestDailyReport`.`No run`)) AS `Subject` from `LatestDailyReport` */; /*!50001 SET character_set_client = @saved_cs_client */; /*!50001 SET character_set_results = @saved_cs_results */; /*!50001 SET collation_connection = @saved_col_connection */; @@ -542,4 +955,4 @@ SET character_set_client = @saved_cs_client; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2016-06-29 4:52:47 +-- Dump completed on 2016-07-07 11:48:15 From 3b92cfb5c4cace00a3d55053f31fcb0d703ac02a Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Mon, 18 Jul 2016 20:49:05 +0800 Subject: [PATCH 010/106] [xCAT Jenkins Email Report] Remove comment from test bundle file, and do chomp()ing --- .../share/xcat/tools/jenkins/testreport/xcatjk-log2sql.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/xCAT-server/share/xcat/tools/jenkins/testreport/xcatjk-log2sql.sh b/xCAT-server/share/xcat/tools/jenkins/testreport/xcatjk-log2sql.sh index d3cff55e3..bc83667e1 100755 --- a/xCAT-server/share/xcat/tools/jenkins/testreport/xcatjk-log2sql.sh +++ b/xCAT-server/share/xcat/tools/jenkins/testreport/xcatjk-log2sql.sh @@ -284,8 +284,11 @@ function xcattestbundle2sql() while read -r test_case_name do - # Need chomp ${test_case_name} + # Remove any comment + test_case_name="${test_case_name%%#*}" + # Chomp test_case_name=$(echo ${test_case_name}) + [ -z "${test_case_name}" ] && continue while read -r ; do echo "${REPLY}" ; done <<-EOF INSERT INTO TestCase (TestCaseId, TestCaseName) From dd783ff14b3d1616209f416615ab37fc04ff9ce5 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 27 Jul 2016 03:50:30 -0400 Subject: [PATCH 011/106] 1596:Enhance the process of reinstall for PCM --- xCAT-server/lib/xcat/plugins/profilednodes.pm | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/profilednodes.pm b/xCAT-server/lib/xcat/plugins/profilednodes.pm index c5458e334..d44beca15 100644 --- a/xCAT-server/lib/xcat/plugins/profilednodes.pm +++ b/xCAT-server/lib/xcat/plugins/profilednodes.pm @@ -996,8 +996,16 @@ Usage: # Add BMC/FSP as reserve NICs and not remove it form nics table foreach my $oldNic (keys %$oldNicsRef) { - if ($oldNicsRef->{$oldNic}->{'type'} ne 'BMC' and $oldNicsRef->{$oldNic}->{'type'} ne 'FSP') { - $updateNicsHash{$oldNic} = 1; + if ($oldNicsRef->{$oldNic}->{'type'} ne 'BMC' and $oldNicsRef->{$oldNic}->{'type'} ne 'FSP'){ + if ($oldNicsRef->{$oldNic}->{'network'} eq $newNicsRef->{$oldNic}->{'network'}){ + $reserveNicsHash{$oldNic} = 1; + if(exists $updateNicsHash{$oldNic}) + { + delete($updateNicsHash{$oldNic}); + } + } else { + $updateNicsHash{$oldNic} = 1; + } } else { $reserveNicsHash{$oldNic} = 1; } From 463f69e3a4cbbc3db9e5c50642e39b135da77b25 Mon Sep 17 00:00:00 2001 From: hu-weihua Date: Tue, 9 Aug 2016 02:30:05 -0400 Subject: [PATCH 012/106] Implement replay and state control function for os provision probe --- xCAT-probe/subcmds/osdeploy | 713 ++++++++++++++++++++++++++++-------- 1 file changed, 559 insertions(+), 154 deletions(-) diff --git a/xCAT-probe/subcmds/osdeploy b/xCAT-probe/subcmds/osdeploy index dabbd16fe..c051e6e56 100755 --- a/xCAT-probe/subcmds/osdeploy +++ b/xCAT-probe/subcmds/osdeploy @@ -9,35 +9,158 @@ use probe_utils; use xCAT::NetworkUtils; use File::Basename; use IO::Select; +use Time::Local; +use Data::Dumper; use Getopt::Long qw(:config no_ignore_case); my $program_name = basename("$0"); my $help; my $test; -my $output = "stdout"; -my $verbose = 0; -my $rst = 0; +my $maxwaittime = 60; #unit is minute +my $output = "stdout"; +my $verbose = 0; +my $rst = 0; my $noderange; -my %rawdata; -my %ipnodemap; -my %macmap; my $terminal = 0; +my $installnic; +my $monitor = 0; +my $replaylog; ##used by feature replay deploymen log + +my %rawdata; + +#-%rawdata structure------- +# $rawdata{nodename}{"history"} #array, the log history of current node +# $rawdata{nodename}{"state"} #the latest status of current node, used for State Machine +# $rawdata{nodename}{"statehistory"} #array, the history status of current node, used for State Machine +#-------------------------- + +my %macmap; + +#-%macmap structure------- +# $macmap{mac_addr}{"ip"}="x.x.x.x" +# $macmap{mac_addr}{"node"}="nodename" +#------------------------- + +my %ipnodemap; + +#-%ipnodemap structure------- +# $ipnodemap{ip_addr}="nodename" +#--------------------------- + my %monitor_nodes; +#- %monitor_nodes structure------- +# $monitor_nodes{nodename}{"status"} #useless now +# $monitor_nodes{nodename}{"rst"} +#--------------------------------- + +# provision state machine +my %state_set = ( + "unknown" => 0, + "sever_reboot" => 1, + "loaded_kernel_and_initrd" => 2, + "kernel_and_initrd_got_ip" => 3, + "install_os_packages" => 4, + "run_postscript" => 5, + "run_postbootscript" => 6, + "done" => 7, +); + +my %state_set_reverse = ( + "0" => "unknown", + "1" => "sever_reboot", + "2" => "loaded_kernel_and_initrd", + "3" => "kernel_and_initrd_got_ip", + "4" => "install_os_packages", + "5" => "run_postscript", + "6" => "run_postbootscript", + "7" => "done", +); + +my %valid_process; +$valid_process{1}{process} = [ $state_set{unknown}, $state_set{done} ]; +$valid_process{1}{type} = "reboot"; + +$valid_process{2}{process} = [ $state_set{unknown}, $state_set{sever_reboot}, $state_set{done} ]; +$valid_process{2}{type} = "reboot"; + +$valid_process{3}{process} = [ $state_set{unknown}, $state_set{sever_reboot}, $state_set{run_postbootscript}, $state_set{done} ]; +$valid_process{3}{type} = "reboot"; + +$valid_process{4}{process} = [ $state_set{unknown}, $state_set{sever_reboot}, $state_set{loaded_kernel_and_initrd}, $state_set{kernel_and_initrd_got_ip}, $state_set{install_os_packages}, $state_set{run_postscript}, $state_set{sever_reboot}, $state_set{run_postbootscript}, $state_set{done} ]; +$valid_process{4}{type} = "deploy"; + +$valid_process{5}{process} = [ $state_set{unknown}, $state_set{loaded_kernel_and_initrd}, $state_set{kernel_and_initrd_got_ip}, $state_set{install_os_packages}, $state_set{run_postscript}, $state_set{sever_reboot}, $state_set{run_postbootscript}, $state_set{done} ]; +$valid_process{5}{type} = "deploy"; + +sub reset_state { + my $state_ref = shift; + my $condition = shift; + my $reset_flag = 1; + + if ($$state_ref == $state_set{unknown} && $condition eq "dhcp") { + $$state_ref = $state_set{sever_reboot}; + } elsif ($$state_ref == $state_set{unknown} && $condition eq "booted") { + $$state_ref = $state_set{done}; + } elsif (($$state_ref == $state_set{unknown} && $condition eq "tftp") || ($$state_ref == $state_set{unknown} && $condition eq "http")) { + $$state_ref = $state_set{loaded_kernel_and_initrd}; + } elsif ($$state_ref == $state_set{sever_reboot} && $condition eq "booted") { + $$state_ref = $state_set{done}; + } elsif ($$state_ref == $state_set{sever_reboot} && $condition eq "postscript") { + $$state_ref = $state_set{run_postbootscript}; + } elsif (($$state_ref == $state_set{sever_reboot} && $condition eq "tftp") || ($$state_ref == $state_set{sever_reboot} && $condition eq "http")) { + $$state_ref = $state_set{loaded_kernel_and_initrd}; + } elsif ($$state_ref == $state_set{loaded_kernel_and_initrd} && $condition eq "dhcp") { + $$state_ref = $state_set{kernel_and_initrd_got_ip}; + } elsif ($$state_ref == $state_set{kernel_and_initrd_got_ip} && $condition eq "http") { + $$state_ref = $state_set{install_os_packages}; + } elsif ($$state_ref == $state_set{install_os_packages} && $condition eq "postscript") { + $$state_ref = $state_set{run_postscript}; + } elsif ($$state_ref == $state_set{run_postscript} && $condition eq "dhcp") { + $$state_ref = $state_set{sever_reboot}; + } elsif ($$state_ref == $state_set{run_postbootscript} && $condition eq "booted") { + $$state_ref = $state_set{done}; + } elsif ($$state_ref == $state_set{done} && $condition eq "dhcp") { + $$state_ref = $state_set{sever_reboot}; + } elsif ($$state_ref == $state_set{done} && $condition eq "poweron") { + $$state_ref = $state_set{sever_reboot}; + } else { + $reset_flag = 0; + } + + return $reset_flag; +} + + +my @candidate_svr_hostname_inlog; +my $svr_hostname_short = `hostname -s`; +chomp($svr_hostname_short); +my $svr_hostname_domain = `hostname -d`; +chomp($svr_hostname_domain); +push(@candidate_svr_hostname_inlog, $svr_hostname_short); +push(@candidate_svr_hostname_inlog, "$svr_hostname_short.$svr_hostname_domain"); + + $::USAGE = "Usage: $program_name -h $program_name -T $program_name -n [-V] + $program_name -n -r [-V] Description: - Do probe for os provision process, realtime monitor of os provision process. - Please run this before rpower node. + Do probe for os provision process. Realtime monitor or replay history of os provision process. + If do realtime monitor, please run this before rpower node. + Unsupport hierarchial structure now. Options: -h : Get usage information of $program_name -T : To verify if $program_name can work, reserve option for probe framework -V : Output more information for debug - -n : The range of monitored node. + -n : The range of node to be monitor or replay log. + -t : The maximum time to wait when doing monitor, the unit is minute, default is 60 minutes. + -r : Replay history log to probe provision. need input a start time when probe should begin from. + Support time format are xxhxxm, xxh, or xxm. h means hour, m means minute. + If there isn't unit input, using hour by default. "; #------------------------------------------ @@ -54,58 +177,58 @@ Options: #------------------------------------------ sub check_noderange { - my $node_range = shift; - my @cmdoutput = `lsdef $node_range -i ip,mac 2>&1`; - my $rst = 0; - my $currentnode = ""; - my $ip = "NOIP"; + my $node_range = shift; + my @cmdoutput = `lsdef $node_range -i ip,mac -c 2>&1`; + my $rst = 0; my %nodecheckrst; - my $mac_line; - my @macs; foreach (@cmdoutput) { chomp($_); $_ =~ s/^\s+|\s+$//g; if ($_ =~ /^Error: Could not find an object named '(\w+)' .+/i) { - $currentnode = $1; - $nodecheckrst{$currentnode}{"error"} = "Could not find node definition"; - $rst = 1; - } elsif ($_ =~ /^\s*Object name: (\w+)/i) { - - # 'rst' is used to check whether the node process finished, 1 is finished. - $monitor_nodes{$1}{"rst"} = 0; - $currentnode = $1; - $ip = "NOIP"; - } elsif ($_ =~ /^ip=(.+)/i) { - if ($1) { - $ip = $1; + $nodecheckrst{$1}{"error"} = "Could not find node definition"; + } elsif ($_ =~ /(\S+):\s+mac=(.*)/i) { + my $node = $1; + my $mac = $2; + if ($mac) { + $nodecheckrst{$node}{"mac"} = $mac; + } else { + $nodecheckrst{$node}{"error"} = "Node $1 doesn't have MAC address"; } - } elsif ($_ =~ /^mac=(.+)/i) { - next unless ($1); - $mac_line = $1; - @macs = split(/\|/, $mac_line); - foreach my $mac (@macs) { - if ($mac =~ /\!\*NOIP\*/) { - $mac =~ s/\!\*NOIP\*//g; - $macmap{$mac}{"ip"} = "NOIP"; - $macmap{$mac}{"node"} = $currentnode; - } - else { - $macmap{$mac}{"ip"} = $ip; - $macmap{$mac}{"node"} = $currentnode; - } + } elsif ($_ =~ /(\S+):\s+ip=(.*)/i) { + my $node = $1; + my $ip = $2; + if ($ip) { + $nodecheckrst{$node}{"ip"} = $ip; } } } foreach my $node (keys %nodecheckrst) { - probe_utils->send_msg("$output", "d", "$node : $nodecheckrst{$node}{error}") if (exists($nodecheckrst{$node}{error})); + if (exists($nodecheckrst{$node}{error})) { + probe_utils->send_msg("$output", "d", "$node : $nodecheckrst{$node}{error}"); + $rst = 1; + next; + } + $monitor_nodes{$node}{"rst"} = 0; + my @macs = split(/\|/, $nodecheckrst{$node}{"mac"}); + foreach my $mac (@macs) { + if ($mac =~ /\!\*NOIP\*/) { + $mac =~ s/\!\*NOIP\*//g; + $macmap{$mac}{"ip"} = "NOIP"; + $macmap{$mac}{"node"} = $node; + } else { + $macmap{$mac}{"ip"} = $nodecheckrst{$node}{"ip"}; + $macmap{$mac}{"node"} = $node; + } + } } unless (%monitor_nodes) { - probe_utils->send_msg("$output", "d", "There is no node to be monitored"); + probe_utils->send_msg("$output", "d", "There is no valid node to handle"); $rst = 1; } + return $rst; } @@ -116,7 +239,7 @@ sub check_noderange { Handle one line log come from dhcp log file Arguments: msg: one line http log - nics: target network interfaces + installnic: target network interfaces Returns: 0 : pass 1 : failed @@ -132,8 +255,8 @@ sub handle_dhcp_msg { if (exists $macmap{$mac}) { my $node = $macmap{$mac}{"node"}; - my $record = "Receive DHCPDISCOVER from [$node] $mac via $nic"; - probe_utils->send_msg("$output", "d", "$record"); + my $record = "Receive DHCPDISCOVER via $nic"; + probe_utils->send_msg("$output", "d", "[$node] $record") if ($monitor); push(@{ $rawdata{$node}{"history"} }, $record); } } elsif ($msg =~ /.+DHCPOFFER\s+on\s+(.+)\s+to\s+(.+)\s+via\s+(.+)/i) { @@ -143,8 +266,8 @@ sub handle_dhcp_msg { if (exists $macmap{$mac}) { my $node = $macmap{$mac}{"node"}; - my $record = "Send DHCPOFFER on $ip back to [$node] $mac via $nic"; - probe_utils->send_msg("$output", "d", "$record"); + my $record = "Send DHCPOFFER on $ip back to $mac via $nic"; + probe_utils->send_msg("$output", "d", "[$node] $record") if ($monitor); push(@{ $rawdata{$node}{"history"} }, $record); } @@ -155,16 +278,10 @@ sub handle_dhcp_msg { my $nic = $4; if (exists $macmap{$mac}) { - my $node = $macmap{$mac}{"node"}; - my $record = "Receive DHCPREQUEST from [$node] $mac for $ip via $nic"; - probe_utils->send_msg("$output", "d", "$record"); + my $node = $macmap{$mac}{"node"}; + my $record = "Receive DHCPREQUEST from $mac for $ip via $nic"; + probe_utils->send_msg("$output", "d", "[$node] $record") if ($monitor); push(@{ $rawdata{$node}{"history"} }, $record); - - if ($macmap{$mac}{"ip"} != "NOIP" and $macmap{$mac}{"ip"} != $ip) { - my $warn_msg = "The ip of [$node] $mac from DHCP $ip is different with definition $macmap{$mac}{'ip'}."; - probe_utils->send_msg("$output", "w", "$warn_msg"); - push(@{ $rawdata{$node}{"history"} }, $warn_msg); - } } } elsif ($msg =~ /.+DHCPACK\s+on\s+(.+)\s+to\s+(.+)\s+via\s+(.+)/) { my $ip = $1; @@ -173,19 +290,25 @@ sub handle_dhcp_msg { if (exists $macmap{$mac}) { my $node = $macmap{$mac}{"node"}; - my $record = "Send DHCPACK on $ip back to [$node] $mac via $nic"; - probe_utils->send_msg("$output", "d", "$record"); + my $record = "Send DHCPACK on $ip back to $mac via $nic"; + probe_utils->send_msg("$output", "d", "[$node] $record") if ($monitor); push(@{ $rawdata{$node}{"history"} }, $record); $ipnodemap{$ip} = $node; + push(@{ $rawdata{$node}{statehistory} }, $rawdata{$node}{state}) if (reset_state(\$rawdata{$node}{state}, "dhcp")); + + if ($macmap{$mac}{"ip"} != "NOIP" and $macmap{$mac}{"ip"} != $ip) { + my $warn_msg = "The ip($ip) assigned to $mac via DHCP is different with the ip($macmap{$mac}{'ip'}) in node definition."; + probe_utils->send_msg("$output", "w", "$warn_msg") if ($monitor); + push(@{ $rawdata{$node}{"history"} }, $warn_msg); + } } } elsif ($msg =~ /.+BOOTREQUEST\s+from\s+(.+)\s+via\s+([^:]+)(.*)/) { my $mac = $1; my $nic = $2; - if (exists $macmap{$mac}) { my $node = $macmap{$mac}{"node"}; - my $record = "Receive BOOTREQUEST from [$node] $mac via $nic"; - probe_utils->send_msg("$output", "d", "$record"); + my $record = "Receive BOOTREQUEST from $mac via $nic"; + probe_utils->send_msg("$output", "d", "[$node] $record") if ($monitor); push(@{ $rawdata{$node}{"history"} }, $record); } } elsif ($msg =~ /.+BOOTREPLY\s+for\s+(.+)\s+to\s+.+(\w\w:\w\w:\w\w:\w\w:\w\w:\w\w).+via\s+(.+)/) { @@ -195,14 +318,15 @@ sub handle_dhcp_msg { if (exists $macmap{$mac}) { my $node = $macmap{$mac}{"node"}; - my $record = "Send BOOTREPLY on $ip back to [$node] $mac via $nic"; - probe_utils->send_msg("$output", "d", "$record"); + my $record = "Send BOOTREPLY on $ip back to $mac via $nic"; + probe_utils->send_msg("$output", "d", "[$node] $record") if ($monitor); push(@{ $rawdata{$node}{"history"} }, $record); $ipnodemap{$ip} = $node; + push(@{ $rawdata{$node}{statehistory} }, $rawdata{$node}{state}) if (reset_state(\$rawdata{$node}{state}, "dhcp")); if ($macmap{$mac}{"ip"} != "NOIP" and $macmap{$mac}{"ip"} != $ip) { - my $warn_msg = "The ip of [$node] $mac from DHCP $ip is different with definition $macmap{$mac}{'ip'}."; - probe_utils->send_msg("$output", "w", "$warn_msg"); + my $warn_msg = "The ip($ip) assigned to $mac via DHCP is different with the ip($macmap{$mac}{'ip'}) in node definition."; + probe_utils->send_msg("$output", "w", "$warn_msg") if ($monitor); push(@{ $rawdata{$node}{"history"} }, $warn_msg); } } @@ -230,11 +354,11 @@ sub handle_tftp_msg { if ($msg =~ /RRQ\s+from\s+(.+)\s+filename\s+(.+)/i) { my $ip = $1; my $file = $2; - my $record = "[$ipnodemap{$ip}] Via TFTP $ip download $file"; - + my $record = "Via TFTP download $file"; if (exists($rawdata{"$ipnodemap{$ip}"})) { - probe_utils->send_msg("$output", "d", "$record"); + probe_utils->send_msg("$output", "d", "[$ipnodemap{$ip}] $record") if ($monitor); push(@{ $rawdata{ $ipnodemap{$ip} }{"history"} }, $record); + push(@{ $rawdata{ $ipnodemap{$ip} }{statehistory} }, $rawdata{ $ipnodemap{$ip} }{state}) if (reset_state(\$rawdata{ $ipnodemap{$ip} }{state}, "tftp")); } } } @@ -257,11 +381,12 @@ sub handle_http_msg { if ($msg =~ /(\d+\.\d+.\d+.\d+)\s.+GET\s+(.+)\s+HTTP.+/) { my $ip = $1; my $file = $2; - my $record = "[$ipnodemap{$ip}] Via HTTP $ip GET $file"; + my $record = "Via HTTP get $file"; if (exists($rawdata{"$ipnodemap{$ip}"})) { - probe_utils->send_msg("$output", "d", "$record"); + probe_utils->send_msg("$output", "d", "[$ipnodemap{$ip}] $record") if ($monitor); push(@{ $rawdata{ $ipnodemap{$ip} }{"history"} }, $record); + push(@{ $rawdata{ $ipnodemap{$ip} }{statehistory} }, $rawdata{ $ipnodemap{$ip} }{state}) if (reset_state(\$rawdata{ $ipnodemap{$ip} }{state}, "http")); } } return 0; @@ -286,37 +411,29 @@ sub handle_cluster_msg { my $msg; my $status; - if ($line =~ /.+\s+xcat:\s+(.+)\s+status:\s+(.+)\s+statustime:\s(.+)/) { - $node = $1; - $status = $2; + my @splitline = split(/\s+/, $line); + if (($splitline[4] =~ /^xcat/i) || ($splitline[5] =~ /^xcat/i)) { - if (exists($rawdata{$node})) { - my $record = "Receive from $node : status is $status"; - probe_utils->send_msg("$output", "d", "$record"); - push(@{ $rawdata{$node}{"history"} }, $record); - } + #log like: Aug 7 22:30:31 c910f02c01p09 xcat: c910f02c04p04 status: booted statustime: 08-07-2016 22:30:31 + if (($splitline[6] =~ /^status:$/i) && ($splitline[8] =~ /^statustime:$/)) { + $node = $splitline[5]; + $status = $splitline[7]; + if (exists($rawdata{$node})) { + my $record = "Node status is changed to $status"; + probe_utils->send_msg("$output", "d", "[$node] $record") if ($monitor); + push(@{ $rawdata{$node}{"history"} }, $record); - # When receive 'status is booted', check whether the $monitor_nodes{$node}{"status"} is installing. - # If so, the node has finished its os provision. - if (exists($rawdata{$node}) and ($status eq "booted")) { - if ($monitor_nodes{$node}{"status"} eq "installing") { - $record = "Node $node has finished it's os provision process"; - probe_utils->send_msg("$output", "o", "$record"); - push(@{ $rawdata{$node}{"history"} }, $record); - } else { - $record = "NO installing process detected for node $node"; - probe_utils->send_msg("$output", "f", "$record"); - push(@{ $rawdata{$node}{"history"} }, $record); + #one node finish deployment + if ($status eq "booted") { + $monitor_nodes{$node}{"rst"} = 1 if (defined($monitor_nodes{$node})); + push(@{ $rawdata{$node}{statehistory} }, $rawdata{$node}{state}) if (reset_state(\$rawdata{$node}{state}, "booted")); + } + + if ($status eq "powering-on") { + push(@{ $rawdata{$node}{statehistory} }, $rawdata{$node}{state}) if (reset_state(\$rawdata{$node}{state}, "poweron")); + } } - $monitor_nodes{$node}{"rst"} = 1 if (defined($monitor_nodes{$node})); - } elsif (exists($rawdata{$node}) and ($status eq "failed")) { - $monitor_nodes{$node}{"rst"} = 1 if (defined($monitor_nodes{$node})); - probe_utils->send_msg("$output", "f", "Node $node has finished it's os provision process"); - push(@{ $rawdata{$node}{"history"} }, "Node $node os provision failed"); - } elsif (exists($rawdata{$node}) and ($status eq "installing")) { - # record 'installing' status, to check when receive 'booted' status - $monitor_nodes{$node}{"status"} = "installing"; } } return 0; @@ -350,10 +467,15 @@ sub handle_compute_msg { } else { $node = $ipnodemap{$sender}; } + if ($node ne "" && exists($rawdata{$node})) { - my $record = "Receive from $node : $msg"; - probe_utils->send_msg("$output", "d", "$record"); - push(@{ $rawdata{$node}{"history"} }, $record); + probe_utils->send_msg("$output", "d", "[$node] $msg") if ($monitor); + push(@{ $rawdata{$node}{"history"} }, $msg); + + #node start to run postscript or postbootscript + if ($msg =~ /Running postscript/) { + push(@{ $rawdata{$node}{statehistory} }, $rawdata{$node}{state}) if (reset_state(\$rawdata{$node}{state}, "postscript")); + } } } @@ -407,30 +529,113 @@ sub dump_history { print "$title\n"; foreach $node (keys %rawdata) { - my $line_num = 0; - my $http_num = 0; - my $length_http; - for (my $i = @{ $rawdata{$node}{"history"} } ; $i >= 0 ; $i--) { - if (${ $rawdata{$node}{"history"} }[$i] =~ /Via HTTP/) { - $length_http = $i; - last; + + if ($verbose) { + print "[$node]\n"; + + my $httphit = 0; + my @httptmp; + foreach my $line (@{ $rawdata{$node}{"history"} }) { + if ($line =~ /Via HTTP/) { + if ($httphit) { + shift @httptmp if ($#httptmp > 0); + push @httptmp, $line; + } else { + print "\t$line\n"; + $httphit = 1; + } + } else { + if ($#httptmp > -1) { + print "\tVia HTTP ..........\n"; + print "\t$_\n" foreach (@httptmp); + } + @httptmp = (); + $httphit = 0; + print "\t$line\n"; + } } } - foreach my $line (@{ $rawdata{$node}{"history"} }) { - # Print http message less than 10 lines - if ($line =~ /Via HTTP/) - { - if (($http_num <= 4) or ($length_http - $line_num <= 4)) { - probe_utils->send_msg("$output", "d", "\t$line"); + my @tmpnodestatehistory = @{ $rawdata{$node}{statehistory} }; + + #print "state history = @tmpnodestatehistory\n"; + + my %match_result; + my $procidx = 0; + my $newloop = 0; + my $notfirstloop = 0; + while (@tmpnodestatehistory) { + undef %match_result if ($notfirstloop); + $newloop = 0; + foreach my $type (keys %valid_process) { + if ($notfirstloop) { + $procidx = 1; } else { - probe_utils->send_msg("$output", "d", "\t......") if ($http_num == 5); + $procidx = 0; } - $http_num++; - } else { - probe_utils->send_msg("$output", "d", "\t$line"); + my $proclen = scalar(@{ $valid_process{$type}{process} }); + my $i; + for ($i = 0 ; $i < scalar(@tmpnodestatehistory) ; $i++) { + if ($procidx < $proclen) { + if ($tmpnodestatehistory[$i] == $valid_process{$type}{process}[$procidx]) { + ++$procidx; + } else { + --$procidx if (notfirstloop); + push @{ $match_result{$procidx} }, $type; + last; + } + } else { + splice(@tmpnodestatehistory, 0, $i); + $newloop = 1; + $notfirstloop = 1; + last; + } + } + if ($i == scalar(@tmpnodestatehistory)) { + push @{ $match_result{$procidx} }, $type; + next; + } + last if ($newloop); + } + last if (!$newloop); + } + + # print "------------result---------------\n"; + # print Dumper %match_result; + + my $max_match = 0; + foreach my $key (keys %match_result) { + $max_match = $key if ($key > $max_match); + } + + my $formatprefix; + if ($max_match == 0) { + my $statelist = ""; + for (my $i = 0 ; $i < scalar(@{ $rawdata{$node}{statehistory} }) ; $i++) { + $statelist .= "$state_set_reverse{$rawdata{$node}{statehistory}[$i]} "; + } + probe_utils->send_msg("$output", "f", "[$node] deployment failed"); + probe_utils->send_msg("$output", "d", "\t$node did unknown process, state change history is $statelist"); + } elsif (scalar(@{ $match_result{$max_match} }) > 1) { + probe_utils->send_msg("$output", "f", "[$node] deployment failed"); + probe_utils->send_msg("$output", "d", "\tThere are more than one possible process satisfy $node situation"); + foreach my $proc (@{ $match_result{$max_match} }) { + if ($valid_process{$proc}{type} eq "deploy") { + probe_utils->send_msg("$output", "d", "\tpossible process \"deploy\", pass $state_set_reverse{$valid_process{$proc}{process}[$max_match-1]} stage, something wrong during $state_set_reverse{$valid_process{$proc}{process}[$max_match]} stage"); + } elsif ($valid_process{$proc}{type} eq "reboot") { + probe_utils->send_msg("$output", "d", "\tpossible process \"reboot\", pass $state_set_reverse{$valid_process{$proc}{process}[$max_match-1]} stage, something wrong during $state_set_reverse{$valid_process{$proc}{process}[$max_match]} stage"); + } + } + } else { + if (($valid_process{ $match_result{$max_match}[0] }{type} eq "deploy") && ($valid_process{ $match_result{$max_match}[0] }{process}[ $max_match - 1 ] == $state_set{done})) { + probe_utils->send_msg("$output", "o", "[$node] deployment completed"); + } elsif (($valid_process{ $match_result{$max_match}[0] }{type} eq "deploy") && ($valid_process{ $match_result{$max_match}[0] }{process}[ $max_match - 1 ] != $state_set{done})) { + probe_utils->send_msg("$output", "f", "[$node] deployment failed, pass $state_set_reverse{$valid_process{$match_result{$max_match}[0]}{process}[$max_match-1]} stage, something wrong during $state_set_reverse{$valid_process{$match_result{$max_match}[0]}{process}[$max_match]} stage") + } elsif (($valid_process{ $match_result{$max_match}[0] }{type} eq "reboot") && ($valid_process{ $match_result{$max_match}[0] }{process}[ $max_match - 1 ] == $state_set{done})) { + probe_utils->send_msg("$output", "f", "[$node] reboot completed, without deployment process"); + } elsif (($valid_process{ $match_result{$max_match}[0] }{type} eq "reboot") && ($valid_process{ $match_result{$max_match}[0] }{process}[ $max_match - 1 ] != $state_set{done})) { + probe_utils->send_msg("$output", "f", "[$node] reboot failed,without deployment process, stop at $state_set_reverse{$valid_process{$match_result{$max_match}[0]}{process}[$max_match-1]} stage, something wrong during $state_set_reverse{$valid_process{$match_result{$max_match}[0]}{process}[$max_match]} stage"); } - $line_num++; } } } @@ -451,29 +656,6 @@ sub do_monitor { $terminal = 1; }; - my $msg = "All pre_defined nodes are valid"; - my $rc = check_noderange($noderange); - if ($rc) { - probe_utils->send_msg("$output", "f", $msg); - $rst = 1; - unless (%monitor_nodes) { - return $rst; - } - } else { - probe_utils->send_msg("$output", "o", $msg); - } - - if (!$nics) { - my $masteripinsite = `tabdump site | awk -F',' '/^"master",/ { gsub(/"/, "", \$2) ; print \$2 }'`; - chomp($masteripinsite); - $nics = `ip addr |grep -B2 $masteripinsite|awk -F" " '/mtu/{gsub(/:/,"",\$2); print \$2}'`; - chomp($nics); - if (!$nics) { - probe_utils->send_msg("$output", "f", "The value of master in site table is $masteripinsite, can't get corresponding network interface"); - return 1; - } - } - my $rst = 0; my $startline = "------------------------------------------------------------- @@ -514,6 +696,7 @@ Start to capture every message during os provision process...... if (!-e "$clusterlog") { probe_utils->send_msg("$output", "w", "$clusterlog doesn't exist"); + probe_utils->send_msg("$output", "i", "If sles11 or xCAT2.11.x is using, please ignore above warning"); } else { if (!($clusterpid = open(CLUSTERLOGFILE, "tail -f -n 0 $clusterlog 2>&1 |"))) { probe_utils->send_msg("$output", "f", "Can't open $clusterlog to get logs"); @@ -532,6 +715,7 @@ Start to capture every message during os provision process...... } if (!-e "$computelog") { probe_utils->send_msg("$output", "w", "$computelog doesn't exist"); + probe_utils->send_msg("$output", "i", "If sles11 or xCAT2.11.x is using, please ignore above warning"); } else { if (!($computerpid = open(COMPUTERFILE, "tail -f -n 0 $computelog 2>&1 |"))) { probe_utils->send_msg("$output", "f", "Can't open $computelog to get logs"); @@ -551,21 +735,15 @@ Start to capture every message during os provision process...... my @hdls; my $hdl; - my @candidate_svr_hostname_inlog; - my $svr_hostname_short = `hostname -s`; - chomp($svr_hostname_short); - my $svr_hostname_domain = `hostname -d`; - chomp($svr_hostname_domain); - push(@candidate_svr_hostname_inlog, $svr_hostname_short); - push(@candidate_svr_hostname_inlog, "$svr_hostname_short.$svr_hostname_domain"); - + my $starttime = time(); + $monitor = 1; for (; ;) { if (@hdls = $select->can_read(0)) { foreach $hdl (@hdls) { if ($hdl == \*VARLOGMSGFILE) { chomp($line = ); my @tmp = split(/\s+/, $line); - if ($tmp[4] =~ /dhcpd:/i && $line =~ /$nics/) { + if ($tmp[4] =~ /dhcpd:/i && $line =~ /$installnic/) { handle_dhcp_msg("$line"); } elsif ($tmp[4] =~ /in.tftpd/i) { handle_tftp_msg("$line"); @@ -596,7 +774,13 @@ Start to capture every message during os provision process...... probe_utils->send_msg("$output", "o", "All nodes need to monitor have finished os provision process"); } last; - } sleep 0.01; + } + + if (time() - $starttime > ($maxwaittime * 60)) { + probe_utils->send_msg("$output", "i", "$maxwaittime minutes are expired, stop monitor"); + last; + } + sleep 0.01; } &dump_history; } @@ -612,6 +796,176 @@ Start to capture every message during os provision process...... return $rst; } +sub get_valid_logs { + my $ref_timestamp = shift; + my $year = shift; + my $epoch_seconds_of_now = shift; + my $bthistory_ref = shift; + my $nics = "eth0"; + my @orglogfilelist = ("/var/log/xcat/cluster.log", + "/var/log/messages", + "/var/log/xcat/computes.log"); + my $httplog; + if (-e "/var/log/httpd/access_log") { + $httplog = "/var/log/httpd/access_log"; + } elsif (-e "/var/log/apache2/access_log") { + $httplog = "/var/log/apache2/access_log"; + } elsif (-e "/var/log/apache2/access.log") { + $httplog = "/var/log/apache2/access.log"; + } + push @orglogfilelist, $httplog; + + foreach my $f (@orglogfilelist) { + my $filename = basename("$f"); + $filename =~ s/(.+)\.(.+)/$1/g; + my $path_only = dirname("$f"); + my @rotatefiles; + my @alltargetfiles = `ls -lt $path_only |awk -F" " '/ $filename/ {print \$9}'`; + foreach my $samenamefile (@alltargetfiles) { + chomp($samenamefile); + push @rotatefiles, "$path_only/$samenamefile"; + } + + my $ishttplog = 0; + $ishttplog = 1 if ($filename =~ /access[\._]log/); + + foreach my $file (@rotatefiles) { + my $fd; + my $filetype = `file $file 2>&1`; + chomp($filetype); + if ($filetype =~ /ASCII text/) { + if (!open($fd, "$file")) { + print "open $files failed\n"; + next; + } + } else { + + #TODO handle compression files + } + + #print "--->load $file\n"; + my $line; + my $historynum = 0; + last unless ($line = <$fd>); + chomp($line); + my $needrotate = 0; + my $istorynum = 0; + my $logindex = 0; + my @splitline = split(/\s+/, $line); + my $timestamp; + my $timestampepoch; + + if ($ishttplog) { + $splitline[3] =~ s/^\[(.+)/$1/g; + $timestampepoch = probe_utils->convert_to_epoch_seconds($splitline[3]); + } else { + $timestamp = join(" ", @splitline[ 0 .. 2 ]); + $timestampepoch = probe_utils->convert_to_epoch_seconds($timestamp, $year, $epoch_seconds_of_now); + } + if ($ref_timestamp <= $timestampepoch) { + $needrotate = 1; + } else { + seek($fd, 0, 2); + my $tail = tell; + my $head = 0; + my $lasttail = $tail; + my $i = 0; + while ($head <= $tail) { + my $middle = int(($tail - $head) / 2) + $head; + seek($fd, $middle, 0); + $line = <$fd>; + $middle += length($line); + last unless ($line = <$fd>); + @splitline = split(/\s+/, $line); + if ($ishttplog) { + $splitline[3] =~ s/^\[(.+)/$1/g; + $timestampepoch = probe_utils->convert_to_epoch_seconds($splitline[3]); + } else { + $timestamp = join(" ", @splitline[ 0 .. 2 ]); + $timestampepoch = probe_utils->convert_to_epoch_seconds($timestamp, $year, $epoch_seconds_of_now); + } if ($ref_timestamp == $timestampepoch) { + $historynum = $middle; + last; + } elsif ($ref_timestamp < $timestampepoch) { + $tail = $middle; + last if ($tail == $lasttail); + $lasttail = $tail; + } else { + $head = $middle; + } + } + $historynum = $head unless ($historynum); + } + + seek($fd, $historynum, 0); + while (<$fd>) { + chomp; + @splitline = split(/\s+/, $_); + if ($ishttplog) { + $splitline[3] =~ s/^\[(.+)/$1/g; + $timestampepoch = probe_utils->convert_to_epoch_seconds($splitline[3]); + } else { + $timestamp = join(" ", @splitline[ 0 .. 2 ]); + $timestampepoch = probe_utils->convert_to_epoch_seconds($timestamp, $year, $epoch_seconds_of_now); + } + + if (($splitline[4] =~ /dhcpd:/i && $_ =~ /$nics/) + || ($splitline[4] =~ /in.tftpd/i) + || (($splitline[4] =~ /^xcat/i) || ($splitline[5] =~ /^xcat/i)) + || ($splitline[5] =~ /GET/ && $splitline[7] =~ /HTTP/)) { + my $log = "$timestampepoch $filename$logindex $_"; + $logindex++; + push @$bthistory_ref, $log; + } + } + close($fd); + last unless ($needrotate); + } + } + + #sort logs depending on time + my @sort_ht = sort(@$bthistory_ref); + for ($i = 0 ; $i <= $#sort_ht ; $i++) { + $sort_ht[$i] =~ s/^(\d+) (\S+) (.+)/$1 $3/g; + } + + #delete duplicate logs + my %count; + @$bthistory_ref = grep { ++$count{$_} < 2; } @sort_ht; +} + +sub do_replay { + my $ref_timestamp = shift; + + my $timestr = scalar(localtime($ref_timestamp)); + print "Start to search logs after '$timestr', please waiting for a while.............\n"; + + my ($sec, $min, $hour, $day, $mon, $year, $wday, $yday, $isdst) = localtime(time()); + my $epoch_seconds_of_now = time(); + my @bthistory; + get_valid_logs($ref_timestamp, $year, $epoch_seconds_of_now, \@bthistory); + + foreach my $line (@bthistory) { + $line =~ s/(\d+) (.+)/$2/g; + my @tmp = split(/\s+/, $line); + if ($tmp[4] =~ /dhcpd:/i && $line =~ /$nics/) { + handle_dhcp_msg("$line"); + } elsif ($tmp[4] =~ /in.tftpd/i) { + handle_tftp_msg("$line"); + } elsif (($tmp[4] =~ /^xcat/i) || ($tmp[5] =~ /^xcat/i)) { + if (grep(/^$tmp[3]$/, @candidate_svr_hostname_inlog)) { + handle_cluster_msg("$line"); + } else { + handle_compute_msg("$line"); + } + } elsif ($tmp[5] =~ /GET/ && $tmp[7] =~ /HTTP/) { + handle_http_msg("$line"); + } + } + &dump_history; + return 0; +} + #------------------------------------- # main process #------------------------------------- @@ -619,6 +973,8 @@ if ( !GetOptions("--help|h|?" => \$help, "T" => \$test, "V" => \$verbose, + "t" => \$maxwaittime, + "r=s" => \$replaylog, "n=s" => \$noderange)) { probe_utils->send_msg("$output", "f", "Invalid parameter for $program_name"); @@ -641,11 +997,60 @@ if ($test) { } unless ($noderange) { - probe_utils->send_msg("$output", "f", "Option -n is required"); + probe_utils->send_msg("$output", "f", "A noderange is needed"); probe_utils->send_msg("$output", "d", "$::USAGE"); exit 1; } +my $epoch_starttime = time(); +if ($replaylog) { + if ($replaylog =~ /(\d+)h(\d+)m/i) { + $epoch_starttime -= ($1 * 3600 + $2 * 60) + } elsif ($replaylog =~ /^(\d+)h*$/i) { + $epoch_starttime -= $1 * 3600; + } elsif ($replaylog =~ /^(\d+)m$/) { + $epoch_starttime -= $1 * 60; + } else { + probe_utils->send_msg("$output", "f", "Unsupport time format for replay history log"); + print "$::USAGE"; + exit 1; + } +} + +my $msg = "All pre_defined nodes are valid"; +my $rc = check_noderange($noderange); +if ($rc) { + probe_utils->send_msg("$output", "f", $msg); + $rst = 1; +} else { + probe_utils->send_msg("$output", "o", $msg); +} + +unless ($installnic) { + my $masteripinsite = `tabdump site | awk -F',' '/^"master",/ { gsub(/"/, "", \$2) ; print \$2 }'`; + chomp($masteripinsite); + $installnic = `ip addr |grep -B2 $masteripinsite|awk -F" " '/mtu/{gsub(/:/,"",\$2); print \$2}'`; + chomp($installnic); + if (!$installnic) { + probe_utils->send_msg("$output", "f", "The value of master in site table is $masteripinsite, can't get corresponding network interface"); + $rst = 1; + } else { + probe_utils->send_msg("$output", "i", "The installation network interface is $installnic"); + } +} + +exit $rst if ($rst); + +foreach my $node (keys %monitor_nodes) { + $rawdata{$node}{state} = $state_set{unknown}; + push(@{ $rawdata{$node}{statehistory} }, $rawdata{$node}{state}); +} + +if ($replaylog) { + $rst = do_replay($epoch_starttime); + exit $rst; +} + $rst = do_monitor(); exit $rst; From 43dc07c56fd768d324bad07626a01e19aec881db Mon Sep 17 00:00:00 2001 From: immarvin Date: Tue, 9 Aug 2016 03:31:17 -0400 Subject: [PATCH 013/106] fix [FVT]:ubuntu build script build-ubunturepo does not support minor release #1604 --- build-ubunturepo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-ubunturepo b/build-ubunturepo index 6c9e001cd..3cf553ccb 100755 --- a/build-ubunturepo +++ b/build-ubunturepo @@ -203,7 +203,7 @@ then pkg_type="snap" build_string="Snap_Build" cur_date=`date +%Y%m%d%H%M` - pkg_version="${short_ver}-${pkg_type}${cur_date}" + pkg_version="${ver}-${pkg_type}${cur_date}" if [ ! -d ../../$package_dir_name ];then mkdir -p "../../$package_dir_name" From c67da2b4d636b79568fa3ed1944d5a4f7826082b Mon Sep 17 00:00:00 2001 From: "litingt@cn.ibm.com" Date: Tue, 9 Aug 2016 04:42:00 -0400 Subject: [PATCH 014/106] update bundle files according to go-xcat change --- xCAT-test/autotest/bundle/rhels6.8_ppc64.bundle | 9 +++------ xCAT-test/autotest/bundle/rhels6.8_x86_64.bundle | 9 +++------ xCAT-test/autotest/bundle/rhels7.2_ppc64.bundle | 9 +++------ xCAT-test/autotest/bundle/rhels7.2_ppc64le.bundle | 9 +++------ xCAT-test/autotest/bundle/rhels7.2_x86_64.bundle | 9 +++------ xCAT-test/autotest/bundle/sles11.4_ppc64.bundle | 9 +++------ xCAT-test/autotest/bundle/sles11.4_x86_64.bundle | 9 +++------ xCAT-test/autotest/bundle/sles12.1_ppc64le.bundle | 9 +++------ xCAT-test/autotest/bundle/sles12.1_x86_64.bundle | 9 +++------ .../autotest/bundle/ubuntu14.04.4_ppc64le.bundle | 9 +++------ .../autotest/bundle/ubuntu14.04.4_x86_64.bundle | 9 +++------ .../autotest/bundle/ubuntu16.04.1_ppc64le.bundle | 9 +++------ .../autotest/bundle/ubuntu16.04.1_x86_64.bundle | 13 +++++-------- .../autotest/bundle/ubuntu16.04_ppc64le.bundle | 9 +++------ xCAT-test/autotest/bundle/ubuntu16.04_x86_64.bundle | 13 +++++-------- 15 files changed, 49 insertions(+), 94 deletions(-) diff --git a/xCAT-test/autotest/bundle/rhels6.8_ppc64.bundle b/xCAT-test/autotest/bundle/rhels6.8_ppc64.bundle index 8c990aa86..50cf77787 100644 --- a/xCAT-test/autotest/bundle/rhels6.8_ppc64.bundle +++ b/xCAT-test/autotest/bundle/rhels6.8_ppc64.bundle @@ -1,12 +1,9 @@ reg_linux_diskfull_installation_flat -go_xcat_local_repo_case1 -go_xcat_local_repo_case2 -go_xcat_local_repo_case3 -go_xcat_local_repo_case4 -go_xcat_local_repo_case5 -go_xcat_local_repo_case6 go_xcat_local_repo_case7 go_xcat_noinput +go_xcat_with_x +go_xcat_with_xcat-version-1 +go_xcat_online_repo_case6 updatenode_h updatenode_v updatenode_diskful_syncfiles diff --git a/xCAT-test/autotest/bundle/rhels6.8_x86_64.bundle b/xCAT-test/autotest/bundle/rhels6.8_x86_64.bundle index 7b014eafb..1ea9aa544 100644 --- a/xCAT-test/autotest/bundle/rhels6.8_x86_64.bundle +++ b/xCAT-test/autotest/bundle/rhels6.8_x86_64.bundle @@ -1,12 +1,9 @@ reg_linux_diskfull_installation_flat -go_xcat_local_repo_case1 -go_xcat_local_repo_case2 -go_xcat_local_repo_case3 -go_xcat_local_repo_case4 -go_xcat_local_repo_case5 -go_xcat_local_repo_case6 go_xcat_local_repo_case7 go_xcat_noinput +go_xcat_with_x +go_xcat_with_xcat-version-1 +go_xcat_online_repo_case6 makehosts_h makehosts_help makehosts_n diff --git a/xCAT-test/autotest/bundle/rhels7.2_ppc64.bundle b/xCAT-test/autotest/bundle/rhels7.2_ppc64.bundle index b348a21c5..f2b8df3fc 100644 --- a/xCAT-test/autotest/bundle/rhels7.2_ppc64.bundle +++ b/xCAT-test/autotest/bundle/rhels7.2_ppc64.bundle @@ -1,12 +1,9 @@ reg_linux_diskfull_installation_flat -go_xcat_local_repo_case1 -go_xcat_local_repo_case2 -go_xcat_local_repo_case3 -go_xcat_local_repo_case4 -go_xcat_local_repo_case5 -go_xcat_local_repo_case6 go_xcat_local_repo_case7 go_xcat_noinput +go_xcat_with_x +go_xcat_with_xcat-version-1 +go_xcat_online_repo_case6 updatenode_h updatenode_v updatenode_diskful_syncfiles diff --git a/xCAT-test/autotest/bundle/rhels7.2_ppc64le.bundle b/xCAT-test/autotest/bundle/rhels7.2_ppc64le.bundle index cc15f6b88..016cc6e18 100644 --- a/xCAT-test/autotest/bundle/rhels7.2_ppc64le.bundle +++ b/xCAT-test/autotest/bundle/rhels7.2_ppc64le.bundle @@ -1,13 +1,10 @@ Diskless_installation_flat_p8_le Full_installation_flat_p8_le -go_xcat_local_repo_case1 -go_xcat_local_repo_case2 -go_xcat_local_repo_case3 -go_xcat_local_repo_case4 -go_xcat_local_repo_case5 -go_xcat_local_repo_case6 go_xcat_local_repo_case7 go_xcat_noinput +go_xcat_with_x +go_xcat_with_xcat-version-1 +go_xcat_online_repo_case6 makehosts_h makehosts_help makehosts_n diff --git a/xCAT-test/autotest/bundle/rhels7.2_x86_64.bundle b/xCAT-test/autotest/bundle/rhels7.2_x86_64.bundle index d9d0ba4e8..b49f7d3d5 100644 --- a/xCAT-test/autotest/bundle/rhels7.2_x86_64.bundle +++ b/xCAT-test/autotest/bundle/rhels7.2_x86_64.bundle @@ -1,12 +1,9 @@ reg_linux_diskfull_installation_flat -go_xcat_local_repo_case1 -go_xcat_local_repo_case2 -go_xcat_local_repo_case3 -go_xcat_local_repo_case4 -go_xcat_local_repo_case5 -go_xcat_local_repo_case6 go_xcat_local_repo_case7 go_xcat_noinput +go_xcat_with_x +go_xcat_with_xcat-version-1 +go_xcat_online_repo_case6 makehosts_h makehosts_help makehosts_n diff --git a/xCAT-test/autotest/bundle/sles11.4_ppc64.bundle b/xCAT-test/autotest/bundle/sles11.4_ppc64.bundle index d9d8a1ad7..e87ae4427 100644 --- a/xCAT-test/autotest/bundle/sles11.4_ppc64.bundle +++ b/xCAT-test/autotest/bundle/sles11.4_ppc64.bundle @@ -1,12 +1,9 @@ reg_linux_diskfull_installation_flat -go_xcat_local_repo_case1 -go_xcat_local_repo_case2 -go_xcat_local_repo_case3 -go_xcat_local_repo_case4 -go_xcat_local_repo_case5 -go_xcat_local_repo_case6 go_xcat_local_repo_case7 go_xcat_noinput +go_xcat_with_x +go_xcat_with_xcat-version-1 +go_xcat_online_repo_case6 chdef_null chdef_t_node chdef_t_network diff --git a/xCAT-test/autotest/bundle/sles11.4_x86_64.bundle b/xCAT-test/autotest/bundle/sles11.4_x86_64.bundle index 0ba277a04..7a7e5fd18 100644 --- a/xCAT-test/autotest/bundle/sles11.4_x86_64.bundle +++ b/xCAT-test/autotest/bundle/sles11.4_x86_64.bundle @@ -1,12 +1,9 @@ reg_linux_diskfull_installation_flat -go_xcat_local_repo_case1 -go_xcat_local_repo_case2 -go_xcat_local_repo_case3 -go_xcat_local_repo_case4 -go_xcat_local_repo_case5 -go_xcat_local_repo_case6 go_xcat_local_repo_case7 go_xcat_noinput +go_xcat_with_x +go_xcat_with_xcat-version-1 +go_xcat_online_repo_case6 makehosts_h makehosts_help makehosts_n diff --git a/xCAT-test/autotest/bundle/sles12.1_ppc64le.bundle b/xCAT-test/autotest/bundle/sles12.1_ppc64le.bundle index 61ae6ffdb..908c9e336 100644 --- a/xCAT-test/autotest/bundle/sles12.1_ppc64le.bundle +++ b/xCAT-test/autotest/bundle/sles12.1_ppc64le.bundle @@ -1,13 +1,10 @@ Diskless_installation_flat_p8_le Full_installation_flat_p8_le -go_xcat_local_repo_case1 -go_xcat_local_repo_case2 -go_xcat_local_repo_case3 -go_xcat_local_repo_case4 -go_xcat_local_repo_case5 -go_xcat_local_repo_case6 go_xcat_local_repo_case7 go_xcat_noinput +go_xcat_with_x +go_xcat_with_xcat-version-1 +go_xcat_online_repo_case6 makehosts_h makehosts_help makehosts_n diff --git a/xCAT-test/autotest/bundle/sles12.1_x86_64.bundle b/xCAT-test/autotest/bundle/sles12.1_x86_64.bundle index cedd4f898..de0b6e294 100644 --- a/xCAT-test/autotest/bundle/sles12.1_x86_64.bundle +++ b/xCAT-test/autotest/bundle/sles12.1_x86_64.bundle @@ -1,12 +1,9 @@ reg_linux_diskfull_installation_flat -go_xcat_local_repo_case1 -go_xcat_local_repo_case2 -go_xcat_local_repo_case3 -go_xcat_local_repo_case4 -go_xcat_local_repo_case5 -go_xcat_local_repo_case6 go_xcat_local_repo_case7 go_xcat_noinput +go_xcat_with_x +go_xcat_with_xcat-version-1 +go_xcat_online_repo_case6 makehosts_h makehosts_help makehosts_n diff --git a/xCAT-test/autotest/bundle/ubuntu14.04.4_ppc64le.bundle b/xCAT-test/autotest/bundle/ubuntu14.04.4_ppc64le.bundle index 4e9c2fb3f..5e2b828c7 100644 --- a/xCAT-test/autotest/bundle/ubuntu14.04.4_ppc64le.bundle +++ b/xCAT-test/autotest/bundle/ubuntu14.04.4_ppc64le.bundle @@ -1,13 +1,10 @@ Diskless_installation_flat_p8_le Full_installation_flat_p8_le -go_xcat_local_repo_case1 -go_xcat_local_repo_case2 -go_xcat_local_repo_case3 -go_xcat_local_repo_case4 -go_xcat_local_repo_case5 -go_xcat_local_repo_case6 go_xcat_local_repo_case7 go_xcat_noinput +go_xcat_with_x +go_xcat_with_xcat-version-1 +go_xcat_online_repo_case6 makehosts_h makehosts_help makehosts_n_noderange diff --git a/xCAT-test/autotest/bundle/ubuntu14.04.4_x86_64.bundle b/xCAT-test/autotest/bundle/ubuntu14.04.4_x86_64.bundle index b86bc7dfa..94301d77b 100644 --- a/xCAT-test/autotest/bundle/ubuntu14.04.4_x86_64.bundle +++ b/xCAT-test/autotest/bundle/ubuntu14.04.4_x86_64.bundle @@ -1,13 +1,10 @@ Ubuntu_diskless_installation_flat_x86_vm Ubuntu_full_installation_flat_x86_vm -go_xcat_local_repo_case1 -go_xcat_local_repo_case2 -go_xcat_local_repo_case3 -go_xcat_local_repo_case4 -go_xcat_local_repo_case5 -go_xcat_local_repo_case6 go_xcat_local_repo_case7 go_xcat_noinput +go_xcat_with_x +go_xcat_with_xcat-version-1 +go_xcat_online_repo_case6 makehosts_h makehosts_help makehosts_n_noderange diff --git a/xCAT-test/autotest/bundle/ubuntu16.04.1_ppc64le.bundle b/xCAT-test/autotest/bundle/ubuntu16.04.1_ppc64le.bundle index ae76c787f..28cd9b4c0 100644 --- a/xCAT-test/autotest/bundle/ubuntu16.04.1_ppc64le.bundle +++ b/xCAT-test/autotest/bundle/ubuntu16.04.1_ppc64le.bundle @@ -1,13 +1,10 @@ Diskless_installation_flat_p8_le Full_installation_flat_p8_le -go_xcat_local_repo_case1 -go_xcat_local_repo_case2 -go_xcat_local_repo_case3 -go_xcat_local_repo_case4 -go_xcat_local_repo_case5 -go_xcat_local_repo_case6 go_xcat_local_repo_case7 go_xcat_noinput +go_xcat_with_x +go_xcat_with_xcat-version-1 +go_xcat_online_repo_case6 makehosts_h makehosts_help makehosts_n_noderange diff --git a/xCAT-test/autotest/bundle/ubuntu16.04.1_x86_64.bundle b/xCAT-test/autotest/bundle/ubuntu16.04.1_x86_64.bundle index 0fd26a629..fe6034954 100644 --- a/xCAT-test/autotest/bundle/ubuntu16.04.1_x86_64.bundle +++ b/xCAT-test/autotest/bundle/ubuntu16.04.1_x86_64.bundle @@ -1,5 +1,10 @@ Ubuntu_diskless_installation_flat_x86_vm Ubuntu_full_installation_flat_x86_vm +go_xcat_local_repo_case7 +go_xcat_noinput +go_xcat_with_x +go_xcat_with_xcat-version-1 +go_xcat_online_repo_case6 makehosts_h makehosts_help makehosts_n_noderange @@ -250,11 +255,3 @@ run_command_with_XCATBYPASS_systemd disable_root_permission_in_policy_table_systemd assign_certain_command_permission_systemd nodeset_check_warninginfo -go_xcat_local_repo_case1 -go_xcat_local_repo_case2 -go_xcat_local_repo_case3 -go_xcat_local_repo_case4 -go_xcat_local_repo_case5 -go_xcat_local_repo_case6 -go_xcat_local_repo_case7 -go_xcat_noinput diff --git a/xCAT-test/autotest/bundle/ubuntu16.04_ppc64le.bundle b/xCAT-test/autotest/bundle/ubuntu16.04_ppc64le.bundle index ae76c787f..28cd9b4c0 100644 --- a/xCAT-test/autotest/bundle/ubuntu16.04_ppc64le.bundle +++ b/xCAT-test/autotest/bundle/ubuntu16.04_ppc64le.bundle @@ -1,13 +1,10 @@ Diskless_installation_flat_p8_le Full_installation_flat_p8_le -go_xcat_local_repo_case1 -go_xcat_local_repo_case2 -go_xcat_local_repo_case3 -go_xcat_local_repo_case4 -go_xcat_local_repo_case5 -go_xcat_local_repo_case6 go_xcat_local_repo_case7 go_xcat_noinput +go_xcat_with_x +go_xcat_with_xcat-version-1 +go_xcat_online_repo_case6 makehosts_h makehosts_help makehosts_n_noderange diff --git a/xCAT-test/autotest/bundle/ubuntu16.04_x86_64.bundle b/xCAT-test/autotest/bundle/ubuntu16.04_x86_64.bundle index 0fd26a629..fe6034954 100644 --- a/xCAT-test/autotest/bundle/ubuntu16.04_x86_64.bundle +++ b/xCAT-test/autotest/bundle/ubuntu16.04_x86_64.bundle @@ -1,5 +1,10 @@ Ubuntu_diskless_installation_flat_x86_vm Ubuntu_full_installation_flat_x86_vm +go_xcat_local_repo_case7 +go_xcat_noinput +go_xcat_with_x +go_xcat_with_xcat-version-1 +go_xcat_online_repo_case6 makehosts_h makehosts_help makehosts_n_noderange @@ -250,11 +255,3 @@ run_command_with_XCATBYPASS_systemd disable_root_permission_in_policy_table_systemd assign_certain_command_permission_systemd nodeset_check_warninginfo -go_xcat_local_repo_case1 -go_xcat_local_repo_case2 -go_xcat_local_repo_case3 -go_xcat_local_repo_case4 -go_xcat_local_repo_case5 -go_xcat_local_repo_case6 -go_xcat_local_repo_case7 -go_xcat_noinput From c458718ebf1a616ae9a11be70907fa6f15a6a387 Mon Sep 17 00:00:00 2001 From: Casandra Qiu Date: Tue, 9 Aug 2016 16:54:08 -0400 Subject: [PATCH 015/106] move config switch files to scripts dir --- xCAT-server/lib/xcat/plugins/switchdiscover.pm | 2 +- xCAT-server/share/xcat/{tools => scripts}/configBNT | 0 xCAT-server/share/xcat/{tools => scripts}/configMellanox | 0 3 files changed, 1 insertion(+), 1 deletion(-) rename xCAT-server/share/xcat/{tools => scripts}/configBNT (100%) rename xCAT-server/share/xcat/{tools => scripts}/configMellanox (100%) diff --git a/xCAT-server/lib/xcat/plugins/switchdiscover.pm b/xCAT-server/lib/xcat/plugins/switchdiscover.pm index 12e552556..2d4682ecf 100644 --- a/xCAT-server/lib/xcat/plugins/switchdiscover.pm +++ b/xCAT-server/lib/xcat/plugins/switchdiscover.pm @@ -1402,7 +1402,7 @@ sub switchsetup { } foreach my $mytype (keys %$nodes_to_config) { - my $config_script = "$::XCATROOT/shart/xcat/tools/config".$mytype; + my $config_script = "$::XCATROOT/share/xcat/scripts/config".$mytype; if (-r -x $config_script) { my $switches = join(",",@{${nodes_to_config}->{$mytype}}); send_msg($request, 0, "call to config $mytype switches $switches\n"); diff --git a/xCAT-server/share/xcat/tools/configBNT b/xCAT-server/share/xcat/scripts/configBNT similarity index 100% rename from xCAT-server/share/xcat/tools/configBNT rename to xCAT-server/share/xcat/scripts/configBNT diff --git a/xCAT-server/share/xcat/tools/configMellanox b/xCAT-server/share/xcat/scripts/configMellanox similarity index 100% rename from xCAT-server/share/xcat/tools/configMellanox rename to xCAT-server/share/xcat/scripts/configMellanox From 08cb5f16600467e2f9fd7b56980c3cbd7bd04c54 Mon Sep 17 00:00:00 2001 From: hu-weihua Date: Tue, 9 Aug 2016 22:01:43 -0400 Subject: [PATCH 016/106] Probe package, add ServiceNodeUtils.pm to probe lib --- build-ubunturepo | 1 + makerpm | 1 + 2 files changed, 2 insertions(+) diff --git a/build-ubunturepo b/build-ubunturepo index 6c9e001cd..ef7bab083 100755 --- a/build-ubunturepo +++ b/build-ubunturepo @@ -236,6 +236,7 @@ then mkdir -p ${CURDIR}/xCAT-probe/lib/perl/xCAT/ cp -f ${CURDIR}/perl-xCAT/xCAT/NetworkUtils.pm ${CURDIR}/xCAT-probe/lib/perl/xCAT/ cp -f ${CURDIR}/perl-xCAT/xCAT/GlobalDef.pm ${CURDIR}/xCAT-probe/lib/perl/xCAT/ + cp -f ${CURDIR}/perl-xCAT/xCAT/ServiceNodeUtils.pm ${CURDIR}/xCAT-probe/lib/perl/xCAT/ fi dpkg-buildpackage -uc -us else diff --git a/makerpm b/makerpm index c3cd442df..983b3ecc5 100755 --- a/makerpm +++ b/makerpm @@ -50,6 +50,7 @@ function makenoarch { mkdir -p ${CURDIR}/xCAT-probe/lib/perl/xCAT/ cp -f ${CURDIR}/perl-xCAT/xCAT/NetworkUtils.pm ${CURDIR}/xCAT-probe/lib/perl/xCAT/ cp -f ${CURDIR}/perl-xCAT/xCAT/GlobalDef.pm ${CURDIR}/xCAT-probe/lib/perl/xCAT/ + cp -f ${CURDIR}/perl-xCAT/xCAT/ServiceNodeUtils.pm ${CURDIR}/xCAT-probe/lib/perl/xCAT/ fi tar --exclude .svn -czf $RPMROOT/SOURCES/$RPMNAME-$VER.tar.gz $RPMNAME From 8b5f44c44a0020fad44c7abd324da4cb19185918 Mon Sep 17 00:00:00 2001 From: ertaozh Date: Wed, 10 Aug 2016 01:01:46 -0400 Subject: [PATCH 017/106] Modify xcat-genesis-script pkg name for ubuntu --- xCAT-genesis-scripts/debian/control-amd64 | 8 ++++---- xCAT-genesis-scripts/xCAT-genesis-scripts.spec | 14 +------------- xCAT/debian/control | 2 +- xCAT/xCAT.spec | 5 ++--- xCATsn/debian/control | 2 +- xCATsn/xCATsn.spec | 5 ++--- 6 files changed, 11 insertions(+), 25 deletions(-) diff --git a/xCAT-genesis-scripts/debian/control-amd64 b/xCAT-genesis-scripts/debian/control-amd64 index 7e883f328..20b99c52e 100644 --- a/xCAT-genesis-scripts/debian/control-amd64 +++ b/xCAT-genesis-scripts/debian/control-amd64 @@ -5,11 +5,11 @@ Maintainer: xCAT Build-Depends: debhelper (>= 8.0.0) Standards-Version: 3.9.2 -Package: xcat-genesis-scripts-x86-64 +Package: xcat-genesis-scripts-amd64 Architecture: all -Depends: xcat-genesis-base-x86-64 -Conflicts: xcat-genesis-scripts,xcat-genesis-scripts-amd64 -Replaces: xcat-genesis-scripts,xcat-genesis-scripts-amd64 +Depends: xcat-genesis-base-amd64 +Conflicts: xcat-genesis-scripts,xcat-genesis-scripts-x86-64 +Replaces: xcat-genesis-scripts,xcat-genesis-scripts-x86-64 Description: xCAT genesis (Genesis Enhanced Netboot Environment for System Information and Servicing) is a small, embedded-like environment for xCAT's use in discovery and management actions when interaction with an OS is infeasible. This package reperesents the EPL content that is more tightly bound to specific xcat-core versions diff --git a/xCAT-genesis-scripts/xCAT-genesis-scripts.spec b/xCAT-genesis-scripts/xCAT-genesis-scripts.spec index 02d8292df..0f7bddcf7 100755 --- a/xCAT-genesis-scripts/xCAT-genesis-scripts.spec +++ b/xCAT-genesis-scripts/xCAT-genesis-scripts.spec @@ -99,21 +99,9 @@ touch /etc/xcat/genesis-scripts-updated %{rpminstallroot}/bin/update_flash %{rpminstallroot}/bin/update_flash_nv %{rpminstallroot}/bin/restart -%{rpminstallroot}/debian/changelog -%{rpminstallroot}/debian/compat -%{rpminstallroot}/debian/control-amd64 -%{rpminstallroot}/debian/control-ppc64el -%{rpminstallroot}/debian/copyright -#%{rpminstallroot}/debian/dirs -%{rpminstallroot}/debian/docs -#%{rpminstallroot}/debian/install -%{rpminstallroot}/debian/postinst -%{rpminstallroot}/debian/postrm -%{rpminstallroot}/debian/preinst -%{rpminstallroot}/debian/prerm -%{rpminstallroot}/debian/rules %{rpminstallroot}/etc/init.d/functions %{rpminstallroot}/etc/udev/rules.d/99-imm.rules %{rpminstallroot}/etc/udev/rules.d/98-mlx.rules %{rpminstallroot}/sbin/setupimmnic %{rpminstallroot}/sbin/loadmlxeth +%exclude %{rpminstallroot}/debian/* diff --git a/xCAT/debian/control b/xCAT/debian/control index 69dd56b0e..997910a96 100644 --- a/xCAT/debian/control +++ b/xCAT/debian/control @@ -7,6 +7,6 @@ Standards-Version: 3.7.2 Package: xcat Architecture: amd64 ppc64el -Depends: ${perl:Depends}, xcat-server, xcat-client, libdbd-sqlite3-perl, isc-dhcp-server, apache2, nfs-kernel-server, nmap, bind9, libxml-parser-perl, xinetd, tftpd-hpa, tftp-hpa, conserver-xcat, libnet-telnet-perl, ipmitool-xcat (>=1.8.15-2), syslinux[any-amd64], libsys-virt-perl, syslinux-xcat[any-amd64], xnba-undi, xcat-genesis-scripts-ppc64, xcat-genesis-scripts-x86-64, elilo-xcat, xcat-buildkit, xcat-probe (>=2.12) +Depends: ${perl:Depends}, xcat-server, xcat-client, libdbd-sqlite3-perl, isc-dhcp-server, apache2, nfs-kernel-server, nmap, bind9, libxml-parser-perl, xinetd, tftpd-hpa, tftp-hpa, conserver-xcat, libnet-telnet-perl, ipmitool-xcat (>=1.8.15-2), syslinux[any-amd64], libsys-virt-perl, syslinux-xcat[any-amd64], xnba-undi, xcat-genesis-scripts-ppc64, xcat-genesis-scripts-amd64, elilo-xcat, xcat-buildkit, xcat-probe (>=2.12) Description: Server and configuration utilities of the xCAT management project xcat-server provides the core server and configuration management components of xCAT. This package should be installed on your management server diff --git a/xCAT/xCAT.spec b/xCAT/xCAT.spec index c800f288d..8557d2c8c 100644 --- a/xCAT/xCAT.spec +++ b/xCAT/xCAT.spec @@ -25,7 +25,7 @@ Source7: xcat.conf.apach24 Provides: xCAT = %{version} Conflicts: xCATsn -Requires: xCAT-server xCAT-client perl-DBD-SQLite xCAT-probe >= 2.12.1 +Requires: xCAT-server xCAT-client perl-DBD-SQLite xCAT-probe >= 2.12.1 xCAT-genesis-scripts-x86_64 xCAT-genesis-scripts-ppc64 %define pcm %(if [ "$pcm" = "1" ];then echo 1; else echo 0; fi) %define notpcm %(if [ "$pcm" = "1" ];then echo 0; else echo 1; fi) @@ -60,13 +60,12 @@ Requires: conserver-xcat %endif %ifarch i386 i586 i686 x86 x86_64 -Requires: syslinux xCAT-genesis-scripts-x86_64 elilo-xcat +Requires: syslinux elilo-xcat Requires: ipmitool-xcat >= 1.8.15-2 Requires: xnba-undi %endif %ifos linux %ifarch ppc ppc64 ppc64le -Requires: xCAT-genesis-scripts-ppc64 Requires: ipmitool-xcat >= 1.8.15-2 %endif %endif diff --git a/xCATsn/debian/control b/xCATsn/debian/control index 8283481f1..865c48925 100644 --- a/xCATsn/debian/control +++ b/xCATsn/debian/control @@ -7,7 +7,7 @@ Standards-Version: 3.7.2 Package: xcatsn Architecture: all -Depends: ${perl:Depends}, xcat-server, perl-xcat, xcat-client, libdbd-sqlite3-perl, libxml-parser-perl, tftpd-hpa, tftp-hpa, conserver-xcat, libnet-telnet-perl, dhcp3-server, apache2, expect, nfs-kernel-server, nmap, bind9, ipmitool-xcat (>=1.8.15-2), syslinux-xcat, xnba-undi, xcat-genesis-scripts-ppc64, xcat-genesis-scripts-x86-64, elilo-xcat,libsys-virt-perl +Depends: ${perl:Depends}, xcat-server, perl-xcat, xcat-client, libdbd-sqlite3-perl, libxml-parser-perl, tftpd-hpa, tftp-hpa, conserver-xcat, libnet-telnet-perl, dhcp3-server, apache2, expect, nfs-kernel-server, nmap, bind9, ipmitool-xcat (>=1.8.15-2), syslinux-xcat, xnba-undi, xcat-genesis-scripts-ppc64, xcat-genesis-scripts-amd64, elilo-xcat,libsys-virt-perl Recommends: yaboot-xcat Description: Metapackage for a common, default xCAT service node setup xCATsn is a service node management package intended for at-scale management, including hardware management and software management. diff --git a/xCATsn/xCATsn.spec b/xCATsn/xCATsn.spec index ffcf1e5eb..fd0fca2d8 100644 --- a/xCATsn/xCATsn.spec +++ b/xCATsn/xCATsn.spec @@ -17,7 +17,7 @@ Source3: xCATSN Source5: templates.tar.gz Source6: xcat.conf.apach24 Provides: xCATsn = %{version} -Requires: xCAT-server xCAT-client perl-DBD-SQLite +Requires: xCAT-server xCAT-client perl-DBD-SQLite xCAT-genesis-scripts-x86_64 xCAT-genesis-scripts-ppc64 Conflicts: xCAT @@ -55,13 +55,12 @@ Requires: conserver-xcat %endif %ifarch i386 i586 i686 x86 x86_64 -Requires: syslinux xCAT-genesis-scripts-x86_64 elilo-xcat +Requires: syslinux elilo-xcat Requires: ipmitool-xcat >= 1.8.15-2 Requires: xnba-undi %endif %ifos linux %ifarch ppc ppc64 ppc64le -Requires: xCAT-genesis-scripts-ppc64 Requires: ipmitool-xcat >= 1.8.15-2 %endif %endif From 8c2381d9764be3a8d244353e53bb42575b140a52 Mon Sep 17 00:00:00 2001 From: junxiawang Date: Wed, 10 Aug 2016 08:01:07 -0400 Subject: [PATCH 018/106] add bundle for rhels7.3 ppc64le --- .../autotest/bundle/rhels7.3_ppc64le.bundle | 207 ++++++++++++++++++ 1 file changed, 207 insertions(+) create mode 100644 xCAT-test/autotest/bundle/rhels7.3_ppc64le.bundle diff --git a/xCAT-test/autotest/bundle/rhels7.3_ppc64le.bundle b/xCAT-test/autotest/bundle/rhels7.3_ppc64le.bundle new file mode 100644 index 000000000..cc15f6b88 --- /dev/null +++ b/xCAT-test/autotest/bundle/rhels7.3_ppc64le.bundle @@ -0,0 +1,207 @@ +Diskless_installation_flat_p8_le +Full_installation_flat_p8_le +go_xcat_local_repo_case1 +go_xcat_local_repo_case2 +go_xcat_local_repo_case3 +go_xcat_local_repo_case4 +go_xcat_local_repo_case5 +go_xcat_local_repo_case6 +go_xcat_local_repo_case7 +go_xcat_noinput +makehosts_h +makehosts_help +makehosts_n +makehosts_n_noderange +chdef_null +chdef_z +chdef_t_o_error +chtab_null +chtab_d +chtab_modify_node +chtab_modify_key +chtab_h +chtab_v +packimage_o_p_a_m +packimage_p_a_o +packimage_imagename +packimage_h +packimage_v +pping_h +pping_v +pping_node +gettab_key_table +gettab_H +gettab_err +gettab_h +lsdef_null +lsdef_a +lsdef_t_o_l +lsdef_t_o_l_z +lsdef_t +lsdef_t_i_o +lsdef_t_w +lsdef_t_err +makeconservercf_null +makeconservercf_noderange +makeconservercf_d +makedhcp_n +makedhcp_a +makedhcp_a_d +makedhcp_d +mkdef_null +mkdef_z +mkdef_t_o_error +nodeadd_noderange +nodeadd_err_symbol +nodeadd_null +nodeadd_noderange_nodetype +nodeadd_v +nodeadd_h +nodegrpch_v +nodegrpch_h +nodegrpch_groups +nodegrpch_err +nodech_noderange_table +nodech_noderange_table_comma +nodech_noderange_table_arrow +nodech_noderanage_table_at +nodech_delete +nodech_error_node +nodech_error_table +nodech_h +nodech_v +nodech_noderange_table_include +nodech_noderange_table_uninclude +nodech_noderange_table_equal +nodech_noderange_table_unequal +nodech_noderange_shortname_groups +nodech_noderange_shortname_tags +nodech_noderange_shortname_mgt +nodels_null +nodels_H +nodels_noderange +nodels_err_symbol +nodels_err_noderange +nodels_noderange_shortname_groups +nodels_noderange_shortname_tags +nodels_noderange_shortname_mgt +nodels_table_include +nodels_noderange_table_uninclude +nodels_noderange_table_equal +nodels_noderange_table_unequal +nodels_b +nodels_S +nodels_noderange_table +nodels_tablevalue +nodels_tablevalue_tablecolumn +nodels_noderange_tablecolumn +nodels_h +nodels_v +xcatstanzafile_colon +xcatstanzafile_attribute +xcatstanzafile_objtype +xcatstanzafile_tab +xcatstanzafile_multattr +xcatstanzafile_defaultvalue +xcatstanzafile_specificvalue +noderm_noderange +noderm_h +noderm_null +noderm_err_node +nodeset_stat +nodeset_noderange +nodestat_err_node +rinv_noderange_err +rmdef_null +rmdef_t_err +rpower_err_noderange +rvitals_noderange_err +tabdump_table +tabdump_d +tabdump_v +tabdump_h +tabdump_help +tabdump_w_match +tabdump_w_equal +tabdump_w_ne +tabdump_w_notmatch +tabdump_w_gt +tabdump_w_ge +tabdump_w_lt +tabdump_w_le +tabdump_f_d +tabdump_d_nodehm +tabprune_h +tabprune_v +tabprune_a_eventlog +tabprune_V_a_eventlog +tabprune_i_auditlog +tabprune_V_n_auditlog +tabgrep_node +tabgrep_null +tabgrep_h +tabgrep_err +tabrestore_table +tabrestore_null +tabrestore_h +tabrestore_err +dumpxCATdb_h +dumpxCATdb_v +dumpxCATdb_p_nullskiptables +dumpxCATdb_a_p_nullskiptables +dumpxCATdb_p_skiptables +dumpxCATdb_a_p_skiptables +dumpxCATdb_p_nullskiptables_V +dumpxCATdb_a_p_nullskiptables_V +dumpxCATdb_p_V +restorexCAT_h +restorexCATdb_v +restorexCATdb_p_V +restorexCATdb_a_p_V +restorexCATdb_wrongpath +regnotif_null +regnotif_o +regnotif_err +regnotif_h +regnotif_v +unregnotif_null +unregnotif_f +unregnotif_h +unregnotif_v +lsxcatd_null +lsxcatd_h +lsxcatd_d +lsxcatd_a +makedns_d_node +makedns_n +makedns +copycds_iso +copycds_n +copycds_a +copycds_n_a +xdsh_h +xdsh_V +xdsh_regular_command +xdsh_Q_command +xdsh_c_cn +xdsh_e_filename +xdsh_E +xdsh_i_linux +xdsh_t +xdsh_q +xdsh_T +xdsh_o +switchdiscover_range_default +switchdiscover_h +switchdiscover_range_s +switchdiscover_range_default_w +switchdiscover_range_r +switchdiscover_range_x +switchdiscover_range_z +switchdiscover_range_z_V +nodeset_shell +nodeset_cmdline +nodeset_runimg +redhat_migration1 +redhat_migration2 +clean_up_env From 989548aef15eae01106f6d149cb413f29e5b33ee Mon Sep 17 00:00:00 2001 From: XuWei Date: Tue, 26 Jul 2016 03:26:40 -0400 Subject: [PATCH 019/106] xCATprobe check xcat service node --- xCAT-probe/lib/perl/probe_utils.pm | 15 +- xCAT-probe/subcmds/xcatmn | 1372 ++++++++++++++++++---------- 2 files changed, 914 insertions(+), 473 deletions(-) diff --git a/xCAT-probe/lib/perl/probe_utils.pm b/xCAT-probe/lib/perl/probe_utils.pm index ace99bf60..8f2198fca 100644 --- a/xCAT-probe/lib/perl/probe_utils.pm +++ b/xCAT-probe/lib/perl/probe_utils.pm @@ -50,6 +50,8 @@ sub send_msg { if ($output eq "stdout") { print "$flag$msg\n"; + } elsif($output) { + syswrite $output, "$flag$msg\n"; } else { if (!open(LOGFILE, ">> $output")) { return 1; @@ -324,20 +326,21 @@ sub is_tftp_ready { sub is_dns_ready { my $mnip = shift; $mnip = shift if (($mnip) && ($mnip =~ /probe_utils/)); + my $serverip = shift; my $hostname = shift; my $domain = shift; - my $output = `nslookup $mnip $mnip 2>&1`; + my $output = `nslookup $mnip $serverip 2>&1`; if ($?) { return 0; } else { chomp($output); - my $tmp = `echo "$output" |grep "Server:[\t\s]*$mnip" >/dev/null 2>&1`; - print "$tmp"; - return 0 if ($?); - $tmp = `echo "$output"|grep "name ="|grep "$hostname\.$domain" >/dev/null 2>&1`; - return 0 if ($?); + my $tmp = grep {$_ =~ "Server:[\t\s]*$serverip"} split(/\n/, $output); + return 0 if ($tmp == 0); + + $tmp = grep {$_ =~ "name = $hostname\.$domain"} split(/\n/, $output); + return 0 if ($tmp == 0); return 1; } } diff --git a/xCAT-probe/subcmds/xcatmn b/xCAT-probe/subcmds/xcatmn index ed88011f8..e564197f4 100755 --- a/xCAT-probe/subcmds/xcatmn +++ b/xCAT-probe/subcmds/xcatmn @@ -1,56 +1,801 @@ -#! /usr/bin/perl +#!/usr/bin/perl # IBM(c) 2016 EPL license http://www.eclipse.org/legal/epl-v10.html BEGIN { $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : -d '/opt/xcat' ? '/opt/xcat' : '/usr'; } use lib "$::XCATROOT/probe/lib/perl"; use probe_utils; +use xCAT::ServiceNodeUtils; +use xCAT::NetworkUtils; use File::Basename; use Getopt::Long qw(:config no_ignore_case); +use IO::Select; +use Data::Dumper; -my $proname = basename("$0"); -my $help; +my $program_name = basename("$0"); #current sub_command name +my $help = 0; #command line attribute '-h', get usage information +my $test = 0; #command line attribute '-T' +my $verbose = 0; #command line attribute '-V' +my $noderange; #command line attribute '-n' my $installnic; -my $test; -my $output = "stdout"; -my $verbose = 0; -my $rst = 0; +my $output = "stdout"; #used by probe_utils->send_msg("$output", "o", "xxxxxxxxxx"); print output to STDOUT +my $is_sn = 0; #flag current server is SN +my $rst = 0; #the exit code of current command +my $terminal = 0; #means get INT signal from STDIN +my %summaryoutput; #save all output from commands running on SNs and MN +#a map of SNs and command which will be dispatched to current SN +# $dispatchcmd{snname} = "command" +my %dispatchcmd; + +#save command line attributes from STDIN +my @tmpargv; + +#-------------------------------- +# below are some options rules used by default +# -h : Get usage information of current sub command +# -V : Output more information for debug +# -T : To verify if $program_name can work, reserve option for probe framework, dosen't use by customer +# -n : In xCAT probe, -n is uesd to specify node range uniformly +#-------------------------------- $::USAGE = "Usage: - $proname -h - $proname -T - $proname [-n ] [-V] + $program_name -h + $program_name [-i ] [-V] Description: - After xcat installation, use this command to check if xcat has been installed correctly and is ready for use. + After xcat installation, use this command to check if xcat has been installed correctly and is ready for use. + For hierarchical cluster, just support that the provision network is in the same network with management node. If in the different nework, please ignore the results. Options: - -h : Get usage information of $proname - -T : To verify if $proname can work, reserve option for probe framework - -n : Required. Specify the network interface name of provision network + -h : Get usage information of $program_name -V : Output more information for debug + -i : Required. Specify the network interface name of provision network "; + sub returncmdoutput { my $rst = shift; chomp($rst); + my $outputtarget = shift; my @lines = split("[\n\r]", $rst); foreach my $line (@lines) { - probe_utils->send_msg("$output", "d", "$line"); + probe_utils->send_msg("$outputtarget", "d", "$line"); } } +#------------------------------------- +# TWO FUNCTIONS MUST BE IMPLEMENTED BY EACH SUB COMMAND +# They are do_main_job and summary_all_jobs_output +#------------------------------------- + +#------------------------------------ +# Please implement the main checking job of current command in do_main_job function +# If $outputtarget has input value, that means do_main_job is running on MN, so every message needed to print on STDOUT should be written into pipe $outputtarget. +# If $outputtarget has no value, that means do_main_job is running on SN, all message just need to print on STDOUT +# Recommand to use probe_utils->send_msg() to handle message you plan to print out +#------------------------------------ +sub do_main_job { + my $outputtarget = shift; + $outputtarget = "stdout" if (!$outputtarget); + my $rst = 0; + + my $msg; + my $serverip; + + $msg = "Sub process 'xcatd: SSL listener' is running"; + my $xcatdproc = `ps aux|grep -v grep|grep xcatd`; + chomp($xcatdproc); + if ($xcatdproc =~ /xcatd: SSL listener/) { + probe_utils->send_msg($outputtarget, "o", "$msg"); + } else { + probe_utils->send_msg($outputtarget, "f", "$msg"); + $rst = 1; + } + + $msg = "Sub process 'xcatd: DB Access' is running"; + if ($xcatdproc =~ /xcatd: DB Access/) { + probe_utils->send_msg($outputtarget, "o", "$msg"); + } else { + probe_utils->send_msg($outputtarget, "f", "$msg"); + $rst = 1; + } + + $msg = "Sub process 'xcatd: UDP listener' is running"; + if ($xcatdproc =~ /xcatd: UDP listener/) { + probe_utils->send_msg($outputtarget, "o", "$msg"); + } else { + probe_utils->send_msg($outputtarget, "f", "$msg"); + $rst = 1; + } + + $msg = "Sub process 'xcatd: install monitor' is running"; + if ($xcatdproc =~ /xcatd: install monitor/) { + probe_utils->send_msg($outputtarget, "o", "$msg"); + } else { + probe_utils->send_msg($outputtarget, "f", "$msg"); + $rst = 1; + } + + $msg = "Sub process 'xcatd: Discovery worker' is running"; + if ($xcatdproc =~ /xcatd: Discovery worker/) { + probe_utils->send_msg($outputtarget, "o", "$msg"); + } else { + probe_utils->send_msg($outputtarget, "f", "$msg"); + $rst = 1; + } + + $msg = "Sub process 'xcatd: Command log writer' is running"; + if ($xcatdproc =~ /xcatd: Command log writer/) { + probe_utils->send_msg($outputtarget, "o", "$msg"); + } else { + probe_utils->send_msg($outputtarget, "w", "Sub process 'xcatd: Command log writer' isn't running"); + } + return 1 if ($rst); + + my $xcatdport = `lsdef -t site -i xcatdport -c | awk -F'=' '{print \$2}'`; + chomp($xcatdport); + probe_utils->send_msg($outputtarget, "d", "The port used by the xcatd daemon for client/server communication is $xcatdport") if ($verbose); + $msg = "xcatd is listening on port $xcatdport"; + my $cmdoutput = `netstat -ant|grep LISTEN|grep $xcatdport`; + if ($?) { + probe_utils->send_msg($outputtarget, "f", "$msg"); + $rst = 1; + } else { + probe_utils->send_msg($outputtarget, "o", "$msg"); + } + + my $xcatiport = `lsdef -t site -i xcatiport -c | awk -F'=' '{print \$2}'`; + chomp($xcatiport); + probe_utils->send_msg($outputtarget, "d", "The port used by xcatd to receive install status updates from nodes is $xcatiport") if ($verbose); + $msg = "xcatd is listening on port $xcatiport"; + $cmdoutput = `netstat -antp | grep -i xcatd|grep LISTEN|grep $xcatiport`; + if ($?) { + probe_utils->send_msg($outputtarget, "f", "$msg"); + $rst = 1; + } else { + probe_utils->send_msg($outputtarget, "o", "$msg"); + } + return 1 if ($rst); + + $msg = "'lsxcatd -a' works"; + $cmdoutput = `lsxcatd -a 2>&1`; + $rst = $?; + returncmdoutput($cmdoutput, $outputtarget) if ($verbose); + if ($rst) { + probe_utils->send_msg($outputtarget, "f", "$msg"); + return $rst; + } else { + probe_utils->send_msg($outputtarget, "o", "$msg"); + } + + my $masteripinsite = `lsdef -t site -i master -c | awk -F'=' '{print \$2}'`; + chomp($masteripinsite); + probe_utils->send_msg($outputtarget, "d", "The value of 'master' in 'site' table is $masteripinsite") if ($verbose); + probe_utils->send_msg($outputtarget, "f", "There isn't 'master' definition in 'site' talbe") if ($masteripinsite eq ""); + + $msg = "The value of 'master' in 'site' table is a IP address"; + if (probe_utils->is_ip_addr("$masteripinsite")) { + probe_utils->send_msg($outputtarget, "o", "$msg"); + } else { + probe_utils->send_msg($outputtarget, "f", "$msg"); + return 1; + } + + if (!$is_sn) { + + # on MN, check the validity of installnic and get ip address of the NIC + $msg = "NIC $installnic exists on current server"; + my $nics = `ip addr show $installnic >/dev/null 2>&1`; + if ($?) { + probe_utils->send_msg($outputtarget, "f", "$msg"); + probe_utils->send_msg($outputtarget, "d", "Please use 'ip addr show' to check if there is NIC named $installnic on current server"); + return 1; + } else { + probe_utils->send_msg($outputtarget, "o", "$msg"); + } + + $msg = "Get ip address of NIC $installnic"; + $serverip = `ip addr show $installnic | awk -F" " '/inet / {print \$2}'|awk -F"/" '{print \$1}'`; + chomp($serverip); + if (!defined($serverip) || ($serverip eq "")) { + probe_utils->send_msg($outputtarget, "f", "$msg"); + probe_utils->send_msg($outputtarget, "d", "Please use 'ip addr show' to check if there is ip assigned to $installnic"); + return 1; + } else { + probe_utils->send_msg($outputtarget, "d", "The IP of NIC $installnic is $serverip") if ($verbose); + probe_utils->send_msg($outputtarget, "o", "$msg"); + } + + if ($serverip) { + $msg = "The IP $serverip of $installnic equals the value of 'master' in 'site' table"; + if ($serverip eq $masteripinsite) { + probe_utils->send_msg($outputtarget, "o", "$msg"); + } else { + probe_utils->send_msg($outputtarget, "f", "$msg"); + $rst = 1; + } + } + + $msg = "IP $serverip of NIC $installnic is a static IP on current server"; + if (probe_utils->is_static_ip("$serverip", "$installnic")) { + probe_utils->send_msg($outputtarget, "o", "$msg"); + } else { + probe_utils->send_msg($outputtarget, "w", "IP $serverip of $installnic is not a static ip on current server"); + } + } else { + + # on SN, get ip address by compare 'master' attribute in 'site' table + # choose the one in the same network with 'master' + my @ipoutput = `ip addr show | grep inet | grep -v inet6 2>&1`; + + foreach (@ipoutput) { + if ($_ =~ /inet\s+(.+)\/(.+)\s+brd\s+(.+)\s+scope global/i) { + if (xCAT::NetworkUtils::isInSameSubnet($masteripinsite, $1, $2, 1)) { + $serverip = $1; + } + } + } + + $msg = "Get ip address that in the same network with master $masteripinsite"; + if (!defined($serverip) || ($serverip eq "")) { + probe_utils->send_msg($outputtarget, "f", "$msg"); + return 1; + } else { + probe_utils->send_msg($outputtarget, "d", "The IP is $serverip") if ($verbose); + probe_utils->send_msg($outputtarget, "o", "$msg"); + } + } + + $msg = "$serverip belongs to one of networks defined in 'networks' table"; + my $networks = `tabdump networks|grep -v "^#"`; + $networks =~ s/\"//g; + my $netcnt = `echo "$networks"|wc -l`; + my $hit = 0; + for (my $i = 1 ; $i < $netcnt + 1 ; $i++) { + my $line = `echo "$networks" |sed -n ${i}p |awk -F"," '{print \$2,\$3,\$4}'`; + chomp($line); + if ($line =~ /(.+) (.+) (.+)/) { + if (!$is_sn) { + $hit = 1 if (probe_utils->is_ip_belong_to_net("$1", "$2", $serverip) && ("$3" eq "$installnic")); + } else { + $hit = 1 if (probe_utils->is_ip_belong_to_net("$1", "$2", $serverip)); + } + } + } + if ($hit) { + probe_utils->send_msg($outputtarget, "o", "$msg"); + } else { + probe_utils->send_msg($outputtarget, "f", "$msg"); + $rst = 1; + } + + $msg = "There is domain definition in 'site' table"; + my $domain = `lsdef -t site -i domain -c | awk -F'=' '{print \$2}'`; + chomp($domain); + if ($domain) { + probe_utils->send_msg($outputtarget, "d", "The value of 'domain' in 'site' table is $domain") if ($verbose); + probe_utils->send_msg($outputtarget, "o", "$msg"); + } else { + probe_utils->send_msg($outputtarget, "f", "$msg"); + $rst = 1; + } + + $msg = "There is configuration in 'passwd' table for 'system' for node provision"; + my $passwd = `tabdump passwd |awk -F',' '/system/ { gsub(/"/, "", \$2); gsub(/"/, "", \$3); print \$2,\$3 }'`; + chomp($passwd); + my ($username, $pw) = split(" ", $passwd); + if ($username eq "" || $pw eq "") { + probe_utils->send_msg($outputtarget, "f", "$msg"); + probe_utils->send_msg($outputtarget, "d", "Please define username and password for 'system' in 'passwd' table"); + $rst = 1; + } else { + probe_utils->send_msg($outputtarget, "o", "$msg"); + } + + my $installdir = `lsdef -t site -i installdir -c | awk -F'=' '{print \$2}'`; + chomp($installdir); + probe_utils->send_msg($outputtarget, "d", "The 'install' directory is set to $installdir in 'site' table on current server") if ($verbose); + my $tftpdir = `lsdef -t site -i tftpdir -c | awk -F'=' '{print \$2}'`; + chomp($tftpdir); + probe_utils->send_msg($outputtarget, "d", "The 'tftp' directory is set to $tftpdir in 'site' talbe on current server") if ($verbose); + + $msg = "There is $installdir directory on current server"; + if (-e "$installdir/postscripts/") { + probe_utils->send_msg($outputtarget, "o", "$msg"); + } else { + probe_utils->send_msg($outputtarget, "f", "$msg"); + $rst = 1; + } + + if ($is_sn) { + my $mountoutput = `mount | grep '$masteripinsite' | grep '$installdir'`; + chomp($mountoutput); + + $msg = "installdir $installdir is mounted on from the Management Node"; + if ($mountoutput =~ /$masteripinsite:$installdir on $installdir/) { + probe_utils->send_msg($outputtarget, "o", "$msg"); + } + else { + probe_utils->send_msg($outputtarget, "f", "$msg"); + $rst = 1; + } + } + + $msg = "There is $tftpdir directory on current server"; + if (-e "$tftpdir") { + probe_utils->send_msg($outputtarget, "o", "$msg"); + } else { + probe_utils->send_msg($outputtarget, "f", "$msg"); + $rst = 1; + } + + if ($is_sn) { + my $mountoutput = `mount | grep '$masteripinsite' | grep '$tftpdir'`; + chomp($mountoutput); + + $msg = "tftpdir $tftpdir is mounted on from the Management Node"; + if ($mountoutput =~ /$masteripinsite:$tftpdir on $tftpdir/) { + probe_utils->send_msg($outputtarget, "o", "$msg"); + } + else { + probe_utils->send_msg($outputtarget, "f", "$msg"); + $rst = 1; + } + } + + my $expected = 10; + $msg = "The free space of / directory is more than $expected G"; + my $diskspace = `df -h|awk '{print \$4,\$6}'|grep -E "/\$"`; + if ($?) { + probe_utils->send_msg($outputtarget, "d", "There isn't any filesystem mount on / directory"); + probe_utils->send_msg($outputtarget, "f", "$msg"); + $rst = 1; + } else { + chomp($diskspace); + my ($size, $dir) = split(" ", $diskspace); + $size =~ s/G//g; + probe_utils->send_msg($outputtarget, "d", "The free space of / is $size G") if ($verbose); + if ($size < $expected) { + probe_utils->send_msg($outputtarget, "w", "The free space of / is less than $expected G"); + } else { + probe_utils->send_msg($outputtarget, "o", "$msg"); + } + } + + $expected = 1; + $msg = "The free space of /var directory is more than $expected G"; + $diskspace = `df -h|awk '{print \$4,\$6}'|grep -E "/var\$"`; + if (!$?) { + chomp($diskspace); + my ($size, $dir) = split(" ", $diskspace); + $size =~ s/G//g; + probe_utils->send_msg($outputtarget, "d", "The free space of /var is $size G") if ($verbose); + if ($size < $expected) { + probe_utils->send_msg($outputtarget, "w", "The free space of /var is less than $expected G"); + } else { + probe_utils->send_msg($outputtarget, "o", "$msg"); + } + } + + $expected = 1; + $msg = "The free space of /tmp directory is more than $expected G"; + $diskspace = `df -h|awk '{print \$4,\$6}'|grep -E "/tmp\$"`; + if (!$?) { + chomp($diskspace); + my ($size, $dir) = split(" ", $diskspace); + $size =~ s/G//g; + probe_utils->send_msg($outputtarget, "d", "The free space of /tmp is $size G") if ($verbose); + if ($size < $expected) { + probe_utils->send_msg($outputtarget, "w", "The free space of /tmp is less than $expected G"); + } else { + probe_utils->send_msg($outputtarget, "o", "$msg"); + } + } + + $expected = 10; + $msg = "The free space of $installdir directory is more than $expected G"; + $diskspace = `df -h|awk '{print \$4,\$6}'|grep -E "$installdir\$"`; + if (!$?) { + chomp($diskspace); + my ($size, $dir) = split(" ", $diskspace); + $size =~ s/G//g; + probe_utils->send_msg($outputtarget, "d", "The free space of /install is $size G") if ($verbose); + if ($size < $expected) { + probe_utils->send_msg($outputtarget, "w", "The free space of /install is less than $expected G"); + } else { + probe_utils->send_msg($outputtarget, "o", "$msg"); + } + } + + $msg = "SELinux is disabled on current server"; + if (probe_utils->is_selinux_enable()) { + probe_utils->send_msg($outputtarget, "f", "$msg"); + $rst = 1; + } else { + probe_utils->send_msg($outputtarget, "o", "$msg"); + } + + $msg = "Firewall is closed on current server"; + if (probe_utils->is_firewall_open()) { + probe_utils->send_msg($outputtarget, "w", "Firewall is configured on current server"); + } else { + probe_utils->send_msg($outputtarget, "o", "$msg"); + } + + `which wget > /dev/null 2>&1`; + if ($?) { + probe_utils->send_msg($outputtarget, "w", "wget tool isn't installed on current server, skip checking HTTP service."); + probe_utils->send_msg($outputtarget, "d", "Please do probe again after installing wget"); + } else { + $msg = "HTTP service is ready on $serverip"; + if (probe_utils->is_http_ready("$serverip")) { + probe_utils->send_msg($outputtarget, "o", "$msg"); + } else { + probe_utils->send_msg($outputtarget, "f", "$msg"); + $rst = 1; + } + } + + my $nodename = `hostname -s`; + chomp($nodename); + + # For sn, 'setuptftp' attribute could be set to '0' or '1'. + # if '0', sn does not need to provie TFTP service, will not check it + my $checktftp = 1; + if ($is_sn) { + $checktftp = `lsdef $nodename -i setuptftp -c | awk -F'=' '{print \$2}'`; + chomp($checktftp); + unless ($checktftp) { + probe_utils->send_msg($outputtarget, "d", "SN $nodename is not set to provide TFTP service"); + } + } + if ($checktftp) { + `which tftp > /dev/null 2>&1`; + if ($?) { + probe_utils->send_msg($outputtarget, "w", "tftp tool isn't installed on current server, skip checking tftp service."); + probe_utils->send_msg($outputtarget, "d", "Please do probe again after installing tftp"); + } else { + $msg = "TFTP service is ready on $serverip"; + if (probe_utils->is_tftp_ready("$serverip")) { + probe_utils->send_msg($outputtarget, "o", "$msg"); + } else { + probe_utils->send_msg($outputtarget, "f", "$msg"); + $rst = 1; + } + } + } + + # For sn, 'setupdns' attribute could be set to '0' or '1'. + # if '0', sn does not need to provie DNS service, will not check it + my $checkdns = 1; + if ($is_sn) { + $checkdns = `lsdef $nodename -i setupnameserver -c | awk -F'=' '{print \$2}'`; + chomp($checkdns); + unless ($checkdns) { + probe_utils->send_msg($outputtarget, "d", "SN $nodename is not set to provide DNS service"); + } + } + + if ($checkdns) { + `which nslookup > /dev/null 2>&1`; + if ($?) { + probe_utils->send_msg($outputtarget, "w", "nslookup tool isn't installed in current server, skip checking DNS service."); + probe_utils->send_msg($outputtarget, "d", "Please do probe again after installing nslookup"); + } else { + $msg = "DNS server is ready on $serverip"; + probe_utils->send_msg($outputtarget, "d", "Domain used to check DNS is $domain") if ($verbose); + + my $rc = 0; + + if (!$is_sn) { + + # if this is a hierarchical cluster, nslookup one of sn to check DNS service + my @snlist = xCAT::ServiceNodeUtils->getAllSN(); + my $sntmp = shift(@snlist); + if ($sntmp) { + my $sninfo = `cat /etc/hosts | grep $sntmp`; + if ($sninfo =~ /(\d+).(\d+).(\d+).(\d+)/) { + my $snip = "$1.$2.$3.$4"; + if (!probe_utils->is_dns_ready("$snip", "$serverip", "$sntmp", "$domain")) { + probe_utils->send_msg("$outputtarget", "d", "nslookup $sntmp $snip failed"); + $rc = 1; + } + } + } else { + + # if there is no sn, simulate a host to check DNS service + `cp /etc/hosts /etc/hosts.bak.probe > /dev/null 2>&1`; + + { #very important brace to create a block + open HOSTFILE, ">> /etc/hosts"; + print HOSTFILE "$serverip xcatmntest xcatmntest.$domain"; + close HOSTFILE; + + probe_utils->send_msg($outputtarget, "d", "To do 'makedns -n xcatmntest'") if ($verbose); + $tmp = `makedns -V -n 2>&1`; + if ($?) { + returncmdoutput($tmp, $outputtarget) if ($verbose); + probe_utils->send_msg($outputtarget, "d", "makedns -n xcatmntest failed") if ($verbose); + $rc = 1; + last; + } + + if (!probe_utils->is_dns_ready("$serverip", "$serverip", "xcatmntest", "$domain")) { + probe_utils->send_msg($outputtarget, "d", "nslookup xcatmntest $serverip failed"); + $rc = 1; + last; + } + } + `rm /etc/hosts > /dev/null 2>&1`; + `mv /etc/hosts.bak.probe /etc/hosts > /dev/null 2>&1`; + `makedns -n 2>&1`; + } + if ($rc) { + probe_utils->send_msg($outputtarget, "f", "$msg"); + $rst = 1; + } else { + probe_utils->send_msg($outputtarget, "o", "$msg"); + } + } else { + + # on sn, nslookup it's ip to check DNS service + if (!probe_utils->is_dns_ready("$serverip", "$masteripinsite", "$nodename", "$domain")) { + probe_utils->send_msg($outputtarget, "d", "nslookup $serverip failed"); + probe_utils->send_msg($outputtarget, "f", "$msg"); + } + else { + probe_utils->send_msg($outputtarget, "o", "$msg"); + } + } + } + } + + # For sn, 'setupdhcp' attribute could be set to '0' or '1'. + # if '0', sn does not need to provie DHCP service, will not check it + my $checkdhcp = 1; + my $rc = 0; + if ($is_sn) { + $checkdhcp = `lsdef $nodename -i setupdhcp -c | awk -F'=' '{print \$2}'`; + chomp($checkdhcp); + if ($checkdhcp) { + + # on sn, just check dhcpd service whether running + $msg = "DHCP service is ready on $serverip"; + my $dhcpoutput = `ps aux | grep dhcpd |grep -v grep`; + if ($dhcpoutput) { + probe_utils->send_msg($outputtarget, "o", "$msg"); + } else { + probe_utils->send_msg($outputtarget, "f", "$msg"); + } + } else { + probe_utils->send_msg($outputtarget, "d", "SN $nodename is not set to provide DHCP service"); + } + } else { + my $leasefile = ""; + if (-e "/var/lib/dhcpd/dhcpd.leases") { + $leasefile = "/var/lib/dhcpd/dhcpd.leases"; + } elsif (-e "/var/lib/dhcp/db/dhcpd.leases") { + $leasefile = "/var/lib/dhcp/db/dhcpd.leases"; + } elsif (-e "/var/lib/dhcp/dhcpd.leases") { + $leasefile = "/var/lib/dhcp/dhcpd.leases"; + } + + $msg = "The size of $leasefile is less than 100M"; + my $filesizetmp = `du -sb $leasefile`; + if ($?) { + returncmdoutput($filesizetmp) if ($verbose); + probe_utils->send_msg($outputtarget, "f", "$msg"); + $rst = 1; + } else { + chomp($filesizetmp); + my ($size, $file) = split(" ", $filesizetmp); + probe_utils->send_msg($outputtarget, "d", "The size of $leasefile is $size byte") if ($verbose); + if ($size > 104857600) { + probe_utils->send_msg($outputtarget, "w", "The size of $leasefile is more than 100M"); + } else { + probe_utils->send_msg($outputtarget, "o", "$msg"); + } + } + + my $rc = 0; + my $msg = "DHCP service is ready on $serverip"; + { #very important brace to create a block + my $tmp = `chdef xcatmntest groups=all ip=$serverip mac=aa:aa:aa:aa:aa:aa`; + if ($?) { + returncmdoutput($tmp, $outputtarget) if ($verbose); + probe_utils->send_msg($outputtarget, "d", "Simulate a node by chdef failed") if ($verbose); + $rc = 1; + last; + } else { + probe_utils->send_msg($outputtarget, "d", "Simulate a node xcatmntest to do dhcp test") if ($verbose); + } + + `cp /etc/hosts /etc/hosts.bak.probe > /dev/null 2>&1`; + + open HOSTFILE, ">> /etc/hosts"; + print HOSTFILE "$serverip xcatmntest xcatmntest.$domain"; + close HOSTFILE; + + probe_utils->send_msg($outputtarget, "d", "To do 'makedhcp xcatmntest'") if ($verbose); + $tmp = `makedhcp xcatmntest 2>&1`; + if ($?) { + returncmdoutput($tmp, $outputtarget) if ($verbose); + probe_utils->send_msg($outputtarget, "d", "makedhcp xcatmntest failed") if ($verbose); + $rc = 1; + `rmdef xcatmntest`; + last; + } + + probe_utils->send_msg($outputtarget, "d", "To do 'makedhcp -q xcatmntest'") if ($verbose); + $tmp = `makedhcp -q xcatmntest`; + if ($?) { + returncmdoutput($tmp, $outputtarget) if ($verbose); + probe_utils->send_msg($outputtarget, "d", "makedhcp -q xcatmntest failed") if ($verbose); + $rc = 1; + `makedhcp -d xcatmntest && rmdef xcatmntest`; + last; + } + chomp($tmp); + if ($tmp !~ /xcatmntest: ip-address = $serverip, hardware-address = aa:aa:aa:aa:aa:aa/) { + returncmdoutput($tmp, $outputtarget) if ($verbose); + probe_utils->send_msg($outputtarget, "d", "DHCP server's reply is wrong") if ($verbose); + $rc = 1; + `makedhcp -d xcatmntest && rmdef xcatmntest`; + last; + } + + probe_utils->send_msg($outputtarget, "d", "Start to clear simulate information for dhcp test") if ($verbose); + $tmp = `makedhcp -d xcatmntest && rmdef xcatmntest`; + returncmdoutput($tmp, $outputtarget) if ($verbose); + } + + `rm /etc/hosts`; + `mv /etc/hosts.bak.probe /etc/hosts`; + + if ($rc) { + probe_utils->send_msg($outputtarget, "f", "$msg"); + probe_utils->send_msg($outputtarget, "d", "please run 'makedhcp -n' if never run it before."); + $rst = 1; + } else { + probe_utils->send_msg($outputtarget, "o", "$msg"); + } + } + + + return $rst; +} #------------------------------------- -# main process +# When this command return from all SNs and MN, you need to generate a summary +# All history outpout from SNs and MN are saved in globle hash %summaryoutput. +# $ummaryoutput{mn} = @mnhistory +# $ummaryoutput{snname1} = @snname1history; +# The entry in each histroy array isn't categorized, the message coming early is arranged before the one coming later. #------------------------------------- +sub summary_all_jobs_output { + + print "\n======================do ERROR summary=====================\n"; + my $isprint = 1; + + foreach my $line (@{ $summaryoutput{mn} }) { + if ($line =~ /\[failed\]/) { + if ($isprint) { + print "[mn]:\n"; + $isprint = 0; + } + print "\t$line\n"; + } + } + + $isprint = 1; + foreach my $node (keys %summaryoutput) { + next if ($node eq "mn"); + foreach my $log (@{ $summaryoutput{$node} }) { + if ($log =~ /\[failed\]/) { + if ($isprint) { + print "[$node]:\n"; + $isprint = 0; + } + print "\t$log\n"; + } elsif ($log !~ /^(\[\w+\]\s*):\s*(.*)/) { + if ($isprint) { + print "[$node]:\n"; + $isprint = 0; + } + print "\t$log\n"; + } + } + } +} + +#------------------------------------- +# Each probe sub command is supposed to support hierarchical. +# This funtion is used to caclulate which SN should be dispatched which command +#------------------------------------- +sub caclulate_dispatch_cmd { + my @snlist = xCAT::ServiceNodeUtils->getAllSN(); + if ($noderange) { + my @nodes = `nodels $noderange 2>&1`; + if ($?) { + my $error = join(" ", @nodes); + if ($error =~ /Error: Invalid nodes and\/or groups in noderange: (.+)/) { + probe_utils->send_msg("$output", "f", "There are invaild nodes ($1) in command line attribute node range"); + } else { + probe_utils->send_msg("$output", "f", "There is error in command line attribute node range, please using nodels to check"); + } + return 1; + } else { + chomp foreach (@nodes); + my $snnodemap = xCAT::ServiceNodeUtils->get_ServiceNode(\@nodes, "xcat", "MN"); + my %newsnnodemap; + foreach my $sn (keys %$snnodemap) { + if (grep(/^$sn$/, @snlist)) { + push(@{ $newsnnodemap{$sn} }, @{ $snnodemap->{$sn} }); + } else { + push(@{ $newsnnodemap{mn} }, @{ $snnodemap->{$sn} }); + } + } + + foreach my $sn (keys %newsnnodemap) { + my $nodes = join(",", @{ $newsnnodemap{$sn} }); + if ($sn eq "mn") { + $noderange = $nodes; + } else { + for (my $i = 0 ; $i <= $#tmpargv ; $i++) { + if ($tmpargv[$i] eq "-n") { + $tmpargv[ $i + 1 ] = $nodes; + last; + } + } + my $args = join(" ", @tmpargv); + $dispatchcmd{$sn} = "$::XCATROOT/probe/subcmds/$program_name $args 2>&1"; + } + } + } + } else { + if (@snlist) { + my $args = join(" ", @tmpargv); + if ($args =~ /\-V/) { + $args = "-V"; + } else { + $args = " "; + } + my $sns = join(",", @snlist); + $dispatchcmd{$sns} = "$::XCATROOT/probe/subcmds/$program_name $args 2>&1" if (!$?); + } + } + return 0; +} + +#------------------------------------ +# print sn's msg after all msg received +#------------------------------------ +sub send_sn_msg { + foreach $node (keys %summaryoutput) { + next if ($node eq "mn"); + foreach my $line (@{ $summaryoutput{$node} }) { + if ($line =~ /^(\[\w+\]\s*):\s*(.*)/) { + $line = "$1:$node: $2"; + print "$line\n"; + } else { + print "[failed] :$node: $line\n"; + } + } + } +} + +#------------------------------------- +# main process start +#------------------------------------- +@tmpargv = @ARGV; if ( !GetOptions("--help|h" => \$help, "T" => \$test, + "n=s" => \$noderange, "V" => \$verbose, - "n=s" => \$installnic)) + "i=s" => \$installnic)) { - probe_utils->send_msg("$output", "f", "Invalid parameter for $proname"); + probe_utils->send_msg("$output", "f", "Invalid parameter for $program_name"); probe_utils->send_msg("$output", "d", "$::USAGE"); exit 1; } @@ -69,481 +814,174 @@ if ($test) { exit 0; } +$SIG{TERM} = $SIG{INT} = sub { + $terminal = 1; +}; + +#-------------------------------------------- +# To confirm what current node is, MN or SN +#-------------------------------------------- +$is_sn = 1 if (-e "/etc/xCATSN"); + +if ($is_sn) { + $rst = do_main_job(); + exit $rst; +} + if (!defined($installnic)) { - probe_utils->send_msg("$output", "f", "Option -n is required"); + probe_utils->send_msg("$output", "f", "Option -i is required"); probe_utils->send_msg("$output", "d", "$::USAGE"); exit 1; } -my $msg = "NIC $installnic exists on current server"; -my $nics = `ip addr show $installnic >/dev/null 2>&1`; -if ($?) { - probe_utils->send_msg("$output", "f", "$msg"); - probe_utils->send_msg("$output", "d", "Please use 'ip addr show' to check if there is NIC named $installnic on current server"); - exit 1; -} else { - probe_utils->send_msg("$output", "o", "$msg"); -} +#-------------------------------------------- +# Each probe tool is supposed to support hierarchical. +#-------------------------------------------- +$rst = caclulate_dispatch_cmd(); -$msg = "Get ip address of NIC $installnic"; -my $mnip = `ip addr show $installnic | awk -F" " '/inet / {print \$2}'|awk -F"/" '{print \$1}'`; -chomp($mnip); -if (!defined($mnip) || ($mnip eq "")) { - probe_utils->send_msg("$output", "f", "$msg"); - probe_utils->send_msg("$output", "d", "Please use 'ip addr show' to check if there is ip assigned to $installnic"); - exit 1; -} else { - probe_utils->send_msg("$output", "d", "The IP of NIC $installnic is $mnip") if ($verbose); - probe_utils->send_msg("$output", "o", "$msg"); -} +#print Dumper \%dispatchcmd; +#print "node left to mn : $noderange\n"; +exit $rst if ($rst); -$msg = "Sub process 'xcatd: SSL listener' is running"; -my $xcatdproc = `ps aux|grep -v grep|grep xcatd`; -chomp($xcatdproc); -if ($xcatdproc =~ /xcatd: SSL listener/) { - probe_utils->send_msg("$output", "o", "$msg"); -} else { - probe_utils->send_msg("$output", "f", "$msg"); - $rst = 1; -} - -$msg = "Sub process 'xcatd: DB Access' is running"; -if ($xcatdproc =~ /xcatd: DB Access/) { - probe_utils->send_msg("$output", "o", "$msg"); -} else { - probe_utils->send_msg("$output", "f", "$msg"); - $rst = 1; -} - -$msg = "Sub process 'xcatd: UDP listener' is running"; -if ($xcatdproc =~ /xcatd: UDP listener/) { - probe_utils->send_msg("$output", "o", "$msg"); -} else { - probe_utils->send_msg("$output", "f", "$msg"); - $rst = 1; -} - -$msg = "Sub process 'xcatd: install monitor' is running"; -if ($xcatdproc =~ /xcatd: install monitor/) { - probe_utils->send_msg("$output", "o", "$msg"); -} else { - probe_utils->send_msg("$output", "f", "$msg"); - $rst = 1; -} - -$msg = "Sub process 'xcatd: Discovery worker' is running"; -if ($xcatdproc =~ /xcatd: Discovery worker/) { - probe_utils->send_msg("$output", "o", "$msg"); -} else { - probe_utils->send_msg("$output", "f", "$msg"); - $rst = 1; -} - -$msg = "Sub process 'xcatd: Command log writer' is running"; -if ($xcatdproc =~ /xcatd: Command log writer/) { - probe_utils->send_msg("$output", "o", "$msg"); -} else { - probe_utils->send_msg("$output", "w", "Sub process 'xcatd: Command log writer' isn't running"); -} -exit 1 if ($rst); - - -my $xcatdport = `tabdump site 2>&1 | awk -F',' '/^"xcatdport",/ { gsub(/"/, "", \$2) ; print \$2 }'`; -chomp($xcatdport); -probe_utils->send_msg("$output", "d", "The port used by the xcatd daemon for client/server communication is $xcatdport") if ($verbose); -$msg = "xcatd is listening on port $xcatdport"; -my $cmdoutput = `netstat -ant|grep LISTEN|grep $xcatdport`; -if ($?) { - probe_utils->send_msg("$output", "f", "$msg"); - $rst = 1; -} else { - probe_utils->send_msg("$output", "o", "$msg"); -} - -my $xcatiport = `tabdump site 2>&1| awk -F',' '/^"xcatiport",/ { gsub(/"/, "", \$2) ; print \$2 }'`; -chomp($xcatiport); -probe_utils->send_msg("$output", "d", "The port used by xcatd to receive install status updates from nodes is $xcatiport") if ($verbose); -$msg = "xcatd is listening on port $xcatiport"; -$cmdoutput = `netstat -antp | grep -i xcatd|grep LISTEN|grep $xcatiport`; -if ($?) { - probe_utils->send_msg("$output", "f", "$msg"); - $rst = 1; -} else { - probe_utils->send_msg("$output", "o", "$msg"); -} -exit 1 if ($rst); - -$msg = "'lsxcatd -a' works"; -$cmdoutput = `lsxcatd -a 2>&1`; -$rst = $?; -returncmdoutput($cmdoutput) if ($verbose); -if ($rst) { - probe_utils->send_msg("$output", "f", "$msg"); - exit $rst; -} else { - probe_utils->send_msg("$output", "o", "$msg"); -} - -my $masteripinsite = `tabdump site | awk -F',' '/^"master",/ { gsub(/"/, "", \$2) ; print \$2 }'`; -chomp($masteripinsite); -probe_utils->send_msg("$output", "d", "The value of 'master' in 'site' table is $masteripinsite") if ($verbose); -probe_utils->send_msg("$output", "f", "There isn't 'master' definition in 'site' talbe") if ($masteripinsite eq ""); - -$msg = "The value of 'master' in 'site' table is a IP address"; -if (probe_utils->is_ip_addr("$masteripinsite")) { - probe_utils->send_msg("$output", "o", "$msg"); -} else { - probe_utils->send_msg("$output", "f", "$msg"); - exit 1; -} - -if ($mnip) { - $msg = "The IP $mnip of $installnic equals the value of 'master' in 'site' table"; - if ($mnip eq $masteripinsite) { - probe_utils->send_msg("$output", "o", "$msg"); - } else { - probe_utils->send_msg("$output", "f", "$msg"); +#-------------------------------------------- +# dispatch job to MN and SN +#-------------------------------------------- +my $mnjobpid = 0; +my @snsjobpids = (); +my @snsjobfds = (); +my $pipe_parent_read; +my $pipe_child_write; +pipe $pipe_parent_read, $pipe_child_write; +{ + #handle job in MN + $mnjobpid = fork(); + if (!defined($mnjobpid)) { + probe_utils->send_msg("$output", "f", "fork process to handle MN job failed: $!"); $rst = 1; + last; + } elsif ($mnjobpid == 0) { + $SIG{TERM} = $SIG{INT} = sub { + exit 1; + }; + + close $pipe_parent_read; + $rst = do_main_job($pipe_child_write); + exit $rst; } -} + $SIG{CHLD} = sub { waitpid($mnjobpid, WNOHANG) }; + close $pipe_child_write; -$msg = "IP $mnip of NIC $installnic is a static IP on current server"; -if (probe_utils->is_static_ip("$mnip", "$installnic")) { - probe_utils->send_msg("$output", "o", "$msg"); -} else { - probe_utils->send_msg("$output", "w", "IP $mnip of $installnic is not a static ip on current server"); -} + #handle job dispatch to SN + foreach my $sn (keys %dispatchcmd) { + my $snjobcmd = "xdsh $sn -s \"$dispatchcmd{$sn}\" 2>&1"; + probe_utils->send_msg("$output", "i", "Dispatch cmd $program_name to $sn $1"); -$msg = "$mnip belongs to one of networks defined in 'networks' table"; -my $networks = `tabdump networks|grep -v "^#"`; -$networks =~ s/\"//g; -my $netcnt = `echo "$networks"|wc -l`; -my $hit = 0; -for (my $i = 1 ; $i < $netcnt + 1 ; $i++) { - my $line = `echo "$networks" |sed -n ${i}p |awk -F"," '{print \$2,\$3,\$4}'`; - chomp($line); - if ($line =~ /(.+) (.+) (.+)/) { - $hit = 1 if (probe_utils->is_ip_belong_to_net("$1", "$2", $mnip) && ("$3" eq "$installnic")); + my $snjobfd; + my $snjobpid; + if (!($snjobpid = open($snjobfd, "$snjobcmd |"))) { + probe_utils->send_msg("$output", "f", "fork process to dispatch cmd $snjobcmd to $sn failed: $!"); + next; + } + push(@snsjobpids, $snjobpid); + push(@snsjobfds, $snjobfd); } -} -if ($hit) { - probe_utils->send_msg("$output", "o", "$msg"); -} else { - probe_utils->send_msg("$output", "f", "$msg"); - $rst = 1; -} -$msg = "There is domain definition in 'site' table"; -my $domain = `tabdump site | awk -F',' '/^"domain",/ { gsub(/"/, "", \$2) ; print \$2 }'`; -chomp($domain); -if ($domain) { - probe_utils->send_msg("$output", "d", "The value of 'domain' in 'site' table is $domain") if ($verbose); - probe_utils->send_msg("$output", "o", "$msg"); -} else { - probe_utils->send_msg("$output", "f", "$msg"); - $rst = 1; -} + my $select = new IO::Select; + $select->add(\*$pipe_parent_read) if ($pipe_parent_read); + $select->add(\*$_) foreach (@snsjobfds); + $| = 1; -$msg = "There is configuration in 'passwd' table for 'system' for node provision"; -my $passwd = `tabdump passwd |awk -F',' '/system/ { gsub(/"/, "", \$2); gsub(/"/, "", \$3); print \$2,\$3 }'`; -chomp($passwd); -my ($username, $pw) = split(" ", $passwd); -if ($username eq "" || $pw eq "") { - probe_utils->send_msg("$output", "f", "$msg"); - probe_utils->send_msg("$output", "d", "Please define username and password for 'system' in 'passwd' table"); - $rst = 1; -} else { - probe_utils->send_msg("$output", "o", "$msg"); -} - -my $installdir = `tabdump site 2>&1 | awk -F',' '/^"installdir"/ { gsub(/"/, "", \$2) ; print \$2 }'`; -chomp($installdir); -probe_utils->send_msg("$output", "d", "The 'install' directory is set to $installdir in 'site' table on current server") if ($verbose); -my $tftpdir = `tabdump site 2>&1 | awk -F',' '/^"tftpdir",/ { gsub(/"/, "", \$2) ; print \$2 }'`; -chomp($tftpdir); -probe_utils->send_msg("$output", "d", "The 'tftp' directory is set to $tftpdir in 'site' talbe on current server") if ($verbose); - -$msg = "There is $installdir directory on current server"; -if (-e "$installdir/postscripts/") { - probe_utils->send_msg("$output", "o", "$msg"); -} else { - probe_utils->send_msg("$output", "f", "$msg"); - $rst = 1; -} - -$msg = "There is $tftpdir directory on current server"; -if (-e "$tftpdir") { - probe_utils->send_msg("$output", "o", "$msg"); -} else { - probe_utils->send_msg("$output", "f", "$msg"); - $rst = 1; -} - -my $expected = 10; -$msg = "The free space of / directory is more than $expected G"; -my $diskspace = `df -h|awk '{print \$4,\$6}'|grep -E "/\$"`; -if ($?) { - probe_utils->send_msg("$output", "d", "There isn't any filesystem mount on / directory"); - probe_utils->send_msg("$output", "f", "$msg"); - $rst = 1; -} else { - chomp($diskspace); - my ($size, $dir) = split(" ", $diskspace); - $size =~ s/G//g; - probe_utils->send_msg("$output", "d", "The free space of / is $size G") if ($verbose); - if ($size < $expected) { - probe_utils->send_msg("$output", "w", "The free space of / is less than $expected G"); - } else { - probe_utils->send_msg("$output", "o", "$msg"); + my $line; + my %pipeisnonull; + $pipeisnonull{mn} = 1; + $pipeisnonull{$_} = 1 foreach (@snsjobfds); + my $onepipeisnonull = 1; + while ($onepipeisnonull) { + if (@hdls = $select->can_read(0)) { + foreach $hdl (@hdls) { + if ($pipeisnonull{mn} && $hdl == \*$pipe_parent_read) { + if (eof($pipe_parent_read)) { + $pipeisnonull{mn} = 0; + } else { + chomp($line = <$pipe_parent_read>); + print "$line\n"; + push @{ $summaryoutput{mn} }, $line; + } + } else { + foreach my $fd (@snsjobfds) { + if ($pipeisnonull{$fd} && $hdl == \*$fd) { + if (eof($fd)) { + $pipeisnonull{$fd} = 0; + } else { + chomp($line = <$fd>); + if ($line =~ /(Error:)\s+(\w+)\s+(.+)/i) { + push @{ $summaryoutput{$2} }, $line; + } elsif ($line =~ /^(\w+)\s*:\s(.*)/) { + push @{ $summaryoutput{$1} }, $2; + $line = "$2:$1: $3" if ($line =~ /^(\w+)\s*:\s*(\[\w+\]\s*):\s*(.*)/); + } + } + } + } + } + } + $onepipeisnonull = 0; + $onepipeisnonull |= $pipeisnonull{$_} foreach (keys %pipeisnonull); + } + last if ($terminal); + sleep 1; } + send_sn_msg(); } +close($pipe_child_write) if ($pipe_child_write); +close($pipe_parent_read) if ($pipe_parent_read); +close($_) foreach (@snsjobfds); -$expected = 1; -$msg = "The free space of /var directory is more than $expected G"; -$diskspace = `df -h|awk '{print \$4,\$6}'|grep -E "/var\$"`; -if (!$?) { - chomp($diskspace); - my ($size, $dir) = split(" ", $diskspace); - $size =~ s/G//g; - probe_utils->send_msg("$output", "d", "The free space of /var is $size G") if ($verbose); - if ($size < $expected) { - probe_utils->send_msg("$output", "w", "The free space of /var is less than $expected G"); - } else { - probe_utils->send_msg("$output", "o", "$msg"); - } -} +my %runningpid; +$runningpid{$mnjobpid} = 1 if ($mnjobpid); +$runningpid{$_} = 1 foreach (@snsjobpids); +my $existrunningpid = 0; +$existrunningpid = 1 if (%runningpid); -$expected = 1; -$msg = "The free space of /tmp directory is more than $expected G"; -$diskspace = `df -h|awk '{print \$4,\$6}'|grep -E "/tmp\$"`; -if (!$?) { - chomp($diskspace); - my ($size, $dir) = split(" ", $diskspace); - $size =~ s/G//g; - probe_utils->send_msg("$output", "d", "The free space of /tmp is $size G") if ($verbose); - if ($size < $expected) { - probe_utils->send_msg("$output", "w", "The free space of /tmp is less than $expected G"); - } else { - probe_utils->send_msg("$output", "o", "$msg"); - } -} +my $trytime = 0; +while ($existrunningpid) { - -$expected = 10; -$msg = "The free space of $installdir directory is more than $expected G"; -$diskspace = `df -h|awk '{print \$4,\$6}'|grep -E "$installdir\$"`; -if (!$?) { - chomp($diskspace); - my ($size, $dir) = split(" ", $diskspace); - $size =~ s/G//g; - probe_utils->send_msg("$output", "d", "The free space of /install is $size G") if ($verbose); - if ($size < $expected) { - probe_utils->send_msg("$output", "w", "The free space of /install is less than $expected G"); - } else { - probe_utils->send_msg("$output", "o", "$msg"); - } -} - -$msg = "SELinux is disabled on current server"; -if (probe_utils->is_selinux_enable()) { - probe_utils->send_msg("$output", "f", "$msg"); - $rst = 1; -} else { - probe_utils->send_msg("$output", "o", "$msg"); -} - -$msg = "Firewall is closed on current server"; -if (probe_utils->is_firewall_open()) { - probe_utils->send_msg("$output", "w", "Firewall is configured on current server"); -} else { - probe_utils->send_msg("$output", "o", "$msg"); -} - -`which wget > /dev/null 2>&1`; -if ($?) { - probe_utils->send_msg("$output", "w", "wget tool isn't installed on current server, skip checking HTTP service."); - probe_utils->send_msg("$output", "d", "Please do probe again after installing wget"); -} else { - $msg = "HTTP service is ready on $mnip"; - if (probe_utils->is_http_ready("$mnip")) { - probe_utils->send_msg("$output", "o", "$msg"); - } else { - probe_utils->send_msg("$output", "f", "$msg"); - $rst = 1; - } -} - -`which tftp > /dev/null 2>&1`; -if ($?) { - probe_utils->send_msg("$output", "w", "tftp tool isn't installed on current server, skip checking tftp service."); - probe_utils->send_msg("$output", "d", "Please do probe again after installing tftp"); -} else { - $msg = "TFTP service is ready on $mnip"; - if (probe_utils->is_tftp_ready("$mnip")) { - probe_utils->send_msg("$output", "o", "$msg"); - } else { - probe_utils->send_msg("$output", "f", "$msg"); - $rst = 1; - } -} - -`which nslookup > /dev/null 2>&1`; -if ($?) { - probe_utils->send_msg("$output", "w", "nslookup tool isn't installed in current server, skip checking DNS service."); - probe_utils->send_msg("$output", "d", "Please do probe again after installing nslookup"); -} else { - $msg = "DNS server is ready on $mnip"; - probe_utils->send_msg("$output", "d", "Domain used to check DNS is $domain") if ($verbose); - - my $rc = 0; - { #very important brace to create a block - my $tmp = `chdef xcatmntest groups=all ip=$mnip`; - if ($?) { - returncmdoutput($tmp) if ($verbose); - probe_utils->send_msg("$output", "d", "Simulate a node by chdef failed") if ($verbose); - $rc = 1; - last; - } else { - probe_utils->send_msg("$output", "d", "Simulate a node xcatmntest to do DNS test") if ($verbose); + #try INT 5 up to 5 times + if ($try < 5) { + foreach my $pid (keys %runningpid) { + kill 'INT', $pid if ($runningpid{$pid}); } - probe_utils->send_msg("$output", "d", "To do 'makehosts xcatmntest'") if ($verbose); - $tmp = `makehosts xcatmntest`; - if ($?) { - returncmdoutput($tmp) if ($verbose); - probe_utils->send_msg("$output", "d", "makehosts xcatmntest failed") if ($verbose); - $rc = 1; - `rmdef xcatmntest`; - last; + #try TERM 5 up to 5 times + } elsif ($try < 10) { + foreach my $pid (keys %runningpid) { + kill 'TERM', $pid if ($runningpid{$pid}); } - $tmp = `cat /etc/hosts |grep xcatmntest |grep $mnip`; - if ($?) { - probe_utils->send_msg("$output", "d", "makehosts failed to add test node xcatmntest to /etc/hosts") if ($verbose); - $rc = 1; - `rmdef xcatmntest`; - last; - } - - probe_utils->send_msg("$output", "d", "To do 'makedns -n xcatmntest'") if ($verbose); - $tmp = `makedns -V -n xcatmntest 2>&1`; - if ($?) { - returncmdoutput($tmp) if ($verbose); - probe_utils->send_msg("$output", "d", "makedns -n xcatmntest failed") if ($verbose); - $rc = 1; - `makehosts -d xcatmntest && rmdef xcatmntest`; - last; - } - - if (!probe_utils->is_dns_ready("$mnip", "xcatmntest", "$domain")) { - probe_utils->send_msg("$output", "d", "nslookup xcatmntest $mnip failed"); - $rc = 1; - `makehosts -d xcatmntest && rmdef xcatmntest`; - last; - } - - probe_utils->send_msg("$output", "d", "Start to clear simulate information for DNS test") if ($verbose); - $tmp = `makedns -d xcatmntest && makehosts -d xcatmntest && rmdef xcatmntest`; - returncmdoutput($tmp) if ($verbose); - } - - if ($rc) { - probe_utils->send_msg("$output", "f", "$msg"); - $rst = 1; + #try KILL 1 time } else { - probe_utils->send_msg("$output", "o", "$msg"); + foreach my $pid (keys %runningpid) { + kill 'KILL', $pid if ($runningpid{$pid}); + } } + ++$try; + + sleep 1; + foreach my $pid (keys %runningpid) { + $runningpid{$pid} = 0 if (waitpid($pid, WNOHANG)); + } + $existrunningpid = 0; + $existrunningpid |= $runningpid{$_} foreach (keys %runningpid); + last if ($try > 10); } -my $os = probe_utils->get_os(); -my $leasefile = ""; -$leasefile = "/var/lib/dhcpd/dhcpd.leases" if ($os =~ /redhat/i); -$leasefile = "/var/lib/dhcp/db/dhcpd.leases" if ($os =~ /sles/i); -$leasefile = "/var/lib/dhcp/dhcpd.leases" if ($os =~ /ubuntu/i); -$msg = "The size of $leasefile is less than 100M"; -my $filesizetmp = `du -sb $leasefile`; -if ($?) { - returncmdoutput($filesizetmp) if ($verbose); - probe_utils->send_msg("$output", "f", "$msg"); - $rst = 1; -} else { - chomp($filesizetmp); - my ($size, $file) = split(" ", $filesizetmp); - probe_utils->send_msg("$output", "d", "The size of $leasefile is $size bytes") if ($verbose); - if ($size > 104857600) { - probe_utils->send_msg("$output", "w", "The size of $leasefile is more than 100M"); - } else { - probe_utils->send_msg("$output", "o", "$msg"); - } -} +#------------------------------------- +# summary all jobs output to display +#------------------------------------- +$rst = summary_all_jobs_output(); -my $msg = "DHCP service is ready on $mnip"; -my $rc = 0; -{ #very important brace to create a block - my $tmp = `chdef xcatmntest groups=all ip=$mnip mac=aa:aa:aa:aa:aa:aa`; if ($?) { - returncmdoutput($tmp) if ($verbose); - probe_utils->send_msg("$output", "d", "Simulate a node by chdef failed") if ($verbose); - $rc = 1; - last; - } else { - probe_utils->send_msg("$output", "d", "Simulate a node xcatmntest to do dhcp test") if ($verbose); - } - - probe_utils->send_msg("$output", "d", "To do 'makehosts xcatmntest'") if ($verbose); - $tmp = `makehosts xcatmntest`; - if ($?) { - returncmdoutput($tmp) if ($verbose); - probe_utils->send_msg("$output", "d", "makehosts xcatmntest failed") if ($verbose); - $rc = 1; - `rmdef xcatmntest`; - last; - } - - $tmp = `cat /etc/hosts |grep xcatmntest |grep $mnip`; - if ($?) { - probe_utils->send_msg("$output", "d", "makehosts failed to add test node xcatmntest to /etc/hosts") if ($verbose); - $rc = 1; - `rmdef xcatmntest`; - last; - } - - probe_utils->send_msg("$output", "d", "To do 'makedhcp xcatmntest'") if ($verbose); - $tmp = `makedhcp xcatmntest 2>&1`; - if ($?) { - returncmdoutput($tmp) if ($verbose); - probe_utils->send_msg("$output", "d", "makedhcp xcatmntest failed") if ($verbose); - $rc = 1; - `makehosts -d xcatmntest && rmdef xcatmntest`; - last; - } - - probe_utils->send_msg("$output", "d", "To do 'makedhcp -q xcatmntest'") if ($verbose); - $tmp = `makedhcp -q xcatmntest`; - if ($?) { - returncmdoutput($tmp) if ($verbose); - probe_utils->send_msg("$output", "d", "makedhcp -q xcatmntest failed") if ($verbose); - $rc = 1; -`makedhcp -d xcatmntest && makehosts -d xcatmntest && rmdef xcatmntest`; - last; - } - chomp($tmp); - if ($tmp !~ /xcatmntest: ip-address = $mnip, hardware-address = aa:aa:aa:aa:aa:aa/) { - returncmdoutput($tmp) if ($verbose); - probe_utils->send_msg("$output", "d", "DHCP server's reply is wrong") if ($verbose); - $rc = 1; -`makedhcp -d xcatmntest && makehosts -d xcatmntest && rmdef xcatmntest`; - last; - } - - probe_utils->send_msg("$output", "d", "Start to clear simulate information for dhcp test") if ($verbose); - $tmp = `makedhcp -d xcatmntest && makehosts -d xcatmntest && rmdef xcatmntest`; - returncmdoutput($tmp) if ($verbose); -} -if ($rc) { - probe_utils->send_msg("$output", "f", "$msg"); - probe_utils->send_msg("$output", "d", "please run 'makedhcp -n' if never run it before."); - $rst = 1; -} else { - probe_utils->send_msg("$output", "o", "$msg"); -} exit $rst; + + + + From d4c410491d710673a8426c5ee172730ca2c6d93c Mon Sep 17 00:00:00 2001 From: junxiawang Date: Wed, 10 Aug 2016 09:45:41 -0400 Subject: [PATCH 020/106] modify bundle file --- xCAT-test/autotest/bundle/rhels7.3_ppc64le.bundle | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/xCAT-test/autotest/bundle/rhels7.3_ppc64le.bundle b/xCAT-test/autotest/bundle/rhels7.3_ppc64le.bundle index cc15f6b88..a9a3aa760 100644 --- a/xCAT-test/autotest/bundle/rhels7.3_ppc64le.bundle +++ b/xCAT-test/autotest/bundle/rhels7.3_ppc64le.bundle @@ -1,13 +1,10 @@ Diskless_installation_flat_p8_le Full_installation_flat_p8_le -go_xcat_local_repo_case1 -go_xcat_local_repo_case2 -go_xcat_local_repo_case3 -go_xcat_local_repo_case4 -go_xcat_local_repo_case5 -go_xcat_local_repo_case6 go_xcat_local_repo_case7 go_xcat_noinput +go_xcat_with_x +go_xcat_with_xcat-version-1 +go_xcat_online_repo_case6 makehosts_h makehosts_help makehosts_n @@ -202,6 +199,4 @@ switchdiscover_range_z_V nodeset_shell nodeset_cmdline nodeset_runimg -redhat_migration1 -redhat_migration2 clean_up_env From e78dfb7f3858b842a7c2bb38e05afbd3a7b342f1 Mon Sep 17 00:00:00 2001 From: Andreas Hilboll Date: Wed, 10 Aug 2016 22:08:20 +0200 Subject: [PATCH 021/106] Update features.rst --- docs/source/overview/features.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/source/overview/features.rst b/docs/source/overview/features.rst index c15ac8471..176d6b82a 100644 --- a/docs/source/overview/features.rst +++ b/docs/source/overview/features.rst @@ -51,6 +51,7 @@ Features * Parallel ping #. Integrate xCAT in Cloud + * Openstack * SoftLayer From 9842b155e88e07b5e0cf1c4e653e94e6a638b652 Mon Sep 17 00:00:00 2001 From: XuWei Date: Wed, 10 Aug 2016 21:27:31 -0400 Subject: [PATCH 022/106] modify summary output of xcatmn --- xCAT-probe/subcmds/xcatmn | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xCAT-probe/subcmds/xcatmn b/xCAT-probe/subcmds/xcatmn index e564197f4..0b72e8886 100755 --- a/xCAT-probe/subcmds/xcatmn +++ b/xCAT-probe/subcmds/xcatmn @@ -668,9 +668,10 @@ sub do_main_job { #------------------------------------- # When this command return from all SNs and MN, you need to generate a summary # All history outpout from SNs and MN are saved in globle hash %summaryoutput. -# $ummaryoutput{mn} = @mnhistory -# $ummaryoutput{snname1} = @snname1history; +# $summaryoutput{mn} = @mnhistory +# $summaryoutput{snname1} = @snname1history; # The entry in each histroy array isn't categorized, the message coming early is arranged before the one coming later. +# A simple example of how to dump %summaryoutput has been written in function #------------------------------------- sub summary_all_jobs_output { @@ -775,8 +776,7 @@ sub send_sn_msg { next if ($node eq "mn"); foreach my $line (@{ $summaryoutput{$node} }) { if ($line =~ /^(\[\w+\]\s*):\s*(.*)/) { - $line = "$1:$node: $2"; - print "$line\n"; + print "$1:$node: $2\n"; } else { print "[failed] :$node: $line\n"; } From 7831ea277d698c6c7ce43296bc6e9f3bf00464a0 Mon Sep 17 00:00:00 2001 From: neo954 Date: Thu, 11 Aug 2016 01:21:07 -0500 Subject: [PATCH 023/106] [go-xcat] Version 1.0.2 Fix a couple of bugs. (#1663) * [go-xcat] Let the end user see the original interactive prompt of yum, zypper and apt-get. * [go-xcat] Change the package list for Ubuntu based on commit number 8b5f44c * [go-xcat] Change the default behavior of this script to show the help message * [go-xcat] Add a secret verbose help message * [go-xcat] A secret verbose help output * [go-xcat] Print out help message instantly while wrong command line argument were passed * [go-xcat] Add error handling for unknown command line argument --- xCAT-server/share/xcat/tools/go-xcat | 146 ++++++++++++++++++++++----- 1 file changed, 122 insertions(+), 24 deletions(-) diff --git a/xCAT-server/share/xcat/tools/go-xcat b/xCAT-server/share/xcat/tools/go-xcat index 775c87ae3..610bf3ebc 100755 --- a/xCAT-server/share/xcat/tools/go-xcat +++ b/xCAT-server/share/xcat/tools/go-xcat @@ -2,7 +2,7 @@ # # go-xcat - Install xCAT automatically. # -# Version 1.0.1 +# Version 1.0.2 # # Copyright (C) 2016 International Business Machines # Eclipse Public License, Version 1.0 (EPL-1.0) @@ -59,6 +59,65 @@ function usage() EOF } +# +# verbose_usage This function be will be called when user run +# `go-xcat --long-help'. +# Including a bunch of secert usage. +# +function verbose_usage() +( + local script="${0##*/}" + + exec 42< <(usage) + + function println() + { + local -i i + for (( i = 0 ; i < "$1" ; ++i )) + do + read -r -u 42 + [[ "$?" -ne "0" ]] && break + echo "${REPLY}" + done + } + + println 7 + println 1 >/dev/null # Drop a line + while read -r ; do echo "${REPLY}" ; done <<-EOF + -h, --help display a simply version of help and exit + --long-help display this help and exit + EOF + println 9 + while read -r ; do echo "${REPLY}" ; done <<-EOF + check check the version of the installed packages + of xCAT and packages in the repository + EOF + println 2 + while read -r ; do echo "${REPLY}" ; done <<-EOF + smoke-test preform basic tests of the xCAT installation + EOF + println 11 + while read -r ; do echo "${REPLY}" ; done <<-EOF + ${script} --xcat-core=/path/to/xcat-core.repo install + ${script} --xcat-core=/path/to/xcat-core install + ${script} --xcat-core=/path/to/xcat-core.tar install + ${script} --xcat-core=/path/to/xcat-core.tar.Z install + ${script} --xcat-core=/path/to/xcat-core.tar.gz install + ${script} --xcat-core=/path/to/xcat-core.tar.bz2 install + ${script} --xcat-core=/path/to/xcat-core.tar.xz install + ${script} --xcat-core=http://xcat.org/path/to/xcat-core.repo install + ${script} --xcat-core=http://xcat.org/path/to/xcat-core install + ${script} --xcat-core=http://xcat.org/path/to/xcat-core.tar.bz2 install + ${script} --xcat-core=/path/to/xcat-core.repo \\ + --xcat-dep=/path/to/xcat-dep.repo install + ${script} --xcat-core=/path/to/xcat-core \\ + --xcat-dep=/path/to/xcat-dep install + EOF + println 999999 # Print out all the rest of lines + + exec 42<&- +) + # # version Print out the version number. # @@ -83,8 +142,8 @@ GO_XCAT_CORE_PACKAGE_LIST=(perl-xCAT xCAT xCAT-SoftLayer xCAT-buildkit # For Debian/Ubuntu, it will need a sight different package list type dpkg >/dev/null 2>&1 && GO_XCAT_CORE_PACKAGE_LIST=(perl-xcat xcat xcat-buildkit xcat-client - xcat-confluent xcat-genesis-scripts xcat-server xcat-test xcat-vlan - xcatsn) + xcat-confluent xcat-genesis-scripts-amd64 xcat-genesis-script-ppc64 + xcat-server xcat-test xcat-vlan xcatsn) GO_XCAT_DEP_PACKAGE_LIST=() # The package list of all the packages should be installed @@ -95,7 +154,7 @@ GO_XCAT_INSTALL_LIST=(perl-xCAT xCAT xCAT-buildkit xCAT-client # For Debian/Ubuntu, it will need a sight different package list type dpkg >/dev/null 2>&1 && GO_XCAT_INSTALL_LIST=(perl-xcat xcat xcat-buildkit xcat-client - xcat-genesis-scripts xcat-server + xcat-genesis-scripts-amd64 xcat-genesis-script-ppc64 xcat-server conserver-xcat elilo-xcat grub2-xcat ipmitool-xcat syslinux-xcat xcat-genesis-base-amd64 xcat-genesis-base-ppc64 xnba-undi) @@ -715,6 +774,8 @@ function extract_archive() # $2 repo id function add_repo_by_url_yum_or_zypper() { + local -a yes=() + [[ "$1" = "-y" ]] && yes=("-y") && shift local url="$1" local repo_id="$2" local tmp="" @@ -786,6 +847,8 @@ function add_repo_by_url_yum_or_zypper() function add_repo_by_url_apt() { [[ -d /etc/apt/sources.list.d/ ]] || return 255 + local -a yes=() + [[ "$1" = "-y" ]] && yes=("-y") && shift local url="$1" local repo_id="$2" local tmp="" @@ -882,6 +945,8 @@ function remove_repo() function add_xcat_core_repo_yum_or_zypper() { type yum >/dev/null 2>&1 || type zypper >/dev/null 2>&1 || return 255 + local -a yes=() + [[ "$1" = "-y" ]] && yes=("-y") && shift local url="$1" local ver="$2" local tmp="" @@ -906,6 +971,8 @@ function add_xcat_core_repo_yum_or_zypper() function add_xcat_core_repo_apt() { [[ -d "/etc/apt/sources.list.d" ]] || return 255 + local -a yes=() + [[ "$1" = "-y" ]] && yes=("-y") && shift local url="$1" local ver="$2" local tmp="" @@ -939,6 +1006,8 @@ function add_xcat_core_repo() function add_xcat_dep_repo_yum_or_zypper() { type yum >/dev/null 2>&1 || type zypper >/dev/null 2>&1 || return 255 + local -a yes=() + [[ "$1" = "-y" ]] && yes=("-y") && shift local url="$1" local tmp="" local install_path="${GO_XCAT_DEFAULT_INSTALL_PATH}" @@ -1003,6 +1072,8 @@ function add_xcat_dep_repo_yum_or_zypper() function add_xcat_dep_repo_apt() { [[ -d "/etc/apt/sources.list.d" ]] || return 255 + local -a yes=() + [[ "$1" = "-y" ]] && yes=("-y") && shift local url="$1" [[ -z "${url}" ]] && url="${GO_XCAT_DEFAULT_BASE_URL}/apt/xcat-dep" @@ -1046,33 +1117,33 @@ function update_repo() function install_packages_dnf() { type dnf >/dev/null 2>&1 || return 255 - local -a args=() - [[ "$1" = "-y" ]] && args=("-y") && shift - dnf --nogpgcheck "${args[@]}" install "$@" + local -a yes=() + [[ "$1" = "-y" ]] && yes=("-y") && shift + dnf --nogpgcheck "${yes[@]}" install "$@" } function install_packages_yum() { type yum >/dev/null 2>&1 || return 255 - local -a args=() - [[ "$1" = "-y" ]] && args=("-y") && shift - yum --nogpgcheck "${args[@]}" install "$@" + local -a yes=() + [[ "$1" = "-y" ]] && yes=("-y") && shift + yum --nogpgcheck "${yes[@]}" install "$@" } function install_packages_zypper() { type zypper >/dev/null 2>&1 || return 255 - local -a args=() - [[ "$1" = "-y" ]] && args=("-n") && shift - zypper --no-gpg-checks "${args[@]}" install "$@" + local -a yes=() + [[ "$1" = "-y" ]] && yes=("-n") && shift + zypper --no-gpg-checks "${yes[@]}" install "$@" } function install_packages_apt() { type apt-get >/dev/null 2>&1 || return 255 - local -a args=() - [[ "$1" = "-y" ]] && args=("-y") && shift - apt-get --allow-unauthenticated install "${args[@]}" "$@" + local -a yes=() + [[ "$1" = "-y" ]] && yes=("-y") && shift + apt-get --allow-unauthenticated install "${yes[@]}" "$@" } function install_packages() @@ -1309,6 +1380,10 @@ do usage exit 0 ;; + "--long-help") + verbose_usage + exit 0 + ;; "--xcat-core="*) GO_XCAT_CORE_URL="${1##--xcat-core=}" ;; @@ -1325,8 +1400,15 @@ do "-y"|"--yes") GO_XCAT_YES=("-y") ;; + "-"*) + warn_if_bad 1 "invalid option -- '$1'" + exit_if_bad 1 "Try \`$0 --help' for more information" + ;; *) [ "$1" == "--" ] && shift + [ -z "${GO_XCAT_ACTION}" ] + warn_if_bad "$?" "redundancy action -- '$1'" + exit_if_bad "$?" "Try \`$0 --help' for more information" GO_XCAT_ACTION="$1" ;; esac @@ -1334,10 +1416,20 @@ do done case "${GO_XCAT_ACTION}" in +"check"|"install"|"update") + ;; "smoke-test") perform_smoke_test exit "$?" ;; +"") + usage + exit 1 + ;; +*) + warn_if_bad 1 "invalid action -- '${GO_XCAT_ACTION}'" + exit_if_bad 1 "Try \`$0 --help' for more information" + ;; esac GO_XCAT_OS="$(check_os)" @@ -1386,9 +1478,9 @@ echo echo -n "Reading repositories " show_progress_meters ERR_MSG="$({ - if add_xcat_core_repo "${GO_XCAT_CORE_URL}" "${GO_XCAT_VERSION}" + if add_xcat_core_repo "${GO_XCAT_YES[@]}" "${GO_XCAT_CORE_URL}" "${GO_XCAT_VERSION}" then - if add_xcat_dep_repo "${GO_XCAT_DEP_URL}" + if add_xcat_dep_repo "${GO_XCAT_YES[@]}" "${GO_XCAT_DEP_URL}" then update_repo && exit 0 remove_repo "xcat-dep" @@ -1408,6 +1500,9 @@ fi echo "done" case "${GO_XCAT_ACTION}" in +"check") + list_xcat_packages + ;; "install"|"update") GO_XCAT_INSTALLER="${GO_XCAT_ACTION}_xcat" if [[ "${#GO_XCAT_YES[@]}" -eq "0" ]] @@ -1424,7 +1519,7 @@ case "${GO_XCAT_ACTION}" in esac fi ( - "${GO_XCAT_INSTALLER}" -y 2>&1 1>&42 | + "${GO_XCAT_INSTALLER}" "${GO_XCAT_YES[@]}" 2>&1 1>&42 | tee "${TMP_DIR}/${GO_XCAT_INSTALLER}.stderr" >&2 exit "${PIPESTATUS[0]}" ) 42>&1 | tee "${TMP_DIR}/${GO_XCAT_INSTALLER}.stdout" @@ -1482,8 +1577,9 @@ case "${GO_XCAT_ACTION}" in exit "${RET}" fi - if [ ${GO_XCAT_ACTION} == 'install' ]; then - # only print out this message on install + case "${GO_XCAT_ACTION}" in + "install") + # Only print out this message on install while read -r ; do echo "${REPLY}" ; done <<-EOF xCAT has been installed! @@ -1497,17 +1593,19 @@ case "${GO_XCAT_ACTION}" in or csh, \`source /etc/profile.d/xcat.csh\` EOF - else + ;; + "update") while read -r ; do echo "${REPLY}" ; done <<-EOF xCAT has been updated! ====================== EOF - fi + ;; + esac ;; *) - list_xcat_packages + exit 1 ;; esac # case "${GO_XCAT_ACTION}" in From 79426ad21e602b8a1bf5c02084ffb8c8ca9bf01e Mon Sep 17 00:00:00 2001 From: penguhyang Date: Thu, 11 Aug 2016 16:09:43 +0800 Subject: [PATCH 024/106] add new option to indicate compress method (#1669) --- .../references/man1/packimage.1.rst | 2 + xCAT-client/pods/man1/packimage.1.pod | 2 + xCAT-server/lib/xcat/plugins/anaconda.pm | 8 +- xCAT-server/lib/xcat/plugins/debian.pm | 9 +- xCAT-server/lib/xcat/plugins/packimage.pm | 95 ++++++++++++------- xCAT-server/lib/xcat/plugins/sles.pm | 8 +- .../share/xcat/netboot/rh/compute.pkglist | 1 + .../xcat/netboot/rh/compute.rhels6.pkglist | 1 + .../netboot/rh/compute.rhels6.ppc64.pkglist | 1 + .../netboot/rh/compute.rhels6.x86_64.pkglist | 1 + .../netboot/rh/compute.rhels7.ppc64.pkglist | 1 + .../netboot/rh/compute.rhels7.x86_64.pkglist | 1 + .../xcat/netboot/rh/dracut/install.netboot | 2 +- .../share/xcat/netboot/rh/dracut/xcatroot | 28 ++++-- .../netboot/rh/dracut_033/install.netboot | 2 +- .../share/xcat/netboot/rh/dracut_033/xcatroot | 30 ++++-- xCAT-server/share/xcat/netboot/rh/genimage | 28 ++++-- .../share/xcat/netboot/sles/compute.pkglist | 1 + .../xcat/netboot/sles/compute.sles11.pkglist | 1 + .../netboot/sles/compute.sles11.ppc64.pkglist | 1 + .../sles/compute.sles12.ppc64le.pkglist | 1 + .../sles/compute.sles12.x86_64.pkglist | 1 + .../netboot/sles/dracut_033/install.netboot | 2 +- .../xcat/netboot/sles/dracut_033/xcatroot | 30 ++++-- xCAT-server/share/xcat/netboot/sles/genimage | 30 ++++-- .../share/xcat/netboot/ubuntu/compute.pkglist | 1 + .../compute.ubuntu14.04.4.ppc64el.pkglist | 1 + .../compute.ubuntu14.04.4.x86_64.pkglist | 1 + .../ubuntu/compute.ubuntu14.04.pkglist | 1 + .../ubuntu/compute.ubuntu16.04.pkglist | 1 + .../compute.ubuntu16.04.ppc64el.pkglist | 1 + .../ubuntu/compute.ubuntu16.04.x86_64.pkglist | 1 + .../netboot/ubuntu/dracut/install.netboot | 2 +- .../share/xcat/netboot/ubuntu/dracut/xcatroot | 26 +++-- .../share/xcat/netboot/ubuntu/genimage | 32 +++++-- 35 files changed, 247 insertions(+), 107 deletions(-) diff --git a/docs/source/guides/admin-guides/references/man1/packimage.1.rst b/docs/source/guides/admin-guides/references/man1/packimage.1.rst index d0520af54..20651fbda 100644 --- a/docs/source/guides/admin-guides/references/man1/packimage.1.rst +++ b/docs/source/guides/admin-guides/references/man1/packimage.1.rst @@ -64,6 +64,8 @@ OPTIONS \ **-m**\ Archive Method (cpio,tar,squashfs, default is cpio) +\ **-c**\ Compress Method (pigz,gzip,xz, default is pigz) + ************ RETURN VALUE diff --git a/xCAT-client/pods/man1/packimage.1.pod b/xCAT-client/pods/man1/packimage.1.pod index 0fa78542c..60b34fe6f 100644 --- a/xCAT-client/pods/man1/packimage.1.pod +++ b/xCAT-client/pods/man1/packimage.1.pod @@ -38,6 +38,8 @@ B<-a> Architecture (ppc64,x86_64,etc) B<-m> Archive Method (cpio,tar,squashfs, default is cpio) +B<-c> Compress Method (pigz,gzip,xz, default is pigz) + =head1 RETURN VALUE diff --git a/xCAT-server/lib/xcat/plugins/anaconda.pm b/xCAT-server/lib/xcat/plugins/anaconda.pm index a0e9f768d..bb6d1738b 100644 --- a/xCAT-server/lib/xcat/plugins/anaconda.pm +++ b/xCAT-server/lib/xcat/plugins/anaconda.pm @@ -462,9 +462,11 @@ sub mknetboot } $platform = xCAT_plugin::anaconda::getplatform($osver); - my $suffix = 'gz'; + my $suffix = 'cpio.gz'; $suffix = 'sfs' if (-r "$rootimgdir/rootimg.sfs"); - $suffix = 'tgz' if (-r "$rootimgdir/rootimg.tgz"); + $suffix = 'cpio.xz' if (-r "$rootimgdir/rootimg.cpio.xz"); + $suffix = 'tar.gz' if (-r "$rootimgdir/rootimg.tar.gz"); + $suffix = 'tar.xz' if (-r "$rootimgdir/rootimg.tar.xz"); # statelite images are not packed. if ($statelite) { @@ -513,7 +515,7 @@ sub mknetboot copy("$rootimgdir/initrd.gz", "$rootimgdir/initrd-stateless.gz"); } } - unless (-r "$rootimgdir/rootimg.gz" or -r "$rootimgdir/rootimg.tgz" or -r "$rootimgdir/rootimg.sfs") { + unless (-r "$rootimgdir/rootimg.cpio.gz" or -r "$rootimgdir/rootimg.cpio.xz" or -r "$rootimgdir/rootimg.tar.gz" or -r "$rootimgdir/rootimg.tar.xz" or -r "$rootimgdir/rootimg.sfs") { $callback->({ error => ["No packed image for platform $osver, architecture $arch, and profile $profile found at $rootimgdir/rootimg.gz or $rootimgdir/rootimg.sfs on $myname, please run packimage (e.g. packimage -o $osver -p $profile -a $arch"], errorcode => [1] }); diff --git a/xCAT-server/lib/xcat/plugins/debian.pm b/xCAT-server/lib/xcat/plugins/debian.pm index 5d57bea30..927886864 100644 --- a/xCAT-server/lib/xcat/plugins/debian.pm +++ b/xCAT-server/lib/xcat/plugins/debian.pm @@ -1170,9 +1170,10 @@ sub mknetboot } $platform = xCAT_plugin::debian::getplatform($osver); - my $suffix = 'gz'; - $suffix = 'sfs' if (-r "$rootimgdir/rootimg.sfs"); - $suffix = 'tgz' if (-r "$rootimgdir/rootimg.tgz"); + my $suffix = 'cpio.gz'; + $suffix = 'cpio.xz' if (-r "$rootimgdir/rootimg.cpio.xz"); + $suffix = 'tar.gz' if (-r "$rootimgdir/rootimg.tar.gz"); + $suffix = 'tar.xz' if (-r "$rootimgdir/rootimg.tar.xz"); # statelite images are not packed. if ($statelite) { @@ -1222,7 +1223,7 @@ sub mknetboot copy("$rootimgdir/initrd.gz", "$rootimgdir/initrd-stateless.gz"); } } - unless (-r "$rootimgdir/rootimg.gz" or -r "$rootimgdir/rootimg.tgz" or -r "$rootimgdir/rootimg.sfs") { + unless (-r "$rootimgdir/rootimg.cpio.gz" or -r "$rootimgdir/rootimg.cpio.xz" or -r "$rootimgdir/rootimg.tar.gz" or -r "$rootimgdir/rootimg.tar.xz" or -r "$rootimgdir/rootimg.sfs") { $callback->({ error => ["No packed image for platform $osver, architecture $arch, and profile $profile, please run packimage (e.g. packimage -o $osver -p $profile -a $arch"], errorcode => [1] }); diff --git a/xCAT-server/lib/xcat/plugins/packimage.pm b/xCAT-server/lib/xcat/plugins/packimage.pm index 6d6518df7..ca92c8f37 100755 --- a/xCAT-server/lib/xcat/plugins/packimage.pm +++ b/xCAT-server/lib/xcat/plugins/packimage.pm @@ -87,6 +87,7 @@ sub process_request { my $arch; my $profile; my $method = 'cpio'; + my $compress; my $exlistloc; my $syncfile; my $rootimg_dir; @@ -102,6 +103,7 @@ sub process_request { "arch|a=s" => \$arch, "osver|o=s" => \$osver, "method|m=s" => \$method, + "compress|c=s" => \$compress, "tracker=s" => \$dotorrent, "help|h" => \$help, "version|v" => \$version @@ -419,51 +421,77 @@ sub process_request { unlink("$destdir/rootimg.gz"); unlink("$destdir/rootimg.sfs"); - $callback->({ info => ["archive method:$method"] }); - if ($method =~ /cpio/) { - my $compress = "gzip"; - - #use "pigz" as the compress tool instead of gzip if "pigz" exist - my $ispigz = system("bash -c 'type -p pigz' >/dev/null 2>&1"); - if ($ispigz == 0) { - $compress = "pigz"; - } - $callback->({ info => ["compress method:$compress"] }); - if (!$exlistloc) { - $excludestr = "find . -xdev -print0 | cpio -H newc -o -0 | $compress -c - > ../rootimg.gz"; - } else { - chdir("$rootimg_dir"); - system("$excludestr >> $xcat_packimg_tmpfile"); - if ($includestr) { - system("$includestr >> $xcat_packimg_tmpfile"); + my $suffix; + if ($compress) { + if ($compress eq 'gzip') { + my $isgzip = system("bash -c 'type -p gzip' >/dev/null 2>&1"); + unless ($isgzip == 0) { + $callback->({ error => ["Command gzip does not exist, please make sure it is installed."] }); + return 1; } - $excludestr = "cat $xcat_packimg_tmpfile|cpio -H newc -o | $compress -c - > ../rootimg.gz"; + $suffix = "gz"; + } elsif ($compress eq 'pigz') { + my $ispigz = system("bash -c 'type -p pigz' >/dev/null 2>&1"); + unless ($ispigz == 0) { + $callback->({ error => ["Command pigz does not exist, please make sure it is installed."] }); + return 1; + } + $suffix = "gz"; + } elsif ($compress eq 'xz') { + my $isxz = system("bash -c 'type -p xz' >/dev/null 2>&1"); + unless ($isxz == 0) { + $callback->({ error => ["Command xz does not exist, please make sure it is installed."] }); + return 1; + } + $suffix = "xz"; + } else { + $callback->({ error => ["Invalid compress method '$compress' requested"], errorcode => [1] }); + return 1; } - $oldmask = umask 0077; - } elsif ($method =~ /tar/) { - my $compress = "gzip"; - - #use "pigz" as the compress tool instead of gzip if "pigz" exist + } else { my $ispigz = system("bash -c 'type -p pigz' >/dev/null 2>&1"); if ($ispigz == 0) { $compress = "pigz"; } else { my $isgzip = system("bash -c 'type -p gzip' >/dev/null 2>&1"); - unless ($isgzip == 0) { - $callback->({ error => ["Command gzip does not exist, please make sure it works."] }); + if ($isgzip == 0) { + $compress = "gzip"; + } else { + $callback->({ error => ["The default compress tool 'gzip' and 'pigz' does not exist, please specify an available compress method with '-c'."] }); return 1; } } + $suffix = "gz"; + } + + $callback->({ info => ["archive method:$method"] }); + unless ($method =~ /squashfs/) { $callback->({ info => ["compress method:$compress"] }); + } + + $suffix = $method.".".$suffix; + if ($method =~ /cpio/) { if (!$exlistloc) { - $excludestr = "find . -xdev -print0 | tar --selinux --xattrs-include='*' --null -T - -c | $compress -c - > ../rootimg.tgz"; + $excludestr = "find . -xdev -print0 | cpio -H newc -o -0 | $compress -c - > ../rootimg.$suffix"; } else { chdir("$rootimg_dir"); system("$excludestr >> $xcat_packimg_tmpfile"); if ($includestr) { system("$includestr >> $xcat_packimg_tmpfile"); } - $excludestr = "cat $xcat_packimg_tmpfile| tar --selinux --xattrs-include='*' -T - -c | $compress -c - > ../rootimg.tgz"; + $excludestr = "cat $xcat_packimg_tmpfile|cpio -H newc -o | $compress -c - > ../rootimg.$suffix"; + } + $oldmask = umask 0077; + } elsif ($method =~ /tar/) { + if (!$exlistloc) { + $excludestr = "find . -xdev -print0 | tar --selinux --xattrs-include='*' --null -T - -c | $compress -c - > ../rootimg.$suffix"; + } else { + chdir("$rootimg_dir"); + system("$excludestr >> $xcat_packimg_tmpfile"); + if ($includestr) { + system("$includestr >> $xcat_packimg_tmpfile"); + } + $excludestr = "cat $xcat_packimg_tmpfile| tar --selinux --xattrs-include='*' -T - -c | $compress -c - > ../rootimg.$suffix"; } $oldmask = umask 0077; } elsif ($method =~ /squashfs/) { @@ -476,24 +504,25 @@ sub process_request { } $excludestr = "cat $xcat_packimg_tmpfile|cpio -dump $temppath"; } else { - $callback->({ error => ["Invalid method '$method' requested"], errorcode => [1] }); + $callback->({ error => ["Invalid archive method '$method' requested"], errorcode => [1] }); + return 1; } chdir("$rootimg_dir"); my $outputmsg = `$excludestr`; $callback->({ info => ["$outputmsg"] }); if ($method =~ /cpio/) { - chmod 0644, "$destdir/rootimg.gz"; + chmod 0644, "$destdir/rootimg.$suffix"; if ($dotorrent) { my $currdir = getcwd; chdir($destdir); - unlink("rootimg.gz.metainfo"); - system("ctorrent -t -u $dotorrent -l 1048576 -s rootimg.gz.metainfo rootimg.gz"); - chmod 0644, "rootimg.gz.metainfo"; + unlink("rootimg.$suffix.metainfo"); + system("ctorrent -t -u $dotorrent -l 1048576 -s rootimg.$suffix.metainfo rootimg.$suffix"); + chmod 0644, "rootimg.$suffix.metainfo"; chdir($currdir); } umask $oldmask; } elsif ($method =~ /tar/) { - chmod 0644, "$destdir/rootimg.tgz"; + chmod 0644, "$destdir/rootimg.$suffix"; umask $oldmask; } elsif ($method =~ /squashfs/) { my $flags; diff --git a/xCAT-server/lib/xcat/plugins/sles.pm b/xCAT-server/lib/xcat/plugins/sles.pm index a833353ea..7429da3cf 100644 --- a/xCAT-server/lib/xcat/plugins/sles.pm +++ b/xCAT-server/lib/xcat/plugins/sles.pm @@ -327,9 +327,11 @@ sub mknetboot $platform = "sles"; } - my $suffix = 'gz'; + my $suffix = 'cpio.gz'; $suffix = 'sfs' if (-r "$rootimgdir/rootimg.sfs"); - $suffix = 'tgz' if (-r "$rootimgdir/rootimg.tgz"); + $suffix = 'cpio.xz' if (-r "$rootimgdir/rootimg.cpio.xz"); + $suffix = 'tar.gz' if (-r "$rootimgdir/rootimg.tar.gz"); + $suffix = 'tar.xz' if (-r "$rootimgdir/rootimg.tar.xz"); if ($statelite) { unless (-r "$rootimgdir/kernel") { @@ -381,7 +383,7 @@ sub mknetboot } } - unless (-r "$rootimgdir/rootimg.gz" or -r "$rootimgdir/rootimg.tgz" or -r "$rootimgdir/rootimg.sfs") { + unless (-r "$rootimgdir/rootimg.cpio.gz" or -r "$rootimgdir/rootimg.cpio.xz" or -r "$rootimgdir/rootimg.tar.gz" or -r "$rootimgdir/rootimg.tar.xz" or -r "$rootimgdir/rootimg.sfs") { $callback->({ error => [qq{No packed image for platform $osver, architecture $arch, and profile $profile, please run packimage before nodeset}], errorcode => [1] diff --git a/xCAT-server/share/xcat/netboot/rh/compute.pkglist b/xCAT-server/share/xcat/netboot/rh/compute.pkglist index 2824c79fc..42f78c8a2 100644 --- a/xCAT-server/share/xcat/netboot/rh/compute.pkglist +++ b/xCAT-server/share/xcat/netboot/rh/compute.pkglist @@ -14,3 +14,4 @@ rpm rsync tar gzip +xz diff --git a/xCAT-server/share/xcat/netboot/rh/compute.rhels6.pkglist b/xCAT-server/share/xcat/netboot/rh/compute.rhels6.pkglist index e2389d3de..c5eaece65 100644 --- a/xCAT-server/share/xcat/netboot/rh/compute.rhels6.pkglist +++ b/xCAT-server/share/xcat/netboot/rh/compute.rhels6.pkglist @@ -15,3 +15,4 @@ rsyslog e2fsprogs gzip tar +xz diff --git a/xCAT-server/share/xcat/netboot/rh/compute.rhels6.ppc64.pkglist b/xCAT-server/share/xcat/netboot/rh/compute.rhels6.ppc64.pkglist index fbaf36a2a..1439425ef 100644 --- a/xCAT-server/share/xcat/netboot/rh/compute.rhels6.ppc64.pkglist +++ b/xCAT-server/share/xcat/netboot/rh/compute.rhels6.ppc64.pkglist @@ -26,3 +26,4 @@ procps parted gzip tar +xz diff --git a/xCAT-server/share/xcat/netboot/rh/compute.rhels6.x86_64.pkglist b/xCAT-server/share/xcat/netboot/rh/compute.rhels6.x86_64.pkglist index ae873e99f..24c092e95 100644 --- a/xCAT-server/share/xcat/netboot/rh/compute.rhels6.x86_64.pkglist +++ b/xCAT-server/share/xcat/netboot/rh/compute.rhels6.x86_64.pkglist @@ -22,3 +22,4 @@ e2fsprogs parted gzip tar +xz diff --git a/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64.pkglist b/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64.pkglist index bb9af2ce9..2a7c348d3 100644 --- a/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64.pkglist +++ b/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64.pkglist @@ -26,3 +26,4 @@ parted net-tools gzip tar +xz diff --git a/xCAT-server/share/xcat/netboot/rh/compute.rhels7.x86_64.pkglist b/xCAT-server/share/xcat/netboot/rh/compute.rhels7.x86_64.pkglist index 3c54123a8..e0dede612 100644 --- a/xCAT-server/share/xcat/netboot/rh/compute.rhels7.x86_64.pkglist +++ b/xCAT-server/share/xcat/netboot/rh/compute.rhels7.x86_64.pkglist @@ -21,3 +21,4 @@ parted net-tools gzip tar +xz diff --git a/xCAT-server/share/xcat/netboot/rh/dracut/install.netboot b/xCAT-server/share/xcat/netboot/rh/dracut/install.netboot index f14ffa1c0..0b19df672 100755 --- a/xCAT-server/share/xcat/netboot/rh/dracut/install.netboot +++ b/xCAT-server/share/xcat/netboot/rh/dracut/install.netboot @@ -1,6 +1,6 @@ #!/bin/sh echo $drivers -dracut_install wget tar cpio gzip dash modprobe touch echo cut wc +dracut_install wget tar cpio gzip dash modprobe touch echo cut wc xz dracut_install -o ctorrent dracut_install grep ifconfig hostname awk egrep grep dirname expr dracut_install mount.nfs diff --git a/xCAT-server/share/xcat/netboot/rh/dracut/xcatroot b/xCAT-server/share/xcat/netboot/rh/dracut/xcatroot index 688d7f772..4d20531fa 100755 --- a/xCAT-server/share/xcat/netboot/rh/dracut/xcatroot +++ b/xCAT-server/share/xcat/netboot/rh/dracut/xcatroot @@ -67,8 +67,8 @@ if [ -r /rootimg.sfs ]; then mkdir -p $NEWROOT/rw mount --move /ro $NEWROOT/ro mount --move /rw $NEWROOT/rw -elif [ -r /rootimg.gz ]; then - [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "rootimg.gz downloaded,setting up RAM-root tmpfs...." +elif [ -r /rootimg.cpio.gz ] || [ -r /rootimg.cpio.xz ]; then + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "rootimg downloaded,setting up RAM-root tmpfs...." echo Setting up RAM-root tmpfs. if [ -z $rootlimit ];then mount -t tmpfs -o mode=755 rootfs $NEWROOT @@ -79,15 +79,23 @@ elif [ -r /rootimg.gz ]; then cd $NEWROOT [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Extracting root filesystem:" echo -n "Extracting root filesystem:" - if [ -x /bin/cpio ]; then - gzip -cd /rootimg.gz |/bin/cpio -idum - else - gzip -cd /rootimg.gz |cpio -idum + if [ -r /rootimg.cpio.gz ]; then + if [ -x /bin/cpio ]; then + gzip -cd /rootimg.cpio.gz |/bin/cpio -idum + else + gzip -cd /rootimg.cpio.gz |cpio -idum + fi + elif [ -r /rootimg.cpio.xz ]; then + if [ -x /bin/cpio ]; then + xz -cd /rootimg.cpio.xz |/bin/cpio -idum + else + xz -cd /rootimg.cpio.xz |cpio -idum + fi fi $NEWROOT/etc/init.d/localdisk [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Done...." echo Done -elif [ -r /rootimg.tgz ]; then +elif [ -r /rootimg.tar.gz ] || [ -r /rootimg.tar.xz ]; then echo Setting up RAM-root tmpfs. if [ -z $rootlimit ];then mount -t tmpfs -o mode=755 rootfs $NEWROOT @@ -97,7 +105,11 @@ elif [ -r /rootimg.tgz ]; then cd $NEWROOT echo -n "Extracting root filesystem:" - tar --selinux --xattrs-include='*' -zxvf /rootimg.tgz + if [ -r /rootimg.tar.gz ]; then + tar --selinux --xattrs-include='*' -zxvf /rootimg.tar.gz + elif [ -r /rootimg.tar.xz ]; then + tar --selinux --xattrs-include='*' -Jxvf /rootimg.tar.xz + fi $NEWROOT/etc/init.d/localdisk echo Done elif [ -r /rootimg-statelite.gz ]; then diff --git a/xCAT-server/share/xcat/netboot/rh/dracut_033/install.netboot b/xCAT-server/share/xcat/netboot/rh/dracut_033/install.netboot index e1227868b..cca462a0b 100755 --- a/xCAT-server/share/xcat/netboot/rh/dracut_033/install.netboot +++ b/xCAT-server/share/xcat/netboot/rh/dracut_033/install.netboot @@ -1,6 +1,6 @@ #!/bin/sh echo $drivers -dracut_install wget tar cpio gzip modprobe touch echo cut wc +dracut_install wget tar cpio gzip modprobe touch echo cut wc xz dracut_install grep ifconfig hostname awk egrep grep dirname expr dracut_install mount.nfs dracut_install parted mke2fs bc mkswap swapon chmod diff --git a/xCAT-server/share/xcat/netboot/rh/dracut_033/xcatroot b/xCAT-server/share/xcat/netboot/rh/dracut_033/xcatroot index 328068a32..0bc2ebcd9 100755 --- a/xCAT-server/share/xcat/netboot/rh/dracut_033/xcatroot +++ b/xCAT-server/share/xcat/netboot/rh/dracut_033/xcatroot @@ -69,8 +69,8 @@ if [ -r /rootimg.sfs ]; then mkdir -p $NEWROOT/rw mount --move /ro $NEWROOT/ro mount --move /rw $NEWROOT/rw -elif [ -r /rootimg.gz ]; then - [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "rootimg.gz downloaded,setting up RAM-root tmpfs...." +elif [ -r /rootimg.cpio.gz ] || [ -r /rootimg.cpio.xz ]; then + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "rootimg downloaded,setting up RAM-root tmpfs...." echo Setting up RAM-root tmpfs. if [ -z $rootlimit ];then mount -t tmpfs -o mode=755 rootfs $NEWROOT @@ -81,16 +81,24 @@ elif [ -r /rootimg.gz ]; then cd $NEWROOT [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Extracting root filesystem:" echo -n "Extracting root filesystem:" - if [ -x /bin/cpio ]; then - gzip -cd /rootimg.gz |/bin/cpio -idum - else - gzip -cd /rootimg.gz |cpio -idum + if [ -r /rootimg.cpio.gz ]; then + if [ -x /bin/cpio ]; then + gzip -cd /rootimg.cpio.gz |/bin/cpio -idum + else + gzip -cd /rootimg.cpio.gz |cpio -idum + fi + elif [ -r /rootimg.cpio.xz ]; then + if [ -x /bin/cpio ]; then + xz -cd /rootimg.cpio.xz |/bin/cpio -idum + else + xz -cd /rootimg.cpio.xz |cpio -idum + fi fi $NEWROOT/etc/init.d/localdisk [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Done...." echo Done -elif [ -r /rootimg.tgz ]; then - [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "rootimg.tgz downloaded,setting up RAM-root tmpfs...." +elif [ -r /rootimg.tar.gz ] || [ -r /rootimg.tar.xz ]; then + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "rootimg downloaded,setting up RAM-root tmpfs...." echo Setting up RAM-root tmpfs. if [ -z $rootlimit ];then mount -t tmpfs -o mode=755 rootfs $NEWROOT @@ -101,7 +109,11 @@ elif [ -r /rootimg.tgz ]; then cd $NEWROOT [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Extracting root filesystem:" echo -n "Extracting root filesystem:" - tar --selinux --xattrs-include='*' -zxvf /rootimg.tgz + if [ -r /rootimg.tar.gz ]; then + tar --selinux --xattrs-include='*' -zxvf /rootimg.tar.gz + elif [ -r /rootimg.tar.xz ]; then + tar --selinux --xattrs-include='*' -Jxvf /rootimg.tar.xz + fi $NEWROOT/etc/init.d/localdisk [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Done...." echo Done diff --git a/xCAT-server/share/xcat/netboot/rh/genimage b/xCAT-server/share/xcat/netboot/rh/genimage index 0879cabb9..aa13d2855 100755 --- a/xCAT-server/share/xcat/netboot/rh/genimage +++ b/xCAT-server/share/xcat/netboot/rh/genimage @@ -1606,7 +1606,7 @@ if [ -r /rootimg.sfs ]; then mount --move /ro \$NEWROOT/ro mount --move /rw \$NEWROOT/rw EOMS - print $inifile "elif [ -r /rootimg.gz ]; then\n"; + print $inifile "elif [ -r /rootimg.cpio.gz ] || [ -r /rootimg.cpio.xz ]; then\n"; print $inifile "echo Setting up RAM-root tmpfs.\n"; if ($rootlimit) { print $inifile " mount -o size=$rootlimit,mode=755 -t tmpfs rootfs \$NEWROOT\n"; @@ -1615,13 +1615,21 @@ EOMS } print $inifile " cd \$NEWROOT\n"; print $inifile " echo -n \"Extracting root filesystem:\"\n"; - print $inifile " if [ -x /bin/cpio ]; then\n"; - print $inifile " zcat /rootimg.gz |/bin/cpio -idum\n"; - print $inifile " else\n"; - print $inifile " zcat /rootimg.gz |cpio -idum\n"; + print $inifile " if [ -r /rootimg.cpio.gz ]; then\n"; + print $inifile " if [ -x /bin/cpio ]; then\n"; + print $inifile " zcat /rootimg.cpio.gz |/bin/cpio -idum\n"; + print $inifile " else\n"; + print $inifile " zcat /rootimg.cpio.gz |cpio -idum\n"; + print $inifile " fi\n"; + print $inifile " elif [ -r /rootimg.cpio.xz ]; then\n"; + print $inifile " if [ -x /bin/cpio ]; then\n"; + print $inifile " xz -cd /rootimg.cpio.xz |/bin/cpio -idum\n"; + print $inifile " else\n"; + print $inifile " xz -cd /rootimg.cpio.xz |cpio -idum\n"; + print $inifile " fi\n"; print $inifile " fi\n"; print $inifile " echo Done\n"; - print $inifile "elif [ -r /rootimg.tgz ]; then\n"; + print $inifile "elif [ -r /rootimg.tar.gz ] || [ -r /rootimg.tar.xz ]; then\n"; print $inifile " echo Setting up RAM-root tmpfs.\n"; if ($rootlimit) { @@ -1631,7 +1639,11 @@ EOMS } print $inifile " cd \$NEWROOT\n"; print $inifile " echo -n \"Extracting root filesystem:\"\n"; - print $inifile " tar --selinux --xattrs-include='*' -zxvf /rootimg.tgz\n"; + print $inifile " if [ -r /rootimg.tar.gz ]; then\n"; + print $inifile " tar --selinux --xattrs-include='*' -zxvf /rootimg.tar.gz\n"; + print $inifile " elif [ -r /rootimg.tar.xz ]; then\n"; + print $inifile " tar --selinux --xattrs-include='*' -Jxvf /rootimg.tar.xz\n"; + print $inifile " fi\n"; print $inifile " echo Done\n"; print $inifile "else\n"; print $inifile " echo -n Failed to download image, panicing in 5...\n"; @@ -1708,7 +1720,7 @@ EOMS } # add rsync for statelite - foreach ("bin/cpio", "sbin/nash", "sbin/busybox.anaconda", "sbin/rmmod", "bin/bash", "usr/sbin/chroot", "sbin/mount.nfs", "usr/bin/rsync", "usr/bin/wc", "usr/bin/gzip", "usr/bin/tar") { + foreach ("bin/cpio", "sbin/nash", "sbin/busybox.anaconda", "sbin/rmmod", "bin/bash", "usr/sbin/chroot", "sbin/mount.nfs", "usr/bin/rsync", "usr/bin/wc", "usr/bin/xz", "usr/bin/gzip", "usr/bin/tar") { getlibs($_); push @filestoadd, $_; } diff --git a/xCAT-server/share/xcat/netboot/sles/compute.pkglist b/xCAT-server/share/xcat/netboot/sles/compute.pkglist index cc5a5fd87..a3165f834 100644 --- a/xCAT-server/share/xcat/netboot/sles/compute.pkglist +++ b/xCAT-server/share/xcat/netboot/sles/compute.pkglist @@ -13,3 +13,4 @@ timezone ntp tar gzip +xz diff --git a/xCAT-server/share/xcat/netboot/sles/compute.sles11.pkglist b/xCAT-server/share/xcat/netboot/sles/compute.sles11.pkglist index e284622f1..8787c0177 100644 --- a/xCAT-server/share/xcat/netboot/sles/compute.sles11.pkglist +++ b/xCAT-server/share/xcat/netboot/sles/compute.sles11.pkglist @@ -19,3 +19,4 @@ bc ntp gzip tar +xz diff --git a/xCAT-server/share/xcat/netboot/sles/compute.sles11.ppc64.pkglist b/xCAT-server/share/xcat/netboot/sles/compute.sles11.ppc64.pkglist index 26e735587..3f9ffbed3 100644 --- a/xCAT-server/share/xcat/netboot/sles/compute.sles11.ppc64.pkglist +++ b/xCAT-server/share/xcat/netboot/sles/compute.sles11.ppc64.pkglist @@ -21,3 +21,4 @@ procps ntp gzip tar +xz diff --git a/xCAT-server/share/xcat/netboot/sles/compute.sles12.ppc64le.pkglist b/xCAT-server/share/xcat/netboot/sles/compute.sles12.ppc64le.pkglist index 1eebf1414..d0b4c3a0e 100644 --- a/xCAT-server/share/xcat/netboot/sles/compute.sles12.ppc64le.pkglist +++ b/xCAT-server/share/xcat/netboot/sles/compute.sles12.ppc64le.pkglist @@ -41,3 +41,4 @@ udev kernel-default kernel-firmware adaptec-firmware +xz diff --git a/xCAT-server/share/xcat/netboot/sles/compute.sles12.x86_64.pkglist b/xCAT-server/share/xcat/netboot/sles/compute.sles12.x86_64.pkglist index 1eebf1414..d0b4c3a0e 100644 --- a/xCAT-server/share/xcat/netboot/sles/compute.sles12.x86_64.pkglist +++ b/xCAT-server/share/xcat/netboot/sles/compute.sles12.x86_64.pkglist @@ -41,3 +41,4 @@ udev kernel-default kernel-firmware adaptec-firmware +xz diff --git a/xCAT-server/share/xcat/netboot/sles/dracut_033/install.netboot b/xCAT-server/share/xcat/netboot/sles/dracut_033/install.netboot index e1227868b..cca462a0b 100755 --- a/xCAT-server/share/xcat/netboot/sles/dracut_033/install.netboot +++ b/xCAT-server/share/xcat/netboot/sles/dracut_033/install.netboot @@ -1,6 +1,6 @@ #!/bin/sh echo $drivers -dracut_install wget tar cpio gzip modprobe touch echo cut wc +dracut_install wget tar cpio gzip modprobe touch echo cut wc xz dracut_install grep ifconfig hostname awk egrep grep dirname expr dracut_install mount.nfs dracut_install parted mke2fs bc mkswap swapon chmod diff --git a/xCAT-server/share/xcat/netboot/sles/dracut_033/xcatroot b/xCAT-server/share/xcat/netboot/sles/dracut_033/xcatroot index 91b6a3aa4..acd7b3ebf 100755 --- a/xCAT-server/share/xcat/netboot/sles/dracut_033/xcatroot +++ b/xCAT-server/share/xcat/netboot/sles/dracut_033/xcatroot @@ -67,8 +67,8 @@ if [ -r /rootimg.sfs ]; then mkdir -p $NEWROOT/rw mount --move /ro $NEWROOT/ro mount --move /rw $NEWROOT/rw -elif [ -r /rootimg.gz ]; then - [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "rootimg.gz downloaded,setting up RAM-root tmpfs...." +elif [ -r /rootimg.cpio.gz ] || [ -r /rootimg.cpio.xz ]; then + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "rootimg downloaded,setting up RAM-root tmpfs...." echo Setting up RAM-root tmpfs. if [ -z $rootlimit ];then mount -t tmpfs -o mode=755 rootfs $NEWROOT @@ -79,16 +79,24 @@ elif [ -r /rootimg.gz ]; then cd $NEWROOT [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Extracting root filesystem:" echo -n "Extracting root filesystem:" - if [ -x /bin/cpio ]; then - gzip -cd /rootimg.gz |/bin/cpio -idum - else - gzip -cd /rootimg.gz |cpio -idum + if [ -r /rootimg.cpio.gz ]; then + if [ -x /bin/cpio ]; then + gzip -cd /rootimg.cpio.gz |/bin/cpio -idum + else + gzip -cd /rootimg.cpio.gz |cpio -idum + fi + elif [ -r /rootimg.cpio.xz ]; then + if [ -x /bin/cpio ]; then + xz -cd /rootimg.cpio.xz |/bin/cpio -idum + else + xz -cd /rootimg.cpio.xz |cpio -idum + fi fi $NEWROOT/etc/init.d/localdisk [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Done...." echo Done -elif [ -r /rootimg.tgz ]; then - [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "rootimg.tgz downloaded,setting up RAM-root tmpfs...." +elif [ -r /rootimg.tar.gz ] || [ -r /rootimg.tar.xz ]; then + [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "rootimg downloaded,setting up RAM-root tmpfs...." echo Setting up RAM-root tmpfs. if [ -z $rootlimit ];then mount -t tmpfs -o mode=755 rootfs $NEWROOT @@ -99,7 +107,11 @@ elif [ -r /rootimg.tgz ]; then cd $NEWROOT [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Extracting root filesystem:" echo -n "Extracting root filesystem:" - tar --selinux --xattrs-include='*' -zxvf /rootimg.tgz + if [ -r /rootimg.tar.gz ]; then + tar --selinux --xattrs-include='*' -zxvf /rootimg.tar.gz + elif [ -r /rootimg.tar.xz ]; then + tar --selinux --xattrs-include='*' -Jxvf /rootimg.tar.xz + fi $NEWROOT/etc/init.d/localdisk [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Done...." echo Done diff --git a/xCAT-server/share/xcat/netboot/sles/genimage b/xCAT-server/share/xcat/netboot/sles/genimage index 5b894e37a..3fbe3c6c2 100755 --- a/xCAT-server/share/xcat/netboot/sles/genimage +++ b/xCAT-server/share/xcat/netboot/sles/genimage @@ -1624,7 +1624,7 @@ if [ -r /rootimg.sfs ]; then mount --move /ro /sysroot/ro mount --move /rw /sysroot/rw EOMS - print $inifile "elif [ -r /rootimg.gz ]; then\n"; + print $inifile "elif [ -r /rootimg.cpio.gz ] || [ -r /rootimg.cpio.xz ]; then\n"; print $inifile "echo Setting up RAM-root tmpfs.\n"; if ($rootlimit) { print $inifile " mount -o size=$rootlimit,mode=755 -t tmpfs rootfs \$NEWROOT\n"; @@ -1633,13 +1633,21 @@ EOMS } print $inifile " cd /sysroot\n"; print $inifile " echo -n \"Extracting root filesystem:\"\n"; - print $inifile " if [ -x /bin/cpio ]; then\n"; - print $inifile " zcat /rootimg.gz |/bin/cpio -idum\n"; - print $inifile " else\n"; - print $inifile " zcat /rootimg.gz |cpio -idum\n"; + print $inifile " if [ -r /rootimg.cpio.gz ]; then\n"; + print $inifile " if [ -x /bin/cpio ]; then\n"; + print $inifile " zcat /rootimg.cpio.gz |/bin/cpio -idum\n"; + print $inifile " else\n"; + print $inifile " zcat /rootimg.cpio.gz |cpio -idum\n"; + print $inifile " fi\n"; + print $inifile " elif [ -r /rootimg.cpio.xz ]; then\n"; + print $inifile " if [ -x /bin/cpio ]; then\n"; + print $inifile " xz -cd /rootimg.cpio.xz |/bin/cpio -idum\n"; + print $inifile " else\n"; + print $inifile " xz -cd /rootimg.cpio.xz |cpio -idum\n"; + print $inifile " fi\n"; print $inifile " fi\n"; print $inifile " echo Done\n"; - print $inifile "elif [ -r /rootimg.tgz ]; then\n"; + print $inifile "elif [ -r /rootimg.tar.gz ] || [ -r /rootimg.tar.xz ]; then\n"; print $inifile " echo Setting up RAM-root tmpfs.\n"; if ($rootlimit) { @@ -1649,7 +1657,11 @@ EOMS } print $inifile " cd \$NEWROOT\n"; print $inifile " echo -n \"Extracting root filesystem:\"\n"; - print $inifile " tar --selinux --xattrs-include='*' -zxvf /rootimg.tgz\n"; + print $inifile " if [ -r /rootimg.tar.gz ]; then\n"; + print $inifile " tar --selinux --xattrs-include='*' -zxvf /rootimg.tar.gz\n"; + print $inifile " elif [ -r /rootimg.tar.xz ]; then\n"; + print $inifile " tar --selinux --xattrs-include='*' -Jxvf /rootimg.tar.xz\n"; + print $inifile " fi\n"; print $inifile " echo Done\n"; print $inifile "else\n"; print $inifile " echo -n Failed to download image, panicing in 5...\n"; @@ -1758,7 +1770,7 @@ EOMS } } if ($mode eq "statelite") { - foreach ("sbin/ifconfig", "usr/bin/clear", "usr/bin/touch", "bin/hostname", "usr/bin/egrep", "bin/ln", "bin/ls", "usr/bin/dirname", "usr/bin/expr", "usr/bin/chroot", "usr/bin/grep", "bin/cpio", "bin/sleep", "bin/mount", "bin/umount", "sbin/dhcpcd", "bin/bash", "sbin/insmod", "bin/mkdir", "bin/mknod", "sbin/ip", "bin/cat", "usr/bin/awk", "usr/bin/wget", "bin/cp", "usr/bin/cpio", "usr/bin/zcat", "usr/bin/gzip", "lib/mkinitrd/bin/run-init", "usr/bin/uniq", "usr/bin/sed", "usr/bin/wc", "bin/sed", "sbin/udevd", "usr/bin/readlink", "usr/sbin/parted", "sbin/mke2fs", "sbin/mkswap", "sbin/swapon", "bin/chmod", "usr/bin/bc", "usr/bin/gzip", "usr/bin/tar") { + foreach ("sbin/ifconfig", "usr/bin/clear", "usr/bin/touch", "bin/hostname", "usr/bin/egrep", "bin/ln", "bin/ls", "usr/bin/dirname", "usr/bin/expr", "usr/bin/chroot", "usr/bin/grep", "bin/cpio", "bin/sleep", "bin/mount", "bin/umount", "sbin/dhcpcd", "bin/bash", "sbin/insmod", "bin/mkdir", "bin/mknod", "sbin/ip", "bin/cat", "usr/bin/awk", "usr/bin/wget", "bin/cp", "usr/bin/cpio", "usr/bin/zcat", "usr/bin/gzip", "lib/mkinitrd/bin/run-init", "usr/bin/uniq", "usr/bin/sed", "usr/bin/wc", "bin/sed", "sbin/udevd", "usr/bin/readlink", "usr/sbin/parted", "sbin/mke2fs", "sbin/mkswap", "sbin/swapon", "bin/chmod", "usr/bin/bc", "usr/bin/xz", "usr/bin/gzip", "usr/bin/tar") { getlibs($_); push @filestoadd, $_; } @@ -1770,7 +1782,7 @@ EOMS } } else { - foreach ("sbin/ifconfig", "usr/bin/clear", "usr/bin/touch", "usr/bin/grep", "usr/bin/egrep", "bin/cpio", "bin/sleep", "bin/mount", "sbin/dhcpcd", "bin/bash", "sbin/insmod", "bin/mkdir", "bin/mknod", "sbin/ip", "bin/cat", "usr/bin/awk", "usr/bin/wget", "bin/cp", "usr/bin/cpio", "usr/bin/zcat", "usr/bin/gzip", "lib/mkinitrd/bin/run-init", "usr/bin/uniq", "usr/bin/sed", "sbin/udevd", "usr/bin/readlink", "usr/bin/expr", "usr/sbin/parted", "sbin/mke2fs", "sbin/mkswap", "sbin/swapon", "bin/chmod", "usr/bin/bc", "usr/bin/gzip", "usr/bin/tar") { + foreach ("sbin/ifconfig", "usr/bin/clear", "usr/bin/touch", "usr/bin/grep", "usr/bin/egrep", "bin/cpio", "bin/sleep", "bin/mount", "sbin/dhcpcd", "bin/bash", "sbin/insmod", "bin/mkdir", "bin/mknod", "sbin/ip", "bin/cat", "usr/bin/awk", "usr/bin/wget", "bin/cp", "usr/bin/cpio", "usr/bin/zcat", "usr/bin/gzip", "lib/mkinitrd/bin/run-init", "usr/bin/uniq", "usr/bin/sed", "sbin/udevd", "usr/bin/readlink", "usr/bin/expr", "usr/sbin/parted", "sbin/mke2fs", "sbin/mkswap", "sbin/swapon", "bin/chmod", "usr/bin/bc", "usr/bin/xz", "usr/bin/gzip", "usr/bin/tar") { getlibs($_); push @filestoadd, $_; } diff --git a/xCAT-server/share/xcat/netboot/ubuntu/compute.pkglist b/xCAT-server/share/xcat/netboot/ubuntu/compute.pkglist index c3839a534..cac5d706a 100644 --- a/xCAT-server/share/xcat/netboot/ubuntu/compute.pkglist +++ b/xCAT-server/share/xcat/netboot/ubuntu/compute.pkglist @@ -14,3 +14,4 @@ busybox-static gawk tar gzip +xz-utils diff --git a/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu14.04.4.ppc64el.pkglist b/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu14.04.4.ppc64el.pkglist index 730382c86..1dea61ecb 100644 --- a/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu14.04.4.ppc64el.pkglist +++ b/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu14.04.4.ppc64el.pkglist @@ -15,3 +15,4 @@ gawk dnsutils tar gzip +xz-utils diff --git a/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu14.04.4.x86_64.pkglist b/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu14.04.4.x86_64.pkglist index 730382c86..1dea61ecb 100644 --- a/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu14.04.4.x86_64.pkglist +++ b/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu14.04.4.x86_64.pkglist @@ -15,3 +15,4 @@ gawk dnsutils tar gzip +xz-utils diff --git a/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu14.04.pkglist b/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu14.04.pkglist index b1357ac5f..6e3b04dc2 100644 --- a/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu14.04.pkglist +++ b/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu14.04.pkglist @@ -14,3 +14,4 @@ busybox-static gawk tar gzip +xz-utils diff --git a/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu16.04.pkglist b/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu16.04.pkglist index d3e1da021..77dffd96f 100644 --- a/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu16.04.pkglist +++ b/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu16.04.pkglist @@ -14,3 +14,4 @@ busybox-static gawk tar gzip +xz-utils diff --git a/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu16.04.ppc64el.pkglist b/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu16.04.ppc64el.pkglist index 8276befc2..df556b887 100644 --- a/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu16.04.ppc64el.pkglist +++ b/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu16.04.ppc64el.pkglist @@ -16,3 +16,4 @@ gawk dnsutils tar gzip +xz-utils diff --git a/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu16.04.x86_64.pkglist b/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu16.04.x86_64.pkglist index 8276befc2..df556b887 100644 --- a/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu16.04.x86_64.pkglist +++ b/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu16.04.x86_64.pkglist @@ -16,3 +16,4 @@ gawk dnsutils tar gzip +xz-utils diff --git a/xCAT-server/share/xcat/netboot/ubuntu/dracut/install.netboot b/xCAT-server/share/xcat/netboot/ubuntu/dracut/install.netboot index 10f1c7320..372fa4df8 100755 --- a/xCAT-server/share/xcat/netboot/ubuntu/dracut/install.netboot +++ b/xCAT-server/share/xcat/netboot/ubuntu/dracut/install.netboot @@ -1,6 +1,6 @@ #!/bin/sh echo $drivers -dracut_install wget tar cpio gzip dash modprobe touch echo cut wc +dracut_install wget tar cpio gzip dash modprobe touch echo cut wc xz dracut_install grep ifconfig hostname awk egrep grep dirname expr dracut_install mount.nfs inst "$moddir/xcatroot" "/sbin/xcatroot" diff --git a/xCAT-server/share/xcat/netboot/ubuntu/dracut/xcatroot b/xCAT-server/share/xcat/netboot/ubuntu/dracut/xcatroot index 073ec1e4b..67f40c8ed 100755 --- a/xCAT-server/share/xcat/netboot/ubuntu/dracut/xcatroot +++ b/xCAT-server/share/xcat/netboot/ubuntu/dracut/xcatroot @@ -39,23 +39,35 @@ if [ -r /rootimg.sfs ]; then mkdir -p $NEWROOT/rw mount --move /ro $NEWROOT/ro mount --move /rw $NEWROOT/rw -elif [ -r /rootimg.gz ]; then +elif [ -r /rootimg.cpio.gz ] || [ -r /rootimg.cpio.xz ]; then echo Setting up RAM-root tmpfs. mount -t tmpfs -o mode=755 rootfs $NEWROOT cd $NEWROOT echo -n "Extracting root filesystem:" - if [ -x /bin/cpio ]; then - gzip -cd /rootimg.gz |/bin/cpio -idum - else - gzip -cd /rootimg.gz |cpio -idum + if [ -r /rootimg.cpio.gz ]; then + if [ -x /bin/cpio ]; then + gzip -cd /rootimg.cpio.gz |/bin/cpio -idum + else + gzip -cd /rootimg.cpio.gz |cpio -idum + fi + elif [ -r /rootimg.cpio.xz ]; then + if [ -x /bin/cpio ]; then + xz -cd /rootimg.cpio.xz |/bin/cpio -idum + else + xz -cd /rootimg.cpio.xz |cpio -idum + fi fi echo Done -elif [ -r /rootimg.tgz ]; then +elif [ -r /rootimg.tar.gz ] || [ -r /rootimg.tar.xz ]; then echo Setting up RAM-root tmpfs. mount -t tmpfs -o mode=755 rootfs $NEWROOT cd $NEWROOT echo -n "Extracting root filesystem:" - tar --selinux --xattrs-include='*' -zxvf /rootimg.tgz + if [ -r /rootimg.tar.gz ]; then + tar --selinux --xattrs-include='*' -zxvf /rootimg.tar.gz + elif [ -r /rootimg.tar.xz ]; then + tar --selinux --xattrs-include='*' -Jxvf /rootimg.tar.xz + fi echo Done elif [ -r /rootimg-statelite.gz ]; then echo Setting up RAM-root tmpfs for statelite mode. diff --git a/xCAT-server/share/xcat/netboot/ubuntu/genimage b/xCAT-server/share/xcat/netboot/ubuntu/genimage index 870c13b73..8934e44b1 100755 --- a/xCAT-server/share/xcat/netboot/ubuntu/genimage +++ b/xCAT-server/share/xcat/netboot/ubuntu/genimage @@ -1441,8 +1441,8 @@ if [ -r /rootimg.sfs ]; then mount --move /ro \$NEWROOT/ro mount --move /rw \$NEWROOT/rw EOMS - print $inifile "elif [ -r /rootimg.gz ]; then\n"; - print $inifile " ([ \"\$xcatdebugmode\" = \"1\" ] || [ \"\$xcatdebugmode\" = \"2\" ]) && logger -t xcat -p debug \"rootimg.gz downloaded,setting up RAM-root tmpfs...\"\n"; + print $inifile "elif [ -r /rootimg.cpio.gz ] || [ -r /rootimg.cpio.xz ]; then\n"; + print $inifile " ([ \"\$xcatdebugmode\" = \"1\" ] || [ \"\$xcatdebugmode\" = \"2\" ]) && logger -t xcat -p debug \"rootimg downloaded,setting up RAM-root tmpfs...\"\n"; print $inifile " echo Setting up RAM-root tmpfs.\n"; if ($rootlimit) { print $inifile " mount -o \"size=$rootlimit,mode=755\" -t tmpfs rootfs \$NEWROOT\n"; @@ -1452,15 +1452,23 @@ EOMS print $inifile " cd \$NEWROOT\n"; print $inifile " ([ \"\$xcatdebugmode\" = \"1\" ] || [ \"\$xcatdebugmode\" = \"2\" ]) && logger -t xcat -p debug \"Extracting root filesystem:\"\n"; print $inifile " echo -n \"Extracting root filesystem:\"\n"; - print $inifile " if [ -x /bin/cpio ]; then\n"; - print $inifile " zcat /rootimg.gz |/bin/cpio -idum\n"; - print $inifile " else\n"; - print $inifile " zcat /rootimg.gz |cpio -idum\n"; + print $inifile " if [ -r /rootimg.cpio.gz ]; then\n"; + print $inifile " if [ -x /bin/cpio ]; then\n"; + print $inifile " zcat /rootimg.cpio.gz |/bin/cpio -idum\n"; + print $inifile " else\n"; + print $inifile " zcat /rootimg.cpio.gz |cpio -idum\n"; + print $inifile " fi\n"; + print $inifile " elif [ -r /rootimg.cpio.xz ]; then\n"; + print $inifile " if [ -x /bin/cpio ]; then\n"; + print $inifile " xz -cd /rootimg.cpio.xz |/bin/cpio -idum\n"; + print $inifile " else\n"; + print $inifile " xz -cd /rootimg.cpio.xz |cpio -idum\n"; + print $inifile " fi\n"; print $inifile " fi\n"; print $inifile " ([ \"\$xcatdebugmode\" = \"1\" ] || [ \"\$xcatdebugmode\" = \"2\" ]) && logger -t xcat -p debug \"Done...\"\n"; print $inifile " echo Done\n"; - print $inifile "elif [ -r /rootimg.tgz ]; then\n"; - print $inifile " ([ \"\$xcatdebugmode\" = \"1\" ] || [ \"\$xcatdebugmode\" = \"2\" ]) && logger -t xcat -p debug \"rootimg.tgz downloaded,setting up RAM-root tmpfs...\"\n"; + print $inifile "elif [ -r /rootimg.tar.gz ] || [ -r /rootimg.tar.xz ]; then\n"; + print $inifile " ([ \"\$xcatdebugmode\" = \"1\" ] || [ \"\$xcatdebugmode\" = \"2\" ]) && logger -t xcat -p debug \"rootimg downloaded,setting up RAM-root tmpfs...\"\n"; print $inifile " echo Setting up RAM-root tmpfs.\n"; if ($rootlimit) { @@ -1471,7 +1479,11 @@ EOMS print $inifile " cd \$NEWROOT\n"; print $inifile " ([ \"\$xcatdebugmode\" = \"1\" ] || [ \"\$xcatdebugmode\" = \"2\" ]) && logger -t xcat -p debug \"Extracting root filesystem:\"\n"; print $inifile " echo -n \"Extracting root filesystem:\"\n"; - print $inifile " tar --selinux --xattrs-include='*' -zxvf /rootimg.tgz\n"; + print $inifile " if [ -r /rootimg.tar.gz ]; then\n"; + print $inifile " tar --selinux --xattrs-include='*' -zxvf /rootimg.tar.gz\n"; + print $inifile " elif [ -r /rootimg.tar.xz ]; then\n"; + print $inifile " tar --selinux --xattrs-include='*' -Jxvf /rootimg.tar.xz\n"; + print $inifile " fi\n"; print $inifile " ([ \"\$xcatdebugmode\" = \"1\" ] || [ \"\$xcatdebugmode\" = \"2\" ]) && logger -t xcat -p debug \"Done...\"\n"; print $inifile " echo Done\n"; print $inifile "else\n"; @@ -1612,7 +1624,7 @@ EOMS } # add rsync for statelite - foreach ("usr/bin/dig", "bin/busybox", "bin/bash", "sbin/mount.nfs", "usr/bin/rsync", "sbin/insmod", "sbin/udevd", "sbin/udevadm", "sbin/modprobe", "sbin/blkid", "sbin/depmod", "usr/bin/wget", "usr/bin/gzip", "usr/bin/tar") { + foreach ("usr/bin/dig", "bin/busybox", "bin/bash", "sbin/mount.nfs", "usr/bin/rsync", "sbin/insmod", "sbin/udevd", "sbin/udevadm", "sbin/modprobe", "sbin/blkid", "sbin/depmod", "usr/bin/wget", "usr/bin/xz", "usr/bin/gzip", "usr/bin/tar") { getlibs($_); push @filestoadd, $_; } From c70913262d51b297eb04e59873f1bb75101ef1b4 Mon Sep 17 00:00:00 2001 From: immarvin Date: Thu, 11 Aug 2016 05:11:03 -0400 Subject: [PATCH 025/106] fix issue [DEV] Diskless boot failed for rhel7.3 because selinux disabled. #1666 ; disable selinux in the rootimg --- .../share/xcat/netboot/rh/compute.rhels7.ppc64.postinstall | 4 ++++ .../share/xcat/netboot/rh/compute.rhels7.x86_64.postinstall | 6 ++++++ xCAT-server/share/xcat/netboot/rh/service.postinstall | 6 ++++++ 3 files changed, 16 insertions(+) diff --git a/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64.postinstall b/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64.postinstall index dc423d20d..0819752bb 100755 --- a/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64.postinstall +++ b/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64.postinstall @@ -32,6 +32,10 @@ END #cons:12345:respawn:/sbin/smart_agetty -L 38400 console echo "co:2345:respawn:/sbin/agetty -L 38400 console" >> $installroot/etc/inittab +#-- Disable SELinux in the rootimg +#-- Redhat 7.3 will install selinux-policy and selinux is enabled by default +#-- Need to disable selinux, otherwise, the booting will hang on "Loading selinux policy" +sed -i 's/SELINUX=enforcing\|permissive/SELINUX=disabled/' $installroot/etc/selinux/config #-- Example of booted image versioning #-- We want to know, with what configuration (version of the image) each node was booted. diff --git a/xCAT-server/share/xcat/netboot/rh/compute.rhels7.x86_64.postinstall b/xCAT-server/share/xcat/netboot/rh/compute.rhels7.x86_64.postinstall index 01bc23cb4..b8eee319e 100755 --- a/xCAT-server/share/xcat/netboot/rh/compute.rhels7.x86_64.postinstall +++ b/xCAT-server/share/xcat/netboot/rh/compute.rhels7.x86_64.postinstall @@ -32,6 +32,12 @@ END #echo "co:2345:respawn:/sbin/agetty -L 38400 console" >> $installroot/etc/inittab +#-- Disable SELinux in the rootimg +#-- Redhat 7.3 will install selinux-policy and selinux is enabled by default +#-- Need to disable selinux, otherwise, the booting will hang on "Loading selinux policy" +sed -i 's/SELINUX=enforcing\|permissive/SELINUX=disabled/' $installroot/etc/selinux/config + + #-- Example of booted image versioning #-- We want to know, with what configuration (version of the image) each node was booted. #-- Hence, we keep image definition files and postscripts in CVS. During image generation we create file /etc/IMGVERSION and fill it with CVS "$Id$" of files with image definition (.pkglist, .exlist, .repolist, .postinstall). Then, during boot, each "CVS enabled" postscript (see /install/postscripts/cvs_template.sh and /install/postscripts/cvs_template.pl) adds one line to /etc/IMGVERSION. Then you can determine in any time what image you are running and what postscipts in which versions were run. diff --git a/xCAT-server/share/xcat/netboot/rh/service.postinstall b/xCAT-server/share/xcat/netboot/rh/service.postinstall index 5fbd8e26a..86e295e45 100755 --- a/xCAT-server/share/xcat/netboot/rh/service.postinstall +++ b/xCAT-server/share/xcat/netboot/rh/service.postinstall @@ -35,6 +35,12 @@ workdir=$5 echo "co:2345:respawn:/sbin/agetty -L 38400 console" >> $installroot/etc/inittab + +#-- Disable SELinux in the rootimg +#-- Redhat 7.3 will install selinux-policy and selinux is enabled by default +#-- Need to disable selinux, otherwise, the booting will hang on "Loading selinux policy" +sed -i 's/SELINUX=enforcing\|permissive/SELINUX=disabled/' $installroot/etc/selinux/config + #-- Example of booted image versioning #-- We want to know, with what configuration (version of the image) each node was booted. #-- Hence, we keep image definition files and postscripts in CVS. During image generation we create file /etc/IMGVERSION and fill it with CVS "$Id$" of files with image definition (.pkglist, .exlist, .repolist, .postinstall). Then, during boot, each "CVS enabled" postscript (see /install/postscripts/cvs_template.sh and /install/postscripts/cvs_template.pl) adds one line to /etc/IMGVERSION. Then you can determine in any time what image you are running and what postscipts in which versions were run. From 672b7113d7db057943254447a6d0295087cc634a Mon Sep 17 00:00:00 2001 From: Casandra Qiu Date: Thu, 11 Aug 2016 11:35:42 -0400 Subject: [PATCH 026/106] CUDA8 support on rhel7.2 and rhel7.3 --- .../xcat/install/rh/cudafull.rhels7.ppc64le.pkglist | 2 +- .../xcat/install/rh/cudaruntime.rhels7.ppc64le.pkglist | 6 +++++- .../share/xcat/netboot/rh/compute.rhels7.ppc64.pkglist | 3 +++ .../netboot/rh/cudafull.rhels7.ppc64le.otherpkgs.pkglist | 2 +- .../rh/cudaruntime.rhels7.ppc64le.otherpkgs.pkglist | 6 +++++- xCAT/postscripts/config_cuda | 9 ++++----- 6 files changed, 19 insertions(+), 9 deletions(-) diff --git a/xCAT-server/share/xcat/install/rh/cudafull.rhels7.ppc64le.pkglist b/xCAT-server/share/xcat/install/rh/cudafull.rhels7.ppc64le.pkglist index b08d9ac4d..c7f35565a 100644 --- a/xCAT-server/share/xcat/install/rh/cudafull.rhels7.ppc64le.pkglist +++ b/xCAT-server/share/xcat/install/rh/cudafull.rhels7.ppc64le.pkglist @@ -1,6 +1,6 @@ #INCLUDE:compute.rhels7.pkglist# -#For Cuda 7.5 +#For Cuda kernel-devel gcc pciutils diff --git a/xCAT-server/share/xcat/install/rh/cudaruntime.rhels7.ppc64le.pkglist b/xCAT-server/share/xcat/install/rh/cudaruntime.rhels7.ppc64le.pkglist index 1efe75819..a48175537 100644 --- a/xCAT-server/share/xcat/install/rh/cudaruntime.rhels7.ppc64le.pkglist +++ b/xCAT-server/share/xcat/install/rh/cudaruntime.rhels7.ppc64le.pkglist @@ -1,9 +1,13 @@ #INCLUDE:compute.rhels7.pkglist# -#For Cuda 7.5 +#For Cuda kernel-devel gcc pciutils dkms +#To install cuda-runtime, need to specify the version +#if want to install cuda-runtime-8-0, uncomment it, +#then comment out cuda-runtime-7-5 +#cuda-runtime-8-0 cuda-runtime-7-5 diff --git a/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64.pkglist b/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64.pkglist index 2a7c348d3..6c101ad23 100644 --- a/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64.pkglist +++ b/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64.pkglist @@ -27,3 +27,6 @@ net-tools gzip tar xz +grub2 +grub2-tools +bzip2 diff --git a/xCAT-server/share/xcat/netboot/rh/cudafull.rhels7.ppc64le.otherpkgs.pkglist b/xCAT-server/share/xcat/netboot/rh/cudafull.rhels7.ppc64le.otherpkgs.pkglist index bbb7cc418..01f740b46 100644 --- a/xCAT-server/share/xcat/netboot/rh/cudafull.rhels7.ppc64le.otherpkgs.pkglist +++ b/xCAT-server/share/xcat/netboot/rh/cudafull.rhels7.ppc64le.otherpkgs.pkglist @@ -1,5 +1,5 @@ -#For Cuda 7.5 +#For Cuda kernel-devel gcc pciutils diff --git a/xCAT-server/share/xcat/netboot/rh/cudaruntime.rhels7.ppc64le.otherpkgs.pkglist b/xCAT-server/share/xcat/netboot/rh/cudaruntime.rhels7.ppc64le.otherpkgs.pkglist index 8a5acb857..12c60f80a 100644 --- a/xCAT-server/share/xcat/netboot/rh/cudaruntime.rhels7.ppc64le.otherpkgs.pkglist +++ b/xCAT-server/share/xcat/netboot/rh/cudaruntime.rhels7.ppc64le.otherpkgs.pkglist @@ -1,8 +1,12 @@ -#For Cuda 7.5 +#For Cuda kernel-devel gcc pciutils dkms +#To install cuda-runtime, need to specify the version +#if want to install cuda-runtime-8-0, uncomment it, +#then comment out cuda-runtime-7-5 +#cuda-runtime-8-0 cuda-runtime-7-5 diff --git a/xCAT/postscripts/config_cuda b/xCAT/postscripts/config_cuda index 42d98b3b9..db4ee9fb8 100755 --- a/xCAT/postscripts/config_cuda +++ b/xCAT/postscripts/config_cuda @@ -1,8 +1,7 @@ #!/bin/sh -# set the paths required for cuda7.5 -CUDA_VER="cuda-7.5" -FILENAME="/etc/profile.d/xcat-${CUDA_VER}.sh" +# set the paths required for cuda +FILENAME="/etc/profile.d/xcat-cuda.sh" -echo "export PATH=/usr/local/${CUDA_VER}/bin:\$PATH" > ${FILENAME} -echo "export LD_LIBRARY_PATH=/usr/local/${CUDA_VER}/lib64:\$LD_LIBRARY_PATH" >> ${FILENAME} +echo "export PATH=/usr/local/cuda/bin:\$PATH" > ${FILENAME} +echo "export LD_LIBRARY_PATH=/usr/local/cuda/lib64:\$LD_LIBRARY_PATH" >> ${FILENAME} From c6684895eb2a8ab73b440a44444fcd351f204a23 Mon Sep 17 00:00:00 2001 From: XuWei Date: Thu, 11 Aug 2016 22:13:33 -0400 Subject: [PATCH 027/106] Fix xcatprobe xcatmn(hierarchy) issue --- xCAT-probe/subcmds/xcatmn | 226 +++++++++++++++++++++++++------------- 1 file changed, 152 insertions(+), 74 deletions(-) diff --git a/xCAT-probe/subcmds/xcatmn b/xCAT-probe/subcmds/xcatmn index 0b72e8886..1744e3bf6 100755 --- a/xCAT-probe/subcmds/xcatmn +++ b/xCAT-probe/subcmds/xcatmn @@ -49,7 +49,7 @@ Description: Options: -h : Get usage information of $program_name -V : Output more information for debug - -i : Required. Specify the network interface name of provision network + -i : Required. Specify the network interface name of provision network on Management Node "; @@ -308,11 +308,21 @@ sub do_main_job { } if ($is_sn) { - my $mountoutput = `mount | grep '$masteripinsite' | grep '$installdir'`; + my $mountoutput = `mount | grep '$installdir'`; chomp($mountoutput); + my $mountip; + if ($mountoutput =~ /(.+):$installdir on $installdir /) { + my $mountsource = $1; + if (xCAT::NetworkUtils->isIpaddr($mountsource)) { + $mountip = $mountsource; + } else { + $mountip = xCAT::NetworkUtils->getipaddr($mountsource); + } + } + $msg = "installdir $installdir is mounted on from the Management Node"; - if ($mountoutput =~ /$masteripinsite:$installdir on $installdir/) { + if ($mountip eq $masteripinsite) { probe_utils->send_msg($outputtarget, "o", "$msg"); } else { @@ -330,11 +340,21 @@ sub do_main_job { } if ($is_sn) { - my $mountoutput = `mount | grep '$masteripinsite' | grep '$tftpdir'`; + my $mountoutput = `mount | grep '$tftpdir'`; chomp($mountoutput); + my $mountip; + if ($mountoutput =~ /(.+):$tftpdir on $tftpdir /) { + my $mountsource = $1; + if (xCAT::NetworkUtils->isIpaddr($mountsource)) { + $mountip = $mountsource; + } else { + $mountip = xCAT::NetworkUtils->getipaddr($mountsource); + } + } + $msg = "tftpdir $tftpdir is mounted on from the Management Node"; - if ($mountoutput =~ /$masteripinsite:$tftpdir on $tftpdir/) { + if ($mountip eq $masteripinsite) { probe_utils->send_msg($outputtarget, "o", "$msg"); } else { @@ -599,59 +619,89 @@ sub do_main_job { my $rc = 0; my $msg = "DHCP service is ready on $serverip"; + { #very important brace to create a block - my $tmp = `chdef xcatmntest groups=all ip=$serverip mac=aa:aa:aa:aa:aa:aa`; - if ($?) { - returncmdoutput($tmp, $outputtarget) if ($verbose); - probe_utils->send_msg($outputtarget, "d", "Simulate a node by chdef failed") if ($verbose); - $rc = 1; - last; + my @snlist = xCAT::ServiceNodeUtils->getAllSN(); + my $sntmp = shift(@snlist); + if ($sntmp) { + my $tmp = `makedhcp -q $sntmp`; + if ($?) { + returncmdoutput($tmp, $outputtarget) if ($verbose); + probe_utils->send_msg($outputtarget, "d", "makedhcp -q $sntmp failed") if ($verbose); + $rc = 1; + last; + } + chomp($tmp); + my $snip = xCAT::NetworkUtils->getipaddr($sntmp); + my $snmac = `lsdef $sntmp -i mac -c | awk -F'=' '{print \$2}'`; + chomp ($snmac); + my $tmpmac; + if ($tmp =~ /$sntmp: ip-address = $snip, hardware-address = (.+)/) { + $tmpmac = $1; + if ($tmpmac !~ $snmac) { + returncmdoutput($tmp, $outputtarget) if ($verbose); + probe_utils->send_msg($outputtarget, "d", "DHCP server's reply is wrong") if ($verbose); + $rc = 1; + } + } else { + returncmdoutput($tmp, $outputtarget) if ($verbose); + probe_utils->send_msg($outputtarget, "d", "DHCP server's reply is wrong") if ($verbose); + $rc = 1; + } } else { - probe_utils->send_msg($outputtarget, "d", "Simulate a node xcatmntest to do dhcp test") if ($verbose); - } - `cp /etc/hosts /etc/hosts.bak.probe > /dev/null 2>&1`; + my $tmp = `chdef xcatmntest groups=all ip=$serverip mac=aa:aa:aa:aa:aa:aa`; + if ($?) { + returncmdoutput($tmp, $outputtarget) if ($verbose); + probe_utils->send_msg($outputtarget, "d", "Simulate a node by chdef failed") if ($verbose); + $rc = 1; + last; + } else { + probe_utils->send_msg($outputtarget, "d", "Simulate a node xcatmntest to do dhcp test") if ($verbose); + } - open HOSTFILE, ">> /etc/hosts"; - print HOSTFILE "$serverip xcatmntest xcatmntest.$domain"; - close HOSTFILE; + `cp /etc/hosts /etc/hosts.bak.probe > /dev/null 2>&1`; - probe_utils->send_msg($outputtarget, "d", "To do 'makedhcp xcatmntest'") if ($verbose); - $tmp = `makedhcp xcatmntest 2>&1`; - if ($?) { + open HOSTFILE, ">> /etc/hosts"; + print HOSTFILE "$serverip xcatmntest xcatmntest.$domain"; + close HOSTFILE; + + probe_utils->send_msg($outputtarget, "d", "To do 'makedhcp xcatmntest'") if ($verbose); + $tmp = `makedhcp xcatmntest 2>&1`; + if ($?) { + returncmdoutput($tmp, $outputtarget) if ($verbose); + probe_utils->send_msg($outputtarget, "d", "makedhcp xcatmntest failed") if ($verbose); + $rc = 1; + `rmdef xcatmntest`; + last; + } + + probe_utils->send_msg($outputtarget, "d", "To do 'makedhcp -q xcatmntest'") if ($verbose); + $tmp = `makedhcp -q xcatmntest`; + if ($?) { + returncmdoutput($tmp, $outputtarget) if ($verbose); + probe_utils->send_msg($outputtarget, "d", "makedhcp -q xcatmntest failed") if ($verbose); + $rc = 1; + `makedhcp -d xcatmntest && rmdef xcatmntest`; + last; + } + chomp($tmp); + if ($tmp !~ /xcatmntest: ip-address = $serverip, hardware-address = aa:aa:aa:aa:aa:aa/) { + returncmdoutput($tmp, $outputtarget) if ($verbose); + probe_utils->send_msg($outputtarget, "d", "DHCP server's reply is wrong") if ($verbose); + $rc = 1; + `makedhcp -d xcatmntest && rmdef xcatmntest`; + last; + } + + probe_utils->send_msg($outputtarget, "d", "Start to clear simulate information for dhcp test") if ($verbose); + $tmp = `makedhcp -d xcatmntest && rmdef xcatmntest`; returncmdoutput($tmp, $outputtarget) if ($verbose); - probe_utils->send_msg($outputtarget, "d", "makedhcp xcatmntest failed") if ($verbose); - $rc = 1; - `rmdef xcatmntest`; - last; - } - probe_utils->send_msg($outputtarget, "d", "To do 'makedhcp -q xcatmntest'") if ($verbose); - $tmp = `makedhcp -q xcatmntest`; - if ($?) { - returncmdoutput($tmp, $outputtarget) if ($verbose); - probe_utils->send_msg($outputtarget, "d", "makedhcp -q xcatmntest failed") if ($verbose); - $rc = 1; - `makedhcp -d xcatmntest && rmdef xcatmntest`; - last; + `rm /etc/hosts`; + `mv /etc/hosts.bak.probe /etc/hosts`; } - chomp($tmp); - if ($tmp !~ /xcatmntest: ip-address = $serverip, hardware-address = aa:aa:aa:aa:aa:aa/) { - returncmdoutput($tmp, $outputtarget) if ($verbose); - probe_utils->send_msg($outputtarget, "d", "DHCP server's reply is wrong") if ($verbose); - $rc = 1; - `makedhcp -d xcatmntest && rmdef xcatmntest`; - last; - } - - probe_utils->send_msg($outputtarget, "d", "Start to clear simulate information for dhcp test") if ($verbose); - $tmp = `makedhcp -d xcatmntest && rmdef xcatmntest`; - returncmdoutput($tmp, $outputtarget) if ($verbose); } - - `rm /etc/hosts`; - `mv /etc/hosts.bak.probe /etc/hosts`; - if ($rc) { probe_utils->send_msg($outputtarget, "f", "$msg"); probe_utils->send_msg($outputtarget, "d", "please run 'makedhcp -n' if never run it before."); @@ -675,38 +725,66 @@ sub do_main_job { #------------------------------------- sub summary_all_jobs_output { - print "\n======================do ERROR summary=====================\n"; - my $isprint = 1; + print "\n======================do summary=====================\n"; + my @summary; + push @summary, "[ok]:[MN]: Check on MN PASS."; foreach my $line (@{ $summaryoutput{mn} }) { - if ($line =~ /\[failed\]/) { - if ($isprint) { - print "[mn]:\n"; - $isprint = 0; - } - print "\t$line\n"; + if ($line =~ /(\[failed\]\s*):\s*(.*)/) { + push @summary, "$1:\t$2"; + $summary[0] = "[failed]:[MN]: Check on MN FAILED."; + } elsif ($line =~ /(\[warning\]\s*):\s*(.*)/) { + push @summary, "$1:\t$2"; } } - $isprint = 1; + my %summary_sn = (); foreach my $node (keys %summaryoutput) { next if ($node eq "mn"); + ${ $summary_sn{$node}{"rst"} } = 1; + push @{ $summary_sn{$node}{"details"} }, "[ok]:[SN:$node]: Check on SN $node PASS."; foreach my $log (@{ $summaryoutput{$node} }) { - if ($log =~ /\[failed\]/) { - if ($isprint) { - print "[$node]:\n"; - $isprint = 0; - } - print "\t$log\n"; + if ($log =~ /(\[failed\]\s*):\s*(.*)/) { + push @{ $summary_sn{$node}{"details"} }, "$1:\t$2"; + ${ $summary_sn{$node}{"rst"} } = 0; + $summary_sn{$node}{"details"}[0] = "[failed]:[SN:$node]: Check on SN $node FAILED."; + } elsif ($log =~ /(\[warning\]\s*):\s*(.*)/) { + push @{ $summary_sn{$node}{"details"} }, "$1:\t$2"; } elsif ($log !~ /^(\[\w+\]\s*):\s*(.*)/) { - if ($isprint) { - print "[$node]:\n"; - $isprint = 0; - } - print "\t$log\n"; + push @{ $summary_sn{$node}{"details"} }, "[failed] :\t$log"; + ${ $summary_sn{$node}{"rst"} } = 0; + $summary_sn{$node}{"details"}[0] = "[failed]:[SN:$node]: Check on SN $node FAILED."; } } } + if ($summary[0] =~ /^\[ok\]:/) { + foreach (@summary) { + print "$_\n"; + } + } + + foreach my $node (keys %summary_sn) { + if (${ $summary_sn{$node}{"rst"} }) { + foreach (@{ $summary_sn{$node}{"details"} }) { + print "$_\n"; + } + } + } + + if ($summary[0] =~ /^\[failed\]:/) { + foreach (@summary) { + print "$_\n"; + } + } + + foreach my $node (keys %summary_sn) { + if (!${ $summary_sn{$node}{"rst"} }) { + foreach (@{ $summary_sn{$node}{"details"} }) { + print "$_\n"; + } + } + } + } #------------------------------------- @@ -776,10 +854,10 @@ sub send_sn_msg { next if ($node eq "mn"); foreach my $line (@{ $summaryoutput{$node} }) { if ($line =~ /^(\[\w+\]\s*):\s*(.*)/) { - print "$1:$node: $2\n"; + print "$1:[SN:$node]: $2\n"; } else { print "[failed] :$node: $line\n"; - } + } } } } @@ -874,8 +952,6 @@ pipe $pipe_parent_read, $pipe_child_write; #handle job dispatch to SN foreach my $sn (keys %dispatchcmd) { my $snjobcmd = "xdsh $sn -s \"$dispatchcmd{$sn}\" 2>&1"; - probe_utils->send_msg("$output", "i", "Dispatch cmd $program_name to $sn $1"); - my $snjobfd; my $snjobpid; if (!($snjobpid = open($snjobfd, "$snjobcmd |"))) { @@ -904,7 +980,9 @@ pipe $pipe_parent_read, $pipe_child_write; $pipeisnonull{mn} = 0; } else { chomp($line = <$pipe_parent_read>); - print "$line\n"; + if ($line =~ /(\[\w+\]\s*):\s*(.*)/) { + print "$1:[MN]: $2\n"; + } push @{ $summaryoutput{mn} }, $line; } } else { From f7aa0cc2faeb52e1b1710de23d1225d50f210bc5 Mon Sep 17 00:00:00 2001 From: XuWei Date: Thu, 11 Aug 2016 23:33:32 -0400 Subject: [PATCH 028/106] add cleanup function --- xCAT-probe/subcmds/xcatmn | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/xCAT-probe/subcmds/xcatmn b/xCAT-probe/subcmds/xcatmn index 1744e3bf6..9b475c1f4 100755 --- a/xCAT-probe/subcmds/xcatmn +++ b/xCAT-probe/subcmds/xcatmn @@ -725,6 +725,9 @@ sub do_main_job { #------------------------------------- sub summary_all_jobs_output { + if ($terminal) { + return 0; + } print "\n======================do summary=====================\n"; my @summary; @@ -787,6 +790,24 @@ sub summary_all_jobs_output { } +#------------------------------------- +# Clean up test environment +# ------------------------------------- +sub cleanup { + my $tmptest = `lsdef xcatmntest 2>&1`; + if ($tmptest =~ /Error: Could not find an object named 'xcatmntest' of type 'node'./) { + if (-e "/etc/hosts.bak.probe") { + `rm /etc/hosts > /dev/null 2>&1`; + `mv /etc/hosts.bak.probe /etc/hosts > /dev/null 2>&1`; + `makedns -n 2>&1`; + } + } else { + `makedhcp -d xcatmntest && rmdef xcatmntest`; + `rm /etc/hosts`; + `mv /etc/hosts.bak.probe /etc/hosts`; + } +} + #------------------------------------- # Each probe sub command is supposed to support hierarchical. # This funtion is used to caclulate which SN should be dispatched which command @@ -894,6 +915,7 @@ if ($test) { $SIG{TERM} = $SIG{INT} = sub { $terminal = 1; + cleanup(); }; #-------------------------------------------- From 28144017e438578f89120fda9a09d623e48b2bfc Mon Sep 17 00:00:00 2001 From: penguhyang Date: Fri, 12 Aug 2016 14:03:39 +0800 Subject: [PATCH 029/106] update pkglist for redhat sles ubuntu (#1680) --- xCAT-server/share/xcat/netboot/SL/compute.pkglist | 3 +++ xCAT-server/share/xcat/netboot/centos/compute.centos6.pkglist | 3 +++ xCAT-server/share/xcat/netboot/centos/compute.pkglist | 3 +++ xCAT-server/share/xcat/netboot/centos/kvm.centos6.pkglist | 3 +++ xCAT-server/share/xcat/netboot/debian/compute.pkglist | 3 +++ xCAT-server/share/xcat/netboot/fedora/compute.fedora13.pkglist | 3 +++ xCAT-server/share/xcat/netboot/fedora/compute.fedora14.pkglist | 3 +++ xCAT-server/share/xcat/netboot/fedora/compute.pkglist | 3 +++ xCAT-server/share/xcat/netboot/fedora/compute.ppc64.pkglist | 3 +++ xCAT-server/share/xcat/netboot/fedora/service.pkglist | 3 +++ xCAT-server/share/xcat/netboot/fedora12/compute.pkglist | 3 +++ xCAT-server/share/xcat/netboot/fedora12/compute.ppc64.pkglist | 3 +++ xCAT-server/share/xcat/netboot/fedora12/service.pkglist | 3 +++ xCAT-server/share/xcat/netboot/rh/compute.ppc64.pkglist | 3 +++ xCAT-server/share/xcat/netboot/rh/compute.rhas4.pkglist | 3 +++ xCAT-server/share/xcat/netboot/rh/compute.rhel5.s390x.pkglist | 3 +++ xCAT-server/share/xcat/netboot/rh/compute.rhel6.pkglist | 3 +++ xCAT-server/share/xcat/netboot/rh/compute.rhel6.ppc64.pkglist | 3 +++ xCAT-server/share/xcat/netboot/rh/compute.rhel6.s390x.pkglist | 3 +++ xCAT-server/share/xcat/netboot/rh/compute.rhelhpc6.pkglist | 3 +++ xCAT-server/share/xcat/netboot/rh/compute.rhels5.pkglist | 3 +++ xCAT-server/share/xcat/netboot/rh/compute.rhels5.ppc64.pkglist | 3 +++ xCAT-server/share/xcat/netboot/rh/kvm.rhels5.4.pkglist | 3 +++ xCAT-server/share/xcat/netboot/rh/kvm.rhels6.pkglist | 3 +++ xCAT-server/share/xcat/netboot/rh/nfsroot.pkglist | 3 +++ xCAT-server/share/xcat/netboot/rh/service.pkglist | 3 +++ xCAT-server/share/xcat/netboot/rh/service.ppc64.pkglist | 3 +++ xCAT-server/share/xcat/netboot/rh/service.rhels6.ppc64.pkglist | 3 +++ xCAT-server/share/xcat/netboot/rh/xen.pkglist | 3 +++ .../share/xcat/netboot/sles/compute.sles10.ppc64.pkglist | 3 +++ .../share/xcat/netboot/sles/compute.sles11.s390x.pkglist | 3 +++ xCAT-server/share/xcat/netboot/sles/service.pkglist | 3 +++ .../share/xcat/netboot/sles/service.sles10.ppc64.pkglist | 3 +++ xCAT-server/share/xcat/netboot/sles/service.sles11.pkglist | 3 +++ .../share/xcat/netboot/sles/service.sles11.ppc64.pkglist | 3 +++ xCAT-server/share/xcat/netboot/sles/service.sles12.pkglist | 1 + xCAT-server/share/xcat/netboot/suse/compute.suse11.pkglist | 3 +++ .../share/xcat/netboot/ubuntu/compute.ubuntu12.04.1.pkglist | 3 +++ .../share/xcat/netboot/ubuntu/compute.ubuntu12.04.2.pkglist | 3 +++ .../xcat/netboot/ubuntu/compute.ubuntu14.04.2.ppc64el.pkglist | 3 +++ .../xcat/netboot/ubuntu/compute.ubuntu14.04.2.x86_64.pkglist | 3 +++ .../xcat/netboot/ubuntu/compute.ubuntu14.04.3.ppc64el.pkglist | 3 +++ .../xcat/netboot/ubuntu/compute.ubuntu14.04.3.x86_64.pkglist | 3 +++ .../xcat/netboot/ubuntu/compute.ubuntu14.04.ppc64el.pkglist | 3 +++ .../share/xcat/netboot/ubuntu/compute.ubuntu16.04.1.pkglist | 1 + 45 files changed, 131 insertions(+) diff --git a/xCAT-server/share/xcat/netboot/SL/compute.pkglist b/xCAT-server/share/xcat/netboot/SL/compute.pkglist index 30d4e4feb..42f78c8a2 100644 --- a/xCAT-server/share/xcat/netboot/SL/compute.pkglist +++ b/xCAT-server/share/xcat/netboot/SL/compute.pkglist @@ -12,3 +12,6 @@ ntp sysklogd rpm rsync +tar +gzip +xz diff --git a/xCAT-server/share/xcat/netboot/centos/compute.centos6.pkglist b/xCAT-server/share/xcat/netboot/centos/compute.centos6.pkglist index 46791764c..908c031cb 100644 --- a/xCAT-server/share/xcat/netboot/centos/compute.centos6.pkglist +++ b/xCAT-server/share/xcat/netboot/centos/compute.centos6.pkglist @@ -16,3 +16,6 @@ parted bc ntp rsyslog +tar +gzip +xz diff --git a/xCAT-server/share/xcat/netboot/centos/compute.pkglist b/xCAT-server/share/xcat/netboot/centos/compute.pkglist index d6ccc612c..59545ae2e 100644 --- a/xCAT-server/share/xcat/netboot/centos/compute.pkglist +++ b/xCAT-server/share/xcat/netboot/centos/compute.pkglist @@ -8,3 +8,6 @@ openssh-clients busybox-anaconda wget rsync +tar +gzip +xz diff --git a/xCAT-server/share/xcat/netboot/centos/kvm.centos6.pkglist b/xCAT-server/share/xcat/netboot/centos/kvm.centos6.pkglist index 60a3da31f..e04f5aa7a 100644 --- a/xCAT-server/share/xcat/netboot/centos/kvm.centos6.pkglist +++ b/xCAT-server/share/xcat/netboot/centos/kvm.centos6.pkglist @@ -17,3 +17,6 @@ qemu-kvm e2fsprogs parted bc +tar +gzip +xz diff --git a/xCAT-server/share/xcat/netboot/debian/compute.pkglist b/xCAT-server/share/xcat/netboot/debian/compute.pkglist index 74b91240d..814e4c449 100644 --- a/xCAT-server/share/xcat/netboot/debian/compute.pkglist +++ b/xCAT-server/share/xcat/netboot/debian/compute.pkglist @@ -10,3 +10,6 @@ vim ntp rsyslog rsync +tar +gzip +xz-utils diff --git a/xCAT-server/share/xcat/netboot/fedora/compute.fedora13.pkglist b/xCAT-server/share/xcat/netboot/fedora/compute.fedora13.pkglist index 927dd6e36..8e577d5c6 100644 --- a/xCAT-server/share/xcat/netboot/fedora/compute.fedora13.pkglist +++ b/xCAT-server/share/xcat/netboot/fedora/compute.fedora13.pkglist @@ -12,3 +12,6 @@ ntp rpm rsync rsyslog +tar +gzip +xz diff --git a/xCAT-server/share/xcat/netboot/fedora/compute.fedora14.pkglist b/xCAT-server/share/xcat/netboot/fedora/compute.fedora14.pkglist index 927dd6e36..8e577d5c6 100644 --- a/xCAT-server/share/xcat/netboot/fedora/compute.fedora14.pkglist +++ b/xCAT-server/share/xcat/netboot/fedora/compute.fedora14.pkglist @@ -12,3 +12,6 @@ ntp rpm rsync rsyslog +tar +gzip +xz diff --git a/xCAT-server/share/xcat/netboot/fedora/compute.pkglist b/xCAT-server/share/xcat/netboot/fedora/compute.pkglist index 332b191e0..0995c70f7 100644 --- a/xCAT-server/share/xcat/netboot/fedora/compute.pkglist +++ b/xCAT-server/share/xcat/netboot/fedora/compute.pkglist @@ -10,3 +10,6 @@ wget ntp vim-minimal rsync +tar +gzip +xz diff --git a/xCAT-server/share/xcat/netboot/fedora/compute.ppc64.pkglist b/xCAT-server/share/xcat/netboot/fedora/compute.ppc64.pkglist index c649fd6a1..59d797324 100644 --- a/xCAT-server/share/xcat/netboot/fedora/compute.ppc64.pkglist +++ b/xCAT-server/share/xcat/netboot/fedora/compute.ppc64.pkglist @@ -9,3 +9,6 @@ openssh-server openssh-clients wget rsync +tar +gzip +xz diff --git a/xCAT-server/share/xcat/netboot/fedora/service.pkglist b/xCAT-server/share/xcat/netboot/fedora/service.pkglist index ccc842946..e8794e18e 100644 --- a/xCAT-server/share/xcat/netboot/fedora/service.pkglist +++ b/xCAT-server/share/xcat/netboot/fedora/service.pkglist @@ -23,3 +23,6 @@ unixODBC perl-DBD-MySQL mysql-connector-odbc perl-DBD-Pg +tar +gzip +xz diff --git a/xCAT-server/share/xcat/netboot/fedora12/compute.pkglist b/xCAT-server/share/xcat/netboot/fedora12/compute.pkglist index 4f0a1b8cb..e91239135 100644 --- a/xCAT-server/share/xcat/netboot/fedora12/compute.pkglist +++ b/xCAT-server/share/xcat/netboot/fedora12/compute.pkglist @@ -9,3 +9,6 @@ wget ntp vim-minimal rsync +tar +gzip +xz diff --git a/xCAT-server/share/xcat/netboot/fedora12/compute.ppc64.pkglist b/xCAT-server/share/xcat/netboot/fedora12/compute.ppc64.pkglist index c649fd6a1..59d797324 100644 --- a/xCAT-server/share/xcat/netboot/fedora12/compute.ppc64.pkglist +++ b/xCAT-server/share/xcat/netboot/fedora12/compute.ppc64.pkglist @@ -9,3 +9,6 @@ openssh-server openssh-clients wget rsync +tar +gzip +xz diff --git a/xCAT-server/share/xcat/netboot/fedora12/service.pkglist b/xCAT-server/share/xcat/netboot/fedora12/service.pkglist index df38907b7..2d4329581 100644 --- a/xCAT-server/share/xcat/netboot/fedora12/service.pkglist +++ b/xCAT-server/share/xcat/netboot/fedora12/service.pkglist @@ -19,3 +19,6 @@ wget vsftpd ntp rsync +tar +gzip +xz diff --git a/xCAT-server/share/xcat/netboot/rh/compute.ppc64.pkglist b/xCAT-server/share/xcat/netboot/rh/compute.ppc64.pkglist index eae393156..97b853f42 100644 --- a/xCAT-server/share/xcat/netboot/rh/compute.ppc64.pkglist +++ b/xCAT-server/share/xcat/netboot/rh/compute.ppc64.pkglist @@ -14,3 +14,6 @@ rpm rsync ppc64-utils iputils +tar +gzip +xz diff --git a/xCAT-server/share/xcat/netboot/rh/compute.rhas4.pkglist b/xCAT-server/share/xcat/netboot/rh/compute.rhas4.pkglist index 05192311c..fa3706381 100644 --- a/xCAT-server/share/xcat/netboot/rh/compute.rhas4.pkglist +++ b/xCAT-server/share/xcat/netboot/rh/compute.rhas4.pkglist @@ -14,3 +14,6 @@ rpm rsync busybox util-linux +tar +gzip +xz diff --git a/xCAT-server/share/xcat/netboot/rh/compute.rhel5.s390x.pkglist b/xCAT-server/share/xcat/netboot/rh/compute.rhel5.s390x.pkglist index b448841a0..4083ebcd8 100644 --- a/xCAT-server/share/xcat/netboot/rh/compute.rhel5.s390x.pkglist +++ b/xCAT-server/share/xcat/netboot/rh/compute.rhel5.s390x.pkglist @@ -15,3 +15,6 @@ rpm rsync udev s390utils +tar +gzip +xz diff --git a/xCAT-server/share/xcat/netboot/rh/compute.rhel6.pkglist b/xCAT-server/share/xcat/netboot/rh/compute.rhel6.pkglist index 927dd6e36..8e577d5c6 100644 --- a/xCAT-server/share/xcat/netboot/rh/compute.rhel6.pkglist +++ b/xCAT-server/share/xcat/netboot/rh/compute.rhel6.pkglist @@ -12,3 +12,6 @@ ntp rpm rsync rsyslog +tar +gzip +xz diff --git a/xCAT-server/share/xcat/netboot/rh/compute.rhel6.ppc64.pkglist b/xCAT-server/share/xcat/netboot/rh/compute.rhel6.ppc64.pkglist index 69e3cdf2f..a705db414 100644 --- a/xCAT-server/share/xcat/netboot/rh/compute.rhel6.ppc64.pkglist +++ b/xCAT-server/share/xcat/netboot/rh/compute.rhel6.ppc64.pkglist @@ -22,3 +22,6 @@ bc lsvpd irqbalance procps +tar +gzip +xz diff --git a/xCAT-server/share/xcat/netboot/rh/compute.rhel6.s390x.pkglist b/xCAT-server/share/xcat/netboot/rh/compute.rhel6.s390x.pkglist index bfa4a7fc0..bcbff4391 100644 --- a/xCAT-server/share/xcat/netboot/rh/compute.rhel6.s390x.pkglist +++ b/xCAT-server/share/xcat/netboot/rh/compute.rhel6.s390x.pkglist @@ -14,3 +14,6 @@ rsync rsyslog udev s390utils +tar +gzip +xz diff --git a/xCAT-server/share/xcat/netboot/rh/compute.rhelhpc6.pkglist b/xCAT-server/share/xcat/netboot/rh/compute.rhelhpc6.pkglist index e235bfaba..914888c93 100644 --- a/xCAT-server/share/xcat/netboot/rh/compute.rhelhpc6.pkglist +++ b/xCAT-server/share/xcat/netboot/rh/compute.rhelhpc6.pkglist @@ -20,3 +20,6 @@ rsync rsyslog e2fsprogs parted +tar +gzip +xz diff --git a/xCAT-server/share/xcat/netboot/rh/compute.rhels5.pkglist b/xCAT-server/share/xcat/netboot/rh/compute.rhels5.pkglist index 6175ca101..261bc3594 100644 --- a/xCAT-server/share/xcat/netboot/rh/compute.rhels5.pkglist +++ b/xCAT-server/share/xcat/netboot/rh/compute.rhels5.pkglist @@ -14,3 +14,6 @@ sysklogd rpm rsync db4-utils +tar +gzip +xz diff --git a/xCAT-server/share/xcat/netboot/rh/compute.rhels5.ppc64.pkglist b/xCAT-server/share/xcat/netboot/rh/compute.rhels5.ppc64.pkglist index 6eae74b38..e8f6a1a70 100644 --- a/xCAT-server/share/xcat/netboot/rh/compute.rhels5.ppc64.pkglist +++ b/xCAT-server/share/xcat/netboot/rh/compute.rhels5.ppc64.pkglist @@ -15,3 +15,6 @@ rpm rsync ppc64-utils iputils +tar +gzip +xz diff --git a/xCAT-server/share/xcat/netboot/rh/kvm.rhels5.4.pkglist b/xCAT-server/share/xcat/netboot/rh/kvm.rhels5.4.pkglist index 3de9dd585..f9981f273 100644 --- a/xCAT-server/share/xcat/netboot/rh/kvm.rhels5.4.pkglist +++ b/xCAT-server/share/xcat/netboot/rh/kvm.rhels5.4.pkglist @@ -23,3 +23,6 @@ python-urlgrabber.noarch python-virtinst screen xnba-kvm +tar +gzip +xz diff --git a/xCAT-server/share/xcat/netboot/rh/kvm.rhels6.pkglist b/xCAT-server/share/xcat/netboot/rh/kvm.rhels6.pkglist index 60a3da31f..e04f5aa7a 100644 --- a/xCAT-server/share/xcat/netboot/rh/kvm.rhels6.pkglist +++ b/xCAT-server/share/xcat/netboot/rh/kvm.rhels6.pkglist @@ -17,3 +17,6 @@ qemu-kvm e2fsprogs parted bc +tar +gzip +xz diff --git a/xCAT-server/share/xcat/netboot/rh/nfsroot.pkglist b/xCAT-server/share/xcat/netboot/rh/nfsroot.pkglist index 30d4e4feb..42f78c8a2 100644 --- a/xCAT-server/share/xcat/netboot/rh/nfsroot.pkglist +++ b/xCAT-server/share/xcat/netboot/rh/nfsroot.pkglist @@ -12,3 +12,6 @@ ntp sysklogd rpm rsync +tar +gzip +xz diff --git a/xCAT-server/share/xcat/netboot/rh/service.pkglist b/xCAT-server/share/xcat/netboot/rh/service.pkglist index bcb1155ba..c98d88113 100644 --- a/xCAT-server/share/xcat/netboot/rh/service.pkglist +++ b/xCAT-server/share/xcat/netboot/rh/service.pkglist @@ -13,6 +13,9 @@ ksh nfs-utils dhcp bzip2 +tar +gzip +xz rootfiles vixie-cron wget diff --git a/xCAT-server/share/xcat/netboot/rh/service.ppc64.pkglist b/xCAT-server/share/xcat/netboot/rh/service.ppc64.pkglist index f783e0c78..2ebaa4caa 100644 --- a/xCAT-server/share/xcat/netboot/rh/service.ppc64.pkglist +++ b/xCAT-server/share/xcat/netboot/rh/service.ppc64.pkglist @@ -13,6 +13,9 @@ ksh nfs-utils dhcp bzip2 +tar +gzip +xz rootfiles vixie-cron wget diff --git a/xCAT-server/share/xcat/netboot/rh/service.rhels6.ppc64.pkglist b/xCAT-server/share/xcat/netboot/rh/service.rhels6.ppc64.pkglist index 0064ef136..b059fb0de 100644 --- a/xCAT-server/share/xcat/netboot/rh/service.rhels6.ppc64.pkglist +++ b/xCAT-server/share/xcat/netboot/rh/service.rhels6.ppc64.pkglist @@ -13,6 +13,9 @@ ksh nfs-utils dhcp bzip2 +tar +gzip +xz rootfiles cronie wget diff --git a/xCAT-server/share/xcat/netboot/rh/xen.pkglist b/xCAT-server/share/xcat/netboot/rh/xen.pkglist index e39f5b37e..36aab9d51 100644 --- a/xCAT-server/share/xcat/netboot/rh/xen.pkglist +++ b/xCAT-server/share/xcat/netboot/rh/xen.pkglist @@ -18,3 +18,6 @@ iscsi-initiator-utils xen libvirt.x86_64 screen +tar +gzip +xz diff --git a/xCAT-server/share/xcat/netboot/sles/compute.sles10.ppc64.pkglist b/xCAT-server/share/xcat/netboot/sles/compute.sles10.ppc64.pkglist index 3030207bd..ff31bff94 100644 --- a/xCAT-server/share/xcat/netboot/sles/compute.sles10.ppc64.pkglist +++ b/xCAT-server/share/xcat/netboot/sles/compute.sles10.ppc64.pkglist @@ -26,3 +26,6 @@ powerpc-utils timezone iputils ntp +tar +gzip +xz diff --git a/xCAT-server/share/xcat/netboot/sles/compute.sles11.s390x.pkglist b/xCAT-server/share/xcat/netboot/sles/compute.sles11.s390x.pkglist index d21a59702..05d3f016e 100644 --- a/xCAT-server/share/xcat/netboot/sles/compute.sles11.s390x.pkglist +++ b/xCAT-server/share/xcat/netboot/sles/compute.sles11.s390x.pkglist @@ -27,3 +27,6 @@ s390-tools mdadm udev ntp +tar +gzip +xz diff --git a/xCAT-server/share/xcat/netboot/sles/service.pkglist b/xCAT-server/share/xcat/netboot/sles/service.pkglist index 768ea3a64..856926487 100644 --- a/xCAT-server/share/xcat/netboot/sles/service.pkglist +++ b/xCAT-server/share/xcat/netboot/sles/service.pkglist @@ -20,3 +20,6 @@ vsftpd rsync timezone ntp +tar +gzip +xz diff --git a/xCAT-server/share/xcat/netboot/sles/service.sles10.ppc64.pkglist b/xCAT-server/share/xcat/netboot/sles/service.sles10.ppc64.pkglist index 1bd102e81..c850779bc 100644 --- a/xCAT-server/share/xcat/netboot/sles/service.sles10.ppc64.pkglist +++ b/xCAT-server/share/xcat/netboot/sles/service.sles10.ppc64.pkglist @@ -50,3 +50,6 @@ powerpc-utils bc iputils ntp +tar +gzip +xz diff --git a/xCAT-server/share/xcat/netboot/sles/service.sles11.pkglist b/xCAT-server/share/xcat/netboot/sles/service.sles11.pkglist index 9bd0bced2..9c9ca2019 100644 --- a/xCAT-server/share/xcat/netboot/sles/service.sles11.pkglist +++ b/xCAT-server/share/xcat/netboot/sles/service.sles11.pkglist @@ -20,6 +20,9 @@ cron wget vsftpd util-linux +tar +gzip +xz module-init-tools mkinitrd apache2 diff --git a/xCAT-server/share/xcat/netboot/sles/service.sles11.ppc64.pkglist b/xCAT-server/share/xcat/netboot/sles/service.sles11.ppc64.pkglist index f10b610c2..2fe8be069 100644 --- a/xCAT-server/share/xcat/netboot/sles/service.sles11.ppc64.pkglist +++ b/xCAT-server/share/xcat/netboot/sles/service.sles11.ppc64.pkglist @@ -20,6 +20,9 @@ cron wget vsftpd util-linux +tar +gzip +xz module-init-tools mkinitrd apache2 diff --git a/xCAT-server/share/xcat/netboot/sles/service.sles12.pkglist b/xCAT-server/share/xcat/netboot/sles/service.sles12.pkglist index cc15ffcfe..447e5a3ea 100644 --- a/xCAT-server/share/xcat/netboot/sles/service.sles12.pkglist +++ b/xCAT-server/share/xcat/netboot/sles/service.sles12.pkglist @@ -23,6 +23,7 @@ e2fsprogs fcoe-utils gpg2 gzip +xz kernel-default keyutils lvm2 diff --git a/xCAT-server/share/xcat/netboot/suse/compute.suse11.pkglist b/xCAT-server/share/xcat/netboot/suse/compute.suse11.pkglist index a097d39d4..dee4ca23f 100644 --- a/xCAT-server/share/xcat/netboot/suse/compute.suse11.pkglist +++ b/xCAT-server/share/xcat/netboot/suse/compute.suse11.pkglist @@ -14,3 +14,6 @@ syslog-ng klogd vim rsync +tar +gzip +xz diff --git a/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu12.04.1.pkglist b/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu12.04.1.pkglist index c23ba181a..6e3b04dc2 100644 --- a/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu12.04.1.pkglist +++ b/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu12.04.1.pkglist @@ -12,3 +12,6 @@ rsyslog rsync busybox-static gawk +tar +gzip +xz-utils diff --git a/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu12.04.2.pkglist b/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu12.04.2.pkglist index 7b6014760..324fdb29e 100644 --- a/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu12.04.2.pkglist +++ b/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu12.04.2.pkglist @@ -12,3 +12,6 @@ rsyslog rsync busybox-static gawk +tar +gzip +xz-utils diff --git a/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu14.04.2.ppc64el.pkglist b/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu14.04.2.ppc64el.pkglist index 0b69a32dc..65dbbdc7f 100644 --- a/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu14.04.2.ppc64el.pkglist +++ b/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu14.04.2.ppc64el.pkglist @@ -13,3 +13,6 @@ rsync busybox-static gawk dnsutils +tar +gzip +xz-utils diff --git a/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu14.04.2.x86_64.pkglist b/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu14.04.2.x86_64.pkglist index 0b69a32dc..65dbbdc7f 100644 --- a/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu14.04.2.x86_64.pkglist +++ b/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu14.04.2.x86_64.pkglist @@ -13,3 +13,6 @@ rsync busybox-static gawk dnsutils +tar +gzip +xz-utils diff --git a/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu14.04.3.ppc64el.pkglist b/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu14.04.3.ppc64el.pkglist index 0ca8402aa..7ad80186e 100644 --- a/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu14.04.3.ppc64el.pkglist +++ b/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu14.04.3.ppc64el.pkglist @@ -13,3 +13,6 @@ rsync busybox-static gawk dnsutils +tar +gzip +xz-utils diff --git a/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu14.04.3.x86_64.pkglist b/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu14.04.3.x86_64.pkglist index 0ca8402aa..7ad80186e 100644 --- a/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu14.04.3.x86_64.pkglist +++ b/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu14.04.3.x86_64.pkglist @@ -13,3 +13,6 @@ rsync busybox-static gawk dnsutils +tar +gzip +xz-utils diff --git a/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu14.04.ppc64el.pkglist b/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu14.04.ppc64el.pkglist index 818b8f26f..5b1f2b327 100644 --- a/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu14.04.ppc64el.pkglist +++ b/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu14.04.ppc64el.pkglist @@ -13,3 +13,6 @@ rsync busybox-static gawk dnsutils +tar +gzip +xz-utils diff --git a/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu16.04.1.pkglist b/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu16.04.1.pkglist index a5861a9e0..5bf569fd1 100644 --- a/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu16.04.1.pkglist +++ b/xCAT-server/share/xcat/netboot/ubuntu/compute.ubuntu16.04.1.pkglist @@ -15,3 +15,4 @@ gawk dnsutils tar gzip +xz-utils From d44176f1d1ea12735649bdec6042db3ae0a9497b Mon Sep 17 00:00:00 2001 From: penguhyang Date: Fri, 12 Aug 2016 14:46:52 +0800 Subject: [PATCH 030/106] update code of packimage (#1685) --- xCAT-server/lib/xcat/plugins/packimage.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/packimage.pm b/xCAT-server/lib/xcat/plugins/packimage.pm index ca92c8f37..c6d96ebb5 100755 --- a/xCAT-server/lib/xcat/plugins/packimage.pm +++ b/xCAT-server/lib/xcat/plugins/packimage.pm @@ -220,7 +220,7 @@ sub process_request { } } - #before generating rootimg.gz, copy $installroot/postscripts into the image at /xcatpost + #before generating rootimg.$suffix, copy $installroot/postscripts into the image at /xcatpost if (-e "$rootimg_dir/xcatpost") { system("rm -rf $rootimg_dir/xcatpost"); } @@ -240,7 +240,7 @@ sub process_request { `echo TIMESTAMP="'$timestamp'" >> $rootimg_dir/opt/xcat/xcatinfo`; - # before generating rootimg.gz or rootimg.sfs, need to switch the rootimg to stateless mode if necessary + # before generating rootimg.$suffix or rootimg.sfs, need to switch the rootimg to stateless mode if necessary my $rootimg_status = 0; # 0 means stateless mode, while 1 means statelite mode $rootimg_status = 1 if (-f "$rootimg_dir/.statelite/litefile.save"); @@ -418,8 +418,6 @@ sub process_request { return 1; } $callback->({ data => ["Packing contents of $rootimg_dir"] }); - unlink("$destdir/rootimg.gz"); - unlink("$destdir/rootimg.sfs"); my $suffix; if ($compress) { @@ -470,6 +468,8 @@ sub process_request { } $suffix = $method.".".$suffix; + unlink("$destdir/rootimg.$suffix"); + unlink("$destdir/rootimg.sfs"); if ($method =~ /cpio/) { if (!$exlistloc) { $excludestr = "find . -xdev -print0 | cpio -H newc -o -0 | $compress -c - > ../rootimg.$suffix"; From b9d8138395af47ff7c260a1c726ccde0ad19d997 Mon Sep 17 00:00:00 2001 From: immarvin Date: Fri, 12 Aug 2016 02:52:03 -0400 Subject: [PATCH 031/106] fix issue Nodeset for Ubuntu OS displays warning, but we should be more specific and only print on conditions where it might fail #1097 --- xCAT-server/lib/xcat/plugins/debian.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/debian.pm b/xCAT-server/lib/xcat/plugins/debian.pm index 927886864..412e8a87f 100644 --- a/xCAT-server/lib/xcat/plugins/debian.pm +++ b/xCAT-server/lib/xcat/plugins/debian.pm @@ -891,7 +891,7 @@ sub mkinstall { $kcmdline .= "n8r"; } } else { - $callback->({ warning => ["rcons my not work since no serialport specified"], }); + $callback->({ warning => ["rcons may not work since no serialport is specified for $node"], }); } # need to add these in, otherwise aptitude will ask questions @@ -1548,7 +1548,7 @@ sub mknetboot } else { $callback->( { - warning => ["rcons my not work since no serialport specified"], + warning => ["rcons may not work since no serialport is specified for $node"], } ); } From 578fda6663eb0bc40971586b83784f554a9727f5 Mon Sep 17 00:00:00 2001 From: hu-weihua Date: Fri, 12 Aug 2016 03:46:54 -0400 Subject: [PATCH 032/106] modify depending on comments --- xCAT-probe/subcmds/osdeploy | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/xCAT-probe/subcmds/osdeploy b/xCAT-probe/subcmds/osdeploy index c051e6e56..a468d577d 100755 --- a/xCAT-probe/subcmds/osdeploy +++ b/xCAT-probe/subcmds/osdeploy @@ -210,18 +210,34 @@ sub check_noderange { $rst = 1; next; } - $monitor_nodes{$node}{"rst"} = 0; + my $noerror=1; my @macs = split(/\|/, $nodecheckrst{$node}{"mac"}); foreach my $mac (@macs) { + + #[NOTE] don't support 2 adapters in the same network now. TODO + if ($mac =~ /\!\*NOIP\*/) { $mac =~ s/\!\*NOIP\*//g; $macmap{$mac}{"ip"} = "NOIP"; $macmap{$mac}{"node"} = $node; } else { - $macmap{$mac}{"ip"} = $nodecheckrst{$node}{"ip"}; $macmap{$mac}{"node"} = $node; + if($nodecheckrst{$node}{"ip"}){ + $macmap{$mac}{"ip"} = $nodecheckrst{$node}{"ip"}; + }else{ + my $nodeip = xCAT::NetworkUtils->getipaddr($node); + if($nodeip){ + $macmap{$mac}{"ip"} = $nodeip; + }else{ + $noerror = 0; + $rst = 1; + probe_utils->send_msg("$output", "f", "$node : can't be resolved to a IP address"); + } + } } } + + $monitor_nodes{$node}{"rst"} = 0 if($noerror); } unless (%monitor_nodes) { @@ -600,8 +616,8 @@ sub dump_history { last if (!$newloop); } - # print "------------result---------------\n"; - # print Dumper %match_result; + print "------------result---------------\n"; + print Dumper %match_result; my $max_match = 0; foreach my $key (keys %match_result) { @@ -820,6 +836,8 @@ sub get_valid_logs { $filename =~ s/(.+)\.(.+)/$1/g; my $path_only = dirname("$f"); my @rotatefiles; + + #TODO using opendir to refine below code my @alltargetfiles = `ls -lt $path_only |awk -F" " '/ $filename/ {print \$9}'`; foreach my $samenamefile (@alltargetfiles) { chomp($samenamefile); From f9d725808c85bd7c4785904577f18762cc7c93a1 Mon Sep 17 00:00:00 2001 From: XuWei Date: Fri, 12 Aug 2016 03:13:11 -0400 Subject: [PATCH 033/106] modify dns check and cleanup --- xCAT-probe/subcmds/xcatmn | 52 ++++++++++++++------------------------- 1 file changed, 18 insertions(+), 34 deletions(-) diff --git a/xCAT-probe/subcmds/xcatmn b/xCAT-probe/subcmds/xcatmn index 9b475c1f4..d12c2c622 100755 --- a/xCAT-probe/subcmds/xcatmn +++ b/xCAT-probe/subcmds/xcatmn @@ -523,32 +523,20 @@ sub do_main_job { } } else { - # if there is no sn, simulate a host to check DNS service - `cp /etc/hosts /etc/hosts.bak.probe > /dev/null 2>&1`; + # if there is no sn, nslookup mnip + my $nslkp = `nslookup $serverip $serverip 2>&1`; - { #very important brace to create a block - open HOSTFILE, ">> /etc/hosts"; - print HOSTFILE "$serverip xcatmntest xcatmntest.$domain"; - close HOSTFILE; - - probe_utils->send_msg($outputtarget, "d", "To do 'makedns -n xcatmntest'") if ($verbose); - $tmp = `makedns -V -n 2>&1`; - if ($?) { - returncmdoutput($tmp, $outputtarget) if ($verbose); - probe_utils->send_msg($outputtarget, "d", "makedns -n xcatmntest failed") if ($verbose); + if ($?) { + probe_utils->send_msg($outputtarget, "d", "nslookup $serverip $serverip failed"); + $rc = 1; + } else { + chomp($nslkp); + my $tmp = grep {$_ =~ "Server:[\t\s]*$serverip"} split (/\n/, $output); + if (!$tmp) { + probe_utils->send_msg($outputtarget, "d", "nslookup $serverip $serverip failed"); $rc = 1; - last; - } - - if (!probe_utils->is_dns_ready("$serverip", "$serverip", "xcatmntest", "$domain")) { - probe_utils->send_msg($outputtarget, "d", "nslookup xcatmntest $serverip failed"); - $rc = 1; - last; } } - `rm /etc/hosts > /dev/null 2>&1`; - `mv /etc/hosts.bak.probe /etc/hosts > /dev/null 2>&1`; - `makedns -n 2>&1`; } if ($rc) { probe_utils->send_msg($outputtarget, "f", "$msg"); @@ -754,7 +742,7 @@ sub summary_all_jobs_output { } elsif ($log =~ /(\[warning\]\s*):\s*(.*)/) { push @{ $summary_sn{$node}{"details"} }, "$1:\t$2"; } elsif ($log !~ /^(\[\w+\]\s*):\s*(.*)/) { - push @{ $summary_sn{$node}{"details"} }, "[failed] :\t$log"; + push @{ $summary_sn{$node}{"details"} }, "[failed]:\t$log"; ${ $summary_sn{$node}{"rst"} } = 0; $summary_sn{$node}{"details"}[0] = "[failed]:[SN:$node]: Check on SN $node FAILED."; } @@ -794,17 +782,13 @@ sub summary_all_jobs_output { # Clean up test environment # ------------------------------------- sub cleanup { - my $tmptest = `lsdef xcatmntest 2>&1`; - if ($tmptest =~ /Error: Could not find an object named 'xcatmntest' of type 'node'./) { - if (-e "/etc/hosts.bak.probe") { - `rm /etc/hosts > /dev/null 2>&1`; - `mv /etc/hosts.bak.probe /etc/hosts > /dev/null 2>&1`; - `makedns -n 2>&1`; - } - } else { - `makedhcp -d xcatmntest && rmdef xcatmntest`; - `rm /etc/hosts`; - `mv /etc/hosts.bak.probe /etc/hosts`; + my $tmptest = `nodels xcatmntest 2>&1`; + if ($tmptest !~ /Error: Invalid nodes and\/or groups in noderange: xcatmntest/) { + `makedhcp -d xcatmntest && rmdef xcatmntest > /dev/null 2>&1`; + } + if (-e "/etc/hosts.bak.probe") { + `rm /etc/hosts > /dev/null 2>&1`; + `mv /etc/hosts.bak.probe /etc/hosts > /dev/null 2>&1`; } } From 7debe6a95e0fcf8845f91b2afaed5a03c597ad82 Mon Sep 17 00:00:00 2001 From: hu-weihua Date: Fri, 12 Aug 2016 04:45:22 -0400 Subject: [PATCH 034/106] comment some debug line out --- xCAT-probe/subcmds/osdeploy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xCAT-probe/subcmds/osdeploy b/xCAT-probe/subcmds/osdeploy index a468d577d..f0010700f 100755 --- a/xCAT-probe/subcmds/osdeploy +++ b/xCAT-probe/subcmds/osdeploy @@ -616,8 +616,8 @@ sub dump_history { last if (!$newloop); } - print "------------result---------------\n"; - print Dumper %match_result; + #print "------------result---------------\n"; + #print Dumper %match_result; my $max_match = 0; foreach my $key (keys %match_result) { From 45bbe0f9ba4fad90daacda604346e696ff22b4f6 Mon Sep 17 00:00:00 2001 From: hu-weihua Date: Fri, 12 Aug 2016 06:02:03 -0400 Subject: [PATCH 035/106] modefy depending on comments --- xCAT-probe/subcmds/osdeploy | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/xCAT-probe/subcmds/osdeploy b/xCAT-probe/subcmds/osdeploy index f0010700f..5d3a8e025 100755 --- a/xCAT-probe/subcmds/osdeploy +++ b/xCAT-probe/subcmds/osdeploy @@ -57,7 +57,7 @@ my %monitor_nodes; # provision state machine my %state_set = ( "unknown" => 0, - "sever_reboot" => 1, + "server_reboot" => 1, "loaded_kernel_and_initrd" => 2, "kernel_and_initrd_got_ip" => 3, "install_os_packages" => 4, @@ -68,7 +68,7 @@ my %state_set = ( my %state_set_reverse = ( "0" => "unknown", - "1" => "sever_reboot", + "1" => "server_reboot", "2" => "loaded_kernel_and_initrd", "3" => "kernel_and_initrd_got_ip", "4" => "install_os_packages", @@ -81,16 +81,16 @@ my %valid_process; $valid_process{1}{process} = [ $state_set{unknown}, $state_set{done} ]; $valid_process{1}{type} = "reboot"; -$valid_process{2}{process} = [ $state_set{unknown}, $state_set{sever_reboot}, $state_set{done} ]; +$valid_process{2}{process} = [ $state_set{unknown}, $state_set{server_reboot}, $state_set{done} ]; $valid_process{2}{type} = "reboot"; -$valid_process{3}{process} = [ $state_set{unknown}, $state_set{sever_reboot}, $state_set{run_postbootscript}, $state_set{done} ]; +$valid_process{3}{process} = [ $state_set{unknown}, $state_set{server_reboot}, $state_set{run_postbootscript}, $state_set{done} ]; $valid_process{3}{type} = "reboot"; -$valid_process{4}{process} = [ $state_set{unknown}, $state_set{sever_reboot}, $state_set{loaded_kernel_and_initrd}, $state_set{kernel_and_initrd_got_ip}, $state_set{install_os_packages}, $state_set{run_postscript}, $state_set{sever_reboot}, $state_set{run_postbootscript}, $state_set{done} ]; +$valid_process{4}{process} = [ $state_set{unknown}, $state_set{server_reboot}, $state_set{loaded_kernel_and_initrd}, $state_set{kernel_and_initrd_got_ip}, $state_set{install_os_packages}, $state_set{run_postscript}, $state_set{server_reboot}, $state_set{run_postbootscript}, $state_set{done} ]; $valid_process{4}{type} = "deploy"; -$valid_process{5}{process} = [ $state_set{unknown}, $state_set{loaded_kernel_and_initrd}, $state_set{kernel_and_initrd_got_ip}, $state_set{install_os_packages}, $state_set{run_postscript}, $state_set{sever_reboot}, $state_set{run_postbootscript}, $state_set{done} ]; +$valid_process{5}{process} = [ $state_set{unknown}, $state_set{loaded_kernel_and_initrd}, $state_set{kernel_and_initrd_got_ip}, $state_set{install_os_packages}, $state_set{run_postscript}, $state_set{server_reboot}, $state_set{run_postbootscript}, $state_set{done} ]; $valid_process{5}{type} = "deploy"; sub reset_state { @@ -99,16 +99,16 @@ sub reset_state { my $reset_flag = 1; if ($$state_ref == $state_set{unknown} && $condition eq "dhcp") { - $$state_ref = $state_set{sever_reboot}; + $$state_ref = $state_set{server_reboot}; } elsif ($$state_ref == $state_set{unknown} && $condition eq "booted") { $$state_ref = $state_set{done}; } elsif (($$state_ref == $state_set{unknown} && $condition eq "tftp") || ($$state_ref == $state_set{unknown} && $condition eq "http")) { $$state_ref = $state_set{loaded_kernel_and_initrd}; - } elsif ($$state_ref == $state_set{sever_reboot} && $condition eq "booted") { + } elsif ($$state_ref == $state_set{server_reboot} && $condition eq "booted") { $$state_ref = $state_set{done}; - } elsif ($$state_ref == $state_set{sever_reboot} && $condition eq "postscript") { + } elsif ($$state_ref == $state_set{server_reboot} && $condition eq "postscript") { $$state_ref = $state_set{run_postbootscript}; - } elsif (($$state_ref == $state_set{sever_reboot} && $condition eq "tftp") || ($$state_ref == $state_set{sever_reboot} && $condition eq "http")) { + } elsif (($$state_ref == $state_set{server_reboot} && $condition eq "tftp") || ($$state_ref == $state_set{server_reboot} && $condition eq "http")) { $$state_ref = $state_set{loaded_kernel_and_initrd}; } elsif ($$state_ref == $state_set{loaded_kernel_and_initrd} && $condition eq "dhcp") { $$state_ref = $state_set{kernel_and_initrd_got_ip}; @@ -117,13 +117,13 @@ sub reset_state { } elsif ($$state_ref == $state_set{install_os_packages} && $condition eq "postscript") { $$state_ref = $state_set{run_postscript}; } elsif ($$state_ref == $state_set{run_postscript} && $condition eq "dhcp") { - $$state_ref = $state_set{sever_reboot}; + $$state_ref = $state_set{server_reboot}; } elsif ($$state_ref == $state_set{run_postbootscript} && $condition eq "booted") { $$state_ref = $state_set{done}; } elsif ($$state_ref == $state_set{done} && $condition eq "dhcp") { - $$state_ref = $state_set{sever_reboot}; + $$state_ref = $state_set{server_reboot}; } elsif ($$state_ref == $state_set{done} && $condition eq "poweron") { - $$state_ref = $state_set{sever_reboot}; + $$state_ref = $state_set{server_reboot}; } else { $reset_flag = 0; } @@ -867,7 +867,6 @@ sub get_valid_logs { last unless ($line = <$fd>); chomp($line); my $needrotate = 0; - my $istorynum = 0; my $logindex = 0; my @splitline = split(/\s+/, $line); my $timestamp; From 5bb901d5eed05ac5f672d7f76ca87ecd96f09d5a Mon Sep 17 00:00:00 2001 From: junxiawang Date: Fri, 12 Aug 2016 08:55:41 -0400 Subject: [PATCH 036/106] add rhels7.3 bundle --- .../autotest/bundle/rhels7.3_x86_64.bundle | 202 ++++++++++++++++++ 1 file changed, 202 insertions(+) create mode 100644 xCAT-test/autotest/bundle/rhels7.3_x86_64.bundle diff --git a/xCAT-test/autotest/bundle/rhels7.3_x86_64.bundle b/xCAT-test/autotest/bundle/rhels7.3_x86_64.bundle new file mode 100644 index 000000000..a9a3aa760 --- /dev/null +++ b/xCAT-test/autotest/bundle/rhels7.3_x86_64.bundle @@ -0,0 +1,202 @@ +Diskless_installation_flat_p8_le +Full_installation_flat_p8_le +go_xcat_local_repo_case7 +go_xcat_noinput +go_xcat_with_x +go_xcat_with_xcat-version-1 +go_xcat_online_repo_case6 +makehosts_h +makehosts_help +makehosts_n +makehosts_n_noderange +chdef_null +chdef_z +chdef_t_o_error +chtab_null +chtab_d +chtab_modify_node +chtab_modify_key +chtab_h +chtab_v +packimage_o_p_a_m +packimage_p_a_o +packimage_imagename +packimage_h +packimage_v +pping_h +pping_v +pping_node +gettab_key_table +gettab_H +gettab_err +gettab_h +lsdef_null +lsdef_a +lsdef_t_o_l +lsdef_t_o_l_z +lsdef_t +lsdef_t_i_o +lsdef_t_w +lsdef_t_err +makeconservercf_null +makeconservercf_noderange +makeconservercf_d +makedhcp_n +makedhcp_a +makedhcp_a_d +makedhcp_d +mkdef_null +mkdef_z +mkdef_t_o_error +nodeadd_noderange +nodeadd_err_symbol +nodeadd_null +nodeadd_noderange_nodetype +nodeadd_v +nodeadd_h +nodegrpch_v +nodegrpch_h +nodegrpch_groups +nodegrpch_err +nodech_noderange_table +nodech_noderange_table_comma +nodech_noderange_table_arrow +nodech_noderanage_table_at +nodech_delete +nodech_error_node +nodech_error_table +nodech_h +nodech_v +nodech_noderange_table_include +nodech_noderange_table_uninclude +nodech_noderange_table_equal +nodech_noderange_table_unequal +nodech_noderange_shortname_groups +nodech_noderange_shortname_tags +nodech_noderange_shortname_mgt +nodels_null +nodels_H +nodels_noderange +nodels_err_symbol +nodels_err_noderange +nodels_noderange_shortname_groups +nodels_noderange_shortname_tags +nodels_noderange_shortname_mgt +nodels_table_include +nodels_noderange_table_uninclude +nodels_noderange_table_equal +nodels_noderange_table_unequal +nodels_b +nodels_S +nodels_noderange_table +nodels_tablevalue +nodels_tablevalue_tablecolumn +nodels_noderange_tablecolumn +nodels_h +nodels_v +xcatstanzafile_colon +xcatstanzafile_attribute +xcatstanzafile_objtype +xcatstanzafile_tab +xcatstanzafile_multattr +xcatstanzafile_defaultvalue +xcatstanzafile_specificvalue +noderm_noderange +noderm_h +noderm_null +noderm_err_node +nodeset_stat +nodeset_noderange +nodestat_err_node +rinv_noderange_err +rmdef_null +rmdef_t_err +rpower_err_noderange +rvitals_noderange_err +tabdump_table +tabdump_d +tabdump_v +tabdump_h +tabdump_help +tabdump_w_match +tabdump_w_equal +tabdump_w_ne +tabdump_w_notmatch +tabdump_w_gt +tabdump_w_ge +tabdump_w_lt +tabdump_w_le +tabdump_f_d +tabdump_d_nodehm +tabprune_h +tabprune_v +tabprune_a_eventlog +tabprune_V_a_eventlog +tabprune_i_auditlog +tabprune_V_n_auditlog +tabgrep_node +tabgrep_null +tabgrep_h +tabgrep_err +tabrestore_table +tabrestore_null +tabrestore_h +tabrestore_err +dumpxCATdb_h +dumpxCATdb_v +dumpxCATdb_p_nullskiptables +dumpxCATdb_a_p_nullskiptables +dumpxCATdb_p_skiptables +dumpxCATdb_a_p_skiptables +dumpxCATdb_p_nullskiptables_V +dumpxCATdb_a_p_nullskiptables_V +dumpxCATdb_p_V +restorexCAT_h +restorexCATdb_v +restorexCATdb_p_V +restorexCATdb_a_p_V +restorexCATdb_wrongpath +regnotif_null +regnotif_o +regnotif_err +regnotif_h +regnotif_v +unregnotif_null +unregnotif_f +unregnotif_h +unregnotif_v +lsxcatd_null +lsxcatd_h +lsxcatd_d +lsxcatd_a +makedns_d_node +makedns_n +makedns +copycds_iso +copycds_n +copycds_a +copycds_n_a +xdsh_h +xdsh_V +xdsh_regular_command +xdsh_Q_command +xdsh_c_cn +xdsh_e_filename +xdsh_E +xdsh_i_linux +xdsh_t +xdsh_q +xdsh_T +xdsh_o +switchdiscover_range_default +switchdiscover_h +switchdiscover_range_s +switchdiscover_range_default_w +switchdiscover_range_r +switchdiscover_range_x +switchdiscover_range_z +switchdiscover_range_z_V +nodeset_shell +nodeset_cmdline +nodeset_runimg +clean_up_env From 4a270db56f836734e463c3ca5191f7f1acd8f9be Mon Sep 17 00:00:00 2001 From: junxiawang Date: Fri, 12 Aug 2016 10:09:17 -0400 Subject: [PATCH 037/106] modify x86_64 bundle --- xCAT-test/autotest/bundle/rhels7.3_x86_64.bundle | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/xCAT-test/autotest/bundle/rhels7.3_x86_64.bundle b/xCAT-test/autotest/bundle/rhels7.3_x86_64.bundle index a9a3aa760..8ecfc8866 100644 --- a/xCAT-test/autotest/bundle/rhels7.3_x86_64.bundle +++ b/xCAT-test/autotest/bundle/rhels7.3_x86_64.bundle @@ -1,5 +1,4 @@ -Diskless_installation_flat_p8_le -Full_installation_flat_p8_le +reg_linux_diskfull_installation_flat go_xcat_local_repo_case7 go_xcat_noinput go_xcat_with_x @@ -38,6 +37,9 @@ lsdef_t lsdef_t_i_o lsdef_t_w lsdef_t_err +lslite_i +lslite_noderange +lslite_h makeconservercf_null makeconservercf_noderange makeconservercf_d @@ -94,6 +96,7 @@ nodels_tablevalue_tablecolumn nodels_noderange_tablecolumn nodels_h nodels_v +xcatstanzafile_normal xcatstanzafile_colon xcatstanzafile_attribute xcatstanzafile_objtype @@ -107,6 +110,7 @@ noderm_null noderm_err_node nodeset_stat nodeset_noderange +nodestat_noderange nodestat_err_node rinv_noderange_err rmdef_null @@ -196,7 +200,15 @@ switchdiscover_range_r switchdiscover_range_x switchdiscover_range_z switchdiscover_range_z_V +nodeset_check_warninginfo nodeset_shell nodeset_cmdline nodeset_runimg +reg_linux_diskless_installation_flat +reg_linux_statelite_installation_flat +SN_setup_case +reg_linux_diskfull_installation_hierarchy +reg_linux_diskless_installation_hierarchy +reg_linux_statelite_installation_hierarchy_by_ramdisk +reg_linux_statelite_installation_hierarchy_by_nfs clean_up_env From 76ed1ab158038d5b017ddb80b5d28d9dfe62232b Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 12 Aug 2016 10:07:16 -0400 Subject: [PATCH 038/106] Provide a workaround for SD350 beacon SD350 standard command does not stay on indefinitely. Provide a workaround to cause that to stay on. --- xCAT-server/lib/xcat/plugins/ipmi.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/ipmi.pm b/xCAT-server/lib/xcat/plugins/ipmi.pm index 58eef13ea..77b65bebb 100644 --- a/xCAT-server/lib/xcat/plugins/ipmi.pm +++ b/xCAT-server/lib/xcat/plugins/ipmi.pm @@ -524,6 +524,10 @@ sub on_bmc_connect { } elsif ($command eq "rspreset") { return resetbmc($sessdata); } elsif ($command eq "rbeacon") { + unless (defined $sessdata->{device_id}) { #need get device id data initted for SD350 workaround + $sessdata->{ipmisession}->subcmd(netfn => 6, command => 1, data => [], callback => \&gotdevid, callback_args => $sessdata); + return; + } return beacon($sessdata); } elsif ($command eq "rsetboot") { return setboot($sessdata); @@ -2354,7 +2358,9 @@ sub beacon { #if stuck with 1.5, say light for 255 seconds. In 2.0, specify to turn it on forever if ($subcommand eq "on") { - if ($ipmiv2) { + if ($sessdata->{mfg_id} == 19046 and $sessdata->{prod_id} == 13616) { # Lenovo SD350 + $sessdata->{ipmisession}->subcmd(netfn => 0x3a, command => 6, data => [ 1, 1 ], callback => \&beacon_answer, callback_args => $sessdata); + } elsif ($ipmiv2) { $sessdata->{ipmisession}->subcmd(netfn => 0, command => 4, data => [ 0, 1 ], callback => \&beacon_answer, callback_args => $sessdata); } else { $sessdata->{ipmisession}->subcmd(netfn => 0, command => 4, data => [0xff], callback => \&beacon_answer, callback_args => $sessdata); From 2b54a0ed337c0373d5f6d2dc2accb6f1274f20d2 Mon Sep 17 00:00:00 2001 From: Casandra Qiu Date: Fri, 12 Aug 2016 15:38:09 -0400 Subject: [PATCH 039/106] genimage failed for rhels7.2 because /etc/selinux/config file didn't exists --- .../share/xcat/netboot/rh/compute.rhels7.ppc64.postinstall | 3 +++ .../share/xcat/netboot/rh/compute.rhels7.x86_64.postinstall | 4 +++- xCAT-server/share/xcat/netboot/rh/service.postinstall | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64.postinstall b/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64.postinstall index 0819752bb..e99463cbe 100755 --- a/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64.postinstall +++ b/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64.postinstall @@ -35,7 +35,10 @@ echo "co:2345:respawn:/sbin/agetty -L 38400 console" >> $installroot/etc/inittab #-- Disable SELinux in the rootimg #-- Redhat 7.3 will install selinux-policy and selinux is enabled by default #-- Need to disable selinux, otherwise, the booting will hang on "Loading selinux policy" +if [ -f "$installroot/etc/selinux/config" ] +then sed -i 's/SELINUX=enforcing\|permissive/SELINUX=disabled/' $installroot/etc/selinux/config +fi #-- Example of booted image versioning #-- We want to know, with what configuration (version of the image) each node was booted. diff --git a/xCAT-server/share/xcat/netboot/rh/compute.rhels7.x86_64.postinstall b/xCAT-server/share/xcat/netboot/rh/compute.rhels7.x86_64.postinstall index b8eee319e..c62bf2c6f 100755 --- a/xCAT-server/share/xcat/netboot/rh/compute.rhels7.x86_64.postinstall +++ b/xCAT-server/share/xcat/netboot/rh/compute.rhels7.x86_64.postinstall @@ -35,8 +35,10 @@ END #-- Disable SELinux in the rootimg #-- Redhat 7.3 will install selinux-policy and selinux is enabled by default #-- Need to disable selinux, otherwise, the booting will hang on "Loading selinux policy" +if [ -f "$installroot/etc/selinux/config" ] +then sed -i 's/SELINUX=enforcing\|permissive/SELINUX=disabled/' $installroot/etc/selinux/config - +fi #-- Example of booted image versioning #-- We want to know, with what configuration (version of the image) each node was booted. diff --git a/xCAT-server/share/xcat/netboot/rh/service.postinstall b/xCAT-server/share/xcat/netboot/rh/service.postinstall index 86e295e45..6eb1f16c5 100755 --- a/xCAT-server/share/xcat/netboot/rh/service.postinstall +++ b/xCAT-server/share/xcat/netboot/rh/service.postinstall @@ -39,7 +39,10 @@ echo "co:2345:respawn:/sbin/agetty -L 38400 console" >> $installroot/etc/inittab #-- Disable SELinux in the rootimg #-- Redhat 7.3 will install selinux-policy and selinux is enabled by default #-- Need to disable selinux, otherwise, the booting will hang on "Loading selinux policy" +if [ -f "$installroot/etc/selinux/config" ] +then sed -i 's/SELINUX=enforcing\|permissive/SELINUX=disabled/' $installroot/etc/selinux/config +fi #-- Example of booted image versioning #-- We want to know, with what configuration (version of the image) each node was booted. From 22fe457bc197a065218c211826b283c8a1005d8f Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 12 Aug 2016 15:57:11 -0400 Subject: [PATCH 040/106] Fix tcons interaction with filename globbing Filename globbing strings are not good to happen to noderanges. Use quotes to avoid it in script. Caller still needs to be careful to quote/escape on their end. --- xCAT-client/bin/tcons | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-client/bin/tcons b/xCAT-client/bin/tcons index c7f5ea4fb..cc0af755d 100755 --- a/xCAT-client/bin/tcons +++ b/xCAT-client/bin/tcons @@ -1,7 +1,7 @@ #!/bin/sh f=1 p=0 -for i in `nodels $1`; do +for i in `nodels "$1"`; do if [ "$f" = 1 ]; then f=0 qdate=$((`date +%s`+5)) From 33d30c8efa8aa41b42af8b969c3f6c2e41b89dfe Mon Sep 17 00:00:00 2001 From: Casandra Qiu Date: Fri, 12 Aug 2016 16:24:13 -0400 Subject: [PATCH 041/106] indent the line space --- .../share/xcat/netboot/rh/compute.rhels7.ppc64.postinstall | 2 +- .../share/xcat/netboot/rh/compute.rhels7.x86_64.postinstall | 2 +- xCAT-server/share/xcat/netboot/rh/service.postinstall | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64.postinstall b/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64.postinstall index e99463cbe..02effbf98 100755 --- a/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64.postinstall +++ b/xCAT-server/share/xcat/netboot/rh/compute.rhels7.ppc64.postinstall @@ -37,7 +37,7 @@ echo "co:2345:respawn:/sbin/agetty -L 38400 console" >> $installroot/etc/inittab #-- Need to disable selinux, otherwise, the booting will hang on "Loading selinux policy" if [ -f "$installroot/etc/selinux/config" ] then -sed -i 's/SELINUX=enforcing\|permissive/SELINUX=disabled/' $installroot/etc/selinux/config + sed -i 's/SELINUX=enforcing\|permissive/SELINUX=disabled/' $installroot/etc/selinux/config fi #-- Example of booted image versioning diff --git a/xCAT-server/share/xcat/netboot/rh/compute.rhels7.x86_64.postinstall b/xCAT-server/share/xcat/netboot/rh/compute.rhels7.x86_64.postinstall index c62bf2c6f..e8883be8f 100755 --- a/xCAT-server/share/xcat/netboot/rh/compute.rhels7.x86_64.postinstall +++ b/xCAT-server/share/xcat/netboot/rh/compute.rhels7.x86_64.postinstall @@ -37,7 +37,7 @@ END #-- Need to disable selinux, otherwise, the booting will hang on "Loading selinux policy" if [ -f "$installroot/etc/selinux/config" ] then -sed -i 's/SELINUX=enforcing\|permissive/SELINUX=disabled/' $installroot/etc/selinux/config + sed -i 's/SELINUX=enforcing\|permissive/SELINUX=disabled/' $installroot/etc/selinux/config fi #-- Example of booted image versioning diff --git a/xCAT-server/share/xcat/netboot/rh/service.postinstall b/xCAT-server/share/xcat/netboot/rh/service.postinstall index 6eb1f16c5..192b22c78 100755 --- a/xCAT-server/share/xcat/netboot/rh/service.postinstall +++ b/xCAT-server/share/xcat/netboot/rh/service.postinstall @@ -41,7 +41,7 @@ echo "co:2345:respawn:/sbin/agetty -L 38400 console" >> $installroot/etc/inittab #-- Need to disable selinux, otherwise, the booting will hang on "Loading selinux policy" if [ -f "$installroot/etc/selinux/config" ] then -sed -i 's/SELINUX=enforcing\|permissive/SELINUX=disabled/' $installroot/etc/selinux/config + sed -i 's/SELINUX=enforcing\|permissive/SELINUX=disabled/' $installroot/etc/selinux/config fi #-- Example of booted image versioning From e1775355f5382880aebadbc90a9093154cd55c4b Mon Sep 17 00:00:00 2001 From: immarvin Date: Fri, 12 Aug 2016 21:11:48 -0400 Subject: [PATCH 042/106] refine the tar options --- xCAT-server/lib/xcat/plugins/packimage.pm | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/packimage.pm b/xCAT-server/lib/xcat/plugins/packimage.pm index c6d96ebb5..82e4411f3 100755 --- a/xCAT-server/lib/xcat/plugins/packimage.pm +++ b/xCAT-server/lib/xcat/plugins/packimage.pm @@ -484,14 +484,14 @@ sub process_request { $oldmask = umask 0077; } elsif ($method =~ /tar/) { if (!$exlistloc) { - $excludestr = "find . -xdev -print0 | tar --selinux --xattrs-include='*' --null -T - -c | $compress -c - > ../rootimg.$suffix"; + $excludestr = "find . -xdev -print0 | tar --selinux --xattrs-include='*' --no-recursion --use-compress-program=$compress --null -T - -cf ../rootimg.$suffix"; } else { chdir("$rootimg_dir"); system("$excludestr >> $xcat_packimg_tmpfile"); if ($includestr) { system("$includestr >> $xcat_packimg_tmpfile"); } - $excludestr = "cat $xcat_packimg_tmpfile| tar --selinux --xattrs-include='*' -T - -c | $compress -c - > ../rootimg.$suffix"; + $excludestr = "cat $xcat_packimg_tmpfile| tar --selinux --xattrs-include='*' --no-recursion --use-compress-program=$compress -T - -cf ../rootimg.$suffix"; } $oldmask = umask 0077; } elsif ($method =~ /squashfs/) { @@ -508,8 +508,15 @@ sub process_request { return 1; } chdir("$rootimg_dir"); - my $outputmsg = `$excludestr`; - $callback->({ info => ["$outputmsg"] }); + my $outputmsg = `$excludestr 2>&1`; + unless($?){ + $callback->({ info => ["$outputmsg"] }); + }else{ + $callback->({ info => ["$outputmsg"] }); + $callback->({ error => ["packimage failed while running: \n $excludestr"], errorcode => [1] }); + system("rm -rf $xcat_packimg_tmpfile"); + return 1; + } if ($method =~ /cpio/) { chmod 0644, "$destdir/rootimg.$suffix"; if ($dotorrent) { From 5699b025dd0602f54124d382265803a3bbe9fae7 Mon Sep 17 00:00:00 2001 From: immarvin Date: Sat, 13 Aug 2016 00:30:56 -0400 Subject: [PATCH 043/106] fix issue [FVT]on rhels6.8, rootimg.tar.gz is only 20 bytes after run packimage -m tar rhels6.8-ppc64-netboot-compute ; fix issue #1689 [FVT]:diskless provision broken using rootimg.tar.gz created by packimage -m tar osimage #1688 --- xCAT-server/share/xcat/netboot/rh/dracut/xcatroot | 4 ++-- xCAT-server/share/xcat/netboot/rh/dracut_033/xcatroot | 4 ++-- xCAT-server/share/xcat/netboot/rh/genimage | 4 ++-- xCAT-server/share/xcat/netboot/sles/dracut_033/xcatroot | 4 ++-- xCAT-server/share/xcat/netboot/sles/genimage | 4 ++-- xCAT-server/share/xcat/netboot/ubuntu/dracut/xcatroot | 4 ++-- xCAT-server/share/xcat/netboot/ubuntu/genimage | 6 +++--- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/xCAT-server/share/xcat/netboot/rh/dracut/xcatroot b/xCAT-server/share/xcat/netboot/rh/dracut/xcatroot index 4d20531fa..367625618 100755 --- a/xCAT-server/share/xcat/netboot/rh/dracut/xcatroot +++ b/xCAT-server/share/xcat/netboot/rh/dracut/xcatroot @@ -106,9 +106,9 @@ elif [ -r /rootimg.tar.gz ] || [ -r /rootimg.tar.xz ]; then cd $NEWROOT echo -n "Extracting root filesystem:" if [ -r /rootimg.tar.gz ]; then - tar --selinux --xattrs-include='*' -zxvf /rootimg.tar.gz + tar --selinux --xattrs-include='*' -zxf /rootimg.tar.gz elif [ -r /rootimg.tar.xz ]; then - tar --selinux --xattrs-include='*' -Jxvf /rootimg.tar.xz + tar --selinux --xattrs-include='*' -Jxf /rootimg.tar.xz fi $NEWROOT/etc/init.d/localdisk echo Done diff --git a/xCAT-server/share/xcat/netboot/rh/dracut_033/xcatroot b/xCAT-server/share/xcat/netboot/rh/dracut_033/xcatroot index 0bc2ebcd9..58a33895e 100755 --- a/xCAT-server/share/xcat/netboot/rh/dracut_033/xcatroot +++ b/xCAT-server/share/xcat/netboot/rh/dracut_033/xcatroot @@ -110,9 +110,9 @@ elif [ -r /rootimg.tar.gz ] || [ -r /rootimg.tar.xz ]; then [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Extracting root filesystem:" echo -n "Extracting root filesystem:" if [ -r /rootimg.tar.gz ]; then - tar --selinux --xattrs-include='*' -zxvf /rootimg.tar.gz + tar --selinux --xattrs-include='*' -zxf /rootimg.tar.gz elif [ -r /rootimg.tar.xz ]; then - tar --selinux --xattrs-include='*' -Jxvf /rootimg.tar.xz + tar --selinux --xattrs-include='*' -Jxf /rootimg.tar.xz fi $NEWROOT/etc/init.d/localdisk [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Done...." diff --git a/xCAT-server/share/xcat/netboot/rh/genimage b/xCAT-server/share/xcat/netboot/rh/genimage index aa13d2855..bc5104c41 100755 --- a/xCAT-server/share/xcat/netboot/rh/genimage +++ b/xCAT-server/share/xcat/netboot/rh/genimage @@ -1640,9 +1640,9 @@ EOMS print $inifile " cd \$NEWROOT\n"; print $inifile " echo -n \"Extracting root filesystem:\"\n"; print $inifile " if [ -r /rootimg.tar.gz ]; then\n"; - print $inifile " tar --selinux --xattrs-include='*' -zxvf /rootimg.tar.gz\n"; + print $inifile " tar --selinux --xattrs-include='*' -zxf /rootimg.tar.gz\n"; print $inifile " elif [ -r /rootimg.tar.xz ]; then\n"; - print $inifile " tar --selinux --xattrs-include='*' -Jxvf /rootimg.tar.xz\n"; + print $inifile " tar --selinux --xattrs-include='*' -Jxf /rootimg.tar.xz\n"; print $inifile " fi\n"; print $inifile " echo Done\n"; print $inifile "else\n"; diff --git a/xCAT-server/share/xcat/netboot/sles/dracut_033/xcatroot b/xCAT-server/share/xcat/netboot/sles/dracut_033/xcatroot index acd7b3ebf..b12eb9a3f 100755 --- a/xCAT-server/share/xcat/netboot/sles/dracut_033/xcatroot +++ b/xCAT-server/share/xcat/netboot/sles/dracut_033/xcatroot @@ -108,9 +108,9 @@ elif [ -r /rootimg.tar.gz ] || [ -r /rootimg.tar.xz ]; then [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Extracting root filesystem:" echo -n "Extracting root filesystem:" if [ -r /rootimg.tar.gz ]; then - tar --selinux --xattrs-include='*' -zxvf /rootimg.tar.gz + tar --selinux --xattrs-include='*' -zxf /rootimg.tar.gz elif [ -r /rootimg.tar.xz ]; then - tar --selinux --xattrs-include='*' -Jxvf /rootimg.tar.xz + tar --selinux --xattrs-include='*' -Jxf /rootimg.tar.xz fi $NEWROOT/etc/init.d/localdisk [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Done...." diff --git a/xCAT-server/share/xcat/netboot/sles/genimage b/xCAT-server/share/xcat/netboot/sles/genimage index 3fbe3c6c2..23ca97d2c 100755 --- a/xCAT-server/share/xcat/netboot/sles/genimage +++ b/xCAT-server/share/xcat/netboot/sles/genimage @@ -1658,9 +1658,9 @@ EOMS print $inifile " cd \$NEWROOT\n"; print $inifile " echo -n \"Extracting root filesystem:\"\n"; print $inifile " if [ -r /rootimg.tar.gz ]; then\n"; - print $inifile " tar --selinux --xattrs-include='*' -zxvf /rootimg.tar.gz\n"; + print $inifile " tar --selinux --xattrs-include='*' -zxf /rootimg.tar.gz\n"; print $inifile " elif [ -r /rootimg.tar.xz ]; then\n"; - print $inifile " tar --selinux --xattrs-include='*' -Jxvf /rootimg.tar.xz\n"; + print $inifile " tar --selinux --xattrs-include='*' -Jxf /rootimg.tar.xz\n"; print $inifile " fi\n"; print $inifile " echo Done\n"; print $inifile "else\n"; diff --git a/xCAT-server/share/xcat/netboot/ubuntu/dracut/xcatroot b/xCAT-server/share/xcat/netboot/ubuntu/dracut/xcatroot index 67f40c8ed..2c76d7690 100755 --- a/xCAT-server/share/xcat/netboot/ubuntu/dracut/xcatroot +++ b/xCAT-server/share/xcat/netboot/ubuntu/dracut/xcatroot @@ -64,9 +64,9 @@ elif [ -r /rootimg.tar.gz ] || [ -r /rootimg.tar.xz ]; then cd $NEWROOT echo -n "Extracting root filesystem:" if [ -r /rootimg.tar.gz ]; then - tar --selinux --xattrs-include='*' -zxvf /rootimg.tar.gz + tar --selinux --xattrs-include='*' -zxf /rootimg.tar.gz elif [ -r /rootimg.tar.xz ]; then - tar --selinux --xattrs-include='*' -Jxvf /rootimg.tar.xz + tar --selinux --xattrs-include='*' -Jxf /rootimg.tar.xz fi echo Done elif [ -r /rootimg-statelite.gz ]; then diff --git a/xCAT-server/share/xcat/netboot/ubuntu/genimage b/xCAT-server/share/xcat/netboot/ubuntu/genimage index 8934e44b1..e2ba372f0 100755 --- a/xCAT-server/share/xcat/netboot/ubuntu/genimage +++ b/xCAT-server/share/xcat/netboot/ubuntu/genimage @@ -1480,9 +1480,9 @@ EOMS print $inifile " ([ \"\$xcatdebugmode\" = \"1\" ] || [ \"\$xcatdebugmode\" = \"2\" ]) && logger -t xcat -p debug \"Extracting root filesystem:\"\n"; print $inifile " echo -n \"Extracting root filesystem:\"\n"; print $inifile " if [ -r /rootimg.tar.gz ]; then\n"; - print $inifile " tar --selinux --xattrs-include='*' -zxvf /rootimg.tar.gz\n"; + print $inifile " /bin/tar --selinux --xattrs-include='*' -zxf /rootimg.tar.gz\n"; print $inifile " elif [ -r /rootimg.tar.xz ]; then\n"; - print $inifile " tar --selinux --xattrs-include='*' -Jxvf /rootimg.tar.xz\n"; + print $inifile " /bin/tar --selinux --xattrs-include='*' -Jxf /rootimg.tar.xz\n"; print $inifile " fi\n"; print $inifile " ([ \"\$xcatdebugmode\" = \"1\" ] || [ \"\$xcatdebugmode\" = \"2\" ]) && logger -t xcat -p debug \"Done...\"\n"; print $inifile " echo Done\n"; @@ -1624,7 +1624,7 @@ EOMS } # add rsync for statelite - foreach ("usr/bin/dig", "bin/busybox", "bin/bash", "sbin/mount.nfs", "usr/bin/rsync", "sbin/insmod", "sbin/udevd", "sbin/udevadm", "sbin/modprobe", "sbin/blkid", "sbin/depmod", "usr/bin/wget", "usr/bin/xz", "usr/bin/gzip", "usr/bin/tar") { + foreach ("usr/bin/dig", "bin/busybox", "bin/bash", "sbin/mount.nfs", "usr/bin/rsync", "sbin/insmod", "sbin/udevd", "sbin/udevadm", "sbin/modprobe", "sbin/blkid", "sbin/depmod", "usr/bin/wget", "usr/bin/xz", "bin/gzip", "bin/tar") { getlibs($_); push @filestoadd, $_; } From be77e5f43f5f55e26da22b9d226972367e4f7287 Mon Sep 17 00:00:00 2001 From: immarvin Date: Sat, 13 Aug 2016 02:53:05 -0400 Subject: [PATCH 044/106] fix issue [DEV] it is ambiguous to determine which compressed rootimg to use among rootimg.tar.gz,rootimg.cpio.gz,rootimg.tar.xz... #1695; update the manpage and usage info of packimage --- .../admin-guides/references/man1/packimage.1.rst | 14 +++++++++++--- xCAT-client/pods/man1/packimage.1.pod | 9 ++++++--- xCAT-server/lib/xcat/plugins/packimage.pm | 12 +++++++++--- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/docs/source/guides/admin-guides/references/man1/packimage.1.rst b/docs/source/guides/admin-guides/references/man1/packimage.1.rst index 20651fbda..4507bdc5c 100644 --- a/docs/source/guides/admin-guides/references/man1/packimage.1.rst +++ b/docs/source/guides/admin-guides/references/man1/packimage.1.rst @@ -23,7 +23,7 @@ SYNOPSIS \ **packimage [-v| -**\ **-version]**\ -\ **packimage**\ \ *imagename*\ +\ **packimage**\ [\ **-m | -**\ **-method**\ \ *cpio|tar*\ ] [\ **-c | -**\ **-compress**\ \ *gzip|pigz|xz*\ ] \ *imagename*\ *********** @@ -62,9 +62,9 @@ OPTIONS \ **-a**\ Architecture (ppc64,x86_64,etc) -\ **-m**\ Archive Method (cpio,tar,squashfs, default is cpio) +\ **-m| -**\ **-method**\ Archive Method (cpio,tar,squashfs, default is cpio) -\ **-c**\ Compress Method (pigz,gzip,xz, default is pigz) +\ **-c| -**\ **-compress**\ Compress Method (pigz,gzip,xz, default is pigz/gzip) ************ @@ -90,6 +90,14 @@ EXAMPLES packimage rhels7.1-x86_64-netboot-compute +2. To pack the osimage rhels7.1-x86_64-netboot-compute with "tar" to archive and "pigz" to compress: + + +.. code-block:: perl + + packimage -m tar -c pigz rhels7.1-x86_64-netboot-compute + + ***** FILES diff --git a/xCAT-client/pods/man1/packimage.1.pod b/xCAT-client/pods/man1/packimage.1.pod index 60b34fe6f..4daa2d03a 100644 --- a/xCAT-client/pods/man1/packimage.1.pod +++ b/xCAT-client/pods/man1/packimage.1.pod @@ -8,7 +8,7 @@ B B -B I +B [B<-m>|B<--method> I] [B<-c>|B<--compress> I] I =head1 DESCRIPTION @@ -36,9 +36,9 @@ B<-p> Profile (compute,service) B<-a> Architecture (ppc64,x86_64,etc) -B<-m> Archive Method (cpio,tar,squashfs, default is cpio) +B<-m| --method> Archive Method (cpio,tar,squashfs, default is cpio) -B<-c> Compress Method (pigz,gzip,xz, default is pigz) +B<-c| --compress> Compress Method (pigz,gzip,xz, default is pigz/gzip) =head1 RETURN VALUE @@ -53,6 +53,9 @@ B<-c> Compress Method (pigz,gzip,xz, default is pigz) packimage rhels7.1-x86_64-netboot-compute +2. To pack the osimage rhels7.1-x86_64-netboot-compute with "tar" to archive and "pigz" to compress: + + packimage -m tar -c pigz rhels7.1-x86_64-netboot-compute =head1 FILES diff --git a/xCAT-server/lib/xcat/plugins/packimage.pm b/xCAT-server/lib/xcat/plugins/packimage.pm index 82e4411f3..60062d26d 100755 --- a/xCAT-server/lib/xcat/plugins/packimage.pm +++ b/xCAT-server/lib/xcat/plugins/packimage.pm @@ -79,7 +79,7 @@ sub process_request { @ARGV = @{$args}; } if (scalar(@ARGV) == 0) { - $callback->({ info => ["Usage:\n packimage \n packimage [-h| --help]\n packimage [-v| --version]"] }); + $callback->({ info => ["Usage:\n packimage [-m| --method=cpio|tar] [-c| --compress=gzip|pigz|xz] \n packimage [-h| --help]\n packimage [-v| --version]"] }); return 0; } @@ -114,7 +114,7 @@ sub process_request { return 0; } if ($help) { - $callback->({ info => ["Usage:\n packimage \n packimage [-h| --help]\n packimage [-v| --version]"] }); + $callback->({ info => ["Usage:\n packimage [-m| --method=cpio|tar] [-c| --compress=gzip|pigz|xz] \n packimage [-h| --help]\n packimage [-v| --version]"] }); return 0; } @@ -468,8 +468,12 @@ sub process_request { } $suffix = $method.".".$suffix; - unlink("$destdir/rootimg.$suffix"); unlink("$destdir/rootimg.sfs"); + unlink("$destdir/rootimg.cpio.xz"); + unlink("$destdir/rootimg.cpio.gz"); + unlink("$destdir/rootimg.tar.xz"); + unlink("$destdir/rootimg.tar.gz"); + if ($method =~ /cpio/) { if (!$exlistloc) { $excludestr = "find . -xdev -print0 | cpio -H newc -o -0 | $compress -c - > ../rootimg.$suffix"; @@ -507,6 +511,7 @@ sub process_request { $callback->({ error => ["Invalid archive method '$method' requested"], errorcode => [1] }); return 1; } + chdir("$rootimg_dir"); my $outputmsg = `$excludestr 2>&1`; unless($?){ @@ -517,6 +522,7 @@ sub process_request { system("rm -rf $xcat_packimg_tmpfile"); return 1; } + if ($method =~ /cpio/) { chmod 0644, "$destdir/rootimg.$suffix"; if ($dotorrent) { From 665bf66f47cf569d4799e0eeb7d078ae1c66f293 Mon Sep 17 00:00:00 2001 From: Weihua Hu Date: Sat, 13 Aug 2016 15:04:55 +0800 Subject: [PATCH 045/106] Fix bug1687 xcatprobe could not surpport xcatmn command on ubuntu (#1691) * fix bug1687 xcatprobe could not surpport xcatmn command on ubuntu * remove useless files --- build-ubunturepo | 6 +- xCAT-probe/lib/perl/xCAT/GlobalDef.pm | 103 - xCAT-probe/lib/perl/xCAT/NetworkUtils.pm | 2651 ---------------------- 3 files changed, 3 insertions(+), 2757 deletions(-) delete mode 100644 xCAT-probe/lib/perl/xCAT/GlobalDef.pm delete mode 100644 xCAT-probe/lib/perl/xCAT/NetworkUtils.pm diff --git a/build-ubunturepo b/build-ubunturepo index c1b02b09a..769b34b67 100755 --- a/build-ubunturepo +++ b/build-ubunturepo @@ -234,9 +234,9 @@ then if [ $file_low = "xcat-probe" ]; then CURDIR=$(pwd) mkdir -p ${CURDIR}/xCAT-probe/lib/perl/xCAT/ - cp -f ${CURDIR}/perl-xCAT/xCAT/NetworkUtils.pm ${CURDIR}/xCAT-probe/lib/perl/xCAT/ - cp -f ${CURDIR}/perl-xCAT/xCAT/GlobalDef.pm ${CURDIR}/xCAT-probe/lib/perl/xCAT/ - cp -f ${CURDIR}/perl-xCAT/xCAT/ServiceNodeUtils.pm ${CURDIR}/xCAT-probe/lib/perl/xCAT/ + cp -f ${CURDIR}/../perl-xCAT/xCAT/NetworkUtils.pm ${CURDIR}/lib/perl/xCAT/ + cp -f ${CURDIR}/../perl-xCAT/xCAT/GlobalDef.pm ${CURDIR}/lib/perl/xCAT/ + cp -f ${CURDIR}/../perl-xCAT/xCAT/ServiceNodeUtils.pm ${CURDIR}/lib/perl/xCAT/ fi dpkg-buildpackage -uc -us else diff --git a/xCAT-probe/lib/perl/xCAT/GlobalDef.pm b/xCAT-probe/lib/perl/xCAT/GlobalDef.pm deleted file mode 100644 index b953a5168..000000000 --- a/xCAT-probe/lib/perl/xCAT/GlobalDef.pm +++ /dev/null @@ -1,103 +0,0 @@ -#!/usr/bin/env perl -# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html -package xCAT::GlobalDef; - -#-------------------------------------------------------------------------------- - -=head1 xCAT::GlobalDef - -=head2 Package Description - -This module contains all the global info for xCAT. - - -=cut - -#-------------------------------------------------------------------------------- - - -# valid values for nodelist.hwtype column -$::NODETYPE_LPAR = "lpar"; -$::NODETYPE_BPA = "bpa"; -$::NODETYPE_FSP = "fsp"; -$::NODETYPE_HMC = "hmc"; -$::NODETYPE_IVM = "ivm"; -$::NODETYPE_FRAME = "frame"; -$::NODETYPE_CEC = "cec"; -$::NODETYPE_BLADE = "blade"; -$::NODETYPE_CMM = "cmm"; - -# valid values for nodelist.nodetype column -$::NODETYPE_OSI = "osi"; -$::NODETYPE_PPC = "ppc"; -$::NODETYPE_ZVM = "zvm"; -$::NODETYPE_MP = "mp"; - -#valid values for nodelist.updatestatus -$::STATUS_SYNCING = "syncing"; -$::STATUS_OUT_OF_SYNC = "out-of-sync"; -$::STATUS_SYNCED = "synced"; -$::STATUS_FAILED = "failed"; - - -# valid values for nodelist.status columns or other status -$::STATUS_ACTIVE = "alive"; -$::STATUS_INACTIVE = "unreachable"; -$::STATUS_INSTALLING = "installing"; -$::STATUS_INSTALLED = "installed"; -$::STATUS_BOOTING = "booting"; -$::STATUS_NETBOOTING = "netbooting"; -$::STATUS_BOOTED = "booted"; -$::STATUS_POWERING_ON = "powering-on"; -$::STATUS_POWERING_OFF = "powering-off"; -$::STATUS_DISCOVERING = "discovering"; -$::STATUS_CONFIGURING = "configuring"; -$::STATUS_STANDING_BY = "standingby"; -$::STATUS_SHELL = "shell"; -$::STATUS_DEFINED = "defined"; -$::STATUS_UNKNOWN = "unknown"; -$::STATUS_FAILED = "failed"; -$::STATUS_BMCREADY = "bmcready"; -%::VALID_STATUS_VALUES = ( - $::STATUS_ACTIVE => 1, - $::STATUS_INACTIVE => 1, - $::STATUS_INSTALLING => 1, - $::STATUS_INSTALLED => 1, - $::STATUS_BOOTING => 1, - $::STATUS_NETBOOTING => 1, - $::STATUS_BOOTED => 1, - $::STATUS_POWERING_ON => 1, - $::STATUS_POWERING_OFF => 1, - $::STATUS_DISCOVERING => 1, - $::STATUS_CONFIGURING => 1, - $::STATUS_STANDING_BY => 1, - $::STATUS_SHELL => 1, - $::STATUS_DEFINED => 1, - $::STATUS_UNKNOWN => 1, - $::STATUS_FAILED => 1, - $::STATUS_BMCREADY => 1, - - $::STATUS_SYNCING => 1, - $::STATUS_OUT_OF_SYNC => 1, - $::STATUS_SYNCED => 1, -); - -#defined->[discovering]->[configuring]->[standingby]->installing->[installed]->booting->alive, defined->[discovering]->[configuring]-[standingby]->netbooting->booted->alive, alive/unreachable->booting->alive, powering-off->unreachable, alive->unreachable -%::NEXT_NODESTAT_VAL = ( - $::STATUS_DEFINED => { $::STATUS_DISCOVERING => 1, $::STATUS_INSTALLING => 1, $::STATUS_NETBOOTING => 1, $::STATUS_POWERING_OFF => 1, $::STATUS_POWERING_ON => 1, $::STATUS_BOOTING => 1, $::STATUS_CONFIGURING => 1 }, - $::STATUS_DISCOVERING => { $::STATUS_INSTALLING => 1, $::STATUS_NETBOOTING => 1, $::STATUS_CONFIGURING => 1, $::STATUS_BOOTING => 1 }, - $::STATUS_CONFIGURING => { $::STATUS_INSTALLING => 1, $::STATUS_NETBOOTING => 1, $::STATUS_STANDING_BY => 1 }, - $::STATUS_INSTALLING => { $::STATUS_INSTALLED => 1, $::STATUS_BOOTING => 1 }, - $::STATUS_INSTALLED => { $::STATUS_BOOTING => 1 }, - $::STATUS_BOOTING => { $::STATUS_BOOTED => 1, $::STATUS_ACTIVE => 1, $::STATUS_INACTIVE => 1 }, - $::STATUS_NETBOOTING => { $::STATUS_BOOTED => 1 }, - $::STATUS_BOOTED => { $::STATUS_ACTIVE => 1, $::STATUS_INACTIVE => 1 }, - $::STATUS_ACTIVE => { $::STATUS_INACTIVE => 1, $::STATUS_DISCOVERING => 1, $::STATUS_CONFIGURING => 1, $::STATUS_INSTALLING => 1, $::STATUS_NETBOOTING => 1, $::STATUS_POWERING_OFF => 1, $::STATUS_POWERING_ON => 1 }, - $::STATUS_INACTIVE => { $::STATUS_ACTIVE => 1, $::STATUS_DISCOVERING => 1, $::STATUS_CONFIGURING => 1, $::STATUS_INSTALLING => 1, $::STATUS_NETBOOTING => 1, $::STATUS_POWERING_OFF => 1, $::STATUS_POWERING_ON => 1 }, - $::STATUS_POWERING_OFF => { $::STATUS_INACTIVE => 1 }, - $::STATUS_POWERING_ON => { $::STATUS_BOOTED => 1 } -); - - -1; - diff --git a/xCAT-probe/lib/perl/xCAT/NetworkUtils.pm b/xCAT-probe/lib/perl/xCAT/NetworkUtils.pm deleted file mode 100644 index ed4694a70..000000000 --- a/xCAT-probe/lib/perl/xCAT/NetworkUtils.pm +++ /dev/null @@ -1,2651 +0,0 @@ -#!/usr/bin/env perl -# IBM(c) 2010 EPL license http://www.eclipse.org/legal/epl-v10.html -package xCAT::NetworkUtils; - -BEGIN -{ - $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat'; -} - -# if AIX - make sure we include perl 5.8.2 in INC path. -# Needed to find perl dependencies shipped in deps tarball. -if ($^O =~ /^aix/i) { - unshift(@INC, qw(/usr/opt/perl5/lib/5.8.2/aix-thread-multi /usr/opt/perl5/lib/5.8.2 /usr/opt/perl5/lib/site_perl/5.8.2/aix-thread-multi /usr/opt/perl5/lib/site_perl/5.8.2)); -} - -use lib "$::XCATROOT/lib/perl"; -use POSIX qw(ceil); -use File::Path; -use Math::BigInt; -use Socket; -use xCAT::GlobalDef; - -#use Data::Dumper; -use strict; -use warnings "all"; -my $socket6support = eval { require Socket6 }; - -our @ISA = qw(Exporter); -our @EXPORT_OK = qw(getipaddr); - -my $utildata; #data to persist locally - -#-------------------------------------------------------------------------------- - -=head1 xCAT::NetworkUtils - -=head2 Package Description - -This program module file, is a set of network utilities used by xCAT commands. - -=cut - -#------------------------------------------------------------- - -#------------------------------------------------------------------------------- - -=head3 getNodeDomains - - Gets the network domain for a list of nodes - - The domain value comes from the network definition - associated with the node ip address. - - If the network domain is not set then the default is to - use the site.domain value - - Arguments: - list of nodes - Returns: - error - undef - success - hash ref of domains for each node - Globals: - $::VERBOSE - Error: - Example: - my $nodedomains = xCAT::NetworkUtils->getNodeDomains(\@nodes, $callback); - Comments: - none -=cut - -#------------------------------------------------------------------------------- -sub getNodeDomains() -{ - my $class = shift; - my $nodes = shift; - - my @nodelist = @$nodes; - my %nodedomains; - - # Get the network info for each node - my %nethash = xCAT::DBobjUtils->getNetwkInfo(\@nodelist); - - # get the site domain value - my @domains = xCAT::TableUtils->get_site_attribute("domain"); - my $sitedomain = $domains[0]; - - # for each node - set hash value to network domain or default - # to site domain - foreach my $node (@nodelist) { - unless (defined($node)) { next; } - if (defined($nethash{$node}) && $nethash{$node}{domain}) { - $nodedomains{$node} = $nethash{$node}{domain}; - } else { - $nodedomains{$node} = $sitedomain; - } - } - - return \%nodedomains; -} - -#------------------------------------------------------------------------------- - -=head3 gethostnameandip - Works for both IPv4 and IPv6. - Takes either a host name or an IP address string - and performs a lookup on that name, - returns an array with two elements: the hostname, the ip address - if the host name or ip address can not be resolved, - the corresponding element in the array will be undef - Arguments: - hostname or ip address - Returns: the hostname and the ip address - Globals: - - Error: - none - Example: - my ($host, $ip) = xCAT::NetworkUtils->gethostnameandip($iporhost); - Comments: - none -=cut - -#------------------------------------------------------------------------------- -sub gethostnameandip() -{ - my ($class, $iporhost) = @_; - - if (($iporhost =~ /\d+\.\d+\.\d+\.\d+/) || ($iporhost =~ /:/)) #ip address - { - return (xCAT::NetworkUtils->gethostname($iporhost), $iporhost); - } - else #hostname - { - return ($iporhost, xCAT::NetworkUtils->getipaddr($iporhost)); - } -} - -#------------------------------------------------------------------------------- - -=head3 gethostname - Works for both IPv4 and IPv6. - Takes an IP address string and performs a lookup on that name, - returns the hostname of the ip address - if the ip address can not be resolved, returns undef - Arguments: - ip address - Returns: the hostname - Globals: - cache: %::iphosthash - Error: - none - Example: - my $host = xCAT::NetworkUtils->gethostname($ip); - Comments: - none -=cut - -#------------------------------------------------------------------------------- -sub gethostname() -{ - my ($class, $iporhost) = @_; - - if (!defined($iporhost)) - { - return undef; - } - - if (ref($iporhost) eq 'ARRAY') - { - $iporhost = @{$iporhost}[0]; - if (!$iporhost) - { - return undef; - } - } - - if (($iporhost !~ /\d+\.\d+\.\d+\.\d+/) && ($iporhost !~ /:/)) - { - #why you do so? pass in a hostname and only want a hostname?? - return $iporhost; - } - - #cache, do not lookup DNS each time - if (defined($::iphosthash{$iporhost}) && $::iphosthash{$iporhost}) - { - return $::iphosthash{$iporhost}; - } - else - { - if ($socket6support) # the getaddrinfo and getnameinfo supports both IPv4 and IPv6 - { - my ($family, $socket, $protocol, $ip, $name) = Socket6::getaddrinfo($iporhost, 0, AF_UNSPEC, SOCK_STREAM, 6); #specifically ask for TCP capable records, maximizing chance of no more than one return per v4/v6 - my $host = (Socket6::getnameinfo($ip))[0]; - if ($host eq $iporhost) # can not resolve - { - return undef; - } - if ($host) - { - $host =~ s/\..*//; #short hostname - } - return $host; - } - else - { - #it is possible that no Socket6 available, - #but passing in IPv6 address, such as ::1 on loopback - if ($iporhost =~ /:/) - { - return undef; - } - my $hostname = gethostbyaddr(inet_aton($iporhost), AF_INET); - if ($hostname) { - $hostname =~ s/\..*//; #short hostname - } - return $hostname; - } - } -} - -#------------------------------------------------------------------------------- - -=head3 getipaddr - Works for both IPv4 and IPv6. - Takes a hostname string and performs a lookup on that name, - returns the the ip address of the hostname - if the hostname can not be resolved, returns undef - Arguments: - hostname - Optional: - GetNumber=>1 (return the address as a BigInt instead of readable string) - Returns: ip address - Globals: - cache: %::hostiphash - Error: - none - Example: - my $ip = xCAT::NetworkUtils->getipaddr($hostname); - Comments: - none -=cut - -#------------------------------------------------------------------------------- -sub getipaddr -{ - my $iporhost = shift; - if ($iporhost eq 'xCAT::NetworkUtils') { #was called with -> syntax - $iporhost = shift; - } - my %extraarguments = @_; - - if (!defined($iporhost)) - { - return undef; - } - - if (ref($iporhost) eq 'ARRAY') - { - $iporhost = @{$iporhost}[0]; - if (!$iporhost) - { - return undef; - } - } - - #go ahead and do the reverse lookup on ip, useful to 'frontend' aton/pton and also to - #spit out a common abbreviation if leading zeroes or using different ipv6 presentation rules - #if ($iporhost and ($iporhost =~ /\d+\.\d+\.\d+\.\d+/) || ($iporhost =~ /:/)) - #{ - # #pass in an ip and only want an ip?? - # return $iporhost; - #} - - #cache, do not lookup DNS each time - if ($::hostiphash and defined($::hostiphash{$iporhost}) && $::hostiphash{$iporhost}) - { - return $::hostiphash{$iporhost}; - } - else - { - if ($socket6support) # the getaddrinfo and getnameinfo supports both IPv4 and IPv6 - { - my @returns; - my $reqfamily = AF_UNSPEC; - if ($extraarguments{OnlyV6}) { - $reqfamily = AF_INET6; - } elsif ($extraarguments{OnlyV4}) { - $reqfamily = AF_INET; - } - my @addrinfo = Socket6::getaddrinfo($iporhost, 0, $reqfamily, SOCK_STREAM, 6); - my ($family, $socket, $protocol, $ip, $name) = splice(@addrinfo, 0, 5); - while ($ip) - { - if ($extraarguments{GetNumber}) { #return a BigInt for compare, e.g. for comparing ip addresses for determining if they are in a common network or range - my $ip = (Socket6::getnameinfo($ip, Socket6::NI_NUMERICHOST()))[0]; - my $bignumber = Math::BigInt->new(0); - foreach (unpack("N*", Socket6::inet_pton($family, $ip))) { #if ipv4, loop will iterate once, for v6, will go 4 times - $bignumber->blsft(32); - $bignumber->badd($_); - } - push(@returns, $bignumber); - } else { - push @returns, (Socket6::getnameinfo($ip, Socket6::NI_NUMERICHOST()))[0]; - } - if (scalar @addrinfo and $extraarguments{GetAllAddresses}) { - ($family, $socket, $protocol, $ip, $name) = splice(@addrinfo, 0, 5); - } else { - $ip = 0; - } - } - unless ($extraarguments{GetAllAddresses}) { - return $returns[0]; - } - return @returns; - } - else - { - #return inet_ntoa(inet_aton($iporhost)) - #TODO, what if no scoket6 support, but passing in a IPv6 hostname? - if ($iporhost =~ /:/) { #ipv6 - return undef; - - #die "Attempt to process IPv6 address, but system does not have requisite IPv6 perl support"; - } - my $packed_ip; - $iporhost and $packed_ip = inet_aton($iporhost); - if (!$packed_ip) - { - return undef; - } - if ($extraarguments{GetNumber}) { #only 32 bits, no for loop needed. - return Math::BigInt->new(unpack("N*", $packed_ip)); - } - return inet_ntoa($packed_ip); - } - } -} - -#------------------------------------------------------------------------------- - -=head3 linklocaladdr - Only for IPv6. - Takes a mac address, calculate the IPv6 link local address - Arguments: - mac address - Returns: - ipv6 link local address. returns undef if passed in a invalid mac address - Globals: - Error: - none - Example: - my $linklocaladdr = xCAT::NetworkUtils->linklocaladdr($mac); - Comments: - none -=cut - -#------------------------------------------------------------------------------- -sub linklocaladdr { - my ($class, $mac) = @_; - $mac = lc($mac); - my $localprefix = "fe80"; - - my ($m1, $m2, $m3, $m6, $m7, $m8); - - # mac address can be 00215EA376B0 or 00:21:5E:A3:76:B0 - if ($mac =~ /^([0-9A-Fa-f]{2}).*?([0-9A-Fa-f]{2}).*?([0-9A-Fa-f]{2}).*?([0-9A-Fa-f]{2}).*?([0-9A-Fa-f]{2}).*?([0-9A-Fa-f]{2})$/) - { - ($m1, $m2, $m3, $m6, $m7, $m8) = ($1, $2, $3, $4, $5, $6); - } - else - { - #not a valid mac address - return undef; - } - my ($m4, $m5) = ("ff", "fe"); - - #my $bit = (int $m1) & 2; - #if ($bit) { - # $m1 = $m1 - 2; - #} else { - # $m1 = $m1 + 2; - #} - $m1 = hex($m1); - $m1 = $m1 ^ 2; - $m1 = sprintf("%x", $m1); - - $m1 = $m1 . $m2; - $m3 = $m3 . $m4; - $m5 = $m5 . $m6; - $m7 = $m7 . $m8; - - my $laddr = join ":", $m1, $m3, $m5, $m7; - $laddr = join "::", $localprefix, $laddr; - - return $laddr; -} - - -#------------------------------------------------------------------------------- - -=head3 ishostinsubnet - Works for both IPv4 and IPv6. - Takes an ip address, the netmask and a subnet, - chcek if the ip address is in the subnet - Arguments: - ip address, netmask, subnet - Returns: - 1 - if the ip address is in the subnet - 0 - if the ip address is NOT in the subnet - Globals: - Error: - none - Example: - if(xCAT::NetworkUtils->ishostinsubnet($ip, $netmask, $subnet); - Comments: - none -=cut - -#------------------------------------------------------------------------------- -sub ishostinsubnet { - my ($class, $ip, $mask, $subnet) = @_; - - #safe guard - if (!defined($ip) || !defined($mask) || !defined($subnet)) - { - return 0; - } - my $numbits = 32; - if ($ip =~ /:/) { #ipv6 - $numbits = 128; - } - if ($mask) { - if ($mask =~ /\//) { - $mask =~ s/^\///; - $mask = Math::BigInt->new("0b" . ("1" x $mask) . ("0" x ($numbits - $mask))); - } else { - $mask = getipaddr($mask, GetNumber => 1); - } - } else { #CIDR notation supported - if ($subnet && ($subnet =~ /\//)) { - ($subnet, $mask) = split /\//, $subnet, 2; - $mask = Math::BigInt->new("0b" . ("1" x $mask) . ("0" x ($numbits - $mask))); - } else { - die "ishostinsubnet must either be called with a netmask or CIDR /bits notation"; - } - } - if ($subnet && ($subnet =~ /\//)) #remove CIDR suffix from subnet - { - $subnet =~ s/\/.*$//; - } - $ip = getipaddr($ip, GetNumber => 1); - $subnet = getipaddr($subnet, GetNumber => 1); - $ip &= $mask; - if ($ip && $subnet && ($ip == $subnet)) { - return 1; - } else { - return 0; - } -} - -#----------------------------------------------------------------------------- - -=head3 setup_ip_forwarding - - Sets up ip forwarding on localhost - -=cut - -#----------------------------------------------------------------------------- -sub setup_ip_forwarding -{ - my ($class, $enable) = @_; - if (xCAT::Utils->isLinux()) { - my $conf_file = "/etc/sysctl.conf"; - `grep "net.ipv4.ip_forward" $conf_file`; - if ($? == 0) { -`sed -i "s/^net.ipv4.ip_forward = .*/net.ipv4.ip_forward = $enable/" $conf_file`; -`sed -i "s/^#net.ipv4.ip_forward *= *.*/net.ipv4.ip_forward = $enable/" $conf_file`; #debian/ubuntu have different default format - } else { - `echo "net.ipv4.ip_forward = $enable" >> $conf_file`; - } - `sysctl -e -p $conf_file`; # workaround for redhat bug 639821 - } - else - { - `no -o ipforwarding=$enable`; - } - return 0; -} - -#----------------------------------------------------------------------------- - -=head3 setup_ipv6_forwarding - - Sets up ipv6 forwarding on localhost - -=cut - -#----------------------------------------------------------------------------- -sub setup_ipv6_forwarding -{ - my ($class, $enable) = @_; - if (xCAT::Utils->isLinux()) { - my $conf_file = "/etc/sysctl.conf"; - `grep "net.ipv6.conf.all.forwarding" $conf_file`; - if ($? == 0) { -`sed -i "s/^net.ipv6.conf.all.forwarding = .*/net.ipv6.conf.all.forwarding = $enable/" $conf_file`; - } else { - `echo "net.ipv6.conf.all.forwarding = $enable" >> $conf_file`; - } - `sysctl -e -p $conf_file`; - } - else - { - `no -o ip6forwarding=$enable`; - } - return 0; -} - -#------------------------------------------------------------------------------- - -=head3 prefixtomask - Convert the IPv6 prefix length(e.g. 64) to the netmask(e.g. ffff:ffff:ffff:ffff:0000:0000:0000:0000). - Till now, the netmask format ffff:ffff:ffff:: only works for AIX NIM - - Arguments: - prefix length - Returns: - netmask - netmask like ffff:ffff:ffff:ffff:0000:0000:0000:0000 - 0 - if the prefix length is not correct - Globals: - Error: - none - Example: - my #netmask = xCAT::NetworkUtils->prefixtomask($prefixlength); - Comments: - none -=cut - -#------------------------------------------------------------------------------- -sub prefixtomask { - my ($class, $prefixlength) = @_; - - if (($prefixlength < 1) || ($prefixlength > 128)) - { - return 0; - } - - my $number = Math::BigInt->new("0b" . ("1" x $prefixlength) . ("0" x (128 - $prefixlength))); - my $mask = $number->as_hex(); - $mask =~ s/^0x//; - $mask =~ s/(....)/$1/g; - return $mask; -} - -#------------------------------------------------------------------------------- - -=head3 my_ip_in_subnet - Get the facing ip for some specific network - - Arguments: - net - subnet, such as 192.168.0.01 - mask - netmask, such as 255.255.255.0 - Returns: - facing_ip - The local ip address in the subnet, - returns undef if no local ip address is in the subnet - Globals: - Error: - none - Example: - my $facingip = xCAT::NetworkUtils->my_ip_in_subnet($net, $mask); - Comments: - none -=cut - -#------------------------------------------------------------------------------- -sub my_ip_in_subnet -{ - my ($class, $net, $mask) = @_; - - if (!$net || !$mask) - { - return undef; - } - - my $fmask = xCAT::NetworkUtils::formatNetmask($mask, 0, 1); - - my $localnets = xCAT::NetworkUtils->my_nets(); - - return $localnets->{"$net\/$fmask"}; -} - -#------------------------------------------------------------------------------- - -=head3 ip_forwarding_enabled - Check if the ip_forward enabled on the system - - Arguments: - Returns: - 1 - The ip_forwarding is eanbled - 0 - The ip_forwarding is not eanbled - Globals: - Error: - none - Example: - if(xCAT::NetworkUtils->ip_forwarding_enabled()) - Comments: - none -=cut - -#------------------------------------------------------------------------------- -sub ip_forwarding_enabled -{ - - my $enabled; - if (xCAT::Utils->isLinux()) - { - $enabled = `sysctl -n net.ipv4.ip_forward`; - chomp($enabled); - } - else - { - $enabled = `no -o ipforwarding`; - chomp($enabled); - $enabled =~ s/ipforwarding\s+=\s+//; - } - return $enabled; -} - -#------------------------------------------------------------------------------- - -=head3 get_nic_ip - Get the ip address for the node nics - - Arguments: - Returns: - Hash of the mapping of the nic and the ip addresses - Globals: - Error: - none - Example: - xCAT::NetworkUtils->get_nic_ip() - Comments: - none -=cut - -#------------------------------------------------------------------------------- - -sub get_nic_ip -{ - my $nic; - my %iphash; - my $mode = "MULTICAST"; - my $payingattention = 0; - my $interface; - my $keepcurrentiface; - - - if (xCAT::Utils->isAIX()) { - ############################################################## - # Should look like this for AIX: - # en0: flags=4e080863,80 - # inet 30.0.0.1 netmask 0xffffff00 broadcast 30.0.0.255 - # inet 192.168.2.1 netmask 0xffffff00 broadcast 192.168.2.255 - # en1: ... - # - ############################################################## - my $cmd = "ifconfig -a"; - my $result = `$cmd`; - ############################################# - # Error running command - ############################################# - if (!$result) { - return undef; - } - my @adapter = split /(\w+\d+):\s+flags=/, $result; - foreach (@adapter) { - if ($_ =~ /^(en\d)/) { - $nic = $1; - next; - } - if (!($_ =~ /LOOPBACK/) and - $_ =~ /UP(,|>)/ and - $_ =~ /$mode/) { - my @ip = split /\n/; - for my $ent (@ip) { - if ($ent =~ /^\s*inet\s+(\d+\.\d+\.\d+\.\d+)/) { - $iphash{$nic} = $1; - next; - } - } - } - } - } - else { # linux - my @ipoutput = `ip addr`; - ############################################# - # Error running command - ############################################# - if (!@ipoutput) { - return undef; - } - foreach my $line (@ipoutput) { - if ($line =~ /^\d/) { # new interface, new context.. - if ($interface and not $keepcurrentiface) { - - #don't bother reporting unusable nics - delete $iphash{$interface}; - } - $keepcurrentiface = 0; - if (!($line =~ /LOOPBACK/) and - $line =~ /UP( |,|>)/ and - $line =~ /$mode/) { - - $payingattention = 1; - $line =~ /^([^:]*): ([^:]*):/; - $interface = $2; - } else { - $payingattention = 0; - next; - } - } - unless ($payingattention) { next; } - if ($line =~ /inet/) { - $keepcurrentiface = 1; - } - if ($line =~ /^\s*inet \s*(\d+\.\d+\.\d+\.\d+)/) { - $iphash{$interface} = $1; - } - } - } - return \%iphash; -} - -#------------------------------------------------------------------------------- - -=head3 classful_networks_for_net_and_mask - - Arguments: - network and mask - Returns: - a list of classful subnets that constitute the entire potentially classless arguments - Globals: - none - Error: - none - Example: - Comments: - none -=cut - -#------------------------------------------------------------------------------- -sub classful_networks_for_net_and_mask -{ - my $network = shift; - my $mask = shift; - my $given_mask = 0; - if ($mask =~ /\./) - { - $given_mask = 1; - my $masknumber = unpack("N", inet_aton($mask)); - $mask = 32; - until ($masknumber % 2) - { - $masknumber = $masknumber >> 1; - $mask--; - } - } - - my @results; - my $bitstoeven = (8 - ($mask % 8)); - if ($bitstoeven == 8) { $bitstoeven = 0; } - my $resultmask = $mask + $bitstoeven; - if ($given_mask) - { - $resultmask = - inet_ntoa(pack("N", (2**$resultmask - 1) << (32 - $resultmask))); - } - push @results, $resultmask; - - my $padbits = (32 - ($bitstoeven + $mask)); - my $numchars = int(($mask + $bitstoeven) / 4); - my $curmask = 2**$mask - 1 << (32 - $mask); - my $nown = unpack("N", inet_aton($network)); - $nown = $nown & $curmask; - my $highn = $nown + ((2**$bitstoeven - 1) << (32 - $mask - $bitstoeven)); - - while ($nown <= $highn) - { - push @results, inet_ntoa(pack("N", $nown)); - - #$rethash->{substr($nowhex, 0, $numchars)} = $network; - $nown += 1 << (32 - $mask - $bitstoeven); - } - return @results; -} - - -#------------------------------------------------------------------------------- - -=head3 my_hexnets - - Arguments: - none - Returns: - Globals: - none - Error: - none - Example: - xCAT::NetworkUtils->my_hexnets - Comments: - none -=cut - -#------------------------------------------------------------------------------- -sub my_hexnets -{ - my $rethash; - my @nets = split /\n/, `/sbin/ip addr`; - foreach (@nets) - { - my @elems = split /\s+/; - unless (/^\s*inet\s/) - { - next; - } - (my $curnet, my $maskbits) = split /\//, $elems[2]; - my $bitstoeven = (4 - ($maskbits % 4)); - if ($bitstoeven == 4) { $bitstoeven = 0; } - my $padbits = (32 - ($bitstoeven + $maskbits)); - my $numchars = int(($maskbits + $bitstoeven) / 4); - my $curmask = 2**$maskbits - 1 << (32 - $maskbits); - my $nown = unpack("N", inet_aton($curnet)); - $nown = $nown & $curmask; - my $highn = - $nown + ((2**$bitstoeven - 1) << (32 - $maskbits - $bitstoeven)); - - while ($nown <= $highn) - { - my $nowhex = sprintf("%08x", $nown); - $rethash->{ substr($nowhex, 0, $numchars) } = $curnet; - $nown += 1 << (32 - $maskbits - $bitstoeven); - } - } - return $rethash; -} - -#------------------------------------------------------------------------------- - -=head3 get_host_from_ip - Description: - Get the hostname of an IP addresses. First from hosts table, and then try system resultion. - If there is a shortname, it will be returned. Otherwise it will return long name. If the IP cannot be resolved, return undef; - - Arguments: - $ip: the IP to get; - - Returns: - Return: the hostname. -For an example - - Globals: - none - - Error: - none - - Example: - xCAT::NetworkUtils::get_host_from_ip('192.168.200.1') - - Comments: -=cut - -#----------------------------------------------------------------------- -sub get_host_from_ip -{ - my $ip = shift; -} - -#------------------------------------------------------------------------------- - -=head3 isPingable - Description: - Check if an IP address can be pinged - - Arguments: - $ip: the IP to ping; - - Returns: - Return: 1 indicates yes; 0 indicates no. -For an example - - Globals: - none - - Error: - none - - Example: - xCAT::NetworkUtils::isPingable('192.168.200.1') - - Comments: - none -=cut - -#----------------------------------------------------------------------- -my %PING_CACHE; - -sub isPingable -{ - my $ip = shift; - - my $rc; - if (exists $PING_CACHE{$ip}) - { - $rc = $PING_CACHE{$ip}; - } - else - { - my $res = `LANG=C ping -c 1 -w 5 $ip 2>&1`; - if ($res =~ /100% packet loss/g) - { - $rc = 1; - } - else - { - $rc = 0; - } - $PING_CACHE{$ip} = $rc; - } - - return !$rc; -} - -#------------------------------------------------------------------------------- - -=head3 my_nets - Description: - Return a hash ref that contains all subnet and netmask on the mn (or sn). This subroutine can be invoked on both Linux and AIX. - - Arguments: - none. - - Returns: - Return a hash ref. Each entry will be: =>; - For an example: - '192.168.200.0/255.255.255.0' => '192.168.200.246'; -For an example - - Globals: - none - - Error: - none - - Example: - xCAT::NetworkUtils::my_nets(). - - Comments: - none -=cut - -#----------------------------------------------------------------------- -sub my_nets -{ - require xCAT::Table; - my $rethash; - my @nets; - my $v6net; - my $v6ip; - if ($^O eq 'aix') - { - @nets = split /\n/, `/usr/sbin/ifconfig -a`; - } - else - { - @nets = split /\n/, `/sbin/ip addr`; #could use ip route, but to match hexnets... - } - foreach (@nets) - { - $v6net = ''; - my @elems = split /\s+/; - unless (/^\s*inet/) - { - next; - } - my $curnet; my $maskbits; - if ($^O eq 'aix') - { - if ($elems[1] eq 'inet6') - { - $v6net = $elems[2]; - $v6ip = $elems[2]; - $v6ip =~ s/\/.*//; # ipv6 address 4000::99/64 - $v6ip =~ s/\%.*//; # ipv6 address ::1%1/128 - } - else - { - $curnet = $elems[2]; - $maskbits = formatNetmask($elems[4], 2, 1); - } - } - else - { - if ($elems[1] eq 'inet6') - { - next; #Linux IPv6 TODO, do not return IPv6 networks on Linux for now - } - ($curnet, $maskbits) = split /\//, $elems[2]; - } - if (!$v6net) - { - my $curmask = 2**$maskbits - 1 << (32 - $maskbits); - my $nown = unpack("N", inet_aton($curnet)); - $nown = $nown & $curmask; - my $textnet = inet_ntoa(pack("N", $nown)); - $textnet .= "/$maskbits"; - $rethash->{$textnet} = $curnet; - } - else - { - $rethash->{$v6net} = $v6ip; - } - } - - - # now get remote nets - my $nettab = xCAT::Table->new("networks"); - - #my $sitetab = xCAT::Table->new("site"); - #my $master = $sitetab->getAttribs({key=>'master'},'value'); - #$master = $master->{value}; - my @masters = xCAT::TableUtils->get_site_attribute("master"); - my $master = $masters[0]; - my @vnets = $nettab->getAllAttribs('net', 'mgtifname', 'mask'); - - foreach (@vnets) { - my $n = $_->{net}; - my $if = $_->{mgtifname}; - my $nm = $_->{mask}; - if (!$n || !$if || !$nm) - { - next; #incomplete network - } - if ($if =~ /!remote!/) { #only take in networks with special interface - $nm = formatNetmask($nm, 0, 1); - $n .= "/$nm"; - - #$rethash->{$n} = $if; - $rethash->{$n} = $master; - } - } - return $rethash; -} - -#------------------------------------------------------------------------------- - -=head3 my_if_netmap - Arguments: - none - Returns: - hash of networks to interface names - Globals: - none - Error: - none - Comments: - none -=cut - -#------------------------------------------------------------------------------- -sub my_if_netmap -{ - my $net; - if (scalar(@_)) - { #called with the other syntax - $net = shift; - } - my @rtable = split /\n/, `netstat -rn`; - if ($?) - { - return "Unable to run netstat, $?"; - } - my %retmap; - foreach (@rtable) - { - if (/^\D/) { next; } #skip headers - if (/^\S+\s+\S+\s+\S+\s+\S*G/) - { - next; - } #Skip networks that require gateways to get to - /^(\S+)\s.*\s(\S+)$/; - $retmap{$1} = $2; - } - return \%retmap; -} - -#------------------------------------------------------------------------------- - -=head3 my_ip_facing - Returns my ip address in the same network with the specified node - Linux only - Arguments: - nodename - Returns: - result and error message or my ip address - 1. If node can not be resolved, the return info will be like this: - [1, "The $node can not be resolved"]. - 2. If no IP found that matching the giving node, the return info will be: - [2, "The IP address of node $node is in an undefined subnet"]. - 3. If IP found: - [0,ip1,ip2,...] - Globals: - none - Error: - none - Example: - my @ip = xCAT::NetworkUtils->my_ip_facing($peerip) # return multiple - Comments: - none -=cut - -#------------------------------------------------------------------------------- -sub my_ip_facing -{ - my $peer = shift; - if (@_) - { - $peer = shift; - } - - return my_ip_facing_aix($peer) if ($^O eq 'aix'); - my @rst; - my $peernumber = inet_aton($peer); #TODO: IPv6 support - unless ($peernumber) { - $rst[0] = 1; - $rst[1] = "The $peer can not be resolved"; - return @rst; } - my $noden = unpack("N", $peernumber); - my @nets = split /\n/, `/sbin/ip addr`; - - my @ips; - foreach (@nets) - { - my @elems = split /\s+/; - unless (/^\s*inet\s/) - { - next; - } - (my $curnet, my $maskbits) = split /\//, $elems[2]; - my $curmask = 2**$maskbits - 1 << (32 - $maskbits); - my $curn = unpack("N", inet_aton($curnet)); - if (($noden & $curmask) == ($curn & $curmask)) - { - push @ips, $curnet; - } - } - - if (@ips) { - $rst[0] = 0; - push @rst, @ips; - } else { - $rst[0] = 2; - $rst[1] = "The IP address of node $peer is in an undefined subnet"; - } - return @rst; -} - -#------------------------------------------------------------------------------- - -=head3 my_ip_facing_aix - Returns my ip address - AIX only - Arguments: - nodename - Returns: - Globals: - none - Error: - none - Example: - Comments: - none -=cut - -#------------------------------------------------------------------------------- -sub my_ip_facing_aix -{ - my $peer = shift; - my @nets = `ifconfig -a`; - chomp @nets; - my @ips; - my @rst; - foreach my $net (@nets) - { - my ($curnet, $netmask); - if ($net =~ /^\s*inet\s+([\d\.]+)\s+netmask\s+(\w+)\s+broadcast/) - { - ($curnet, $netmask) = ($1, $2); - } - elsif ($net =~ /^\s*inet6\s+(.*)$/) - { - ($curnet, $netmask) = split('/', $1); - } - else - { - next; - } - if (isInSameSubnet($peer, $curnet, $netmask, 2)) - { - push @ips, $curnet; - } - } - if (@ips) - { - $rst[0] = 0; - push @rst, @ips; - } - else - { - $rst[0] = 2; - $rst[1] = "The IP address of node $peer is in an undefined subnet"; - } - return @rst; -} - -#------------------------------------------------------------------------------- - -=head3 formatNetmask - Description: - Transform netmask to one of 3 formats (255.255.255.0, 24, 0xffffff00). - - Arguments: - $netmask: the original netmask - $origType: the original netmask type. The valid value can be 0, 1, 2: - Type 0: 255.255.255.0 - Type 1: 24 - Type 2: 0xffffff00 - $newType: the new netmask type, valid values can be 0,1,2, as above. - - Returns: - Return undef if any error. Otherwise return the netmask in new format. - - Globals: - none - - Error: - none - - Example: - xCAT::NetworkUtils::formatNetmask( '24', 1, 0); #return '255.255.255.0'. - - Comments: - none -=cut - -#----------------------------------------------------------------------- -sub formatNetmask -{ - my $mask = shift; - my $origType = shift; - my $newType = shift; - my $maskn; - if ($origType == 0) - { - $maskn = unpack("N", inet_aton($mask)); - } - elsif ($origType == 1) - { - $maskn = 2**$mask - 1 << (32 - $mask); - } - elsif ($origType == 2) - { - $maskn = hex $mask; - } - else - { - return undef; - } - - if ($newType == 0) - { - return inet_ntoa(pack('N', $maskn)); - } - if ($newType == 1) - { - my $bin = unpack("B32", pack("N", $maskn)); - my @dup = ($bin =~ /(1{1})0*/g); - return scalar(@dup); - } - if ($newType == 2) - { - return sprintf "0x%1x", $maskn; - } - return undef; -} - -#------------------------------------------------------------------------------- - -=head3 isInSameSubnet - Description: - Check if 2 given IP addresses are in same subnet - - Arguments: - $ip1: the first IP - $ip2: the second IP - $mask: the netmask, here are 3 possible netmask types, following are examples for these 3 types: - Type 0: 255.255.255.0 - Type 1: 24 - Type 2: 0xffffff00 - $masktype: the netmask type, 3 possible values: 0,1,2, as indicated above - - Returns: - 1: they are in same subnet - 2: not in same subnet - - Globals: - none - - Error: - none - - Example: - xCAT::NetworkUtils::isInSameSubnet( '192.168.10.1', '192.168.10.2', '255.255.255.0', 0); - - Comments: - none -=cut - -#----------------------------------------------------------------------- -sub isInSameSubnet -{ - my $ip1 = shift; - my $ip2 = shift; - my $mask = shift; - my $maskType = shift; - - $ip1 = xCAT::NetworkUtils->getipaddr($ip1); - $ip2 = xCAT::NetworkUtils->getipaddr($ip2); - - if (!defined($ip1) || !defined($ip2)) - { - return undef; - } - - if ((($ip1 =~ /\d+\.\d+\.\d+\.\d+/) && ($ip2 !~ /\d+\.\d+\.\d+\.\d+/)) - || (($ip1 !~ /\d+\.\d+\.\d+\.\d+/) && ($ip2 =~ /\d+\.\d+\.\d+\.\d+/))) - { - #ipv4 and ipv6 can not be in the same subnet - return undef; - } - - if (($ip1 =~ /\d+\.\d+\.\d+\.\d+/) && ($ip2 =~ /\d+\.\d+\.\d+\.\d+/)) - { - my $maskn; - if ($maskType == 0) - { - $maskn = unpack("N", inet_aton($mask)); - } - elsif ($maskType == 1) - { - $maskn = 2**$mask - 1 << (32 - $mask); - } - elsif ($maskType == 2) - { - $maskn = hex $mask; - } - else - { - return undef; - } - - my $ip1n = unpack("N", inet_aton($ip1)); - my $ip2n = unpack("N", inet_aton($ip2)); - - return (($ip1n & $maskn) == ($ip2n & $maskn)); - } - else - { - #ipv6 - if (($ip1 =~ /\%/) || ($ip2 =~ /\%/)) - { - return undef; - } - my $netipmodule = eval { require Net::IP; }; - if ($netipmodule) { - my $eip1 = Net::IP::ip_expand_address($ip1, 6); - my $eip2 = Net::IP::ip_expand_address($ip2, 6); - my $bmask = Net::IP::ip_get_mask($mask, 6); - my $bip1 = Net::IP::ip_iptobin($eip1, 6); - my $bip2 = Net::IP::ip_iptobin($eip2, 6); - if (($bip1 & $bmask) == ($bip2 & $bmask)) { - return 1; - } - } # else, can not check without Net::IP module - return undef; - } -} - -#------------------------------------------------------------------------------- - -=head3 nodeonmynet - checks to see if node is on any network this server is attached to or remote network potentially managed by this system - Arguments: - Node name - Returns: 1 if node is on the network - Globals: - none - Error: - none - Example: - xCAT::NetworkUtils->nodeonmynet - Comments: - none -=cut - -#------------------------------------------------------------------------------- - -sub nodeonmynet -{ - require xCAT::Table; - my $nodetocheck = shift; - if (scalar(@_)) - { - $nodetocheck = shift; - } - - my $nodeip = getNodeIPaddress($nodetocheck); - if (!$nodeip) - { - return 0; - } - unless ($nodeip =~ /\d+\.\d+\.\d+\.\d+/) - { - #IPv6 - if ($^O eq 'aix') - { - my @subnets = get_subnet_aix(); - for my $net_ent (@subnets) - { - if ($net_ent !~ /-/) - { - #ipv4 - next; - } - my ($net, $interface, $mask, $flag) = split /-/, $net_ent; - if (xCAT::NetworkUtils->ishostinsubnet($nodeip, $mask, $net)) - { - return 1; - } - } - - } else { - my @v6routes = split /\n/, `ip -6 route`; - foreach (@v6routes) { - if (/via/ or /^unreachable/ or /^fe80::\/64/) { - - #only count local ones, remote ones can be caught in next loop - #also, link-local would be a pitfall, - #since more context than address is - #needed to determine locality - next; - } - s/ .*//; #remove all after the space - if (xCAT::NetworkUtils->ishostinsubnet($nodeip, '', $_)) { #bank on CIDR support - return 1; - } - } - } - my $nettab = xCAT::Table->new("networks"); - my @vnets = $nettab->getAllAttribs('net', 'mgtifname', 'mask'); - foreach (@vnets) { - if ((defined $_->{mgtifname}) && ($_->{mgtifname} eq '!remote!')) - { - if (xCAT::NetworkUtils->ishostinsubnet($nodeip, $_->{mask}, $_->{net})) - { - return 1; - } - } - } - return 0; - } - my $noden = unpack("N", inet_aton($nodeip)); - my @nets; - if ($utildata->{nodeonmynetdata} and $utildata->{nodeonmynetdata}->{pid} == $$) { - @nets = @{ $utildata->{nodeonmynetdata}->{nets} }; - } else { - if ($^O eq 'aix') - { - my @subnets = get_subnet_aix(); - for my $net_ent (@subnets) - { - if ($net_ent =~ /-/) - { - #ipv6 - next; - } - my @ents = split /:/, $net_ent; - push @nets, $ents[0] . '/' . $ents[2] . ' dev ' . $ents[1]; - } - - } - else - { - @nets = split /\n/, `/sbin/ip route`; - } - my $nettab = xCAT::Table->new("networks"); - my @vnets = $nettab->getAllAttribs('net', 'mgtifname', 'mask'); - foreach (@vnets) { - if ((defined $_->{mgtifname}) && ($_->{mgtifname} eq '!remote!')) - { #global scoped network - my $curm = unpack("N", inet_aton($_->{mask})); - my $bits = 32; - until ($curm & 1) { - $bits--; - $curm = $curm >> 1; - } - push @nets, $_->{'net'} . "/" . $bits . " dev remote"; - } - } - $utildata->{nodeonmynetdata}->{pid} = $$; - $utildata->{nodeonmynetdata}->{nets} = \@nets; - } - foreach (@nets) - { - my @elems = split /\s+/; - unless ($elems[1] =~ /dev/) - { - next; - } - (my $curnet, my $maskbits) = split /\//, $elems[0]; - my $curmask = 2**$maskbits - 1 << (32 - $maskbits); - my $curn = unpack("N", inet_aton($curnet)); - if (($noden & $curmask) == $curn) - { - return 1; - } - } - return 0; -} - -#------------------------------------------------------------------------------- - -=head3 getNodeIPaddress - Arguments: - Node name only one at a time - Returns: ip address(s) - Globals: - none - Error: - none - Example: my $c1 = xCAT::NetworkUtils::getNodeIPaddress($nodetocheck); - -=cut - -#------------------------------------------------------------------------------- - -sub getNodeIPaddress -{ - require xCAT::Table; - my $nodetocheck = shift; - my $port = shift; - my $nodeip; - - $nodeip = xCAT::NetworkUtils->getipaddr($nodetocheck); - if (!$nodeip) - { - my $hoststab = xCAT::Table->new('hosts'); - my $ent = $hoststab->getNodeAttribs($nodetocheck, ['ip']); - if ($ent->{'ip'}) { - $nodeip = $ent->{'ip'}; - } - } - - if ($nodeip) { - return $nodeip; - } else { - return undef; - } -} - - - -#------------------------------------------------------------------------------- - -=head3 thishostisnot - returns 0 if host is not the same - Arguments: - hostname - Returns: - Globals: - none - Error: - none - Example: - xCAT::NetworkUtils->thishostisnot - Comments: - none -=cut - -#------------------------------------------------------------------------------- - -sub thishostisnot -{ - my $comparison = shift; - if (scalar(@_)) - { - $comparison = shift; - } - - my @ips; - if ($^O eq 'aix') - { - @ips = split /\n/, `/usr/sbin/ifconfig -a`; - } - else - { - @ips = split /\n/, `/sbin/ip addr`; - } - my $comp = xCAT::NetworkUtils->getipaddr($comparison); - if ($comp) - { - foreach (@ips) - { - if (/^\s*inet.?\s+/) - { - my @ents = split(/\s+/); - my $ip = $ents[2]; - $ip =~ s/\/.*//; - $ip =~ s/\%.*//; - if ($ip eq $comp) - { - return 0; - } - } - } - } - return 1; -} - -#----------------------------------------------------------------------------- - -=head3 gethost_ips (AIX and Linux) - Will use ifconfig to determine all possible ip addresses for the - host it is running on and then gethostbyaddr to get all possible hostnames - - input: - output: array of ipaddress(s) and hostnames - example: @ips=xCAT::NetworkUtils->gethost_ips(); - -=cut - -#----------------------------------------------------------------------------- -#sub gethost_ips1 -#{ -# my ($class) = @_; -# my $cmd; -# my @ipaddress; -# $cmd = "ifconfig" . " -a"; -# $cmd = $cmd . "| grep \"inet\""; -# my @result = xCAT::Utils->runcmd($cmd, 0); -# if ($::RUNCMD_RC != 0) -# { -# xCAT::MsgUtils->message("S", "Error from $cmd\n"); -# exit $::RUNCMD_RC; -# } -# foreach my $addr (@result) -# { -# my @ip; -# if (xCAT::Utils->isLinux()) -# { -# if ($addr =~ /inet6/) -# { -# #TODO, Linux ipv6 -# } -# else -# { -# my ($inet, $addr1, $Bcast, $Mask) = split(" ", $addr); -# #@ip = split(":", $addr1); -# #push @ipaddress, $ip[1]; -# $addr1 =~ s/.*://; -# push @ipaddress, $addr1; -# } -# } -# else -# { #AIX -# if ($addr =~ /inet6/) -# { -# $addr =~ /\s*inet6\s+([\da-fA-F:]+).*\/(\d+)/; -# my $v6ip = $1; -# my $v6mask = $2; -# if ($v6ip) -# { -# push @ipaddress, $v6ip; -# } -# } -# else -# { -# my ($inet, $addr1, $netmask, $mask1, $Bcast, $bcastaddr) = -# split(" ", $addr); -# push @ipaddress, $addr1; -# } -# -# } -# } -# my @names = @ipaddress; -# foreach my $ipaddr (@names) -# { -# my $hostname = xCAT::NetworkUtils->gethostname($ipaddr); -# if ($hostname) -# { -# my @shorthost = split(/\./, $hostname); -# push @ipaddress, $shorthost[0]; -# } -# } -# -# return @ipaddress; -#} - - -sub gethost_ips -{ - my ($class) = @_; - my $cmd; - my @ipaddress; - if (xCAT::Utils->isLinux()) - { - $cmd = "ip -4 --oneline addr show |awk -F ' ' '{print \$4}'|awk -F '/' '{print \$1}'"; - my @result = xCAT::Utils->runcmd($cmd); - if ($::RUNCMD_RC != 0) - { - xCAT::MsgUtils->message("S", "Error from $cmd\n"); - exit $::RUNCMD_RC; - } - - push @ipaddress, @result; - } - else - { #AIX - - $cmd = "ifconfig" . " -a"; - $cmd = $cmd . "| grep \"inet\""; - my @result = xCAT::Utils->runcmd($cmd, 0); - if ($::RUNCMD_RC != 0) - { - xCAT::MsgUtils->message("S", "Error from $cmd\n"); - exit $::RUNCMD_RC; - } - - foreach my $addr (@result) - { - if ($addr =~ /inet6/) - { - $addr =~ /\s*inet6\s+([\da-fA-F:]+).*\/(\d+)/; - my $v6ip = $1; - my $v6mask = $2; - if ($v6ip) - { - push @ipaddress, $v6ip; - } - } - else - { - my ($inet, $addr1, $netmask, $mask1, $Bcast, $bcastaddr) = - split(" ", $addr); - push @ipaddress, $addr1; - } - - } - } - - my @names = @ipaddress; - foreach my $ipaddr (@names) - { - my $hostname = xCAT::NetworkUtils->gethostname($ipaddr); - if ($hostname) - { - my @shorthost = split(/\./, $hostname); - push @ipaddress, $shorthost[0]; - } - } - return @ipaddress; -} - -#------------------------------------------------------------------------------- - -=head3 get_subnet_aix - Description: - To get present subnet configuration by parsing the output of 'netstat'. Only designed for AIX. - Arguments: - None - Returns: - @aix_nrn : An array with entries in format "net:nic:netmask:flag". Following is an example entry: - 9.114.47.224:en0:27:U - Globals: - none - Error: - none - Example: - my @nrn =xCAT::NetworkUtils::get_subnet_aix - Comments: - none - -=cut - -#------------------------------------------------------------------------------- -sub get_subnet_aix -{ - my @netstat_res = `/usr/bin/netstat -rn`; - chomp @netstat_res; - my @aix_nrn; - for my $entry (@netstat_res) - { - #We need to find entries like: - #Destination Gateway Flags Refs Use If Exp Groups - #9.114.47.192/27 9.114.47.205 U 1 1 en0 - #4000::/64 link#4 UCX 1 0 en2 - - - my ($net, $netmask, $flag, $nic); - if ($entry =~ /^\s*([\d\.]+)\/(\d+)\s+[\d\.]+\s+(\w+)\s+\d+\s+\d+\s(\w+)/) - { - ($net, $netmask, $flag, $nic) = ($1, $2, $3, $4); - my @dotsec = split /\./, $net; - for (my $i = 4 ; $i > scalar(@dotsec) ; $i--) - { - $net .= '.0'; - } - push @aix_nrn, "$net:$nic:$netmask:$flag" if ($net ne '127.0.0.0'); - } - elsif ($entry =~ /^\s*([\dA-Fa-f\:]+)\/(\d+)\s+.*?\s+(\w+)\s+\d+\s+\d+\s(\w+)/) - { - #print "=====$entry====\n"; - ($net, $netmask, $flag, $nic) = ($1, $2, $3, $4); - - # for ipv6, can not use : as the delimiter - push @aix_nrn, "$net-$nic-$netmask-$flag" if ($net ne '::') - } - } - return @aix_nrn; -} - -#----------------------------------------------------------------------------- - -=head3 determinehostname and ip address(s) - - Used on the service node to figure out what hostname and ip address(s) - are valid names and addresses - Input: None - Output: ipaddress(s),nodename -=cut - -#----------------------------------------------------------------------------- -sub determinehostname -{ - my $hostname; - my $hostnamecmd = "/bin/hostname"; - my @thostname = xCAT::Utils->runcmd($hostnamecmd, 0); - if ($::RUNCMD_RC != 0) - { # could not get hostname - xCAT::MsgUtils->message("S", - "Error $::RUNCMD_RC from $hostnamecmd command\n"); - exit $::RUNCMD_RC; - } - $hostname = $thostname[0]; - - #get all potentially valid abbreviations, and pick the one that is ok - #by 'noderange' - my @hostnamecandidates; - my $nodename; - while ($hostname =~ /\./) { - push @hostnamecandidates, $hostname; - $hostname =~ s/\.[^\.]*//; - } - push @hostnamecandidates, $hostname; - my $checkhostnames = join(',', @hostnamecandidates); - my @validnodenames = xCAT::NodeRange::noderange($checkhostnames); - unless (scalar @validnodenames) { #If the node in question is not in table, take output literrally. - push @validnodenames, $hostnamecandidates[0]; - } - - #now, noderange doesn't guarantee the order, so we search the preference order, most to least specific. - foreach my $host (@hostnamecandidates) { - if (grep /^$host$/, @validnodenames) { - $nodename = $host; - last; - } - } - my @ips = xCAT::NetworkUtils->gethost_ips; - my @hostinfo = (@ips, $nodename); - - return @hostinfo; -} - -#----------------------------------------------------------------------------- - -=head3 toIP - - IPv4 function to convert hostname to IP address - -=cut - -#----------------------------------------------------------------------------- -sub toIP -{ - - if (($_[0] =~ /^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/) || ($_[0] =~ /:/)) - { - return ([ 0, $_[0] ]); - } - my $ip = xCAT::NetworkUtils->getipaddr($_[0]); - if (!$ip) - { - return ([ 1, "Cannot Resolve: $_[0]\n" ]); - } - return ([ 0, $ip ]); -} - -#------------------------------------------------------------------------------- - -=head3 validate_ip - Validate list of IPs - Arguments: - List of IPs - Returns: - 1 - Invalid IP address in the list - 0 - IP addresses are all valid - Globals: - none - Error: - none - Example: - if (xCAT::NetworkUtils->validate_ip($IP)) {} - Comments: - none -=cut - -#------------------------------------------------------------------------------- -sub validate_ip -{ - my ($class, @IPs) = @_; - foreach (@IPs) { - my $ip = $_; - - #TODO need more check for IPv6 address - if ($ip =~ /:/) - { - return ([0]); - } - ################################### - # Length is 4 for IPv4 addresses - ################################### - my (@octets) = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/; - if (scalar(@octets) != 4) { - return ([ 1, "Invalid IP address1: $ip" ]); - } - foreach my $octet (@octets) { - if (($octet < 0) or ($octet > 255)) { - return ([ 1, "Invalid IP address2: $ip" ]); - } - } - } - return ([0]); -} - -#------------------------------------------------------------------------------- - -=head3 isIpaddr - - returns 1 if parameter is has a valid IP address form. - - Arguments: - dot qulaified IP address: e.g. 1.2.3.4 - Returns: - 1 - if legal IP address - 0 - if not legal IP address. - Globals: - none - Error: - none - Example: - if ($ipAddr) { blah; } - Comments: - Doesn't test if the IP address is on the network, - just tests its form. - -=cut - -#------------------------------------------------------------------------------- -sub isIpaddr -{ - my $addr = shift; - if (($addr) && ($addr =~ /xCAT::NetworkUtils/)) - { - $addr = shift; - } - - unless ($addr) - { - return 0; - } - - #print "addr=$addr\n"; - if ($addr !~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/) - { - return 0; - } - - if ($1 > 255 || $1 == 0 || $2 > 255 || $3 > 255 || $4 > 255) - { - return 0; - } - else - { - return 1; - } -} - - - - -#------------------------------------------------------------------------------- - -=head3 getNodeNameservers - Description: - Get nameservers of specified nodes. - The priority: noderes.nameservers > networks.nameservers > site.nameservers - Arguments: - node: node name list - Returns: - Return a hash ref, of the $nameservers{$node} - undef - Failed to get the nameservers - Globals: - none - Error: - none - Example: - my $nameservers = xCAT::NetworkUtils::getNodeNameservers(\@node); - Comments: - none - -=cut - -#------------------------------------------------------------------------------- -sub getNodeNameservers { - my $nodes = shift; - if ($nodes =~ /xCAT::NetworkUtils/) - { - $nodes = shift; - } - my @nodelist = @$nodes; - my %nodenameservers; - my $nrtab = xCAT::Table->new('noderes', -create => 0); - my %nrhash = %{ $nrtab->getNodesAttribs(\@nodelist, ['nameservers']) }; - - my $nettab = xCAT::Table->new("networks"); - my %nethash = xCAT::DBobjUtils->getNetwkInfo(\@nodelist); - - my @nameservers = xCAT::TableUtils->get_site_attribute("nameservers"); - my $sitenameservers = $nameservers[0]; - - - foreach my $node (@nodelist) { - if ($nrhash{$node} and $nrhash{$node}->[0] and $nrhash{$node}->[0]->{nameservers}) - { - $nodenameservers{$node} = $nrhash{$node}->[0]->{nameservers}; - } elsif ($nethash{$node}{nameservers}) - { - $nodenameservers{$node} = $nethash{$node}{nameservers}; - } elsif ($sitenameservers) - { - $nodenameservers{$node} = $sitenameservers; - } - } - - return \%nodenameservers; -} - - -#------------------------------------------------------------------------------- - -=head3 getNodeNetworkCfg - Description: - Get node network configuration, including "IP, hostname(the nodename),and netmask" by this node's name. - - Arguments: - node: the nodename - Returns: - Return an array, which contains (IP,hostname,gateway,netmask'). - undef - Failed to get the network configuration info - Globals: - none - Error: - none - Example: - my ($ip,$host,undef,$mask) = xCAT::NetworkUtils::getNodeNetworkCfg('node1'); - Comments: - Presently gateway is always blank. Need to be improved. - -=cut - -#------------------------------------------------------------------------------- -sub getNodeNetworkCfg -{ - my $node = shift; - if ($node =~ /xCAT::NetworkUtils/) - { - $node = shift; - } - - my $ip = xCAT::NetworkUtils->getipaddr($node); - my $mask = undef; - my $gateway = undef; - - my $nettab = xCAT::Table->new("networks"); - if ($nettab) { - my @nets = $nettab->getAllAttribs('net', 'mask', 'gateway'); - foreach my $net (@nets) { - if (xCAT::NetworkUtils::isInSameSubnet($net->{'net'}, $ip, $net->{'mask'}, 0)) { - $gateway = $net->{'gateway'}; - $mask = $net->{'mask'}; - } - } - } - - return ($ip, $node, $gateway, xCAT::NetworkUtils::formatNetmask($mask, 0, 0)); -} - -#------------------------------------------------------------------------------- - -=head3 getNodesNetworkCfg - Description: - Get network configuration (ip,netmask,gateway) for a group of nodes - - Arguments: - nodes: the group of nodes - Returns: - If failed: (1, error_msg) - If success: (0, the hash variable store network configuration info for nodes that get matching network entry) - Error: - none - Example: - my ($ret, $hash) = xCAT::NetworkUtils::getNodesNetworkCfg($noderange); - Comments: - -=cut - -#------------------------------------------------------------------------------- - -sub getNodesNetworkCfg -{ - my $nodes = shift; - if ($nodes =~ /xCAT::NetworkUtils/) { - $nodes = shift; - } - my @nets = (); - my $nettab = xCAT::Table->new("networks"); - if ($nettab) { - my @error_net = (); - my @all_nets = $nettab->getAllAttribs('net', 'mask', 'gateway'); - foreach my $net (@all_nets) { - my $gateway = $net->{gateway}; - if (defined($gateway) and ($gateway eq '')) { - my @gatewayd = xCAT::NetworkUtils->my_ip_facing($net->{'net'}); - unless ($gatewayd[0]) { - $gateway = $gatewayd[1]; - } - } - push @nets, { net => $net->{net}, mask => $net->{mask}, gateway => $gateway }; - } - $nettab->close; - } - else { - return (1, "Open \"networks\" table failed"); - } - if (!scalar(@nets)) { - return (1, "No entry find in \"networks\" table"); - } - my %rethash = (); - foreach my $node (@$nodes) { - my $ip = xCAT::NetworkUtils->getipaddr($node); - foreach my $net (@nets) { - if (xCAT::NetworkUtils::isInSameSubnet($net->{'net'}, $ip, $net->{'mask'}, 0)) { - $rethash{$node}->{ip} = $ip; - $rethash{$node}->{mask} = $net->{'mask'}; - $rethash{$node}->{gateway} = $net->{'gateway'}; - last; - } - } - } - return (0, \%rethash); -} - -#------------------------------------------------------------------------------- - -=head3 get_hdwr_ip - Description: - Get hardware(CEC, BPA) IP from the hosts table, and then /etc/hosts. - - Arguments: - node: the nodename(cec, or bpa) - Returns: - Return the node IP - -1 - Failed to get the IP. - Globals: - none - Error: - none - Example: - my $ip = xCAT::NetworkUtils::get_hdwr_ip('node1'); - Comments: - Used in FSPpower FSPflash, FSPinv. - -=cut - -#------------------------------------------------------------------------------- -sub get_hdwr_ip -{ - require xCAT::Table; - my $node = shift; - my $ip = undef; - my $Rc = undef; - - my $ip_tmp_res = xCAT::NetworkUtils::toIP($node); - ($Rc, $ip) = @$ip_tmp_res; - if ($Rc) { - my $hosttab = xCAT::Table->new('hosts'); - if ($hosttab) { - my $node_ip_hash = $hosttab->getNodeAttribs($node, [qw(ip)]); - $ip = $node_ip_hash->{ip}; - } - - } - - if (!$ip) { - return undef; - } - - return $ip; -} - -#-------------------------------------------------------------------------------- - -=head3 pingNodeStatus - This function takes an array of nodes and returns their status using nmap or fping. - Arguments: - nodes-- an array of nodes. - Returns: - a hash that has the node status. The format is: - {alive=>[node1, node3,...], unreachable=>[node4, node2...]} -=cut - -#-------------------------------------------------------------------------------- -sub pingNodeStatus { - my ($class, @mon_nodes) = @_; - my %status = (); - my @active_nodes = (); - my @inactive_nodes = (); - - #print "NetworkUtils->pingNodeStatus called, nodes=@mon_nodes\n"; - if ((@mon_nodes) && (@mon_nodes > 0)) { - - #get all the active nodes - my $nodes = join(' ', @mon_nodes); - if (-x '/usr/bin/nmap' or -x '/usr/local/bin/nmap') { #use nmap - #print "use nmap\n"; - my %deadnodes; - foreach (@mon_nodes) { - $deadnodes{$_} = 1; - } - - # get additional options from site table - my @nmap_options = xCAT::TableUtils->get_site_attribute("nmapoptions"); - my $more_options = $nmap_options[0]; - - #call namp - open(NMAP, "nmap -PE --system-dns --send-ip -sP $more_options " . $nodes . " 2> /dev/null|") or die("Cannot open nmap pipe: $!"); - my $node; - while () { - if (/Host (.*) \(.*\) appears to be up/) { - $node = $1; - unless ($deadnodes{$node}) { - foreach (keys %deadnodes) { - if ($node =~ /^$_\./) { - $node = $_; - last; - } - } - } - delete $deadnodes{$node}; - push(@active_nodes, $node); - } elsif (/Nmap scan report for ([^ ]*) /) { - $node = $1; - } elsif (/Host is up./) { - unless ($deadnodes{$node}) { - foreach (keys %deadnodes) { - if ($node =~ /^$_\./) { - $node = $_; - last; - } - } - } - delete $deadnodes{$node}; - push(@active_nodes, $node); - } - } - foreach (sort keys %deadnodes) { - push(@inactive_nodes, $_); - } - } else { #use fping - #print "use fping\n"; - - my $temp = `fping -a $nodes 2> /dev/null`; - chomp($temp); - @active_nodes = split(/\n/, $temp); - - #get all the inactive nodes by substracting the active nodes from all. - my %temp2; - if ((@active_nodes) && (@active_nodes > 0)) { - foreach (@active_nodes) { $temp2{$_} = 1 } - foreach (@mon_nodes) { - if (!$temp2{$_}) { push(@inactive_nodes, $_); } - } - } - else { @inactive_nodes = @mon_nodes; } - } - } - - $status{$::STATUS_ACTIVE} = \@active_nodes; - $status{$::STATUS_INACTIVE} = \@inactive_nodes; - - #use Data::Dumper; - #print Dumper(%status); - - return %status; -} - -#------------------------------------------------------------------------------- - -=head3 isValidMAC - Description : Validate whether specified string is a MAC string. - Arguments : macstr - the string to be validated. - Returns : 1 - valid MAC String. - 0 - invalid MAC String. -=cut - -#------------------------------------------------------------------------------- -sub isValidMAC -{ - my ($class, $macstr) = @_; - if ($macstr =~ /^[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}$/) { - return 1; - } - return 0; -} - -#------------------------------------------------------------------------------- - -=head3 isValidHostname - Description : Validate whether specified string is a valid hostname. - Arguments : hostname - the string to be validated. - Returns : 1 - valid hostname String. - 0 - invalid hostname String. -=cut - -#------------------------------------------------------------------------------- -sub isValidHostname -{ - my ($class, $hostname) = @_; - if ($hostname =~ /^[a-z0-9]/) { - if ($hostname =~ /[a-z0-9]$/) { - if ($hostname =~ /^[\-a-z0-9]+$/) { - return 1; - } - } - } - return 0; -} - - -#------------------------------------------------------------------------------- - -=head3 isValidFQDN - Description : Validate whether specified string is a valid FQDN. - Arguments : hostname - the string to be validated. - Returns : 1 - valid hostname FQDN. - 0 - invalid hostname FQDN. -=cut - -#------------------------------------------------------------------------------- -sub isValidFQDN -{ - my ($class, $hostname) = @_; - if ($hostname =~ /^[a-z0-9][\.\-a-z0-9]+[a-z0-9]$/) { - return 1; - } - return 0; -} - - -#------------------------------------------------------------------------------- - -=head3 ip_to_int - Description : convert an IPv4 string into int. - Arguments : ipstr - the IPv4 string. - Returns : ipint - int number -=cut - -#------------------------------------------------------------------------------- -sub ip_to_int -{ - my ($class, $ipstr) = @_; - my $ipint = 0; - my @ipnums = split('\.', $ipstr); - $ipint += $ipnums[0] << 24; - $ipint += $ipnums[1] << 16; - $ipint += $ipnums[2] << 8; - $ipint += $ipnums[3]; - return $ipint; -} - -#------------------------------------------------------------------------------- - -=head3 int_to_ip - Description : convert an int into IPv4 String. - Arguments : ipnit - the input int number. - Returns : ipstr - IPv4 String. -=cut - -#------------------------------------------------------------------------------- -sub int_to_ip -{ - my ($class, $ipint) = @_; - return inet_ntoa(inet_aton($ipint)); -} - -#------------------------------------------------------------------------------- - -=head3 getBroadcast - Description : Get the broadcast ips - Arguments : ipstr - the IPv4 string ip. - netmask - the subnet mask of network - Returns : bcipint - the IPv4 string of broadcast ip. -=cut - -#------------------------------------------------------------------------------- -sub getBroadcast -{ - my ($class, $ipstr, $netmask) = @_; - my $ipint = xCAT::NetworkUtils->ip_to_int($ipstr); - my $maskint = xCAT::NetworkUtils->ip_to_int($netmask); - my $tmp = sprintf("%d", ~$maskint); - my $bcnum = sprintf("%d", ($ipint | $tmp) & hex('0x00000000FFFFFFFF')); - return xCAT::NetworkUtils->int_to_ip($bcnum); -} - -#------------------------------------------------------------------------------- - -=head3 get_allips_in_range - Description : Get all IPs in a IP range, return in a list. - Arguments : $startip - start IP address - $endip - end IP address - $increment - increment factor - Returns : IP list in this range. - Example : - my $startip = "192.168.0.1"; - my $endip = "192.168.0.100"; - xCAT::NetworkUtils->get_allips_in_range($startip, $endip, 1); -=cut - -#------------------------------------------------------------------------------- -sub get_allips_in_range -{ - my $class = shift; - my $startip = shift; - my $endip = shift; - my $increment = shift; - my @iplist = (); - my $tmpip; - - my $startipnum = xCAT::NetworkUtils->ip_to_int($startip); - my $endipnum = xCAT::NetworkUtils->ip_to_int($endip); - - if ($increment > 0) { - while ($startipnum <= $endipnum) { - $tmpip = xCAT::NetworkUtils->int_to_ip($startipnum); - $startipnum += $increment; - push(@iplist, $tmpip); - } - } elsif ($increment < 0) { - while ($endipnum >= $startipnum) { - $tmpip = xCAT::NetworkUtils->int_to_ip($endipnum); - $endipnum += $increment; - push(@iplist, $tmpip); - } - } - return \@iplist; -} - -#------------------------------------------------------------------------------- - -=head3 get_all_ips - Description : Get all IP addresses from table nics, column nicips. - Arguments : hashref - if not set, will return a reference of list, - if set, will return a reference of hash. - Returns : All IPs reference. -=cut - -#------------------------------------------------------------------------------- -sub get_all_nicips { - my ($class, $hashref) = @_; - my %allipshash; - my @allipslist; - - my $table = xCAT::Table->new('nics'); - my @entries = $table->getAllNodeAttribs(['nicips']); - foreach (@entries) { - - # $_->{nicips} looks like "eth0:ip1,eth1:ip2,bmc:ip3..." - if ($_->{nicips}) { - my @nicandiplist = split(',', $_->{nicips}); - - # Each record in @nicandiplist looks like "eth0:ip1" - # delimiter has been changed to use "!" in xCAT 2.8 - foreach (@nicandiplist) { - my @nicandip; - if ($_ =~ /!/) { - @nicandip = split('!', $_); - } else { - @nicandip = split(':', $_); - } - if ($hashref) { - $allipshash{ $nicandip[1] } = 0; - } else { - push(@allipslist, $nicandip[1]); - } - } - } - } - if ($hashref) { - return \%allipshash; - } else { - return \@allipslist; - } -} - -#------------------------------------------------------------------------------- - -=head3 gen_net_boot_params - - Description: - This subroutine is used to generate all possible kernel parameters for network boot (rh/sles/ubuntu + diskfull/diskless) - The supported network boot parameters: - ksdevice - Specify network device for Anaconda. For rh6 and earlier. Format: 'ksdevice={$mac|$nicname}' - BOOTIF - Specify network device for Anaconda. The boot device which set by pxe. xCAT also set it if the bootload is not pxe. Format 'BOOTIF={$mac}' - ifname - Specify a interfacename<->mac pair, it will set the interfacename to the interface which has the . Format 'ifname=$ifname:$mac' - # This will only be generated when linuximage.nodebootif is set. - bootdev - Specify the boot device. Mostly it's used with parameter and when there are multiple params. Format 'bootdev={$mac|$ifname} - ip - Specify the network configuration for an interface. Format: 'ip=dhcp', 'ip=$ifname:dhcp' - - netdevice - Specify network device for Linuxrc (Suse bootloader). Format: 'netdevice={$mac|$nicname}' - - netdev - Specify the interfacename which is used by xCAT diskless boot script to select the network interface. Format: 'netdev=$nicname' - - Reference: - Redhat anaconda doc: https://github.com/rhinstaller/anaconda/blob/master/docs/boot-options.txt - Suse Linuxrc do: https://en.opensuse.org/SDB:Linuxrc - - Arguments: - $installnic <- node.installnic - $primarynic <- node.primarynic - $macmac <- node.mac - $nodebootif <- linuximage.nodebootif - - Returns: - $net_params - The key will be the parameter name, the value for the key will be the parameter value. - Valid Parameter Name: - ksdevice - netdev - netdevice - ip - ifname - BOOTIF - - And following two keys also will be returned for reference - mac - nicname - - Example: - my $netparams = xCAT::NetworkUtils->gen_net_boot_params($installnic, $primmarynic, $macmac, $nodebootif); - -=cut - -#------------------------------------------------------------------------------- - -sub gen_net_boot_params -{ - my $class = shift; - my $installnic = shift; - my $primarynic = shift; - my $macmac = shift; - my $nodebootif = shift; - - my $net_params; - - # arbitrary use primarynic if installnic is not set - unless ($installnic) { - $installnic = $primarynic; - } - - # just use the installnic to generate the nic related kernel parameters - my $mac; - my $nicname; - - # set the default nicname to nodebootif from image definition - if ($nodebootif) { - $nicname = $nodebootif; - } - - if ((!defined($installnic)) || ($installnic eq "") || ($installnic =~ /^mac$/i)) { - $mac = $macmac; - $net_params->{mac} = $mac; - } elsif ($installnic =~ /^[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}$/) { - $mac = $installnic; - $net_params->{mac} = $mac; - $net_params->{setmac} = $mac; - } else { - $mac = $macmac; - $nicname = $installnic; - $net_params->{nicname} = $nicname; - $net_params->{mac} = $mac; - } - - # if nicname is set and mac.mac is NOT set to , use nicname in the boot parameters - if ($nicname && !defined($net_params->{setmac})) { - $net_params->{ksdevice} = "ksdevice=$nicname"; - $net_params->{ip} = "ip=$nicname:dhcp"; - $net_params->{netdev} = "netdev=$nicname"; - $net_params->{netdevice} = "netdevice=$nicname"; - $net_params->{ifname} = "ifname=$nicname:$mac"; # todo: may not use mac arbitrary - } elsif ($mac) { - $net_params->{ksdevice} = "ksdevice=$mac"; - $net_params->{BOOTIF} = "BOOTIF=$mac"; - $net_params->{bootdev} = "bootdev=$mac"; - $net_params->{ip} = "ip=dhcp"; - $net_params->{netdevice} = "netdevice=$mac"; - } - - return $net_params; -} - -1; From 506d0c9660a7e22b5a0c373b565f6b21691a820c Mon Sep 17 00:00:00 2001 From: immarvin Date: Sun, 14 Aug 2016 06:11:04 -0400 Subject: [PATCH 046/106] fix issue [Customer] nodeset failed with meaningless messages #1529 --- xCAT-server/lib/perl/xCAT/Template.pm | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/xCAT-server/lib/perl/xCAT/Template.pm b/xCAT-server/lib/perl/xCAT/Template.pm index 41511ef3e..52c8db034 100644 --- a/xCAT-server/lib/perl/xCAT/Template.pm +++ b/xCAT-server/lib/perl/xCAT/Template.pm @@ -114,7 +114,8 @@ sub subvars { } unless ($master) { - die "Unable to identify master for $node"; + $tmplerr = "Unable to identify master for $node"; + return; } $ENV{XCATMASTER} = $master; @@ -1009,7 +1010,7 @@ sub kickstartnetwork { $line .= $ulaaddr; } elsif ($::XCATSITEVALS{managedaddressmode} =~ /static/) { my ($ipaddr, $hostname, $gateway, $netmask) = xCAT::NetworkUtils->getNodeNetworkCfg($node); - unless ($ipaddr) { die "cannot resolve the network configuration of $node"; } + unless ($ipaddr) { $tmplerr = "cannot resolve the network configuration of $node"; return; } if ($gateway eq '') { @@ -1116,9 +1117,9 @@ sub yast2network { my $line; my $hoststab; my $mactab = xCAT::Table->new('mac', -create => 0); - unless ($mactab) { die "mac table should always exist prior to template processing when doing autoula"; } + unless ($mactab) { $tmplerr="mac table should always exist prior to template processing when doing autoula"; return;} my $ent = $mactab->getNodeAttribs($node, ['mac'], prefetchcache => 1); - unless ($ent and $ent->{mac}) { die "missing mac data for $node"; } + unless ($ent and $ent->{mac}) { $tmplerr="missing mac data for $node"; return; } my $suffix = xCAT::Utils->parseMacTabEntry($ent->{mac}, $node); $suffix = lc($suffix); @@ -1128,7 +1129,7 @@ sub yast2network { return "#YAST2NET autoula unsupported" } elsif ($::XCATSITEVALS{managedaddressmode} =~ /static/) { my ($ipaddr, $hostname, $gateway, $netmask) = xCAT::NetworkUtils->getNodeNetworkCfg($node); - unless ($ipaddr) { die "cannot resolve the network configuration of $node"; } + unless ($ipaddr) { $tmplerr = "cannot resolve the network configuration of $node"; return; } if ($gateway eq '') { my @gatewayd = xCAT::NetworkUtils->my_ip_facing($ipaddr); From 0f59a399ee5ae17ef6ec914fb8917834fca53c14 Mon Sep 17 00:00:00 2001 From: "litingt@cn.ibm.com" Date: Mon, 15 Aug 2016 02:36:40 -0400 Subject: [PATCH 047/106] update cases for packimage code change --- xCAT-test/autotest/testcase/packimg/cases0 | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/xCAT-test/autotest/testcase/packimg/cases0 b/xCAT-test/autotest/testcase/packimg/cases0 index 5e0fc612e..aeca509ea 100644 --- a/xCAT-test/autotest/testcase/packimg/cases0 +++ b/xCAT-test/autotest/testcase/packimg/cases0 @@ -3,17 +3,17 @@ os:Linux description: cmd:copycds $$ISO cmd:ls /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg;if [ $? -eq 0 ];then mv -f /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg /rootimg.bak;fi -cmd:ls /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.gz;if [ $? -eq 0 ];then mv -f /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.gz /rootimg.gz.bak;fi +cmd:ls /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.cpio.gz;if [ $? -eq 0 ];then mv -f /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.cpio.gz /rootimg.cpio.gz.bak;fi cmd:genimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute check:rc==0 cmd:ls -l /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg check:rc==0 cmd:packimage -o __GETNODEATTR($$CN,os)__ -p compute -a __GETNODEATTR($$CN,arch)__ -m cpio check:rc==0 -cmd:ls -l /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.gz +cmd:ls -l /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.cpio.gz check:rc==0 -cmd:rm -rf /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.gz -cmd:mv -f /rootimg.gz.bak /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.gz +cmd:rm -rf /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.cpio.gz +cmd:mv -f /rootimg.cpio.gz.bak /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.cpio.gz cmd:rm -rf /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg cmd:mv -f /rootimg.bak /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg end @@ -21,17 +21,17 @@ end start:packimage_p_a_o os:Linux cmd:ls /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg;if [ $? -eq 0 ];then mv -f /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg /rootimg.bak;fi -cmd:ls /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.gz;if [ $? -eq 0 ];then mv -f /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.gz /rootimg.gz.bak;fi +cmd:ls /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.cpio.gz;if [ $? -eq 0 ];then mv -f /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.cpio.gz /rootimg.cpio.gz.bak;fi cmd:genimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute check:rc==0 cmd:ls -l /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg check:rc==0 cmd:packimage -p compute -a __GETNODEATTR($$CN,arch)__ -o __GETNODEATTR($$CN,os)__ check:rc==0 -cmd:ls -l /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.gz +cmd:ls -l /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.cpio.gz check:rc==0 -cmd:rm -rf /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.gz -cmd:mv -f /rootimg.gz.bak /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.gz +cmd:rm -rf /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.cpio.gz +cmd:mv -f /rootimg.cpio.gz.bak /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.cpio.gz cmd:rm -rf /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg cmd:mv -f /rootimg.bak /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg end @@ -40,17 +40,17 @@ start:packimage_imagename os:Linux description: cmd:ls /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg;if [ $? -eq 0 ];then mv -f /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg /rootimg.bak;fi -cmd:ls /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.gz;if [ $? -eq 0 ];then mv -f /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.gz /rootimg.gz.bak;fi +cmd:ls /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.cpio.gz;if [ $? -eq 0 ];then mv -f /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.cpio.gz /rootimg.cpio.gz.bak;fi cmd:genimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute check:rc==0 cmd:ls -l /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg check:rc==0 cmd:packimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute check:rc==0 -cmd:ls -l /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.gz +cmd:ls -l /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.cpio.gz check:rc==0 -cmd:rm -rf /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.gz -cmd:mv -f /rootimg.gz.bak /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.gz +cmd:rm -rf /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.cpio.gz +cmd:mv -f /rootimg.cpio.gz.bak /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.cpio.gz cmd:rm -rf /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg cmd:mv -f /rootimg.bak /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg end From d4a397adce112baff1129b8ef91f66c20194a2b5 Mon Sep 17 00:00:00 2001 From: penguhyang Date: Sun, 14 Aug 2016 23:17:23 -0400 Subject: [PATCH 048/106] support tar for redhat6.8 --- xCAT-server/lib/xcat/plugins/packimage.pm | 14 ++++++++++++-- xCAT-server/share/xcat/netboot/rh/dracut/xcatroot | 6 ++++++ .../share/xcat/netboot/rh/dracut_033/xcatroot | 6 ++++++ xCAT-server/share/xcat/netboot/rh/genimage | 6 ++++++ 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/packimage.pm b/xCAT-server/lib/xcat/plugins/packimage.pm index 60062d26d..216e21ae1 100755 --- a/xCAT-server/lib/xcat/plugins/packimage.pm +++ b/xCAT-server/lib/xcat/plugins/packimage.pm @@ -488,14 +488,24 @@ sub process_request { $oldmask = umask 0077; } elsif ($method =~ /tar/) { if (!$exlistloc) { - $excludestr = "find . -xdev -print0 | tar --selinux --xattrs-include='*' --no-recursion --use-compress-program=$compress --null -T - -cf ../rootimg.$suffix"; + my $checkoption = `tar --xattrs-include 2>&1`; + if ($checkoption =~ /unrecognized/) { + $excludestr = "find . -xdev -print0 | tar --selinux --no-recursion --use-compress-program=$compress --null -T - -cf ../rootimg.$suffix"; + } else { + $excludestr = "find . -xdev -print0 | tar --selinux --xattrs-include='*' --no-recursion --use-compress-program=$compress --null -T - -cf ../rootimg.$suffix"; + } } else { chdir("$rootimg_dir"); system("$excludestr >> $xcat_packimg_tmpfile"); if ($includestr) { system("$includestr >> $xcat_packimg_tmpfile"); } - $excludestr = "cat $xcat_packimg_tmpfile| tar --selinux --xattrs-include='*' --no-recursion --use-compress-program=$compress -T - -cf ../rootimg.$suffix"; + my $checkoption = `tar --xattrs-include 2>&1`; + if ($checkoption =~ /unrecognized/) { + $excludestr = "cat $xcat_packimg_tmpfile| tar --selinux --no-recursion --use-compress-program=$compress -T - -cf ../rootimg.$suffix"; + } else { + $excludestr = "cat $xcat_packimg_tmpfile| tar --selinux --xattrs-include='*' --no-recursion --use-compress-program=$compress -T - -cf ../rootimg.$suffix"; + } } $oldmask = umask 0077; } elsif ($method =~ /squashfs/) { diff --git a/xCAT-server/share/xcat/netboot/rh/dracut/xcatroot b/xCAT-server/share/xcat/netboot/rh/dracut/xcatroot index 367625618..b53ccb366 100755 --- a/xCAT-server/share/xcat/netboot/rh/dracut/xcatroot +++ b/xCAT-server/share/xcat/netboot/rh/dracut/xcatroot @@ -107,8 +107,14 @@ elif [ -r /rootimg.tar.gz ] || [ -r /rootimg.tar.xz ]; then echo -n "Extracting root filesystem:" if [ -r /rootimg.tar.gz ]; then tar --selinux --xattrs-include='*' -zxf /rootimg.tar.gz + if [ $? -ne 0 ]; then + tar --selinux -zxf /rootimg.tar.gz + fi elif [ -r /rootimg.tar.xz ]; then tar --selinux --xattrs-include='*' -Jxf /rootimg.tar.xz + if [ $? -ne 0 ]; then + tar --selinux -Jxf /rootimg.tar.xz + fi fi $NEWROOT/etc/init.d/localdisk echo Done diff --git a/xCAT-server/share/xcat/netboot/rh/dracut_033/xcatroot b/xCAT-server/share/xcat/netboot/rh/dracut_033/xcatroot index 58a33895e..c53a209b6 100755 --- a/xCAT-server/share/xcat/netboot/rh/dracut_033/xcatroot +++ b/xCAT-server/share/xcat/netboot/rh/dracut_033/xcatroot @@ -111,8 +111,14 @@ elif [ -r /rootimg.tar.gz ] || [ -r /rootimg.tar.xz ]; then echo -n "Extracting root filesystem:" if [ -r /rootimg.tar.gz ]; then tar --selinux --xattrs-include='*' -zxf /rootimg.tar.gz + if [ $? -ne 0 ]; then + tar --selinux -zxf /rootimg.tar.gz + fi elif [ -r /rootimg.tar.xz ]; then tar --selinux --xattrs-include='*' -Jxf /rootimg.tar.xz + if [ $? -ne 0 ]; then + tar --selinux -Jxf /rootimg.tar.xz + fi fi $NEWROOT/etc/init.d/localdisk [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Done...." diff --git a/xCAT-server/share/xcat/netboot/rh/genimage b/xCAT-server/share/xcat/netboot/rh/genimage index bc5104c41..a56e157b6 100755 --- a/xCAT-server/share/xcat/netboot/rh/genimage +++ b/xCAT-server/share/xcat/netboot/rh/genimage @@ -1641,8 +1641,14 @@ EOMS print $inifile " echo -n \"Extracting root filesystem:\"\n"; print $inifile " if [ -r /rootimg.tar.gz ]; then\n"; print $inifile " tar --selinux --xattrs-include='*' -zxf /rootimg.tar.gz\n"; + print $inifile " if [ \$? -ne 0 ]; then\n"; + print $inifile " tar --selinux -zxf /rootimg.tar.gz\n"; + print $inifile " fi\n"; print $inifile " elif [ -r /rootimg.tar.xz ]; then\n"; print $inifile " tar --selinux --xattrs-include='*' -Jxf /rootimg.tar.xz\n"; + print $inifile " if [ \$? -ne 0 ]; then\n"; + print $inifile " tar --selinux -Jxf /rootimg.tar.xz\n"; + print $inifile " fi\n"; print $inifile " fi\n"; print $inifile " echo Done\n"; print $inifile "else\n"; From 67d03b2c421b59eeeb9cefeab97c139687a62e9f Mon Sep 17 00:00:00 2001 From: "litingt@cn.ibm.com" Date: Mon, 15 Aug 2016 03:51:08 -0400 Subject: [PATCH 049/106] use dependency on mn to run test --- xCAT-test/autotest/testcase/go-xcat/case2 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xCAT-test/autotest/testcase/go-xcat/case2 b/xCAT-test/autotest/testcase/go-xcat/case2 index b0fab9bc1..80049f229 100644 --- a/xCAT-test/autotest/testcase/go-xcat/case2 +++ b/xCAT-test/autotest/testcase/go-xcat/case2 @@ -163,12 +163,14 @@ cmd:xdsh $$CN "cd /; rm -rf /go-xcat" check:rc==0 cmd:xdsh $$CN "cd /; scp -r $$MN:/opt/xcat/share/xcat/tools/go-xcat ./" check:rc==0 +cmd:cp /xcat-dep-*.tar.bz2 /install/ +check:rc==0 cmd:if grep Ubuntu /etc/*release;then code=`lsb_release -sc` && xdsh $$CN "scp -r $$MN:/opt/xcat/share/xcat/tools/autotest/testcase/go-xcat/$code-__GETNODEATTR($$CN,arch)__.sources.list /etc/apt/sources.list"; fi cmd:if grep Ubuntu /etc/*release;then xdsh $$CN "scp -r $$MN:/etc/resolv.conf /etc/resolv.conf" && xdsh $$CN "wget -O - http://sourceforge.net/projects/xcat/files/ubuntu/apt.key/download | apt-key add -"; fi check:rc==0 cmd:if grep Ubuntu /etc/*release;then xdsh $$CN "apt-get clean && apt-get update"; fi check:rc==0 -cmd:if grep Ubuntu /etc/*release;then xdsh $$CN "cd /; ./go-xcat --xcat-core=http://xcat.org/files/xcat/xcat-core/devel/Ubuntu/core-snap/core-debs-snap.tar.bz2 --xcat-dep=http://xcat.org/files/xcat/xcat-dep/2.x_Ubuntu/xcat-dep-2.12-ubuntu.tar.bz2 -y install"; else xdsh $$CN "cd /; ./go-xcat --xcat-core=http://xcat.org/files/xcat/xcat-core/devel/Linux/core-snap/core-rpms-snap.tar.bz2 --xcat-dep=http://xcat.org/files/xcat/xcat-dep/2.x_Linux/xcat-dep-2.12-linux.tar.bz2 -y install"; fi +cmd:dep=`ls /install/xcat-dep-*.tar.bz2`;if grep Ubuntu /etc/*release;then xdsh $$CN "cd /; ./go-xcat --xcat-core=http://xcat.org/files/xcat/xcat-core/devel/Ubuntu/core-snap/core-debs-snap.tar.bz2 --xcat-dep=http://$$MN/$dep -y install"; else xdsh $$CN "cd /; ./go-xcat --xcat-core=http://xcat.org/files/xcat/xcat-core/devel/Linux/core-snap/core-rpms-snap.tar.bz2 --xcat-dep=http://$$MN/$dep -y install"; fi check:rc==0 cmd:xdsh $$CN "source /etc/profile.d/xcat.sh;lsxcatd -v" check:rc==0 From d7a683b200ca41f5d1fc24c991f7ff508f68d69a Mon Sep 17 00:00:00 2001 From: hu-weihua Date: Mon, 15 Aug 2016 04:00:03 -0400 Subject: [PATCH 050/106] fix probe bugs --- xCAT-probe/lib/perl/probe_utils.pm | 77 +++++++++++++++++++++ xCAT-probe/subcmds/xcatmn | 103 +++++++---------------------- xCAT-probe/xcatprobe | 1 + xCATsn/debian/control | 2 +- xCATsn/xCATsn.spec | 2 +- 5 files changed, 104 insertions(+), 81 deletions(-) diff --git a/xCAT-probe/lib/perl/probe_utils.pm b/xCAT-probe/lib/perl/probe_utils.pm index 8f2198fca..00a3a59f7 100644 --- a/xCAT-probe/lib/perl/probe_utils.pm +++ b/xCAT-probe/lib/perl/probe_utils.pm @@ -5,6 +5,7 @@ package probe_utils; use strict; use File::Path; use File::Copy; +use Time::Local; use Socket; #----------------------------------------- @@ -439,4 +440,80 @@ sub get_hostname_from_ip { return $hostname; } +#------------------------------------------ + +=head3 + Description: + Check if the free space of specific directory is more than expected value + Arguments: + targetdir: The directory needed to be checked + expect_free_space: the expected free space for above directory + Returns: + 0: the free space of specific directory is less than expected value + 1: the free space of specific directory is more than expected value + 2: the specific directory isn't mounted on standalone disk. it is a part of "/" +=cut + +#------------------------------------------ +sub is_dir_has_enough_space{ + my $targetdir=shift; + $targetdir = shift if (($targetdir) && ($targetdir =~ /probe_utils/)); + my $expect_free_space = shift; + my @output = `df -k`; + + foreach my $line (@output){ + chomp($line); + my @line_array = split(/\s+/, $line); + if($line_array[5] =~ /^$targetdir$/){ + my $left_space = $line_array[3]/1048576; + if($left_space >= $expect_free_space){ + return 1; + }else{ + return 0; + } + } + } + return 2; +} + +#------------------------------------------ + +=head3 + Description: + Convert input time format to the number of non-leap seconds since whatever time the system considers to be the epoch + the format of input time are two kinds + one like "Aug 15 02:43:31", another likes "15/Aug/2016:01:10:24" + Arguments: + timestr: the time format need to be converted + yday: the year of current time. + Returns: + the number of non-leap seconds since whatever time the system considers to be the epoch +=cut + +#------------------------------------------ +sub convert_to_epoch_seconds { + my $timestr=shift; + $timestr = shift if (($timestr) && ($timestr =~ /probe_utils/)); + my $yday=shift; + my $ref_seconds=shift; + my $mday; + my $dday; + my $h; + my $m; + my $s; + my $epoch_seconds=-1; + my %monthsmap = ("Jan"=>0,"Feb"=>1,"Mar"=>2,"Apr"=>3,"May"=>4,"Jun"=>5,"Jul"=>6,"Aug"=>7,"Sep"=>8,"Oct"=>9,"Nov"=>10,"Dec"=>11); + + if($timestr =~/(\w+)\s+(\d+)\s+(\d+):(\d+):(\d+)/){ + ($mday,$dday,$h,$m,$s)=($1,$2,$3,$4,$5); + $epoch_seconds = timelocal($s,$m,$h,$dday,$monthsmap{$mday},$yday); + if($epoch_seconds>$ref_seconds){ + $yday-=1; + $epoch_seconds = timelocal($s,$m,$h,$dday,$monthsmap{$mday},$yday); + } + }elsif($timestr =~ /(\d+)\/(\w+)\/(\d+):(\d+):(\d+):(\d+)/){ + $epoch_seconds = timelocal($6,$5,$4,$1,$monthsmap{$2},($3-1900)); + } + return $epoch_seconds; +} 1; diff --git a/xCAT-probe/subcmds/xcatmn b/xCAT-probe/subcmds/xcatmn index d12c2c622..8a28b045e 100755 --- a/xCAT-probe/subcmds/xcatmn +++ b/xCAT-probe/subcmds/xcatmn @@ -363,68 +363,23 @@ sub do_main_job { } } - my $expected = 10; - $msg = "The free space of / directory is more than $expected G"; - my $diskspace = `df -h|awk '{print \$4,\$6}'|grep -E "/\$"`; - if ($?) { - probe_utils->send_msg($outputtarget, "d", "There isn't any filesystem mount on / directory"); - probe_utils->send_msg($outputtarget, "f", "$msg"); - $rst = 1; - } else { - chomp($diskspace); - my ($size, $dir) = split(" ", $diskspace); - $size =~ s/G//g; - probe_utils->send_msg($outputtarget, "d", "The free space of / is $size G") if ($verbose); - if ($size < $expected) { - probe_utils->send_msg($outputtarget, "w", "The free space of / is less than $expected G"); - } else { - probe_utils->send_msg($outputtarget, "o", "$msg"); + #check the free space of specific directory + #if "/var" is mounted on standalone disk, more than 1G free space is expected + #if "/tmp" is mounted on standalone disk, more than 1G free space is expected + #if installdir is mounted on standalone disk, more than 10G free space is expected. + #if any one of above three directories hasn't standalone disk, "/" directory should cover its space requirement. + my @dir_expectedspace_list = (["/var", "1"], ["/tmp", "1"], ["$installdir", "10"], ["/" , "0"]); + foreach my $dir (@dir_expectedspace_list){ + next if($dir->[0] eq "/" && $dir->[1] == 0); + my $checkrst = probe_utils->is_dir_has_enough_space($dir->[0], $dir->[1]); + if($checkrst == 2){ + $dir_expectedspace_list[$#dir_expectedspace_list][1] += $dir->[1]; + }elsif($checkrst == 1){ + probe_utils->send_msg($outputtarget, "o", "The free space of '$dir->[0]' directory is more than $dir->[1] G"); + }elsif($checkrst == 0){ + probe_utils->send_msg($outputtarget, "w", "The free space of '$dir->[0]' is less than $dir->[1] G"); } - } - $expected = 1; - $msg = "The free space of /var directory is more than $expected G"; - $diskspace = `df -h|awk '{print \$4,\$6}'|grep -E "/var\$"`; - if (!$?) { - chomp($diskspace); - my ($size, $dir) = split(" ", $diskspace); - $size =~ s/G//g; - probe_utils->send_msg($outputtarget, "d", "The free space of /var is $size G") if ($verbose); - if ($size < $expected) { - probe_utils->send_msg($outputtarget, "w", "The free space of /var is less than $expected G"); - } else { - probe_utils->send_msg($outputtarget, "o", "$msg"); - } - } - - $expected = 1; - $msg = "The free space of /tmp directory is more than $expected G"; - $diskspace = `df -h|awk '{print \$4,\$6}'|grep -E "/tmp\$"`; - if (!$?) { - chomp($diskspace); - my ($size, $dir) = split(" ", $diskspace); - $size =~ s/G//g; - probe_utils->send_msg($outputtarget, "d", "The free space of /tmp is $size G") if ($verbose); - if ($size < $expected) { - probe_utils->send_msg($outputtarget, "w", "The free space of /tmp is less than $expected G"); - } else { - probe_utils->send_msg($outputtarget, "o", "$msg"); - } - } - - $expected = 10; - $msg = "The free space of $installdir directory is more than $expected G"; - $diskspace = `df -h|awk '{print \$4,\$6}'|grep -E "$installdir\$"`; - if (!$?) { - chomp($diskspace); - my ($size, $dir) = split(" ", $diskspace); - $size =~ s/G//g; - probe_utils->send_msg($outputtarget, "d", "The free space of /install is $size G") if ($verbose); - if ($size < $expected) { - probe_utils->send_msg($outputtarget, "w", "The free space of /install is less than $expected G"); - } else { - probe_utils->send_msg($outputtarget, "o", "$msg"); - } } $msg = "SELinux is disabled on current server"; @@ -444,8 +399,7 @@ sub do_main_job { `which wget > /dev/null 2>&1`; if ($?) { - probe_utils->send_msg($outputtarget, "w", "wget tool isn't installed on current server, skip checking HTTP service."); - probe_utils->send_msg($outputtarget, "d", "Please do probe again after installing wget"); + probe_utils->send_msg($outputtarget, "w", "'wget' tool isn't installed, skip checking HTTP service. please install wget then try again"); } else { $msg = "HTTP service is ready on $serverip"; if (probe_utils->is_http_ready("$serverip")) { @@ -472,8 +426,7 @@ sub do_main_job { if ($checktftp) { `which tftp > /dev/null 2>&1`; if ($?) { - probe_utils->send_msg($outputtarget, "w", "tftp tool isn't installed on current server, skip checking tftp service."); - probe_utils->send_msg($outputtarget, "d", "Please do probe again after installing tftp"); + probe_utils->send_msg($outputtarget, "w", "'tftp' tool isn't installed, skip checking tftp service. Please install tftp then try again"); } else { $msg = "TFTP service is ready on $serverip"; if (probe_utils->is_tftp_ready("$serverip")) { @@ -499,14 +452,12 @@ sub do_main_job { if ($checkdns) { `which nslookup > /dev/null 2>&1`; if ($?) { - probe_utils->send_msg($outputtarget, "w", "nslookup tool isn't installed in current server, skip checking DNS service."); - probe_utils->send_msg($outputtarget, "d", "Please do probe again after installing nslookup"); + probe_utils->send_msg($outputtarget, "w", "'nslookup' tool isn't installed, skip checking DNS service. please install nslookup then try again"); } else { $msg = "DNS server is ready on $serverip"; probe_utils->send_msg($outputtarget, "d", "Domain used to check DNS is $domain") if ($verbose); my $rc = 0; - if (!$is_sn) { # if this is a hierarchical cluster, nslookup one of sn to check DNS service @@ -517,7 +468,7 @@ sub do_main_job { if ($sninfo =~ /(\d+).(\d+).(\d+).(\d+)/) { my $snip = "$1.$2.$3.$4"; if (!probe_utils->is_dns_ready("$snip", "$serverip", "$sntmp", "$domain")) { - probe_utils->send_msg("$outputtarget", "d", "nslookup $sntmp $snip failed"); + probe_utils->send_msg("$outputtarget", "d", "nslookup $sntmp $snip failed") if($verbose); $rc = 1; } } @@ -525,17 +476,11 @@ sub do_main_job { # if there is no sn, nslookup mnip my $nslkp = `nslookup $serverip $serverip 2>&1`; - - if ($?) { - probe_utils->send_msg($outputtarget, "d", "nslookup $serverip $serverip failed"); + chomp($nslkp); + my $tmp = grep {$_ =~ "Server:[\t\s]*$serverip"} split (/\n/, $nslkp); + if (!$tmp) { + probe_utils->send_msg($outputtarget, "d", "nslookup $serverip $serverip failed") if($verbose); $rc = 1; - } else { - chomp($nslkp); - my $tmp = grep {$_ =~ "Server:[\t\s]*$serverip"} split (/\n/, $output); - if (!$tmp) { - probe_utils->send_msg($outputtarget, "d", "nslookup $serverip $serverip failed"); - $rc = 1; - } } } if ($rc) { @@ -861,7 +806,7 @@ sub send_sn_msg { if ($line =~ /^(\[\w+\]\s*):\s*(.*)/) { print "$1:[SN:$node]: $2\n"; } else { - print "[failed] :$node: $line\n"; + print "[failed] :[SN:$node]: $line\n"; } } } diff --git a/xCAT-probe/xcatprobe b/xCAT-probe/xcatprobe index 0ded99666..6cd0b5e95 100755 --- a/xCAT-probe/xcatprobe +++ b/xCAT-probe/xcatprobe @@ -31,6 +31,7 @@ Options: -h : get usage information of $program_name -l : list all valid sub commands -V : print verbose information of $program_name + -w : show each line completely. by default if one is too long, the long part will be omitted. "; #----------------------------------- diff --git a/xCATsn/debian/control b/xCATsn/debian/control index 865c48925..105f97304 100644 --- a/xCATsn/debian/control +++ b/xCATsn/debian/control @@ -7,7 +7,7 @@ Standards-Version: 3.7.2 Package: xcatsn Architecture: all -Depends: ${perl:Depends}, xcat-server, perl-xcat, xcat-client, libdbd-sqlite3-perl, libxml-parser-perl, tftpd-hpa, tftp-hpa, conserver-xcat, libnet-telnet-perl, dhcp3-server, apache2, expect, nfs-kernel-server, nmap, bind9, ipmitool-xcat (>=1.8.15-2), syslinux-xcat, xnba-undi, xcat-genesis-scripts-ppc64, xcat-genesis-scripts-amd64, elilo-xcat,libsys-virt-perl +Depends: ${perl:Depends}, xcat-server, perl-xcat, xcat-client, libdbd-sqlite3-perl, libxml-parser-perl, tftpd-hpa, tftp-hpa, conserver-xcat, libnet-telnet-perl, dhcp3-server, apache2, expect, nfs-kernel-server, nmap, bind9, ipmitool-xcat (>=1.8.15-2), syslinux-xcat, xnba-undi, xcat-genesis-scripts-ppc64, xcat-genesis-scripts-amd64, elilo-xcat,libsys-virt-perl, xcat-probe (>=2.12) Recommends: yaboot-xcat Description: Metapackage for a common, default xCAT service node setup xCATsn is a service node management package intended for at-scale management, including hardware management and software management. diff --git a/xCATsn/xCATsn.spec b/xCATsn/xCATsn.spec index fd0fca2d8..f18eda6d0 100644 --- a/xCATsn/xCATsn.spec +++ b/xCATsn/xCATsn.spec @@ -17,7 +17,7 @@ Source3: xCATSN Source5: templates.tar.gz Source6: xcat.conf.apach24 Provides: xCATsn = %{version} -Requires: xCAT-server xCAT-client perl-DBD-SQLite xCAT-genesis-scripts-x86_64 xCAT-genesis-scripts-ppc64 +Requires: xCAT-server xCAT-client perl-DBD-SQLite xCAT-genesis-scripts-x86_64 xCAT-genesis-scripts-ppc64 xCAT-probe >= 2.12.2 Conflicts: xCAT From f492ceb7e9254f3637da48ec7d573e475f4930d1 Mon Sep 17 00:00:00 2001 From: Casandra Qiu Date: Mon, 15 Aug 2016 08:50:49 -0400 Subject: [PATCH 051/106] use cudaruntime-8-0 as default --- .../xcat/install/rh/cudaruntime.rhels7.ppc64le.pkglist | 8 ++++---- .../rh/cudaruntime.rhels7.ppc64le.otherpkgs.pkglist | 8 ++++---- xCAT/postscripts/config_cuda | 5 +++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/xCAT-server/share/xcat/install/rh/cudaruntime.rhels7.ppc64le.pkglist b/xCAT-server/share/xcat/install/rh/cudaruntime.rhels7.ppc64le.pkglist index a48175537..d5fcc574a 100644 --- a/xCAT-server/share/xcat/install/rh/cudaruntime.rhels7.ppc64le.pkglist +++ b/xCAT-server/share/xcat/install/rh/cudaruntime.rhels7.ppc64le.pkglist @@ -6,8 +6,8 @@ gcc pciutils dkms #To install cuda-runtime, need to specify the version -#if want to install cuda-runtime-8-0, uncomment it, -#then comment out cuda-runtime-7-5 -#cuda-runtime-8-0 -cuda-runtime-7-5 +#if want to install cuda-runtime-7-5, uncomment it, +#then comment out cuda-runtime-8-0 +#cuda-runtime-7-5 +cuda-runtime-8-0 diff --git a/xCAT-server/share/xcat/netboot/rh/cudaruntime.rhels7.ppc64le.otherpkgs.pkglist b/xCAT-server/share/xcat/netboot/rh/cudaruntime.rhels7.ppc64le.otherpkgs.pkglist index 12c60f80a..ec78a1dea 100644 --- a/xCAT-server/share/xcat/netboot/rh/cudaruntime.rhels7.ppc64le.otherpkgs.pkglist +++ b/xCAT-server/share/xcat/netboot/rh/cudaruntime.rhels7.ppc64le.otherpkgs.pkglist @@ -5,8 +5,8 @@ gcc pciutils dkms #To install cuda-runtime, need to specify the version -#if want to install cuda-runtime-8-0, uncomment it, -#then comment out cuda-runtime-7-5 -#cuda-runtime-8-0 -cuda-runtime-7-5 +#if want to install cuda-runtime-7-5, uncomment it, +#then comment out cuda-runtime-8-0 +#cuda-runtime-7-5 +cuda-runtime-8-0 diff --git a/xCAT/postscripts/config_cuda b/xCAT/postscripts/config_cuda index db4ee9fb8..87aa910d3 100755 --- a/xCAT/postscripts/config_cuda +++ b/xCAT/postscripts/config_cuda @@ -1,7 +1,8 @@ #!/bin/sh # set the paths required for cuda +CUDA_PATH=/usr/local/cuda FILENAME="/etc/profile.d/xcat-cuda.sh" -echo "export PATH=/usr/local/cuda/bin:\$PATH" > ${FILENAME} -echo "export LD_LIBRARY_PATH=/usr/local/cuda/lib64:\$LD_LIBRARY_PATH" >> ${FILENAME} +echo "export PATH=$CUDA_PATH/bin:\$PATH" > ${FILENAME} +echo "export LD_LIBRARY_PATH=$CUDA_PATH/lib64:\$LD_LIBRARY_PATH" >> ${FILENAME} From 6a197828ae18cff89daebb130a159af0c905b957 Mon Sep 17 00:00:00 2001 From: Casandra Qiu Date: Mon, 15 Aug 2016 14:31:25 -0400 Subject: [PATCH 052/106] modify comments --- .../share/xcat/install/rh/cudaruntime.rhels7.ppc64le.pkglist | 5 ++--- .../netboot/rh/cudaruntime.rhels7.ppc64le.otherpkgs.pkglist | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/xCAT-server/share/xcat/install/rh/cudaruntime.rhels7.ppc64le.pkglist b/xCAT-server/share/xcat/install/rh/cudaruntime.rhels7.ppc64le.pkglist index d5fcc574a..304628eb2 100644 --- a/xCAT-server/share/xcat/install/rh/cudaruntime.rhels7.ppc64le.pkglist +++ b/xCAT-server/share/xcat/install/rh/cudaruntime.rhels7.ppc64le.pkglist @@ -5,9 +5,8 @@ kernel-devel gcc pciutils dkms -#To install cuda-runtime, need to specify the version -#if want to install cuda-runtime-7-5, uncomment it, -#then comment out cuda-runtime-8-0 +#To install cuda-runtime-7-5 #cuda-runtime-7-5 +#To install cuda-runtime-8-0 cuda-runtime-8-0 diff --git a/xCAT-server/share/xcat/netboot/rh/cudaruntime.rhels7.ppc64le.otherpkgs.pkglist b/xCAT-server/share/xcat/netboot/rh/cudaruntime.rhels7.ppc64le.otherpkgs.pkglist index ec78a1dea..f513fcbeb 100644 --- a/xCAT-server/share/xcat/netboot/rh/cudaruntime.rhels7.ppc64le.otherpkgs.pkglist +++ b/xCAT-server/share/xcat/netboot/rh/cudaruntime.rhels7.ppc64le.otherpkgs.pkglist @@ -4,9 +4,8 @@ kernel-devel gcc pciutils dkms -#To install cuda-runtime, need to specify the version -#if want to install cuda-runtime-7-5, uncomment it, -#then comment out cuda-runtime-8-0 +#To install cuda-runtime-7-5 #cuda-runtime-7-5 +#To install cuda-runtime-8-0 cuda-runtime-8-0 From 5f5bb2052f82c790149cd0bd3be25c3b03beb02e Mon Sep 17 00:00:00 2001 From: Patrick Lundgren Date: Mon, 15 Aug 2016 15:50:40 -0400 Subject: [PATCH 053/106] Added check for GTB Model Type to hpm upgrade buffer size --- xCAT-server/lib/xcat/plugins/ipmi.pm | 31 +++++++++++++++++----------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/ipmi.pm b/xCAT-server/lib/xcat/plugins/ipmi.pm index 77b65bebb..fb0a7fc16 100644 --- a/xCAT-server/lib/xcat/plugins/ipmi.pm +++ b/xCAT-server/lib/xcat/plugins/ipmi.pm @@ -524,10 +524,6 @@ sub on_bmc_connect { } elsif ($command eq "rspreset") { return resetbmc($sessdata); } elsif ($command eq "rbeacon") { - unless (defined $sessdata->{device_id}) { #need get device id data initted for SD350 workaround - $sessdata->{ipmisession}->subcmd(netfn => 6, command => 1, data => [], callback => \&gotdevid, callback_args => $sessdata); - return; - } return beacon($sessdata); } elsif ($command eq "rsetboot") { return setboot($sessdata); @@ -1732,9 +1728,22 @@ sub do_firmware_update { } xCAT::SvrUtils::sendmsg("rflash started, please wait.......", $callback, $sessdata->{node}, %allerrornodes); + + # check for 8335-GTB Model Type to adjust buffer size + my $buffer_size = "30000"; + my $cmd = $pre_cmd . " fru print 3"; + $output = xCAT::Utils->runcmd($cmd, -1); + if ($::RUNCMD_RC != 0) { + xCAT::SvrUtils::sendmsg([ 1, "Running ipmitool command $cmd failed: $output" ], + $callback, $sessdata->{node}, %allerrornodes); + return -1; + } + if ($output =~ /8335-GTB/) { + $buffer_size = "15000"; + } # step 1 power off - my $cmd = $pre_cmd . " chassis power off"; + $cmd = $pre_cmd . " chassis power off"; $output = xCAT::Utils->runcmd($cmd, -1); if ($::RUNCMD_RC != 0) { xCAT::SvrUtils::sendmsg([ 1, "Running ipmitool command $cmd failed: $output" ], @@ -1751,14 +1760,14 @@ sub do_firmware_update { return -1; } - #check reset status + # check reset status unless (check_bmc_status_with_ipmitool($pre_cmd, 5, 24)) { xCAT::SvrUtils::sendmsg([ 1, "Timeout to check the bmc status" ], $callback, $sessdata->{node}, %allerrornodes); return -1; } - #step 3 protect network + # step 3 protect network $cmd = $pre_cmd . " raw 0x32 0xba 0x18 0x00"; $output = xCAT::Utils->runcmd($cmd, -1); if ($::RUNCMD_RC != 0) { @@ -1768,9 +1777,9 @@ sub do_firmware_update { } # step 4 upgrade firmware - $cmd = $pre_cmd . " -z 30000 hpm upgrade $hpm_file force"; + $cmd = $pre_cmd . " -z " . $buffer_size . " hpm upgrade $hpm_file force"; $output = xCAT::Utils->runcmd($cmd, -1); - + if ($::RUNCMD_RC != 0) { xCAT::SvrUtils::sendmsg([ 1, "Running ipmitool command $cmd failed." ], $callback, $sessdata->{node}, %allerrornodes); @@ -2358,9 +2367,7 @@ sub beacon { #if stuck with 1.5, say light for 255 seconds. In 2.0, specify to turn it on forever if ($subcommand eq "on") { - if ($sessdata->{mfg_id} == 19046 and $sessdata->{prod_id} == 13616) { # Lenovo SD350 - $sessdata->{ipmisession}->subcmd(netfn => 0x3a, command => 6, data => [ 1, 1 ], callback => \&beacon_answer, callback_args => $sessdata); - } elsif ($ipmiv2) { + if ($ipmiv2) { $sessdata->{ipmisession}->subcmd(netfn => 0, command => 4, data => [ 0, 1 ], callback => \&beacon_answer, callback_args => $sessdata); } else { $sessdata->{ipmisession}->subcmd(netfn => 0, command => 4, data => [0xff], callback => \&beacon_answer, callback_args => $sessdata); From 91e29ba7f52e3e3bf013eb7cd3aa2a4e9a953f14 Mon Sep 17 00:00:00 2001 From: hu-weihua Date: Mon, 15 Aug 2016 23:03:54 -0400 Subject: [PATCH 054/106] Fix issue, xcat-core builed failed in ubuntu due to xcat probe code checking --- build-ubunturepo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-ubunturepo b/build-ubunturepo index 769b34b67..6eae01394 100755 --- a/build-ubunturepo +++ b/build-ubunturepo @@ -233,7 +233,7 @@ then #3 symbolic link can't work during package if [ $file_low = "xcat-probe" ]; then CURDIR=$(pwd) - mkdir -p ${CURDIR}/xCAT-probe/lib/perl/xCAT/ + mkdir -p ${CURDIR}/lib/perl/xCAT/ cp -f ${CURDIR}/../perl-xCAT/xCAT/NetworkUtils.pm ${CURDIR}/lib/perl/xCAT/ cp -f ${CURDIR}/../perl-xCAT/xCAT/GlobalDef.pm ${CURDIR}/lib/perl/xCAT/ cp -f ${CURDIR}/../perl-xCAT/xCAT/ServiceNodeUtils.pm ${CURDIR}/lib/perl/xCAT/ From 433cd390687786120524ab1b39a6aeef19643e03 Mon Sep 17 00:00:00 2001 From: ertaozh Date: Tue, 16 Aug 2016 02:32:54 -0400 Subject: [PATCH 055/106] modify doc to add arch keyword for ubuntu online repo --- .../guides/install-guides/apt/configure_xcat.rst | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/source/guides/install-guides/apt/configure_xcat.rst b/docs/source/guides/install-guides/apt/configure_xcat.rst index 435b57ba9..887ef327f 100644 --- a/docs/source/guides/install-guides/apt/configure_xcat.rst +++ b/docs/source/guides/install-guides/apt/configure_xcat.rst @@ -12,14 +12,20 @@ From the xCAT download page, find the build you want to install and add to ``/et To configure the xCAT development build, add the following line to ``/etc/apt/sources.list``: :: - deb http://xcat.org/files/xcat/repos/apt/devel/core-snap trusty main + [For x86_64 servers] + deb [arch=amd64] http://xcat.org/files/xcat/repos/apt/devel/core-snap trusty main + [For ppc64el servers] + deb [arch=ppc64el] http://xcat.org/files/xcat/repos/apt/devel/core-snap trusty main **[xcat-dep]** To configure the xCAT deps online repository, add the following line to ``/etc/apt/sources.list``: :: - deb http://xcat.org/files/xcat/repos/apt/xcat-dep trusty main + [For x86_64 servers] + deb [arch=amd64] http://xcat.org/files/xcat/repos/apt/xcat-dep trusty main + [For ppc64el servers] + deb [arch=ppc64el] http://xcat.org/files/xcat/repos/apt/xcat-dep trusty main If using internet repositories, continue to the next step to install xCAT. From 47b37f57897a600051cc50e8a823dd9851684277 Mon Sep 17 00:00:00 2001 From: hu-weihua Date: Tue, 16 Aug 2016 04:59:26 -0400 Subject: [PATCH 056/106] add dependency to support rhels7.2+IB --- xCAT-server/share/xcat/ib/netboot/rh/ib.rhels7.ppc64le.pkglist | 1 + 1 file changed, 1 insertion(+) diff --git a/xCAT-server/share/xcat/ib/netboot/rh/ib.rhels7.ppc64le.pkglist b/xCAT-server/share/xcat/ib/netboot/rh/ib.rhels7.ppc64le.pkglist index 90723aa51..f951d4ac9 100644 --- a/xCAT-server/share/xcat/ib/netboot/rh/ib.rhels7.ppc64le.pkglist +++ b/xCAT-server/share/xcat/ib/netboot/rh/ib.rhels7.ppc64le.pkglist @@ -17,3 +17,4 @@ cairo gcc createrepo libnl +ethtool From 91bd846c451dd2a31b4f7cb990c11fa0667a58aa Mon Sep 17 00:00:00 2001 From: hu-weihua Date: Tue, 16 Aug 2016 05:32:23 -0400 Subject: [PATCH 057/106] Fix bug 1017 --- xCAT-probe/subcmds/osdeploy | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/xCAT-probe/subcmds/osdeploy b/xCAT-probe/subcmds/osdeploy index 5d3a8e025..23effab68 100755 --- a/xCAT-probe/subcmds/osdeploy +++ b/xCAT-probe/subcmds/osdeploy @@ -570,6 +570,11 @@ sub dump_history { print "\t$line\n"; } } + my $statelist = ""; + for (my $i = 0 ; $i < scalar(@{ $rawdata{$node}{statehistory} }) ; $i++) { + $statelist .= "$state_set_reverse{$rawdata{$node}{statehistory}[$i]} "; + } + probe_utils->send_msg("$output", "d", "[$node] state history: $statelist"); } my @tmpnodestatehistory = @{ $rawdata{$node}{statehistory} }; @@ -817,7 +822,6 @@ sub get_valid_logs { my $year = shift; my $epoch_seconds_of_now = shift; my $bthistory_ref = shift; - my $nics = "eth0"; my @orglogfilelist = ("/var/log/xcat/cluster.log", "/var/log/messages", "/var/log/xcat/computes.log"); @@ -851,7 +855,7 @@ sub get_valid_logs { my $fd; my $filetype = `file $file 2>&1`; chomp($filetype); - if ($filetype =~ /ASCII text/) { + if ($filetype =~ /ASCII/) { if (!open($fd, "$file")) { print "open $files failed\n"; next; @@ -926,7 +930,7 @@ sub get_valid_logs { $timestampepoch = probe_utils->convert_to_epoch_seconds($timestamp, $year, $epoch_seconds_of_now); } - if (($splitline[4] =~ /dhcpd:/i && $_ =~ /$nics/) + if (($splitline[4] =~ /dhcpd:/i && $_ =~ /$installnic/) || ($splitline[4] =~ /in.tftpd/i) || (($splitline[4] =~ /^xcat/i) || ($splitline[5] =~ /^xcat/i)) || ($splitline[5] =~ /GET/ && $splitline[7] =~ /HTTP/)) { @@ -965,7 +969,7 @@ sub do_replay { foreach my $line (@bthistory) { $line =~ s/(\d+) (.+)/$2/g; my @tmp = split(/\s+/, $line); - if ($tmp[4] =~ /dhcpd:/i && $line =~ /$nics/) { + if ($tmp[4] =~ /dhcpd:/i && $line =~ /$installnic/) { handle_dhcp_msg("$line"); } elsif ($tmp[4] =~ /in.tftpd/i) { handle_tftp_msg("$line"); From 484cf08bfde7377ca46b83dd6f68288ec0d5bad0 Mon Sep 17 00:00:00 2001 From: Patrick Lundgren Date: Tue, 16 Aug 2016 09:49:46 -0400 Subject: [PATCH 058/106] Removed unintended changes that were result of scp from dev machine --- xCAT-server/lib/xcat/plugins/ipmi.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/ipmi.pm b/xCAT-server/lib/xcat/plugins/ipmi.pm index fb0a7fc16..f9a1a3434 100644 --- a/xCAT-server/lib/xcat/plugins/ipmi.pm +++ b/xCAT-server/lib/xcat/plugins/ipmi.pm @@ -524,6 +524,10 @@ sub on_bmc_connect { } elsif ($command eq "rspreset") { return resetbmc($sessdata); } elsif ($command eq "rbeacon") { + unless (defined $sessdata->{device_id}) { #need get device id data initted for SD350 workaround + $sessdata->{ipmisession}->subcmd(netfn => 6, command => 1, data => [], callback => \&gotdevid, callback_args => $sessdata); + return; + } return beacon($sessdata); } elsif ($command eq "rsetboot") { return setboot($sessdata); @@ -2367,7 +2371,9 @@ sub beacon { #if stuck with 1.5, say light for 255 seconds. In 2.0, specify to turn it on forever if ($subcommand eq "on") { - if ($ipmiv2) { + if ($sessdata->{mfg_id} == 19046 and $sessdata->{prod_id} == 13616) { # Lenovo SD350 + $sessdata->{ipmisession}->subcmd(netfn => 0x3a, command => 6, data => [ 1, 1 ], callback => \&beacon_answer, callback_args => $sessdata); + } elsif ($ipmiv2) { $sessdata->{ipmisession}->subcmd(netfn => 0, command => 4, data => [ 0, 1 ], callback => \&beacon_answer, callback_args => $sessdata); } else { $sessdata->{ipmisession}->subcmd(netfn => 0, command => 4, data => [0xff], callback => \&beacon_answer, callback_args => $sessdata); From fc1f1c575d556f14ffb54536b7ea073db122c302 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Tue, 16 Aug 2016 13:07:29 -0400 Subject: [PATCH 059/106] xcat-probe grammar and spelling fixes --- xCAT-probe/subcmds/detect_dhcpd | 28 +++++++------- xCAT-probe/subcmds/discovery | 64 ++++++++++++++++---------------- xCAT-probe/subcmds/osdeploy | 45 +++++++++++----------- xCAT-probe/subcmds/switch-macmap | 12 +++--- xCAT-probe/subcmds/xcatmn | 60 +++++++++++++++--------------- xCAT-probe/xcatprobe | 4 +- 6 files changed, 106 insertions(+), 107 deletions(-) diff --git a/xCAT-probe/subcmds/detect_dhcpd b/xCAT-probe/subcmds/detect_dhcpd index f1a2947b8..b8430761e 100755 --- a/xCAT-probe/subcmds/detect_dhcpd +++ b/xCAT-probe/subcmds/detect_dhcpd @@ -26,10 +26,10 @@ Description: This command can be used to detect the dhcp server in a network for a specific mac address. Options: - -i interface: Required. The interface which facing the target network. - -m macaddress: The mac that will be used to detect dhcp server. Recommend to use the real mac of the node that will be netboot. If no specified, the mac of interface which specified by -i will be used. + -i interface: Required. The interface facing the target network. + -m macaddress: The mac that will be used to detect dhcp server. Use the real mac of the node that will be netboot. If not specified, the mac specified by -i will be used. -d duration: The time to wait to detect the dhcp messages. The default value is 10s. - -V verbose: To print additional debug information. + -V verbose: Print additional debug information. "; #--------------------------- @@ -59,7 +59,7 @@ if ($::HELP) { } if ($::TEST) { - probe_utils->send_msg("$output", "o", "$program_name can be used to detect the dhcp server in a network for a specific mac address. Before using this command, please install tcpdump command ahead. The operating system supported are redhat, sles, ubuntu and debian."); + probe_utils->send_msg("$output", "o", "$program_name can be used to detect the dhcp server in a network for a specific mac address. Before using this command, install 'tcpdump' command. The operating system supported are RedHat, SLES, Ubuntu and Debian."); exit 0; } @@ -72,12 +72,12 @@ unless (-x "/usr/sbin/tcpdump") { if ($::IF) { $nic = $::IF; } else { - probe_utils->send_msg("$output", "f", "Option '-i' needs to be assigned value for $program_name"); + probe_utils->send_msg("$output", "f", "Option '-i' needs to be assigned a value for $program_name"); probe_utils->send_msg("$output", "d", "$::USAGE"); exit 1; } -my $msg = "Find right IP/MAC to do dhcp discover"; +my $msg = "Find correct IP/MAC to do dhcp discover"; my $IP = `ip addr show dev $nic | awk -F" " '/inet / {print \$2}' | head -n 1 |awk -F"/" '{print \$1}'`; chomp($IP); my $MAC; @@ -88,7 +88,7 @@ if ($::MACADD) { } chomp($MAC); -probe_utils->send_msg("$output", "d", "Send out dhcp discover from: NIC = $nic, IP = $IP, MAC = $MAC") if ($::VERBOSE); +probe_utils->send_msg("$output", "d", "Send dhcp discover from: NIC = $nic, IP = $IP, MAC = $MAC") if ($::VERBOSE); if (!$IP || !$MAC) { probe_utils->send_msg("$output", "f", $msg); @@ -108,7 +108,7 @@ if (-f "/etc/redhat-release") { $os = "debian"; } else { probe_utils->send_msg("$output", "f", $msg); - probe_utils->send_msg("$output", "d", "Only support the redhat, sles, ubuntu and debian OS"); + probe_utils->send_msg("$output", "d", "Only support the RedHat, SLES, Ubuntu and Debian OS"); exit 1; } probe_utils->send_msg("$output", "d", "Current operating system is $os") if ($::VERBOSE); @@ -118,7 +118,7 @@ if ($::DURATION) { $duration = $::DURATION; } -probe_utils->send_msg("$output", "d", "The duration of capturing DHCP package is $duration second") if ($::VERBOSE); +probe_utils->send_msg("$output", "d", "The duration of capturing DHCP package is $duration second(s)") if ($::VERBOSE); # send out the package $msg = "Build the socket to send out DHCP request"; @@ -204,7 +204,7 @@ while () { if ($line =~ /^\d\d:\d\d:\d\d/) { # A new packet was captured. Parse the last one. - probe_utils->send_msg("$output", "d", "The server I found: mac = $chaddr, clientip = $ciaddr, serverip = $siaddr, offer = $offer") if ($::VERBOSE); + probe_utils->send_msg("$output", "d", "The server found: mac = $chaddr, clientip = $ciaddr, serverip = $siaddr, offer = $offer") if ($::VERBOSE); if ($os eq "sles") { $offer = 1; } if ($chaddr =~ /$MAC/i && $offer && $ciaddr && $siaddr && $rsiaddr) { $output{$rsiaddr}{'client'} = $ciaddr; @@ -245,15 +245,15 @@ close(FILE); my $sn = scalar(keys %output); probe_utils->send_msg("$output", "i", "++++++++++++++++++++++++++++++++++"); -probe_utils->send_msg("$output", "i", "There are $sn servers reply the dhcp discover."); +probe_utils->send_msg("$output", "i", "There are $sn servers replied to dhcp discover."); foreach my $server (keys %output) { - probe_utils->send_msg("$output", "i", " Server:$server assign IP [$output{$server}{'client'}] to you. The next server is [$output{$server}{'nextsv'}]!"); + probe_utils->send_msg("$output", "i", " Server:$server assign IP [$output{$server}{'client'}]. The next server is [$output{$server}{'nextsv'}]!"); } probe_utils->send_msg("$output", "i", "++++++++++++++++++++++++++++++++++"); if (scalar(@snack)) { probe_utils->send_msg("$output", "i", "==================================="); - probe_utils->send_msg("$output", "i", "The dhcp servers which sending out NACK in present network:"); + probe_utils->send_msg("$output", "i", "The dhcp servers sending out NACK in present network:"); foreach my $nack (@snack) { probe_utils->send_msg("$output", "i", " $nack"); } @@ -379,5 +379,5 @@ sub kill_child { foreach my $cpid (@pidoftcpdump) { kill 15, $cpid; } - probe_utils->send_msg("$output", "d", "Kill process $pid which is used to capture the packet by tcpdump") if ($::VERBOSE); + probe_utils->send_msg("$output", "d", "Kill process $pid used to capture the packet by 'tcpdump'") if ($::VERBOSE); } diff --git a/xCAT-probe/subcmds/discovery b/xCAT-probe/subcmds/discovery index bfcec74f4..efdae9901 100755 --- a/xCAT-probe/subcmds/discovery +++ b/xCAT-probe/subcmds/discovery @@ -35,16 +35,16 @@ $::USAGE = "Usage: $program_name [-V] [-m -n ] [--noprecheck] Description: - Do probe for discovery process, including pre-check for required configuration and realtime monitor of discovery process. - If all pre-check items pass, $program_name will go to monitor directly, otherwise $program_name exit for error. - In order to do realtime monitor, $program_name probe program must be run along with the node discovery procedure. Plese trigger this command before trigger node discovery procedure. + Probe the discovery process, including pre-check for required configuration and realtime monitor of discovery process. + If all pre-check items pass, $program_name will go to monitor directly, otherwise $program_name will exit. + In order to do realtime monitor, $program_name probe must be run along with the node discovery procedure. Trigger this command before triggering node discovery procedure. Currently, this command does not support hierarchy. Options: -h : Get usage information of $program_name. -V : Output more information for debug. -m : The method of discovery, the valid values are $valid_discovery_type_str. - -n : The range of predefined node, must used with option -m. + -n : The range of predefined nodes, must be used with option -m. --noprecheck : skip pre-checking discovery to validate correct configuration. "; @@ -64,12 +64,12 @@ Options: sub check_genesis_file { my $arch = shift; if (($arch ne "ppc64") and ($arch ne "x86_64")) { - probe_utils->send_msg("$output", "d", "Please input correct arch type") if ($verbose); + probe_utils->send_msg("$output", "d", "Specify correct arch type") if ($verbose); return 1; } my $rst_f = 0; - probe_utils->send_msg("$output", "d", "Start to check genesis files for $arch...") if ($verbose); + probe_utils->send_msg("$output", "d", "Starting to check genesis files for $arch...") if ($verbose); my $os = probe_utils->get_os(); my $genesis_base; @@ -92,11 +92,11 @@ sub check_genesis_file { $genesis_scripts = `rpm -qa | grep -i "xcat-genesis-scripts" | grep -i "$arch"`; } unless ($genesis_base and $genesis_scripts) { - probe_utils->send_msg("$output", "d", "xCAT-genesis for $arch did not be installed.") if ($verbose); + probe_utils->send_msg("$output", "d", "xCAT-genesis for $arch is not installed.") if ($verbose); return 1; } - probe_utils->send_msg("$output", "d", "xCAT-genesis for $arch installed, start to check files...") if ($verbose); + probe_utils->send_msg("$output", "d", "xCAT-genesis for $arch is installed, starting to check files...") if ($verbose); my $tftpdir = `tabdump site | awk -F',' '/^"tftpdir",/ { gsub(/"/, "", \$2) ; print \$2 }'`; chomp($tftpdir); @@ -109,7 +109,7 @@ sub check_genesis_file { if ($arch eq "ppc64") { $genesis_folder = "$tftpdir/pxelinux.cfg/p"; unless (-d "$genesis_folder") { - probe_utils->send_msg("$output", "d", "There is no genesis file for $arch. Please run 'mknb ppc64' if you use ppc64/ppc64le machine.") if ($verbose); + probe_utils->send_msg("$output", "d", "There is no genesis file for $arch. Run 'mknb ppc64' if using ppc64/ppc64le machine.") if ($verbose); return 1; } @@ -131,7 +131,7 @@ sub check_genesis_file { $initrd_path = $initrd_info[1]; $wget_rst = system("wget -q --spider $initrd_path -T 0.5 -t 3"); if ($wget_rst) { - probe_utils->send_msg("$output", "d", "initrd cannot be downloaded from $initrd_path.") if ($verbose); + probe_utils->send_msg("$output", "d", "'initrd' cannot be downloaded from $initrd_path.") if ($verbose); $rst_f = 1; } else { probe_utils->send_msg("$output", "d", "Check initrd file: $initrd_path PASS.") if ($verbose); @@ -154,7 +154,7 @@ sub check_genesis_file { } else { $genesis_folder = "$tftpdir/xcat/xnba/nets"; unless (-d "$genesis_folder") { - probe_utils->send_msg("$output", "d", "There is no genesis file for $arch. Please run 'mknb x86_64' if you use x86_64 machine.") if ($verbose); + probe_utils->send_msg("$output", "d", "There is no genesis file for $arch. Run 'mknb x86_64' if using x86_64 machine.") if ($verbose); return 1; } @@ -185,13 +185,13 @@ sub check_genesis_file { } unless ($host_ip) { - probe_utils->send_msg("$output", "d", "There is no ip for range $ip_range") if ($verbose); + probe_utils->send_msg("$output", "d", "There is no IP for range $ip_range") if ($verbose); $rst_f = 1; next; } unless (open(FILE, $_)) { - probe_utils->send_msg("$output", "d", "Can not open file $_."); + probe_utils->send_msg("$output", "d", "Cannot open file $_."); $rst_f = 1; next; } @@ -222,7 +222,7 @@ sub check_genesis_file { } else { probe_utils->send_msg("$output", "d", "Check elilo file: $elilo_http PASS.") if ($verbose); unless (open(FILE_ELILO, $elilo_path)) { - probe_utils->send_msg("$output", "d", "Can not open file $_.") if ($verbose); + probe_utils->send_msg("$output", "d", "Cannot open file $_.") if ($verbose); $rst_f = 1; next; } @@ -250,7 +250,7 @@ sub check_genesis_file { $wget_rst = system("wget -q --spider $initrd_http -T 0.5 -t 3"); if ($wget_rst) { - probe_utils->send_msg("$output", "d", "initrd cannot be downloaded from $initrd_http.") if ($verbose); + probe_utils->send_msg("$output", "d", "'initrd' cannot be downloaded from $initrd_http.") if ($verbose); $rst_f = 1; } else { probe_utils->send_msg("$output", "d", "Check initrd file: $initrd_http PASS.") if ($verbose); @@ -286,7 +286,7 @@ sub get_node_ip { foreach my $node (keys %nodeip) { $ip_net = xCAT::NetworkUtils->getipaddr($node); if ($nodeip{$node} and ($nodeip{$node} ne $ip_net)) { - probe_utils->send_msg("$output", "d", "IP $nodeip{$node} of definition for $node is not correct") if ($verbose); + probe_utils->send_msg("$output", "d", "IP $nodeip{$node} definition for $node is not correct") if ($verbose); } $nodeip{$node} = $ip_net; } @@ -424,7 +424,7 @@ sub dhcp_dynamic_range_check { } } } else { - probe_utils->send_msg("$output", "d", "Dynamic range for net $net did not be configured.") if ($verbose); + probe_utils->send_msg("$output", "d", "Dynamic range for net $net is not configured.") if ($verbose); $rst = 1; next; } @@ -631,7 +631,7 @@ sub handle_compute_msg { my $node = `lsdef -i mac -c 2>&1 | awk -F: '/$ipmacmap{$ip}/ {print \$1}'`; chomp($node); $monitor_nodes{$node} = 1 if (defined($monitor_nodes{$node})); - probe_utils->send_msg("$output", "o", "Node $node has finished it's discovery process"); + probe_utils->send_msg("$output", "o", "Node $node has finished its discovery process"); my $output = `lsdef $node 2>&1`; print "-------------------\n$output-------------------\n"; } @@ -757,7 +757,7 @@ sub check_pre_defined_node { if (!exists($nodecheckrst{$node}{error})) { if ($discovery_type eq "mtms") { if (!(exists($nodecheckrst{$node}{"mtm"}) && exists($nodecheckrst{$node}{"serial"}))) { - $nodecheckrst{$node}{"error"} = "node definition is wrong for '$discovery_type' type discovery"; + $nodecheckrst{$node}{"error"} = "Node definition is wrong for '$discovery_type' type discovery"; $rst = 1; } } elsif ($discovery_type eq "switch") { @@ -770,23 +770,23 @@ sub check_pre_defined_node { my $tmpoutput = `lsdef $nodecheckrst{$node}{"switch"} 2>&1`; if ($?) { - $nodecheckrst{$node}{"error"} = "Miss definition for related switch $nodeswitch"; + $nodecheckrst{$node}{"error"} = "Missing definition for related switch $nodeswitch"; $rst = 1; last; } if ($tmpoutput !~ /snmpversion=/) { - $nodecheckrst{$node}{"error"} = "Miss attribute 'snmpversion' definition for related switch $nodeswitch"; + $nodecheckrst{$node}{"error"} = "Missing attribute 'snmpversion' definition for related switch $nodeswitch"; $rst = 1; last; } if ($tmpoutput !~ /username=/) { - $nodecheckrst{$node}{"error"} = "Miss attribute 'username' definition for related switch $nodeswitch"; + $nodecheckrst{$node}{"error"} = "Missing attribute 'username' definition for related switch $nodeswitch"; $rst = 1; last; } if ($tmpoutput !~ /password=/) { - $nodecheckrst{$node}{"error"} = "Miss attribute 'password' definition for related switch $nodeswitch"; + $nodecheckrst{$node}{"error"} = "Missing attribute 'password' definition for related switch $nodeswitch"; $rst = 1; last; } @@ -852,7 +852,7 @@ sub do_pre_check { exit 1; } - $msg = "The input network interfaces $nics exist and are configured well on current server"; + $msg = "The input network interfaces $nics exist and are configured correctly on current server"; my $miss = 0; my @nic_array = split(",", $nics); foreach my $nic (@nic_array) { @@ -884,13 +884,13 @@ sub do_pre_check { my $masteripinsite = `tabdump site | awk -F',' '/^"master",/ { gsub(/"/, "", \$2) ; print \$2 }'`; chomp($masteripinsite); if ($masteripinsite eq "") { - probe_utils->send_msg("$output", "d", "There isn't 'master' definition in 'site' talbe") if ($verbose); + probe_utils->send_msg("$output", "d", "There isn't 'master' definition in 'site' table") if ($verbose); probe_utils->send_msg("$output", "f", $msg); exit 1; } if (!xCAT::NetworkUtils->isIpaddr("$masteripinsite")) { - probe_utils->send_msg("$output", "d", "The value of 'master' in 'site' table isn't a IP address") if ($verbose); + probe_utils->send_msg("$output", "d", "The value of 'master' in 'site' table isn't an IP address") if ($verbose); probe_utils->send_msg("$output", "f", $msg); exit 1; } @@ -921,7 +921,7 @@ sub do_pre_check { probe_utils->send_msg("$output", "o", $msg); if (check_genesis_file("x86_64")) { probe_utils->send_msg("$output", "w", "Genesis files for x86 are not available"); - probe_utils->send_msg("$output", "i", "If don't plan to manage a x86 server, please ignore above warning"); + probe_utils->send_msg("$output", "i", "Ignore above warning if not planning on managing x86 server"); } else { probe_utils->send_msg("$output", "o", "Genesis files for x86 are available"); } @@ -934,7 +934,7 @@ sub do_pre_check { probe_utils->send_msg("$output", "o", $msg); if (check_genesis_file("ppc64")) { probe_utils->send_msg("$output", "w", "Genesis files for ppc64/ppc64le are not available"); - probe_utils->send_msg("$output", "i", "If don't plan to manage a ppc64/ppc64le server, please ignore above warning"); + probe_utils->send_msg("$output", "i", "ignore above warning if not planning on managing ppc64/ppc64le server"); } else { probe_utils->send_msg("$output", "o", "Genesis files for ppc64/ppc64le are available"); } @@ -978,7 +978,7 @@ sub do_monitor { $nics = `ip addr |grep -B2 $masteripinsite|awk -F" " '/mtu/{gsub(/:/,"",\$2); print \$2}'`; chomp($nics); if (!$nics) { - probe_utils->send_msg("$output", "f", "The value of master in site table is $masteripinsite, can't get corresponding network interface"); + probe_utils->send_msg("$output", "f", "The value of 'master' in 'site' table is $masteripinsite, can't get corresponding network interface"); return 1; } } @@ -993,7 +993,7 @@ sub do_monitor { /_/\\_\\\\____/_/ \\_\\_| .+|______|__.-||__)`-'(((/ (((/ ------------------------------------------------------------- "; - print "$startline\nStart to capture every message during discovery process......\n"; + print "$startline\nStart capturing every message during discovery process......\n"; my $varlogmsg = "/var/log/messages"; my $clusterlog = "/var/log/xcat/cluster.log"; @@ -1088,7 +1088,7 @@ sub do_monitor { if ($terminal) { probe_utils->send_msg("$output", "d", "Got from STDIN"); } else { - probe_utils->send_msg("$output", "o", "All nodes need to monitor have finished discovery process"); + probe_utils->send_msg("$output", "o", "All nodes specified to monitor have finished discovery process"); } last; } @@ -1136,7 +1136,7 @@ if ($help) { } if ($test) { - probe_utils->send_msg("$output", "o", "Do probe for discovery process, including pre-check for required configuration and realtime monitor of discovery process.Before using this command, please install nslookup command ahead. Currently, this command does not support hierarchy."); + probe_utils->send_msg("$output", "o", "Probe the discovery process, including pre-check for required configuration and realtime monitor of discovery process. Before using this command, please install 'nslookup' command. Currently, this command does not support hierarchy."); exit 0; } diff --git a/xCAT-probe/subcmds/osdeploy b/xCAT-probe/subcmds/osdeploy index 23effab68..049d125af 100755 --- a/xCAT-probe/subcmds/osdeploy +++ b/xCAT-probe/subcmds/osdeploy @@ -148,19 +148,18 @@ $::USAGE = "Usage: $program_name -n -r [-V] Description: - Do probe for os provision process. Realtime monitor or replay history of os provision process. - If do realtime monitor, please run this before rpower node. - Unsupport hierarchial structure now. + Probe for OS provision process. Realtime monitor or replay history of OS provision process. + If realtime monitor, run this before 'rpower' node. + Currently, hierarchial structure is not supported. Options: -h : Get usage information of $program_name - -T : To verify if $program_name can work, reserve option for probe framework + -T : Verify if $program_name can work, reserved option for probe framework -V : Output more information for debug - -n : The range of node to be monitor or replay log. - -t : The maximum time to wait when doing monitor, the unit is minute, default is 60 minutes. - -r : Replay history log to probe provision. need input a start time when probe should begin from. - Support time format are xxhxxm, xxh, or xxm. h means hour, m means minute. - If there isn't unit input, using hour by default. + -n : The range of nodes for monitor or replay log. + -t : The maximum time in minutes to wait when doing monitor, default is 60. + -r : Replay history log for probe provisioniong. Input a start time when probe should begin. + Supported time formats are xxhxxm, xxh, or xxm. If units not specified, hour will be used by default. "; #------------------------------------------ @@ -231,7 +230,7 @@ sub check_noderange { }else{ $noerror = 0; $rst = 1; - probe_utils->send_msg("$output", "f", "$node : can't be resolved to a IP address"); + probe_utils->send_msg("$output", "f", "$node : can't be resolved to an IP address"); } } } @@ -313,7 +312,7 @@ sub handle_dhcp_msg { push(@{ $rawdata{$node}{statehistory} }, $rawdata{$node}{state}) if (reset_state(\$rawdata{$node}{state}, "dhcp")); if ($macmap{$mac}{"ip"} != "NOIP" and $macmap{$mac}{"ip"} != $ip) { - my $warn_msg = "The ip($ip) assigned to $mac via DHCP is different with the ip($macmap{$mac}{'ip'}) in node definition."; + my $warn_msg = "The ip($ip) assigned to $mac via DHCP is different from the ip($macmap{$mac}{'ip'}) in node definition."; probe_utils->send_msg("$output", "w", "$warn_msg") if ($monitor); push(@{ $rawdata{$node}{"history"} }, $warn_msg); } @@ -341,7 +340,7 @@ sub handle_dhcp_msg { push(@{ $rawdata{$node}{statehistory} }, $rawdata{$node}{state}) if (reset_state(\$rawdata{$node}{state}, "dhcp")); if ($macmap{$mac}{"ip"} != "NOIP" and $macmap{$mac}{"ip"} != $ip) { - my $warn_msg = "The ip($ip) assigned to $mac via DHCP is different with the ip($macmap{$mac}{'ip'}) in node definition."; + my $warn_msg = "The ip($ip) assigned to $mac via DHCP is different from the ip($macmap{$mac}{'ip'}) in node definition."; probe_utils->send_msg("$output", "w", "$warn_msg") if ($monitor); push(@{ $rawdata{$node}{"history"} }, $warn_msg); } @@ -655,7 +654,7 @@ sub dump_history { } elsif (($valid_process{ $match_result{$max_match}[0] }{type} eq "reboot") && ($valid_process{ $match_result{$max_match}[0] }{process}[ $max_match - 1 ] == $state_set{done})) { probe_utils->send_msg("$output", "f", "[$node] reboot completed, without deployment process"); } elsif (($valid_process{ $match_result{$max_match}[0] }{type} eq "reboot") && ($valid_process{ $match_result{$max_match}[0] }{process}[ $max_match - 1 ] != $state_set{done})) { - probe_utils->send_msg("$output", "f", "[$node] reboot failed,without deployment process, stop at $state_set_reverse{$valid_process{$match_result{$max_match}[0]}{process}[$max_match-1]} stage, something wrong during $state_set_reverse{$valid_process{$match_result{$max_match}[0]}{process}[$max_match]} stage"); + probe_utils->send_msg("$output", "f", "[$node] reboot failed, without deployment process, stop at $state_set_reverse{$valid_process{$match_result{$max_match}[0]}{process}[$max_match-1]} stage, something wrong during $state_set_reverse{$valid_process{$match_result{$max_match}[0]}{process}[$max_match]} stage"); } } } @@ -680,7 +679,7 @@ sub do_monitor { my $rst = 0; my $startline = "------------------------------------------------------------- -Start to capture every message during os provision process...... +Start capturing every message during OS provision process...... ------------------------------------------------------------- "; @@ -717,7 +716,7 @@ Start to capture every message during os provision process...... if (!-e "$clusterlog") { probe_utils->send_msg("$output", "w", "$clusterlog doesn't exist"); - probe_utils->send_msg("$output", "i", "If sles11 or xCAT2.11.x is using, please ignore above warning"); + probe_utils->send_msg("$output", "i", "If using SLES11 or xCAT2.11.x, ignore above warning"); } else { if (!($clusterpid = open(CLUSTERLOGFILE, "tail -f -n 0 $clusterlog 2>&1 |"))) { probe_utils->send_msg("$output", "f", "Can't open $clusterlog to get logs"); @@ -736,7 +735,7 @@ Start to capture every message during os provision process...... } if (!-e "$computelog") { probe_utils->send_msg("$output", "w", "$computelog doesn't exist"); - probe_utils->send_msg("$output", "i", "If sles11 or xCAT2.11.x is using, please ignore above warning"); + probe_utils->send_msg("$output", "i", "If sles11 or xCAT2.11.x, ignore above warning"); } else { if (!($computerpid = open(COMPUTERFILE, "tail -f -n 0 $computelog 2>&1 |"))) { probe_utils->send_msg("$output", "f", "Can't open $computelog to get logs"); @@ -792,13 +791,13 @@ Start to capture every message during os provision process...... if ($terminal) { probe_utils->send_msg("$output", "d", "Get INT or TERM signal from STDIN"); } else { - probe_utils->send_msg("$output", "o", "All nodes need to monitor have finished os provision process"); + probe_utils->send_msg("$output", "o", "All nodes specified to monitor, have finished OS provision process"); } last; } if (time() - $starttime > ($maxwaittime * 60)) { - probe_utils->send_msg("$output", "i", "$maxwaittime minutes are expired, stop monitor"); + probe_utils->send_msg("$output", "i", "$maxwaittime minutes have expired, stop monitoring"); last; } sleep 0.01; @@ -959,7 +958,7 @@ sub do_replay { my $ref_timestamp = shift; my $timestr = scalar(localtime($ref_timestamp)); - print "Start to search logs after '$timestr', please waiting for a while.............\n"; + print "Start logs search after '$timestr', waiting for a while.............\n"; my ($sec, $min, $hour, $day, $mon, $year, $wday, $yday, $isdst) = localtime(time()); my $epoch_seconds_of_now = time(); @@ -1013,12 +1012,12 @@ if ($help) { } if ($test) { - probe_utils->send_msg("$output", "o", "Do probe for os provision process, realtime monitor of os provision process."); + probe_utils->send_msg("$output", "o", "Probe for OS provision process, realtime monitor of OS provision process."); exit 0; } unless ($noderange) { - probe_utils->send_msg("$output", "f", "A noderange is needed"); + probe_utils->send_msg("$output", "f", "A noderange is required"); probe_utils->send_msg("$output", "d", "$::USAGE"); exit 1; } @@ -1032,7 +1031,7 @@ if ($replaylog) { } elsif ($replaylog =~ /^(\d+)m$/) { $epoch_starttime -= $1 * 60; } else { - probe_utils->send_msg("$output", "f", "Unsupport time format for replay history log"); + probe_utils->send_msg("$output", "f", "Unsupported time format for history log replay"); print "$::USAGE"; exit 1; } @@ -1053,7 +1052,7 @@ unless ($installnic) { $installnic = `ip addr |grep -B2 $masteripinsite|awk -F" " '/mtu/{gsub(/:/,"",\$2); print \$2}'`; chomp($installnic); if (!$installnic) { - probe_utils->send_msg("$output", "f", "The value of master in site table is $masteripinsite, can't get corresponding network interface"); + probe_utils->send_msg("$output", "f", "The value of 'master' in 'site' table is $masteripinsite, can't get corresponding network interface"); $rst = 1; } else { probe_utils->send_msg("$output", "i", "The installation network interface is $installnic"); diff --git a/xCAT-probe/subcmds/switch-macmap b/xCAT-probe/subcmds/switch-macmap index ca567a26e..fbbb0cc6e 100755 --- a/xCAT-probe/subcmds/switch-macmap +++ b/xCAT-probe/subcmds/switch-macmap @@ -23,8 +23,8 @@ Description: Currently, this command does not support hierarchy. Options: - -c: To check whether the switch is OK to retrieve MAC address mapping. - -V: Output verbose information when accessing switch + -c: Check if the switch is OK to retrieve MAC address mapping. + -V: Output verbose information when accessing the switch "; my $help; @@ -36,13 +36,13 @@ if (!GetOptions("help|h" => \$help, "T" => \$test, "c" => \$check, "V" => \$verbose)) { - probe_utils->send_msg("$output", "f", "Option not support"); + probe_utils->send_msg("$output", "f", "Option not supported"); probe_utils->send_msg("$output", "d", $::USAGE); exit 1; } foreach (@ARGV) { if (/^-\w*/) { - probe_utils->send_msg("$output", "f", "Option $_ not support"); + probe_utils->send_msg("$output", "f", "Option $_ not supported"); exit 1; } else { push @nodes, $_; @@ -63,10 +63,10 @@ if (!-e "$currdir/bin/switchprobe") { if ($test) { `$currdir/bin/switchprobe -h`; if ($?) { - probe_utils->send_msg("$output", "f", "No switchprobe tool is available at $currdir/bin/"); + probe_utils->send_msg("$output", "f", "No 'switchprobe' tool is available at $currdir/bin/"); exit 1; } else { - probe_utils->send_msg("$output", "o", "To retrieve MAC address mapping for the specified switch, or all the switches defined in switches table in xCAT db. Currently, this command does not support hierarchy."); + probe_utils->send_msg("$output", "o", "To retrieve MAC address mapping for the specified switch, or all the switches defined in 'switches' table in xCAT db. Currently, this command does not support hierarchy."); exit 0; } } diff --git a/xCAT-probe/subcmds/xcatmn b/xCAT-probe/subcmds/xcatmn index 8a28b045e..6890bfc8f 100755 --- a/xCAT-probe/subcmds/xcatmn +++ b/xCAT-probe/subcmds/xcatmn @@ -35,8 +35,8 @@ my @tmpargv; # below are some options rules used by default # -h : Get usage information of current sub command # -V : Output more information for debug -# -T : To verify if $program_name can work, reserve option for probe framework, dosen't use by customer -# -n : In xCAT probe, -n is uesd to specify node range uniformly +# -T : To verify if $program_name can work, reserved option for probe framework, not for use by customer +# -n : In xCAT probe, -n is used to specify node range uniformly #-------------------------------- $::USAGE = "Usage: $program_name -h @@ -44,12 +44,12 @@ $::USAGE = "Usage: Description: After xcat installation, use this command to check if xcat has been installed correctly and is ready for use. - For hierarchical cluster, just support that the provision network is in the same network with management node. If in the different nework, please ignore the results. + For hierarchical cluster, only the provision network on the same network as the management node is supported. If in the different network, ignore the results. Options: -h : Get usage information of $program_name -V : Output more information for debug - -i : Required. Specify the network interface name of provision network on Management Node + -i : Required. Specify the network interface name of provision network on management node "; @@ -171,9 +171,9 @@ sub do_main_job { my $masteripinsite = `lsdef -t site -i master -c | awk -F'=' '{print \$2}'`; chomp($masteripinsite); probe_utils->send_msg($outputtarget, "d", "The value of 'master' in 'site' table is $masteripinsite") if ($verbose); - probe_utils->send_msg($outputtarget, "f", "There isn't 'master' definition in 'site' talbe") if ($masteripinsite eq ""); + probe_utils->send_msg($outputtarget, "f", "There isn't 'master' definition in 'site' table") if ($masteripinsite eq ""); - $msg = "The value of 'master' in 'site' table is a IP address"; + $msg = "The value of 'master' in 'site' table is an IP address"; if (probe_utils->is_ip_addr("$masteripinsite")) { probe_utils->send_msg($outputtarget, "o", "$msg"); } else { @@ -188,18 +188,18 @@ sub do_main_job { my $nics = `ip addr show $installnic >/dev/null 2>&1`; if ($?) { probe_utils->send_msg($outputtarget, "f", "$msg"); - probe_utils->send_msg($outputtarget, "d", "Please use 'ip addr show' to check if there is NIC named $installnic on current server"); + probe_utils->send_msg($outputtarget, "d", "Use 'ip addr show' to check if there is NIC named $installnic on current server"); return 1; } else { probe_utils->send_msg($outputtarget, "o", "$msg"); } - $msg = "Get ip address of NIC $installnic"; + $msg = "Get IP address of NIC $installnic"; $serverip = `ip addr show $installnic | awk -F" " '/inet / {print \$2}'|awk -F"/" '{print \$1}'`; chomp($serverip); if (!defined($serverip) || ($serverip eq "")) { probe_utils->send_msg($outputtarget, "f", "$msg"); - probe_utils->send_msg($outputtarget, "d", "Please use 'ip addr show' to check if there is ip assigned to $installnic"); + probe_utils->send_msg($outputtarget, "d", "Use 'ip addr show' to check if there is IP assigned to $installnic"); return 1; } else { probe_utils->send_msg($outputtarget, "d", "The IP of NIC $installnic is $serverip") if ($verbose); @@ -220,7 +220,7 @@ sub do_main_job { if (probe_utils->is_static_ip("$serverip", "$installnic")) { probe_utils->send_msg($outputtarget, "o", "$msg"); } else { - probe_utils->send_msg($outputtarget, "w", "IP $serverip of $installnic is not a static ip on current server"); + probe_utils->send_msg($outputtarget, "w", "IP $serverip of $installnic is not a static IP on current server"); } } else { @@ -236,7 +236,7 @@ sub do_main_job { } } - $msg = "Get ip address that in the same network with master $masteripinsite"; + $msg = "Get IP address that on the same network as master $masteripinsite"; if (!defined($serverip) || ($serverip eq "")) { probe_utils->send_msg($outputtarget, "f", "$msg"); return 1; @@ -280,13 +280,13 @@ sub do_main_job { $rst = 1; } - $msg = "There is configuration in 'passwd' table for 'system' for node provision"; + $msg = "There is a configuration in 'passwd' table for 'system' for node provisioning"; my $passwd = `tabdump passwd |awk -F',' '/system/ { gsub(/"/, "", \$2); gsub(/"/, "", \$3); print \$2,\$3 }'`; chomp($passwd); my ($username, $pw) = split(" ", $passwd); if ($username eq "" || $pw eq "") { probe_utils->send_msg($outputtarget, "f", "$msg"); - probe_utils->send_msg($outputtarget, "d", "Please define username and password for 'system' in 'passwd' table"); + probe_utils->send_msg($outputtarget, "d", "Define username and password for 'system' in 'passwd' table"); $rst = 1; } else { probe_utils->send_msg($outputtarget, "o", "$msg"); @@ -297,7 +297,7 @@ sub do_main_job { probe_utils->send_msg($outputtarget, "d", "The 'install' directory is set to $installdir in 'site' table on current server") if ($verbose); my $tftpdir = `lsdef -t site -i tftpdir -c | awk -F'=' '{print \$2}'`; chomp($tftpdir); - probe_utils->send_msg($outputtarget, "d", "The 'tftp' directory is set to $tftpdir in 'site' talbe on current server") if ($verbose); + probe_utils->send_msg($outputtarget, "d", "The 'tftp' directory is set to $tftpdir in 'site' table on current server") if ($verbose); $msg = "There is $installdir directory on current server"; if (-e "$installdir/postscripts/") { @@ -321,7 +321,7 @@ sub do_main_job { } } - $msg = "installdir $installdir is mounted on from the Management Node"; + $msg = "installdir $installdir is mounted from the management node"; if ($mountip eq $masteripinsite) { probe_utils->send_msg($outputtarget, "o", "$msg"); } @@ -353,7 +353,7 @@ sub do_main_job { } } - $msg = "tftpdir $tftpdir is mounted on from the Management Node"; + $msg = "tftpdir $tftpdir is mounted from the management node"; if ($mountip eq $masteripinsite) { probe_utils->send_msg($outputtarget, "o", "$msg"); } @@ -399,7 +399,7 @@ sub do_main_job { `which wget > /dev/null 2>&1`; if ($?) { - probe_utils->send_msg($outputtarget, "w", "'wget' tool isn't installed, skip checking HTTP service. please install wget then try again"); + probe_utils->send_msg($outputtarget, "w", "'wget' tool isn't installed, skip checking HTTP service. Install 'wget' then try again"); } else { $msg = "HTTP service is ready on $serverip"; if (probe_utils->is_http_ready("$serverip")) { @@ -426,7 +426,7 @@ sub do_main_job { if ($checktftp) { `which tftp > /dev/null 2>&1`; if ($?) { - probe_utils->send_msg($outputtarget, "w", "'tftp' tool isn't installed, skip checking tftp service. Please install tftp then try again"); + probe_utils->send_msg($outputtarget, "w", "'tftp' tool isn't installed, skip checking tftp service. Install 'tftp' then try again"); } else { $msg = "TFTP service is ready on $serverip"; if (probe_utils->is_tftp_ready("$serverip")) { @@ -452,7 +452,7 @@ sub do_main_job { if ($checkdns) { `which nslookup > /dev/null 2>&1`; if ($?) { - probe_utils->send_msg($outputtarget, "w", "'nslookup' tool isn't installed, skip checking DNS service. please install nslookup then try again"); + probe_utils->send_msg($outputtarget, "w", "'nslookup' tool isn't installed, skip checking DNS service. Install 'nslookup' then try again"); } else { $msg = "DNS server is ready on $serverip"; probe_utils->send_msg($outputtarget, "d", "Domain used to check DNS is $domain") if ($verbose); @@ -573,12 +573,12 @@ sub do_main_job { $tmpmac = $1; if ($tmpmac !~ $snmac) { returncmdoutput($tmp, $outputtarget) if ($verbose); - probe_utils->send_msg($outputtarget, "d", "DHCP server's reply is wrong") if ($verbose); + probe_utils->send_msg($outputtarget, "d", "DHCP server reply is wrong") if ($verbose); $rc = 1; } } else { returncmdoutput($tmp, $outputtarget) if ($verbose); - probe_utils->send_msg($outputtarget, "d", "DHCP server's reply is wrong") if ($verbose); + probe_utils->send_msg($outputtarget, "d", "DHCP server reply is wrong") if ($verbose); $rc = 1; } } else { @@ -586,7 +586,7 @@ sub do_main_job { my $tmp = `chdef xcatmntest groups=all ip=$serverip mac=aa:aa:aa:aa:aa:aa`; if ($?) { returncmdoutput($tmp, $outputtarget) if ($verbose); - probe_utils->send_msg($outputtarget, "d", "Simulate a node by chdef failed") if ($verbose); + probe_utils->send_msg($outputtarget, "d", "Node simulation by 'chdef' has failed") if ($verbose); $rc = 1; last; } else { @@ -603,31 +603,31 @@ sub do_main_job { $tmp = `makedhcp xcatmntest 2>&1`; if ($?) { returncmdoutput($tmp, $outputtarget) if ($verbose); - probe_utils->send_msg($outputtarget, "d", "makedhcp xcatmntest failed") if ($verbose); + probe_utils->send_msg($outputtarget, "d", "makedhcp xcatmntest failed") if ($verbose); $rc = 1; `rmdef xcatmntest`; last; } - probe_utils->send_msg($outputtarget, "d", "To do 'makedhcp -q xcatmntest'") if ($verbose); + probe_utils->send_msg($outputtarget, "d", "To do 'makedhcp -q xcatmntest'") if ($verbose); $tmp = `makedhcp -q xcatmntest`; if ($?) { returncmdoutput($tmp, $outputtarget) if ($verbose); probe_utils->send_msg($outputtarget, "d", "makedhcp -q xcatmntest failed") if ($verbose); $rc = 1; - `makedhcp -d xcatmntest && rmdef xcatmntest`; + `makedhcp -d xcatmntest && rmdef xcatmntest`; last; } chomp($tmp); if ($tmp !~ /xcatmntest: ip-address = $serverip, hardware-address = aa:aa:aa:aa:aa:aa/) { returncmdoutput($tmp, $outputtarget) if ($verbose); - probe_utils->send_msg($outputtarget, "d", "DHCP server's reply is wrong") if ($verbose); + probe_utils->send_msg($outputtarget, "d", "DHCP server reply is wrong") if ($verbose); $rc = 1; `makedhcp -d xcatmntest && rmdef xcatmntest`; last; } - probe_utils->send_msg($outputtarget, "d", "Start to clear simulate information for dhcp test") if ($verbose); + probe_utils->send_msg($outputtarget, "d", "Start clearing simulation information for dhcp test") if ($verbose); $tmp = `makedhcp -d xcatmntest && rmdef xcatmntest`; returncmdoutput($tmp, $outputtarget) if ($verbose); @@ -637,7 +637,7 @@ sub do_main_job { } if ($rc) { probe_utils->send_msg($outputtarget, "f", "$msg"); - probe_utils->send_msg($outputtarget, "d", "please run 'makedhcp -n' if never run it before."); + probe_utils->send_msg($outputtarget, "d", "Run 'makedhcp -n' if it has not been ran before."); $rst = 1; } else { probe_utils->send_msg($outputtarget, "o", "$msg"); @@ -750,7 +750,7 @@ sub caclulate_dispatch_cmd { if ($error =~ /Error: Invalid nodes and\/or groups in noderange: (.+)/) { probe_utils->send_msg("$output", "f", "There are invaild nodes ($1) in command line attribute node range"); } else { - probe_utils->send_msg("$output", "f", "There is error in command line attribute node range, please using nodels to check"); + probe_utils->send_msg("$output", "f", "There is an error in command line attribute node range, use 'nodels' to check"); } return 1; } else { @@ -838,7 +838,7 @@ if ($help) { } if ($test) { - probe_utils->send_msg("$output", "o", "After xcat installation, use this command to check if xcat has been installed correctly and is ready for use. Before using this command, please install tftp, nslookup and wget commands ahead. The platform supported are redhat, sles and ubuntu."); + probe_utils->send_msg("$output", "o", "After xcat installation, use this command to check if xcat has been installed correctly and is ready for use. Before using this command, install 'tftp', 'nslookup' and 'wget' commands. Supported platforms are RedHat, SLES and Ubuntu."); exit 0; } diff --git a/xCAT-probe/xcatprobe b/xCAT-probe/xcatprobe index 6cd0b5e95..dae96b42a 100755 --- a/xCAT-probe/xcatprobe +++ b/xCAT-probe/xcatprobe @@ -31,7 +31,7 @@ Options: -h : get usage information of $program_name -l : list all valid sub commands -V : print verbose information of $program_name - -w : show each line completely. by default if one is too long, the long part will be omitted. + -w : show each line completely. By default long lines are truncated. "; #----------------------------------- @@ -275,7 +275,7 @@ if ($ARGV[0] eq "-l") { } if (!defined($pluginname)) { - print "There isn't sub command input from command line, please use '-l' to list all valid subcommand\n"; + print "There isn't sub command input from command line, use '-l' to list all valid subcommand\n"; exit 0; } From 8abf2b0334301bcb9f92712b245ab12fd15350da Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Tue, 16 Aug 2016 14:34:32 -0400 Subject: [PATCH 060/106] Provide Security Notice for Vulnerability created on 2016-08-15 --- docs/source/security/2016/20160815_openssl.rst | 18 ++++++++++++++++++ docs/source/security/2016/index.rst | 1 + 2 files changed, 19 insertions(+) create mode 100644 docs/source/security/2016/20160815_openssl.rst diff --git a/docs/source/security/2016/20160815_openssl.rst b/docs/source/security/2016/20160815_openssl.rst new file mode 100644 index 000000000..1a99c972d --- /dev/null +++ b/docs/source/security/2016/20160815_openssl.rst @@ -0,0 +1,18 @@ +2016-08-16 - OpenSSL Vulnerabilities +==================================== + +This vulnerability has no fix available at this time (other then mentioned patches below) + +Issue: https://bugzilla.redhat.com/show_bug.cgi?id=1359615 + +Patch: https://github.com/openssl/openssl/commit/0ed26acce328ec16a3aa635f1ca37365e8c7403a + +Advisory CVEs +------------- + +`CVE-2016-2180 `_ - OpenSSL is vulnerable to a denial of service, caused by an out-of-bounds read in the TS_OBJ_print_bio function. + +Action +------ + +xCAT uses OpenSSL for client-server communication but **does not** ship it. It is highly recommended to keep your OpenSSL levels up-to-date to prevent any potential security threats. diff --git a/docs/source/security/2016/index.rst b/docs/source/security/2016/index.rst index 3017c40dd..3a564ae52 100644 --- a/docs/source/security/2016/index.rst +++ b/docs/source/security/2016/index.rst @@ -8,3 +8,4 @@ 20160301_openssl.rst 20160128_openssl.rst 20160115_openssl.rst + 20160815_openssl.rst From 60f54f7fb2addb0bdf24defcadca42d31990c12f Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Tue, 16 Aug 2016 20:34:15 -0400 Subject: [PATCH 061/106] Support --resize option for chvm (#1598) * Support --resize option for chvm * Handle generic error from libvirt when resizing VM * Improve finding the disk to resize --- .../admin-guides/references/man1/chvm.1.rst | 18 ++++-- xCAT-client/pods/man1/chvm.1.pod | 14 +++-- xCAT-server/lib/xcat/plugins/kvm.pm | 60 ++++++++++++++++++- 3 files changed, 80 insertions(+), 12 deletions(-) diff --git a/docs/source/guides/admin-guides/references/man1/chvm.1.rst b/docs/source/guides/admin-guides/references/man1/chvm.1.rst index 056aa31e3..bd81a7f17 100644 --- a/docs/source/guides/admin-guides/references/man1/chvm.1.rst +++ b/docs/source/guides/admin-guides/references/man1/chvm.1.rst @@ -62,7 +62,7 @@ VMware/KVM specific: ==================== -\ **chvm**\ \ *noderange*\ [\ **-a**\ \ *size*\ ] [\ **-d**\ \ *disk*\ ] [\ **-p**\ \ *disk*\ ] [\ **-**\ **-resize**\ \ **disk**\ =\ *size*\ ] [\ **-**\ **-cpus**\ \ *count*\ ] [\ **-**\ **-mem**\ \ *memory*\ ] +\ **chvm**\ \ *noderange*\ [\ **-a**\ \ *size*\ ] [\ **-d**\ \ *disk*\ ] [\ **-p**\ \ *disk*\ ] [\ **-**\ **-resize**\ \ *disk*\ =\ *size*\ ] [\ **-**\ **-cpus**\ \ *count*\ ] [\ **-**\ **-mem**\ \ *memory*\ ] zVM specific: @@ -318,7 +318,7 @@ VMware/KVM specific: \ **-d**\ \ *disk*\ - Deregister the Hard disk but leave the backing files. Multiple can be done with comma separated values. The disks are specified by SCSI id. Size defaults to GB. + Deregister the Hard disk but leave the backing files. Multiple can be done with comma separated values. The disks are specified by SCSI id. @@ -330,13 +330,13 @@ VMware/KVM specific: \ **-p**\ \ *disk*\ - Purge the Hard disk. Deregisters and deletes the files. Multiple can be done with comma separated values. The disks are specified by SCSI id. Size defaults to GB. + Purge the Hard disk. Deregisters and deletes the files. Multiple can be done with comma separated values. The disks are specified by SCSI id. -\ **-**\ **-resize**\ \ **disk**\ =\ *size*\ +\ **-**\ **-resize**\ \ *disk*\ =\ *size*\ - Change the size of the Hard disk. The disk can never be set to less than it's current size. Multiple disks can be resized to \ *size*\ by using comma separated values on the left side of \ **=**\ . The disks are specified by SCSI id. Size defaults to GB. + Change the size of the Hard disk. The disk in \ *qcow2*\ format can not be set to less than it's current size. The disk in \ *raw*\ format can be resized smaller, please use caution. Multiple disks can be resized by using comma separated \ *disk*\ \ **=**\ \ *size*\ pairs. The disks are specified by SCSI id. Size defaults to GB. @@ -976,6 +976,14 @@ Output is similar to: gpok3: Replacing user entry of LNX3... Done +8. To resize virtual machine's disk sdb to 10G and sdc to 15G: + + +.. code-block:: perl + + chvm gpok3 --resize sdb=10G,sdc=15G + + ***** diff --git a/xCAT-client/pods/man1/chvm.1.pod b/xCAT-client/pods/man1/chvm.1.pod index 4a52a7a38..615ec1fca 100644 --- a/xCAT-client/pods/man1/chvm.1.pod +++ b/xCAT-client/pods/man1/chvm.1.pod @@ -38,7 +38,7 @@ B I [B<--devdetach> I...] =head2 VMware/KVM specific: -B I [B<-a> I] [B<-d> I] [B<-p> I] [B<--resize> B=I] [B<--cpus> I] [B<--mem> I] +B I [B<-a> I] [B<-d> I] [B<-p> I] [B<--resize> I=I] [B<--cpus> I] [B<--mem> I] =head2 zVM specific: @@ -236,7 +236,7 @@ Set the number of CPUs. =item B<-d> I -Deregister the Hard disk but leave the backing files. Multiple can be done with comma separated values. The disks are specified by SCSI id. Size defaults to GB. +Deregister the Hard disk but leave the backing files. Multiple can be done with comma separated values. The disks are specified by SCSI id. =item B<--mem> I @@ -244,11 +244,11 @@ Set the memory, defaults to MB. =item B<-p> I -Purge the Hard disk. Deregisters and deletes the files. Multiple can be done with comma separated values. The disks are specified by SCSI id. Size defaults to GB. +Purge the Hard disk. Deregisters and deletes the files. Multiple can be done with comma separated values. The disks are specified by SCSI id. -=item B<--resize> B=I +=item B<--resize> I=I -Change the size of the Hard disk. The disk can never be set to less than it's current size. Multiple disks can be resized to I by using comma separated values on the left side of B<=>. The disks are specified by SCSI id. Size defaults to GB. +Change the size of the Hard disk. The disk in I format can not be set to less than it's current size. The disk in I format can be resized smaller, please use caution. Multiple disks can be resized by using comma separated IB<=>I pairs. The disks are specified by SCSI id. Size defaults to GB. =back @@ -640,6 +640,10 @@ Output is similar to: gpok3: Replacing user entry of LNX3... Done +8. To resize virtual machine's disk sdb to 10G and sdc to 15G: + + chvm gpok3 --resize sdb=10G,sdc=15G + =head1 FILES /opt/xcat/bin/chvm diff --git a/xCAT-server/lib/xcat/plugins/kvm.pm b/xCAT-server/lib/xcat/plugins/kvm.pm index d0d8eab11..32b73c72a 100755 --- a/xCAT-server/lib/xcat/plugins/kvm.pm +++ b/xCAT-server/lib/xcat/plugins/kvm.pm @@ -1807,7 +1807,7 @@ sub rmvm { sub chvm { shift; my @addsizes; - my %resize; + my $resize; my $cpucount; my @purge; my @derefdisks; @@ -1831,7 +1831,7 @@ sub chvm { "eject" => \$eject, "cpus|cpu=s" => \$cpucount, "p=s" => \@purge, - "resize=s%" => \%resize, + "resize=s" => \$resize, "cpupin=s" => \$pcpuset, "membind=s" => \$numanodeset, "devpassthru=s" => \$passthrudevices, @@ -2096,6 +2096,62 @@ sub chvm { $updatetable->{kvm_nodedata}->{$node}->{xml} = $vmxml; } } + if ($resize) { + my $shrinking_not_supported = "qcow2 doesn't support shrinking images yet"; + # Get a list of disk=size pairs + my @resize_disks = split(/,/, $resize); + for my $single_disk (@resize_disks) { + # For each comma separated disk, get disk name and the size to change it to + my ($disk_to_resize, $value) = split(/=/, $single_disk); + if ($disk_to_resize) { + unless (exists $useddisks{$disk_to_resize}) { + # Disk name given does not match any disks for this vm + xCAT::SvrUtils::sendmsg([ 1, "Disk $disk_to_resize does not exist" ], $callback, $node); + next; + } + # Get desired (new) disk size + $value = getUnits($value, "G", 1); + # Now search kvm_nodedata table to find the volume for this disk + my $myxml = $parser->parse_string($vmxml); + my @alldisks = $myxml->findnodes("/domain/devices/disk"); + # Look through all the disk entries + foreach my $disknode (@alldisks) { + my $devicetype = $disknode->getAttribute("device"); + # Skip cdrom devices + if ($devicetype eq "cdrom") { next; } + # Get name of the disk + my $diskname = $disknode->findnodes('./target')->[0]->getAttribute('dev'); + # Is this a disk we were looking for to resize ? + if ($diskname eq $disk_to_resize) { + my $file = $disknode->findnodes('./source')->[0]->getAttribute('file'); + my $vol = $hypconn->get_storage_volume_by_path($file); + if ($vol) { + # Always pass RESIZE_SHRINK flag to resize(). It is required when shrinking + # the volume size and is ignored when growing volume size + eval { + $vol->resize($value, &Sys::Virt::StorageVol::RESIZE_SHRINK); + }; + if ($@) { + if ($@ =~ /$shrinking_not_supported/) { + # qcow2 does not support shrinking volumes, display more readable error + xCAT::SvrUtils::sendmsg([ 1, "Resizing disk $disk_to_resize failed, $shrinking_not_supported" ], $callback, $node); + } + else { + # some other resize error from libvirt, just display it + xCAT::SvrUtils::sendmsg([ 1, "Resizing disk $disk_to_resize failed, $@" ], $callback, $node); + } + } + else { + # success + xCAT::SvrUtils::sendmsg([ 0, "Resized disk $disk_to_resize" ], $callback, $node); + } + } + last; # Found the disk we were looking for. Go to the next disk. + } + } + } + } + } if ($cpucount or $memory) { if ($currstate eq 'on') { if ($cpucount) { xCAT::SvrUtils::sendmsg([ 1, "Hot add of cpus not supported (VM must be powered down to successfuly change)" ], $callback, $node); } From 758b1c9b96311c22b2fa2de5d3c2faae4a183b6d Mon Sep 17 00:00:00 2001 From: hu-weihua Date: Wed, 17 Aug 2016 01:36:02 -0400 Subject: [PATCH 062/106] Remove the Debian Support Message in the xcatprobe command. --- xCAT-probe/subcmds/detect_dhcpd | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xCAT-probe/subcmds/detect_dhcpd b/xCAT-probe/subcmds/detect_dhcpd index b8430761e..c95f784c8 100755 --- a/xCAT-probe/subcmds/detect_dhcpd +++ b/xCAT-probe/subcmds/detect_dhcpd @@ -59,7 +59,7 @@ if ($::HELP) { } if ($::TEST) { - probe_utils->send_msg("$output", "o", "$program_name can be used to detect the dhcp server in a network for a specific mac address. Before using this command, install 'tcpdump' command. The operating system supported are RedHat, SLES, Ubuntu and Debian."); + probe_utils->send_msg("$output", "o", "$program_name can be used to detect the dhcp server in a network for a specific mac address. Before using this command, install 'tcpdump' command. The operating system supported are RedHat, SLES and Ubuntu."); exit 0; } @@ -104,11 +104,11 @@ if (-f "/etc/redhat-release") { $os = "sles"; } elsif (-f "/etc/lsb-release") { $os = "ubuntu"; -} elsif (-f "/etc/debian_version") { - $os = "debian"; +#} elsif (-f "/etc/debian_version") { +# $os = "debian"; } else { probe_utils->send_msg("$output", "f", $msg); - probe_utils->send_msg("$output", "d", "Only support the RedHat, SLES, Ubuntu and Debian OS"); + probe_utils->send_msg("$output", "d", "Only support the RedHat, SLES and Ubuntu."); exit 1; } probe_utils->send_msg("$output", "d", "Current operating system is $os") if ($::VERBOSE); From 6c43f8f716ae3b228806588a19d41e58ee1646b5 Mon Sep 17 00:00:00 2001 From: ertaozh Date: Wed, 17 Aug 2016 02:55:28 -0400 Subject: [PATCH 063/106] run mknb for both ppc64 and x86_64 --- xCAT-server/sbin/xcatconfig | 48 +++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 26 deletions(-) diff --git a/xCAT-server/sbin/xcatconfig b/xCAT-server/sbin/xcatconfig index 2686e9b98..e960e1640 100755 --- a/xCAT-server/sbin/xcatconfig +++ b/xCAT-server/sbin/xcatconfig @@ -1911,7 +1911,8 @@ sub setupLinuxexports Creates a network boot root image on Linux Run mknb to put xCAT-genesis-scripts-x86_64 and xCAT-genesis-base-x86_64 together and in /tftpboot - + From 2.12.2, both xCAT-genesis-scripts-x86_64 and xCAT-genesis-scripts-ppc64 will be installed. + So, will run mknb twice, one for ppc64 and another for x86_64 =cut #----------------------------------------------------------------------------- @@ -1920,35 +1921,30 @@ sub mknb # The xCAT-genesis-scripts.spec file touches /etc/xcat/genesis-scripts-updated or # the xCAT-genesis-base.spec file touches /etc/xcat/genesis-base-updated, # so we know to run mknb here. - my $cmd; - if ($::arch =~ /ppc/) { - $::arch = "ppc64"; - } - if ((($::arch eq "x86_64") || ($::arch =~ /ppc/)) && (-f '/etc/xcat/genesis-scripts-updated')) { + my $cmd = "$::XCATROOT/sbin/mknb"; + my $run_mknb = 0; + if (-f '/etc/xcat/genesis-scripts-updated') { unlink '/etc/xcat/genesis-scripts-updated'; - - # Do not print messages or run command twice - if (-f '/etc/xcat/genesis-base-updated') { - unlink '/etc/xcat/genesis-base-updated'; - } - $cmd = "$::XCATROOT/sbin/mknb $::arch"; - xCAT::MsgUtils->message('I', "Running '$cmd', triggered by the installation/update of xCAT-genesis-scripts-$::arch ..."); + $run_mknb = 1; + xCAT::MsgUtils->message('I', "Running '$cmd', triggered by the installation/update of xCAT-genesis-scripts ..."); } - if ((($::arch eq "x86_64") || ($::arch =~ /ppc/)) && (-f '/etc/xcat/genesis-base-updated')) { + if (-f '/etc/xcat/genesis-base-updated') { unlink '/etc/xcat/genesis-base-updated'; - $cmd = "$::XCATROOT/sbin/mknb $::arch"; - xCAT::MsgUtils->message('I', "Running '$cmd', triggered by the installation/update of xCAT-genesis-base-$::arch ..."); - } - - # my $outref = xCAT::Utils->runcmd("$cmd", 0); - if ($cmd) { - system($cmd); - if ($? != 0) { - my $rc = $? >> 8; - xCAT::MsgUtils->message('E', "The 'mknb $::arch' command returned error code: $rc."); + unless ($run_mknb) { + $run_mknb = 1; + xCAT::MsgUtils->message('I', "Running '$cmd', triggered by the installation/update of xCAT-genesis-base ..."); } - else { - xCAT::MsgUtils->message('I', "The 'mknb $::arch' command completed successfully."); + } + if ($run_mknb) { + foreach (qw(ppc64 x86_64)) { + system("$cmd $_"); + if ($? != 0) { + my $rc = $? >> 8; + xCAT::MsgUtils->message('E', "The 'mknb $_' command returned error code: $rc."); + } + else { + xCAT::MsgUtils->message('I', "The 'mknb $_' command completed successfully."); + } } } } From 823e1380993d49d575ce4888bd830d4024d2f12a Mon Sep 17 00:00:00 2001 From: "litingt@cn.ibm.com" Date: Wed, 17 Aug 2016 04:04:53 -0400 Subject: [PATCH 064/106] add cases for the packimage -m -c option --- xCAT-test/autotest/testcase/packimg/cases0 | 292 +++++++++++++++++++++ 1 file changed, 292 insertions(+) diff --git a/xCAT-test/autotest/testcase/packimg/cases0 b/xCAT-test/autotest/testcase/packimg/cases0 index aeca509ea..5029ab9d7 100644 --- a/xCAT-test/autotest/testcase/packimg/cases0 +++ b/xCAT-test/autotest/testcase/packimg/cases0 @@ -69,3 +69,295 @@ cmd:packimage -v check:output=~version|Version end +start:packimage_m_cpio_c_gzip +os:Linux +description:test packimage -m cpio -c gzip +cmd:copycds $$ISO +cmd:ls /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg;if [ $? -eq 0 ];then mv -f /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg /rootimg.bak;fi +cmd:ls /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.cpio.gz;if [ $? -eq 0 ];then mv -f /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.cpio.gz /rootimg.cpio.gz.bak;fi +cmd:genimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute +check:rc==0 +cmd:ls -l /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg +check:rc==0 +cmd:packimage -o __GETNODEATTR($$CN,os)__ -p compute -a __GETNODEATTR($$CN,arch)__ -m cpio -c gzip +check:rc==0 +check:output=~archive method:cpio +check:output=~compress method:gzip +cmd:ls -l /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.cpio.gz +check:rc==0 +cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute +check:rc==0 +cmd:if [[ "__GETNODEATTR($$CN,arch)__" = "ppc64" ]]; then rnetboot $$CN;else rpower $$CN boot; fi +check:rc==0 +cmd:sleep 900 +cmd:a=0;while ! `lsdef -l $$CN|grep status|grep booted >/dev/null`; do sleep 10;((a++));if [ $a -gt 60 ];then break;fi done +cmd:ping $$CN -c 3 +check:rc==0 +check:output=~64 bytes from $$CN +cmd:lsdef -l $$CN | grep status +check:rc==0 +check:output=~booted +cmd:xdsh $$CN date +check:rc==0 +check:output=~\d\d:\d\d:\d\d +cmd:xdsh $$CN mount +check:rc==0 +check:output=~on / type tmpfs +cmd:rootimgdir=`lsdef -t osimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute|grep rootimgdir|awk -F'=' '{print $2}'`; if [ -d $rootimgdir.regbak ]; then rm -rf $rootimgdir; mv $rootimgdir.regbak $rootimgdir; fi +check:rc==0 +cmd:rm -rf /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.cpio.gz +cmd:mv -f /rootimg.cpio.gz.bak /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.cpio.gz +cmd:rm -rf /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg +cmd:mv -f /rootimg.bak /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg +end + +start:packimage_m_cpio_c_pigz +os:Linux +description:test packimage -m cpio -c pigz +#cmd:copycds $$ISO +cmd:ls /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg;if [ $? -eq 0 ];then mv -f /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg /rootimg.bak;fi +cmd:ls /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.cpio.gz;if [ $? -eq 0 ];then mv -f /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.cpio.gz /rootimg.cpio.gz.bak;fi +cmd:genimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute +check:rc==0 +cmd:ls -l /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg +check:rc==0 +cmd:if grep SUSE /etc/*release;then zypper install -y pigz;fi +check:rc==0 +cmd:if grep Ubuntu /etc/*release;then apt-get install pigz -y; fi +check:rc==0 +cmd:packimage -o __GETNODEATTR($$CN,os)__ -p compute -a __GETNODEATTR($$CN,arch)__ -m cpio -c pigz +check:rc==0 +check:output=~archive method:cpio +check:output=~compress method:pigz +cmd:ls -l /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.cpio.gz +check:rc==0 +cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute +check:rc==0 +cmd:if [[ "__GETNODEATTR($$CN,arch)__" = "ppc64" ]]; then rnetboot $$CN;else rpower $$CN boot; fi +check:rc==0 +cmd:sleep 900 +cmd:a=0;while ! `lsdef -l $$CN|grep status|grep booted >/dev/null`; do sleep 10;((a++));if [ $a -gt 60 ];then break;fi done +cmd:ping $$CN -c 3 +check:rc==0 +check:output=~64 bytes from $$CN +cmd:lsdef -l $$CN | grep status +check:rc==0 +check:output=~booted +cmd:xdsh $$CN date +check:rc==0 +check:output=~\d\d:\d\d:\d\d +cmd:xdsh $$CN mount +check:rc==0 +check:output=~on / type tmpfs +cmd:rootimgdir=`lsdef -t osimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute|grep rootimgdir|awk -F'=' '{print $2}'`; if [ -d $rootimgdir.regbak ]; then rm -rf $rootimgdir; mv $rootimgdir.regbak $rootimgdir; fi +check:rc==0 +cmd:rm -rf /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.cpio.gz +cmd:mv -f /rootimg.cpio.gz.bak /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.cpio.gz +cmd:rm -rf /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg +cmd:mv -f /rootimg.bak /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg +end + +start:packimage_m_cpio_c_xz +os:Linux +description:test packimage -m cpio -c xz +#cmd:copycds $$ISO +cmd:ls /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg;if [ $? -eq 0 ];then mv -f /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg /rootimg.bak;fi +cmd:ls /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.cpio.xz;if [ $? -eq 0 ];then mv -f /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.cpio.xz /rootimg.cpio.xz.bak;fi +cmd:genimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute +check:rc==0 +cmd:ls -l /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg +check:rc==0 +cmd:packimage -o __GETNODEATTR($$CN,os)__ -p compute -a __GETNODEATTR($$CN,arch)__ -m cpio -c xz +check:rc==0 +check:output=~archive method:cpio +check:output=~compress method:xz +cmd:ls -l /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.cpio.xz +check:rc==0 +cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute +check:rc==0 +cmd:if [[ "__GETNODEATTR($$CN,arch)__" = "ppc64" ]]; then rnetboot $$CN;else rpower $$CN boot; fi +check:rc==0 +cmd:sleep 900 +cmd:a=0;while ! `lsdef -l $$CN|grep status|grep booted >/dev/null`; do sleep 10;((a++));if [ $a -gt 60 ];then break;fi done +cmd:ping $$CN -c 3 +check:rc==0 +check:output=~64 bytes from $$CN +cmd:lsdef -l $$CN | grep status +check:rc==0 +check:output=~booted +cmd:xdsh $$CN date +check:rc==0 +check:output=~\d\d:\d\d:\d\d +cmd:xdsh $$CN mount +check:rc==0 +check:output=~on / type tmpfs +cmd:rootimgdir=`lsdef -t osimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute|grep rootimgdir|awk -F'=' '{print $2}'`; if [ -d $rootimgdir.regbak ]; then rm -rf $rootimgdir; mv $rootimgdir.regbak $rootimgdir; fi +check:rc==0 +cmd:rm -rf /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.cpio.xz +cmd:mv -f /rootimg.cpio.xz.bak /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.cpio.xz +cmd:rm -rf /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg +cmd:mv -f /rootimg.bak /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg +end + +start:packimage_m_tar_c_pigz +os:Linux +description:test packimage -m tar -c pigz +#cmd:copycds $$ISO +cmd:ls /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg;if [ $? -eq 0 ];then mv -f /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg /rootimg.bak;fi +cmd:ls /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.tar.gz;if [ $? -eq 0 ];then mv -f /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.tar.gz /rootimg.tar.gz.bak;fi +cmd:genimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute +check:rc==0 +cmd:ls -l /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg +check:rc==0 +cmd:if grep SUSE /etc/*release;then zypper install -y pigz;fi +check:rc==0 +cmd:if grep Ubuntu /etc/*release;then apt-get install pigz -y; fi +check:rc==0 +cmd:packimage -o __GETNODEATTR($$CN,os)__ -p compute -a __GETNODEATTR($$CN,arch)__ -m tar -c pigz +check:rc==0 +check:output=~archive method:tar +check:output=~compress method:pigz +cmd:ls -l /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.tar.gz +check:rc==0 +cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute +check:rc==0 +cmd:if [[ "__GETNODEATTR($$CN,arch)__" = "ppc64" ]]; then rnetboot $$CN;else rpower $$CN boot; fi +check:rc==0 +cmd:sleep 900 +cmd:a=0;while ! `lsdef -l $$CN|grep status|grep booted >/dev/null`; do sleep 10;((a++));if [ $a -gt 60 ];then break;fi done +cmd:ping $$CN -c 3 +check:rc==0 +check:output=~64 bytes from $$CN +cmd:lsdef -l $$CN | grep status +check:rc==0 +check:output=~booted +cmd:xdsh $$CN date +check:rc==0 +check:output=~\d\d:\d\d:\d\d +cmd:xdsh $$CN mount +check:rc==0 +check:output=~on / type tmpfs +cmd:rootimgdir=`lsdef -t osimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute|grep rootimgdir|awk -F'=' '{print $2}'`; if [ -d $rootimgdir.regbak ]; then rm -rf $rootimgdir; mv $rootimgdir.regbak $rootimgdir; fi +check:rc==0 +cmd:rm -rf /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.tar.gz +cmd:mv -f /rootimg.tar.gz.bak /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.tar.gz +cmd:rm -rf /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg +cmd:mv -f /rootimg.bak /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg +end + +start:packimage_m_tar_c_gzip +os:Linux +description:test packimage -m tar -c gzip +#cmd:copycds $$ISO +cmd:ls /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg;if [ $? -eq 0 ];then mv -f /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg /rootimg.bak;fi +cmd:ls /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.tar.gz;if [ $? -eq 0 ];then mv -f /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.tar.gz /rootimg.tar.gz.bak;fi +cmd:genimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute +check:rc==0 +cmd:ls -l /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg +check:rc==0 +cmd:packimage -o __GETNODEATTR($$CN,os)__ -p compute -a __GETNODEATTR($$CN,arch)__ -m tar -c gzip +check:rc==0 +check:output=~archive method:tar +check:output=~compress method:gzip +cmd:ls -l /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.tar.gz +check:rc==0 +cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute +check:rc==0 +cmd:if [[ "__GETNODEATTR($$CN,arch)__" = "ppc64" ]]; then rnetboot $$CN;else rpower $$CN boot; fi +check:rc==0 +cmd:sleep 900 +cmd:a=0;while ! `lsdef -l $$CN|grep status|grep booted >/dev/null`; do sleep 10;((a++));if [ $a -gt 60 ];then break;fi done +cmd:ping $$CN -c 3 +check:rc==0 +check:output=~64 bytes from $$CN +cmd:lsdef -l $$CN | grep status +check:rc==0 +check:output=~booted +cmd:xdsh $$CN date +check:rc==0 +check:output=~\d\d:\d\d:\d\d +cmd:xdsh $$CN mount +check:rc==0 +check:output=~on / type tmpfs +cmd:rootimgdir=`lsdef -t osimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute|grep rootimgdir|awk -F'=' '{print $2}'`; if [ -d $rootimgdir.regbak ]; then rm -rf $rootimgdir; mv $rootimgdir.regbak $rootimgdir; fi +check:rc==0 +cmd:rm -rf /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.tar.gz +cmd:mv -f /rootimg.tar.gz.bak /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.tar.gz +cmd:rm -rf /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg +cmd:mv -f /rootimg.bak /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg +end + +start:packimage_m_tar_c_xz +os:Linux +description:test packimage -m tar -c xz +#cmd:copycds $$ISO +cmd:ls /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg;if [ $? -eq 0 ];then mv -f /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg /rootimg.bak;fi +cmd:ls /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.tar.xz;if [ $? -eq 0 ];then mv -f /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.tar.xz /rootimg.tar.xz.bak;fi +cmd:genimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute +check:rc==0 +cmd:ls -l /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg +check:rc==0 +cmd:packimage -o __GETNODEATTR($$CN,os)__ -p compute -a __GETNODEATTR($$CN,arch)__ -m tar -c xz +check:rc==0 +check:output=~archive method:tar +check:output=~compress method:xz +cmd:ls -l /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.tar.xz +check:rc==0 +cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute +check:rc==0 +cmd:if [[ "__GETNODEATTR($$CN,arch)__" = "ppc64" ]]; then rnetboot $$CN;else rpower $$CN boot; fi +check:rc==0 +cmd:sleep 900 +cmd:a=0;while ! `lsdef -l $$CN|grep status|grep booted >/dev/null`; do sleep 10;((a++));if [ $a -gt 60 ];then break;fi done +cmd:ping $$CN -c 3 +check:rc==0 +check:output=~64 bytes from $$CN +cmd:lsdef -l $$CN | grep status +check:rc==0 +check:output=~booted +cmd:xdsh $$CN date +check:rc==0 +check:output=~\d\d:\d\d:\d\d +cmd:xdsh $$CN mount +check:rc==0 +check:output=~on / type tmpfs +cmd:rootimgdir=`lsdef -t osimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute|grep rootimgdir|awk -F'=' '{print $2}'`; if [ -d $rootimgdir.regbak ]; then rm -rf $rootimgdir; mv $rootimgdir.regbak $rootimgdir; fi +check:rc==0 +cmd:rm -rf /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.tar.xz +cmd:mv -f /rootimg.tar.xz.bak /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.tar.xz +cmd:rm -rf /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg +cmd:mv -f /rootimg.bak /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg +end + +start:packimage_m_invalid_archive_method +os:Linux +description:test packimage with invalid archive method +#cmd:copycds $$ISO +cmd:ls /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg;if [ $? -eq 0 ];then mv -f /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg /rootimg.bak;fi +cmd:genimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute +check:rc==0 +cmd:ls -l /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg +check:rc==0 +cmd:packimage -o __GETNODEATTR($$CN,os)__ -p compute -a __GETNODEATTR($$CN,arch)__ -m invalid +check:rc!=0 +check:output=~Error: Invalid archive method 'invalid' requested +cmd:rm -rf /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg +cmd:mv -f /rootimg.bak /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg +end + +start:packimage_m_invalid_compress_method +os:Linux +description:test packimage with invalid compress method +#cmd:copycds $$ISO +cmd:ls /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg;if [ $? -eq 0 ];then mv -f /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg /rootimg.bak;fi +cmd:genimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute +check:rc==0 +cmd:ls -l /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg +check:rc==0 +cmd:packimage -o __GETNODEATTR($$CN,os)__ -p compute -a __GETNODEATTR($$CN,arch)__ -c invalid +check:rc!=0 +check:output=~Error: Invalid compress method 'invalid' requested +cmd:rm -rf /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg +cmd:mv -f /rootimg.bak /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg +end + From d58495a39194804aabb38a20a4926409015960a1 Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Wed, 17 Aug 2016 16:21:07 +0800 Subject: [PATCH 065/106] [go-xcat] Fix typo --- xCAT-server/share/xcat/tools/go-xcat | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xCAT-server/share/xcat/tools/go-xcat b/xCAT-server/share/xcat/tools/go-xcat index 610bf3ebc..62b7ed9e6 100755 --- a/xCAT-server/share/xcat/tools/go-xcat +++ b/xCAT-server/share/xcat/tools/go-xcat @@ -142,7 +142,7 @@ GO_XCAT_CORE_PACKAGE_LIST=(perl-xCAT xCAT xCAT-SoftLayer xCAT-buildkit # For Debian/Ubuntu, it will need a sight different package list type dpkg >/dev/null 2>&1 && GO_XCAT_CORE_PACKAGE_LIST=(perl-xcat xcat xcat-buildkit xcat-client - xcat-confluent xcat-genesis-scripts-amd64 xcat-genesis-script-ppc64 + xcat-confluent xcat-genesis-scripts-amd64 xcat-genesis-scripts-ppc64 xcat-server xcat-test xcat-vlan xcatsn) GO_XCAT_DEP_PACKAGE_LIST=() @@ -154,7 +154,7 @@ GO_XCAT_INSTALL_LIST=(perl-xCAT xCAT xCAT-buildkit xCAT-client # For Debian/Ubuntu, it will need a sight different package list type dpkg >/dev/null 2>&1 && GO_XCAT_INSTALL_LIST=(perl-xcat xcat xcat-buildkit xcat-client - xcat-genesis-scripts-amd64 xcat-genesis-script-ppc64 xcat-server + xcat-genesis-scripts-amd64 xcat-genesis-scripts-ppc64 xcat-server conserver-xcat elilo-xcat grub2-xcat ipmitool-xcat syslinux-xcat xcat-genesis-base-amd64 xcat-genesis-base-ppc64 xnba-undi) From 25865721325cc01661716ce15b4c5b5b6dcda7bd Mon Sep 17 00:00:00 2001 From: Patrick Lundgren Date: Wed, 17 Aug 2016 11:07:54 -0400 Subject: [PATCH 066/106] Added check for GRS hardware current firmware version above 1.7_2.55 (1610A) --- xCAT-server/lib/xcat/plugins/ipmi.pm | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/ipmi.pm b/xCAT-server/lib/xcat/plugins/ipmi.pm index f9a1a3434..c8d933571 100644 --- a/xCAT-server/lib/xcat/plugins/ipmi.pm +++ b/xCAT-server/lib/xcat/plugins/ipmi.pm @@ -1746,6 +1746,27 @@ sub do_firmware_update { $buffer_size = "15000"; } + # check for 8335-GTB Firmware above 1610A release. If below, exit + if ($output =~ /8335-GTB/) { + $cmd = $pre_cmd . " fru print 47"; + $output = xCAT::Utils->runcmd($cmd, -1); + if ($::RUNCMD_RC != 0) { + xCAT::SvrUtils::sendmsg([ 1, "Running ipmitool command $cmd failed: $output" ], + $callback, $sessdata->{node}, %allerrornodes); + return -1; + } + my $grs_version = $output =~ /OP8_v(\d*\.\d*_\d*\.\d*)/; + if ($grs_version =~ /\d\.(\d+)_(\d+\.\d+)/) { + my $prim_grs_version = $1; + my $sec_grs_version = $2; + if ($prim_grs_version <= 7 && $sec_grs_version < 2.55) { + xCAT::SvrUtils::sendmsg([ 1, "Error: Current firmware level OP8v_$grs_version requires one-time manual update to at least version OP8v_1.7_2.55" ], + $callback, $sessdata->{node}, %allerrornodes); + return -1; + } + } + } + # step 1 power off $cmd = $pre_cmd . " chassis power off"; $output = xCAT::Utils->runcmd($cmd, -1); From 13388737ac9fa44fc2f218425eb3dca2d1bc8d96 Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Wed, 17 Aug 2016 15:02:47 -0400 Subject: [PATCH 067/106] Update create_img.rst Fix type of install on this page --- .../manage_clusters/common/deployment/create_img.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/guides/admin-guides/manage_clusters/common/deployment/create_img.rst b/docs/source/guides/admin-guides/manage_clusters/common/deployment/create_img.rst index c07b65f78..ce750d346 100644 --- a/docs/source/guides/admin-guides/manage_clusters/common/deployment/create_img.rst +++ b/docs/source/guides/admin-guides/manage_clusters/common/deployment/create_img.rst @@ -61,7 +61,7 @@ For ubuntu ppc64le, the initrd.gz shipped with the ISO does not support network * Copy the netboot initrd.gz to osimage :: mkdir -p /install//ppc64el/install/netboot - cp /tmp/iso/install/initrd.gz /install//ppc64el/installe/netboot + cp /tmp/iso/install/initrd.gz /install//ppc64el/install/netboot **[Below tips maybe helpful for you]** From 918127991337d5360710597d60d1b176807bdcf0 Mon Sep 17 00:00:00 2001 From: cxhong Date: Wed, 17 Aug 2016 19:44:19 -0400 Subject: [PATCH 068/106] mysqlsetup failed becuase /usr/bin/mysql_install_db is not available (#1702) * mysqlsetup failed becuase /usr/bin/mysql_install_db is not available * use variable * chang "-e" to "-x" --- xCAT-client/bin/mysqlsetup | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/xCAT-client/bin/mysqlsetup b/xCAT-client/bin/mysqlsetup index e61857a20..e242ed930 100755 --- a/xCAT-client/bin/mysqlsetup +++ b/xCAT-client/bin/mysqlsetup @@ -916,7 +916,13 @@ sub initmysqldb } else { - $cmd = "/usr/bin/mysql_install_db --user=mysql"; + my $sqlcmd = "/usr/bin/mysql_install_db"; + if (!(-x ($sqlcmd))) { + xCAT::MsgUtils->message("E", "$sqlcmd is not available, please install required mysql/mariadb packages"); + exit(1); + } + + $cmd = "$sqlcmd --user=mysql"; } xCAT::Utils->runcmd($cmd, 0); if ($::RUNCMD_RC != 0) From a4a1706d4444d8bc335c917ef23017b3006a8c45 Mon Sep 17 00:00:00 2001 From: hu-weihua Date: Wed, 17 Aug 2016 21:49:38 -0400 Subject: [PATCH 069/106] fix bug #1717 [fvt]2.12.2 xcatprobe osdeploy -n could not monitor the node deploy process if message's log : dhcp[process id] --- xCAT-probe/subcmds/osdeploy | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xCAT-probe/subcmds/osdeploy b/xCAT-probe/subcmds/osdeploy index 049d125af..969941453 100755 --- a/xCAT-probe/subcmds/osdeploy +++ b/xCAT-probe/subcmds/osdeploy @@ -763,7 +763,7 @@ Start capturing every message during OS provision process...... if ($hdl == \*VARLOGMSGFILE) { chomp($line = ); my @tmp = split(/\s+/, $line); - if ($tmp[4] =~ /dhcpd:/i && $line =~ /$installnic/) { + if ($tmp[4] =~ /dhcpd/i && $line =~ /$installnic/) { handle_dhcp_msg("$line"); } elsif ($tmp[4] =~ /in.tftpd/i) { handle_tftp_msg("$line"); @@ -848,7 +848,7 @@ sub get_valid_logs { } my $ishttplog = 0; - $ishttplog = 1 if ($filename =~ /access[\._]log/); + $ishttplog = 1 if ($filename =~ /access/); foreach my $file (@rotatefiles) { my $fd; @@ -929,7 +929,7 @@ sub get_valid_logs { $timestampepoch = probe_utils->convert_to_epoch_seconds($timestamp, $year, $epoch_seconds_of_now); } - if (($splitline[4] =~ /dhcpd:/i && $_ =~ /$installnic/) + if (($splitline[4] =~ /dhcpd/i && $_ =~ /$installnic/) || ($splitline[4] =~ /in.tftpd/i) || (($splitline[4] =~ /^xcat/i) || ($splitline[5] =~ /^xcat/i)) || ($splitline[5] =~ /GET/ && $splitline[7] =~ /HTTP/)) { @@ -968,7 +968,7 @@ sub do_replay { foreach my $line (@bthistory) { $line =~ s/(\d+) (.+)/$2/g; my @tmp = split(/\s+/, $line); - if ($tmp[4] =~ /dhcpd:/i && $line =~ /$installnic/) { + if ($tmp[4] =~ /dhcpd/i && $line =~ /$installnic/) { handle_dhcp_msg("$line"); } elsif ($tmp[4] =~ /in.tftpd/i) { handle_tftp_msg("$line"); From 8dc30b1e4056259933a5fb9db90c84681c72b1a5 Mon Sep 17 00:00:00 2001 From: "litingt@cn.ibm.com" Date: Thu, 18 Aug 2016 03:13:07 -0400 Subject: [PATCH 070/106] add packimage cases in the daily run bundle --- xCAT-test/autotest/bundle/rhels6.8_ppc64.bundle | 6 ++++++ xCAT-test/autotest/bundle/rhels6.8_x86_64.bundle | 6 ++++++ xCAT-test/autotest/bundle/rhels7.2_ppc64.bundle | 6 ++++++ xCAT-test/autotest/bundle/rhels7.2_ppc64le.bundle | 8 ++++++++ xCAT-test/autotest/bundle/rhels7.2_x86_64.bundle | 6 ++++++ xCAT-test/autotest/bundle/rhels7.3_ppc64le.bundle | 6 ++++++ xCAT-test/autotest/bundle/rhels7.3_x86_64.bundle | 6 ++++++ xCAT-test/autotest/bundle/sles11.4_ppc64.bundle | 8 ++++++++ xCAT-test/autotest/bundle/sles12.1_ppc64le.bundle | 8 ++++++++ xCAT-test/autotest/bundle/sles12.1_x86_64.bundle | 8 ++++++++ xCAT-test/autotest/bundle/ubuntu14.04.4_ppc64le.bundle | 8 ++++++++ xCAT-test/autotest/bundle/ubuntu14.04.4_x86_64.bundle | 8 ++++++++ xCAT-test/autotest/bundle/ubuntu16.04.1_ppc64le.bundle | 8 ++++++++ xCAT-test/autotest/bundle/ubuntu16.04.1_x86_64.bundle | 8 ++++++++ 14 files changed, 100 insertions(+) diff --git a/xCAT-test/autotest/bundle/rhels6.8_ppc64.bundle b/xCAT-test/autotest/bundle/rhels6.8_ppc64.bundle index 50cf77787..17ab440e5 100644 --- a/xCAT-test/autotest/bundle/rhels6.8_ppc64.bundle +++ b/xCAT-test/autotest/bundle/rhels6.8_ppc64.bundle @@ -299,6 +299,12 @@ run_command_with_XCATBYPASS disable_root_permission_in_policy_table assign_certain_command_permission reg_linux_diskless_installation_flat +packimage_m_cpio_c_gzip +packimage_m_cpio_c_xz +packimage_m_tar_c_gzip +packimage_m_tar_c_xz +packimage_m_invalid_archive_method +packimage_m_invalid_compress_method reg_linux_statelite_installation_flat SN_setup_case reg_linux_diskfull_installation_hierarchy diff --git a/xCAT-test/autotest/bundle/rhels6.8_x86_64.bundle b/xCAT-test/autotest/bundle/rhels6.8_x86_64.bundle index 1ea9aa544..713051325 100644 --- a/xCAT-test/autotest/bundle/rhels6.8_x86_64.bundle +++ b/xCAT-test/autotest/bundle/rhels6.8_x86_64.bundle @@ -205,6 +205,12 @@ nodeset_cmdline nodeset_runimg nodeset_check_warninginfo reg_linux_diskless_installation_flat +packimage_m_cpio_c_gzip +packimage_m_cpio_c_xz +packimage_m_tar_c_gzip +packimage_m_tar_c_xz +packimage_m_invalid_archive_method +packimage_m_invalid_compress_method reg_linux_statelite_installation_flat SN_setup_case reg_linux_diskfull_installation_hierarchy diff --git a/xCAT-test/autotest/bundle/rhels7.2_ppc64.bundle b/xCAT-test/autotest/bundle/rhels7.2_ppc64.bundle index f2b8df3fc..2843be128 100644 --- a/xCAT-test/autotest/bundle/rhels7.2_ppc64.bundle +++ b/xCAT-test/autotest/bundle/rhels7.2_ppc64.bundle @@ -299,6 +299,12 @@ run_command_with_XCATBYPASS disable_root_permission_in_policy_table assign_certain_command_permission reg_linux_diskless_installation_flat +packimage_m_cpio_c_gzip +packimage_m_cpio_c_xz +packimage_m_tar_c_gzip +packimage_m_tar_c_xz +packimage_m_invalid_archive_method +packimage_m_invalid_compress_method reg_linux_statelite_installation_flat SN_setup_case reg_linux_diskfull_installation_hierarchy diff --git a/xCAT-test/autotest/bundle/rhels7.2_ppc64le.bundle b/xCAT-test/autotest/bundle/rhels7.2_ppc64le.bundle index 016cc6e18..abca02957 100644 --- a/xCAT-test/autotest/bundle/rhels7.2_ppc64le.bundle +++ b/xCAT-test/autotest/bundle/rhels7.2_ppc64le.bundle @@ -23,6 +23,14 @@ packimage_p_a_o packimage_imagename packimage_h packimage_v +packimage_m_cpio_c_gzip +packimage_m_cpio_c_pigz +packimage_m_cpio_c_xz +packimage_m_tar_c_pigz +packimage_m_tar_c_gzip +packimage_m_tar_c_xz +packimage_m_invalid_archive_method +packimage_m_invalid_compress_method pping_h pping_v pping_node diff --git a/xCAT-test/autotest/bundle/rhels7.2_x86_64.bundle b/xCAT-test/autotest/bundle/rhels7.2_x86_64.bundle index b49f7d3d5..192781e59 100644 --- a/xCAT-test/autotest/bundle/rhels7.2_x86_64.bundle +++ b/xCAT-test/autotest/bundle/rhels7.2_x86_64.bundle @@ -205,6 +205,12 @@ nodeset_shell nodeset_cmdline nodeset_runimg reg_linux_diskless_installation_flat +packimage_m_cpio_c_gzip +packimage_m_cpio_c_xz +packimage_m_tar_c_gzip +packimage_m_tar_c_xz +packimage_m_invalid_archive_method +packimage_m_invalid_compress_method reg_linux_statelite_installation_flat SN_setup_case reg_linux_diskfull_installation_hierarchy diff --git a/xCAT-test/autotest/bundle/rhels7.3_ppc64le.bundle b/xCAT-test/autotest/bundle/rhels7.3_ppc64le.bundle index a9a3aa760..cb5e4d8db 100644 --- a/xCAT-test/autotest/bundle/rhels7.3_ppc64le.bundle +++ b/xCAT-test/autotest/bundle/rhels7.3_ppc64le.bundle @@ -23,6 +23,12 @@ packimage_p_a_o packimage_imagename packimage_h packimage_v +packimage_m_cpio_c_gzip +packimage_m_cpio_c_xz +packimage_m_tar_c_gzip +packimage_m_tar_c_xz +packimage_m_invalid_archive_method +packimage_m_invalid_compress_method pping_h pping_v pping_node diff --git a/xCAT-test/autotest/bundle/rhels7.3_x86_64.bundle b/xCAT-test/autotest/bundle/rhels7.3_x86_64.bundle index 8ecfc8866..488607822 100644 --- a/xCAT-test/autotest/bundle/rhels7.3_x86_64.bundle +++ b/xCAT-test/autotest/bundle/rhels7.3_x86_64.bundle @@ -22,6 +22,12 @@ packimage_p_a_o packimage_imagename packimage_h packimage_v +packimage_m_cpio_c_gzip +packimage_m_cpio_c_xz +packimage_m_tar_c_gzip +packimage_m_tar_c_xz +packimage_m_invalid_archive_method +packimage_m_invalid_compress_method pping_h pping_v pping_node diff --git a/xCAT-test/autotest/bundle/sles11.4_ppc64.bundle b/xCAT-test/autotest/bundle/sles11.4_ppc64.bundle index e87ae4427..5c9b5b196 100644 --- a/xCAT-test/autotest/bundle/sles11.4_ppc64.bundle +++ b/xCAT-test/autotest/bundle/sles11.4_ppc64.bundle @@ -33,6 +33,14 @@ packimage_p_a_o packimage_imagename packimage_h packimage_v +packimage_m_cpio_c_gzip +packimage_m_cpio_c_pigz +packimage_m_cpio_c_xz +packimage_m_tar_c_pigz +packimage_m_tar_c_gzip +packimage_m_tar_c_xz +packimage_m_invalid_archive_method +packimage_m_invalid_compress_method pping_h pping_v pping_node diff --git a/xCAT-test/autotest/bundle/sles12.1_ppc64le.bundle b/xCAT-test/autotest/bundle/sles12.1_ppc64le.bundle index 908c9e336..11fd59720 100644 --- a/xCAT-test/autotest/bundle/sles12.1_ppc64le.bundle +++ b/xCAT-test/autotest/bundle/sles12.1_ppc64le.bundle @@ -25,6 +25,14 @@ packimage_p_a_o packimage_imagename packimage_h packimage_v +packimage_m_cpio_c_gzip +packimage_m_cpio_c_pigz +packimage_m_cpio_c_xz +packimage_m_tar_c_pigz +packimage_m_tar_c_gzip +packimage_m_tar_c_xz +packimage_m_invalid_archive_method +packimage_m_invalid_compress_method pping_h pping_v pping_node diff --git a/xCAT-test/autotest/bundle/sles12.1_x86_64.bundle b/xCAT-test/autotest/bundle/sles12.1_x86_64.bundle index de0b6e294..3eba1e79f 100644 --- a/xCAT-test/autotest/bundle/sles12.1_x86_64.bundle +++ b/xCAT-test/autotest/bundle/sles12.1_x86_64.bundle @@ -217,3 +217,11 @@ assign_certain_command_permission_systemd sles_migration1 sles_migration2 reg_linux_diskless_installation_flat +packimage_m_cpio_c_gzip +packimage_m_cpio_c_pigz +packimage_m_cpio_c_xz +packimage_m_tar_c_pigz +packimage_m_tar_c_gzip +packimage_m_tar_c_xz +packimage_m_invalid_archive_method +packimage_m_invalid_compress_method diff --git a/xCAT-test/autotest/bundle/ubuntu14.04.4_ppc64le.bundle b/xCAT-test/autotest/bundle/ubuntu14.04.4_ppc64le.bundle index 5e2b828c7..f2e48965f 100644 --- a/xCAT-test/autotest/bundle/ubuntu14.04.4_ppc64le.bundle +++ b/xCAT-test/autotest/bundle/ubuntu14.04.4_ppc64le.bundle @@ -23,6 +23,14 @@ packimage_p_a_o packimage_imagename packimage_h packimage_v +packimage_m_cpio_c_gzip +packimage_m_cpio_c_pigz +packimage_m_cpio_c_xz +packimage_m_tar_c_pigz +packimage_m_tar_c_gzip +packimage_m_tar_c_xz +packimage_m_invalid_archive_method +packimage_m_invalid_compress_method pping_h pping_v pping_node diff --git a/xCAT-test/autotest/bundle/ubuntu14.04.4_x86_64.bundle b/xCAT-test/autotest/bundle/ubuntu14.04.4_x86_64.bundle index 94301d77b..9eaf3f422 100644 --- a/xCAT-test/autotest/bundle/ubuntu14.04.4_x86_64.bundle +++ b/xCAT-test/autotest/bundle/ubuntu14.04.4_x86_64.bundle @@ -23,6 +23,14 @@ packimage_p_a_o packimage_imagename packimage_h packimage_v +packimage_m_cpio_c_gzip +packimage_m_cpio_c_pigz +packimage_m_cpio_c_xz +packimage_m_tar_c_pigz +packimage_m_tar_c_gzip +packimage_m_tar_c_xz +packimage_m_invalid_archive_method +packimage_m_invalid_compress_method pping_h pping_v pping_node diff --git a/xCAT-test/autotest/bundle/ubuntu16.04.1_ppc64le.bundle b/xCAT-test/autotest/bundle/ubuntu16.04.1_ppc64le.bundle index 28cd9b4c0..6d53f9ed9 100644 --- a/xCAT-test/autotest/bundle/ubuntu16.04.1_ppc64le.bundle +++ b/xCAT-test/autotest/bundle/ubuntu16.04.1_ppc64le.bundle @@ -23,6 +23,14 @@ packimage_p_a_o packimage_imagename packimage_h packimage_v +packimage_m_cpio_c_gzip +packimage_m_cpio_c_pigz +packimage_m_cpio_c_xz +packimage_m_tar_c_pigz +packimage_m_tar_c_gzip +packimage_m_tar_c_xz +packimage_m_invalid_archive_method +packimage_m_invalid_compress_method pping_h pping_v pping_node diff --git a/xCAT-test/autotest/bundle/ubuntu16.04.1_x86_64.bundle b/xCAT-test/autotest/bundle/ubuntu16.04.1_x86_64.bundle index fe6034954..fb803c3b9 100644 --- a/xCAT-test/autotest/bundle/ubuntu16.04.1_x86_64.bundle +++ b/xCAT-test/autotest/bundle/ubuntu16.04.1_x86_64.bundle @@ -23,6 +23,14 @@ packimage_p_a_o packimage_imagename packimage_h packimage_v +packimage_m_cpio_c_gzip +packimage_m_cpio_c_pigz +packimage_m_cpio_c_xz +packimage_m_tar_c_pigz +packimage_m_tar_c_gzip +packimage_m_tar_c_xz +packimage_m_invalid_archive_method +packimage_m_invalid_compress_method pping_h pping_v pping_node From 2d08093120f9c684fe71c6f9965d06063bb4ccbb Mon Sep 17 00:00:00 2001 From: hu-weihua Date: Thu, 18 Aug 2016 05:33:05 -0400 Subject: [PATCH 071/106] fix bug #1727, probe sub_command discovery has syntax error in ubuntu --- xCAT-probe/subcmds/discovery | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-probe/subcmds/discovery b/xCAT-probe/subcmds/discovery index efdae9901..4d4859c27 100755 --- a/xCAT-probe/subcmds/discovery +++ b/xCAT-probe/subcmds/discovery @@ -204,7 +204,7 @@ sub check_genesis_file { my @file_path = split(' ', $genesis_line); my $elilo_efi = $file_path[1]; my $elilo_path = $file_path[3]; - $elilo_efi =~ s/\${next-server}/$host_ip/i; + $elilo_efi =~ s/\$\{next-server\}/$host_ip/i; $wget_rst = system("wget -q --spider $elilo_efi -T 0.5 -t 3"); if ($wget_rst) { From b90fe2709697bac01b00ddf6f07746d41aedafcc Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Thu, 18 Aug 2016 09:29:42 -0400 Subject: [PATCH 072/106] Created the security notices that were on SF for 2015 into the xCAT documentation so we can clean up the GitHub Wiki to remove security notices from that location. I think saving the last 2 years is sufficient and probably should get removed over time. --- .../source/security/2015/20150312_openssl.rst | 20 +++++++++ .../source/security/2015/20150324_openssl.rst | 12 ++++++ .../source/security/2015/20150403_openssl.rst | 14 +++++++ .../source/security/2015/20150519_openssl.rst | 27 ++++++++++++ .../source/security/2015/20150520_openssl.rst | 20 +++++++++ .../source/security/2015/20151203_openssl.rst | 42 +++++++++++++++++++ docs/source/security/2015/index.rst | 12 ++++++ docs/source/security/index.rst | 1 + 8 files changed, 148 insertions(+) create mode 100644 docs/source/security/2015/20150312_openssl.rst create mode 100644 docs/source/security/2015/20150324_openssl.rst create mode 100644 docs/source/security/2015/20150403_openssl.rst create mode 100644 docs/source/security/2015/20150519_openssl.rst create mode 100644 docs/source/security/2015/20150520_openssl.rst create mode 100644 docs/source/security/2015/20151203_openssl.rst create mode 100644 docs/source/security/2015/index.rst diff --git a/docs/source/security/2015/20150312_openssl.rst b/docs/source/security/2015/20150312_openssl.rst new file mode 100644 index 000000000..698b5e76c --- /dev/null +++ b/docs/source/security/2015/20150312_openssl.rst @@ -0,0 +1,20 @@ +2015-03-12 - OpenSSL Vulnerabilities (FREAK) +============================================= + +OpenSSL announced security fixes on 01/08/15 in the following bulletin: https://www-origin.openssl.org/news/secadv/20150108.txt + +Advisory CVEs +------------- + +* CVE-2015-0204 **RSA silently downgrades to EXPORT_RSA [Client]** (Severity: Low) + +FREAK vulnerability CVE-2015-0204 is involved when 'RSA_EXPORT' ssl cipher suit is used in ssl server/client. + +Action +------ + +xCAT does not use RSA_EXPORT ciphers for ssl communication by default. However, xCAT does allow user to choose the ciphers from the site.xcatsslciphers attribute. + +Please make sure you do not put RSA_EXPORT related ciphers in this attribute. + +It is recommended that you upgrade openssl to 1.0.1L and upper version for the fix of this problem. Please go to the os distribution to get the latest openssl package. diff --git a/docs/source/security/2015/20150324_openssl.rst b/docs/source/security/2015/20150324_openssl.rst new file mode 100644 index 000000000..973bfa57f --- /dev/null +++ b/docs/source/security/2015/20150324_openssl.rst @@ -0,0 +1,12 @@ +2015-03-24 - OpenSSL Vulnerabilities +==================================== + +OpenSSL 1.0.2 introduced the "multiblock" performance improvement. This feature only applies on 64 bit x86 architecture platforms that support AES NI instructions. A defect in the implementation of "multiblock" can cause a segmentation fault within OpenSSL, thus enabling a potential DoS attack. + +This issue affects OpenSSL version: 1.0.2 + + +Action +------ + +xCAT uses OpenSSL for client-server communication but **does not** ship it. Please upgrade OpenSSL to 1.0.2a or higher. diff --git a/docs/source/security/2015/20150403_openssl.rst b/docs/source/security/2015/20150403_openssl.rst new file mode 100644 index 000000000..12262015c --- /dev/null +++ b/docs/source/security/2015/20150403_openssl.rst @@ -0,0 +1,14 @@ +2015-04-03 - OpenSSL Vulnerabilities (BAR MITZVAH) +================================================== + +The RC4 Bar mitzvah attack is an attack on the SSL/TLS protocols when both the client and server have RC4 enabled. + +* http://www.darkreading.com/attacks-breaches/ssl-tls-suffers-bar-mitzvah-attack-/d/d-id/1319633 +* http://www.imperva.com/docs/HII_Attacking_SSL_when_using_RC4.pdf. + +Action +------ + +xCAT uses OpenSSL shipped with OS distribution for client-server communication. It does not use RC4 ciphers explicitly. However, it allows user to specify xcatsslciphers on the site table for ssl communication. It is recommended that the user not specify RC4 ciphers to avoid the Bar mitzvah attack. + +It is also recommended that the user go to the OS distribution to get latest OpenSSL package for the fix of this problem. diff --git a/docs/source/security/2015/20150519_openssl.rst b/docs/source/security/2015/20150519_openssl.rst new file mode 100644 index 000000000..280cf6eb7 --- /dev/null +++ b/docs/source/security/2015/20150519_openssl.rst @@ -0,0 +1,27 @@ +2015-05-19 - OpenSSL Vulnerabilities (VENOM) +============================================ + +Advisory CVEs +------------- + +* CVE-2015-3456 - **(aka VENOM) is a security flaw in the QEMU's Floppy Disk Controller (FDC) emulation.** + +VENOM vulnerability could expose virtual machines on unpatched host systems + +A new vulnerability known as VENOM has been discovered, which could allow an attacker to escape a guest virtual machine (VM) and access the host system along with other VMs running on this system. The VENOM bug could potentially allow an attacker to steal sensitive data on any of the virtual machines on this system and gain elevated access to the host''''s local network and its systems. + +The VENOM bug (CVE-2015-3456) exists in the virtual Floppy Disk Controller for the open-source hypervisor QEMU, which is installed by default in a number of virtualization infrastructures such as Xen hypervisors, the QEMU client, and Kernel-based Virtual Machine (KVM). VENOM does not affect VMware, Microsoft Hyper-V, and Bochs hypervisors. + +* QEMU: http://git.qemu.org/?p=qemu.git;a=commitdiff;h=e907746266721f305d67bc0718795fedee2e824c +* Xen Project: http://xenbits.xen.org/xsa/advisory-133.html +* Red Hat: https://access.redhat.com/articles/1444903 +* SUSE: https://www.suse.com/support/kb/doc.php?id=7016497 +* Ubuntu: http://www.ubuntu.com/usn/usn-2608-1/ + + +Action +------ + +xCAT does not ship any rpms that have QEMU component directly. However xCAT does make system calls to QEMU when doing KVM/Xen visualization. If you are using xCAT to manage KVM or Xen hosts and quests, please get the latest rpms that have QEMU component from the os distro and do a upgrade on both xCAT management node and the KVM/Xen hosts. + + diff --git a/docs/source/security/2015/20150520_openssl.rst b/docs/source/security/2015/20150520_openssl.rst new file mode 100644 index 000000000..8cbaf20c0 --- /dev/null +++ b/docs/source/security/2015/20150520_openssl.rst @@ -0,0 +1,20 @@ +2015-05-20 - OpenSSL Vulnerabilities (LOGJAM) +============================================= + +A Logjam vulnerability attacks openssl and web services on weak (512-bit) Diffie-Hellman key groups. Please refer to the following documents for details. + +Main site: https://weakdh.org/ + +Server test: https://weakdh.org/sysadmin.html + +Please refer to the following openssl link for more details regarding the fix: https://www.openssl.org/blog/blog/2015/05/20/logjam-freak-upcoming-changes/ + + OpenSSL 1.0.2 users should upgrade to 1.0.2b + OpenSSL 1.0.1 users should upgrade to 1.0.1n + +Action +------ + +xCAT uses OpenSSL for client-server communication but **does not** ship it. It uses the default ciphers from openssl. It also allows the user to customize it through site.xcatsslversion and site.xcatsslciphers. Please make sure you do not enable DH or DHE ciphers. + +Please get the latest openssl package from the os distros and upgrade it on all the xCAT management nodes, the service nodes and xCAT client nodes. diff --git a/docs/source/security/2015/20151203_openssl.rst b/docs/source/security/2015/20151203_openssl.rst new file mode 100644 index 000000000..da5e9e772 --- /dev/null +++ b/docs/source/security/2015/20151203_openssl.rst @@ -0,0 +1,42 @@ +2015-12-03 - OpenSSL Vulnerabilities +==================================== + +OpenSSL announced security fixes on 12/03/15 in the following bulletin: http://openssl.org/news/secadv/20151203.txt + +Advisory CVEs +------------- + +* CVE-2015-3193 - **BN_mod_exp may produce incorrect results on x86_64** (Severity:Moderate) + + OpenSSL 1.0.2 users should upgrade to 1.0.2e + +* CVE-2015-3194 - **Certificate verify crash with missing PSS parameter** (Severity:Moderate) + + OpenSSL 1.0.2 users should upgrade to 1.0.2e + OpenSSL 1.0.1 users should upgrade to 1.0.1q + +* CVE-2015-3195 - **X509_ATTRIBUTE memory leak** (Severity:Moderate) + + OpenSSL 1.0.2 users should upgrade to 1.0.2e + OpenSSL 1.0.1 users should upgrade to 1.0.1q + OpenSSL 1.0.0 users should upgrade to 1.0.0t + OpenSSL 0.9.8 users should upgrade to 0.9.8zh + +* CVE-2015-3196 - **Race condition handling PSK identify hint** (Severity:Low) + + OpenSSL 1.0.2 users should upgrade to 1.0.2d + OpenSSL 1.0.1 users should upgrade to 1.0.1p + OpenSSL 1.0.0 users should upgrade to 1.0.0t + +* CVE-2015-1794 - **Anon DH ServerKeyExchange with 0 p parameter** (Severity:Low) + + OpenSSL 1.0.2 users should upgrade to 1.0.2e + + +Action +------ + +xCAT uses OpenSSL for client-server communication but **does not** ship it. + +It is recommended to keep your OpenSSL levels up-to-date with the indicated versions in the security bulletins to prevent any potential security threats. + diff --git a/docs/source/security/2015/index.rst b/docs/source/security/2015/index.rst new file mode 100644 index 000000000..4da7c1928 --- /dev/null +++ b/docs/source/security/2015/index.rst @@ -0,0 +1,12 @@ +2015 Notices +============ + +.. toctree:: + :maxdepth: 1 + + 20151203_openssl.rst + 20150520_openssl.rst + 20150519_openssl.rst + 20150403_openssl.rst + 20150324_openssl.rst + 20150312_openssl.rst diff --git a/docs/source/security/index.rst b/docs/source/security/index.rst index 9952ab44f..4f9535ac9 100644 --- a/docs/source/security/index.rst +++ b/docs/source/security/index.rst @@ -5,3 +5,4 @@ Security Notices :maxdepth: 2 2016/index.rst + 2015/index.rst From edc454edffb96cc535bbc892d04e290c2a455fe1 Mon Sep 17 00:00:00 2001 From: Victor Hu Date: Thu, 18 Aug 2016 10:51:04 -0400 Subject: [PATCH 073/106] Add the URL for the 16.04.1 mini.iso --- .../manage_clusters/common/deployment/create_img.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/source/guides/admin-guides/manage_clusters/common/deployment/create_img.rst b/docs/source/guides/admin-guides/manage_clusters/common/deployment/create_img.rst index ce750d346..a7dbc54ec 100644 --- a/docs/source/guides/admin-guides/manage_clusters/common/deployment/create_img.rst +++ b/docs/source/guides/admin-guides/manage_clusters/common/deployment/create_img.rst @@ -53,6 +53,8 @@ For ubuntu ppc64le, the initrd.gz shipped with the ISO does not support network [ubuntu 16.04]: http://xcat.org/files/netboot/ubuntu16.04/ppc64el/mini.iso + [ubuntu 16.04.1]: http://xcat.org/files/netboot/ubuntu16.04.1/ppc64el/mini.iso + * Mount mini.iso :: mkdir /tmp/iso From 4396cb3b7189d2e7d74accebd8502ded213bb7a1 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Thu, 18 Aug 2016 15:08:03 -0400 Subject: [PATCH 074/106] Check output of xdsh commaned before continuing --- xCAT-probe/subcmds/image | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/xCAT-probe/subcmds/image b/xCAT-probe/subcmds/image index a79f16ab6..f7a26745a 100755 --- a/xCAT-probe/subcmds/image +++ b/xCAT-probe/subcmds/image @@ -214,9 +214,21 @@ probe_utils->send_msg("$output", "d", "---- Gathering information from all diskl my $pingable_hostname_list = join ",", @pingable_nodes; my $all_xdsh_output = `xdsh $pingable_hostname_list "cat /opt/xcat/xcatinfo"`; my $xcatinfo_image_UUID = ` echo "$all_xdsh_output" | awk -F"=" '/IMAGEUUID/ {gsub(/IMAGEUUID/,"",\$1); gsub(/'"'"'/,"",\$2);; print \$1 \$2}'`; + +# Check to verify xdsh worked and returned some usefull information +if (length($xcatinfo_image_UUID) <= 1) { + probe_utils->send_msg("$output", "w", "Unable to extract image UUID information from compute nodes using xdsh command. No image consistency verification will be performed."); + exit 1; +} my @xdsh_UUID_lines = split("[\n\r]", $xcatinfo_image_UUID); my $xcatinfo_image_name = ` echo "$all_xdsh_output" | awk -F"=" '/IMAGENAME/ {gsub(/IMAGENAME/,"",\$1); gsub(/'"'"'/,"",\$2); print \$1 \$2}'`; + +# Check to verify xdsh worked and returned some usefull information +if (length($xcatinfo_image_name) <= 1) { + probe_utils->send_msg("$output", "w", "Unable to extract image name information from compute nodes using xdsh command. No image consistency verification will be performed."); + exit 1; +} my @xdsh_name_lines = split("[\n\r]", $xcatinfo_image_name); my %node_running_image_uuid_hash; From a89c5c6c7592cadc8bcff0919f88420841f1d251 Mon Sep 17 00:00:00 2001 From: Xiaopeng Wang Date: Fri, 19 Aug 2016 16:56:31 +0800 Subject: [PATCH 075/106] add release info for 2.12.2 --- docs/source/overview/xcat2_release.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/source/overview/xcat2_release.rst b/docs/source/overview/xcat2_release.rst index 1f128f855..f3d2da69a 100644 --- a/docs/source/overview/xcat2_release.rst +++ b/docs/source/overview/xcat2_release.rst @@ -14,6 +14,14 @@ xCAT 2.12.x |xCAT |New OS |New |New Feature | |Version | |Hardware | | +=================================+===============+=============+==================================+ +|| xCAT 2.12.2 |- UBT 16.04.1 | |- nodeset offline | +|| 2016/08/19 | | |- Enhance: node status update | +|| | | |- Support Bond for install nics | +| `2.12.2 Release Notes `_ | | | | +| | | | | ++---------------------------------+---------------+-------------+----------------------------------+ || xCAT 2.12.1 | | |- New xCAT install tool: go-xcat | || 2016/07/08 | | |- New opt: mkdef/lsdef --template | || | | |- Support rinstall for all OS/ARCH| From cbf665f2d1c31c580dec3f9d57beb06ee0116975 Mon Sep 17 00:00:00 2001 From: Xiaopeng Wang Date: Fri, 19 Aug 2016 18:12:04 +0800 Subject: [PATCH 076/106] bump up the version to 2.12.3 --- Version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Version b/Version index 371a952d6..ccc99d021 100644 --- a/Version +++ b/Version @@ -1 +1 @@ -2.12.2 +2.12.3 From c4a536a18f46cae82c0c5943b68715bdbaea237b Mon Sep 17 00:00:00 2001 From: penguhyang Date: Mon, 22 Aug 2016 13:39:09 +0800 Subject: [PATCH 077/106] use the same way to promote error msg (#1749) --- xCAT-server/lib/xcat/plugins/packimage.pm | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/packimage.pm b/xCAT-server/lib/xcat/plugins/packimage.pm index 216e21ae1..c1963d207 100755 --- a/xCAT-server/lib/xcat/plugins/packimage.pm +++ b/xCAT-server/lib/xcat/plugins/packimage.pm @@ -417,7 +417,6 @@ sub process_request { $callback->({ error => ["$rootimg_dir does not exist, run genimage -o $osver -p $profile on a server with matching architecture"] }); return 1; } - $callback->({ data => ["Packing contents of $rootimg_dir"] }); my $suffix; if ($compress) { @@ -462,6 +461,11 @@ sub process_request { $suffix = "gz"; } + unless (($method eq 'cpio') or ($method eq 'tar') or ($method eq 'squashfs')) { + $callback->({ error => ["Invalid archive method '$method' requested"], errorcode => [1] }); + return 1; + } + $callback->({ data => ["Packing contents of $rootimg_dir"] }); $callback->({ info => ["archive method:$method"] }); unless ($method =~ /squashfs/) { $callback->({ info => ["compress method:$compress"] }); @@ -517,9 +521,6 @@ sub process_request { system("$includestr >> $xcat_packimg_tmpfile"); } $excludestr = "cat $xcat_packimg_tmpfile|cpio -dump $temppath"; - } else { - $callback->({ error => ["Invalid archive method '$method' requested"], errorcode => [1] }); - return 1; } chdir("$rootimg_dir"); From 310ba8c1aaeaca569f58df1236e302308b599abc Mon Sep 17 00:00:00 2001 From: GONG Jie Date: Mon, 22 Aug 2016 15:53:21 +0800 Subject: [PATCH 078/106] [xCAT Jenkins Email Report] Fix a issue while no test was run in a day. Handle NULL properly --- .../jenkins/testreport/xCATjkLogAnalyzer.sql | 56 +++++++++---------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/xCAT-server/share/xcat/tools/jenkins/testreport/xCATjkLogAnalyzer.sql b/xCAT-server/share/xcat/tools/jenkins/testreport/xCATjkLogAnalyzer.sql index 93dd428b0..e10e9eda0 100644 --- a/xCAT-server/share/xcat/tools/jenkins/testreport/xCATjkLogAnalyzer.sql +++ b/xCAT-server/share/xcat/tools/jenkins/testreport/xCATjkLogAnalyzer.sql @@ -466,7 +466,7 @@ NOW(), ' ', REPLACE(CONCAT('+', TIME_FORMAT(TIMEDIFF(NOW(), UTC_TIMESTAMP), '%H% '' ) AS HTML FROM ( -SELECT GROUP_CONCAT(HTML SEPARATOR '') AS HTML +SELECT IFNULL(GROUP_CONCAT(HTML SEPARATOR ''), '') AS HTML FROM ( SELECT CONCAT( 'Total', "\n", '-', "\n", '', -SEC_TO_TIME(SUM(TIME_TO_SEC(Duration))), '', "\n" +IFNULL(SEC_TO_TIME(SUM(TIME_TO_SEC(Duration))), 'N/A'), '', "\n" '', -SUM(Passed), '', "\n", +IFNULL(SUM(Passed), 'N/A'), '', "\n", '', -SUM(Failed), '', "\n", +IFNULL(SUM(Failed), 'N/A'), '', "\n", '', -SUM(`No run`), '', "\n", +IFNULL(SUM(`No run`), 'N/A'), '', "\n", '', -SUM(Subtotal), '', "\n", +IFNULL(SUM(Subtotal), 'N/A'), '', "\n", '', IFNULL(CONCAT(ROUND(SUM(Passed) / (SUM(Passed) + SUM(Failed)) * 100, 2), '%'), 'N/A'), '', "\n", '', "\n" ) AS HTML FROM LatestDailyReport ) AS LatestDailyReportSummary, ( -SELECT GROUP_CONCAT(HTML SEPARATOR '') AS HTML +SELECT IFNULL(GROUP_CONCAT(HTML SEPARATOR ''), '') AS HTML FROM ( SELECT CONCAT( 'Total', "\n", '-', "\n", '', -SUM(`Test runs`), '', "\n", +IFNULL(SUM(`Test runs`), 'N/A'), '', "\n", '', -SUM(Passed), '', "\n", +IFNULL(SUM(Passed), 'N/A'), '', "\n", '', -SUM(Failed), '', "\n", +IFNULL(SUM(Failed), 'N/A'), '', "\n", '', -SUM(`No run`), '', "\n", +IFNULL(SUM(`No run`), 'N/A'), '', "\n", '', -SUM(Subtotal), '', "\n", +IFNULL(SUM(Subtotal), 'N/A'), '', "\n", '', IFNULL(CONCAT(ROUND(SUM(Passed) / (SUM(Passed) + SUM(Failed)) * 100, 2), '%'), 'N/A'), '', "\n", '', "\n" ) AS HTML FROM SevenDayLookBack ) AS SevenDayLookBackSummary, ( -SELECT GROUP_CONCAT(HTML SEPARATOR '') AS HTML +SELECT IFNULL(GROUP_CONCAT(HTML SEPARATOR ''), '') AS HTML FROM ( SELECT CONCAT( 'Total', "\n", '-', "\n", '', -SUM(`Test runs`), '', "\n", +IFNULL(SUM(`Test runs`), 'N/A'), '', "\n", '', -SUM(Passed), '', "\n", +IFNULL(SUM(Passed), 'N/A'), '', "\n", '', -SUM(Failed), '', "\n", +IFNULL(SUM(Failed), 'N/A'), '', "\n", '', -SUM(`No run`), '', "\n", +IFNULL(SUM(`No run`), 'N/A'), '', "\n", '', -SUM(Subtotal), '', "\n", +IFNULL(SUM(Subtotal), 'N/A'), '', "\n", '', IFNULL(CONCAT(ROUND(SUM(Passed) / (SUM(Passed) + SUM(Failed)) * 100, 2), '%'), 'N/A'), '', "\n", '', "\n" ) AS HTML FROM ThirtyDayLookBack ) AS ThirtyDayLookBackSummary, ( -SELECT GROUP_CONCAT(HTML SEPARATOR '') AS HTML +SELECT IFNULL(GROUP_CONCAT(HTML SEPARATOR ''), '') AS HTML FROM ( SELECT CONCAT( 'Total', "\n", '-', "\n", '', -SUM(`Test runs`), '', "\n", +IFNULL(SUM(`Test runs`), 'N/A'), '', "\n", '', -SUM(Passed), '', "\n", +IFNULL(SUM(Passed), 'N/A'), '', "\n", '', -SUM(Failed), '', "\n", +IFNULL(SUM(Failed), 'N/A'), '', "\n", '', -SUM(`No run`), '', "\n", +IFNULL(SUM(`No run`), 'N/A'), '', "\n", '', -SUM(Subtotal), '', "\n", +IFNULL(SUM(Subtotal), 'N/A'), '', "\n", '', IFNULL(CONCAT(ROUND(SUM(Passed) / (SUM(Passed) + SUM(Failed)) * 100, 2), '%'), 'N/A'), '', "\n", '', "\n" ) AS HTML FROM NinetyDayLookBack ) AS NinetyDayLookBackSummary, ( -SELECT GROUP_CONCAT(HTML SEPARATOR '') AS HTML +SELECT IFNULL(GROUP_CONCAT(HTML SEPARATOR ''), '') AS HTML FROM ( SELECT CONCAT( ' Date: Tue, 23 Aug 2016 22:05:32 -0400 Subject: [PATCH 080/106] update cases since -o -p and -a is not supported anymore --- xCAT-test/autotest/testcase/packimg/cases0 | 32 +++++----------------- 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/xCAT-test/autotest/testcase/packimg/cases0 b/xCAT-test/autotest/testcase/packimg/cases0 index 5029ab9d7..b7b7d398f 100644 --- a/xCAT-test/autotest/testcase/packimg/cases0 +++ b/xCAT-test/autotest/testcase/packimg/cases0 @@ -8,7 +8,7 @@ cmd:genimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute check:rc==0 cmd:ls -l /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg check:rc==0 -cmd:packimage -o __GETNODEATTR($$CN,os)__ -p compute -a __GETNODEATTR($$CN,arch)__ -m cpio +cmd:packimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute -m cpio check:rc==0 cmd:ls -l /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.cpio.gz check:rc==0 @@ -18,24 +18,6 @@ cmd:rm -rf /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/ cmd:mv -f /rootimg.bak /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg end -start:packimage_p_a_o -os:Linux -cmd:ls /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg;if [ $? -eq 0 ];then mv -f /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg /rootimg.bak;fi -cmd:ls /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.cpio.gz;if [ $? -eq 0 ];then mv -f /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.cpio.gz /rootimg.cpio.gz.bak;fi -cmd:genimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute -check:rc==0 -cmd:ls -l /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg -check:rc==0 -cmd:packimage -p compute -a __GETNODEATTR($$CN,arch)__ -o __GETNODEATTR($$CN,os)__ -check:rc==0 -cmd:ls -l /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.cpio.gz -check:rc==0 -cmd:rm -rf /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.cpio.gz -cmd:mv -f /rootimg.cpio.gz.bak /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg.cpio.gz -cmd:rm -rf /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg -cmd:mv -f /rootimg.bak /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg -end - start:packimage_imagename os:Linux description: @@ -79,7 +61,7 @@ cmd:genimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute check:rc==0 cmd:ls -l /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg check:rc==0 -cmd:packimage -o __GETNODEATTR($$CN,os)__ -p compute -a __GETNODEATTR($$CN,arch)__ -m cpio -c gzip +cmd:packimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute -m cpio -c gzip check:rc==0 check:output=~archive method:cpio check:output=~compress method:gzip @@ -125,7 +107,7 @@ cmd:if grep SUSE /etc/*release;then zypper install -y pigz;fi check:rc==0 cmd:if grep Ubuntu /etc/*release;then apt-get install pigz -y; fi check:rc==0 -cmd:packimage -o __GETNODEATTR($$CN,os)__ -p compute -a __GETNODEATTR($$CN,arch)__ -m cpio -c pigz +cmd:packimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute -m cpio -c pigz check:rc==0 check:output=~archive method:cpio check:output=~compress method:pigz @@ -167,7 +149,7 @@ cmd:genimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute check:rc==0 cmd:ls -l /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg check:rc==0 -cmd:packimage -o __GETNODEATTR($$CN,os)__ -p compute -a __GETNODEATTR($$CN,arch)__ -m cpio -c xz +cmd:packimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute -m cpio -c xz check:rc==0 check:output=~archive method:cpio check:output=~compress method:xz @@ -213,7 +195,7 @@ cmd:if grep SUSE /etc/*release;then zypper install -y pigz;fi check:rc==0 cmd:if grep Ubuntu /etc/*release;then apt-get install pigz -y; fi check:rc==0 -cmd:packimage -o __GETNODEATTR($$CN,os)__ -p compute -a __GETNODEATTR($$CN,arch)__ -m tar -c pigz +cmd:packimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute -m tar -c pigz check:rc==0 check:output=~archive method:tar check:output=~compress method:pigz @@ -255,7 +237,7 @@ cmd:genimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute check:rc==0 cmd:ls -l /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg check:rc==0 -cmd:packimage -o __GETNODEATTR($$CN,os)__ -p compute -a __GETNODEATTR($$CN,arch)__ -m tar -c gzip +cmd:packimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute -m tar -c gzip check:rc==0 check:output=~archive method:tar check:output=~compress method:gzip @@ -297,7 +279,7 @@ cmd:genimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute check:rc==0 cmd:ls -l /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg check:rc==0 -cmd:packimage -o __GETNODEATTR($$CN,os)__ -p compute -a __GETNODEATTR($$CN,arch)__ -m tar -c xz +cmd:packimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute -m tar -c xz check:rc==0 check:output=~archive method:tar check:output=~compress method:xz From 55968a0321cda953d61caa3b91872b1bdf269c1f Mon Sep 17 00:00:00 2001 From: caomengmeng Date: Wed, 24 Aug 2016 10:59:29 +0800 Subject: [PATCH 081/106] delete long time wait sleep delete long time wait sleep --- xCAT-test/autotest/testcase/packimg/cases0 | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/xCAT-test/autotest/testcase/packimg/cases0 b/xCAT-test/autotest/testcase/packimg/cases0 index 5029ab9d7..c3a65a7fc 100644 --- a/xCAT-test/autotest/testcase/packimg/cases0 +++ b/xCAT-test/autotest/testcase/packimg/cases0 @@ -89,8 +89,7 @@ cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-net check:rc==0 cmd:if [[ "__GETNODEATTR($$CN,arch)__" = "ppc64" ]]; then rnetboot $$CN;else rpower $$CN boot; fi check:rc==0 -cmd:sleep 900 -cmd:a=0;while ! `lsdef -l $$CN|grep status|grep booted >/dev/null`; do sleep 10;((a++));if [ $a -gt 60 ];then break;fi done +cmd:a=0;while ! `lsdef -l $$CN|grep status|grep booted >/dev/null`; do sleep 10;((a++));if [ $a -gt 150 ];then break;fi done cmd:ping $$CN -c 3 check:rc==0 check:output=~64 bytes from $$CN @@ -135,8 +134,7 @@ cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-net check:rc==0 cmd:if [[ "__GETNODEATTR($$CN,arch)__" = "ppc64" ]]; then rnetboot $$CN;else rpower $$CN boot; fi check:rc==0 -cmd:sleep 900 -cmd:a=0;while ! `lsdef -l $$CN|grep status|grep booted >/dev/null`; do sleep 10;((a++));if [ $a -gt 60 ];then break;fi done +cmd:a=0;while ! `lsdef -l $$CN|grep status|grep booted >/dev/null`; do sleep 10;((a++));if [ $a -gt 150 ];then break;fi done cmd:ping $$CN -c 3 check:rc==0 check:output=~64 bytes from $$CN @@ -177,8 +175,7 @@ cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-net check:rc==0 cmd:if [[ "__GETNODEATTR($$CN,arch)__" = "ppc64" ]]; then rnetboot $$CN;else rpower $$CN boot; fi check:rc==0 -cmd:sleep 900 -cmd:a=0;while ! `lsdef -l $$CN|grep status|grep booted >/dev/null`; do sleep 10;((a++));if [ $a -gt 60 ];then break;fi done +cmd:a=0;while ! `lsdef -l $$CN|grep status|grep booted >/dev/null`; do sleep 10;((a++));if [ $a -gt 150 ];then break;fi done cmd:ping $$CN -c 3 check:rc==0 check:output=~64 bytes from $$CN @@ -223,8 +220,7 @@ cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-net check:rc==0 cmd:if [[ "__GETNODEATTR($$CN,arch)__" = "ppc64" ]]; then rnetboot $$CN;else rpower $$CN boot; fi check:rc==0 -cmd:sleep 900 -cmd:a=0;while ! `lsdef -l $$CN|grep status|grep booted >/dev/null`; do sleep 10;((a++));if [ $a -gt 60 ];then break;fi done +cmd:a=0;while ! `lsdef -l $$CN|grep status|grep booted >/dev/null`; do sleep 10;((a++));if [ $a -gt 150 ];then break;fi done cmd:ping $$CN -c 3 check:rc==0 check:output=~64 bytes from $$CN @@ -265,8 +261,7 @@ cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-net check:rc==0 cmd:if [[ "__GETNODEATTR($$CN,arch)__" = "ppc64" ]]; then rnetboot $$CN;else rpower $$CN boot; fi check:rc==0 -cmd:sleep 900 -cmd:a=0;while ! `lsdef -l $$CN|grep status|grep booted >/dev/null`; do sleep 10;((a++));if [ $a -gt 60 ];then break;fi done +cmd:a=0;while ! `lsdef -l $$CN|grep status|grep booted >/dev/null`; do sleep 10;((a++));if [ $a -gt 150 ];then break;fi done cmd:ping $$CN -c 3 check:rc==0 check:output=~64 bytes from $$CN @@ -307,8 +302,7 @@ cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-net check:rc==0 cmd:if [[ "__GETNODEATTR($$CN,arch)__" = "ppc64" ]]; then rnetboot $$CN;else rpower $$CN boot; fi check:rc==0 -cmd:sleep 900 -cmd:a=0;while ! `lsdef -l $$CN|grep status|grep booted >/dev/null`; do sleep 10;((a++));if [ $a -gt 60 ];then break;fi done +cmd:a=0;while ! `lsdef -l $$CN|grep status|grep booted >/dev/null`; do sleep 10;((a++));if [ $a -gt 150 ];then break;fi done cmd:ping $$CN -c 3 check:rc==0 check:output=~64 bytes from $$CN From 4c1c47e2425d449b8b4119033186e1f1712b59b0 Mon Sep 17 00:00:00 2001 From: caomengmeng Date: Wed, 24 Aug 2016 11:06:23 +0800 Subject: [PATCH 082/106] delete long time wait sleep delete long time wait sleep --- xCAT-test/autotest/testcase/runcmdinstaller/cases0 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-test/autotest/testcase/runcmdinstaller/cases0 b/xCAT-test/autotest/testcase/runcmdinstaller/cases0 index f39db8a1a..2ad618f19 100644 --- a/xCAT-test/autotest/testcase/runcmdinstaller/cases0 +++ b/xCAT-test/autotest/testcase/runcmdinstaller/cases0 @@ -28,7 +28,7 @@ cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-ins check:rc==0 cmd:if [[ "__GETNODEATTR($$CN,arch)__" =~ "ppc64" ]]; then rnetboot $$CN;elif [[ "__GETNODEATTR($$CN,arch)__" =~ "x86_64" ]];then rpower $$CN boot; fi check:rc==0 -cmd:sleep 1200 +cmd:a=0;while ! `lsdef -l $$CN|grep status|grep booted >/dev/null`; do sleep 10;((a++));if [ $a -gt 300 ];then break;fi done cmd:cat /var/log/messages /var/log/xcat/computes.log 2>/dev/null | grep "Running post-installation scripts" cmd:rc==0 cmd:cat /var/log/messages /var/log/xcat/computes.log 2>/dev/null | grep "program: ++" From 816376645e391c4cd4b373e2a3c3365d12a6b1e0 Mon Sep 17 00:00:00 2001 From: caomengmeng Date: Wed, 24 Aug 2016 11:15:53 +0800 Subject: [PATCH 083/106] delete long time wait sleep --- .../installation/reg_linux_diskfull_installation_flat | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/xCAT-test/autotest/testcase/installation/reg_linux_diskfull_installation_flat b/xCAT-test/autotest/testcase/installation/reg_linux_diskfull_installation_flat index 5ee4a9d22..242c77ea3 100644 --- a/xCAT-test/autotest/testcase/installation/reg_linux_diskfull_installation_flat +++ b/xCAT-test/autotest/testcase/installation/reg_linux_diskfull_installation_flat @@ -35,11 +35,8 @@ check:rc==0 cmd:if [ "__GETNODEATTR($$CN,mgt)__" != "ipmi" ];then if [ "__GETNODEATTR($$CN,arch)__" = "ppc64" ];then rnetboot $$CN;else rpower $$CN boot;fi else rpower $$CN boot;fi check:rc==0 -cmd:if [[ "__GETNODEATTR($$CN,mgt)__" =~ "ipmi" ]]; then sleep 1800;elif [[ "__GETNODEATTR($$CN,arch)__" =~ "ppc64" ]];then sleep 1200;else sleep 600;fi - -cmd:lsdef -l $$CN | grep status - -cmd:a=0;while ! `lsdef -l $$CN|grep status|grep booted >/dev/null`; do sleep 10;((a++));if [ $a -gt 300 ];then break;fi done +cmd:sleep 300 +cmd:a=0;while ! `lsdef -l $$CN|grep status|grep booted >/dev/null`; do sleep 20;((a++));if [ $a -gt 300 ];then break;fi done cmd:ping $$CN -c 3 check:rc==0 From ce65a730ff8395992e4a4b9aa5234fec345bdb7b Mon Sep 17 00:00:00 2001 From: caomengmeng Date: Wed, 24 Aug 2016 11:18:57 +0800 Subject: [PATCH 084/106] delete long time wait sleep --- .../installation/ubuntu_full_installation_vm_docker | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xCAT-test/autotest/testcase/installation/ubuntu_full_installation_vm_docker b/xCAT-test/autotest/testcase/installation/ubuntu_full_installation_vm_docker index 15dcce60a..cca833817 100644 --- a/xCAT-test/autotest/testcase/installation/ubuntu_full_installation_vm_docker +++ b/xCAT-test/autotest/testcase/installation/ubuntu_full_installation_vm_docker @@ -26,10 +26,10 @@ cmd:nodeset $$CN osimage=__GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-in check:rc==0 cmd:rpower $$CN boot check:rc==0 -cmd:sleep 40 -cmd:lsdef -l $$CN | grep status -cmd:sleep 2400 -check:rc==0 + +cmd:sleep 900 +cmd:a=0;while ! `lsdef -l $$CN|grep status|grep booted >/dev/null`; do sleep 10;((a++));if [ $a -gt 60 ];then break;fi done + cmd:ping $$CN -c 3 check:output=~64 bytes from $$CN check:rc==0 From a4abdbffae687f4d514a87e2a77ec0f526af4f1d Mon Sep 17 00:00:00 2001 From: caomengmeng Date: Wed, 24 Aug 2016 11:26:38 +0800 Subject: [PATCH 085/106] delete stop label --- xCAT-test/autotest/testcase/migration/redhat_migration | 1 - 1 file changed, 1 deletion(-) diff --git a/xCAT-test/autotest/testcase/migration/redhat_migration b/xCAT-test/autotest/testcase/migration/redhat_migration index 472a71644..a0495ec39 100644 --- a/xCAT-test/autotest/testcase/migration/redhat_migration +++ b/xCAT-test/autotest/testcase/migration/redhat_migration @@ -1,7 +1,6 @@ start:redhat_migration1 os:Linux description:update xCAT from $$MIGRATION1_VERSION to $$LATEST_VERSION, these two global parameter defined in config file -stop:yes #cmd:if ping -c 1 $$SN > /dev/null;then rpower $$SN off > /dev/null;fi #cmd:chdef -t node -o $$CN servicenode= monserver=$$MN nfsserver=$$MN tftpserver=$$MN xcatmaster=$$MN From c93b215c2c1fe101d34016fadf97a05d089bddb8 Mon Sep 17 00:00:00 2001 From: penguhyang Date: Wed, 24 Aug 2016 12:13:36 +0800 Subject: [PATCH 086/106] fix sles11.4 packimage return error when use tar compress method (#1743) --- xCAT-server/lib/xcat/plugins/packimage.pm | 23 +++++++++---------- .../xcat/netboot/sles/dracut_033/xcatroot | 6 +++++ xCAT-server/share/xcat/netboot/sles/genimage | 10 ++++++-- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/packimage.pm b/xCAT-server/lib/xcat/plugins/packimage.pm index c1963d207..d0434eb06 100755 --- a/xCAT-server/lib/xcat/plugins/packimage.pm +++ b/xCAT-server/lib/xcat/plugins/packimage.pm @@ -491,25 +491,24 @@ sub process_request { } $oldmask = umask 0077; } elsif ($method =~ /tar/) { + my $checkoption1 = `tar --xattrs-include 2>&1`; + my $checkoption2 = `tar --selinux 2>&1`; + my $option; + if ($checkoption1 !~ /unrecognized/) { + $option .= "--xattrs-include='*' "; + } + if ($checkoption2 !~ /unrecognized/) { + $option .= "--selinux "; + } if (!$exlistloc) { - my $checkoption = `tar --xattrs-include 2>&1`; - if ($checkoption =~ /unrecognized/) { - $excludestr = "find . -xdev -print0 | tar --selinux --no-recursion --use-compress-program=$compress --null -T - -cf ../rootimg.$suffix"; - } else { - $excludestr = "find . -xdev -print0 | tar --selinux --xattrs-include='*' --no-recursion --use-compress-program=$compress --null -T - -cf ../rootimg.$suffix"; - } + $excludestr = "find . -xdev -print0 | tar $option --no-recursion --use-compress-program=$compress --null -T - -cf ../rootimg.$suffix"; } else { chdir("$rootimg_dir"); system("$excludestr >> $xcat_packimg_tmpfile"); if ($includestr) { system("$includestr >> $xcat_packimg_tmpfile"); } - my $checkoption = `tar --xattrs-include 2>&1`; - if ($checkoption =~ /unrecognized/) { - $excludestr = "cat $xcat_packimg_tmpfile| tar --selinux --no-recursion --use-compress-program=$compress -T - -cf ../rootimg.$suffix"; - } else { - $excludestr = "cat $xcat_packimg_tmpfile| tar --selinux --xattrs-include='*' --no-recursion --use-compress-program=$compress -T - -cf ../rootimg.$suffix"; - } + $excludestr = "cat $xcat_packimg_tmpfile| tar $option --no-recursion --use-compress-program=$compress -T - -cf ../rootimg.$suffix"; } $oldmask = umask 0077; } elsif ($method =~ /squashfs/) { diff --git a/xCAT-server/share/xcat/netboot/sles/dracut_033/xcatroot b/xCAT-server/share/xcat/netboot/sles/dracut_033/xcatroot index b12eb9a3f..80b366d9a 100755 --- a/xCAT-server/share/xcat/netboot/sles/dracut_033/xcatroot +++ b/xCAT-server/share/xcat/netboot/sles/dracut_033/xcatroot @@ -109,8 +109,14 @@ elif [ -r /rootimg.tar.gz ] || [ -r /rootimg.tar.xz ]; then echo -n "Extracting root filesystem:" if [ -r /rootimg.tar.gz ]; then tar --selinux --xattrs-include='*' -zxf /rootimg.tar.gz + if [ $? -ne 0 ]; then + tar -zxf /rootimg.tar.gz + fi elif [ -r /rootimg.tar.xz ]; then tar --selinux --xattrs-include='*' -Jxf /rootimg.tar.xz + if [ $? -ne 0 ]; then + tar -Jxf /rootimg.tar.xz + fi fi $NEWROOT/etc/init.d/localdisk [ "$xcatdebugmode" > "0" ] && logger -t xcat -p debug "Done...." diff --git a/xCAT-server/share/xcat/netboot/sles/genimage b/xCAT-server/share/xcat/netboot/sles/genimage index 23ca97d2c..e4d0d7686 100755 --- a/xCAT-server/share/xcat/netboot/sles/genimage +++ b/xCAT-server/share/xcat/netboot/sles/genimage @@ -1659,8 +1659,14 @@ EOMS print $inifile " echo -n \"Extracting root filesystem:\"\n"; print $inifile " if [ -r /rootimg.tar.gz ]; then\n"; print $inifile " tar --selinux --xattrs-include='*' -zxf /rootimg.tar.gz\n"; + print $inifile " if [ \$? -ne 0 ]; then\n"; + print $inifile " tar -zxf /rootimg.tar.gz\n"; + print $inifile " fi\n"; print $inifile " elif [ -r /rootimg.tar.xz ]; then\n"; print $inifile " tar --selinux --xattrs-include='*' -Jxf /rootimg.tar.xz\n"; + print $inifile " if [ \$? -ne 0 ]; then\n"; + print $inifile " tar -Jxf /rootimg.tar.xz\n"; + print $inifile " fi\n"; print $inifile " fi\n"; print $inifile " echo Done\n"; print $inifile "else\n"; @@ -1770,7 +1776,7 @@ EOMS } } if ($mode eq "statelite") { - foreach ("sbin/ifconfig", "usr/bin/clear", "usr/bin/touch", "bin/hostname", "usr/bin/egrep", "bin/ln", "bin/ls", "usr/bin/dirname", "usr/bin/expr", "usr/bin/chroot", "usr/bin/grep", "bin/cpio", "bin/sleep", "bin/mount", "bin/umount", "sbin/dhcpcd", "bin/bash", "sbin/insmod", "bin/mkdir", "bin/mknod", "sbin/ip", "bin/cat", "usr/bin/awk", "usr/bin/wget", "bin/cp", "usr/bin/cpio", "usr/bin/zcat", "usr/bin/gzip", "lib/mkinitrd/bin/run-init", "usr/bin/uniq", "usr/bin/sed", "usr/bin/wc", "bin/sed", "sbin/udevd", "usr/bin/readlink", "usr/sbin/parted", "sbin/mke2fs", "sbin/mkswap", "sbin/swapon", "bin/chmod", "usr/bin/bc", "usr/bin/xz", "usr/bin/gzip", "usr/bin/tar") { + foreach ("sbin/ifconfig", "usr/bin/clear", "usr/bin/touch", "bin/hostname", "usr/bin/egrep", "bin/ln", "bin/ls", "usr/bin/dirname", "usr/bin/expr", "usr/bin/chroot", "usr/bin/grep", "bin/cpio", "bin/sleep", "bin/mount", "bin/umount", "sbin/dhcpcd", "bin/bash", "sbin/insmod", "bin/mkdir", "bin/mknod", "sbin/ip", "bin/cat", "usr/bin/awk", "usr/bin/wget", "bin/cp", "usr/bin/cpio", "usr/bin/zcat", "usr/bin/gzip", "lib/mkinitrd/bin/run-init", "usr/bin/uniq", "usr/bin/sed", "usr/bin/wc", "bin/sed", "sbin/udevd", "usr/bin/readlink", "usr/sbin/parted", "sbin/mke2fs", "sbin/mkswap", "sbin/swapon", "bin/chmod", "usr/bin/bc", "usr/bin/xz", "usr/bin/gzip", "bin/tar") { getlibs($_); push @filestoadd, $_; } @@ -1782,7 +1788,7 @@ EOMS } } else { - foreach ("sbin/ifconfig", "usr/bin/clear", "usr/bin/touch", "usr/bin/grep", "usr/bin/egrep", "bin/cpio", "bin/sleep", "bin/mount", "sbin/dhcpcd", "bin/bash", "sbin/insmod", "bin/mkdir", "bin/mknod", "sbin/ip", "bin/cat", "usr/bin/awk", "usr/bin/wget", "bin/cp", "usr/bin/cpio", "usr/bin/zcat", "usr/bin/gzip", "lib/mkinitrd/bin/run-init", "usr/bin/uniq", "usr/bin/sed", "sbin/udevd", "usr/bin/readlink", "usr/bin/expr", "usr/sbin/parted", "sbin/mke2fs", "sbin/mkswap", "sbin/swapon", "bin/chmod", "usr/bin/bc", "usr/bin/xz", "usr/bin/gzip", "usr/bin/tar") { + foreach ("sbin/ifconfig", "usr/bin/clear", "usr/bin/touch", "usr/bin/grep", "usr/bin/egrep", "bin/cpio", "bin/sleep", "bin/mount", "sbin/dhcpcd", "bin/bash", "sbin/insmod", "bin/mkdir", "bin/mknod", "sbin/ip", "bin/cat", "usr/bin/awk", "usr/bin/wget", "bin/cp", "usr/bin/cpio", "usr/bin/zcat", "usr/bin/gzip", "lib/mkinitrd/bin/run-init", "usr/bin/uniq", "usr/bin/sed", "sbin/udevd", "usr/bin/readlink", "usr/bin/expr", "usr/sbin/parted", "sbin/mke2fs", "sbin/mkswap", "sbin/swapon", "bin/chmod", "usr/bin/bc", "usr/bin/xz", "usr/bin/gzip", "bin/tar") { getlibs($_); push @filestoadd, $_; } From ea839ee02ae4c42194c0447ac68797180ff54882 Mon Sep 17 00:00:00 2001 From: "litingt@cn.ibm.com" Date: Wed, 24 Aug 2016 03:14:00 -0400 Subject: [PATCH 087/106] increase the time since we add some time-consuming test cases --- xCAT-server/share/xcat/tools/jenkins/xcatjktest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-server/share/xcat/tools/jenkins/xcatjktest b/xCAT-server/share/xcat/tools/jenkins/xcatjktest index ffec553af..0518cd60e 100755 --- a/xCAT-server/share/xcat/tools/jenkins/xcatjktest +++ b/xCAT-server/share/xcat/tools/jenkins/xcatjktest @@ -1277,7 +1277,7 @@ while(! $sub_process_rt) { } } - if(time() - $regstarttime > 28800) { + if(time() - $regstarttime > 36000) { send_msg(1, "[timing] 8 hours is expired"); last; } From 6a242e8936e1fbf45126fc32b4b1b4c902542ccd Mon Sep 17 00:00:00 2001 From: "litingt@cn.ibm.com" Date: Wed, 24 Aug 2016 03:21:15 -0400 Subject: [PATCH 088/106] update the message --- xCAT-server/share/xcat/tools/jenkins/xcatjktest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-server/share/xcat/tools/jenkins/xcatjktest b/xCAT-server/share/xcat/tools/jenkins/xcatjktest index 0518cd60e..55c1306c5 100755 --- a/xCAT-server/share/xcat/tools/jenkins/xcatjktest +++ b/xCAT-server/share/xcat/tools/jenkins/xcatjktest @@ -1278,7 +1278,7 @@ while(! $sub_process_rt) { } if(time() - $regstarttime > 36000) { - send_msg(1, "[timing] 8 hours is expired"); + send_msg(1, "[timing] 10 hours is expired"); last; } sleep 1; From bc48e8520524c60e64feefdd100174fbd426dc5c Mon Sep 17 00:00:00 2001 From: junxiawang Date: Wed, 24 Aug 2016 08:49:05 -0400 Subject: [PATCH 089/106] modify genesis test code --- xCAT-test/autotest/testcase/genesis/cases0 | 37 +- .../autotest/testcase/genesis/genesistest.pl | 494 ++++++++++++------ 2 files changed, 346 insertions(+), 185 deletions(-) diff --git a/xCAT-test/autotest/testcase/genesis/cases0 b/xCAT-test/autotest/testcase/genesis/cases0 index 9459ff83d..977261ad0 100644 --- a/xCAT-test/autotest/testcase/genesis/cases0 +++ b/xCAT-test/autotest/testcase/genesis/cases0 @@ -1,48 +1,29 @@ start:nodeset_shell description: verify could log in genesis shell -cmd:nodeset $$CN shell +cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/genesis/genesistest.pl -n $$CN -g check:rc==0 -cmd:rpower $$CN boot +cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/genesis/genesistest.pl -n $$CN -s check:rc==0 -cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/genesis/genesistest.pl -t -n $$CN -cmd:xdsh $$CN cat /proc/cmdline -check:rc==0 -check:output=~destiny=shell -cmd:nodeset $$CN boot -cmd:rpower $$CN boot +cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/genesis/genesistest.pl -n $$CN -c check:rc==0 end start:nodeset_cmdline description:verify could run cmdline successfully -cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/genesis/genesistest.pl -d -r __GETNODEATTR($$CN,arch)__ -cmd:nodeset $$CN runcmd="cmdtest,shell" +cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/genesis/genesistest.pl -n $$CN -g check:rc==0 -cmd:rpower $$CN boot +cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/genesis/genesistest.pl -n $$CN -d check:rc==0 -cmd: perl /opt/xcat/share/xcat/tools/autotest/testcase/genesis/genesistest.pl -t -n $$CN -cmd:xdsh $$CN "cat /tmp/testresult" -check:rc==0 -check:output=~testcmd -cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/genesis/genesistest.pl -c -n $$CN -r __GETNODEATTR($$CN,arch)__ -check:rc==0 -cmd:rpower $$CN boot +cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/genesis/genesistest.pl -n $$CN -c check:rc==0 end start:nodeset_runimg description:verify runimg could work -cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/genesis/genesistest.pl -g -n $$CN -i $$imgip +cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/genesis/genesistest.pl -n $$CN -g check:rc==0 -cmd:rpower $$CN boot +cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/genesis/genesistest.pl -n $$CN -i check:rc==0 -cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/genesis/genesistest.pl -t -n $$CN -check:rc==0 -cmd:xdsh $$CN "cat /tmp/testresult" -check:output=~testimg -check:rc==0 -cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/genesis/genesistest.pl -c -n $$CN -r __GETNODEATTR($$CN,arch)__ -check:rc==0 -cmd:rpower $$CN boot +cmd:perl /opt/xcat/share/xcat/tools/autotest/testcase/genesis/genesistest.pl -n $$CN -c check:rc==0 end diff --git a/xCAT-test/autotest/testcase/genesis/genesistest.pl b/xCAT-test/autotest/testcase/genesis/genesistest.pl index 87a07189f..4ba521608 100755 --- a/xCAT-test/autotest/testcase/genesis/genesistest.pl +++ b/xCAT-test/autotest/testcase/genesis/genesistest.pl @@ -1,6 +1,11 @@ #!/usr/bin/env perl # IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html - +BEGIN +{ + $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : -d '/opt/xcat' ? '/opt/xcat' : '/usr'; +} +use lib "$::XCATROOT/lib/perl"; +use xCAT::Utils; use strict; use warnings; use Getopt::Long; @@ -10,182 +15,357 @@ use Time::Local; use File::Basename; use File::Path; use File::Copy; - -BEGIN -{ - $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : -d '/opt/xcat' ? '/opt/xcat' : '/usr'; -} -use lib "$::XCATROOT/lib/perl"; -my $rungenesiscmd = 0; -my $rungenesisimg = 0; -my $shellmode = 0; -my $cmdtest = "/tmp/cmdtest"; -my $timesleep = 0; +use Sys::Hostname; +my $program_name = basename("$0"); +my $genesis_runcmd_test = 0; +my $genesis_runimg_test = 0; +my $genesis_nodesetshell_test = 0; +my $check_genesis_file; my $noderange; -my $clearenv = 0; -my $arch; -my $imgip; -my $runimgtest = "/tmp/imgtest"; -my $testresult = "/tmp/testresult"; -my $genesisdir = "/opt/xcat/share/xcat/netboot/genesis"; -my $genesisfiledir; - +my $clear_env; +my $help = 0; +$::USAGE = "Usage: + $program_name -h + $program_name -n -s + $program_name -n -d + $program_name -n -i + $program_name -n -c + $program_name -n -g +Description: + Run genesis testcase + There will be default scripts for genesis's runcmd and runimg test if anyone want to use this function to test genesis please write scripts in /tmp/cmdtest for runcmd test and in /tmp/imgtest for runimg test +Options: + -n : The range of node + -i : Run genesis runimage + -d : Run genesis runcmd + -s : Run genesis nodeshell mode + -c : Clear genesis test environment + -g : Check genesis file +"; +################################## +# main process +################################## if ( - !GetOptions("h|?" => \$::HELP, - "d" => \$rungenesiscmd, - "g" => \$rungenesisimg, - "t" => \$timesleep, - "c" => \$clearenv, - "n=s" => \$::NODE, - "i=s" => \$::IMGIP, - "r=s" => \$::ARCH) - ) + !GetOptions("h|?" => \$help, + "s" => \$genesis_nodesetshell_test, + "d" => \$genesis_runcmd_test, + "i" => \$genesis_runimg_test, + "n=s" => \$noderange, + "g" => \$check_genesis_file, + "c" => \$clear_env + )) { - &usage; + send_msg(0, "$::USAGE"); + print "$::USAGE"; exit 1; } - -sub usage -{ - print "Usage:run for genesis cases.\n"; - print " genesistest.pl [-?|-h]\n"; - print " genesistest.pl [-d] [-n node] [-r arch] Test runcmd for genesis \n"; - print " genesistest.pl [-g] [-n ndoe] [-i imgip] Test runimg for genesis\n"; - print " genesistest.pl [-t] [-n node] Sleep for genesis test\n"; - print " genesistest.pl [-c] [-n node][-r arch] Clear environment for genesis test\n"; - print "\n"; - return; +if ($help) { + print "$::USAGE"; + exit 0; } - -sub runcmd -{ - my ($cmd) = @_; - my $rc = 0; - $::RUNCMD_RC = 0; - my $outref = []; - @$outref = `$cmd 2>&1`; - if ($?) - { - $rc = $?; - $rc = $rc >> 8; - $::RUNCMD_RC = $rc; - } - chomp(@$outref); - return @$outref; - +############################### +# init +############################## +if (!defined($noderange)) { + send_msg(0, "Option -n is required"); + print "$::USAGE"; + exit 1; } - -sub rungenesiscmd -{ - open(TESTCMD, ">$cmdtest") - or die "Can't open testscripts for writing: $!"; - print TESTCMD join("\n", "#!/bin/bash"), "\n"; - print TESTCMD join("\n", "#This is test for genesis scripts"), "\n"; - print TESTCMD join("\n", "echo \"testcmd\" >> $testresult"), "\n"; - close(TESTCMD); - if ($arch =~ /ppc64/) - { - $arch = "ppc64"; +my $os = xCAT::Utils->osver("all"); +if ($check_genesis_file) { + send_msg(2, "[$$]:Check genesis file..............."); + &check_genesis_file(&get_arch); + if ($?) { + send_msg(0, "genesis file not available"); + } else { + send_msg(2, "genesis file available"); } - $genesisfiledir = "$genesisdir/$arch/fs/bin"; - copy("$cmdtest", "$genesisfiledir"); - chmod 0755, "$genesisfiledir/cmdtest"; +} +my $master=xCAT::TableUtils->get_site_Master(); +if (!$master) { $master=hostname(); } + +#################################### +####nodesetshell test for genesis +#################################### +if ($genesis_nodesetshell_test) { + send_msg(2, "[$$]:Running nodesetshell test..............."); + `nodeset $noderange shell`; + if ($?) { + send_msg(0, "[$$]:nodeset shell failed..............."); + exit 1; + } + `rpower $noderange boot`; + if ($?) { + send_msg(0, "[$$]:rpower node failed..............."); + exit 1; + } + #run nodeshell test + send_msg(2, "prepare for nodeshell script."); + if ( &testxdsh(3)) { + send_msg(0, "[$$]:Could not verify test results using xdsh..............."); + exit 1; + } + send_msg(2, "[$$]:Running nodesetshell test success..............."); +} +#################################### +####runcmd test for genesis +#################################### +if ($genesis_runcmd_test) { + send_msg(2, "[$$]:Running runcmd test..............."); + if (&testxdsh(&rungenesiscmd(&get_arch))) { + send_msg(0, "[$$]:Could not verify test results using xdsh..............."); + exit 1; + } + send_msg(2, "[$$]:Running runcmd test success..............."); +} +################################## +####runimg test for genesis +################################## +if ($genesis_runimg_test) { + send_msg(2, "[$$]:Run runimg test..............."); + if (&testxdsh(&rungenesisimg)) { + send_msg(0, "[$$]:Could not verify test results using xdsh ..............."); + exit 1; + } + + send_msg(2, "[$$]:Running runimage test success..............."); +} +################################### +####clear test environment +################################### +if ($clear_env) { + send_msg(2, "[$$]:clear genesis test enviroment..............."); + if (&clearenv(&get_arch)) { + send_msg(0, "[$$]:clear environment failed..............."); + exit 1; + } + send_msg(2, "[$$]:clear genesis test enviroment success..............."); +} +################################## +#check_genesis_file +################################# +sub check_genesis_file { + my $arch = shift; + my $genesis_base; + my $genesis_scripts; + if ($os =~ "unknown") { + send_msg(0, "The OS is not supported."); + return 1; + } elsif ($os =~ "ubuntu") { + $genesis_base = `dpkg -l | grep -i "ii xcat-genesis-base" | grep -i "$arch"`; + $genesis_scripts = `dpkg -l | grep -i "ii xcat-genesis-scripts" | grep -i "$arch"`; + } else { + $genesis_base = `rpm -qa | grep -i "xcat-genesis-base" | grep -i "$arch"`; + $genesis_scripts = `rpm -qa | grep -i "xcat-genesis-scripts" | grep -i "$arch"`; + } + unless ($genesis_base and $genesis_scripts) { + send_msg(0, "xCAT-genesis for $arch did not be installed."); + return 1; + } + return 0; +} +################################################### +###write runcmd script to verify runcmd could work +################################################## +sub rungenesiscmd { + my $runcmd_script = "/tmp/cmdtest"; + my $result = "/tmp/testresult"; + my $genesis_base_dir = "$::XCATROOT/share/xcat/netboot/genesis"; + my $genesis_bin_dir; + my $value = 0; + my $arch = shift; + if (!(-e $runcmd_script)) { + $value = 1; + + #means runcmd test using test scripts genesistest.pl writes + send_msg(2, "no runcmd scripts for test prepared."); + open(TESTCMD, ">$runcmd_script") + or die "Can't open testscripts for writing: $!"; + print TESTCMD join("\n", "#!/bin/bash"), "\n"; + print TESTCMD join("\n", "#This is test for genesis scripts"), "\n"; + print TESTCMD join("\n", "echo \"testcmd\" >> $result"), "\n"; + close(TESTCMD); + } else { + $value = 3; + + #means runcmd test using test scripts user writes + send_msg(2, "runcmd scripts for test ready."); + } + $genesis_bin_dir = "$genesis_base_dir/$arch/fs/bin"; + copy("$runcmd_script", "$genesis_bin_dir"); + chmod 0755, "$genesis_bin_dir/cmdtest"; `mknb $arch`; - print "mknb $arch\n"; + if ($?) { + send_msg(0, "mknb $arch failed for runcmd test."); + } + `nodeset $noderange "runcmd=cmdtest,shell"`; + if ($?) { + send_msg(0, "nodeset noderange shell failed for runcmd test"); + } + `rpower $noderange boot`; + if ($?) { + send_msg(0, "rpower noderange boot failed for runcmd test"); + } + return $value; } - -sub rungenesisimg -{ +####################################################################################################################### +####write runimage script to verify runimage could work eg.runimage=http:////image.tgz +####################################################################################################################### +sub rungenesisimg { + my $runimg_script = "/tmp/imgtest"; + my $result = "/tmp/testresult"; + my $genesis_base_dir = "$::XCATROOT/share/xcat/netboot/genesis"; + my $genesis_bin_dir; + my $value = 0; mkdir("/install/my_image"); - open(TESTIMG, ">$runimgtest") - or die "Can't open testscripts for writing: $!"; - print TESTIMG join("\n", "#!/bin/bash"), "\n"; - print TESTIMG join("\n", "#This is test for genesis scripts"), "\n"; - print TESTIMG join("\n", "echo \"testimg\" >> $testresult"), "\n"; - close(TESTIMG); - copy("$runimgtest", "/install/my_image/runme.sh") or die "Copy failed: $!"; + if (!(-e $runimg_script)) { + $value = 2; + + #means runimg test using test scripts genesistest.pl writes + send_msg(2, "no runimg scripts for test prepared."); + open(TESTIMG, ">$runimg_script") + or die "Can't open testscripts for writing: $!"; + print TESTIMG join("\n", "#!/bin/bash"), "\n"; + print TESTIMG join("\n", "#This is test for genesis scripts"), "\n"; + print TESTIMG join("\n", "echo \"testimg\" >> $result"), "\n"; + close(TESTIMG); + print "value is $value \n"; + } else { + $value = 3; + + #means runimg test using test scripts user writes + send_msg(2, "runimg scripts for test ready."); + } + copy("$runimg_script", "/install/my_image/runme.sh") or die "Copy failed: $!"; chmod 0755, "/install/my_image/runme.sh"; - `cd /install/my_image ;tar -zcvf my_image.tgz .`; -`nodeset $noderange "runimage=http://$imgip/install/my_image/my_image.tgz",shell`; + `tar -zcvf /tmp/my_image.tgz -C /install/my_image .`; + copy("/tmp/my_image.tgz", "/install/my_image") or die "Copy failed: $!"; + `nodeset $noderange "runimage=http://$master/install/my_image/my_image.tgz",shell`; + if ($?) { + send_msg(0, "nodeset noderange failed for runimg"); + } + `rpower $noderange boot`; + if ($?) { + send_msg(0, "rpower boot failed for runimg test"); + } + return $value; } - -sub timesleep -{ - my @output = runcmd("ping $noderange -c 10"); - my $value = 0; - print "output is $value ,@output\n"; - if ($::RUNCMD_RC) { - foreach $value (1 .. 60) { - @output = runcmd("ping $noderange -c 10"); - last if ($::RUNCMD_RC == 0); +######################################## +####sleep while for xdsh $$CN could work +######################################### +sub testxdsh { + my $value = shift; + print "value is $value \n"; + my $checkstring; + my $checkfile; + if ($value == 1) { + #mean runcmd test using test scripts genesistest.pl writes + $checkstring = "testcmd"; + $checkfile = "/tmp/testresult"; + } elsif ($value == 2) { + $checkstring = "testimg"; + $checkfile = "/tmp/testresult"; + } elsif ($value == 3) { + $checkstring = "xcatd=$master:3001"; + $checkfile = "/proc/cmdline"; + } + if (($value == 1) || ($value == 2) || ($value == 3)) { + `xdsh $noderange -t 2 cat $checkfile |grep $checkstring`; + if ($?) { + foreach (1 .. 1500) { + `xdsh $noderange -t 2 cat $checkfile | grep $checkstring`; + last if ($? == 0); + } } } - my @output1 = runcmd("xdsh $noderange date"); - if ($::RUNCMD_RC) { - foreach $value (1 .. 60) { - @output1 = runcmd("xdsh $noderange -t 1 date"); - print "sleep $value\n"; - last if ($::RUNCMD_RC == 0); - } - } - if ($::RUNCMD_RC == 0) { - print "test ok\n"; - } + return $?; } - -sub clearenv -{ - if (-f "/tmp/imgtest") { - unlink("/install/my_image/runme.sh"); - unlink("/install/my_image/my_image.tgz"); - unlink("$runimgtest"); - rmdir("/install/my_image"); - print "img del ok\n"; +########################## +####clear test environment +########################## +sub clearenv { + my $arch = shift; + my $runcmd_script = "/tmp/cmdtest"; + my $runimg_script = "/tmp/imgtest"; + my $runme = "/install/my_image/runme.sh"; + my $runmetar = "/install/my_image/my_image.tgz"; + my $runmetar_tmp = "/tmp/my_image.tgz"; + my $runmedir = "/install/my_image"; + my $genesis_base_dir = "$::XCATROOT/share/xcat/netboot/genesis"; + if (-e "$runimg_script") { + unlink("$runme"); + unlink("$runmetar_tmp"); + unlink("$runmetar"); + unlink("$runimg_script"); + rmdir("$runmedir"); + send_msg(2, "clear runimage test environment"); } - if (-f "/tmp/cmdtest") { - if ($arch =~ /ppc64/) - { - $arch = "ppc64"; - } - - $genesisfiledir = "$genesisdir/$arch/fs/bin"; - my $genesisfile = "$genesisfiledir/cmdtest"; - print "genesis file is $genesisfile\n"; - unlink("$genesisfile"); - unlink("$cmdtest"); + if (-e "$runcmd_script") { + my $genesis_bin_dir = "$genesis_base_dir/$arch/fs/bin"; + my $genesis_test_script = "$genesis_bin_dir/cmdtest"; + unlink("$genesis_test_script"); + unlink("$runcmd_script"); `mknb $arch`; - print "mknb $arch\n"; + if ($?) { + send_msg(0, "mknb for runcmd test environment failed"); + exit 1; + } } `nodeset $noderange boot`; + if ($?) { + send_msg(0, "nodeset node failed"); + exit 1; + } + `rpower $noderange boot`; + if ($?) { + send_msg(0, "rpower node failed"); + exit 1; + } + return 0; } -if ($::NODE) -{ - $noderange = $::NODE; +#################################### +#get arch +################################### +sub get_arch { + use POSIX qw(uname); + my @uname = uname(); + my $arch = $uname[4]; + if ($arch =~ /ppc64/i) { + $arch = "ppc64"; + } elsif (($arch =~ /x86/i)&&($os =~ /ubuntu/i)) { + if ($check_genesis_file) { + $arch = "amd64"; + } + } + return $arch; } -if ($::ARCH) -{ - $arch = $::ARCH; -} -if ($::IMGIP) -{ - $imgip = $::IMGIP; -} -if ($::HELP) { - usage; -} -if ($rungenesiscmd) -{ - &rungenesiscmd; -} -if ($timesleep) -{ - ×leep; -} -if ($rungenesisimg) -{ - &rungenesisimg; -} -if ($clearenv) -{ - &clearenv; +####################################### +## send messages +######################################## +sub send_msg { + my $log_level = shift; + my $msg = shift; + my $content; + my $logfile = ""; + my $logfiledir = "/tmp/genesistestlog"; + my $date = `date +"%Y%m%d"`; + chomp($date); + if (!-e $logfiledir) + { + mkpath( $logfiledir ); + } + $logfile = "genesis" . $date . ".log"; + if ($log_level == 0) { + $content = "Fatal error:"; + } elsif ($log_level == 1) { + $content = "Warning:"; + } elsif ($log_level == 2) { + $content = "Notice:"; + } + if (!open(LOGFILE, ">> $logfiledir/$logfile")) { + return 1; + } + print LOGFILE "$date $$ $content $msg\n"; + close LOGFILE; + } From fd747d5fc624c30c51e5e00212014bc4bf749f9e Mon Sep 17 00:00:00 2001 From: penguhyang Date: Thu, 25 Aug 2016 11:10:27 +0800 Subject: [PATCH 090/106] give warnings and return when use -o -p -a for packimage (#1757) --- xCAT-server/lib/xcat/plugins/packimage.pm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/packimage.pm b/xCAT-server/lib/xcat/plugins/packimage.pm index d0434eb06..c4c91149c 100755 --- a/xCAT-server/lib/xcat/plugins/packimage.pm +++ b/xCAT-server/lib/xcat/plugins/packimage.pm @@ -108,6 +108,10 @@ sub process_request { "help|h" => \$help, "version|v" => \$version ); + if ($arch or $osver or $profile) { + $callback->({ error => ["-o, -p and -a options are obsoleted, please use 'packimage ' instead."], errorcode => [1] }); + return 1; + } if ($version) { my $version = xCAT::Utils->Version(); $callback->({ info => [$version] }); From 65e992157cc64309130443cc0870c6d5170e8d0e Mon Sep 17 00:00:00 2001 From: "litingt@cn.ibm.com" Date: Thu, 25 Aug 2016 00:14:12 -0400 Subject: [PATCH 091/106] delete case packimage_p_a_o --- xCAT-test/autotest/bundle/rhels6.7_ppc64.bundle | 1 - xCAT-test/autotest/bundle/rhels6.7_x86_64.bundle | 1 - xCAT-test/autotest/bundle/rhels6.8_ppc64.bundle | 1 - xCAT-test/autotest/bundle/rhels6.8_x86_64.bundle | 1 - xCAT-test/autotest/bundle/rhels7.2_ppc64.bundle | 1 - xCAT-test/autotest/bundle/rhels7.2_ppc64le.bundle | 1 - xCAT-test/autotest/bundle/rhels7.2_x86_64.bundle | 1 - xCAT-test/autotest/bundle/rhels7.3_ppc64le.bundle | 1 - xCAT-test/autotest/bundle/rhels7.3_x86_64.bundle | 1 - xCAT-test/autotest/bundle/sles11.4_ppc64.bundle | 1 - xCAT-test/autotest/bundle/sles11.4_x86_64.bundle | 9 ++++++++- xCAT-test/autotest/bundle/sles12.1_ppc64.bundle | 1 - xCAT-test/autotest/bundle/sles12.1_ppc64le.bundle | 1 - xCAT-test/autotest/bundle/sles12.1_x86_64.bundle | 1 - xCAT-test/autotest/bundle/sles12_ppc64le.bundle | 1 - xCAT-test/autotest/bundle/sles12_x86_64.bundle | 1 - xCAT-test/autotest/bundle/ubuntu14.04.3_ppc64le.bundle | 1 - xCAT-test/autotest/bundle/ubuntu14.04.3_x86_64.bundle | 1 - xCAT-test/autotest/bundle/ubuntu14.04.4_ppc64le.bundle | 1 - xCAT-test/autotest/bundle/ubuntu14.04.4_x86_64.bundle | 1 - xCAT-test/autotest/bundle/ubuntu16.04.1_ppc64le.bundle | 1 - xCAT-test/autotest/bundle/ubuntu16.04.1_x86_64.bundle | 1 - xCAT-test/autotest/bundle/ubuntu16.04_ppc64le.bundle | 1 - xCAT-test/autotest/bundle/ubuntu16.04_x86_64.bundle | 1 - 24 files changed, 8 insertions(+), 24 deletions(-) diff --git a/xCAT-test/autotest/bundle/rhels6.7_ppc64.bundle b/xCAT-test/autotest/bundle/rhels6.7_ppc64.bundle index ee6a786f9..ba479da63 100644 --- a/xCAT-test/autotest/bundle/rhels6.7_ppc64.bundle +++ b/xCAT-test/autotest/bundle/rhels6.7_ppc64.bundle @@ -42,7 +42,6 @@ copycds_n_a copycds_a_err copycds_n_err packimage_o_p_a_m -packimage_p_a_o packimage_imagename packimage_h packimage_v diff --git a/xCAT-test/autotest/bundle/rhels6.7_x86_64.bundle b/xCAT-test/autotest/bundle/rhels6.7_x86_64.bundle index 01a401041..49377b612 100644 --- a/xCAT-test/autotest/bundle/rhels6.7_x86_64.bundle +++ b/xCAT-test/autotest/bundle/rhels6.7_x86_64.bundle @@ -13,7 +13,6 @@ chtab_modify_key chtab_h chtab_v packimage_o_p_a_m -packimage_p_a_o packimage_imagename packimage_h packimage_v diff --git a/xCAT-test/autotest/bundle/rhels6.8_ppc64.bundle b/xCAT-test/autotest/bundle/rhels6.8_ppc64.bundle index 17ab440e5..aa5c1bbd2 100644 --- a/xCAT-test/autotest/bundle/rhels6.8_ppc64.bundle +++ b/xCAT-test/autotest/bundle/rhels6.8_ppc64.bundle @@ -47,7 +47,6 @@ copycds_n_a copycds_a_err copycds_n_err packimage_o_p_a_m -packimage_p_a_o packimage_imagename packimage_h packimage_v diff --git a/xCAT-test/autotest/bundle/rhels6.8_x86_64.bundle b/xCAT-test/autotest/bundle/rhels6.8_x86_64.bundle index 713051325..2f8978948 100644 --- a/xCAT-test/autotest/bundle/rhels6.8_x86_64.bundle +++ b/xCAT-test/autotest/bundle/rhels6.8_x86_64.bundle @@ -18,7 +18,6 @@ chtab_modify_key chtab_h chtab_v packimage_o_p_a_m -packimage_p_a_o packimage_imagename packimage_h packimage_v diff --git a/xCAT-test/autotest/bundle/rhels7.2_ppc64.bundle b/xCAT-test/autotest/bundle/rhels7.2_ppc64.bundle index 2843be128..2a5935deb 100644 --- a/xCAT-test/autotest/bundle/rhels7.2_ppc64.bundle +++ b/xCAT-test/autotest/bundle/rhels7.2_ppc64.bundle @@ -47,7 +47,6 @@ copycds_n_a copycds_a_err copycds_n_err packimage_o_p_a_m -packimage_p_a_o packimage_imagename packimage_h packimage_v diff --git a/xCAT-test/autotest/bundle/rhels7.2_ppc64le.bundle b/xCAT-test/autotest/bundle/rhels7.2_ppc64le.bundle index abca02957..38be7be14 100644 --- a/xCAT-test/autotest/bundle/rhels7.2_ppc64le.bundle +++ b/xCAT-test/autotest/bundle/rhels7.2_ppc64le.bundle @@ -19,7 +19,6 @@ chtab_modify_key chtab_h chtab_v packimage_o_p_a_m -packimage_p_a_o packimage_imagename packimage_h packimage_v diff --git a/xCAT-test/autotest/bundle/rhels7.2_x86_64.bundle b/xCAT-test/autotest/bundle/rhels7.2_x86_64.bundle index 192781e59..7d731ecc9 100644 --- a/xCAT-test/autotest/bundle/rhels7.2_x86_64.bundle +++ b/xCAT-test/autotest/bundle/rhels7.2_x86_64.bundle @@ -18,7 +18,6 @@ chtab_modify_key chtab_h chtab_v packimage_o_p_a_m -packimage_p_a_o packimage_imagename packimage_h packimage_v diff --git a/xCAT-test/autotest/bundle/rhels7.3_ppc64le.bundle b/xCAT-test/autotest/bundle/rhels7.3_ppc64le.bundle index cb5e4d8db..718bcc270 100644 --- a/xCAT-test/autotest/bundle/rhels7.3_ppc64le.bundle +++ b/xCAT-test/autotest/bundle/rhels7.3_ppc64le.bundle @@ -19,7 +19,6 @@ chtab_modify_key chtab_h chtab_v packimage_o_p_a_m -packimage_p_a_o packimage_imagename packimage_h packimage_v diff --git a/xCAT-test/autotest/bundle/rhels7.3_x86_64.bundle b/xCAT-test/autotest/bundle/rhels7.3_x86_64.bundle index 488607822..69eae50c3 100644 --- a/xCAT-test/autotest/bundle/rhels7.3_x86_64.bundle +++ b/xCAT-test/autotest/bundle/rhels7.3_x86_64.bundle @@ -18,7 +18,6 @@ chtab_modify_key chtab_h chtab_v packimage_o_p_a_m -packimage_p_a_o packimage_imagename packimage_h packimage_v diff --git a/xCAT-test/autotest/bundle/sles11.4_ppc64.bundle b/xCAT-test/autotest/bundle/sles11.4_ppc64.bundle index 5c9b5b196..5e36e9c51 100644 --- a/xCAT-test/autotest/bundle/sles11.4_ppc64.bundle +++ b/xCAT-test/autotest/bundle/sles11.4_ppc64.bundle @@ -29,7 +29,6 @@ copycds_n_a copycds_a_err copycds_n_err packimage_o_p_a_m -packimage_p_a_o packimage_imagename packimage_h packimage_v diff --git a/xCAT-test/autotest/bundle/sles11.4_x86_64.bundle b/xCAT-test/autotest/bundle/sles11.4_x86_64.bundle index 7a7e5fd18..d89d7e1bf 100644 --- a/xCAT-test/autotest/bundle/sles11.4_x86_64.bundle +++ b/xCAT-test/autotest/bundle/sles11.4_x86_64.bundle @@ -20,7 +20,6 @@ chtab_err_table chtab_h chtab_v packimage_o_p_a_m -packimage_p_a_o packimage_imagename packimage_h packimage_v @@ -215,6 +214,14 @@ run_command_with_XCATBYPASS disable_root_permission_in_policy_table assign_certain_command_permission reg_linux_diskless_installation_flat +packimage_m_cpio_c_gzip +packimage_m_cpio_c_pigz +packimage_m_cpio_c_xz +packimage_m_tar_c_pigz +packimage_m_tar_c_gzip +packimage_m_tar_c_xz +packimage_m_invalid_archive_method +packimage_m_invalid_compress_method reg_linux_statelite_installation_flat SN_setup_case reg_linux_diskfull_installation_hierarchy diff --git a/xCAT-test/autotest/bundle/sles12.1_ppc64.bundle b/xCAT-test/autotest/bundle/sles12.1_ppc64.bundle index f7f478c0a..6869e65ce 100644 --- a/xCAT-test/autotest/bundle/sles12.1_ppc64.bundle +++ b/xCAT-test/autotest/bundle/sles12.1_ppc64.bundle @@ -24,7 +24,6 @@ copycds_n_a copycds_a_err copycds_n_err packimage_o_p_a_m -packimage_p_a_o packimage_imagename packimage_h packimage_v diff --git a/xCAT-test/autotest/bundle/sles12.1_ppc64le.bundle b/xCAT-test/autotest/bundle/sles12.1_ppc64le.bundle index 11fd59720..7316e85f7 100644 --- a/xCAT-test/autotest/bundle/sles12.1_ppc64le.bundle +++ b/xCAT-test/autotest/bundle/sles12.1_ppc64le.bundle @@ -21,7 +21,6 @@ chtab_err_table chtab_h chtab_v packimage_o_p_a_m -packimage_p_a_o packimage_imagename packimage_h packimage_v diff --git a/xCAT-test/autotest/bundle/sles12.1_x86_64.bundle b/xCAT-test/autotest/bundle/sles12.1_x86_64.bundle index 3eba1e79f..98a3a37b9 100644 --- a/xCAT-test/autotest/bundle/sles12.1_x86_64.bundle +++ b/xCAT-test/autotest/bundle/sles12.1_x86_64.bundle @@ -20,7 +20,6 @@ chtab_err_table chtab_h chtab_v packimage_o_p_a_m -packimage_p_a_o packimage_imagename packimage_h packimage_v diff --git a/xCAT-test/autotest/bundle/sles12_ppc64le.bundle b/xCAT-test/autotest/bundle/sles12_ppc64le.bundle index 2caa4876b..f53523302 100644 --- a/xCAT-test/autotest/bundle/sles12_ppc64le.bundle +++ b/xCAT-test/autotest/bundle/sles12_ppc64le.bundle @@ -16,7 +16,6 @@ chtab_err_table chtab_h chtab_v packimage_o_p_a_m -packimage_p_a_o packimage_imagename packimage_h packimage_v diff --git a/xCAT-test/autotest/bundle/sles12_x86_64.bundle b/xCAT-test/autotest/bundle/sles12_x86_64.bundle index 8e3413dd1..78af43941 100644 --- a/xCAT-test/autotest/bundle/sles12_x86_64.bundle +++ b/xCAT-test/autotest/bundle/sles12_x86_64.bundle @@ -15,7 +15,6 @@ chtab_err_table chtab_h chtab_v packimage_o_p_a_m -packimage_p_a_o packimage_imagename packimage_h packimage_v diff --git a/xCAT-test/autotest/bundle/ubuntu14.04.3_ppc64le.bundle b/xCAT-test/autotest/bundle/ubuntu14.04.3_ppc64le.bundle index c369a3c47..4c1d1b7bd 100644 --- a/xCAT-test/autotest/bundle/ubuntu14.04.3_ppc64le.bundle +++ b/xCAT-test/autotest/bundle/ubuntu14.04.3_ppc64le.bundle @@ -14,7 +14,6 @@ chtab_modify_key chtab_h chtab_v packimage_o_p_a_m -packimage_p_a_o packimage_imagename packimage_h packimage_v diff --git a/xCAT-test/autotest/bundle/ubuntu14.04.3_x86_64.bundle b/xCAT-test/autotest/bundle/ubuntu14.04.3_x86_64.bundle index a43d7cf69..9fac0a0f2 100644 --- a/xCAT-test/autotest/bundle/ubuntu14.04.3_x86_64.bundle +++ b/xCAT-test/autotest/bundle/ubuntu14.04.3_x86_64.bundle @@ -14,7 +14,6 @@ chtab_modify_key chtab_h chtab_v packimage_o_p_a_m -packimage_p_a_o packimage_imagename packimage_h packimage_v diff --git a/xCAT-test/autotest/bundle/ubuntu14.04.4_ppc64le.bundle b/xCAT-test/autotest/bundle/ubuntu14.04.4_ppc64le.bundle index f2e48965f..843c15613 100644 --- a/xCAT-test/autotest/bundle/ubuntu14.04.4_ppc64le.bundle +++ b/xCAT-test/autotest/bundle/ubuntu14.04.4_ppc64le.bundle @@ -19,7 +19,6 @@ chtab_modify_key chtab_h chtab_v packimage_o_p_a_m -packimage_p_a_o packimage_imagename packimage_h packimage_v diff --git a/xCAT-test/autotest/bundle/ubuntu14.04.4_x86_64.bundle b/xCAT-test/autotest/bundle/ubuntu14.04.4_x86_64.bundle index 9eaf3f422..a601f8cb4 100644 --- a/xCAT-test/autotest/bundle/ubuntu14.04.4_x86_64.bundle +++ b/xCAT-test/autotest/bundle/ubuntu14.04.4_x86_64.bundle @@ -19,7 +19,6 @@ chtab_modify_key chtab_h chtab_v packimage_o_p_a_m -packimage_p_a_o packimage_imagename packimage_h packimage_v diff --git a/xCAT-test/autotest/bundle/ubuntu16.04.1_ppc64le.bundle b/xCAT-test/autotest/bundle/ubuntu16.04.1_ppc64le.bundle index 6d53f9ed9..e5e3bc079 100644 --- a/xCAT-test/autotest/bundle/ubuntu16.04.1_ppc64le.bundle +++ b/xCAT-test/autotest/bundle/ubuntu16.04.1_ppc64le.bundle @@ -19,7 +19,6 @@ chtab_modify_key chtab_h chtab_v packimage_o_p_a_m -packimage_p_a_o packimage_imagename packimage_h packimage_v diff --git a/xCAT-test/autotest/bundle/ubuntu16.04.1_x86_64.bundle b/xCAT-test/autotest/bundle/ubuntu16.04.1_x86_64.bundle index fb803c3b9..c7ac8a304 100644 --- a/xCAT-test/autotest/bundle/ubuntu16.04.1_x86_64.bundle +++ b/xCAT-test/autotest/bundle/ubuntu16.04.1_x86_64.bundle @@ -19,7 +19,6 @@ chtab_modify_key chtab_h chtab_v packimage_o_p_a_m -packimage_p_a_o packimage_imagename packimage_h packimage_v diff --git a/xCAT-test/autotest/bundle/ubuntu16.04_ppc64le.bundle b/xCAT-test/autotest/bundle/ubuntu16.04_ppc64le.bundle index 28cd9b4c0..6a8bad79a 100644 --- a/xCAT-test/autotest/bundle/ubuntu16.04_ppc64le.bundle +++ b/xCAT-test/autotest/bundle/ubuntu16.04_ppc64le.bundle @@ -19,7 +19,6 @@ chtab_modify_key chtab_h chtab_v packimage_o_p_a_m -packimage_p_a_o packimage_imagename packimage_h packimage_v diff --git a/xCAT-test/autotest/bundle/ubuntu16.04_x86_64.bundle b/xCAT-test/autotest/bundle/ubuntu16.04_x86_64.bundle index fe6034954..ec034a3af 100644 --- a/xCAT-test/autotest/bundle/ubuntu16.04_x86_64.bundle +++ b/xCAT-test/autotest/bundle/ubuntu16.04_x86_64.bundle @@ -19,7 +19,6 @@ chtab_modify_key chtab_h chtab_v packimage_o_p_a_m -packimage_p_a_o packimage_imagename packimage_h packimage_v From f9d339c3bad2d004039f30bf1139400e9bb00ff2 Mon Sep 17 00:00:00 2001 From: chenglch Date: Wed, 17 Aug 2016 04:24:39 -0400 Subject: [PATCH 092/106] Update rest api for rinstall and console - Refactor console api, console will be looked as a service resource - Add rest api to support rinstall --- xCAT-server/xCAT-wsapi/xcatws.cgi | 52 ++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/xCAT-server/xCAT-wsapi/xcatws.cgi b/xCAT-server/xCAT-wsapi/xcatws.cgi index 20306c00d..3b9fde3c5 100755 --- a/xCAT-server/xCAT-wsapi/xcatws.cgi +++ b/xCAT-server/xCAT-wsapi/xcatws.cgi @@ -217,17 +217,17 @@ my %URIdef = ( outhdler => \&noout, } }, - console => { - desc => "[URI:/nodes/{noderange}/console] - The console configuration for the node {noderange}", - matcher => '^/nodes/[^/]*/console$', - PUT => { - desc => "Update conserver configuration for the node {noderange}.", - usage => "|Json Formatted DataBody: {action:on/off}.|$usagemsg{non_getreturn}|", - example => "|Enable the console capability for node1|PUT|/nodes/node1/console {\"action\":\"on\", \"trust_host\": \"host\"}||", - cmd => "makeconservercf", + provision => { + desc => "[URI:/nodes/{noderange}/provision] - The deployment resource for the node {noderange}", + matcher => '^/nodes/[^/]*/provision$', + PUT => { + desc => "OS provision for the node {noderange}.", + usage => "|Json Formatted DataBody: {osimage: ubuntu16.04.1-x86_64-install-compute, action: boot}.|$usagemsg{non_getreturn}|", + example => "|Provision the node|PUT|/nodes/node1/provision {\"osimage\":\"ubuntu16.04.1-x86_64-install-compute\"}||", + cmd => "rinstall", fhandler => \&actionhdl, outhdler => \&noout, - } + } }, energy => { desc => "[URI:/nodes/{noderange}/energy] - The energy resource for the node {noderange}", @@ -773,7 +773,7 @@ my %URIdef = ( }, #### definition for mknb [-c] nbimage => { - desc => "[URI:/nbimage] - Create netboot root image for specified arch.", + desc => "[URI:/services/nbimage] - Create netboot root image for specified arch.", matcher => '^/services/nbimage/arch/[ppc64|x86_64]', POST => { desc => "creates a network boot root image", @@ -783,6 +783,18 @@ my %URIdef = ( fhandler => \&actionhdl, }, }, + console => { + desc => "[URI:/services/console] - Conserver configuration on management node.", + matcher => '^/services/console$', + PUT => { + desc => "Update conserver configuration", + usage => "|Json Formatted DataBody: {nodes: [node1, node2], action: on/off trust_host: }.|$usagemsg{non_getreturn}|", + example => "|Enable the console capability for node1|PUT|/services/console {\"nodes\":\n[\"node1\", \"node2\"]\"\n, \"action\": \"on\", \n\"trust_host\": \"host\"}||", + cmd => "makeconservercf", + fhandler => \&actionhdl, + outhdler => \&noout, + } + }, }, #### definition for network resources @@ -2194,15 +2206,25 @@ sub actionhdl { } } elsif ($params->{'resourcename'} eq "console") { + delete $request->{noderange}; if ($paramhash->{'action'}) { my %action = ('on' => '', 'off' => '-d'); push @args, $action{$paramhash->{'action'}}; - if ($paramhash->{'trust_host'}) { - push @args, '-t'; - push @args, $paramhash->{'trust_host'}; + if ($paramhash->{'nodes'}) { + $request->{noderange} = join(',', @{$paramhash->{'nodes'}}); + } else { + error("Missed node.") } - } else { - error("Missed Action.", $STATUS_NOT_FOUND); + } + if ($paramhash->{'trust_host'}) { + push @args, '-t'; + push @args, $paramhash->{'trust_host'}; + } + } elsif ($params->{'resourcename'} eq "provision") { + if ($paramhash->{'osimage'}) { + push @args, 'osimage='.$paramhash->{'osimage'}; + } elsif ($paramhash->{'action'}) { + push @args, $paramhash->{'action'}; } } From 12773c44fc9b48c8615e8f6352c1f0e52c815b65 Mon Sep 17 00:00:00 2001 From: bybai Date: Thu, 25 Aug 2016 01:52:19 -0400 Subject: [PATCH 093/106] fix issue 1553 makedns failed when input invalid hostname into /etc/hosts --- xCAT-server/lib/xcat/plugins/ddns.pm | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/ddns.pm b/xCAT-server/lib/xcat/plugins/ddns.pm index 266d15410..4d14a8f22 100755 --- a/xCAT-server/lib/xcat/plugins/ddns.pm +++ b/xCAT-server/lib/xcat/plugins/ddns.pm @@ -423,6 +423,8 @@ sub process_request { my $names; my @hosts; my %nodehash; + my @eachhost; + my $invalid; foreach (@contents) { chomp; #no newline @@ -440,6 +442,18 @@ sub process_request { next; } + @eachhost = split(/ /,$names); + foreach my $hname (@eachhost) { + unless ($hname !~ /^\.[a-z0-9]+/i) { + xCAT::SvrUtils::sendmsg(":Ignoring line $_ in /etc/hosts, names $names start with . ", $callback); + $invalid = $names; + last; + } + } + if ($invalid) { + next; + } + my ($host, $ip) = xCAT::NetworkUtils->gethostnameandip($addr); push @hosts, $host; $nodehash{$addr}{names} = $names; From 6d0bf02cfa3b935e1cf5ec094f5670a7538d16f3 Mon Sep 17 00:00:00 2001 From: penguhyang Date: Thu, 25 Aug 2016 14:48:23 +0800 Subject: [PATCH 094/106] fix return code is 0 when there are errors (#1763) --- xCAT-server/lib/xcat/plugins/packimage.pm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/packimage.pm b/xCAT-server/lib/xcat/plugins/packimage.pm index c4c91149c..d5ab79c76 100755 --- a/xCAT-server/lib/xcat/plugins/packimage.pm +++ b/xCAT-server/lib/xcat/plugins/packimage.pm @@ -418,7 +418,7 @@ sub process_request { my $temppath; my $oldmask; unless (-d $rootimg_dir) { - $callback->({ error => ["$rootimg_dir does not exist, run genimage -o $osver -p $profile on a server with matching architecture"] }); + $callback->({ error => ["$rootimg_dir does not exist, run genimage -o $osver -p $profile on a server with matching architecture"], errorcode => [1] }); return 1; } @@ -427,21 +427,21 @@ sub process_request { if ($compress eq 'gzip') { my $isgzip = system("bash -c 'type -p gzip' >/dev/null 2>&1"); unless ($isgzip == 0) { - $callback->({ error => ["Command gzip does not exist, please make sure it is installed."] }); + $callback->({ error => ["Command gzip does not exist, please make sure it is installed."], errorcode => [1] }); return 1; } $suffix = "gz"; } elsif ($compress eq 'pigz') { my $ispigz = system("bash -c 'type -p pigz' >/dev/null 2>&1"); unless ($ispigz == 0) { - $callback->({ error => ["Command pigz does not exist, please make sure it is installed."] }); + $callback->({ error => ["Command pigz does not exist, please make sure it is installed."], errorcode => [1] }); return 1; } $suffix = "gz"; } elsif ($compress eq 'xz') { my $isxz = system("bash -c 'type -p xz' >/dev/null 2>&1"); unless ($isxz == 0) { - $callback->({ error => ["Command xz does not exist, please make sure it is installed."] }); + $callback->({ error => ["Command xz does not exist, please make sure it is installed."], errorcode => [1] }); return 1; } $suffix = "xz"; @@ -458,7 +458,7 @@ sub process_request { if ($isgzip == 0) { $compress = "gzip"; } else { - $callback->({ error => ["The default compress tool 'gzip' and 'pigz' does not exist, please specify an available compress method with '-c'."] }); + $callback->({ error => ["The default compress tool 'gzip' and 'pigz' does not exist, please specify an available compress method with '-c'."], errorcode => [1] }); return 1; } } From 547516d848432e879462ff72742f87e469fffad4 Mon Sep 17 00:00:00 2001 From: "litingt@cn.ibm.com" Date: Thu, 25 Aug 2016 04:10:41 -0400 Subject: [PATCH 095/106] update the case bundle for some cases are not supported on the specific os --- xCAT-test/autotest/bundle/sles11.4_ppc64.bundle | 2 -- xCAT-test/autotest/bundle/sles11.4_x86_64.bundle | 2 -- xCAT-test/autotest/bundle/ubuntu14.04.4_ppc64le.bundle | 1 - xCAT-test/autotest/bundle/ubuntu14.04.4_x86_64.bundle | 1 - xCAT-test/autotest/bundle/ubuntu16.04.1_ppc64le.bundle | 1 - xCAT-test/autotest/bundle/ubuntu16.04.1_x86_64.bundle | 1 - 6 files changed, 8 deletions(-) diff --git a/xCAT-test/autotest/bundle/sles11.4_ppc64.bundle b/xCAT-test/autotest/bundle/sles11.4_ppc64.bundle index 5e36e9c51..94459a311 100644 --- a/xCAT-test/autotest/bundle/sles11.4_ppc64.bundle +++ b/xCAT-test/autotest/bundle/sles11.4_ppc64.bundle @@ -33,9 +33,7 @@ packimage_imagename packimage_h packimage_v packimage_m_cpio_c_gzip -packimage_m_cpio_c_pigz packimage_m_cpio_c_xz -packimage_m_tar_c_pigz packimage_m_tar_c_gzip packimage_m_tar_c_xz packimage_m_invalid_archive_method diff --git a/xCAT-test/autotest/bundle/sles11.4_x86_64.bundle b/xCAT-test/autotest/bundle/sles11.4_x86_64.bundle index d89d7e1bf..c4548264d 100644 --- a/xCAT-test/autotest/bundle/sles11.4_x86_64.bundle +++ b/xCAT-test/autotest/bundle/sles11.4_x86_64.bundle @@ -215,9 +215,7 @@ disable_root_permission_in_policy_table assign_certain_command_permission reg_linux_diskless_installation_flat packimage_m_cpio_c_gzip -packimage_m_cpio_c_pigz packimage_m_cpio_c_xz -packimage_m_tar_c_pigz packimage_m_tar_c_gzip packimage_m_tar_c_xz packimage_m_invalid_archive_method diff --git a/xCAT-test/autotest/bundle/ubuntu14.04.4_ppc64le.bundle b/xCAT-test/autotest/bundle/ubuntu14.04.4_ppc64le.bundle index 843c15613..e4c01d5b3 100644 --- a/xCAT-test/autotest/bundle/ubuntu14.04.4_ppc64le.bundle +++ b/xCAT-test/autotest/bundle/ubuntu14.04.4_ppc64le.bundle @@ -2,7 +2,6 @@ Diskless_installation_flat_p8_le Full_installation_flat_p8_le go_xcat_local_repo_case7 go_xcat_noinput -go_xcat_with_x go_xcat_with_xcat-version-1 go_xcat_online_repo_case6 makehosts_h diff --git a/xCAT-test/autotest/bundle/ubuntu14.04.4_x86_64.bundle b/xCAT-test/autotest/bundle/ubuntu14.04.4_x86_64.bundle index a601f8cb4..0b405b1ae 100644 --- a/xCAT-test/autotest/bundle/ubuntu14.04.4_x86_64.bundle +++ b/xCAT-test/autotest/bundle/ubuntu14.04.4_x86_64.bundle @@ -2,7 +2,6 @@ Ubuntu_diskless_installation_flat_x86_vm Ubuntu_full_installation_flat_x86_vm go_xcat_local_repo_case7 go_xcat_noinput -go_xcat_with_x go_xcat_with_xcat-version-1 go_xcat_online_repo_case6 makehosts_h diff --git a/xCAT-test/autotest/bundle/ubuntu16.04.1_ppc64le.bundle b/xCAT-test/autotest/bundle/ubuntu16.04.1_ppc64le.bundle index e5e3bc079..bc050eb58 100644 --- a/xCAT-test/autotest/bundle/ubuntu16.04.1_ppc64le.bundle +++ b/xCAT-test/autotest/bundle/ubuntu16.04.1_ppc64le.bundle @@ -2,7 +2,6 @@ Diskless_installation_flat_p8_le Full_installation_flat_p8_le go_xcat_local_repo_case7 go_xcat_noinput -go_xcat_with_x go_xcat_with_xcat-version-1 go_xcat_online_repo_case6 makehosts_h diff --git a/xCAT-test/autotest/bundle/ubuntu16.04.1_x86_64.bundle b/xCAT-test/autotest/bundle/ubuntu16.04.1_x86_64.bundle index c7ac8a304..cb7c8a4ce 100644 --- a/xCAT-test/autotest/bundle/ubuntu16.04.1_x86_64.bundle +++ b/xCAT-test/autotest/bundle/ubuntu16.04.1_x86_64.bundle @@ -2,7 +2,6 @@ Ubuntu_diskless_installation_flat_x86_vm Ubuntu_full_installation_flat_x86_vm go_xcat_local_repo_case7 go_xcat_noinput -go_xcat_with_x go_xcat_with_xcat-version-1 go_xcat_online_repo_case6 makehosts_h From 2a0529876a3207aa6ad38b94c2e4a9998bd50965 Mon Sep 17 00:00:00 2001 From: immarvin Date: Thu, 25 Aug 2016 21:56:05 -0400 Subject: [PATCH 096/106] fix issue enimage deleted /dev/* on the management node... #1767 --- xCAT-server/share/xcat/netboot/rh/genimage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT-server/share/xcat/netboot/rh/genimage b/xCAT-server/share/xcat/netboot/rh/genimage index a56e157b6..83087242d 100755 --- a/xCAT-server/share/xcat/netboot/rh/genimage +++ b/xCAT-server/share/xcat/netboot/rh/genimage @@ -70,7 +70,7 @@ my $noupdate; sub xdie { system("rm -rf /tmp/xcatinitrd.$$"); - umount_chroot($rootimage_dir); + umount_chroot($rootimg_dir); die @_; } From 3a80d1b1bbf58ababa276766a7e2e11b4c1da0db Mon Sep 17 00:00:00 2001 From: "litingt@cn.ibm.com" Date: Fri, 26 Aug 2016 02:46:37 -0400 Subject: [PATCH 097/106] update bundle since rh does not have pigz --- xCAT-test/autotest/bundle/rhels7.2_ppc64le.bundle | 2 -- xCAT-test/autotest/testcase/packimg/cases0 | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/xCAT-test/autotest/bundle/rhels7.2_ppc64le.bundle b/xCAT-test/autotest/bundle/rhels7.2_ppc64le.bundle index 38be7be14..77cc05173 100644 --- a/xCAT-test/autotest/bundle/rhels7.2_ppc64le.bundle +++ b/xCAT-test/autotest/bundle/rhels7.2_ppc64le.bundle @@ -23,9 +23,7 @@ packimage_imagename packimage_h packimage_v packimage_m_cpio_c_gzip -packimage_m_cpio_c_pigz packimage_m_cpio_c_xz -packimage_m_tar_c_pigz packimage_m_tar_c_gzip packimage_m_tar_c_xz packimage_m_invalid_archive_method diff --git a/xCAT-test/autotest/testcase/packimg/cases0 b/xCAT-test/autotest/testcase/packimg/cases0 index 9cdb681d0..b0e2d1502 100644 --- a/xCAT-test/autotest/testcase/packimg/cases0 +++ b/xCAT-test/autotest/testcase/packimg/cases0 @@ -314,7 +314,7 @@ cmd:genimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute check:rc==0 cmd:ls -l /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg check:rc==0 -cmd:packimage -o __GETNODEATTR($$CN,os)__ -p compute -a __GETNODEATTR($$CN,arch)__ -m invalid +cmd:packimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute -m invalid check:rc!=0 check:output=~Error: Invalid archive method 'invalid' requested cmd:rm -rf /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg @@ -330,7 +330,7 @@ cmd:genimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute check:rc==0 cmd:ls -l /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg check:rc==0 -cmd:packimage -o __GETNODEATTR($$CN,os)__ -p compute -a __GETNODEATTR($$CN,arch)__ -c invalid +cmd:packimage __GETNODEATTR($$CN,os)__-__GETNODEATTR($$CN,arch)__-netboot-compute -c invalid check:rc!=0 check:output=~Error: Invalid compress method 'invalid' requested cmd:rm -rf /install/netboot/__GETNODEATTR($$CN,os)__/__GETNODEATTR($$CN,arch)__/compute/rootimg From c8e77245939887abb8ce94cb24ea85c8a79744f5 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Fri, 26 Aug 2016 18:50:07 -0400 Subject: [PATCH 098/106] Do not reuse cdrom device label when adding new disks to KVM (#1751) * Do not reuse cdrom device label when adding new disks to KVM * Return array of cdrom devices instead of just one --- xCAT-server/lib/xcat/plugins/kvm.pm | 34 +++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/kvm.pm b/xCAT-server/lib/xcat/plugins/kvm.pm index 32b73c72a..9832e158f 100755 --- a/xCAT-server/lib/xcat/plugins/kvm.pm +++ b/xCAT-server/lib/xcat/plugins/kvm.pm @@ -1894,6 +1894,18 @@ sub chvm { } } } + + # The function get_multiple_paths_by_url() is used to polulate useddisks hash, + # but it only returns disk volumes from kvm host. + # cdrom is not returned by get_multiple_paths_by_url() but is defined as a disk device + # in xml definition of the VM. + # We add cdrom entry to useddisks hash to make sure the device name used by cdrom is not + # selected for the new disk about to be added (chvm -a) + my @cdrom_names = get_cdrom_device_names($vmxml); + foreach my $cdrom_name (@cdrom_names) { + $useddisks{$cdrom_name} = 1; + } + if (@addsizes) { #need to add disks, first identify used devnames my @diskstoadd; my $location = $confdata->{vm}->{$node}->[0]->{storage}; @@ -1938,6 +1950,7 @@ sub chvm { $dev = $prefix . shift(@suffixes); } while ($useddisks{$dev}); + #ok, now I need a volume created to attach push @diskstoadd, get_filepath_by_url(url => $location, dev => $dev, create => $_, format => $format); } @@ -4093,4 +4106,25 @@ sub dohyp { #print $out $msgtoparent; #$node.": $_\n"; } +# Return array of device names used by cdrom as defined in the kvm_nodedata table +sub get_cdrom_device_names() { + my $xml = shift; + my $device_name; + my @cdrom_device_names; + + my $myxml = $parser->parse_string($xml); + my @alldisks = $myxml->findnodes("/domain/devices/disk"); + # Look through all the disk entries defined in the xml + foreach my $disknode (@alldisks) { + my $devicetype = $disknode->getAttribute("device"); + # Check if it is cdrom + if ($devicetype eq "cdrom") { + # Get name of the cdrom + $device_name = $disknode->findnodes('./target')->[0]->getAttribute('dev'); + push @cdrom_device_names, $device_name; + } + } + return @cdrom_device_names; +} + 1; From a9b9c89c28fa9c914aee3423edd264476bcf10ca Mon Sep 17 00:00:00 2001 From: ertaozh Date: Thu, 25 Aug 2016 01:14:13 -0400 Subject: [PATCH 099/106] Remove the hardcoded password for FSP --- .../references/man1/rspconfig.1.rst | 26 +---- perl-xCAT/xCAT/PPCcfg.pm | 45 +------- perl-xCAT/xCAT/PPCfsp.pm | 102 +----------------- perl-xCAT/xCAT/Usage.pm | 4 - xCAT-client/pods/man1/rspconfig.1.pod | 22 +--- xCAT-server/lib/perl/xCAT/PPC.pm | 2 - 6 files changed, 9 insertions(+), 192 deletions(-) diff --git a/docs/source/guides/admin-guides/references/man1/rspconfig.1.rst b/docs/source/guides/admin-guides/references/man1/rspconfig.1.rst index 911a80222..e737ef070 100644 --- a/docs/source/guides/admin-guides/references/man1/rspconfig.1.rst +++ b/docs/source/guides/admin-guides/references/man1/rspconfig.1.rst @@ -80,16 +80,12 @@ FSP/CEC specific: ================= -\ **rspconfig**\ \ *noderange*\ {\ **autopower | iocap | dev | celogin1 | decfg | memdecfg | procdecfg | time | date | spdump | sysdump | network**\ } +\ **rspconfig**\ \ *noderange*\ {\ **autopower | iocap | decfg | memdecfg | procdecfg | time | date | spdump | sysdump | network**\ } \ **rspconfig**\ \ *noderange*\ \ **autopower**\ ={\ **enable | disable**\ } \ **rspconfig**\ \ *noderange*\ \ **iocap**\ ={\ **enable | disable**\ } -\ **rspconfig**\ \ *noderange*\ \ **dev**\ ={\ **enable | disable**\ } - -\ **rspconfig**\ \ *noderange*\ \ **celogin1**\ ={\ **enable | disable**\ } - \ **rspconfig**\ \ *noderange*\ \ **time**\ =\ *hh:mm:ss*\ \ **rspconfig**\ \ *noderange*\ \ **date**\ =\ *mm:dd:yyyy*\ @@ -142,7 +138,7 @@ BPA/Frame Specific: =================== -\ **rspconfig**\ \ *noderange*\ {\ **network | dev | celogin1**\ } +\ **rspconfig**\ \ *noderange*\ {\ **network**\ } \ **rspconfig**\ \ *noderange*\ \ **network**\ ={\ **nic,**\ \*} @@ -150,10 +146,6 @@ BPA/Frame Specific: \ **rspconfig**\ \ *noderange*\ \ **network**\ ={\ **nic,0.0.0.0**\ } -\ **rspconfig**\ \ *noderange*\ \ **dev**\ ={\ **enable | disable**\ } - -\ **rspconfig**\ \ *noderange*\ \ **celogin1**\ ={\ **enable | disable**\ } - \ **rspconfig**\ \ *noderange*\ \ **HMC_passwd**\ ={\ *currentpasswd,newpasswd*\ } \ **rspconfig**\ \ *noderange*\ \ **admin_passwd**\ ={\ *currentpasswd,newpasswd*\ } @@ -255,7 +247,7 @@ DESCRIPTION \ **rspconfig**\ configures various settings in the nodes' service processors. If only a keyword is specified, without the \ **=**\ , it displays the current value. -For options \ **autopower | iocap | dev | celogin1 | decfg | memdecfg | procdecfg | time | date | spdump | sysdump | network**\ , user need to use \ *chdef -t site enableASMI=yes*\ to enable ASMI first. For options \ **dev | celogin1**\ , user also need to contact IBM service to get the dynamic password for 'celogin' and put it in passwd table. After completed the command, user should use \ *chdef -t site enableASMI=no*\ to disable ASMI. +For options \ **autopower | iocap | decfg | memdecfg | procdecfg | time | date | spdump | sysdump | network**\ , user need to use \ *chdef -t site enableASMI=yes*\ to enable ASMI first. ******* @@ -396,18 +388,6 @@ OPTIONS -\ **dev**\ ={\ **enable**\ | \ **disable**\ } - - Enable or disable the CEC|Frame 'dev' account or display account status if no value specified. - - - -\ **celogin1**\ ={\ **enable**\ | \ **disable**\ } - - Enable or disable the CEC|Frame 'celogin1' account or display account status if no value specified. - - - \ **ip**\ The ip address. diff --git a/perl-xCAT/xCAT/PPCcfg.pm b/perl-xCAT/xCAT/PPCcfg.pm index 9c0f1c2af..cae3b7907 100644 --- a/perl-xCAT/xCAT/PPCcfg.pm +++ b/perl-xCAT/xCAT/PPCcfg.pm @@ -50,9 +50,7 @@ sub parse_args { "general_passwd", "*_passwd", "hostname", - "resetnet", - "dev", - "celogin1" + "resetnet" ); my @bpa = ( "frame", @@ -63,9 +61,7 @@ sub parse_args { "general_passwd", "*_passwd", "hostname", - "resetnet", - "dev", - "celogin1" + "resetnet" ); my @ppc = ( "sshcfg" @@ -169,16 +165,6 @@ sub parse_args { return (usage("No argument specified for '$_'")); } } - { - if ($request->{dev} eq '1' && $request->{other} eq '1') { - return (usage("Invalid command arrays")); - } - - # my $result = parse_dev_option( $request, \%cmds); - # if ($result) { - # return ( usage($result)); - # } - } #################################### # Return method to invoke #################################### @@ -216,25 +202,6 @@ sub parse_args { return (\%opt); } - -sub parse_dev_option { - my $req = shift; - my $cmds = shift; - foreach my $cmd (keys %$cmds) { - if ($cmd =~ /^(dev|celogin1)$/) { - if ($cmds->{$cmd} and ($cmds->{$cmd} !~ /^(enable|disable)$/i)) { - return ("Invalid argument " . $cmds->{$cmd} . " for " . $cmd); - } - $req->{dev} = 1; - } else { - $req->{other} = 1; - } - } - if ($req->{dev} eq '1' && $req->{other} eq '1') { - return ("Invalid command arrays"); - } - return undef; -} ########################################################################## # Parse the command line optional arguments ########################################################################## @@ -324,14 +291,6 @@ sub parse_option { } } - if ($command eq 'dev' or $command eq 'celogin1') { - if ($value !~ /^(enable|disable)$/i) { - return ("Invalid argument '$value'"); - } - $request->{dev} = 1; - } else { - $request->{other} = 1; - } return undef; } diff --git a/perl-xCAT/xCAT/PPCfsp.pm b/perl-xCAT/xCAT/PPCfsp.pm index 081ac4217..be754ee57 100644 --- a/perl-xCAT/xCAT/PPCfsp.pm +++ b/perl-xCAT/xCAT/PPCfsp.pm @@ -38,9 +38,7 @@ my %cmds = ( autopower => [ "Auto Power Restart", \&autopower ], sysdump => [ "System Dump", \&sysdump ], spdump => [ "Service Processor Dump", \&spdump ], - network => [ "Network Configuration", \&netcfg ], - dev => [ "Service Processor Command Line", \&devenable ], - celogin1 => [ "Service Processor Command Line", \&ce1enable ] }, + network => [ "Network Configuration", \&netcfg ]}, ); @@ -216,55 +214,6 @@ sub connect { } -sub ce1enable { - return &loginenable($_[0], $_[1], $_[2], "celogin1"); -} - -sub devenable { - return &loginenable($_[0], $_[1], $_[2], "dev"); -} -my %cmdline_for_log = ( - dev => { - enable => "registry -Hw nets/DevEnabled 1", - disable => "registry -Hw nets/DevEnabled 0", - check_pwd => "registry -l DevPwdFile", - create_pwd => "netsDynPwdTool --create dev FipSdev", - password => "FipSdev" - }, - celogin1 => { - enable => "registry -Hw nets/CE1Enabled 1", - disable => "registry -Hw nets/CE1Enabled 0", - check_pwd => "registry -l Ce1PwdFile", - create_pwd => "netsDynPwdTool --create celogin1 FipSce1", - password => "FipSce1" - }, -); - -sub send_command { - my $ua = shift; - my $server = shift; - my $id = shift; - my $log_name = shift; - my $cmd = shift; - my $cmd_line = $cmdline_for_log{$log_name}{$cmd}; - if (!defined($cmd_line)) { - return undef; - } - my $res = $ua->post("https://$server/cgi-bin/cgi", - [ form => $id, - cmd => $cmd_line, - submit => "Execute" ] - ); - - if (!$res->is_success()) { - return undef; - } - if ($res->content =~ /(not allowed.*\.|Invalid entry)/) { - return undef; - } - return $res->content; -} - sub loginstate { my $ua = shift; my $server = shift; @@ -282,55 +231,6 @@ sub loginstate { } } -sub loginenable { - my $exp = shift; - my $request = shift; - my $id = shift; - my $log_name = shift; - my $ua = @$exp[0]; - my $server = @$exp[1]; - - my $value = $request->{method}{$log_name}; - if (!defined($value)) { - return &loginstate($ua, $server, $log_name); - } - my $url = "https://$server/cgi-bin/cgi?form=$id"; - my $res = $ua->get($url); - if (!$res->is_success()) { - return ([ RC_ERROR, $res->status_line ]); - } - - $res = &send_command($ua, $server, $id, $log_name, $value); - if (!defined($res)) { - return ([ RC_ERROR, "Send command Failed" ]); - } - if ($value =~ m/^disable$/) { - my $out = sprintf("%9s: Disabled", $log_name); - return ([ SUCCESS, $out ]); - } - - #check password# - $res = &send_command($ua, $server, $id, $log_name, "check_pwd"); - if (!defined($res)) { - return ([ RC_ERROR, "Send command Failed" ]); - } - my $password = undef; - if ($res =~ m/\[\d+([a-zA-Z]+)\d+\]/) { - $password = $1; - } else { - - # create password # - $res = &send_command($ua, $server, $id, $log_name, "create_pwd"); - if (!defined($res)) { - return ([ RC_ERROR, "Send command Failed" ]); - } - $password = $cmdline_for_log{$log_name}{password}; - print "create password for $log_name is '$cmdline_for_log{$log_name}{password}'\n"; - } - my $out = sprintf("%9s: Enabled, password: $password", $log_name); - return ([ SUCCESS, $out ]); -} - sub disconnect { my $exp = shift; diff --git a/perl-xCAT/xCAT/Usage.pm b/perl-xCAT/xCAT/Usage.pm index 523ba6acb..b978a03d1 100755 --- a/perl-xCAT/xCAT/Usage.pm +++ b/perl-xCAT/xCAT/Usage.pm @@ -187,10 +187,6 @@ my %usage = ( HMC specific: rspconfig [sshcfg] rspconfig [sshcfg=] - CEC|Frame(using ASM)Specific: - rspconfig [dev|celogin1] - rspconfig [dev=]| - rspconfig [celogin1=] ", "getmacs" => "Usage: diff --git a/xCAT-client/pods/man1/rspconfig.1.pod b/xCAT-client/pods/man1/rspconfig.1.pod index e2f89c4b1..eabf3cb61 100644 --- a/xCAT-client/pods/man1/rspconfig.1.pod +++ b/xCAT-client/pods/man1/rspconfig.1.pod @@ -54,16 +54,12 @@ B I B={[B],[B],[B],[ =head2 FSP/CEC specific: -B I {B|B|B|B|B|B|B|B