netconf

package
v0.0.0-...-65f62e4 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2014 License: BSD-2-Clause-Views Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SSH_DEFAULT_PORT      = 830
	SSH_NETCONF_SUBSYSTEM = "netconf"
)
View Source
const (
	TELNET_DEFAULT_PORT = 23
	TELNET_TIMEOUT      = 10 * time.Second
)
View Source
const (
	MSG_SEPERATOR = "]]>]]>"
)

Variables

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

Functions

func SSHConfigPassword

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

SSHConfigPassword is a convience function that takes a username and password and returns a new ssh.ClientConfig setup to pass that username and password.

func SetLog

func SetLog(l Logger)

Types

type HelloMessage

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

type LogLevel

type LogLevel int
const (
	LogError LogLevel = iota
	LogWarn
	LogInfo
	LogDebug
)

type Logger

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

type NoopLog

type NoopLog struct{}

func (NoopLog) Debugf

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

func (NoopLog) Errorf

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

func (NoopLog) Fatalf

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

func (NoopLog) Infof

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

func (NoopLog) Panicf

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

func (NoopLog) Warnf

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

type RPCError

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"`
}

func (*RPCError) Error

func (re *RPCError) Error() string

type RPCMessage

type RPCMessage struct {
	MessageId string
	Methods   []RPCMethod
}

func NewRpcMessage

func NewRpcMessage(methods []RPCMethod) *RPCMessage

func (*RPCMessage) MarshalXML

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

type RPCMethod

type RPCMethod interface {
	MarshalMethod() string
}

type RPCReply

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:"-"`
}

type RawMethod

type RawMethod string

func MethodGetConfig

func MethodGetConfig(source string) RawMethod

func MethodLock

func MethodLock(target string) RawMethod

func MethodUnlock

func MethodUnlock(target string) RawMethod

func (RawMethod) MarshalMethod

func (r RawMethod) MarshalMethod() string

type ReadWriteCloser

type ReadWriteCloser struct {
	io.Reader
	io.WriteCloser
}

func NewReadWriteCloser

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

type Session

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

func DialSSH

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

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

func DialTelnet

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

func NewSSHSession

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

Create a new NETCONF session using an existing net.Conn.

func NewSession

func NewSession(t Transport) *Session

func (*Session) Close

func (s *Session) Close() error

func (*Session) Exec

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

type StdLog

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

func NewStdLog

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

func (*StdLog) Debugf

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

func (*StdLog) Errorf

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

func (*StdLog) Fatalf

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

func (*StdLog) Infof

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

func (*StdLog) Panicf

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

func (*StdLog) Warnf

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

type Transport

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

type TransportSSH

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

func (*TransportSSH) Close

func (t *TransportSSH) Close() error

func (*TransportSSH) Dial

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

Dials and establishes an 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

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

func (*TransportSSH) ReceiveHello

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

func (*TransportSSH) Send

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

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

func (*TransportSSH) WaitForBytes

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

func (*TransportSSH) WaitForFunc

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

func (*TransportSSH) WaitForRegexp

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

func (*TransportSSH) WaitForString

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

func (*TransportSSH) Writeln

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

type TransportTelnet

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

func (*TransportTelnet) Dial

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

func (*TransportTelnet) Receive

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

func (*TransportTelnet) ReceiveHello

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

func (*TransportTelnet) Send

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

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

func (*TransportTelnet) WaitForBytes

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

func (*TransportTelnet) WaitForFunc

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

func (*TransportTelnet) WaitForRegexp

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

func (*TransportTelnet) WaitForString

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

func (*TransportTelnet) Writeln

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

type VendorIOProc

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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