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