Documentation ¶
Index ¶
- Constants
- func CheckAndSplitCommandArgs(cmdArgs string) (cmdList []string)
- func Cmp(a, b net.IP) int
- func ColorPrintWithTerminalStyle(logLevel string, textBefore interface{}, colorText string, ...)
- func DiffStringSlices(slice1 []string, slice2 []string) []string
- func FileExists(path string) bool
- func FooterColorPrintStyleWithoutTotalHostInfo(taskName string)
- func FooterColorPrintWithStyle(taskName, totalHostsInfo string)
- func FormatResultLogWithBasicStyle(k int, sshResult SSHResult)
- func HeaderColorPrintWithStyle(taskName string)
- func K8sVersionConvertToInt(version string) int
- func Md5SumLocalFile(fileName string) string
- func NextIP(ip net.IP) net.IP
- func ParseIPSegment(ips []string) []string
- func SFTPCommandSessionExecMain(taskName string, ssHost []string, ...)
- func SFTPCopy(...)
- func SessionCommandExec(cobraCmd string, taskName string, ssHost []string, cmdType string, ...)
- func StringSliceCountValues(args []string) (Status bool, AllRepeatValue []string, MaxCount int, MaxValue []string)
- func StringSliceRemoveRepeat(stringSliceList []string) []string
- func StringTwoSliceRepeatElem(a, b []string) []string
- type CommandHostInfo
- type HostRequired
- type LogicSFTPClient
- type LogicSSHClient
- type LogicSSHSession
- type Pool
- type SSHResult
- type SSHResultLog
- func (sl *SSHResultLog) FormatResultLogWithJSONStyle()
- func (sl *SSHResultLog) FormatResultLogWithSimpleStyle()
- func (sl *SSHResultLog) FormatResultLogWithStyle(taskName string)
- func (sl *SSHResultLog) InspectCommandSystemEnvironmentResultCheck(taskName string)
- func (sl *SSHResultLog) ResultCheckRemoteHostFileExist() (hostExist, hostNoExist []string)
- func (sl *SSHResultLog) ResultCheckRemoteHostFileMd5(md5Sum string) (hostExist []string)
- func (sl *SSHResultLog) ResultOutputCgroupDriver() (cgroupDriver string)
- func (sl *SSHResultLog) ResultOutputCheckAndProcessExit(taskName string)
- func (sl *SSHResultLog) ResultOutputKubeadmJoinMasterCert() (certificateKey string)
- func (sl *SSHResultLog) ResultOutputKubeadmJoinParams() (joinToken, tokenCaCertHash string)
- type ScriptHostInfo
Constants ¶
const ( // CommandFailed show ssh command execute Failed CommandFailed = "Failed" // CommandSuccess show ssh command execute Success CommandSuccess = "Success" // CmdCommand show the according to params cmdType value,exec ssh command CmdCommand = "command" // CmdScript show the according to params cmdType value,exec ssh command CmdScript = "script" // Cobra* show cobra subcommand name CobraInspect = "inspect" )
Variables ¶
This section is empty.
Functions ¶
func CheckAndSplitCommandArgs ¶
CheckAndSplitCommandArgs function,check one and more command params whether flagFormat correct,for example: hostname;date;ip addr
func ColorPrintWithTerminalStyle ¶
func ColorPrintWithTerminalStyle(logLevel string, textBefore interface{}, colorText string, textAfter ...interface{})
ColorPrintWithTerminalStyle function, console output color control, compatible with Windows & Linux
func DiffStringSlices ¶
DiffStringSlices function,Get the different items between two slices diffStringSlices function,Get difference items between two slices
func FileExists ¶
determine if the given path file / folder exists
func FooterColorPrintStyleWithoutTotalHostInfo ¶
func FooterColorPrintStyleWithoutTotalHostInfo(taskName string)
func FooterColorPrintWithStyle ¶
func FooterColorPrintWithStyle(taskName, totalHostsInfo string)
func HeaderColorPrintWithStyle ¶
func HeaderColorPrintWithStyle(taskName string)
func K8sVersionConvertToInt ¶
Kubernentes version convert to int
func Md5SumLocalFile ¶
func ParseIPSegment ¶
ParseIPSegment,for example IP 192.168.0.2-192.168.0.6
func SFTPCommandSessionExecMain ¶
func SFTPCommandSessionExecMain(taskName string, ssHost []string, sshPort, sshUser, sshPassword, privateKeyFileName, sshKeyPassword string, localFilePath, remoteFilePath string)
SFTPCommandSessionExecMain function
func SFTPCopy ¶
func SFTPCopy(sshHost, sshPort, sshUser, sshPassword, privateKeyFileName, sshKeyPassword string, localFilePath, remoteFilePath string)
SFTPCopy function,the local file is delivered to other hosts at the same path
func SessionCommandExec ¶
func SessionCommandExec(cobraCmd string, taskName string, ssHost []string, cmdType string, sshUser, sshPort, sshPassword, privateKeyFileName, sshKeyPassword, command, scriptFileName, scriptArgs string)
SessionCommandExec function
func StringSliceCountValues ¶
func StringSliceCountValues(args []string) (Status bool, AllRepeatValue []string, MaxCount int, MaxValue []string)
StringSliceCountValues function,find out how many times there are duplicate elements in an array and their values, If the number of slice elements is higher than 1, the array have duplicate elements
func StringSliceRemoveRepeat ¶
StringSliceRemoveRepeat is used for single string slice remove repeat
func StringTwoSliceRepeatElem ¶
StringTwoSliceRepeatElem function,find two slice repeat elem
Types ¶
type CommandHostInfo ¶
type CommandHostInfo struct { Host string SSHUser string SSHPort string SSHPassword string PrivateKeyFileName string SSHKeyPassword string Command string }
CommandHostInfo struct
func CommandSSHResult ¶
func CommandSSHResult(sshHost, sshUser, sshPort, sshPassword, privateKeyFileName, sshKeyPassword, command string) *CommandHostInfo
CommandSSHResult function
func (*CommandHostInfo) CommandSessionExec ¶
func (ch *CommandHostInfo) CommandSessionExec(chCmd chan SSHResult)
CommandSessionExec function
type LogicSFTPClient ¶
LogicSFTPClient struct
func (*LogicSFTPClient) CloseSFTPClient ¶
func (l *LogicSFTPClient) CloseSFTPClient()
CloseSSHClient function
type LogicSSHClient ¶
LogicSSHClient struct
func (*LogicSSHClient) CloseSSHClient ¶
func (l *LogicSSHClient) CloseSSHClient()
CloseSSHClient function
type LogicSSHSession ¶
type LogicSSHSession struct {
// contains filtered or unexported fields
}
LogicSSHSession struct
func (*LogicSSHSession) CloseSSHSession ¶
func (s *LogicSSHSession) CloseSSHSession()
CloseSSHSession function
type Pool ¶
type Pool struct { Wg *sync.WaitGroup Size int // pool size // contains filtered or unexported fields }
Pool struct https://www.golangtc.com/t/559e97d6b09ecc22f6000053 control the number of Goroutine concurrency by waitGroup + channel
func (*Pool) AvailableCredential ¶
AvailableCredential function
func (*Pool) TryAcquire ¶
TryAcquire function,try acquire credential
type SSHResult ¶
type SSHResult struct { Host string User string Port string Command string Status string Result string StartTime string EndTime string CostTime string }
SSHResult struct,show single machine run result
type SSHResultLog ¶
type SSHResultLog struct { Task string SuccessHosts []SSHResult ErrorHosts []SSHResult TotalHostsInfo string }
SSHResultLog struct
func SSHCommandSessionExecMain ¶
func SSHCommandSessionExecMain(taskName string, ssHost []string, cmdType string, sshUser, sshPort, sshPassword, privateKeyFileName, sshKeyPassword, command string, scriptFileName, scriptArgs string) *SSHResultLog
SSHCommandSessionExecMain function
func (*SSHResultLog) FormatResultLogWithJSONStyle ¶
func (sl *SSHResultLog) FormatResultLogWithJSONStyle()
func (*SSHResultLog) FormatResultLogWithSimpleStyle ¶
func (sl *SSHResultLog) FormatResultLogWithSimpleStyle()
FormatResultLogWithSimpleStyle function
func (*SSHResultLog) FormatResultLogWithStyle ¶
func (sl *SSHResultLog) FormatResultLogWithStyle(taskName string)
FormatResultLogWithStyle function
func (*SSHResultLog) InspectCommandSystemEnvironmentResultCheck ¶
func (sl *SSHResultLog) InspectCommandSystemEnvironmentResultCheck(taskName string)
InspectCommandSystemEnvironmentResultCheck function
func (*SSHResultLog) ResultCheckRemoteHostFileExist ¶
func (sl *SSHResultLog) ResultCheckRemoteHostFileExist() (hostExist, hostNoExist []string)
Host file check, output array with or without host file
func (*SSHResultLog) ResultCheckRemoteHostFileMd5 ¶
func (sl *SSHResultLog) ResultCheckRemoteHostFileMd5(md5Sum string) (hostExist []string)
func (*SSHResultLog) ResultOutputCgroupDriver ¶
func (sl *SSHResultLog) ResultOutputCgroupDriver() (cgroupDriver string)
func (*SSHResultLog) ResultOutputCheckAndProcessExit ¶
func (sl *SSHResultLog) ResultOutputCheckAndProcessExit(taskName string)
ResultOutputCheckAndProcessExit function,mainly used for ssh session command run,check ssh result whether exist error host record.if exist,process exit,otherwise continue run other command.
func (*SSHResultLog) ResultOutputKubeadmJoinMasterCert ¶
func (sl *SSHResultLog) ResultOutputKubeadmJoinMasterCert() (certificateKey string)
func (*SSHResultLog) ResultOutputKubeadmJoinParams ¶
func (sl *SSHResultLog) ResultOutputKubeadmJoinParams() (joinToken, tokenCaCertHash string)
decode master0 output to join token hash and key
type ScriptHostInfo ¶
type ScriptHostInfo struct { Host string SSHUser string SSHPort string SSHPassword string PrivateKeyFileName string SSHKeyPassword string ScriptFileName string ScriptArgs string }
ScriptHostInfo struct
func ScriptSSHResult ¶
func ScriptSSHResult(host, sshUser, sshPort, sshPassword, privateKeyFileName, sshKeyPassword, scriptFileName, scriptArgs string) *ScriptHostInfo
ScriptSSHResult function
func (*ScriptHostInfo) ScriptSessionExec ¶
func (sh *ScriptHostInfo) ScriptSessionExec(chScript chan SSHResult)