Skip to content
Snippets Groups Projects
Verified Commit e05d20c9 authored by Jörg Sachse's avatar Jörg Sachse
Browse files

feat: use SSH control socket for connection to NetApp in order to reduce SSH...

feat: use SSH control socket for connection to NetApp in order to reduce SSH connection overhead there and improve plugin reliability
parent edf76bfa
No related branches found
No related tags found
No related merge requests found
Pipeline #10356 failed
......@@ -78,11 +78,15 @@ function help () {
# IMPORTANT: Set lock using "flock", NOT "touch"!!! It's atomic and doesn't have to be cleared after the script ran.
(
flock -n 9 || exit 1
flock -E 100 -n 9 || exit 1
NFS_SHARES=$( findmnt --raw --noheadings --types "nfs4" | cut -d " " -f 2 )
SSH_CONTROL_PATH='/tmp/ssh-%r-%h-%p'
# create SSH control socket
ssh -fN -o StrictHostKeyChecking=no -oControlMaster=yes -oControlPath="${SSH_CONTROL_PATH}" -oControlPersist=60 -i "${IDENTITY_FILE}" "${SSH_USER}"@"${MGMT}"
for SHARE in ${NFS_SHARES}; do
NETAPP_VOLUME=$( echo "${SHARE}" | cut -d ":" -f 2 | cut -d '/' -f 3 )
RESULT=$( ssh -o StrictHostKeyChecking=no "${SSH_USER}"@"${MGMT}" -C -i "${IDENTITY_FILE}" "${NETAPP_SETTINGS} volume show -vserver ${NETAPP_VSERVER} -volume ${NETAPP_VOLUME} -fields $NETAPP_FIELDS" )
# use SSH control socket to run commands over existing connection
RESULT=$( ssh -o StrictHostKeyChecking=no -oControlMaster=no -oControlPath="${SSH_CONTROL_PATH}" -i "${IDENTITY_FILE}" "${SSH_USER}"@"${MGMT}" -t "${NETAPP_SETTINGS} volume show -vserver ${NETAPP_VSERVER} -volume ${NETAPP_VOLUME} -fields $NETAPP_FIELDS" )
[[ -z "${RESULT}" ]] && echo "Didn't get a valid answer from NetApp system for ${NETAPP_VOLUME}."
RESULT=$( echo "${RESULT}" | tail -n 2 | tr -d '\r' )
OLDIFS=${IFS}
......@@ -96,6 +100,8 @@ flock -n 9 || exit 1
done
IFS=${OLDIFS}
done
# close SSH control socket
ssh -o StrictHostKeyChecking=no -S "${SSH_CONTROL_PATH}" -i "${IDENTITY_FILE}" "${SSH_USER}"@"${MGMT}" -O exit
) 9>"${LOCKFILE}"
# Code checked by shellcheck (https://github.com/koalaman/shellcheck) on 2021-02-19
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment