working on support for managing VM state and IP address

This commit is contained in:
2021-12-05 16:47:37 -06:00
parent 9d74c99ce8
commit cc349d266f
16 changed files with 225 additions and 57 deletions

View File

@ -1,3 +0,0 @@
#!/bin/sh
virsh list --all | grep running | grep -v ' Id' | grep -v -- '----' | awk '{print $2}' | sort

View File

@ -8,15 +8,15 @@ if echo "$ip_address" | grep -vqE '^([0-9]{1,3}\.){3}[0-9]{1,3}$'; then
fi
printf '['
DELIMITER=""
delimiter=""
ssh-keyscan "$ip_address" 2>/dev/null | while read -r line; do
if echo "$line" | grep -qE "^$ip_address"' +(ssh|ecdsa)-[0-9A-Za-z+/_=@. -]+$'; then
KEY_CONTENT="$(echo "$line" | awk '{ print $2 " " $3 }')"
FINGERPRINT_OUTPUT="$(echo "$KEY_CONTENT" | ssh-keygen -l -E sha256 -f - | sed -E 's/^[0-9]+ SHA256:([0-9A-Za-z+/-]+) .+ \(([A-Z0-9]+)\)$/\1 \2/g')"
SHA256_HASH="$(echo "$FINGERPRINT_OUTPUT" | awk '{ print $1 }')"
KEY_TYPE="$(echo "$FINGERPRINT_OUTPUT" | awk '{ print $2 }')"
printf '%s\n {"key_type":"%s", "content":"%s", "sha256":"%s"}' "$DELIMITER" "$KEY_TYPE" "$KEY_CONTENT" "$SHA256_HASH"
DELIMITER=","
key_content="$(echo "$line" | awk '{ print $2 " " $3 }')"
fingerprint_output="$(echo "$key_content" | ssh-keygen -l -E sha256 -f - | sed -E 's/^[0-9]+ SHA256:([0-9A-Za-z+/-]+) .+ \(([A-Z0-9]+)\)$/\1 \2/g')"
sha256_hash="$(echo "$fingerprint_output" | awk '{ print $1 }')"
key_type="$(echo "$fingerprint_output" | awk '{ print $2 }')"
printf '%s\n {"key_type":"%s", "content":"%s", "sha256":"%s"}' "$delimiter" "$key_type" "$key_content" "$sha256_hash"
delimiter=","
fi
done
printf '\n]\n'

View File

@ -0,0 +1,13 @@
#!/bin/sh
printf '['
delimiter=""
virsh list --all | while read -r line; do
if echo "$line" | grep -qE '(running)|(shut off)'; then
capsul_id="$(echo "$line" | awk '{ print $2 }')"
capsul_state="$(echo "$line" | sed -E 's/.*((running)|(shut off))\w*/\1/')"
printf '%s\n {"id":"%s", "state":"%s"}' "$delimiter" "$capsul_id" "$capsul_state"
delimiter=","
fi
done
printf '\n]\n'

View File

@ -0,0 +1,3 @@
#!/bin/sh
virsh net-list --all | tail -n +3 | awk '{ print $1 }'