From abc7b5d7905abda4d9a66ece533cb411fee6441a Mon Sep 17 00:00:00 2001 From: kjg Date: Thu, 23 Jul 2026 22:51:19 +0900 Subject: [PATCH] [ungleich-tools] create script for VM ID --- k8s/k8s-opennebul-get-vmip.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 k8s/k8s-opennebul-get-vmip.sh diff --git a/k8s/k8s-opennebul-get-vmip.sh b/k8s/k8s-opennebul-get-vmip.sh new file mode 100755 index 0000000..698b4fb --- /dev/null +++ b/k8s/k8s-opennebul-get-vmip.sh @@ -0,0 +1,19 @@ +#!/bin/sh +# get VM_ID via IPv6 address + +TARGET="${1:-}" + +if [ -z "$TARGET" ]; then + echo "Usage: $0 " >&2 + echo "Example: $0 2a0a:e5c0:2:2:0:c8ff:fe68:bee8" >&2 + exit 1 +fi + +POD=$(kubectl -n ungleich get pods \ + -l app.kubernetes.io/component=opennebula --output=jsonpath={.items..metadata.name}) + +IDS=$(kubectl exec -ti $POD -n ungleich -c oned -- /bin/bash -c "onevm list --xml | xmllint --xpath '//VM[TEMPLATE/NIC/IP6_GLOBAL=\"$TARGET\"]/ID/text()' -") + +printf 'VM ID: %s\n' "$IDS" + +# kubectl -n ungleich exec -ti $POD -c oned -- /bin/bash