Skip to content

Commit b241f2b

Browse files
committed
Dev: adapt to podman5 network inspect
1 parent 0af43cf commit b241f2b

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

test/run-functional-tests

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,26 @@ create_node() {
241241
}
242242

243243

244+
is_podman5_or_newer() {
245+
podman_version=$(podman --version | awk '{print $3}')
246+
podman_ver=$(echo $podman_version | cut -d '.' -f 1-2)
247+
248+
if [[ "$(echo -e "$podman_ver\n5.0" | sort -V | head -n 1)" == "5.0" ]]; then
249+
info "Podman version 5.x or newer is detected: $podman_version"
250+
return 0
251+
else
252+
return 1
253+
fi
254+
}
255+
244256
config_cluster() {
245257
node_num=$#
246258
insert_str=""
247-
container_ip_array=(`podman network inspect $HA_NETWORK_ARRAY -f '{{range .Containers}}{{printf "%s " .IPv4Address}}{{end}}'`)
259+
if [[ is_podman5_or_newer ]];then
260+
container_ip_array=($(podman network inspect $HA_NETWORK_ARRAY | jq -r '.[] | .containers[] | .interfaces[] | .subnets[] | select(.ipnet | test("^(\\d{1,3}\\.){3}\\d{1,3}\\/\\d+$")) | .ipnet | split("/") | .[0]'))
261+
else
262+
container_ip_array=(`podman network inspect $HA_NETWORK_ARRAY -f '{{range .Containers}}{{printf "%s " .IPv4Address}}{{end}}'`)
263+
fi
248264

249265
for i in $(seq $node_num -1 1);do
250266
ip=`echo ${container_ip_array[$((i-1))]}|awk -F/ '{print $1}'`

0 commit comments

Comments
 (0)