netconf

package
v0.0.0-...-c20f4a1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 25, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NsNetconf             = "urn:ietf:params:xml:ns:netconf:base:1.0"
	NsNetconfWithDefaults = "urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults"
	NsNetconfNotification = "urn:ietf:params:xml:ns:netconf:notification:1.0"
	NsNetmodNotification  = "urn:ietf:params:xml:ns:netmod:notification"
	NsNetconfMonitoring   = "urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring"

	CapNetconf10       = "urn:ietf:params:netconf:base:1.0"
	CapNetconf11       = "urn:ietf:params:netconf:base:1.1"
	CapConfirmedCommit = "urn:ietf:params:netconf:capability:confirmed-commit:1.1"
	CapValidate        = "urn:ietf:params:netconf:capability:validate:1.1"
	CapWithDefaults    = "urn:ietf:params:netconf:capability:with-defaults:1.0"
	CapNotifiction     = "urn:ietf:params:netconf:capability:notification:1.0"
	CapInterleave      = "urn:ietf:params:netconf:capability:interleave:1.0"
	CapStartup         = "urn:ietf:params:netconf:capability:startup:1.0"
	CapWritableRunning = "urn:ietf:params:netconf:capability:writable-running:1.0"
	CapCandidate       = "urn:ietf:params:netconf:capability:candidate:1.0"
	CapRollbackOnError = "urn:ietf:params:netconf:capability:rollback-on-error:1.0"
	CapURL             = "urn:ietf:params:netconf:capability:url:1.0"
	CapXPath           = "urn:ietf:params:netconf:capability:xpath:1.0"
	CapMonitoring      = NsNetconfMonitoring

	Running   Datastore = "running"
	Candidate Datastore = "candidate"
	Startup   Datastore = "startup"
	Intended  Datastore = "intended"

	OpMerge   DefaultOperation = "merge"
	OpReplace DefaultOperation = "replace"
	OpNone    DefaultOperation = "none"

	TestThenSet TestOption = "test-then-set"
	TestOnlySet TestOption = "set"
	TestOnly    TestOption = "test-only"

	StopOnError     ErrorOption = "stop-on-error"
	ContinueOnError ErrorOption = "continue-on-error"
	RollbackOnError ErrorOption = "rollback-on-error"

	ReportAll       DefaultsMode = "report-all"
	ReportAllTagged DefaultsMode = "report-all-tagged"
	Trim            DefaultsMode = "trim"
	Explicit        DefaultsMode = "explicit"
)

List of standardized constants related to the NETCONF protocol and its extensions

Variables

View Source
var ErrCapabilitiesExchange = errors.New("capabilities exchange failed")

ErrCapabilitiesExchange indicates a failed NETCONF hello-exchange due to incompatible versions or invalid session ID

View Source
var ErrFraming = errors.New("NETCONF message framing error")

ErrFraming describes a NETCONF protocol error due to invalid message framing

Functions

This section is empty.

Types

type Action

type Action struct {
	XMLName  xml.Name `xml:"urn:ietf:params:xml:ns:yang:1 action"`
	InnerXML []byte   `xml:",innerxml"`
}

Action defines a Yang 1.1 action

type CancelCommit

type CancelCommit struct {
	XMLName   xml.Name `xml:"urn:ietf:params:xml:ns:netconf:base:1.0 cancel-commit"`
	PersistID *string  `xml:"urn:ietf:params:xml:ns:netconf:base:1.0 persist-id,omitempty"`
}

CancelCommit defines the <cancel-commit> operation for use with Session.CallProcedure

type Client

type Client interface {
	io.Closer
	NewSession() (*Session, error)
}

Client defines a transport-independent interface for NETCONF clients

func DialSSHWithPassword

func DialSSHWithPassword(addr string, username string, password string, cb ssh.HostKeyCallback) (Client, error)

DialSSHWithPassword is a convenience function to creating a new NETCONF over SSH session

func DialSSHWithPublicKey

func DialSSHWithPublicKey(addr string, username string, signer ssh.Signer, cb ssh.HostKeyCallback) (Client, error)

DialSSHWithPublicKey is a convenience function to creating a new NETCONF over SSH session

func NewClientSSH

func NewClientSSH(client *ssh.Client) Client

NewClientSSH creates a new NETCONF SSH client from a

type Commit

type Commit struct {
	XMLName   xml.Name `xml:"urn:ietf:params:xml:ns:netconf:base:1.0 commit"`
	PersistID *string  `xml:"urn:ietf:params:xml:ns:netconf:base:1.0 persist-id,omitempty"`
}

Commit defines the <commit> operation for use with Session.CallProcedure

type CommitConfirmed

