本文整理汇总了Golang中github.com/grrtrr/clcv2.CLIClient.GetServerIPs方法的典型用法代码示例。如果您正苦于以下问题:Golang CLIClient.GetServerIPs方法的具体用法?Golang CLIClient.GetServerIPs怎么用?Golang CLIClient.GetServerIPs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/grrtrr/clcv2.CLIClient
的用法示例。
在下文中一共展示了CLIClient.GetServerIPs方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: printGroupIPs
// Print group hierarchy starting at @g, using initial indentation @indent.
func printGroupIPs(client *clcv2.CLIClient, root *clcv2.Group) {
var serverPrinter = func(g *clcv2.Group, arg interface{}) interface{} {
var indent = arg.(string)
if g.Type == "default" {
fmt.Printf("%s%s/\n", indent, g.Name)
} else {
fmt.Printf("%s[%s]/\n", indent, g.Name)
}
for _, l := range g.Links {
if l.Rel == "server" {
ips, err := client.GetServerIPs(l.Id)
if err != nil {
exit.Fatalf("failed to get IPs of %q in %s: %s", l.Id, g.Name, err)
}
servLine := fmt.Sprintf("%s%s", indent+" ", l.Id)
fmt.Printf("%-50s %s\n", servLine, strings.Join(ips, ", "))
}
}
return indent + " "
}
clcv2.VisitGroupHierarchy(root, serverPrinter, "")
}
示例2: printServerIP
// Print server IP(s)
// @client: authenticated CLCv2 Client
// @servname: server name
func printServerIP(client *clcv2.CLIClient, servname string) {
ips, err := client.GetServerIPs(servname)
if err != nil {
exit.Fatalf("failed get server %q IPs: %s", servname, err)
}
fmt.Printf("%-20s %s\n", servname+":", strings.Join(ips, ", "))
}