jamesmcm/vopono

Force creating a new namespace?

097115 opened this issue · 6 comments

097115 commented

When vopono finds an existing namespace, it proceeds to using it.

Is it possible to force it to create a new one?

Not at the moment - although you could do it by treating the config file as a custom provider.

It'd be simple to add though, as a flag here - https://github.com/jamesmcm/vopono/blob/master/src/exec.rs#L348-L364 and then also adding some randomness to the netns name generation - https://github.com/jamesmcm/vopono/blob/master/src/exec.rs#L284-L293

What is the use case though - compared to sharing the network namespace?

097115 commented

you could do it by treating the config file as a custom provider

Thanks, this solves it for me :). Sorry that I missed it.

What is the use case

It's nothing significant, just experimenting a bit. Certainly not a reason for any additional code, so I'm probably closing this?

BTW, while we at it, is there any way from within a vopono's namespace to get the current namespace's name (or, even better, the host_ip)? I came up with this (for a Bash script):

IP=$(grep -R -o 'host_ip:"[0-9.]*"' $XDG_CONFIG_HOME/vopono | \
     awk -v FS='"' -v N=$(ip netns identify $$) '($0 ~ N){print $2; exit}')

But maybe there's a better way?

Hmm depending what you need it for - it is available to the host scripts - https://github.com/jamesmcm/vopono/blob/master/USERGUIDE.md#configuration-file