commit d2b16e5135b8812e160b815128c82dfc68056c77
Author: Dimitris Aragiorgis <dimara@grnet.gr>
Date:   Wed Apr 11 21:18:57 2012 +0300

    Various changes
    
    Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>

diff --git a/conf/cluster.conf b/conf/cluster.conf
new file mode 100644
index 0000000..f7147c2
--- /dev/null
+++ b/conf/cluster.conf
@@ -0,0 +1,3 @@
+NODEGROUPS="default"
+
+NODES="dev88 dev89"
diff --git a/conf/infra.conf b/conf/infra.conf
new file mode 100644
index 0000000..8a188f3
--- /dev/null
+++ b/conf/infra.conf
@@ -0,0 +1,12 @@
+ROUTER=dev88
+ROUTER_MAC=e4:11:5b:b2:8d:ca
+MAC_MASK=ff:ff:ff:0:0:0
+
+PUBLIC_INTERFACE=eth0
+PUBLIC_VLAN=eth0.201
+PUBLIC_BRIDGE=br0
+PRIVATE_VLAN=eth0.2990
+PRIVATE_BRIDGE=br2990
+MASQ_VLAN=eth0.2991
+MASQ_BRIDGE=br2991
+
diff --git a/conf/snf-network.conf b/conf/snf-network.conf
new file mode 100644
index 0000000..8e3ceb2
--- /dev/null
+++ b/conf/snf-network.conf
@@ -0,0 +1 @@
+SHAREDDIR=/home/dimara/snf-network
diff --git a/configure-interfaces b/configure-interfaces
index 918651e..5dad5bc 100755
--- a/configure-interfaces
+++ b/configure-interfaces
@@ -1,15 +1,19 @@
 #!/bin/bash
 
-source /etc/default/snf-network
+DEFAULT=/etc/default/snf-network
+
+source $DEFAULT
+source $CONF
+source $INFRA
 
 HOSTNAME=$(hostname)
 
 
 INTERFACES=$SHAREDDIR/interfaces/$HOSTNAME
-INFRA=$SHAREDDIR/infra/$HOSTNAME
+HOSTINFRA=$SHAREDDIR/infra/$HOSTNAME
 
