From 9b116603e0549ad0352fd34ee58b6f20cddead32 Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Sat, 27 Jan 2024 20:42:44 -0600 Subject: [PATCH] update --- defaults.inc | 1 + esxi-scripts/iscsi-all-shutdown-verify.ps1 | 6 +-- esxi-scripts/iscsi-all-vm-shutdown.ps1 | 6 +-- esxi-scripts/iscsi-sys-vm-shutdown-verify.ps1 | 6 +-- esxi-scripts/iscsi-sys-vm-shutdown.ps1 | 6 +-- esxi-scripts/iscsi-vm-shutdown-verify.ps1 | 6 +-- esxi-scripts/iscsi-vm-shutdown.ps1 | 6 +-- inc/temp.inc.sh | 4 +- powerwall.sh | 42 +++++++++---------- 9 files changed, 36 insertions(+), 47 deletions(-) diff --git a/defaults.inc b/defaults.inc index 8af1f3a1..dbcd6df0 100755 --- a/defaults.inc +++ b/defaults.inc @@ -1,3 +1,4 @@ +#!/usr/bin/env bash VERS='2.5.168-01272024' diff --git a/esxi-scripts/iscsi-all-shutdown-verify.ps1 b/esxi-scripts/iscsi-all-shutdown-verify.ps1 index 252853d0..4105a8c8 100755 --- a/esxi-scripts/iscsi-all-shutdown-verify.ps1 +++ b/esxi-scripts/iscsi-all-shutdown-verify.ps1 @@ -1,9 +1,7 @@ #!/usr/bin/env pwsh - -Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false | Out-Null . /opt/idssys/powerwall/settings.ps1 -Connect-VIServer -Server $args[0] -Protocol https -User $ESXiUsername -Password $ESXiPassword | Out-Null +Connect-VIServer -Server $VCENTERHOST -Protocol https -User $VCENTERUSER -Password $VCENTERPASS | Out-Null Do { $VMLIST = Get-Datastore | Where {$_.Name -like '*iSCSI-*'} | Get-VM @@ -28,4 +26,4 @@ Do { } Until ($poff -match 'yes') -Disconnect-VIServer -Server $args[0] -Force –Confirm:$false \ No newline at end of file +Disconnect-VIServer -Server $VCENTERHOST -Force –Confirm:$false diff --git a/esxi-scripts/iscsi-all-vm-shutdown.ps1 b/esxi-scripts/iscsi-all-vm-shutdown.ps1 index 37c98e0d..e56a6098 100755 --- a/esxi-scripts/iscsi-all-vm-shutdown.ps1 +++ b/esxi-scripts/iscsi-all-vm-shutdown.ps1 @@ -1,10 +1,8 @@ #!/usr/bin/env pwsh - -Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false | Out-Null . /opt/idssys/powerwall/settings.ps1 -Connect-VIServer -Server $args[0] -Protocol https -User $ESXiUsername -Password $ESXiPassword | Out-Null +Connect-VIServer -Server $VCENTERHOST -Protocol https -User $VCENTERUSER -Password $VCENTERPASS | Out-Null Get-Datastore | Where {$_.Name -like '*iSCSI-*' -and $_.Name -notlike '*vMS*'} | Get-VM | Where {$_.PowerState -like '*On*' -and $_.Name -notlike '*CLS*' -and $_.Name -notlike '*iSCSI-*'} | Shutdown-VMGuest -Confirm:$false -Disconnect-VIServer -Server $args[0] -Force –Confirm:$false \ No newline at end of file +Disconnect-VIServer -Server $VCENTERHOST -Force –Confirm:$false diff --git a/esxi-scripts/iscsi-sys-vm-shutdown-verify.ps1 b/esxi-scripts/iscsi-sys-vm-shutdown-verify.ps1 index a50462c1..efdec6a1 100755 --- a/esxi-scripts/iscsi-sys-vm-shutdown-verify.ps1 +++ b/esxi-scripts/iscsi-sys-vm-shutdown-verify.ps1 @@ -1,9 +1,7 @@ #!/usr/bin/env pwsh - -Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false | Out-Null . /opt/idssys/powerwall/settings.ps1 -Connect-VIServer -Server $args[0] -Protocol https -User $ESXiUsername -Password $ESXiPassword | Out-Null +Connect-VIServer -Server $VCENTERHOST -Protocol https -User $VCENTERUSER -Password $VCENTERPASS | Out-Null Do { $VMLIST = Get-Datastore | Where {$_.Name -like '*iSCSI-SYS*'} | Get-VM @@ -28,4 +26,4 @@ Do { } Until ($poff -match 'yes') -Disconnect-VIServer -Server $args[0] -Force –Confirm:$false \ No newline at end of file +Disconnect-VIServer -Server $VCENTERHOST -Force –Confirm:$false diff --git a/esxi-scripts/iscsi-sys-vm-shutdown.ps1 b/esxi-scripts/iscsi-sys-vm-shutdown.ps1 index 4cbed451..02b74784 100755 --- a/esxi-scripts/iscsi-sys-vm-shutdown.ps1 +++ b/esxi-scripts/iscsi-sys-vm-shutdown.ps1 @@ -1,10 +1,8 @@ #!/usr/bin/env pwsh - -Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false | Out-Null . /opt/idssys/powerwall/settings.ps1 -Connect-VIServer -Server $args[0] -Protocol https -User $ESXiUsername -Password $ESXiPassword | Out-Null +Connect-VIServer -Server $VCENTERHOST -Protocol https -User $VCENTERUSER -Password $VCENTERPASS | Out-Null Get-Datastore | Where {$_.Name -like '*iSCSI-SYS*'} | Get-VM | Where {$_.PowerState -like '*On*' -and $_.Name -notlike '*CLS*'} | Shutdown-VMGuest -Confirm:$false -Disconnect-VIServer -Server $args[0] -Force –Confirm:$false \ No newline at end of file +Disconnect-VIServer -Server $VCENTERHOST -Force –Confirm:$false diff --git a/esxi-scripts/iscsi-vm-shutdown-verify.ps1 b/esxi-scripts/iscsi-vm-shutdown-verify.ps1 index dbe395d6..d2c97175 100755 --- a/esxi-scripts/iscsi-vm-shutdown-verify.ps1 +++ b/esxi-scripts/iscsi-vm-shutdown-verify.ps1 @@ -1,9 +1,7 @@ #!/usr/bin/env pwsh - -Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false | Out-Null . /opt/idssys/powerwall/settings.ps1 -Connect-VIServer -Server $args[0] -Protocol https -User $ESXiUsername -Password $ESXiPassword | Out-Null +Connect-VIServer -Server $VCENTERHOST -Protocol https -User $VCENTERUSER -Password $VCENTERPASS | Out-Null Do { $VMLIST = Get-Datastore | Where {$_.Name -like '*iSCSI-PRI*'} | Get-VM @@ -28,4 +26,4 @@ Do { } Until ($poff -match 'yes') -Disconnect-VIServer -Server $args[0] -Force –Confirm:$false \ No newline at end of file +Disconnect-VIServer -Server $VCENTERHOST -Force –Confirm:$false diff --git a/esxi-scripts/iscsi-vm-shutdown.ps1 b/esxi-scripts/iscsi-vm-shutdown.ps1 index 235805a8..53d409fa 100755 --- a/esxi-scripts/iscsi-vm-shutdown.ps1 +++ b/esxi-scripts/iscsi-vm-shutdown.ps1 @@ -1,10 +1,8 @@ #!/usr/bin/env pwsh - -Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false | Out-Null . /opt/idssys/powerwall/settings.ps1 -Connect-VIServer -Server $args[0] -Protocol https -User $ESXiUsername -Password $ESXiPassword | Out-Null +Connect-VIServer -Server $VCENTERHOST -Protocol https -User $VCENTERUSER -Password $VCENTERPASS | Out-Null Get-Datastore | Where {$_.Name -like '*iSCSI-PRI*'} | Get-VM | Where {$_.PowerState -like '*On*' -and $_.Name -notlike '*CLS*'} | Shutdown-VMGuest -Confirm:$false -Disconnect-VIServer -Server $args[0] -Force –Confirm:$false \ No newline at end of file +Disconnect-VIServer -Server $VCENTERHOST -Force –Confirm:$false diff --git a/inc/temp.inc.sh b/inc/temp.inc.sh index b697857d..6418fb63 100644 --- a/inc/temp.inc.sh +++ b/inc/temp.inc.sh @@ -329,7 +329,7 @@ CHECKTEMP_SERVICE(){ echo -e "($(date +'%Y-%m-%d %H:%M:%S')) - 'Check Temp' Service Startup" >> ${PW_LOGFILE} SENDTEMPS "TEMP Service Startup" & - [ ! -d ${PW_TMPFOLDER}/.lastfancheck ] && mkdir ${PW_TMPFOLDER}/.lastfancheck || rm -f ${PW_TMPFOLDER}/.lastfancheck/*.set + [ ! -d ${PW_TMPFOLDER}/.lastfancheck ] && mkdir ${PW_TMPFOLDER}/.lastfancheck #|| rm -f ${PW_TMPFOLDER}/.lastfancheck/*.set [ ! -d ${PW_TMPFOLDER}/.lastinsert ] && mkdir ${PW_TMPFOLDER}/.lastinsert [ -d ${PW_TMPFOLDER}/.lasttemp ] && rm -Rf ${PW_TMPFOLDER}/.lasttemp mkdir ${PW_TMPFOLDER}/.lasttemp @@ -547,7 +547,7 @@ CHECKTEMP_SERVICE_RUNSENSOR(){ elif [[ "${PW_ESXI_FANSPEEDCONTROL_HOSTS}" = *"${PW_HOST_IDRACS[${SENSORa}]}"* ]] && [[ "${vSENSOR}" = *"Exhaust"* ]]; then - if [ ! -f ${PW_TMPFOLDER}/.lastfancheck/${SENSORa}.set ] || [ $(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/.lastfancheck/${SENSORa}.set)) -ge 600 ]; then + if [ ! -f ${PW_TMPFOLDER}/.lastfancheck/${SENSORa}.set ] || [ $(expr `date +%s` - $(stat -c %Y ${PW_TMPFOLDER}/.lastfancheck/${SENSORa}.set)) -ge 300 ]; then if [ ! -f ${PW_TMPFOLDER}/.lastfancheck/${SENSORa}.set ] && (( $(bc <<< "${temp_f} < ${DEFAULT_ESXI_EXHAUST_MIN}") )); then if [ ${FanSpeed} -ne ${DEFAULT_ESXI_FANSPEED} ]; then if [[ "${PW_ESXI_FANSPEEDCONTROL_HOSTS}" = *"${PW_HOST_IDRACS[${SENSORa}]}"* ]]; then diff --git a/powerwall.sh b/powerwall.sh index dee2abb8..81293425 100755 --- a/powerwall.sh +++ b/powerwall.sh @@ -255,34 +255,34 @@ SHUTDOWN_SERVER(){ fi if [ "${ESXI_HOST}" == "10.10.2.10" ] || [ "${ESXI_HOST}" == "10.10.2.17" ] || [ "${ESXI_HOST}" == "MAIN" ] || [ "${ESXI_HOST}" == "MAINSITE" ] || [ "${ESXI_HOST}" == "ALL" ] || [ "${ESXI_HOST}" == "SYS" ] || [ "${ESXI_HOST}" == "CONSERVE" ]; then - for ESXIHOST in "${PW_MAINSITEHOSTS[@]}"; do + # for ESXIHOST in "${PW_MAINSITEHOSTS[@]}"; do if [ "${ESXI_HOST}" == "10.10.2.10" ] || [ "${ESXI_HOST}" == "MAIN" ] || [ "${ESXI_HOST}" == "CONSERVE" ]; then - MSG="Stopping iSCSI-PRI VM's on: ${PW_ESXI_HOST_NAMES[${ESXIHOST}]}" + MSG="Stopping all iSCSI-PRI VM's" elif [ "${ESXI_HOST}" == "10.10.2.17" ] || [ "${ESXI_HOST}" == "SYS" ]; then - MSG="Stopping iSCSI-SYS VM's on: ${PW_ESXI_HOST_NAMES[${ESXIHOST}]}" + MSG="Stopping all iSCSI-SYS VM's" elif [ "${ESXI_HOST}" == "MAINSITE" ] || [ "${ESXI_HOST}" == "ALL" ]; then - MSG="Stopping All iSCSI VM's on: ${PW_ESXI_HOST_NAMES[${ESXIHOST}]}" + MSG="Stopping all iSCSI VM's" fi c=0; MSG_SPC=''; spc1=`expr ${HC_CW} - ${#MSG}`; until [ ${c} = ${spc1} ]; do MSG_SPC="${MSG_SPC} "; ((c++)); done echo -en "${idsCL[White]}${MSG//${PW_ESXI_HOST_NAMES[${ESXIHOST}]}/${idsCL[LightCyan]}${PW_ESXI_HOST_NAMES[${ESXIHOST}]}}${idsCL[White]}${MSG_SPC}: " if [ "${TEST}" != "true" ]; then if [ "$(ipmitool -I lanplus -H ${PW_HOST_IDRACS[${PW_ESXI_HOST_NAMES[${ESXIHOST}]}]} -U ${PW_ESXI_USER} -P "${PW_ESXI_PASS}" chassis power status | grep 'Power is on')" != "" ]; then if [ "${ESXI_HOST}" == "10.10.2.10" ] || [ "${ESXI_HOST}" == "MAIN" ] || [ "${ESXI_HOST}" == "CONSERVE" ]; then - ${PW_FOLDER}/esxi-scripts/iscsi-vm-shutdown.ps1 ${ESXIHOST} >/dev/null 2>&1 & + ${PW_FOLDER}/esxi-scripts/iscsi-vm-shutdown.ps1 >/dev/null 2>&1 & elif [ "${ESXI_HOST}" == "10.10.2.17" ] || [ "${ESXI_HOST}" == "SYS" ]; then - ${PW_FOLDER}/esxi-scripts/iscsi-sys-vm-shutdown.ps1 ${ESXIHOST} >/dev/null 2>&1 & + ${PW_FOLDER}/esxi-scripts/iscsi-sys-vm-shutdown.ps1 >/dev/null 2>&1 & elif [ "${ESXI_HOST}" == "MAINSITE" ] || [ "${ESXI_HOST}" == "ALL" ]; then - ${PW_FOLDER}/esxi-scripts/iscsi-all-vm-shutdown.ps1 ${ESXIHOST} >/dev/null 2>&1 & + ${PW_FOLDER}/esxi-scripts/iscsi-all-vm-shutdown.ps1 >/dev/null 2>&1 & fi sleep 5s echo -e "${idsCL[Green]}Commands sent${idsCL[Default]}" - else - echo -e "${idsCL[Yellow]}Host Offline${idsCL[Default]}" + # else + # echo -e "${idsCL[Yellow]}Host Offline${idsCL[Default]}" fi else echo -e "${idsCL[Yellow]}(TEST MODE)${idsCL[Default]}" fi - done + # done echo fi @@ -360,15 +360,15 @@ SHUTDOWN_SERVER(){ MSG="Waiting for iSCSI VM's to power down" c=0; MSG_SPC=''; spc1=`expr ${HC_CW} - ${#MSG}`; until [ ${c} = ${spc1} ]; do MSG_SPC="${MSG_SPC} "; ((c++)); done echo -en "${idsCL[White]}${MSG}${idsCL[White]}${MSG_SPC}: " - for ESXIHOST in "${PW_MAINSITEHOSTS[@]}"; do + # for ESXIHOST in "${PW_MAINSITEHOSTS[@]}"; do if [ "${TEST}" != "true" ]; then - if [ "$(ipmitool -I lanplus -H ${PW_HOST_IDRACS[${PW_ESXI_HOST_NAMES[${ESXIHOST}]}]} -U ${PW_ESXI_USER} -P "${PW_ESXI_PASS}" chassis power status | grep 'Power is on')" != "" ] && [ "$(ssh -q -o ConnectTimeout=3 -o ConnectionAttempts=1 root@${ESXIHOST} 'esxcli system maintenanceMode get')" != "Enabled" ]; then - VERIFY_ISCSI_VM_DOWN "${ESXI_HOST}" "${ESXIHOST}" & - else - touch ${PW_TMPFOLDER}/verify.iscsi.${ESXIHOST}.done - fi + # if [ "$(ipmitool -I lanplus -H ${PW_HOST_IDRACS[${PW_ESXI_HOST_NAMES[${ESXIHOST}]}]} -U ${PW_ESXI_USER} -P "${PW_ESXI_PASS}" chassis power status | grep 'Power is on')" != "" ] && [ "$(ssh -q -o ConnectTimeout=3 -o ConnectionAttempts=1 root@${ESXIHOST} 'esxcli system maintenanceMode get')" != "Enabled" ]; then + VERIFY_ISCSI_VM_DOWN "${ESXI_HOST}" & + # else + # touch ${PW_TMPFOLDER}/verify.iscsi.${ESXIHOST}.done + # fi fi - done + # done if [ "${TEST}" != "true" ]; then nc_count=0 @@ -484,13 +484,13 @@ SHUTDOWN_SERVER(){ VERIFY_ISCSI_VM_DOWN(){ if [ "${1}" == "10.10.2.10" ] || [ "${1}" == "MAIN" ]; then - ${PW_FOLDER}/esxi-scripts/iscsi-vm-shutdown-verify.ps1 ${2} >/dev/null 2>&1 + ${PW_FOLDER}/esxi-scripts/iscsi-vm-shutdown-verify.ps1 >/dev/null 2>&1 elif [ "${1}" == "10.10.2.17" ] || [ "${1}" == "SYS" ]; then - ${PW_FOLDER}/esxi-scripts/iscsi-sys-vm-shutdown-verify.ps1 ${2} >/dev/null 2>&1 + ${PW_FOLDER}/esxi-scripts/iscsi-sys-vm-shutdown-verify.ps1 >/dev/null 2>&1 elif [ "${1}" == "MAINSITE" ] || [ "${1}" == "ALL" ]; then - ${PW_FOLDER}/esxi-scripts/iscsi-all-shutdown-verify.ps1 ${2} >/dev/null 2>&1 + ${PW_FOLDER}/esxi-scripts/iscsi-all-shutdown-verify.ps1 >/dev/null 2>&1 fi - touch ${PW_TMPFOLDER}/verify.iscsi.${2}.done + touch ${PW_TMPFOLDER}/verify.iscsi.done } HOSTMGMT(){