Closed ach5948 closed 3 years ago
Hello, could me and my classmates work on this issue please?
Oh oops, I opened a PR and I thought it would show up here but I guess I forgot to mention the issue in the PR itself. https://github.com/lxc/python3-lxc/pull/21.
Sorry about that, didn't get the notification on this one...
Required information
Distribution: Debian Distribution version: Stretch lxc-start --version: 2.0.7 uname -a: Linux 4.9.0-3-amd64 lxc/lxc#1 SMP Debian 4.9.30-2+deb9u2 (2017-06-26) x86_64 GNU/Linux This is specifically for the Python API python version: 3.5.3
Issue description
Calling the len() function on an empty ContainerNetworkList causes a KeyError.
Steps to reproduce
Information to attach
Traceback (most recent call last): File "", line 1, in
File "/usr/lib/python3/dist-packages/lxc/init.py", line 127, in len
values = self.container.get_config_item("lxc.network")
File "/usr/lib/python3/dist-packages/lxc/init.py", line 296, in get_config_item
value = _lxc.Container.get_config_item(self, key)
KeyError: 'Invalid configuration key'
Able to fix by changing the len function in the ContainerNetworkList class: wrap the line: values = self.container.get_config_item("lxc.network") in a try except block: try: values = self.container.get_config_item("lxc.network") except KeyError: return 0