diff options
author | Daniel Baumann <daniel.baumann@open-infrastructure.net> | 2016-06-14 19:09:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@open-infrastructure.net> | 2016-06-14 19:09:28 +0000 |
commit | c2eca53c748e463cc47d849b56cef8f58276c57f (patch) | |
tree | 243e816e9d6b0e1aa590c721eadc3558419fe299 /lib | |
parent | Correcting aligning in container list command. (diff) | |
download | compute-tools-c2eca53c748e463cc47d849b56cef8f58276c57f.tar.xz compute-tools-c2eca53c748e463cc47d849b56cef8f58276c57f.zip |
Showing local containers in container list command only.
Signed-off-by: Daniel Baumann <daniel.baumann@open-infrastructure.net>
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/container/list | 31 |
1 files changed, 29 insertions, 2 deletions
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 |