Commit 92dae219 authored by Weibin Sun's avatar Weibin Sun
Browse files

isswitchport to recognize node.card/port format

parent 2f02f934
......@@ -797,6 +797,17 @@ sub toNodeCardString($) {
return Tokens2IfaceString($_[0]->node_id(), $_[0]->card());
}
sub getEndByNode($$) {
my ($self, $n) = @_;
if ($n eq $self->node_id()) {
return $self;
} elsif ($n eq $self->other_end_node_id()) {
return $self->getOtherEndPort();
} else {
return undef;
}
}
sub getOtherEndTripleString($) {
return Tokens2TripleString($_[0]->other_end_node_id(), $_[0]->other_end_card(), $_[0]->other_end_port());
}
......
......@@ -229,12 +229,13 @@ sub toApconPort($$)
{
my ($self, $p) = @_;
if ($p->node_id() ne $self->{NAME}) {
return $p;
my $apcport = $p->getEndByNode($self->{NAME});
if (!defined($apcport)) {
return $p;
}
my $card = chr(ord('A')+int($p->card()) - 1);
my $port = sprintf("%02d", int($p->port()));
my $card = chr(ord('A')+int($apcport->card()) - 1);
my $port = sprintf("%02d", int($apcport->port()));
return "$card"."$port";
}
......
......@@ -688,7 +688,7 @@ sub convertPortFromIface($;$) {
sub isSwitchPort($) {
my $port = shift;
if ($port =~ /^(.+):(.+)/) {
if ($port =~ /^(.+):(.+)/ || $port =~ /^(.+)\.(.+)\/(.+)$/) {
my $node = $1;
my $result = DBQueryFatal("SELECT isswitch FROM node_types WHERE type IN ".
......
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