summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@open-infrastructure.net>2016-06-14 19:09:28 +0000
committerDaniel Baumann <daniel.baumann@open-infrastructure.net>2016-06-14 19:09:28 +0000
commitc2eca53c748e463cc47d849b56cef8f58276c57f (patch)
tree243e816e9d6b0e1aa590c721eadc3558419fe299 /lib
parentCorrecting aligning in container list command. (diff)
downloadcompute-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-xlib/container/list31
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