Commit 2447aa25 authored by Vitaly Lipatov's avatar Vitaly Lipatov

improve pct support (fix lists and name to id conversion)

parent 54f1433d
...@@ -69,6 +69,11 @@ $(get_help HELPCMD) ...@@ -69,6 +69,11 @@ $(get_help HELPCMD)
Options: Options:
$(get_help HELPOPT) $(get_help HELPOPT)
Params:
ALL - all (even stopped) machines
all - all running machines
ID - id of a machine
Examples: Examples:
# evz start ID ID ID # evz start ID ID ID
# evz list ALL # evz list ALL
...@@ -80,7 +85,7 @@ $(get_help HELPOPT) ...@@ -80,7 +85,7 @@ $(get_help HELPOPT)
print_version() print_version()
{ {
echo "Etersoft virtualization wrapper version @VERSION@" echo "Etersoft virtualization wrapper version @VERSION@"
echo "Copyright (c) Etersoft 2017, 2020, 2021" echo "Copyright (c) Etersoft 2017, 2020, 2021, 2022"
echo "This program may be freely redistributed under the terms of the GNU AGPLv3." echo "This program may be freely redistributed under the terms of the GNU AGPLv3."
} }
......
...@@ -41,15 +41,37 @@ get_list() ...@@ -41,15 +41,37 @@ get_list()
list_all list_all
} }
arg_is_id()
is_existing_id()
{ {
[ -n "$1" ] || return 1
echo " $(list_ALL) " | grep -q " $1 " && return 0 echo " $(list_ALL) " | grep -q " $1 " && return 0
return 1
}
is_existing_name()
{
like_id "$1" && return 1
echo " $(list_ALL_names) " | grep -q " $1 " && return 0 echo " $(list_ALL_names) " | grep -q " $1 " && return 0
return 1
}
arg_is_id()
{
[ -n "$1" ] || return 1
is_existing_id "$1" && return 0
is_existing_name "$1" && return 0
like_id "$1" && fatal "ID $1 is missed on the host. Check # evz list -a output" like_id "$1" && fatal "ID $1 is missed on the host. Check # evz list -a output"
return 1 return 1
} }
get_id_by_name()
{
list_id_names | grep " $1\$" | sed -e "s| .*||"
}
arg_is_all() arg_is_all()
{ {
[ "$1" = "ALL" ] && return [ "$1" = "ALL" ] && return
...@@ -85,7 +107,12 @@ fill_args_list() ...@@ -85,7 +107,12 @@ fill_args_list()
else else
while [ -n "$1" ] ; do while [ -n "$1" ] ; do
arg_is_id "$1" || break arg_is_id "$1" || break
LIST="$LIST $1" local id="$1"
if is_existing_name "$id" ; then
id=$(get_id_by_name "$1")
[ -n "$id" ] || fatal "something goes wrong with $1"
fi
LIST="$LIST $id"
shift shift
done done
fi fi
......
...@@ -25,8 +25,7 @@ list_all() ...@@ -25,8 +25,7 @@ list_all()
return return
fi fi
# TODO a= pct list | grep "running" | grep "[0-9]\+" | sed -e "s| *\([0-9]\+\) .*|\1|" | line_filter
#a= pct list | grep "[0-9]\+" | sed -e "s| *\([0-9]\+\) .*|\1|" | line_filter
} }
# list all containers (or by arg list) # list all containers (or by arg list)
...@@ -37,14 +36,17 @@ list_ALL() ...@@ -37,14 +36,17 @@ list_ALL()
return return
fi fi
# TODO a= pct list | grep "[0-9]\+" | sed -e "s| *\([0-9]\+\) .*|\1|" | line_filter
#a= pct list | grep "[0-9]\+" | sed -e "s| *\([0-9]\+\) .*|\1|" | line_filter
} }
list_ALL_names() list_ALL_names()
{ {
# TODO a= pct list | grep "[0-9]\+" | sed -e "s| *$||" | sed -e "s|.* ||" | line_filter
return }
list_id_names()
{
a= pct list | grep "[0-9]\+" | sed -e "s| *$||" -e "s| *\([0-9]\+\) *\(.*\) \+\(.*\)$|\1 \3|"
} }
like_id() like_id()
...@@ -175,7 +177,8 @@ case $CMD in ...@@ -175,7 +177,8 @@ case $CMD in
done done
;; ;;
enter) # HELPCMD: enter in a container with ID enter) # HELPCMD: enter in a container with ID
docmd pct enter "$1" fill_args_list "$1"
docmd pct enter $LIST
#a= docker exec -ti $SETLANG "$1" bash #a= docker exec -ti $SETLANG "$1" bash
;; ;;
log|logs) # HELPCMD: print container log log|logs) # HELPCMD: print container log
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment