本文整理汇总了Golang中github.com/evergreen-ci/evergreen/model/host.Host.SetDNSName方法的典型用法代码示例。如果您正苦于以下问题:Golang Host.SetDNSName方法的具体用法?Golang Host.SetDNSName怎么用?Golang Host.SetDNSName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/evergreen-ci/evergreen/model/host.Host
的用法示例。
在下文中一共展示了Host.SetDNSName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: IsHostReady
// IsHostReady returns whether or not the specified host is ready for its setup script
// to be run.
func (init *HostInit) IsHostReady(host *host.Host) (bool, error) {
// fetch the appropriate cloud provider for the host
cloudMgr, err := providers.GetCloudManager(host.Distro.Provider, init.Settings)
if err != nil {
return false,
fmt.Errorf("failed to get cloud manager for provider %v: %v", host.Distro.Provider, err)
}
// ask for the instance's status
hostStatus, err := cloudMgr.GetInstanceStatus(host)
if err != nil {
return false, fmt.Errorf("error checking instance status of host %v: %v", host.Id, err)
}
// if the host isn't up yet, we can't do anything
if hostStatus != cloud.StatusRunning {
return false, nil
}
// set the host's dns name, if it is not set
if host.Host == "" {
// get the DNS name for the host
hostDNS, err := cloudMgr.GetDNSName(host)
if err != nil {
return false, fmt.Errorf("error checking DNS name for host %v: %v", host.Id, err)
}
// sanity check for the host DNS name
if hostDNS == "" {
return false, fmt.Errorf("instance %v is running but not returning a DNS name",
host.Id)
}
// update the host's DNS name
if err := host.SetDNSName(hostDNS); err != nil {
return false, fmt.Errorf("error setting DNS name for host %v: %v", host.Id, err)
}
}
// check if the host is reachable via SSH
cloudHost, err := providers.GetCloudHost(host, init.Settings)
if err != nil {
return false, fmt.Errorf("failed to get cloud host for %v: %v", host.Id, err)
}
reachable, err := cloudHost.IsSSHReachable()
if err != nil {
return false, fmt.Errorf("error checking if host %v is reachable: %v", host.Id, err)
}
// at this point, we can run the setup if the host is reachable
return reachable, nil
}