netconf

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2024 License: MIT Imports: 15 Imported by: 9

Documentation

Index

Constants

View Source
const (
	// V1Dot0 is a constant for the NETCONF 1.0 version string.
	V1Dot0 = "1.0"

	// V1Dot1 is a constant for the NETCONF 1.1 version string.
	V1Dot1 = "1.1"
)
View Source
const (

	// FilterSubtree is a constant representing the subtree filter type.
	FilterSubtree = "subtree"

	// FilterXpath is a constant representing the xpath filter type.
	FilterXpath = "xpath"
)

Variables

This section is empty.

Functions

func ForceSelfClosingTags added in v1.1.5

func ForceSelfClosingTags(b []byte) []byte

ForceSelfClosingTags accepts a netconf looking xml byte slice and forces any "empty" tags (tags without attributes) to use self-closing tags. For example:

`<running> </running>`

Would be converted to:

`<running/>`.

Ideally this functino would just be replaced with this: https://github.com/golang/go/issues/59710 but for now this is more preferred than having either a different regex library imported, or importing @ECUST_XX proposed package. Historically, this was simply a regex.ReplaceAll but, there are/were issues with the pattern accidentally matching over already self closed tags inside other tags, for example:

`<target><candidate xyz/></target>`

Would end up like:

`<target><candidate xyz//>

Which is obviously not correct! This could be pretty easily solved in regex with backtracking/ capture groups but since we don't get that in std library go regex we can instead just write some simple code to iterate over stuff and replace as needed after comparing the open/close tags that our pattern found actually do match.

Types

type Driver

type Driver struct {
	Logger *logging.Instance

	TransportType string
	Transport     *transport.Transport

	Channel *channel.Channel

	PreferredVersion string
	SelectedVersion  string

	ForceSelfClosingTags bool
	ExcludeHeader        bool
	// contains filtered or unexported fields
}

Driver embeds generic.Driver and adds "netconf" centric functionality.

func NewDriver

func NewDriver(
	host string,
	opts ...util.Option,
) (*Driver, error)

NewDriver returns an instance of Driver for the provided host with the given options set. Any options in the driver/options package may be passed to this function -- those options may be applied at the network.Driver, generic.Driver, channel.Channel, or Transport depending on the specific option.

func (*Driver) Close

func (d *Driver) Close() error

Close closes the underlying channel.Channel and Transport objects.

func (*Driver) Commit

func (d *Driver) Commit(opts ...util.Option) (*response.NetconfResponse, error)

Commit executes a commit rpc against the NETCONF server.

func (*Driver) CopyConfig

func (d *Driver) CopyConfig(source, target string) (*response.NetconfResponse, error)

CopyConfig executes a copy config RPC against the NETCONF server copying the source to the target datastore.

func (*Driver) DeleteConfig

func (d *Driver) DeleteConfig(target string) (*response.NetconfResponse, error)

DeleteConfig executes the delete-config RPC against the NETCONF server deleting the target datastore.

func (*Driver) Discard

func (d *Driver) Discard() (*response.NetconfResponse, error)

Discard executes a discard rpc against the NETCONF server.

func (*Driver) EditConfig

func (d *Driver) EditConfig(target, config string) (*response.NetconfResponse, error)

EditConfig executes the edit-config RPC pushing the provided config against the target datastore.

func (*Driver) EstablishPeriodicSubscription

func (d *Driver) EstablishPeriodicSubscription(
	xpath string,
	period int,
) (*response.NetconfResponse, error)

EstablishPeriodicSubscription is a BETA method to establish a NETCONF subscription. Seriously, don't trust that this won't change, just pretend it doesn't exist for now or something!

func (*Driver) Get

func (d *Driver) Get(filter string, opts ...util.Option) (*response.NetconfResponse, error)

Get executes a get RPC against the NETCONF server.

func (*Driver) GetConfig

func (d *Driver) GetConfig(source string, opts ...util.Option) (*response.NetconfResponse, error)

GetConfig executes a get-config RPC against the NETCONF server.

func (*Driver) GetSubscriptionMessages

func (d *Driver) GetSubscriptionMessages(i int) [][]byte

GetSubscriptionMessages fetches any messages that have been received for the given subscription id i.

func (*Driver) Lock

func (d *Driver) Lock(target string) (*response.NetconfResponse, error)

Lock executes the lock rpc for the target datastore against the NETCONF server.

func (*Driver) Open

func (d *Driver) Open() (reterr error)

Open opens the underlying generic.Driver, and by extension the channel.Channel and Transport objects. This should be called prior to executing any RPC methods of the Driver.

func (*Driver) RPC

func (d *Driver) RPC(opts ...util.Option) (*response.NetconfResponse, error)

RPC executes a "bare" RPC against the NETCONF server.

func (*Driver) ServerCapabilities added in v1.1.11

func (d *Driver) ServerCapabilities() []string

ServerCapabilities returns the list of capabilities the server sent in the initial Hello message.

func (*Driver) ServerHasCapability

func (d *Driver) ServerHasCapability(s string) bool

ServerHasCapability returns true if the server supports capability s, otherwise false.

func (*Driver) SessionID added in v1.1.11

func (d *Driver) SessionID() uint64

SessionID returns the session ID sent by the server in the initial Hello message.

func (*Driver) Unlock

func (d *Driver) Unlock(target string) (*response.NetconfResponse, error)

Unlock executes unlock rpc for the target datastore against the NETCONF server.

func (*Driver) Validate

func (d *Driver) Validate(source string) (*response.NetconfResponse, error)

Validate executes validate RPC for the source datastore against the NETCONF server.

type OperationOptions

type OperationOptions struct {
	Filter      string
	FilterType  string
	DefaultType string
	Timeout     time.Duration

	CommitConfirmed          bool
	CommitConfirmTimeout     uint
	CommitConfirmedPersist   string
	CommitConfirmedPersistID string
}

OperationOptions is a struct containing "operation" options that are relevant to the Netconf Driver.

func NewOperation

func NewOperation(options ...util.Option) (*OperationOptions, error)

NewOperation returns a new OperationOptions object with the defaults set and any provided options applied.

Jump to

Keyboard shortcuts

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