-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to access lxc.network.link et alii #7
base: main
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
much more cleaner :) thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
checked. Working ok with lxc.network. Looks like lxc.net not yet available in python3 bindinds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.