Add one-get-instances scripts

This commit is contained in:
fnux 2020-01-16 17:25:39 +01:00
parent eec032bc5b
commit 98d8c9810a
1 changed files with 18 additions and 0 deletions

18
one-get-instances Executable file
View File

@ -0,0 +1,18 @@
#!/bin/sh
#
# This script extract VM IDs and filter them if a pattern is provided as first
# argument.
set -e
# Extract instances from ONE.
instances=$(onevm list --csv | tail -n +2)
# Filter them is a pattern has been provided.
if [ "$1" != "" ]; then
filtered_instances="$(echo "$instances" | grep -E "$1")"
instances="$filtered_instances"
fi
# Outputs instance IDs.
echo "$instances" | cut -d ',' -f 1 -