go-netconf: github.com/Juniper/go-netconf/netconf Index | Files | Directories

package netconf

import "github.com/Juniper/go-netconf/netconf"

Index

Package Files

log.go rpc.go session.go transport.go transport_ssh.go transport_telnet.go util.go

Variables

var DefaultCapabilities = []string{
    "urn:ietf:params:xml:ns:netconf:base:1.0",
}

DefaultCapabilities sets the default capabilities of the client library

func SSHConfigPassword Uses

func SSHConfigPassword(user string, pass string) *ssh.ClientConfig

SSHConfigPassword is a convenience function that takes a username and password and returns a new ssh.ClientConfig setup to pass that username and password. Convenience means that HostKey checks are disabled so it's probably less secure

func SSHConfigPubKeyAgent Uses

func SSHConfigPubKeyAgent(user string) (*ssh.ClientConfig, error)

SSHConfigPubKeyAgent is a convience function that takes a username and returns a new ssh.Clientconfig setup to pass credentials received from an ssh agent

func SSHConfigPubKeyFile Uses

func SSHConfigPubKeyFile(user string, file string, passphrase string) (*ssh.ClientConfig, error)

SSHConfigPubKeyFile is a convenience function that takes a username, private key and passphrase and returns a new ssh.ClientConfig setup to pass credentials to DialSSH

func SetLog Uses

func SetLog(l Logger)

SetLog sets the logger as the currently selected logger.

type HelloMessage Uses

type HelloMessage struct {
    XMLName      xml.Name `xml:"hello"`
    Capabilities []string `xml:"capabilities>capability"`
    SessionID    int      `xml:"session-id,omitempty"`
}

HelloMessage is used when bringing up a NetConf session

type LogLevel Uses

type LogLevel int

LogLevel represents at which level the app should log

const (
    LogError LogLevel = iota
    LogWarn
    LogInfo
    LogDebug
)

Sets the log levels based on the system being connected to

type Logger Uses

type Logger interface {
    Debugf(string, ...interface{})
    Infof(string, ...interface{})
    Warnf(string, ...interface{})
    Errorf(string, ...interface{})
    Fatalf(string, ...interface{})
    Panicf(string, ...interface{})
}

Logger defines different logging levels for use by a logger

type NoopLog Uses

type NoopLog struct{}

NoopLog is for use when you don't want to actually log out

func (NoopLog) Debugf Uses

func (l NoopLog) Debugf(format string, v ...interface{})

Debugf adds the formatted debug logging function string

func (NoopLog) Errorf Uses

func (l NoopLog) Errorf(format string, v ...interface{})

Errorf adds the formatted error logging function string

func (NoopLog) Fatalf Uses

func (l NoopLog) Fatalf(format string, v ...interface{})

Fatalf adds the formatted fatal logging function string

func (NoopLog) Infof Uses

func (l NoopLog) Infof(format string, v ...interface{})

Infof adds the formatted information logging function string

func (NoopLog) Panicf Uses

func (l NoopLog) Panicf(format string, v ...interface{})

Panicf adds the formatted panic logging function string

func (NoopLog) Warnf Uses

func (l NoopLog) Warnf(format string, v ...interface{})

Warnf adds the formatted warning logging function string

type RPCError Uses

type RPCError struct {
    Type     string `xml:"error-type"`
    Tag      string `xml:"error-tag"`
    Severity string `xml:"error-severity"`
    Path     string `xml:"error-path"`
    Message  string `xml:"error-message"`
    Info     string `xml:",innerxml"`
}

RPCError defines an error reply to a RPC request

func (*RPCError) Error Uses

func (re *RPCError) Error() string

Error generates a string representation of the provided RPC error

type RPCMessage Uses

type RPCMessage struct {
    MessageID string
    Methods   []RPCMethod
}

RPCMessage represents an RPC Message to be sent.

func NewRPCMessage Uses

func NewRPCMessage(methods []RPCMethod) *RPCMessage

NewRPCMessage generates a new RPC Message structure with the provided methods

func (*RPCMessage) MarshalXML Uses

func (m *RPCMessage) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML marshals the NetConf XML data

type RPCMethod Uses

type RPCMethod interface {
    MarshalMethod() string
}

RPCMethod defines the interface for creating an RPC method.

