Commit a00ec03b authored by Weibin Sun's avatar Weibin Sun

merge with portmerge

parent 8b3e5a5b
...@@ -588,8 +588,7 @@ sub LookupByWireType($$) ...@@ -588,8 +588,7 @@ sub LookupByWireType($$)
my @ports = (); my @ports = ();
my $result = DBQueryFatal("SELECT node_id1, card1, port1, " . my $result = DBQueryFatal("SELECT node_id1, card1, port1, " .
"node_id2, card2, port2 FROM wires ". "node_id2, card2, port2 FROM wires WHERE type='$wt'");
"WHERE type='$wt' and logical=0");
if ($result) { if ($result) {
while (my @row = $result->fetchrow()) { while (my @row = $result->fetchrow()) {
...@@ -876,7 +875,13 @@ sub getOtherEndIfaceString($) { ...@@ -876,7 +875,13 @@ sub getOtherEndIfaceString($) {
# get the other side of a port instance, according to 'wires' DB table # get the other side of a port instance, according to 'wires' DB table
# #
sub getOtherEndPort($) { sub getOtherEndPort($) {
return Port->LookupByTriple($_[0]->getOtherEndTripleString()); my $self = $_[0];
my $pt = Port->LookupByTriple($self->getOtherEndTripleString());
if (defined($pt)) {
return $pt;
} else {
return $self;
}
} }
# #
......
...@@ -337,7 +337,7 @@ DEVICE: foreach my $name (keys %portMap) { ...@@ -337,7 +337,7 @@ DEVICE: foreach my $name (keys %portMap) {
# Figure out which port on which switch this corresponds to # Figure out which port on which switch this corresponds to
# #
my $switchport = $port->getSwitchPort()? my $switchport = $port->getSwitchPort()?
$port->getSwitchPort()->toString():undef; $port->getSwitchPort():undef;
if (!$switchport) { if (!$switchport) {
warn "WARNING: No switch port found for ".$port->toString()."\n"; warn "WARNING: No switch port found for ".$port->toString()."\n";
......
...@@ -405,7 +405,7 @@ sub convertPortFormat($$@) { ...@@ -405,7 +405,7 @@ sub convertPortFormat($$@) {
if ($output == $PORT_FORMAT_NODEPORT) { if ($output == $PORT_FORMAT_NODEPORT) {
$self->debug("Converting ifindex to nodeport\n",2); $self->debug("Converting ifindex to nodeport\n",2);
return map $_->getPCPort()->toTripleString(), @pos; return map $_->getOtherEndPort()->toTripleString(), @pos;
} elsif ($output == $PORT_FORMAT_PORT) { } elsif ($output == $PORT_FORMAT_PORT) {
return @pos; return @pos;
} }
...@@ -419,7 +419,7 @@ sub convertPortFormat($$@) { ...@@ -419,7 +419,7 @@ sub convertPortFormat($$@) {
if ($output == $PORT_FORMAT_NODEPORT) { if ($output == $PORT_FORMAT_NODEPORT) {
$self->debug("Converting modport to nodeport\n",3); $self->debug("Converting modport to nodeport\n",3);
return map $_->getPCPort()->toTripleString(), @pos; return map $_->getOtherEndPort()->toTripleString(), @pos;
} elsif ($output == $PORT_FORMAT_PORT) { } elsif ($output == $PORT_FORMAT_PORT) {
return @pos; return @pos;
} }
...@@ -452,7 +452,7 @@ sub convertPortFormat($$@) { ...@@ -452,7 +452,7 @@ sub convertPortFormat($$@) {
)[1] } @ports; )[1] } @ports;
} elsif ($output == $PORT_FORMAT_NODEPORT) { } elsif ($output == $PORT_FORMAT_NODEPORT) {
$self->debug("Converting port to nodeport\n",3); $self->debug("Converting port to nodeport\n",3);
return map $_->getPCPort()->toTripleString(), @ports; return map $_->getOtherEndPort()->toTripleString(), @ports;
} }
} }
...@@ -1656,7 +1656,7 @@ sub walkTableIfIndex($$$;$) { ...@@ -1656,7 +1656,7 @@ sub walkTableIfIndex($$$;$) {
my $po = convertPortFromString("$self->{NAME}:$index") my $po = convertPortFromString("$self->{NAME}:$index")
|| convertPortFromString("$self->{NAME}:".$self->{IFINDEX}{$index}); || convertPortFromString("$self->{NAME}:".$self->{IFINDEX}{$index});
if (! defined $po) { next; } # Skip if we don't know about it if (! defined $po) { next; } # Skip if we don't know about it
my $port = $po->getPCPort()->toTripleString(); my $port = $po->getOtherEndPort()->toTripleString();
# #
# Apply the user's processing function # Apply the user's processing function
......
...@@ -493,7 +493,7 @@ sub convertPortFormat($$@) { ...@@ -493,7 +493,7 @@ sub convertPortFormat($$@) {
if ($output == $PORT_FORMAT_NODEPORT) { if ($output == $PORT_FORMAT_NODEPORT) {
$self->debug("Converting ifindex to nodeport\n",3); $self->debug("Converting ifindex to nodeport\n",3);
return map $_->getPCPort()->toTripleString(), @pos; return map $_->getOtherEndPort()->toTripleString(), @pos;
} elsif ($output == $PORT_FORMAT_PORT) { } elsif ($output == $PORT_FORMAT_PORT) {
return @pos; return @pos;
} }
...@@ -507,7 +507,7 @@ sub convertPortFormat($$@) { ...@@ -507,7 +507,7 @@ sub convertPortFormat($$@) {
if ($output == $PORT_FORMAT_NODEPORT) { if ($output == $PORT_FORMAT_NODEPORT) {
$self->debug("Converting modport to nodeport\n",3); $self->debug("Converting modport to nodeport\n",3);
return map $_->getPCPort()->toTripleString(), @pos; return map $_->getOtherEndPort()->toTripleString(), @pos;
} elsif ($output == $PORT_FORMAT_PORT) { } elsif ($output == $PORT_FORMAT_PORT) {
return @pos; return @pos;
} }
...@@ -540,7 +540,7 @@ sub convertPortFormat($$@) { ...@@ -540,7 +540,7 @@ sub convertPortFormat($$@) {
)[1] } @ports; )[1] } @ports;
} elsif ($output == $PORT_FORMAT_NODEPORT) { } elsif ($output == $PORT_FORMAT_NODEPORT) {
$self->debug("Converting port to nodeport\n",3); $self->debug("Converting port to nodeport\n",3);
return map $_->getPCPort()->toTripleString(), @ports; return map $_->getOtherEndPort()->toTripleString(), @ports;
} }
} }
...@@ -1364,7 +1364,7 @@ sub listPorts($) { ...@@ -1364,7 +1364,7 @@ sub listPorts($) {
$portname = $self->{NAME} . ":$modport"; $portname = $self->{NAME} . ":$modport";
my $port = Port->LookupByTriple($portname); my $port = Port->LookupByTriple($portname);
if (defined($port)) { if (defined($port)) {
$port = $port->getPCPort(); $port = $port->getOtherEndPort();
} }
# #
...@@ -1422,7 +1422,7 @@ sub getStats() { ...@@ -1422,7 +1422,7 @@ sub getStats() {
my $po = convertPortFromString("$self->{NAME}:$ifindex") my $po = convertPortFromString("$self->{NAME}:$ifindex")
|| convertPortFromString("$self->{NAME}:".$self->{IFINDEX}{$ifindex}); || convertPortFromString("$self->{NAME}:".$self->{IFINDEX}{$ifindex});
if (! defined $po) { next; } # Skip if we don't know about it if (! defined $po) { next; } # Skip if we don't know about it
my $port = $po->getPCPort()->toTripleString(); my $port = $po->getOtherEndPort()->toTripleString();
${$stats{$port}}[$i] = $value; ${$stats{$port}}[$i] = $value;
} }
......
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