vty

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2017 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package vty provides the ability to execute remote commands (e.g. CLI) on an existing remote connection (any transport that implements the Connector interface). To execute remote commands, a new configuration session needs to be opened:

sess, err := NewSession(conn)
// handle error!
defer sess.Close()

Then remote commands can be executed using the ExecCMD method of the session:

output, err := sess.ExecCMD("show ver")
// handle error!

Each command is a string that will be sent as the input via the open connection on a separate line. After sending the command (or multiple commands in one ExecCMD call), all the output will be read and returned, until the shell prompt is read from the connection or until the timeout expires.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connector

type Connector interface {
	// GetVTY returns the interface to VTY for reading and writing.
	GetVTY() (io.Reader, io.Writer, error)

	// Close closes the VTY connection.
	Close()
}

Connector provides the connection to VTY via various transports.

type Session

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

Session is a VTY session handle.

func NewSession

func NewSession(conn Connector) (*Session, error)

NewSession returns a new VTY session opened on provided connector. The session is supposed to be closed via Close().

func (*Session) Close

func (s *Session) Close()

Close closes the VTY session.

func (*Session) ExecCMD

func (s *Session) ExecCMD(cmds ...string) (response string, err error)

ExecCMD executes provided commands on the VTY session.

Directories

Path Synopsis
Package ssh provides the API for connecting to a SSH node.
Package ssh provides the API for connecting to a SSH node.

Jump to

Keyboard shortcuts

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