本文整理汇总了Golang中github.com/juju/juju/apiserver/params.StatusResult类的典型用法代码示例。如果您正苦于以下问题:Golang StatusResult类的具体用法?Golang StatusResult怎么用?Golang StatusResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了StatusResult类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: MachinesWithTransientErrors
// MachinesWithTransientErrors returns status data for machines with provisioning
// errors which are transient.
func (p *ProvisionerAPI) MachinesWithTransientErrors() (params.StatusResults, error) {
results := params.StatusResults{}
canAccessFunc, err := p.getAuthFunc()
if err != nil {
return results, err
}
// TODO (wallyworld) - add state.State API for more efficient machines query
machines, err := p.st.AllMachines()
if err != nil {
return results, err
}
for _, machine := range machines {
if !canAccessFunc(machine.Tag()) {
continue
}
if _, provisionedErr := machine.InstanceId(); provisionedErr == nil {
// Machine may have been provisioned but machiner hasn't set the
// status to Started yet.
continue
}
result := params.StatusResult{}
if result.Status, result.Info, result.Data, err = machine.Status(); err != nil {
continue
}
if result.Status != params.StatusError {
continue
}
// Transient errors are marked as such in the status data.
if transient, ok := result.Data["transient"].(bool); !ok || !transient {
continue
}
result.Id = machine.Id()
result.Life = params.Life(machine.Life().String())
results.Results = append(results.Results, result)
}
return results, nil
}
示例2: getEntityStatus
func (s *StatusGetter) getEntityStatus(tag names.Tag) params.StatusResult {
var result params.StatusResult
entity, err := s.st.FindEntity(tag)
if err != nil {
result.Error = ServerError(err)
return result
}
switch getter := entity.(type) {
case status.StatusGetter:
statusInfo, err := getter.Status()
result.Status = statusInfo.Status
result.Info = statusInfo.Message
result.Data = statusInfo.Data
result.Since = statusInfo.Since
result.Error = ServerError(err)
default:
result.Error = ServerError(NotSupportedError(tag, fmt.Sprintf("getting status, %T", getter)))
}
return result
}