fix headnode not at top of list, support vsys_iplist for default slices
smbaker [Thu, 24 Jan 2013 01:43:25 +0000 (17:43 -0800)]
apps/gacks/bridgeconfig.py

index db883cf..c1cd572 100644 (file)
@@ -118,15 +118,13 @@ class WizardHelper:
                 headnode = node
 
         if headnode:
-            # XXX we don't need to do this anymore, since updating add_host
-            # to automatically move the headnode to the front
-            #nodes = [headnode] + [x for x in nodes if x!=headnode]
-            pass
+            # move the headnode to the top of the list
+            nodes = [headnode] + [x for x in nodes if x!=headnode]
         else:
             headnode = nodes[0]
             self.set_master_node(headnode["hostname"])
 
-        return headnode
+        return (nodes, headnode)
 
 class NetworkBuilder(WizardHelper):
     def __init__(self, plc, slice):
@@ -205,9 +203,10 @@ class NetworkBuilder_gre(NetworkBuilder):
 
         self.set_tag("slice_hostmap", None, "\n".join(hostmap))
         self.set_network_method("gre")
+        self.clear_tags("vsys_ipList")
 
     def generate_star_topology(self, nodes):
-        headnode = self.pick_headnode(nodes)
+        (nodes, headnode) = self.pick_headnode(nodes)
         if not headnode:
             # if there are no nodes, then there is no topology
             return {}
@@ -240,7 +239,7 @@ class NetworkBuilder_IPv4_shared(NetworkBuilder):
         slice_id = slice["slice_id"]
 
         nodes = self.plc.GetNodes(slice["node_ids"], ["node_id", "hostname", "site_id"])
-        headnode = self.pick_headnode(nodes)
+        (nodes, headnode) = self.pick_headnode(nodes)
 
         site_ids = []
         for node in nodes:
@@ -271,6 +270,7 @@ class NetworkBuilder_IPv4_shared(NetworkBuilder):
         self.clear_tags("slice_bridge_name")
         self.clear_tags("slice_bridge_addr")
         self.clear_tags("slice_bridge_neighbors")
+        self.clear_tags("vsys_ipList")
 
 class NetworkBuilder_IPv6_shared(NetworkBuilder):
     """ This sets up each slice as a class A private network.
@@ -291,7 +291,7 @@ class NetworkBuilder_IPv6_shared(NetworkBuilder):
         slice_id = slice["slice_id"]
 
         nodes = self.plc.GetNodes(slice["node_ids"], ["node_id", "hostname", "site_id"])
-        headnode = self.pick_headnode(nodes)
+        (nodes, headnode) = self.pick_headnode(nodes)
 
         hostmap = []
         for node in nodes:
@@ -310,12 +310,21 @@ class NetworkBuilder_IPv6_shared(NetworkBuilder):
         self.clear_tags("slice_bridge_name")
         self.clear_tags("slice_bridge_addr")
         self.clear_tags("slice_bridge_neighbors")
+        self.clear_tags("vsys_ipList")
 
 class NetworkBuilder_default(NetworkBuilder):
     def __init__(self, plc, slice):
         NetworkBuilder.__init__(self, plc, slice)
 
     def configure_slice(self):
+        nodes = self.plc.GetNodes(self.slice["node_ids"], ["node_id", "hostname", "site_id"])
+        (nodes, headnode) = self.pick_headnode(nodes)
+
+        ipList = [node["hostname"] for node in nodes]
+
+        ipList = ",".join(ipList)
+        self.set_tag("vsys_ipList", None, ipList)
+
         self.set_network_method(None)
         self.clear_tags("slice_hostmap")
         self.clear_tags("slice_bridge_name")