-if [ -e $INFRA ]; then
-  source $INFRA
+if [ -e "$HOSTINFRA" ]; then
+  source $HOSTINFRA
 fi
 
 if [ -e /proc/sys/net/ipv4/conf/$PUBLIC_VLAN  -o \
@@ -26,6 +30,9 @@ if [ -e /proc/sys/net/ipv4/conf/$PUBLIC_VLAN  -o \
   exit 1
 fi
 
+PUBLIC_MAC=$(ip link show $PUBLIC_INTERFACE | grep link/ether | awk '{print $2}')
+
+
 
 cat > $INTERFACES<<EOF
 #auto $PUBLIC_BRIDGE
@@ -33,6 +40,7 @@ cat > $INTERFACES<<EOF
 #  bridge_ports $PUBLIC_INTERFACE
 #  bridge_stp off
 #  bridge_fd 2
+#  post-up ip link set $PUBLIC_BRIDGE address $PUBLIC_MAC 
 
 auto $PUBLIC_VLAN
 iface $PUBLIC_VLAN inet manual
@@ -45,6 +53,7 @@ iface $PRIVATE_BRIDGE inet manual
   bridge_ports $PRIVATE_VLAN
   bridge_stp off
   bridge_fd 2
+  post-up ip link set $PRIVATE_BRIDGE address $PUBLIC_MAC 
 
 auto $MASQ_VLAN
 iface $MASQ_VLAN inet manual
@@ -54,6 +63,7 @@ iface $MASQ_BRIDGE inet manual
   bridge_ports $MASQ_VLAN
   bridge_stp off
   bridge_fd 2
+  post-up ip link set $MASQ_BRIDGE address $PUBLIC_MAC 
 EOF
 
 
diff --git a/hooks/group-modify-post.d/snf-network b/hooks/group-modify-post.d/snf-network
index ddb8ef0..9ada1db 100755
--- a/hooks/group-modify-post.d/snf-network
+++ b/hooks/group-modify-post.d/snf-network
@@ -2,53 +2,51 @@
 
 source /etc/default/snf-network
 
-GROUP=$GANETI_GROUP_NAME
+source $CONF
 
+GROUP=$GANETI_GROUP_NAME
 ACTION=$GANETI_GROUP_NETWORK_ACTION
 NETWORK=$GANETI_GROUP_NETWORK_NAME
 MODE=$GANETI_GROUP_NETWORK_MODE
 LINK=$GANETI_GROUP_NETWORK_LINK
 
-
-
-if [ -z $ACTION ]; then
-  exit 0
-fi
+HOSTNAME=$(hostname)
 
 NETFILE=$SHAREDDIR/networks/$NETWORK
+GROUPMAPFILE=$SHAREDDIR/mappings/$NETWORK-$GROUP
+NODEMAPFILE=$SHAREDDIR/mappings/$NETWORK-$HOSTNAME
+NODEINFRAFILE=$SHAREDDIR/infra/$HOSTNAME
 
-MAPFILE=$SHAREDDIR/mappings/$NETWORK-$GROUP
+RT_TABLES=/etc/iproute2/rt_tables
 
-function set_rt_table {
-  ID=$(sed  -n '/^$/ { =; q}' /etc/iproute2/rt_tables)
-  if [ -z $ID ]; then
-    ID=$(wc -l /etc/iproute2/rt_tables)
-    echo $((ID+1)) rt_$NETWORK > /etc/iproute2/rt_tables
-  else
-    sed -i '1,/^$/ s/^$/'"$ID"' rt_'"$NETWORK"'/' /etc/iproute2/rt_tables
-  fi
-}
+source $NODEINFRAFILE
+source $NETFILE
 
+if [ -z "$ACTION" ]; then
+  exit 0
+fi
 
 
-if [ $ACTION == "add" ]; then
-  if [ $MODE == "routed" ]; then 
+if [ "$ACTION" == "add" ]; then
+  if [ "$MODE" == "routed" ]; then 
     VLAN=$LINK
-    if [ $TYPE == "public" ]; then
+    TABLE=rt_$NETWORK
+    if [ "$TYPE" == "public" ]; then
       ARP_IP=$(ipcalc $SUBNET | grep HostMax | awk '{print $2}')
       
       ip link set $VLAN up
 
       echo 1 > "/proc/sys/net/ipv4/conf/$VLAN/proxy_arp"
 
-      set_rt_table
+      ID=$(wc -l < $RT_TABLES)
+      echo $((ID+1)) $TABLE >> $RT_TABLES
 
-      ip rule add iif $VLAN table rt_$NETWORK
+      ip rule add iif $VLAN table $TABLE
 
       ip route add $SUBNET dev $VLAN table main 
 
-      ip route add $SUBNET dev $VLAN table rt_$NETWORK
-      ip route add default via $GATEWAY dev $VLAN table rt_$NETWORK
+      ip route add $SUBNET dev $VLAN table $TABLE
+      ip route add default via $GATEWAY dev $VLAN table $TABLE
       
       echo 1 > /proc/sys/net/ipv4/conf/all/forwarding
 
@@ -58,11 +56,11 @@ if [ $ACTION == "add" ]; then
 
 
 
-  if [ $MODE == "bridged" ]; then
+  if [ "$MODE" == "bridged" ]; then
     BRIDGE=$LINK
-    if [ ! -z $GATEWAY ]; then
-      if [ $TYPE == "private" ]; then 
-        if [ $(hostname) == $ROUTER ]; then
+    if [ ! -z "$GATEWAY" ]; then
+      if [ "$TYPE" == "private" ]; then 
+        if [ "$HOSTNAME" == "$ROUTER" ]; then
           NETMASK=$(ipcalc $SUBNET | grep Netmask | awk '{print $4}')
           ip addr add $GATEWAY/$NETMASK dev $BRIDGE
           iptables -t nat -A POSTROUTING -s $SUBNET \! -d 192.168.0.0/16 -j MASQUERADE
@@ -71,19 +69,19 @@ if [ $ACTION == "add" ]; then
     fi
   fi
   
-  cat > $MAPFILE <<EOF
-MODE=$MODE
-LINK=$LINK
-EOF
+  ln -sf $GROUPMAPFILE $NODEMAPFILE
 
-else
+elif [ "$ACTION" == "remove" ]; then
+  if [ ! -e "$NODEMAPFILE" ]; then
+    exit 0;
+  fi
 
-  source $MAPFILE
+  source $NODEMAPFILE
 
   if [ "$MODE" == "routed" ]; then 
     VLAN=$LINK
     TABLE=rt_$NETWORK
-    if [ $TYPE == "public" ]; then
+    if [ "$TYPE" == "public" ]; then
       ARP_IP=$(ipcalc $SUBNET | grep HostMax | awk '{print $2}')
     
       arptables -D OUTPUT -o $VLAN --opcode request -j mangle --mangle-ip-s  $ARP_IP 
@@ -94,7 +92,8 @@ else
       ip route del $SUBNET dev $VLAN table main 
 
       ip rule del iif $VLAN table $TABLE
-      sed -i 's/.*'"$TABLE"'$//' /etc/iproute2/rt_tables
+      
+      sed -i 's/.*'"$TABLE"'$//' $RT_TABLES
     fi
   fi
 
@@ -102,9 +101,9 @@ else
 
   if [ "$MODE" == "bridged" ]; then
     BRIDGE=$LINK
-    if [ ! -z $GATEWAY ]; then
-      if [ $TYPE == "private" ]; then 
-        if [ $(hostname) == $ROUTER ]; then
+    if [ ! -z "$GATEWAY" ]; then
+      if [ "$TYPE" == "private" ]; then 
+        if [ "$HOSTNAME" == "$ROUTER" ]; then
           NETMASK=$(ipcalc $SUBNET | grep Netmask | awk '{print $4}')
           ip addr del $GATEWAY/$NETMASK dev $BRIDGE
           iptables -t nat -D POSTROUTING -s $SUBNET \! -d 192.168.0.0/16 -j MASQUERADE
@@ -113,6 +112,6 @@ else
     fi
   fi
   
-  rm $MAPFILE
+  rm $NODEMAPFILE
 
 fi
diff --git a/hooks/group-modify-pre.d/snf-network b/hooks/group-modify-pre.d/snf-network
new file mode 100755
index 0000000..d45dc4c
--- /dev/null
+++ b/hooks/group-modify-pre.d/snf-network
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+source /etc/default/snf-network
+
+source $CONF
+
+GROUP=$GANETI_GROUP_NAME
+ACTION=$GANETI_GROUP_NETWORK_ACTION
+NETWORK=$GANETI_GROUP_NETWORK_NAME
+MODE=$GANETI_GROUP_NETWORK_MODE
+LINK=$GANETI_GROUP_NETWORK_LINK
+
+GROUPMAPFILE=$SHAREDDIR/mappings/$NETWORK-$GROUP
+
+
+if [ -z "$ACTION" ]; then
+  exit 0
+fi
+
+if [ "$ACTION" == "add" ]; then
+  cat > $GROUPMAPFILE <<EOF
+MODE=$MODE
+LINK=$LINK
+EOF
+fi
diff --git a/hooks/network-add-post.d/snf-network b/hooks/network-add-post.d/snf-network
index d71802d..02204f7 100755
--- a/hooks/network-add-post.d/snf-network
+++ b/hooks/network-add-post.d/snf-network
@@ -1,6 +1,12 @@
 #!/bin/bash
 
-source /etc/default/snf-network
+DEFAULT=/etc/default/snf-network
+
+source $DEFAULT
+
+source $CONF
+
+NETWORK=$GANETI_NETWORK_NAME
 
 
 NETFILE=$SHAREDDIR/networks/$NETWORK
@@ -19,4 +25,4 @@ MAC_PREFIX=$GANETI_NETWORK_MAC_PREFIX
 TYPE=$GANETI_NETWORK_TYPE
 EOF
 
-
+sed -i 's/None//' $NETFILE
diff --git a/hooks/network-remove-post.d/snf-network b/hooks/network-remove-post.d/snf-network
index 1bc4477..aaa34b8 100755
--- a/hooks/network-remove-post.d/snf-network
+++ b/hooks/network-remove-post.d/snf-network
@@ -1,9 +1,15 @@
 #!/bin/bash
 
-source /etc/default/snf-network
+DEFAULT=/etc/default/snf-network
 
+source $DEFAULT 
 
-NETFILE=$SHAREDDIR/networks/$NETWORK
+source $CONF
+
+NETWORK=$GANETI_NETWORK_NAME
 
-rm $NETFILE
+NETFILE=$SHAREDDIR/networks/$NETWORK
 
+if [ -e "$NETFILE" ]; then
+  rm $NETFILE
+fi
diff --git a/kvm-vif-bridge b/kvm-vif-bridge
index f17be7f..c8b8575 100755
--- a/kvm-vif-bridge
+++ b/kvm-vif-bridge
@@ -7,8 +7,10 @@ TAP_CONSTANT_MAC=cc:47:52:4e:45:54 # GRNET in hex :-)
 MAC2EUI64=/usr/bin/mac2eui64
 NFDHCPD_STATE_DIR=/var/lib/nfdhcpd
 
+
+
 function clear_tap {
- 
+
  arptables -D OUTPUT -o $INTERFACE --opcode request -j mangle >/dev/null 2>&1
  while ip rule del dev $INTERFACE; do :; done
  iptables -D FORWARD -i $INTERFACE -p udp --dport 67 -j DROP 2>/dev/null
@@ -17,11 +19,9 @@ function clear_tap {
 }
 
 function routed_setup_ipv4 {
-	# get the link's default gateway
-	gw=$GATEWAY
 
 	# mangle ARPs to come from the gw's IP
-	arptables -A OUTPUT -o $INTERFACE --opcode request -j mangle --mangle-ip-s "$gw"
+	arptables -A OUTPUT -o $INTERFACE --opcode request -j mangle --mangle-ip-s    "$GATEWAY"
 
 	# route interface to the proper routing table
 	ip rule add dev $INTERFACE table $TABLE
@@ -83,24 +83,26 @@ function routed_setup_firewall {
 function setup_nfdhcpd {
 	umask 022
   FILE=$NFDHCPD_STATE_DIR/$INTERFACE
+  #IFACE is the interface from which the packet seems to arrive
+  #needed in bridged mode where the packets seems to arrive from the
+  #bridge and not from the tap
 	cat >$FILE <<EOF
 IFACE=$1
 IP=$IP
 MAC=$MAC
-LINK=$TABLE
 HOSTNAME=$INSTANCE
 TAGS="$TAGS"
 EOF
-if [ -n $GATEWAY ]; then
+if [ -n "$GATEWAY" ]; then
  echo GATEWAY=$GATEWAY >> $FILE
 fi
-if [ -n $SUBNET ]; then
+if [ -n "$SUBNET" ]; then
  echo SUBNET=$SUBNET >> $FILE
 fi
-if [ -n $GATEWAY6 ]; then
+if [ -n "$GATEWAY6" ]; then
  echo GATEWAY6=$GATEWAY6 >> $FILE
 fi
-if [ -n $SUBNET6 ]; then
+if [ -n "$SUBNET6" ]; then
  echo SUBNET6=$SUBNET6 >> $FILE
 fi
 
@@ -110,9 +112,9 @@ function clear_ebtables {
   TAP=$INTERFACE
   FROM=FROM${TAP^^}
   TO=TO${TAP^^}
-  
+
   exist=$(ebtables -L | grep $TAP)
-  
+
   if [ ! -z "$exist" ]; then
     ebtables -D INPUT -i $TAP -j $FROM
     ebtables -D FORWARD -i $TAP -j $FROM
@@ -132,31 +134,44 @@ function setup_ebtables {
   ebtables -N $FROM
   # do not allow changes in ip-mac pair
   ebtables -A $FROM --ip-source \! $IP -p ipv4 -j DROP
-  ebtables -A $FROM -s \! $MAC -j DROP 
-  ebtables -A FORWARD -i $TAP -j $FROM 
+  ebtables -A $FROM -s \! $MAC -j DROP
+  ebtables -A FORWARD -i $TAP -j $FROM
   ebtables -N $TO
   ebtables -A FORWARD -o $TAP -j $TO
   #accept dhcp responses from host (nfdhcpd)
   ebtables -A $TO -p ipv4 --ip-protocol=udp  --ip-destination-port=68 -j ACCEPT
-  if [ $TYPE == "private" ]; then 
-    if [ ! -z $GATEWAY ]; then 
+  if [ "$TYPE" == "private" ]; then
+    if [ ! -z "$GATEWAY" ]; then
       # allow packets from/to router (for masquerading
-      ebtables -A $TO -s $ROUTER_MAC -j ACCEPT 
-      ebtables -A INPUT -i $TAP -j $FROM 
+      ebtables -A $TO -s $ROUTER_MAC -j ACCEPT
+      ebtables -A INPUT -i $TAP -j $FROM
       ebtables -A OUTPUT -o $TAP -j $TO
     fi
-    # allow only packets from the same mac prefix 
-    ebtables -A $TO -s \! $MAC/$MAC_MASK -j DROP 
+    # allow only packets from the same mac prefix
+    ebtables -A $TO -s \! $MAC/$MAC_MASK -j DROP
   fi
 }
 
 
-TABLE=rt_$NETWORK
 
-source /var/lib/snf-network/networks/$NETWORK
+DEFAULT=/etc/default/snf-network
+source $DEFAULT
+source $CONF
 
+NODEINFRAFILE=$SHAREDDIR/infra/$(hostname)
+
+if [ -e "$NODEINFRAFILE" ]; then
+  source $NODEINFRAFILE
+fi
+
+
+NETFILE=$SHAREDDIR/networks/$NETWORK
+if [ -e "$NETFILE" ]; then
+  source $NETFILE
+fi
 
 if [ "$MODE" = "routed" ]; then
+  TABLE=rt_$NETWORK
 	# special proxy-ARP/NDP routing mode
   clear_tap
 	# use a constant predefined MAC address for the tap
@@ -179,4 +194,4 @@ elif [ "$MODE" = "bridged" ]; then
 	brctl addif $BRIDGE $INTERFACE
 	setup_nfdhcpd $BRIDGE
   setup_ebtables
-fi   
+fi
diff --git a/nfdhcpd/nfdhcpd b/nfdhcpd/nfdhcpd
index 117d8b6..bc4eb9f 100755
--- a/nfdhcpd/nfdhcpd
+++ b/nfdhcpd/nfdhcpd
@@ -142,8 +142,6 @@ def parse_binding_file(path):
             ips = ip.split()
         elif line.startswith("MAC="):
             mac = line.strip().split("=")[1]
-        elif line.startswith("LINK="):
-            link = line.strip().split("=")[1]
         elif line.startswith("HOSTNAME="):
             hostname = line.strip().split("=")[1]
         elif line.startswith("IFACE="):
@@ -155,10 +153,10 @@ def parse_binding_file(path):
         elif line.startswith("SUBNET6="):
             subnet6 = line.strip().split("=")[1]
         elif line.startswith("GATEWAY6="):
-            gatewa6 = line.strip().split("=")[1]
+            gateway6 = line.strip().split("=")[1]
 
     return Client(ifname=ifname, mac=mac, ips=ips, link=link,
-                  hostname=hostname,iface=iface, subnet=subnet,
+                  hostname=hostname, iface=iface, subnet=subnet,
                   gateway=gateway, subnet6=subnet6, gateway6=gateway6 )
 
 class ClientFileHandler(pyinotify.ProcessEvent):
@@ -674,13 +672,9 @@ class VMNetProxy(object): # pylint: disable=R0902
         logging.debug("Sending out periodic RAs")
         start = time.time()
         i = 0
-        for client in self.clients.values():
-            iface = client.iface
-            ifmac = self.get_iface_hw_addr(iface)
-            if not ifmac:
-                continue
-
-            binding = self.clients[ifmac]
+        for binding in self.clients.values():
+            iface = binding.ifname
+            ifmac = binding.mac
             subnet = binding.net6
             if subnet.net is None:
                 logging.debug("Skipping periodic RA on interface %s,"
diff --git a/nfdhcpd/nfdhcpd.conf b/nfdhcpd/nfdhcpd.conf
index e08024e..0cd10b7 100644
--- a/nfdhcpd/nfdhcpd.conf
+++ b/nfdhcpd/nfdhcpd.conf
@@ -11,7 +11,7 @@ user = nobody # An unprivileged user to run as
 enable_dhcp = yes
 lease_lifetime = 604800 # 1 week
 lease_renewal = 3600 	# 1 hour
-server_ip = 192.0.2.1
+server_ip = 1.2.3.4
 dhcp_queue = 42 # NFQUEUE number to listen on for DHCP requests
 # IPv4 nameservers to include in DHCP responses
 nameservers = 194.177.210.210, 194.177.210.10
diff --git a/snf-network-build-infra b/snf-network-build-infra
new file mode 100755
index 0000000..0473233
--- /dev/null
+++ b/snf-network-build-infra
@@ -0,0 +1,60 @@
+#!/bin/bash
+
+function get_value {
+  
+  eval def=\$$1
+  read -p "$1? [$def] " x
+  if [ -n "$x" ]; then eval $1="$x"; fi
+
+}
+
+
+DEFAULT=/etc/default/snf-network
+
+source $DEFAULT
+source $CONF
+source $INFRA
+source $CLUSTER
+
+if [ ! -e "$SHAREDDIR/infra/" ]; then 
+  exit 1
+fi
+
+cd  $SHAREDDIR/infra/
+
+
+
+for nodegroup in $NODEGROUPS; do
+  source $INFRA
+  echo Group: $nodegroup
+  get_value ROUTER
+  get_value ROUTER_MAC
+  get_value MAC_MASK
+  get_value PUBLIC_INTERFACE
+  get_value PUBLIC_BRIDGE
+  get_value PUBLIC_VLAN
+  get_value PRIVATE_VLAN
+  get_value PRIVATE_BRIDGE
+  get_value MASQ_VLAN
+  get_value MASQ_BRIDGE
+  cat > $nodegroup <<EOF
+ROUTER=$ROUTER
+ROUTER_MAC=$ROUTER_MAC
+MAC_MASK=$MAC_MASK
+PUBLIC_INTERFACE=$PUBLIC_INTERFACE
+PUBLIC_BRIDGE=$PUBLIC_BRIDGE
+PUBLIC_VLAN=$PUBLIC_VLAN
+PRIVATE_VLAN=$PRIVATE_VLAN
+PRIVATE_BRIDGE=$PRIVATE_BRIDGE
+MASQ_VLAN=$MASQ_VLAN
+MASQ_BRIDGE=$MASQ_BRIDGE
+EOF
+done
+
+
+for node in $NODES; do
+  echo Node: $node
+  NODEGROUP=default
+  get_value NODEGROUP
+  ln -sf $NODEGROUP $node  
+done
diff --git a/snf-network-enable b/snf-network-enable
index 77517b4..46b7335 100755
--- a/snf-network-enable
+++ b/snf-network-enable
@@ -1,23 +1,12 @@
 #!/bin/bash
 
-function get_value {
-  
-  eval def=\$$1
-  read -p "$1? [$def] " x
-  if [ -n "$x" ]; then eval $1="$x"; fi
-
-}
-
-
 DEFAULT=/etc/default/snf-network
 
-CONF=/etc/snf-network/snf-network.conf
-
-source $CONF
 source $DEFAULT
+source $CONF
 
 
-if [ ! -e $SHAREDDIR ]; then
+if [ ! -e "$SHAREDDIR" ]; then
   mkdir $SHAREDDIR
   mkdir $SHAREDDIR/networks
   mkdir $SHAREDDIR/infra
@@ -25,45 +14,8 @@ if [ ! -e $SHAREDDIR ]; then
   mkdir $SHAREDDIR/mappings
 fi
 
-#if [ -z "$(grep nfdhcpd.ferm /etc/ferm/ferm.conf)" ]; then 
-#  echo @include 'nfdhcpd.ferm'; >> /etc/ferm/ferm.conf
-#  /etc/init.d/ferm restart
-#fi
-
-
-cd  $SHAREDDIR/infra/
-
-for nodegroup in $NODEGROUPS; do
-  source $DEFAULT
-  echo Group: $nodegroup
-  get_value ROUTER
-  get_value ROUTER_MAC
-  get_value MAC_MASK
-  get_value PUBLIC_INTERFACE
-  get_value PUBLIC_BRIDGE
-  get_value PUBLIC_VLAN
-  get_value PRIVATE_VLAN
-  get_value PRIVATE_BRIDGE
-  get_value MASQ_VLAN
-  get_value MASQ_BRIDGE
-  cat > $nodegroup <<EOF
-ROUTER=$ROUTER
-ROUTER_MAC=$ROUTER_MAC
-MAC_MASK=$MAC_MASK
-PUBLIC_INTERFACE=$PUBLIC_INTERFACE
-PUBLIC_BRIDGE=$PUBLIC_BRIDGE
-PUBLIC_VLAN=$PUBLIC_VLAN
-PRIVATE_VLAN=$PRIVATE_VLAN
-PRIVATE_BRIDGE=$PRIVATE_BRIDGE
-MASQ_VLAN=$MASQ_VLAN
-MASQ_BRIDGE=$MASQ_BRIDGE
-EOF
-done
-
+if [ -z "$(grep nfdhcpd.ferm /etc/ferm/ferm.conf)" ]; then 
+  echo @include 'nfdhcpd.ferm'; >> /etc/ferm/ferm.conf
+  /etc/init.d/ferm restart
+fi
 
-for node in $NODES; do
-  echo Node: $node
-  NODEGROUP=default
-  get_value NODEGROUP
-  ln -s $NODEGROUP $node  
-done
diff --git a/snf-network.conf b/snf-network.conf
deleted file mode 100644
index f7147c2..0000000
--- a/snf-network.conf
+++ /dev/null
@@ -1,3 +0,0 @@
-NODEGROUPS="default"
-
-NODES="dev88 dev89"
diff --git a/unconfigure-interfaces b/unconfigure-interfaces
index 7b1dfc8..c5ae25c 100755
--- a/unconfigure-interfaces
+++ b/unconfigure-interfaces
@@ -1,16 +1,16 @@
 #!/bin/bash
 
-source /etc/default/snf-network
+DEFAULT=/etc/default/snf-network
+
+source $DEFAULT
+source $CONF
+source $INFRA
 
 HOSTNAME=$(hostname)
 
 
 INTERFACES=$SHAREDDIR/interfaces/$HOSTNAME
-INFRA=$SHAREDDIR/infra/$HOSTNAME
-
-if [ -e $INFRA ]; then
-  source $INFRA
-fi
+HOSTINFRA=$SHAREDDIR/infra/$HOSTNAME
 
 ifdown -i $INTERFACES -a --force
 
