Commit 0d4f2d5e authored by Leigh Stoller's avatar Leigh Stoller

Create missing interface_state rows.

parent 7a2d0d78
...@@ -101,7 +101,8 @@ while (my ($node_id,$card,$port) = $query_result->fetchrow_array()) { ...@@ -101,7 +101,8 @@ while (my ($node_id,$card,$port) = $query_result->fetchrow_array()) {
$ifaces{"$node_id:$card:$port"} = $interface; $ifaces{"$node_id:$card:$port"} = $interface;
my $node = Node->Lookup($node_id); my $node = Node->Lookup($node_id);
if (!exists($ifaces{"$node_id:$card:$port"}) && $node->role() eq "testnode") { if (!exists($wires{"$node_id:$card:$port"}) &&
$node->role() eq "testnode") {
print STDERR "No wires row for $interface\n"; print STDERR "No wires row for $interface\n";
} }
} }
...@@ -149,7 +150,7 @@ foreach my $interface (values(%ifaces)) { ...@@ -149,7 +150,7 @@ foreach my $interface (values(%ifaces)) {
# #
if (defined($interface->state())) { if (defined($interface->state())) {
if ($interface->state()->{'iface'} eq "") { if ($interface->state()->{'iface'} eq "") {
print STDERR "No iface set for $interface interface_state\n"; print STDERR "No iface set for $interface in interface_state\n";
if ($impotent) { if ($impotent) {
print STDERR "--> Would set it to $iface\n"; print STDERR "--> Would set it to $iface\n";
} }
...@@ -167,6 +168,22 @@ foreach my $interface (values(%ifaces)) { ...@@ -167,6 +168,22 @@ foreach my $interface (values(%ifaces)) {
"$interface (" . $interface->state()->{'iface'} . ")"); "$interface (" . $interface->state()->{'iface'} . ")");
} }
} }
else {
#
# Must be an interface_state for every interface.
#
if ($impotent) {
print STDERR "Would create missing interface_state for ".
"$nodeid:$iface\n";
}
else {
print STDERR "Creating missing interface_state for ".
"$nodeid:$iface\n";
DBQueryFatal("insert into interface_state set ".
" node_id='$nodeid',card='$card',".
" port='$port',iface='$iface'");
}
}
my $ifacename = $interface->node_id() . ":" . $interface->iface(); my $ifacename = $interface->node_id() . ":" . $interface->iface();
if (exists($ifacenames{$ifacename})) { if (exists($ifacenames{$ifacename})) {
......
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