summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@open-infrastructure.net>2018-05-27 18:32:24 +0000
committerDaniel Baumann <daniel.baumann@open-infrastructure.net>2018-05-27 18:44:03 +0000
commit9dfb6f87d0696fbf1930eda7d1957f52f2551988 (patch)
tree2608c0c8607a1689c23bde67cf10be7cb8cb23ad /lib
parentCorrecting typo in verbose option handling of container remove command. (diff)
downloadcompute-tools-9dfb6f87d0696fbf1930eda7d1957f52f2551988.tar.xz
compute-tools-9dfb6f87d0696fbf1930eda7d1957f52f2551988.zip
Adding 'ALL' as pseudo container name for container start, stop, restart, and remove commands to act on all available container respectivly.
Signed-off-by: Daniel Baumann <daniel.baumann@open-infrastructure.net>
Diffstat (limited to 'lib')
-rwxr-xr-xlib/container/remove21
-rwxr-xr-xlib/container/restart15
-rwxr-xr-xlib/container/start17
-rwxr-xr-xlib/container/stop20
4 files changed, 73 insertions, 0 deletions
diff --git a/lib/container/remove b/lib/container/remove
index 427bf4a..275c867 100755
--- a/lib/container/remove
+++ b/lib/container/remove
@@ -28,6 +28,8 @@ MACHINES="/var/lib/machines"
Parameters ()
{
+ OPTIONS_ALL=""
+
GETOPT_LONGOPTIONS="name:,allow-stop,force,verbose,"
GETOPT_OPTIONS="n:,f,v,"
@@ -52,16 +54,22 @@ Parameters ()
--allow-stop)
ALLOW_STOP="true"
shift 1
+
+ OPTIONS_ALL="${OPTIONS_ALL} --allow-stop"
;;
-f|--force)
FORCE="true"
shift 1
+
+ OPTIONS_ALL="${OPTIONS_ALL} --force"
;;
-v|--verbose)
VERBOSE="true"
shift 1
+
+ OPTIONS_ALL="${OPTIONS_ALL} --verbose"
;;
--)
@@ -111,6 +119,19 @@ then
Usage
fi
+case "${NAME}" in
+ ALL)
+ NAMES="$(container list --format shell --stopped)"
+
+ for NAME in ${NAMES}
+ do
+ container remove --name ${NAME} ${OPTIONS_ALL} || true
+ done
+
+ exit 0
+ ;;
+esac
+
if [ ! -e "${MACHINES}/${NAME}" ] && [ ! -e "${CONFIG}/${NAME}.conf" ]
then
echo "'${NAME}': no such container" >&2
diff --git a/lib/container/restart b/lib/container/restart
index a507cc0..a22b970 100755
--- a/lib/container/restart
+++ b/lib/container/restart
@@ -27,6 +27,8 @@ MACHINES="/var/lib/machines"
Parameters ()
{
+ OPTIONS_ALL=""
+
GETOPT_LONGOPTIONS="name:,"
GETOPT_OPTIONS="n:,"
@@ -74,6 +76,19 @@ then
Usage
fi
+case "${NAME}" in
+ ALL)
+ NAMES="$(container list --format shell --started)"
+
+ for NAME in ${NAMES}
+ do
+ container restart --name ${NAME} || true
+ done
+
+ exit 0
+ ;;
+esac
+
if [ ! -e "${MACHINES}/${NAME}" ]
then
echo "'${NAME}': no such container" >&2
diff --git a/lib/container/start b/lib/container/start
index e4b2ee6..62fb926 100755
--- a/lib/container/start
+++ b/lib/container/start
@@ -31,6 +31,8 @@ SYSTEMCTL="true"
Parameters ()
{
+ OPTIONS_ALL=""
+
GETOPT_LONGOPTIONS="name:,force,nspawn,start,"
GETOPT_OPTIONS="n:f,"
@@ -55,6 +57,8 @@ Parameters ()
-f|--force)
FORCE="true"
shift 1
+
+ OPTIONS_ALL="${OPTIONS_ALL} --force"
;;
--nspawn)
@@ -96,6 +100,19 @@ then
Usage
fi
+case "${NAME}" in
+ ALL)
+ NAMES="$(container list --format shell --stopped)"
+
+ for NAME in ${NAMES}
+ do
+ container start --name ${NAME} ${OPTIONS_ALL} || true
+ done
+
+ exit 0
+ ;;
+esac
+
if [ ! -e "${MACHINES}/${NAME}" ]
then
echo "'${NAME}': no such container" >&2
diff --git a/lib/container/stop b/lib/container/stop
index 5099005..d996282 100755
--- a/lib/container/stop
+++ b/lib/container/stop
@@ -30,6 +30,8 @@ CLEAN="false"
Parameters ()
{
+ OPTIONS_ALL=""
+
GETOPT_LONGOPTIONS="name:,force,clean,"
GETOPT_OPTIONS="n:,f,"
@@ -53,12 +55,17 @@ Parameters ()
-f|--force)
FORCE="true"
+ shift 1
+
+ OPTIONS_ALL="${OPTIONS_ALL} --force"
;;
--clean)
# internal option
CLEAN="true"
shift 1
+
+ OPTONS_ALL="${OPTIONS_ALL} --clean"
;;
--)
@@ -108,6 +115,19 @@ then
Usage
fi
+case "${NAME}" in
+ ALL)
+ NAMES="$(container list --format shell --started)"
+
+ for NAME in ${NAMES}
+ do
+ container stop --name ${NAME} ${OPTIONS_ALL} || true
+ done
+
+ exit 0
+ ;;
+esac
+
if [ ! -e "${MACHINES}/${NAME}" ]
then
echo "'${NAME}': no such container" >&2