Documentation
¶
Index ¶
- Variables
- func ExpandCapability(s string) string
- type Capability
- type ErrSeverity
- type ErrType
- type Filter
- type GetConfig
- type GetConfigRPC
- type GetConfigResp
- type HelloMsg
- type NotificationMsg
- type OKResponse
- type RPCError
- type RPCMsg
- type RPCReplyMsg
- type SentinalBool
- type Session
- func (s *Session) Call(ctx context.Context, op interface{}, resp interface{}) error
- func (s *Session) ClientCapabilities() []string
- func (s *Session) Close(ctx context.Context) error
- func (s *Session) Do(ctx context.Context, msg *RPCMsg) (*RPCReplyMsg, error)
- func (s *Session) GetConfig(ctx context.Context, source string) ([]byte, error)
- func (s *Session) ServerCapabilities() []string
- func (s *Session) SessionID() uint64
- type SessionOption
- type StringElem
Constants ¶
This section is empty.
Variables ¶
var DefaultCapabilities = []string{
"urn:ietf:params:netconf:base:1.0",
"urn:ietf:params:netconf:base:1.1",
}
DefaultCapabilties are the capabilties sent by the client during the hello exchange by the server.
Functions ¶
func ExpandCapability ¶
ExpandCapability will automatically add the standard capability prefix of `urn:ietf:params:netconf:capability` if not already present.
Types ¶
type Capability ¶
type Capability string
type ErrSeverity ¶
type ErrSeverity string
const ( SevError ErrSeverity = "error" SevWarning ErrSeverity = "warning" )
type GetConfig ¶
type GetConfig struct { XMLName xml.Name `xml:"get-config"` Source StringElem `xml:"source"` Filter *Filter `xml:"filter,omitempty"` }
type GetConfigRPC ¶
type GetConfigRPC struct { Source StringElem Filter Filter }
XXX: RPC calls these either Methods or Operations depending on what you look at.
type GetConfigResp ¶
type GetConfigResp struct { }
type HelloMsg ¶
type HelloMsg struct { XMLName xml.Name `xml:"urn:ietf:params:xml:ns:netconf:base:1.0 hello"` SessionID uint64 `xml:"session-id,omitempty"` Capabilities []string `xml:"capabilities>capability"` }
helloMsg maps the xml value of the <hello> message in RFC6241
type NotificationMsg ¶
type OKResponse ¶
type OKResponse struct {
Ok SentinalBool `xml:"ok"`
}
type RPCError ¶
type RPCError struct { Type string `xml:"error-type"` Tag string `xml:"error-tag"` Severity ErrSeverity `xml:"error-severity"` AppTag string `xml:"error-app-tag,omitempty"` Path string `xml:"error-path,omitempty"` Message string `xml:"error-message,omitempty"` Info interface{} `xml:"error-info,omitempty"` }
type RPCMsg ¶
type RPCMsg struct { XMLName xml.Name `xml:"urn:ietf:params:xml:ns:netconf:base:1.0 rpc"` MessageID uint64 `xml:"message-id,attr"` Operation interface{} `xml:",innerxml"` }
rpcMsg maps the xml value of <rpc> in RFC6241
type RPCReplyMsg ¶
type RPCReplyMsg struct { XMLName xml.Name `xml:"urn:ietf:params:xml:ns:netconf:base:1.0 rpc-reply"` MessageID uint64 `xml:"message-id,attr"` Errors []RPCError `xml:"rpc-error,omitempty"` Data []byte `xml:",innerxml"` }
rpcReplyMsg maps the xml value of <rpc-reply> in RFC6241
type SentinalBool ¶
type SentinalBool bool
func (SentinalBool) MarshalXML ¶
func (b SentinalBool) MarshalXML(e *xml.Encoder, start xml.StartElement) error
func (*SentinalBool) UnmarshalXML ¶
func (b *SentinalBool) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session is represents a netconf session to a one given device.
func Open ¶
func Open(transport transport.Transport, opts ...SessionOption) (*Session, error)
Open will create a new Session with th=e given transport and open it with the nessesary hello messages.
func (*Session) Call ¶
Call issues a rpc call for the given NETCONF operation and unmashaling the respose into `resp`.
func (*Session) ClientCapabilities ¶
ClientCapabilties will return the capabilities initialized with the session.
func (*Session) Close ¶
Close will gracefully close the sessions first by sending a `close-session` operation to the remote and then closing the underlying transport
func (*Session) Do ¶
Do issues a low level RPC call taking in a full RPCMsg and returning the full RPCReplyMsg. In most cases `Session.Call` will do what you want handling errors and marshaling/unmarshaling your data.`
func (*Session) ServerCapabilities ¶
ServcerCapabilties will return the capabilities returned by the server in it's hello message.
type SessionOption ¶
type SessionOption interface {
// contains filtered or unexported methods
}
func WithCapability ¶
func WithCapability(capabilities ...string) SessionOption
type StringElem ¶
type StringElem string
func (StringElem) MarshalXML ¶
func (s StringElem) MarshalXML(e *xml.Encoder, start xml.StartElement) error