Commit 5a56feed authored by Vitaly Lipatov's avatar Vitaly Lipatov

add fill_args_list and use it intead of copy-paste code

parent 0dad37db
......@@ -102,9 +102,10 @@ case $CMD in
done
;;
set) # HELPCMD: set param. Use with --option param
fill_args_list "$@"
for i in $LIST ; do
info "Do $CMD on $i ..."
todo vzctl $CMD $i $OPTIONS --save
#info "Do $CMD on $i ..."
todo docmdeval $CMD $i "$OPTARGS" --save
done
;;
ubc|resources|show) # HELPCMD: print resource using
......@@ -149,24 +150,9 @@ case $CMD in
info "See evz ports ID for print ports"
;;
exec) # HELPCMD: execute command by list (all for all containers)
###################################
# the same code like in set)
# get all args until ids or all/ALL
LIST=""
if arg_is_all "$1" ; then
LIST="$(get_list "$1")"
shift
else
while [ -n "$1" ] ; do
arg_is_id "$1" || break
LIST="$LIST $1"
shift
done
fi
###################################
fill_args_list "$@"
for i in $LIST ; do
docmd docker exec -ti $SETLANG "$i" "$@"
docmdeval docker exec -ti $SETLANG "$i" "$QUOTEDARGS"
done
;;
enter) # HELPCMD: enter in a container with ID
......
......@@ -74,3 +74,21 @@ quote_args()
done
}
# will fill LIST with ids and QUOTEDARGS with other
fill_args_list()
{
# get all args until ids or all/ALL
LIST=""
if arg_is_all "$1" ; then
LIST="$(get_list "$1")"
shift
else
while [ -n "$1" ] ; do
arg_is_id "$1" || break
LIST="$LIST $1"
shift
done
fi
QUOTEDARGS="$(quote_args "$@")"
}
......@@ -102,25 +102,10 @@ case $CMD in
done
;;
set) # HELPCMD: set param. Use with --option param
###################################
# the same code like in set)
# get all args until ids or all/ALL
LIST=""
if arg_is_all "$1" ; then
LIST="$(get_list "$1")"
shift
else
while [ -n "$1" ] ; do
arg_is_id "$1" || break
LIST="$LIST $1"
shift
done
fi
###################################
fill_args_list "$@"
for i in $LIST ; do
info "Do $CMD on $i ..."
docmd pct set $i "$@"
docmdeval pct set $i "$QUOTEDARGS"
done
;;
ubc|resources|show) # HELPCMD: print resource using
......@@ -184,24 +169,9 @@ case $CMD in
#info "See evz ports ID for print ports"
;;
exec) # HELPCMD: execute command by list (all for all containers)
###################################
# the same code like in set)
# get all args until ids or all/ALL
LIST=""
if arg_is_all "$1" ; then
LIST="$(get_list "$1")"
shift
else
while [ -n "$1" ] ; do
arg_is_id "$1" || break
LIST="$LIST $1"
shift
done
fi
###################################
fill_args_list "$@"
for i in $LIST ; do
docmd pct exec "$i" "$@"
docmd pct exec "$i" "$QUOTEDARGS"
done
;;
enter) # HELPCMD: enter in a container with ID
......
......@@ -100,12 +100,9 @@ case $CMD in
done
;;
set) # HELPCMD: set param. Use with --option param
OPTIONS="$1 $2"
shift 2
LIST="$(get_list "$@")"
fill_args_list "$@"
for i in $LIST ; do
info "Do $CMD on $i ..."
todo vzctl $CMD $i $OPTIONS --save
docmd vzctl $CMD $i "$QUOTEDARGS" --save
done
;;
ubc|resources|show) # HELPCMD: print resource using
......@@ -150,9 +147,7 @@ case $CMD in
fi
;;
exec) # HELPCMD: execute command by list (all for all containers)
INCMD="$1"
shift
LIST="$(get_list "$@")"
fill_args_list "$@"
for i in $LIST ; do
todo showcmd docker exec -ti $SETLANG "$i" "$INCMD"
#a= docker exec -ti $SETLANG "$i" "$INCMD"
......
......@@ -104,26 +104,11 @@ case $CMD in
done
;;
set) # HELPCMD: set param. Use with --option param
###################################
# the same code like in set)
# get all args until ids or all/ALL
LIST=""
if arg_is_all "$1" ; then
LIST="$(get_list "$1")"
shift
else
while [ -n "$1" ] ; do
arg_is_id "$1" || break
LIST="$LIST $1"
shift
done
fi
###################################
fill_args_list "$@"
# show help if empty
[ -n "$LIST" ] || docmd vboxmanage modifyvm
for i in $LIST ; do
docmd vboxmanage modifyvm $i "$@"
docmdeval vboxmanage modifyvm $i "$QUOTEDARGS"
done
;;
ubc|resources|show) # HELPCMD: print resource using by virtual machine(s)
......@@ -185,9 +170,7 @@ case $CMD in
fi
;;
exec) # HELPCMD: execute command by list (all for all virtual machines)
INCMD="$1"
shift
LIST="$(get_list "$@")"
fill_args_list "$@"
for i in $LIST ; do
todo showcmd docker exec -ti $SETLANG "$i" "$INCMD"
todo a= docker exec -ti $SETLANG "$i" "$INCMD"
......
......@@ -80,23 +80,9 @@ case $CMD in
done
;;
set) # HELPCMD: set param. Use with --option param
###################################
# get all args until ids or all/ALL
LIST=""
if arg_is_all "$1" ; then
LIST="$(get_list "$1")"
shift
else
while [ -n "$1" ] ; do
arg_is_id "$1" || break
LIST="$LIST $1"
shift
done
fi
###################################
fill_args_list "$@"
for i in $LIST ; do
docmd vzctl $CMD $i "$@" --save
docmdeval vzctl set $i "$QUOTEDARGS" --save
done
;;
ubc|resources|show) # HELPCMD: print resource using via vzubc
......@@ -141,27 +127,9 @@ case $CMD in
fi
;;
exec) # HELPCMD: execute command by list (all for all containers)
###################################
# the same code like in set)
# get all args until ids or all/ALL
LIST=""
if arg_is_all "$1" ; then
LIST="$(get_list "$1")"
shift
else
while [ -n "$1" ] ; do
arg_is_id "$1" || break
LIST="$LIST $1"
shift
done
fi
###################################
fill_args_list "$@"
for i in $LIST ; do
#info "Executing on $i ..."
#printf "%3d: %s" $i "$(vzctl exec $i "$INCMD")"
#vzctl exec $i "$INCMD" | sed -e "s|^|$(printf "%3d: " $i)|g"
docmd vzctl exec $i "$@"
docmdeval vzctl exec $i "$QUOTEDARGS"
done
;;
enter) # HELPCMD: enter in a container with ID
......
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