Documentation ¶
Index ¶
- Constants
- type CfgDsOpt
- type CloseSessionReq
- type Config
- type ConfigOption
- type ConfigType
- type CopyConfigReq
- type Data
- type DeleteConfigReq
- type DiscardReq
- type EditConfigReq
- type EditOption
- type Filter
- type GetConfigReq
- type GetReq
- type GetSchema
- type KillSessionReq
- type LockReq
- type Namespace
- type NetconfState
- type OpSession
- type Schema
- type UnlockReq
Constants ¶
View Source
const ( // Configuration Datastores RunningCfg = "running" CandidateCfg = "candidate" StartupCfg = "startup" IntendedCfg = "intended" OperationalCfg = "operational" // Edit Config Error Options StopOnErrorErrOpt = "stop-on-error" ContinueOnErrorErrOpt = "continue-on-error" RollbackOnErrorErrOpt = "rollback-on-error" // Edit Config Operation Types MergeOp = "merge" ReplaceOp = "replace" NoneOp = "none" // Edit Config Test Options TestThenSetOpt = "test-then-set" SetOpt = "set" TestOnlyOpt = "test-only" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CloseSessionReq ¶
type ConfigOption ¶
type ConfigOption func(*EditConfigReq)
ConfigOption defines the configuration to be applied by an edit config operation
func Cfg ¶
func Cfg(cfg interface{}) ConfigOption
func CfgUrl ¶
func CfgUrl(url string) ConfigOption
type ConfigType ¶
type CopyConfigReq ¶
type CopyConfigReq struct { XMLName xml.Name `xml:"copy-config"` Target *ConfigType `xml:"target"` Source *ConfigType `xml:"source"` }
type DeleteConfigReq ¶
type DeleteConfigReq struct { XMLName xml.Name `xml:"delete-config"` Target *ConfigType `xml:"target"` }
type DiscardReq ¶
type EditConfigReq ¶
type EditConfigReq struct { XMLName xml.Name `xml:"edit-config"` Target *ConfigType `xml:"target"` ErrorOption string `xml:"error-option,omitempty"` TestOption string `xml:"test-option,omitempty"` DefaultOperation string `xml:"default-operation,omitempty"` Config *Config ConfigUrl string `xml:"url,omitempty"` }
type EditOption ¶
type EditOption func(*EditConfigReq)
EditOption configures an edit config operation.
func DefaultOperation ¶
func DefaultOperation(oper string) EditOption
func ErrorOption ¶
func ErrorOption(opt string) EditOption
func TestOption ¶
func TestOption(opt string) EditOption
type GetConfigReq ¶
type GetConfigReq struct { XMLName xml.Name `xml:"get-config"` Source *ConfigType `xml:"source"` Filter *Filter FilterBody string `xml:",innerxml"` }
type KillSessionReq ¶
type LockReq ¶
type LockReq struct { XMLName xml.Name `xml:"lock"` Target *ConfigType `xml:"target"` }
type NetconfState ¶
type NetconfState struct { XMLName xml.Name `xml:"urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring netconf-state"` Xmlns string `xml:"xmlns,attr"` Schemas struct { Schema []Schema `xml:"schema"` } `xml:"schemas"` Capabilities struct { Text string `xml:",chardata"` Capability []string `xml:"capability"` } `xml:"capabilities"` Statistics struct { Text string `xml:",chardata"` NetconfStartTime string `xml:"netconf-start-time"` InBadHellos string `xml:"in-bad-hellos"` InSessions string `xml:"in-sessions"` DroppedSessions string `xml:"dropped-sessions"` InRpcs string `xml:"in-rpcs"` InBadRpcs string `xml:"in-bad-rpcs"` OutRpcErrors string `xml:"out-rpc-errors"` OutNotifications string `xml:"out-notifications"` } `xml:"statistics"` Sessions struct { Text string `xml:",chardata"` Session struct { Text string `xml:",chardata"` SessionID string `xml:"session-id"` Transport string `xml:"transport"` Username string `xml:"username"` SourceHost string `xml:"source-host"` LoginTime string `xml:"login-time"` InRpcs string `xml:"in-rpcs"` InBadRpcs string `xml:"in-bad-rpcs"` OutRpcErrors string `xml:"out-rpc-errors"` OutNotifications string `xml:"out-notifications"` } `xml:"session"` } `xml:"sessions"` }
type OpSession ¶
type OpSession interface { client.Session // GetSubtree issues a GET request, with the supplied subtree filter and stores the response in the result, which // should be the address of either: // - a string, in which case it will hold the response body, or // - a struct with xml tags. GetSubtree(filter interface{}, result interface{}) error // GetXpath issues a GET request, with the supplied xpath filter and namespace list and stores the response in the result, which // should be the address of either: // - a string, in which case it will hold the response body, or // - a struct with xml tags. GetXpath(xpath string, nslist []Namespace, result interface{}) error // GetConfigSubtree issues a GET-CONFIG request, with the supplied subtree filter and source, and stores the // response in the result, which should be the address of either: // - a string, in which case it will hold the response body, or // - a struct with xml tags. GetConfigSubtree(filter interface{}, source string, result interface{}) error // GetConfigXpath issues a GET-CONFIG request, with the supplied xpath filter, source and namespace list and stores the // response in the result, which should be the address of either: // - a string, in which case it will hold the response body, or // - a struct with xml tags. GetConfigXpath(xpath string, nslist []Namespace, source string, result interface{}) error // GetSchemas returns an array of schemas supported by the device. GetSchemas() ([]Schema, error) // GetSchema returns the text of the schema identified by id and version, in the format defined by fmt. GetSchema(id, version, fmt string) (string, error) // EditConfig issues an edit-config request defined by config to be applied to the target configuration. // EditOptions can be added to qualify the operation. // config will be defined by a ConfigOption, which can be one of: // - Cfg(cfg), where cfg is // o an xml string, in which case it will be used verbatim as the content of the <config> element. // o a struct with xml tags that will be marshalled as the child of the <config> element. // - CfgUrl(url), in which case the configuration is defined by a <url> element. EditConfig(target string, config ConfigOption, options ...EditOption) error // EditConfigCfg issues an edit-config request defined by config to be applied to the target configuration. // EditOptions can be added to qualify the operation. // Convenience method to avoid complications with function arguments when using EditConfig() with a mock object EditConfigCfg(target string, config interface{}, options ...EditOption) error // CopyConfig issues a copy-config request. // source and target are defined by a CfgDsOpt, which can be one of: // - DsName(name) where name defines the configuration data store name (Running, Candidate ...) // - DsUrl(url) where url defines the url of the datastore CopyConfig(source, target CfgDsOpt) error // DeleteConfig issues a delete-config request. // target is defined by a CfgDsOpt, which can be one of: // - DsName(name) where name defines the configuration data store name (Running, Candidate ...) // - DsUrl(url) where url defines the url of the datastore to be deleted DeleteConfig(target CfgDsOpt) error // Lock issues a lock request on the target configuration. Lock(target string) error // Unlock issues an unlock request on the target configuration. Unlock(target string) error // Discard issues a discard changes request. Discard() error // CloseSession issues a close session request. CloseSession() error // KillSession issues a kill session request for the specified session id. KillSession(id uint64) error }
OpSession represents a Netconf Operations OpSession
func NewSession ¶
func NewSession(ctx context.Context, sshcfg *ssh.ClientConfig, target string) (s OpSession, err error)
NewSession connects to the target using the ssh configuration, and establishes a netconf session with default configuration.
type UnlockReq ¶
type UnlockReq struct { XMLName xml.Name `xml:"unlock"` Target *ConfigType `xml:"target"` }
Click to show internal directories.
Click to hide internal directories.