type CommitConfirmed struct {
	XMLName        xml.Name `xml:"urn:ietf:params:xml:ns:netconf:base:1.0 commit"`
	Confirmed      struct{} `xml:"urn:ietf:params:xml:ns:netconf:base:1.0 confirmed"`
	ConfirmTimeout *uint    `xml:"urn:ietf:params:xml:ns:netconf:base:1.0 confirm-timeout,omitempty"`
	Persist        *string  `xml:"urn:ietf:params:xml:ns:netconf:base:1.0 persist,omitempty"`
}

CommitConfirmed defines the <commit> operation for confirmed commits for use with Session.CallProcedure

type CopyConfig

type CopyConfig struct {
	XMLName xml.Name  `xml:"urn:ietf:params:xml:ns:netconf:base:1.0 copy-config"`
	Target  Datastore `xml:"urn:ietf:params:xml:ns:netconf:base:1.0 target"`
	Source  Datastore `xml:"urn:ietf:params:xml:ns:netconf:base:1.0 source"`
}

CopyConfig defines the <copy-config> operation for use with Session.CallProcedure

type CreateSubscription

type CreateSubscription struct {
	XMLName   xml.Name   `xml:"urn:ietf:params:xml:ns:netconf:notification:1.0 create-subscription"`
	Stream    *string    `xml:"urn:ietf:params:xml:ns:netconf:notification:1.0 stream,omitempty"`
	Filter    *Filter    `xml:"urn:ietf:params:xml:ns:netconf:notification:1.0 filter,omitempty"`
	StartTime *time.Time `xml:"urn:ietf:params:xml:ns:netconf:notification:1.0 startTime,omitempty"`
	StopTime  *time.Time `xml:"urn:ietf:params:xml:ns:netconf:notification:1.0 stoptTime,omitempty"`
}

CreateSubscription defines the <create-subscription> operation for use with Session.CallProcedure

type Datastore

type Datastore string

Datastore on NETCONF agent

func (Datastore) MarshalXML

func (d Datastore) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML datastore into XML depending if it is a URL (contains a ':') or not

type DefaultOperation

type DefaultOperation string

DefaultOperation specifies default behavior for edit-config operation

type DefaultsMode

type DefaultsMode string

DefaultsMode specifies how to handle default values specified in YANG

type DeleteConfig

type DeleteConfig struct {
	XMLName xml.Name  `xml:"urn:ietf:params:xml:ns:netconf:base:1.0 delete-config"`
	Target  Datastore `xml:"urn:ietf:params:xml:ns:netconf:base:1.0 target"`
}

DeleteConfig defines the <delete-config> operation for use with Session.CallProcedure

type DiscardChanges

type DiscardChanges struct {
	XMLName xml.Name `xml:"urn:ietf:params:xml:ns:netconf:base:1.0 discard-changes"`
}

DiscardChanges defines the <discard-changes> operation for use with Session.CallProcedure

type EditConfig

type EditConfig struct {
	XMLName          xml.Name          `xml:"urn:ietf:params:xml:ns:netconf:base:1.0 edit-config"`
	Target           Datastore         `xml:"urn:ietf:params:xml:ns:netconf:base:1.0 target"`
	DefaultOperation *DefaultOperation `xml:"urn:ietf:params:xml:ns:netconf:base:1.0 default-operation,omitempty"`
	TestOption       *TestOption       `xml:"urn:ietf:params:xml:ns:netconf:base:1.0 test-option,omitempty"`
	ErrorOption      *ErrorOption      `xml:"urn:ietf:params:xml:ns:netconf:base:1.0 error-option,omitempty"`
	Config           struct {
		InnerXML []byte `xml:",innerxml"`
	} `xml:"urn:ietf:params:xml:ns:netconf:base:1.0 config"`
}

EditConfig defines the <edit-config> operation for use with Session.CallProcedure

type ErrorOption

type ErrorOption string

ErrorOption specifies error-handling for edit-config operation

type Filter

type Filter struct {
	Type    string `xml:"urn:ietf:params:xml:ns:netconf:base:1.0 type,attr,omitempty"`
	Select  string `xml:"select,attr,omitempty"`
	Subtree string `xml:",innerxml"`
}

Filter defines the basic structure of a filter for <get> and <get-config> operations

type Get

type Get struct {
	XMLName      xml.Name     `xml:"get"`
	Filter       *Filter      `xml:"filter,omitempty"`
	WithDefaults DefaultsMode `xml:"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults with-defaults,omitempty"`
}

Get defines the <get> operation for use with Session.Call

type GetConfig

type GetConfig struct {
	XMLName      xml.Name     `xml:"get-config"`
	Source       Datastore    `xml:"source"`
	Filter       *Filter      `xml:"filter,omitempty"`
	WithDefaults DefaultsMode `xml:"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults with-defaults,omitempty"`
}

GetConfig defines the <get-config> operation for use with Session.Call

type GetSchema

type GetSchema struct {
	XMLName    xml.Name `xml:"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring get-schema"`
	Identifier string   `xml:"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring identifier"`
	Version    *string  `xml:"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring version,omitempty"`
	Format     *string  `xml:"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring format,omitempty"`
}

