Hi Serge,
>> to assist to avoid such problems i would propose to introduce macro
>> expansion (of the own tags but also by incorporating the
>environment variables) into the configuration argument parser and to provide
>some useful basics like the container name. Then one may
>use e.g.
>>
>> lxc.hook.mount = $MYCONTAINER_HOME/hooks/$lxc.name
>
>That sounds good. Would you be able to post a patch to do this?
I'm very sorry, I'm no C code developer but a system engineer. I understand a
lot of different code just from reading and may even point out bugs. Or more
abstract things like this :}
>And if you had this, you'd be able to simply use lxc-start without
>the -s? That sounds worthwhile then.
>
>Can you show us an example of a pre-parsed config, and the final
>executed lxc-start command?
I'm using the standard lxc configuration file just for the general setup. The
concrete details are in an additional file per container. But a concrete
containers extra config file might be a symlink to a file describing the
configuration for a class of containers. Also, the container standard config
file normally is a symlink to a central version. By cheating around with such
symlinks, I'm easily able to test out and migrate then to new configuration
scenarios .
In my central lxc command script, i don't have realized the expansion of
"internal" lxc tags, but of environment variables.There's a section to gather
the additional config to the array EXTRA_CONFIG, which is appended later to the
arguments of lxc-start.
LXCBASE="/etc/lxc"
[...]
CONTAINERBASE="$LXCBASE/$CONTAINER"
[ ! -d "$CONTAINERBASE" ] && LOG "unknown container \"$CONTAINER\" (no LXC
basedir found) !" 1>&2 && exit 1
[...]
# build/check standard and extra configuration
declare -a EXTRA_OPTS
[ -e "$CONTAINERBASE/fstab" ] && EXTRA_OPTS=("-s
lxc.mount=$CONTAINERBASE/fstab") # use a central fstab if exist
EXTRA_CONFIG="$CONTAINERBASE/config.$CONTAINER"
[ -f "$EXTRA_CONFIG" ] && while read LINE; do
LINE="${LINE%%#*}" # delete comments
[ -z "$LINE" ] && continue # skip empty lines
TAG=${LINE%%=*}; TAG=`echo $TAG` # split and remove surrounding
whitespace
VALUE=${LINE##*=}; VALUE=`echo $VALUE`; eval VALUE=$VALUE; # same to and
evaluate
[ -n "$VALUE" ] && EXTRA_OPTS=("${EXTRA_OPTS[@]}" "-s $TAG=$VALUE") # push
to array
done <$EXTRA_CONFIG && LOG "extra config processed."
[...]
LOG "starting container \"$CONTAINER\" ..."
lxc-start \
-n $CONTAINER -d \
-l $LXCLOGLEVEL -o "/var/log/lxc/$CONTAINER.log" -c
"/var/log/lxc/$CONTAINER.out" \
-f $CONTAINERBASE/config \
-s lxc.utsname=$CONTAINER \
-s lxc.rootfs=$CONTAINERBASE/rootfs \
-s lxc.pivotdir=$CONTAINER \
-s lxc.network.link=$BRIDGE \
-s lxc.network.hwaddr=$HWADDR \
-s lxc.network.veth.pair=$CONTAINER \
-s lxc.mount.entry="$CGROUPPATH/$CONTAINER cgroup none ro,bind 0 0" \
"${EXTRA_OPTS[@]}"; RC=$?
[...]
An additional config file containing
# sample
lxc.cgroup.memory.limit_in_bytes = 9G
lxc.cgroup.memory.soft_limit_in_bytes = 8G
lxc.editor=$EDITOR # just an senseless example for expansion
would be translated to the "extra options"
-s lxc.cgroup.memory.limit_in_bytes=9G -s
lxc.cgroup.memory.soft_limit_in_bytes=8G -s lxc.editor=vim
------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
Lxc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/lxc-users