X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=tools.py;h=dbfa55f5fe1da2a5dc67311be25e2c336313f075;hb=5a2cdcf15984b8d4de3ad4566c6bb276a0df2e2b;hp=4cbfa3b449c157e4228a3d23cd10796d2211abf9;hpb=185a2e3bf48406e5184c2d9259715adc9e6fd975;p=nodemanager.git diff --git a/tools.py b/tools.py index 4cbfa3b..dbfa55f 100644 --- a/tools.py +++ b/tools.py @@ -300,24 +300,31 @@ def get_node_virt (): except: pass logger.log("Computing virt..") - vs_retcod=subprocess.call ([ 'vserver', '--help' ]) - if vs_retcod == 0: - virt='vs' - else: + try: + if subprocess.call ([ 'vserver', '--help' ]) ==0: virt='vs' + else: virt='lxc' + except: virt='lxc' with file(virt_stamp,"w") as f: f.write(virt) return virt +# how to run a command in a slice +# now this is a painful matter +# the problem is with capsh that forces a bash command to be injected in its exec'ed command +# so because lxcsu uses capsh, you cannot exec anything else than bash +# bottom line is, what actually needs to be called is +# vs: vserver exec slicename command and its arguments +# lxc: lxcsu slicename "command and its arguments" +# which, OK, is no big deal as long as the command is simple enough, +# but do not stretch it with arguments that have spaces or need quoting as that will become a nightmare def command_in_slice (slicename, argv): - # with vserver this can be done using vserver .. exec - # with lxc this is less clear as we are still discussing how lxcsu should behave - # ideally we'd need to run lxcsu .. virt=get_node_virt() if virt=='vs': return [ 'vserver', slicename, 'exec', ] + argv elif virt=='lxc': - return [ 'lxcsu', slicename, ] + argv + # wrap up argv in a single string for -c + return [ 'lxcsu', slicename, ] + [ " ".join(argv) ] logger.log("command_in_slice: WARNING: could not find a valid virt") return argv