Commit 00903d7d by Stéphane Graber

python3: Add support for wlan device add

With this change it's now possible to add wlan devices to the container. This will track down the right phy device, move it to the right namespace (we don't care about its name), then if the user asked for a new device name for the actual interface, we attach to the container and rename the interface in there using attach. I have tested this to work with both Intel and Atheros NICs. This patch is based on the one provided to lxc-devel by Gregor Beck and has then been updated to do the device renaming as well as minor code style changes. Thanks! Reported-by: 's avatarGregor Beck <gbeck@sernet.de> Signed-off-by: 's avatarStéphane Graber <stgraber@ubuntu.com> Acked-by: 's avatarSerge E. Hallyn <serge.hallyn@ubuntu.com>
parent 23b116e3
......@@ -160,6 +160,26 @@ class Container(_lxc.Container):
if not self.running:
return False
if os.path.exists("/sys/class/net/%s/phy80211/name" % name):
with open("/sys/class/net/%s/phy80211/name" % name) as fd:
phy = fd.read().strip()
if subprocess.call(['iw', 'phy', phy, 'set', 'netns',
str(self.init_pid)]) != 0:
return False
if destname:
def rename_interface(args):
old, new = args
return subprocess.call(['ip', 'link', 'set',
'dev', old, 'name', new])
return self.attach_wait(rename_interface, (name, destname),
namespaces=(CLONE_NEWNET)) == 0
return True
if not destname:
destname = name
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment