summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@open-infrastructure.net>2021-06-06 14:04:06 +0000
committerDaniel Baumann <daniel.baumann@open-infrastructure.net>2021-06-06 16:08:11 +0000
commit8485bd8c3cf8eaf6fd7bb5758ce6c095cc5e8b58 (patch)
treefb6692bca608e75bbc0db6c37c52c0fb313b1452 /lib
parentAllowing to specify cnt.start=force in container config to ease fencing with ... (diff)
downloadcompute-tools-8485bd8c3cf8eaf6fd7bb5758ce6c095cc5e8b58.tar.xz
compute-tools-8485bd8c3cf8eaf6fd7bb5758ce6c095cc5e8b58.zip
Using cnt run to determine IP addresses in container list.
Signed-off-by: Daniel Baumann <daniel.baumann@open-infrastructure.net>
Diffstat (limited to '')
-rwxr-xr-xlibexec/container/list25
1 files changed, 17 insertions, 8 deletions
diff --git a/libexec/container/list b/libexec/container/list
index 30446c0..3ef6e49 100755
--- a/libexec/container/list
+++ b/libexec/container/list
@@ -366,15 +366,24 @@ do
ADDRESS=""
- if ls "${MACHINES}/${CONTAINER}/etc/systemd/network"/*.network > /dev/null 2>&1
- then
- ADDRESS="$(awk -FAddress= '/^Address/ { print $2 }' ${MACHINES}/${CONTAINER}/etc/systemd/network/*.network | head -n1)"
- elif [ -e "${MACHINES}/${CONTAINER}/etc/network/interfaces" ]
- then
- ADDRESS="$(awk '/address/ { print $2 }' ${MACHINES}/${CONTAINER}/etc/network/interfaces | head -n1)"
- fi
+ case "${STATE}" in
+ started)
+ ADDRESS="$(cnt run -n ${CONTAINER} -- hostname -I | sed -e 's|\r$||' | awk '{ print $1 }')"
+ ADDRESS="${ADDRESS:-none}"
+ ;;
- ADDRESS="${ADDRESS:-n/a}"
+ *)
+ if ls "${MACHINES}/${CONTAINER}/etc/systemd/network"/*.network > /dev/null 2>&1
+ then
+ ADDRESS="$(awk -FAddress= '/^Address/ { print $2 }' ${MACHINES}/${CONTAINER}/etc/systemd/network/*.network | head -n1)"
+ elif [ -e "${MACHINES}/${CONTAINER}/etc/network/interfaces" ]
+ then
+ ADDRESS="$(awk '/address/ { print $2 }' ${MACHINES}/${CONTAINER}/etc/network/interfaces | head -n1)"
+ fi
+
+ ADDRESS="${ADDRESS:-n/a}"
+ ;;
+ esac
if echo ${LIST} | grep -qs all
then