From c2eca53c748e463cc47d849b56cef8f58276c57f Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Tue, 14 Jun 2016 21:09:28 +0200 Subject: Showing local containers in container list command only. Signed-off-by: Daniel Baumann --- lib/container/list | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'lib/container') diff --git a/lib/container/list b/lib/container/list index 7d66da1..506340e 100755 --- a/lib/container/list +++ b/lib/container/list @@ -20,12 +20,13 @@ set -e COMMAND="$(basename ${0})" +CONFIG="/etc/container-tools/config" MACHINES="/var/lib/machines" Parameters () { - LONG_OPTIONS="all,format:,started,stopped" - OPTIONS="a,f:,s,t" + LONG_OPTIONS="all,format:,host:,started,stopped" + OPTIONS="a,f:,h:,s,t" PARAMETERS="$(getopt --longoptions ${LONG_OPTIONS} --name=${COMMAND} --options ${OPTIONS} --shell sh -- ${@})" @@ -50,6 +51,11 @@ Parameters () shift 2 ;; + -h|--host) + HOST="${2}" + shift 2 + ;; + -s|--started) LIST="started" shift 1 @@ -83,6 +89,7 @@ Parameters "${@}" LIST="${LIST:-all}" FORMAT="${FORMAT:-full}" +HOST="${HOST:-$(hostname -f)}" # Run case "${FORMAT}" in @@ -108,6 +115,26 @@ CONTAINERS="$(cd "${MACHINES}" 2>/dev/null && find -maxdepth 1 -type d -and -not for CONTAINER in ${CONTAINERS} do + if [ "${HOST}" != "all" ] + then + if [ -e "${CONFIG}/${CONTAINER}.conf" ] + then + AUTO="$(awk -F= '/^cnt.auto=/ { print $2 }' ${CONFIG}/${CONTAINER}.conf)" + AUTO="${AUTO:-false}" + + case "${AUTO}" in + ${HOST}|true) + ;; + + *) + continue + ;; + esac + else + continue + fi + fi + # FIXME: ignore lxc container for now if [ -e "${MACHINES}/${CONTAINER}/rootfs" ] then -- cgit v1.2.3