本文整理汇总了Golang中github.com/zenoss/serviced/dao.Host.PoolId方法的典型用法代码示例。如果您正苦于以下问题:Golang Host.PoolId方法的具体用法?Golang Host.PoolId怎么用?Golang Host.PoolId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/zenoss/serviced/dao.Host
的用法示例。
在下文中一共展示了Host.PoolId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: RestAddHost
func RestAddHost(w *rest.ResponseWriter, r *rest.Request, client *serviced.ControlClient) {
var payload dao.Host
var hostId string
err := r.DecodeJsonPayload(&payload)
if err != nil {
glog.V(1).Infof("Could not decode host payload: %v", err)
RestBadRequest(w)
return
}
// Save the pool ID and IP address for later. GetInfo wipes these
pool := payload.PoolId
ipAddr := payload.IpAddr
remoteClient, err := serviced.NewAgentClient(payload.IpAddr)
if err != nil {
glog.Errorf("Could not create connection to host %s: %v", payload.IpAddr, err)
RestServerError(w)
return
}
err = remoteClient.GetInfo(0, &payload)
if err != nil {
glog.Errorf("Unable to get remote host info: %v", err)
RestBadRequest(w)
return
}
// Reset the pool ID and IP address
payload.PoolId = pool
parts := strings.Split(ipAddr, ":")
payload.IpAddr = parts[0]
err = client.AddHost(payload, &hostId)
if err != nil {
glog.Errorf("Unable to add host: %v", err)
RestServerError(w)
return
}
glog.V(0).Info("Added host ", hostId)
w.WriteJson(&SimpleResponse{"Added host", hostLinks(hostId)})
}