tx

package
v0.0.22 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DebugCount = 0
View Source
var KindMap = map[string]KindDef{
	"vr-sros": {
		Platform: "nokia_sros",
		Comment:  "#",
		Commit:   []string{"validate", "compare / ", "commit", "discard /"},
		Compare:  []string{"validate", "compare /", "discard /"},
	},
	"srl": {
		Platform: "nokia_srl",
		Comment:  "#",
		Commit:   []string{"commit validate", "diff ", "commit now"},
		Compare:  []string{"commit validate", "diff", "discard now"},
	},
	"ceos": {
		Platform: "arista_eos",
	},
	"crpd": {
		Platform: "juniper_junos",
	},
	"vr-csr": {
		Platform: "cisco_iosxe",
	},
	"vr-n9kv": {
		Platform: "cisco_nxos",
	},
	"vr-nxos": {
		Platform: "cisco_nxos",
	},
	"vr-pan": {
		Platform: "paloalto_panos",
	},
	"vr-veos": {
		Platform: "arista_eos",
	},
	"vr-vmx": {
		Platform: "juniper_junos",
	},
	"vr-vqfx": {
		Platform: "juniper_junos",
	},
	"vr-xrv": {
		Platform: "cisco_iosxr",
	},
	"vr-xrv9k": {
		Platform: "cisco_iosxr",
	},
}

Functions

func KindMapOverride added in v0.0.8

func KindMapOverride(kindmap map[string]KindDef)

Override KindMap with values from settings

Types

type Action

type Action int
const (
	AUnknown Action = iota
	ASend
	ACompare
	ACommit
)

func StringToAction added in v0.0.3

func StringToAction(str string) (Action, error)

Parse a string and return an action

func (Action) Char added in v0.0.12

func (c Action) Char() string

func (Action) String

func (c Action) String() string

type KindDef

type KindDef struct {
	Platform string   `yaml:"platform"` // the scrapligo SSH platform definition
	Comment  string   `yaml:"comment"`  // character to indicate line is a comment
	Commit   []string `yaml:"commit"`   // commands to commit and compare sessions
	Compare  []string `yaml:"compare"`  // commands  compare sessions
}

type Response

type Response struct {
	Node     string    `json:"node"`
	Source   string    `json:"source"`
	Prompt   string    `json:"prompt"`
	Command  string    `json:"command"`
	Response string    `json:"response"`
	Level    log.Level `json:"level"`
}

The SSH reply, executed command and the prompt

func (*Response) Debug

func (r *Response) Debug(message string)

func (*Response) Log

func (r *Response) Log(level ...log.Level) *Response

func (*Response) Slog

func (r *Response) Slog() string

The Slog will include the entire Response

Each field will be prefixed by a character.
# - command sent
| - result received
? - prompt part of the result

type SSHTx

type SSHTx struct {
	TargetNode *types.NodeConfig
	Vars       map[string]interface{}
	Config     []configLines
}

func (*SSHTx) Prepare

func (st *SSHTx) Prepare(c *config.NodeConfig) (int, error)

Prepare Config to be sent (from rendered templates in config.NodeConfig) Split a rendered template into lines, remove whitespace and comments. Returns an array of configLines, one entry per template

func (*SSHTx) Send

func (st *SSHTx) Send(action Action) ([]*Response, error)

type Tx

type Tx interface {
	Prepare(c *config.NodeConfig) (int, error)
	Send(action Action) ([]*Response, error)
}

Tx Interface to prepare config and to send it

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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