[lxc-devel] Usability: lxc-ls
Jonathan Carter (highvoltage)
jonathan at ubuntu.com
Thu Jun 28 15:38:17 UTC 2012
Hi Stefan!
On 28/06/2012 10:49, Stefan Schlesinger wrote:
> I'm new to LXC and have been using OpenVZ until now.
>
> Something which I immediately missed, when I played around with the LXC
> CLI tools the first time, was that neither lxc-ls nor lxc-list provide
> a nice overview of the current status of your host.
>
> To give you an example here is how the vzlist output looks like:
>
> CTID NPROC STATUS IP_ADDR HOSTNAME
> 17915 11 running - git
> 17918 81 running - rt02
> 17925 81 running - rt01
> 17945 151 running - puppet02
> 17964 56 running - monitor01
> 17968 21 running - ns01
> 17981 193 running - mx01
> 17988 47 running - wiki01
>
> IMHO it perfectly fulfils two puropses: It shows you a list of running
> containers with some helpful extra information (needs -a, to list them all) and
> its nicely parseable by scripts at the same time...
I have the same situation, I work for a company who uses OpenVZ
extensively and people here (myself included!) are really used to some
of the nice ways OpenVZ presents things.
Initially, I put together a wrapper script for myself to make it do what
I'd like it to do.
Here's a screenshot of the list command, which is somewhat OpenVZ'y:
http://irc.jonathancarter.org/files/rlxc/rlxc-list.png
And here's a few others too:
http://irc.jonathancarter.org/files/rlxc/rlxc-status.png
http://irc.jonathancarter.org/files/rlxc/rlxc.png
http://irc.jonathancarter.org/files/rlxc/rlxc-enter-exec.png
It's currently just a shell script. I hacked something together so that
it emulates "vzctl exec" and "vzctl enter" by using ssh. So you can do
an "rlxc updatesshkeys" to sync the ssh keys for that or if you do "rlxc
create" it will sync the keys automatically after creation.
The IP addresses is currently a hack, and you can choose between 3 hacks
for that. You can either let it show you the address specified in
/etc/network/interfaces, or the last address it got from a dhcp lease,
or you can make it do ifconfig and grep it.
It all works fine with me and I'm finishing up an Ubuntu package because
a friend wants to use it, I'd have to test it a little more before I'd
feel comfortable making it public.
It's still just a proof of concept anyway...
So what's been happening is that Stéphane is writing nice Python
bindings for LXC in C. Currently my hacky script is calling the rest of
the current LXC scripts. My goal is to redo rlxc as a nice Python script
that uses that instead. I'm interested in contributing it to LXC
upstream but not sure if they'll just do it anyway or if there's even an
interest for it. I meant to show it to Serge at UDS but there was just
so much happening at the same time that I didn't get the chance and I've
been meaning to post it to the list anyway.
I have a whole list of extra things I want to add to it. Small things
that make administering easier like "rlxc toggleboot $containername"
etc. Also, for things like "rlxc list" I'd like to add options to choose
which ip for which interface should be displayed, and whether it should
be the ipv4 or ipv6 address. For example, "rlxc list eth=eth1 ip=ipv6".
Stéphane has already added the support for this in the LXC bindings, we
just have to use it :)
Well, that's how I see things anyway :)
-Jonathan
More information about the lxc-devel
mailing list