From f3a219755c382d81d7dc385bce237932401c5bde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Floure?= Date: Thu, 16 Jan 2020 17:25:39 +0100 Subject: [PATCH] Add one-get-instances scripts --- one-get-instances | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 one-get-instances diff --git a/one-get-instances b/one-get-instances new file mode 100755 index 0000000..653fed6 --- /dev/null +++ b/one-get-instances @@ -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 -