本文整理匯總了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")
}
}
}