本文整理汇总了Golang中github.com/coreos/fleet/registry.Registry.GetJobState方法的典型用法代码示例。如果您正苦于以下问题:Golang Registry.GetJobState方法的具体用法?Golang Registry.GetJobState怎么用?Golang Registry.GetJobState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/coreos/fleet/registry.Registry
的用法示例。
在下文中一共展示了Registry.GetJobState方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: findAddressInRunningUnits
func findAddressInRunningUnits(r *registry.Registry, lookup string) (string, bool) {
js := r.GetJobState(lookup)
if js == nil {
return "", false
}
return fmt.Sprintf("%s:22", js.MachineState.PublicIP), true
}
示例2: printUnitStatus
func printUnitStatus(c *cli.Context, r *registry.Registry, jobName string) {
js := r.GetJobState(jobName)
if js == nil {
fmt.Printf("%s does not appear to be running\n", jobName)
syscall.Exit(1)
}
addr := fmt.Sprintf("%s:22", js.MachineState.PublicIP)
var err error
var sshClient *gossh.ClientConn
if tun := getTunnelFlag(c); tun != "" {
sshClient, err = ssh.NewTunnelledSSHClient("core", tun, addr)
} else {
sshClient, err = ssh.NewSSHClient("core", addr)
}
if err != nil {
log.Fatalf("Unable to establish SSH connection: %v", err)
}
defer sshClient.Close()
cmd := fmt.Sprintf("systemctl status -l %s", jobName)
stdout, err := ssh.Execute(sshClient, cmd)
if err != nil {
log.Fatalf("Unable to execute command over SSH: %s", err.Error())
}
for true {
bytes, prefix, err := stdout.ReadLine()
if err != nil {
break
}
print(string(bytes))
if !prefix {
print("\n")
}
}
}