Create NAT by default if EGRE key is present
Andy Bavier [Wed, 15 Jul 2009 18:45:23 +0000 (18:45 +0000)]
topo.py

diff --git a/topo.py b/topo.py
index b2cabb8..c895741 100755 (executable)
--- a/topo.py
+++ b/topo.py
@@ -167,6 +167,11 @@ def update_links(slice, myid, topospec, key, netns):
             logger.log("%s: virtual link to node %s exists" % (slice, nodeid))
             refresh_virtual_link(nodeid, key)
 
+
+"""
+Update NAT interface for the slice
+"""
+def update_nat(slice, myid, key, netns):
     if not nat_exists(key):
         if netns:
             setup_nat(slice, myid, key)
@@ -407,14 +412,16 @@ def GetSlivers(data):
         write_conf_and_restart(sliver['name'], netns)
 
         if vserver.VServer(sliver['name']).is_running():
-            if 'egre_key' in attrs and 'topo_rspec' in attrs:
-                logger.log("topo: Update topology for slice %s" % \
-                               sliver['name'])
-                update_links(sliver['name'], data['node_id'], 
-                             attrs['topo_rspec'], attrs['egre_key'], netns)
-                update_quagga_configs(sliver['name'], data['hostname'],
-                               data['node_id'], attrs['topo_rspec'], 
-                               attrs['egre_key'], netns)
+            if 'egre_key' in attrs:
+                logger.log("topo: Update slice %s" % sliver['name'])
+                update_nat(sliver['name'], data['node_id'], attrs['egre_key'],
+                           netns)
+                if 'topo_rspec' in attrs:
+                    update_links(sliver['name'], data['node_id'], 
+                                attrs['topo_rspec'], attrs['egre_key'], netns)
+                    update_quagga_configs(sliver['name'], data['hostname'],
+                                data['node_id'], attrs['topo_rspec'], 
+                                attrs['egre_key'], netns)
             if 'hosts' in attrs:
                 update_hosts(sliver['name'], attrs['hosts'])
         else: