[Lxc-users] lxc-info -q

Brian K. White brian at aljex.com
Mon Oct 10 17:47:43 UTC 2011


lxc 0.7.5
lxc-info -q doesn't work as advertised

nj9:~ # lxc-info -q -n vps001 && echo yes || echo no
state:   RUNNING
pid:      3619
yes
nj9:~ # lxc-info -q -n vps004 && echo yes || echo no
state:   STOPPED
pid:        -1
yes
nj9:~ #

I have an init script that parses the output of lxc-info, which broke 
after upgrading to lxc 0.7.5.

Since there is now an lxc-version, output format changes are only a 
minor annoyance because I can make the script detect at least <0.7.5 and 
individual versions 0.7.5 and later and adjust as needed.

But obviously since lxc-info now has a -q, I'd like it to suppress 
output if given -q, but more importantly, regardless of -q or no -q, I'd 
like it to set meaningful exit values.

Then my init script can stop doing:
   S=`lxc-info -n $CN`
   echo "$S"
   [[ "${S##* }" = "RUNNING" ]] ...
and will no longer be broken by mere changes in output format.

The box the above paste comes from was just upgraded from 0.7.4 to 0.7.5 
while some containers were running. The host hasn't been rebooted yet. 
If this is only expected to work after stopping and restarting 
containers with the new lxc-start, then I'll be doing that later anyways.

-- 
bkw




More information about the lxc-users mailing list