Conversation
| new_key = nk.replace('lxc.network.','lxc.network.{}.'.format(count)) | ||
| print(container.get_config_item(new_key)) | ||
| count +=1 | ||
|
|
There was a problem hiding this comment.
Wouldn't this be cleaner that way (untested):
for idx, interface in enumerate(container.get_config_item("lxc.net")):
for attribute in ("type", "link", "flags", "hwaddr"):
key = "lxc.net.%s.%s" % (idx, attribute)
print("%s = %s" % (key, container.get_config_item(key)))Note the use of lxc.net rather than lxc.network as the code should be aimed at liblxc 3.0 and higher.
There was a problem hiding this comment.
checked. Working ok with lxc.network. Looks like lxc.net not yet available in python3 bindinds.
There was a problem hiding this comment.
What liblxc version are you running? lxc.net needs 2.1 or higher, I confirmed that lxc.network doesn't work here but lxc.net does (on 3.0.2).
There was a problem hiding this comment.
Debian 9 stretch stable, python3-lxc-3.0.2 latest release
lxc package 2.0.7-2+deb9u2
I checked for you and an updated version of lxc is not available stretch-backports
Debian buster and sid have lxc 2.0.9
There was a problem hiding this comment.
That's an odd mix, you're certainly not meant to use python3-lxc 3.0.x with lxc 2.0.x :)
Anyway, can you update your pull request to match the suggested version (with lxc.net)?
Then I think we can merge it.
Some helpful code to help integrators.