rSwitch

package module
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: May 12, 2021 License: MIT Imports: 10 Imported by: 0

README

rf-go-ssh

基于go语言的交换机ssh工具。 (huawei-switch)

version 0.1.0

Switch数据结构

Switch数据结构主要存放连接交换机需要使用的相关配置、会话、日志文件。

type Switch struct{
ip          string // 设备IP地址
port        string // 交换机端口
username    string // 登录设备用户名
password    string   // 登录设备密码
cmds        []string // 执行命令
session     *ssh.Session // 设备连接会话
inChan      chan string  // 输入通道
outChan     chan string  // 输出通道
lastUseTime time.Time    // 连接时间
OutLog      string       // 输出交互内容
Logger      *log.Logger // 日志记录
}

NewSwitchConnect()

创建Switch结构体,初始化ssh连接。配置回显不分页。返回类型:Switch

func NewSwitchConnect(ip, port, username, password string, )

初始化Switch,创建与交换机的连接


Switch.RunCommands(cmds ...string) (string, []string, error)

初始化

相关开源包

uuid logrus ssh

Documentation

Index

Constants

This section is empty.

Variables

Wg 定义一个同步等待组,用于多线程执行命令

View Source
var (
	WorkMode = log.InfoLevel
)

Functions

func NewGoSwitchRunCommands

func NewGoSwitchRunCommands(switchInfo map[string]string, cmds ...string) ([]string, error)

NewGoSwitchRunCommands 创建并发连接会话,并执行命令

Types

type Switch

type Switch struct {
	OutLog string      // 输出交互内容
	Logger *log.Logger // 日志记录
	// contains filtered or unexported fields
}

func NewSwitchConnect

func NewSwitchConnect(ip, port, username, password string) (*Switch, error)

NewSwitchConnect 创建新会话

func (*Switch) RunCommands

func (sw *Switch) RunCommands(cmds ...string) (string, []string, error)

RunCommands 批量下发命令

Jump to

Keyboard shortcuts

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