Support multiple interfaces.
authorDaniel Hokka Zakrisson <dhokka@cs.princeton.edu>
Tue, 27 Nov 2007 22:18:45 +0000 (22:18 +0000)
committerDaniel Hokka Zakrisson <dhokka@cs.princeton.edu>
Tue, 27 Nov 2007 22:18:45 +0000 (22:18 +0000)
source/steps/GetAndUpdateNodeDetails.py
source/steps/WriteNetworkConfig.py

index 3db047d..475847b 100644 (file)
@@ -38,6 +38,7 @@ def Run( vars, log ):
     SKIP_HARDWARE_REQUIREMENT_CHECK     Whether or not we should skip hardware
                                         requirement checks
     NODE_SESSION             The session value returned from BootGetNodeDetails
+    NODE_NETWORKS            The networks associated with this node
     
     Return 1 if able to contact PLC and get node info.
     Raise a BootManagerException if anything fails.
@@ -103,6 +104,8 @@ def Run( vars, log ):
 
     if not got_primary:
         raise BootManagerException, "Node did not have a primary network."
+
+    vars['NODE_NETWORKS']= node_networks
     
     log.write( "Primary network as returned from PLC: %s\n" % str(network) )
 
index f92985c..67bd8e1 100644 (file)
@@ -48,6 +48,7 @@ def Run( vars, log ):
                             (always starts with TEMP_PATH)
     NETWORK_SETTINGS  A dictionary of the values from the network
                                 configuration file
+    NODE_NETWORKS           All the network associated with this node
     Sets the following variables:
     None
     """
@@ -161,3 +162,28 @@ def Run( vars, log ):
         network_file.write( "GATEWAY=%s\n" % gateway )
     network_file.close()
     network_file= None
+
+    interface = 1
+    for network in vars['NODE_NETWORKS']:
+        if network['is_primary'] == 1:
+            continue
+        if method == "static" or method == "dhcp":
+            f = file("%s/etc/sysconfig/network-scripts/ifcfg-eth%d" %
+                     (SYSIMG_PATH, interface), "w")
+            f.write("DEVICE=eth%d\n" % interface)
+            f.write("HWADDR=%s\n" % mac)
+            f.write("ONBOOT=yes\n")
+            f.write("USERCTL=no\n")
+            if method == "static":
+                f.write("BOOTPROTO=static\n")
+                f.write("IPADDR=%s\n" % network['ip'])
+                f.write("NETMASK=%s\n" % network['netmask'])
+            elif method == "dhcp":
+                f.write("BOOTPROTO=dhcp\n")
+                if network['hostname']:
+                    f.write("DHCP_HOSTNAME=%s\n" % network['hostname'])
+                else:
+                    f.write("DHCP_HOSTNAME=%s\n" % hostname)
+                f.write("DHCLIENTARGS='-R subnet-mask'\n")
+            f.close()
+