Commit d4a700fa authored by Leigh Stoller's avatar Leigh Stoller

Script to change the name of an interface. We find all the places in

database (that I know of) and changes them so that things should just
work after the change (say, swapout of an active experiment using that
interface).
parent 9d39d1b8
...@@ -36,7 +36,8 @@ SBIN_SCRIPTS = avail inuse showgraph if2port backup webcontrol node_status \ ...@@ -36,7 +36,8 @@ SBIN_SCRIPTS = avail inuse showgraph if2port backup webcontrol node_status \
idletimes idlemail setsitevar audit changeuid changepid \ idletimes idlemail setsitevar audit changeuid changepid \
elabinelab_bossinit update_permissions mysqld_watchdog \ elabinelab_bossinit update_permissions mysqld_watchdog \
dumperrorlog changeleader checkstats changecreator \ dumperrorlog changeleader checkstats changecreator \
dbupdate geni_control subboss_sync showvlans updatewires dbupdate geni_control subboss_sync showvlans updatewires \
changeiface
WEB_SBIN_SCRIPTS= webnodelog webidlemail webchangeuid \ WEB_SBIN_SCRIPTS= webnodelog webidlemail webchangeuid \
webchangeleader webchangeleader
......
...@@ -112,13 +112,15 @@ while (my ($node_id1,$card1,$port1) = $query_result->fetchrow_array()) { ...@@ -112,13 +112,15 @@ while (my ($node_id1,$card1,$port1) = $query_result->fetchrow_array()) {
} }
$query_result = $query_result =
DBQueryFatal("select node_id,iface,card,port from interfaces"); DBQueryFatal("select node_id,iface from interfaces");
while (my ($node_id,$iface,$card,$port) = $query_result->fetchrow_array()) { while (my ($node_id,$iface) = $query_result->fetchrow_array()) {
my $interface = Interface->LookupByIface($node_id, $iface); my $interface = Interface->LookupByIface($node_id, $iface);
if (!defined($interface)) { if (!defined($interface)) {
print STDERR "No interface object for $node_id:$card:$port\n"; print STDERR "No interface object for $node_id:$iface\n";
next; next;
} }
my $card = $interface->card_saved();
my $port = $interface->port_saved();
$ifaces{"$node_id:$card:$port"} = $interface; $ifaces{"$node_id:$card:$port"} = $interface;
my $node = Node->Lookup($node_id); my $node = Node->Lookup($node_id);
...@@ -165,7 +167,7 @@ foreach my $interface (values(%ifaces)) { ...@@ -165,7 +167,7 @@ foreach my $interface (values(%ifaces)) {
else { else {
$update_state = 1 $update_state = 1
if (defined($interface->state())); if (defined($interface->state()));
$iface = sprintf("eth%02d%02d", $interface->card(), $interface->port()); $iface = sprintf("eth%02d%02d", $card, $port);
} }
print STDERR "No iface set for $interface\n"; print STDERR "No iface set for $interface\n";
if ($impotent) { if ($impotent) {
...@@ -215,8 +217,8 @@ foreach my $interface (values(%ifaces)) { ...@@ -215,8 +217,8 @@ foreach my $interface (values(%ifaces)) {
print STDERR "Creating missing interface_state for ". print STDERR "Creating missing interface_state for ".
"$node_id:$iface\n"; "$node_id:$iface\n";
DBQueryFatal("insert into interface_state set ". DBQueryFatal("insert into interface_state set ".
" node_id='$node_id',card='$card',". " node_id='$node_id',card_saved='$card',".
" port='$port',iface='$iface'"); " port_saved='$port',iface='$iface'");
} }
} }
my $ifacename = $interface->node_id() . ":" . $interface->iface(); my $ifacename = $interface->node_id() . ":" . $interface->iface();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment