Documentation
¶
Overview ¶
MIT License
Copyright (c) 2020 xzx.weiliang ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
MIT License
Copyright (c) 2020 xzx.weiliang ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
MIT License
Copyright (c) 2020 xzx.weiliang ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
MIT License
Copyright (c) 2020 xzx.weiliang ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
MIT License
Copyright (c) 2020 xzx.weiliang ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Index ¶
- func RemoteRun(item RemoteRunItem) command.RunErr
- func SftpConnect(user, password, host string, port string, timeout time.Duration) (sftpClient *sftp.Client, err error)
- type DoRequestItem
- type ExecutorExternal
- type ExecutorInternal
- type InternelServersSlice
- type Item
- type RemoteRunItem
- type ServerExternal
- type ServerInternal
- type ServerListExternal
- type ServerListInternal
- type ShellResult
- func GetResult(item RemoteRunItem) ([]ShellResult, error)
- func LocalRun(shell string, logger *logrus.Logger) ShellResult
- func RunOnNode(shell string, server ServerInternal, timeout time.Duration, ...) (re ShellResult)
- func RunOnNodeWithChangeToRoot(shell string, server ServerInternal, timeout time.Duration, ...) (re ShellResult)
- type ShellResultSlice
- type WindowsErr
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DoRequestItem ¶
type DoRequestItem struct { S ServerInternal R RemoteRunItem Mock bool }
type ExecutorExternal ¶
type ExecutorExternal struct { Servers []ServerExternal `yaml:"server"` Excludes []string `yaml:"excludes"` Script string `yaml:"script"` logrus.Logger }
ExecutorExternal 执行器序列化对象
type ExecutorInternal ¶
type ExecutorInternal struct { Servers []ServerInternal Script string Logger *logrus.Logger OutPutRealTime bool RunShellFunc func(shell string, server ServerInternal, timeout time.Duration, logger *logrus.Logger) ShellResult }
ExecutorInternal 执行器内部对象
func ParseExecutor ¶
func ParseExecutor(b []byte, logger *logrus.Logger) (ExecutorInternal, error)
ParseExecutor 执行器反序列化
func (ExecutorInternal) ParallelRun ¶
func (executor ExecutorInternal) ParallelRun(timeout time.Duration) chan ShellResult
ParallelRun 并发执行 todo: 添加缓冲队列,避免过多goroutine
type InternelServersSlice ¶
type InternelServersSlice []ServerInternal
InternelServersSlice 带有排序的server列表
func (InternelServersSlice) Len ¶
func (servers InternelServersSlice) Len() int
func (InternelServersSlice) Less ¶
func (servers InternelServersSlice) Less(i, j int) bool
func (InternelServersSlice) Swap ¶
func (servers InternelServersSlice) Swap(i, j int)
type Item ¶
type Item struct { Server ServerInternal Cmd string Logger *logrus.Logger OutputRealTime bool }
Item 执行run指令的对象
type RemoteRunItem ¶
type ServerExternal ¶
type ServerExternal struct { Host interface{} `yaml:"host"` Port string `yaml:"port"` Username string `yaml:"username"` Password string `yaml:"password"` RootPassword string `yaml:"rootPassword"` PrivateKeyPath string `yaml:"privateKeyPath"` }
ServerExternal server序列化对象
type ServerInternal ¶
type ServerInternal struct { Host string Port string UserName string // ssh user's name -> root, e.g. Password string RootPassword string PrivateKeyPath string }
ServerInternal server内部对象
func ParseServerList ¶
func ParseServerList(b []byte, logger *logrus.Logger) ([]ServerInternal, error)
ParseServerList ServerList反序列化
func (ServerInternal) ReturnRunResult ¶
func (server ServerInternal) ReturnRunResult(item RemoteRunItem) ShellResult
ReturnRunResult 获取执行结果
func (ServerInternal) SSHConnect ¶
type ServerListExternal ¶
type ServerListExternal struct { Servers []ServerExternal `yaml:"server"` Excludes []string `yaml:"excludes"` }
ServerListExternal server列表序列化对象
type ServerListInternal ¶
type ServerListInternal struct { Servers []ServerInternal Excludes []string }
ServerListInternal server列表内部对象
type ShellResult ¶
type ShellResult struct { Host string `table:"主机地址"` Cmd string `table:"执行语句"` Code int `table:"退出码"` Status string `table:"执行状态"` StdOut string `table:"执行结果"` Output string `table:"标准输出"` StdErrMsg string Err error }
ShellResult shell执行结果
func RunOnNode ¶
func RunOnNode(shell string, server ServerInternal, timeout time.Duration, logger *logrus.Logger) (re ShellResult)
func RunOnNodeWithChangeToRoot ¶
func RunOnNodeWithChangeToRoot(shell string, server ServerInternal, timeout time.Duration, logger *logrus.Logger) (re ShellResult)
type ShellResultSlice ¶
type ShellResultSlice []ShellResult
ShellResultSlice shell执行结果切片
func (ShellResultSlice) Len ¶
func (re ShellResultSlice) Len() int
func (ShellResultSlice) Less ¶
func (re ShellResultSlice) Less(i, j int) bool
func (ShellResultSlice) Swap ¶
func (re ShellResultSlice) Swap(i, j int)
type WindowsErr ¶
type WindowsErr struct {
Errors string
}