本文整理汇总了Golang中github.com/coreos/mantle/platform.Machine.SSHClient方法的典型用法代码示例。如果您正苦于以下问题:Golang Machine.SSHClient方法的具体用法?Golang Machine.SSHClient怎么用?Golang Machine.SSHClient使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/coreos/mantle/platform.Machine
的用法示例。
在下文中一共展示了Machine.SSHClient方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: runInstallScript
// Run and configure the coreos-kubernetes generic install scripts.
func runInstallScript(m platform.Machine, script string, options map[string]string) error {
// use built-in kubelet-wrapper if on-disk file does not exist
// on-disk wrapper should exist as of release 960.0.0
if _, err := m.SSH("sudo stat /usr/lib/coreos/kubelet-wrapper"); err != nil {
plog.Errorf("on-disk kubelet-wrapper not found, using test's built-in version")
options["KUBELET_PATH"] = "/home/core/rktkube.sh"
}
var buffer = new(bytes.Buffer)
tmpl, err := template.New("installScript").Parse(script)
if err != nil {
return err
}
if err := tmpl.Execute(buffer, options); err != nil {
return err
}
if err := platform.InstallFile(buffer, m, "/home/core/install.sh"); err != nil {
return err
}
// only used if kubelet-wrapper doesn't exist
in := strings.NewReader(rktkube)
if err := platform.InstallFile(in, m, "/home/core/rktkube.sh"); err != nil {
return err
}
// use client to collect stderr
client, err := m.SSHClient()
if err != nil {
return err
}
defer client.Close()
session, err := client.NewSession()
if err != nil {
return err
}
defer session.Close()
stderr := bytes.NewBuffer(nil)
session.Stderr = stderr
err = session.Start("sudo /home/core/install.sh")
if err != nil {
return err
}
if err := session.Wait(); err != nil {
return fmt.Errorf("%s", stderr)
}
return nil
}