type RPCReply Uses

type RPCReply struct {
    XMLName  xml.Name   `xml:"rpc-reply"`
    Errors   []RPCError `xml:"rpc-error,omitempty"`
    Data     string     `xml:",innerxml"`
    Ok       bool       `xml:",omitempty"`
    RawReply string     `xml:"-"`
}

RPCReply defines a reply to a RPC request

type RawMethod Uses

type RawMethod string

RawMethod defines how a raw text request will be responded to

func MethodGetConfig Uses

func MethodGetConfig(source string) RawMethod

MethodGetConfig files a Netconf get-config source request with the remote host

func MethodLock Uses

func MethodLock(target string) RawMethod

MethodLock files a Netconf lock target request with the remote host

func MethodUnlock Uses

func MethodUnlock(target string) RawMethod

MethodUnlock files a Netconf unlock target request with the remote host

func (RawMethod) MarshalMethod Uses

func (r RawMethod) MarshalMethod() string

MarshalMethod converts the method's output into a string

type ReadWriteCloser Uses

type ReadWriteCloser struct {
    io.Reader
    io.WriteCloser
}

ReadWriteCloser represents a combined IO Reader and WriteCloser

func NewReadWriteCloser Uses

func NewReadWriteCloser(r io.Reader, w io.WriteCloser) *ReadWriteCloser

NewReadWriteCloser creates a new combined IO Reader and Write Closer from the provided objects

type Session Uses

type Session struct {
    Transport          Transport
    SessionID          int
    ServerCapabilities []string
    ErrOnWarning       bool
}

Session defines the necessary components for a Netconf session

func DialSSH Uses

func DialSSH(target string, config *ssh.ClientConfig) (*Session, error)

DialSSH creates a new NETCONF session using a SSH Transport. See TransportSSH.Dial for arguments.

func DialSSHTimeout Uses

func DialSSHTimeout(target string, config *ssh.ClientConfig, timeout time.Duration) (*Session, error)

DialSSHTimeout creates a new NETCONF session using a SSH Transport with timeout. See TransportSSH.Dial for arguments. The timeout value is used for both connection establishment and Read/Write operations.

func DialTelnet Uses

func DialTelnet(target string, username string, password string, vendor VendorIOProc) (*Session, error)

DialTelnet dials and returns the usable telnet session.

func NewSSHSession Uses

func NewSSHSession(conn net.Conn, config *ssh.ClientConfig) (*Session, error)

NewSSHSession creates a new NETCONF session using an existing net.Conn.

func NewSession Uses

func NewSession(t Transport) *Session

NewSession creates a new NetConf session using the provided transport layer.

func (*Session) Close Uses

func (s *Session) Close() error

Close is used to close and end a transport session

func (*Session) Exec Uses

func (s *Session) Exec(methods ...RPCMethod) (*RPCReply, error)

Exec is used to execute an RPC method or methods

type StdLog Uses

type StdLog struct {
    *stdlog.Logger
    // contains filtered or unexported fields
}

StdLog represents the log level and logger for use in logging

func NewStdLog Uses

func NewStdLog(l *stdlog.Logger, level LogLevel) *StdLog

NewStdLog creates a new StdLog instance with the log level and logger provided

func (*StdLog) Debugf Uses

func (l *StdLog) Debugf(format string, v ...interface{})

Debugf adds the formatted debug logging function string

func (*StdLog) Errorf Uses

func (l *StdLog) Errorf(format string, v ...interface{})

Errorf adds the formatted error logging function string

func (*StdLog) Fatalf Uses

func (l *StdLog) Fatalf(format string, v ...interface{})

Fatalf adds the formatted fatal logging function string

func (*StdLog) Infof Uses

func (l *StdLog) Infof(format string, v ...interface{})

Infof adds the formatted information logging function string

func (*StdLog) Panicf Uses

func (l *StdLog) Panicf(format string, v ...interface{})

Panicf adds the formatted panic logging function string

func (*StdLog) Warnf Uses

func (l *StdLog) Warnf(format string, v ...interface{})

Warnf adds the formatted warning logging function string

type Transport Uses

type Transport interface {
    Send([]byte) error
    Receive() ([]byte, error)
    Close() error
    ReceiveHello() (*HelloMessage, error)
    SendHello(*HelloMessage) error
}

