Documentation
¶
Index ¶
- Constants
- func ForceSelfClosingTags(b []byte) []byte
- type Driver
- func (d *Driver) Close() error
- func (d *Driver) Commit(opts ...util.Option) (*response.NetconfResponse, error)
- func (d *Driver) CopyConfig(source, target string) (*response.NetconfResponse, error)
- func (d *Driver) DeleteConfig(target string) (*response.NetconfResponse, error)
- func (d *Driver) Discard() (*response.NetconfResponse, error)
- func (d *Driver) EditConfig(target, config string) (*response.NetconfResponse, error)
- func (d *Driver) EstablishPeriodicSubscription(xpath string, period int) (*response.NetconfResponse, error)
- func (d *Driver) Get(filter string, opts ...util.Option) (*response.NetconfResponse, error)
- func (d *Driver) GetConfig(source string, opts ...util.Option) (*response.NetconfResponse, error)
- func (d *Driver) GetSubscriptionMessages(i int) [][]byte
- func (d *Driver) Lock(target string) (*response.NetconfResponse, error)
- func (d *Driver) Open() (reterr error)
- func (d *Driver) RPC(opts ...util.Option) (*response.NetconfResponse, error)
- func (d *Driver) ServerCapabilities() []string
- func (d *Driver) ServerHasCapability(s string) bool
- func (d *Driver) SessionID() uint64
- func (d *Driver) Unlock(target string) (*response.NetconfResponse, error)
- func (d *Driver) Validate(source string) (*response.NetconfResponse, error)
- type OperationOptions
Constants ¶
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" )
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
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 ¶
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) 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) GetSubscriptionMessages ¶
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 ¶
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) ServerCapabilities ¶ added in v1.1.11
ServerCapabilities returns the list of capabilities the server sent in the initial Hello message.
func (*Driver) ServerHasCapability ¶
ServerHasCapability returns true if the server supports capability s, otherwise false.
func (*Driver) SessionID ¶ added in v1.1.11
SessionID returns the session ID sent by the server in the initial Hello message.
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.