Skip to content

Commit

Permalink
set_xva_bridge: don't check existing bridge name
Browse files Browse the repository at this point in the history
Bridge name can be checked through get_xva_bridge, no need to spend
another pass on the XVA file for this.

Signed-off-by: Tu Dinh <[email protected]>
  • Loading branch information
Tu Dinh committed Jan 10, 2025
1 parent 5b27920 commit 7a543e9
Showing 1 changed file with 0 additions and 33 deletions.
33 changes: 0 additions & 33 deletions scripts/set_xva_bridge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,6 @@ usage()
echo "----------------------------------------------------------------------------------------"
}

# extract and read ova.xml
get_bridge()
{
TMPFOLD=$(mktemp -d /tmp/xvaXXXX)
tar -xf "${XVA_NAME}" -C "${TMPFOLD}" ova.xml
chmod +r "${TMPFOLD}/ova.xml"
XML_VALUE=$(grep -oE "<member><name>bridge</name><value>[^<]*</value></member>" "${TMPFOLD}/ova.xml")
LENGTH=${#XML_VALUE}
PREFIX_LENGTH=$((${LENGTH}-17))
NETWORK_VALUE=$(cut -c 1-${PREFIX_LENGTH} <<< ${XML_VALUE})
echo $(cut -c 35-${#NETWORK_VALUE} <<< ${NETWORK_VALUE})

if [ -d "${TMPFOLD}" ]; then
rm -Rf "${TMPFOLD}"
fi
}

# check parameters and prompt the usage if needed
if [ -z "${1+set}" ]
then
Expand Down Expand Up @@ -70,22 +53,6 @@ else
BRIDGE_VALUE=$3
fi

# we want to know the value of the network bridge.
# then we can decide if we need to change it or not.
BRIDGE_READVALUE=$(get_bridge)

if [ -z "${BRIDGE_READVALUE}" ]
then
echo "No bridge value detected in the xml file!"
exit 1
else
if [ "${BRIDGE_READVALUE}" == "${BRIDGE_VALUE}" ]
then
echo "The bridge is already ${BRIDGE_VALUE}. Nothing to do."
exit 0
fi
fi

# we detect the compression method of the xva to uncompress it right
OLD_COMPRESSION=$(file -b "${XVA_NAME}" | cut -f 1 -d " ")
if [ "${OLD_COMPRESSION}" != "Zstandard" ] && [ "${OLD_COMPRESSION}" != "gzip" ] && [ "${OLD_COMPRESSION}" != "tar" ]; then
Expand Down

0 comments on commit 7a543e9

Please sign in to comment.