diff --git a/netconf/rpc.go b/netconf/rpc.go
index 0e069c2..7e57213 100644
--- a/netconf/rpc.go
+++ b/netconf/rpc.go
@@ -49,7 +49,7 @@ type RPCReply struct {
XMLName xml.Name `xml:"rpc-reply"`
Errors []RPCError `xml:"rpc-error,omitempty"`
Data string `xml:",innerxml"`
- Ok bool `xml:",omitempty"`
+ Ok bool `xml:"ok,omitempty"`
RawReply string `xml:"-"`
}
@@ -61,6 +61,11 @@ func newRPCReply(rawXML []byte, ErrOnWarning bool) (*RPCReply, error) {
return nil, err
}
+ // ugly workaround for golang's XML unmarshaling of empty tags
+ // if is missing then omitempty behavior makes Ok true
+ // if is present then omitempty behavior makes OK the value of that tag (nil) which then translates to false
+ reply.Ok = !reply.Ok
+
if reply.Errors != nil {
for _, rpcErr := range reply.Errors {
if rpcErr.Severity == "error" || ErrOnWarning {
diff --git a/netconf/rpc_test.go b/netconf/rpc_test.go
index c8fc370..4bbd81d 100644
--- a/netconf/rpc_test.go
+++ b/netconf/rpc_test.go
@@ -105,7 +105,7 @@ var RPCReplytests = []struct {
`,
- false,
+ true,
},
{
`
@@ -160,7 +160,7 @@ configuration check-out failed: (missing mandatory statements)
`,
- false,
+ true,
},
}
@@ -173,5 +173,8 @@ func TestNewRPCReply(t *testing.T) {
if reply.RawReply != tc.rawXML {
t.Errorf("newRPCReply(%q) did not set RawReply to input, got %q", tc.rawXML, reply.RawReply)
}
+ if reply.Ok != tc.replyOk {
+ t.Errorf("newRPCReply(%q).Ok == %v, want %v", tc.rawXML, reply.Ok, tc.replyOk)
+ }
}
}