Skip to content

Commit 7a543e9

Browse files
committed
set_xva_bridge: don't check existing bridge name
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]>
1 parent 5b27920 commit 7a543e9

File tree

1 file changed

+0
-33
lines changed

1 file changed

+0
-33
lines changed

scripts/set_xva_bridge.sh

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,6 @@ usage()
1212
echo "----------------------------------------------------------------------------------------"
1313
}
1414

15-
# extract and read ova.xml
16-
get_bridge()
17-
{
18-
TMPFOLD=$(mktemp -d /tmp/xvaXXXX)
19-
tar -xf "${XVA_NAME}" -C "${TMPFOLD}" ova.xml
20-
chmod +r "${TMPFOLD}/ova.xml"
21-
XML_VALUE=$(grep -oE "<member><name>bridge</name><value>[^<]*</value></member>" "${TMPFOLD}/ova.xml")
22-
LENGTH=${#XML_VALUE}
23-
PREFIX_LENGTH=$((${LENGTH}-17))
24-
NETWORK_VALUE=$(cut -c 1-${PREFIX_LENGTH} <<< ${XML_VALUE})
25-
echo $(cut -c 35-${#NETWORK_VALUE} <<< ${NETWORK_VALUE})
26-
27-
if [ -d "${TMPFOLD}" ]; then
28-
rm -Rf "${TMPFOLD}"
29-
fi
30-
}
31-
3215
# check parameters and prompt the usage if needed
3316
if [ -z "${1+set}" ]
3417
then
@@ -70,22 +53,6 @@ else
7053
BRIDGE_VALUE=$3
7154
fi
7255

73-
# we want to know the value of the network bridge.
74-
# then we can decide if we need to change it or not.
75-
BRIDGE_READVALUE=$(get_bridge)
76-
77-
if [ -z "${BRIDGE_READVALUE}" ]
78-
then
79-
echo "No bridge value detected in the xml file!"
80-
exit 1
81-
else
82-
if [ "${BRIDGE_READVALUE}" == "${BRIDGE_VALUE}" ]
83-
then
84-
echo "The bridge is already ${BRIDGE_VALUE}. Nothing to do."
85-
exit 0
86-
fi
87-
fi
88-
8956
# we detect the compression method of the xva to uncompress it right
9057
OLD_COMPRESSION=$(file -b "${XVA_NAME}" | cut -f 1 -d " ")
9158
if [ "${OLD_COMPRESSION}" != "Zstandard" ] && [ "${OLD_COMPRESSION}" != "gzip" ] && [ "${OLD_COMPRESSION}" != "tar" ]; then

0 commit comments

Comments
 (0)