Transport interface defines what characterisitics make up a NetConf transport layer object.

type TransportSSH Uses

type TransportSSH struct {
    // contains filtered or unexported fields
}

TransportSSH maintains the information necessary to communicate with the remote device over SSH

func (*TransportSSH) Close Uses

func (t *TransportSSH) Close() error

Close closes an existing SSH session and socket if they exist.

func (*TransportSSH) Dial Uses

func (t *TransportSSH) Dial(target string, config *ssh.ClientConfig) error

Dial connects and establishes SSH sessions

target can be an IP address (e.g.) 172.16.1.1 which utlizes the default NETCONF over SSH port of 830. Target can also specify a port with the following format <host>:<port (e.g 172.16.1.1:22)

config takes a ssh.ClientConfig connection. See documentation for go.crypto/ssh for documenation. There is a helper function SSHConfigPassword thar returns a ssh.ClientConfig for simple username/password authentication

func (*TransportSSH) Receive Uses

func (t *TransportSSH) Receive() ([]byte, error)

func (*TransportSSH) ReceiveHello Uses

func (t *TransportSSH) ReceiveHello() (*HelloMessage, error)

func (*TransportSSH) Send Uses

func (t *TransportSSH) Send(data []byte) error

Sends a well formated netconf rpc message as a slice of bytes adding on the nessisary framining messages.

func (*TransportSSH) SendHello Uses

func (t *TransportSSH) SendHello(hello *HelloMessage) error

func (*TransportSSH) WaitForBytes Uses

func (t *TransportSSH) WaitForBytes(b []byte) ([]byte, error)

func (*TransportSSH) WaitForFunc Uses

func (t *TransportSSH) WaitForFunc(f func([]byte) (int, error)) ([]byte, error)

func (*TransportSSH) WaitForRegexp Uses

func (t *TransportSSH) WaitForRegexp(re *regexp.Regexp) ([]byte, [][]byte, error)

func (*TransportSSH) WaitForString Uses

func (t *TransportSSH) WaitForString(s string) (string, error)

func (*TransportSSH) Writeln Uses

func (t *TransportSSH) Writeln(b []byte) (int, error)

type TransportTelnet Uses

type TransportTelnet struct {
    // contains filtered or unexported fields
}

TransportTelnet is used to define what makes up a Telnet Transport layer for NetConf

func (*TransportTelnet) Dial Uses

func (t *TransportTelnet) Dial(target string, username string, password string, vendor VendorIOProc) error

Dial is used to create a TCP Telnet connection to the remote host returning only an error if it is unable to dial the remote host.

func (*TransportTelnet) Receive Uses

func (t *TransportTelnet) Receive() ([]byte, error)

func (*TransportTelnet) ReceiveHello Uses

func (t *TransportTelnet) ReceiveHello() (*HelloMessage, error)

func (*TransportTelnet) Send Uses

func (t *TransportTelnet) Send(data []byte) error

Sends a well formated netconf rpc message as a slice of bytes adding on the nessisary framining messages.

func (*TransportTelnet) SendHello Uses

func (t *TransportTelnet) SendHello(hello *HelloMessage) error

func (*TransportTelnet) WaitForBytes Uses

func (t *TransportTelnet) WaitForBytes(b []byte) ([]byte, error)

func (*TransportTelnet) WaitForFunc Uses

func (t *TransportTelnet) WaitForFunc(f func([]byte) (int, error)) ([]byte, error)

func (*TransportTelnet) WaitForRegexp Uses

func (t *TransportTelnet) WaitForRegexp(re *regexp.Regexp) ([]byte, [][]byte, error)

func (*TransportTelnet) WaitForString Uses

func (t *TransportTelnet) WaitForString(s string) (string, error)

func (*TransportTelnet) Writeln Uses

func (t *TransportTelnet) Writeln(b []byte) (int, error)

type VendorIOProc Uses

type VendorIOProc interface {
    Login(*TransportTelnet, string, string) error
    StartNetconf(*TransportTelnet) error
}

VendorIOProc is the interface used when establishing a telnet Netconf session

Directories

PathSynopsis
jnpr

Package netconf imports 17 packages (graph) and is imported by 12 packages. Updated 2017-05-13. Refresh now. Tools for package owners.