[lxc-devel] [python3-lxc/master] How to access lxc.network.link et alii

n3storm on Github lxc-bot at linuxcontainers.org
Mon Oct 8 10:32:33 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 344 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20181008/63e9d476/attachment.bin>
-------------- next part --------------
From 772de359bcb74aece71367cda1f362aebf1b25b3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?N=C3=A9stor=20D=C3=ADaz=20Valencia?= <nestor at barriolinux.es>
Date: Mon, 8 Oct 2018 12:31:48 +0200
Subject: [PATCH] How to access lxc.network.link et alii

---
 examples/api_test.py | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/examples/api_test.py b/examples/api_test.py
index 1934a23..e5b7f2b 100755
--- a/examples/api_test.py
+++ b/examples/api_test.py
@@ -129,6 +129,19 @@
 # A few basic checks of the current state
 assert(len(ips) > 0)
 
+# Getting config items under indexed key
+print("Accessing indexed config entries")
+count = 0
+networks = len(set(container.get_config_item('lxc.network')))
+network_keys = ['lxc.network.type','lxc.network.link','lxc.network.flags','lxc.netwo
+rk.hwaddr',]
+while (count < networks):
+    for nk in network_keys:
+        new_key = nk.replace('lxc.network.','lxc.network.{}.'.format(count))        
+        print(container.get_config_item(new_key))
+    count +=1
+    
+
 ## Test running config
 assert(container.name == CONTAINER_NAME
        == container.get_config_item("lxc.uts.name")


More information about the lxc-devel mailing list