From 5f942a731f9d57973b709c2225c9026c33be1d9e Mon Sep 17 00:00:00 2001 From: "Leigh B. Stoller" <stoller@flux.utah.edu> Date: Tue, 31 May 2005 19:24:10 +0000 Subject: [PATCH] A few more ELABINELAB related changes. The ordering of interfaces might different, as reported by the newnode MFS. At present, I need the ordering (and thus, the iface names) to agree with the outer emulab since that is how I request vlans to be setup. This is not very pleasing, and I will probably have to change it to use MACs instead. For now, reorder the new_interfaces based on what switchmac (the proxy) tells us. --- www/newnode-defs.php3 | 8 ++++---- www/newnodes_list.php3 | 39 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 5 deletions(-) diff --git a/www/newnode-defs.php3 b/www/newnode-defs.php3 index 59ecdba056..6de6e2a819 100644 --- a/www/newnode-defs.php3 +++ b/www/newnode-defs.php3 @@ -50,15 +50,15 @@ function find_switch_macs(&$mac_list) { if ($ELABINELAB) { # We let switchmac tell us. $mac_list[$MAC]["class"] = $class; + # Need this to reorder the interfaces. + $mac_list[$MAC]["iface"] = $iface; } } $line = fgets($macs); } - pclose($macs); - - return 1; - + # Return exit status to caller! + return pclose($macs); } function guess_node_type($proc,$disk) { diff --git a/www/newnodes_list.php3 b/www/newnodes_list.php3 index f3ecd2fc7d..ccb5fdc039 100644 --- a/www/newnodes_list.php3 +++ b/www/newnodes_list.php3 @@ -143,7 +143,44 @@ if ($research) { } echo "<h3>Looking for MACs, this could take a while...</h3>"; - find_switch_macs($mac_list); + $retval = find_switch_macs($mac_list); + if ($ELABINELAB && $retval == 0) { + # + # Ick, Ick, Ick. Must reorder the interfaces so that they are + # the same as the outside Emulab, so that when we request the + # outer emulab to create a vlan, both are talking about the same + # interface. This is of course, bogus. I think I will have to + # change it so that we use the MACs instead of the iface name. + # That should be an easy change to snmpit_remote and the xmlrpc + # server stub (or the proxy I guess). + # + # Move them out of the way + # + foreach ($mac_list as $mac => $switchport) { + DBQueryFatal("update new_interfaces set card = card + 100 " . + "where new_node_id='$switchport[new_node_id]' and " . + " card=$switchport[card]"); + } + # + # Now move them back to proper location, as specifed by the iface + # that the outer emulab return to us. + # + foreach ($mac_list as $mac => $switchport) { + $iface = $switchport["iface"]; + + if (preg_match("/^(.*\D)(\d+)$/", $iface, $matches)) { + $newcard = $matches[2]; + $oldcard = $switchport["card"] + 100; + + DBQueryFatal("update new_interfaces set card = $newcard " . + "where new_node_id='$switchport[new_node_id]' " . + " and card=$oldcard"); + + # Remember, $switchport is a *copy*, so must change $mac_list + $mac_list[$mac]["card"] = $newcard; + } + } + } foreach ($mac_list as $mac => $switchport) { if ($switchport["switch"]) { $extra_set = ""; -- GitLab