Commit f4929aa5 authored by Kirk Webb's avatar Kirk Webb

Comware OF support: Adjust debug level on some output and minor fixups.

parent 37e01e65
......@@ -2496,39 +2496,44 @@ sub doH3CNetconfCLI($$;$) {
my ($self, $cmd, $execflag) = @_;
my $clitype = $execflag ? "Execution" : "Configuration";
my $id = "$self->{NAME}::doH3CNetconfCLI";
my $retval = undef;
if (!$cmd) {
warn "snmpit_h3c::doH3CNetconfCLI(): Must supply CLI command!\n";
warn "$id: Must supply CLI command!\n";
return undef;
}
my $cli_el = _el($clitype);
$cli_el->appendText($cmd);
my $clires = $self->{NCOBJ}->doRPC("CLI", $cli_el);
if ($clires->[0] == NCRPCRAWRES()) {
if (!defined($clires)) {
warn "$id: Error attempting to run Netconf CLI command!\n";
return undef;
}
elsif ($clires->[0] == NCRPCRAWRES()) {
my $res_el = $clires->[1];
if ($res_el->nodeName() ne "CLI") {
warn "snmpit_h3c::doH3CNetconfCLI(): got non-CLI data back!?\n";
warn "$id: got non-CLI data back!?\n";
return undef;
}
my ($exec_el,) = $res_el->getChildrenByLocalName($clitype);
if (!$exec_el) {
warn "snmpit_h3c::doH3CNetconfCLI(): No return data?!\n";
warn "$id: No return data?!\n";
return undef;
}
$retval = $exec_el->textContent() || "";
}
elsif ($clires->[0] eq NCRPCERR()) {
my $err = $clires->[1];
warn "snmpit_h3c::doH3CNetconfCLI(): Error returned:\n".
warn "$id: Error returned:\n".
"\ttype: $err->{type}, tag: $err->{tag}, sev: $err->{severity}\n".
"\tmessage: $err->{message}\n".
"\textra info: $err->{info}\n";
$retval = undef;
}
else {
warn "snmpit_h3c::doH3CNetconfCLI(): Unhandled return code ".
warn "$id: Unhandled return code ".
"from libNetconf: $clires->[0]\n";
$retval = undef;
}
......@@ -2672,7 +2677,7 @@ sub setOpenflowController($$$$) {
my $controller = shift;
my $option = shift;
my $id = "self->{NAME}::setOpenflowController";
my $id = "$self->{NAME}::setOpenflowController";
my ($ctrlproto, $ctrladdr, $ctrlport) = split(/:/, $controller);
# Get list of OF instances.
......@@ -2719,7 +2724,7 @@ sub setOpenflowListener($$$) {
my $vlan = shift;
my $listener = shift;
warn "$self->{NAME}: OpenFlow listeners are not supported!";
warn "$self->{NAME}: OpenFlow listeners are not supported!\n";
return 0;
}
......@@ -2729,7 +2734,7 @@ sub setOpenflowListener($$$) {
sub getUsedOpenflowListenerPorts($) {
my $self = shift;
warn "$self->{NAME}: OpenFlow listeners are not supported!";
warn "$self->{NAME}: OpenFlow listeners are not supported!\n";
return ();
}
......
......@@ -190,9 +190,7 @@ sub XMLPrettyPrint($) {
eval { require XML::LibXML::PrettyPrint };
if ($@) {
$retstr =
"-> Can't pretty print: XML::LibXML::PrettyPrint not found.\n" .
$xmldom . "\n";
$retstr = $xmldom->toString(2) . "\n";
} else {
my $pp = XML::LibXML::PrettyPrint->new(indent_string => " ");
$retstr = $pp->pretty_print($xmldom->documentElement()->cloneNode(1))->toString();
......@@ -261,15 +259,16 @@ sub _expectConnect($)
my $hellodoc = $self->_mkNCHelloXML();
my $docstr = $hellodoc->serialize() . $NCDELIM;
$docstr =~ s/[\n\r]//g;
$self->debugpr("Sending Hello: ". $docstr ."\n");
$self->debugpr("Sending Hello:\n" . XMLPrettyPrint($hellodoc), 2);
$exp->send($docstr);
#sleep 1;
#$exp->send("\n");
# Snap up the initial Netconf "Hello" message.
# Snap up the initial Netconf "Hello" message from switch.
$self->{SWITCH_HELLO} = $exp->before();
$self->debugpr(XMLPrettyPrint($self->{SWITCH_HELLO}));
$self->debugpr("Switch Hello:\n". $self->{SWITCH_HELLO} ."\n", 2);
# Store it, yo.
$self->{SESS} = $exp;
return 1;
......@@ -346,7 +345,7 @@ sub _decodeRPCReply($$) {
return undef;
}
$self->debugpr("Decoding:\n". XMLPrettyPrint($respdom));
$self->debugpr("Decoding:\n". XMLPrettyPrint($respdom), 2);
# Make sure this is an "rpc-reply" response.
my $root = $respdom->documentElement();
......@@ -439,7 +438,6 @@ sub _closeSession($) {
my $res = $self->doRPC("close-session");
if ($res && $res->[0] eq NCRPCERR()) {
warn "Error closing Netconf session with $self->{NAME}!\n";
$self->debugpr(Dumper($res->[1]));
}
}
......@@ -505,7 +503,7 @@ sub doRPC($$;$) {
my $exp = $self->{SESS};
my $docstr = $xmldoc->serialize() . $NCDELIM;
#$docstr =~ s/[\n\r]//g; # Need line endings for CLI commands...
$self->debugpr("Submitting: ". $docstr ."\n");
$self->debugpr("Submitting: ". XMLPrettyPrint($xmldoc), 2);
sleep 1;
$exp->send($docstr);
......
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