GetSchema defines the <get-schema> operation for use with Session.Call

type KillSession

type KillSession struct {
	XMLName   xml.Name `xml:"urn:ietf:params:xml:ns:netconf:base:1.0 kill-session"`
	SessionID uint64   `xml:"urn:ietf:params:xml:ns:netconf:base:1.0 session-id"`
}

KillSession defines the <kill-session> operation for use with Session.CallProcedure

type Lock

type Lock struct {
	XMLName xml.Name  `xml:"urn:ietf:params:xml:ns:netconf:base:1.0 lock"`
	Target  Datastore `xml:"urn:ietf:params:xml:ns:netconf:base:1.0 target"`
}

Lock defines the <lock> operation for use with Session.CallProcedure

type NCSCommitParameter

type NCSCommitParameter string

NCSCommitParameter defines custom commit parameters for NCS

type Notification

type Notification struct {
	XMLName   xml.Name  `xml:"urn:ietf:params:xml:ns:netconf:notification:1.0 notification"`
	EventTime time.Time `xml:"eventTime"`
}

Notification describes the basic struct for NETCONF notifications (RFC 5277)

type RPCError

type RPCError struct {
	XMLName       xml.Name `xml:"rpc-error"`
	ErrorType     string   `xml:"error-type"`
	ErrorTag      string   `xml:"error-tag"`
	ErrorSeverity string   `xml:"error-severity"`
	ErrorAppTag   string   `xml:"error-app-tag"`
	ErrorPath     string   `xml:"error-path"`
	ErrorMessage  string   `xml:"error-message"`
	ErrorInfo     struct {
		BadElement   string `xml:"bad-element"`
		BadAttribute string `xml:"bad-attribute"`
		BadNamespace string `xml:"bad-namespace"`
		SessionID    string `xml:"session-id"`
		InnerXML     []byte `xml:",innerxml"`
	} `xml:"error-info"`
}

RPCError models a NETCONF <rpc-error> element

func (RPCError) Error

func (e RPCError) Error() string

type RPCReply

type RPCReply struct {
	XMLName  xml.Name   `xml:"urn:ietf:params:xml:ns:netconf:base:1.0 rpc-reply"`
	RPCError []RPCError `xml:"rpc-error"`
}

RPCReply models a NETCONF <rpc-reply> element for inclusion in other structs

type RPCReplyData

type RPCReplyData struct {
	RPCReply
	Data struct {
		InnerXML []byte `xml:",innerxml"`
	} `xml:"data"`
}

RPCReplyData models a NETCONF <rpc-reply> element with a data child

type Session

type Session struct {
	SessionID    uint64
	Capabilities map[string]string
	// contains filtered or unexported fields
}

Session represents a session towards the server

func (*Session) Call

func (s *Session) Call(request interface{}, response interface{}) error

Call a NETCONF RPC and retrieve its reply

func (*Session) CallSimple

func (s *Session) CallSimple(request interface{}) error

CallSimple calls a NETCONF RPC and returns the first rpc-error or nil if there was none

func (*Session) Close

func (s *Session) Close() error

Close the session gracefully

func (*Session) NewReader

func (s *Session) NewReader() io.ReadCloser

NewReader creates a low-level reader for receiving the next NETCONF message

func (*Session) NewWriter

func (s *Session) NewWriter() io.WriteCloser

NewWriter creates a low-level writing for sending the next NETCONF message

func (*Session) Receive

func (s *Session) Receive(response interface{}) error

Receive a message from the server, e.g. a notification

type TailfAction

type TailfAction struct {
	XMLName xml.Name `xml:"http://tail-f.com/ns/netconf/actions/1.0 action"`
	Data    struct {
		InnerXML []byte `xml:",innerxml"`
	} `xml:"data"`
}

TailfAction defines a tailf:action extension

type TestOption

type TestOption string

TestOption specifies test-behavior for edit-config operation

type Unlock

type Unlock struct {
	XMLName xml.Name  `xml:"urn:ietf:params:xml:ns:netconf:base:1.0 lock"`
	Target  Datastore `xml:"urn:ietf:params:xml:ns:netconf:base:1.0 target"`
}

Unlock defines the <unlock> operation for use with Session.CallProcedure

type Validate

type Validate struct {
	XMLName xml.Name  `xml:"urn:ietf:params:xml:ns:netconf:base:1.0 validate"`
	Source  Datastore `xml:"urn:ietf:params:xml:ns:netconf:base:1.0 source"`
}

Validate defines the <validate> operation for use with Session.CallProcedure

type ValidateConfig

type ValidateConfig struct {
	XMLName xml.Name `xml:"urn:ietf:params:xml:ns:netconf:base:1.0 validate"`
	Config  struct {
		InnerXML []byte `xml:",innerxml"`
	} `xml:"source>config"`
}

ValidateConfig defines the <validate> operation on an explicit config for use with Session.CallProcedure

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL