[lxc-devel] [PATCH 1/4] Honor network type and link from lxc-create -f

Dwight Engen dwight.engen at oracle.com
Tue Oct 9 16:19:22 UTC 2012


Make the oracle template honor the lxc.network.type and
lxc.network.link configuration items if a "base" configuration file is
passed to lxc-create. If no configuration file is passed, the template
falls back to the default name created by libvirt.

Signed-off-by: Dwight Engen <dwight.engen at oracle.com>
---
 templates/lxc-oracle.in |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/templates/lxc-oracle.in b/templates/lxc-oracle.in
index ba62f8f..2d62396 100644
--- a/templates/lxc-oracle.in
+++ b/templates/lxc-oracle.in
@@ -27,10 +27,6 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 #
 
-# use virbr0 that is setup by default by libvirtd
-lxc_network_type=veth
-lxc_network_link=virbr0
-
 die()
 {
     echo "failed: $1"
@@ -250,6 +246,18 @@ container_config_create()
 		      head -1 |awk '{print $2}' | cut -c1-10 |\
 		      sed 's/\(..\)/\1:/g; s/.$//'`"
     mkdir -p $cfg_dir || die "unable to create config dir $cfg_dir"
+
+    # see if the network settings are specified in the file thats handed to us
+    lxc_network_type=`grep '^lxc.network.type' $cfg_dir/config | awk -F'[= \t]+' '{ print $2 }'`
+    if [ -z "$lxc_network_type" ]; then
+	lxc_network_type="veth"
+    fi
+
+    lxc_network_link=`grep '^lxc.network.link' $cfg_dir/config | awk -F'[= \t]+' '{ print $2 }'`
+    if [ -z "$lxc_network_link" ]; then
+	lxc_network_link="virbr0"
+    fi
+
     rm -f $cfg_dir/config
     cat <<EOF >> $cfg_dir/config || die "unable to create $cfg_dir/config"
 # Container configuration for Oracle Linux $release_major.$release_minor
-- 
1.7.1





More information about the lxc-devel mailing list