本文整理汇总了Golang中github.com/juju/juju/apiserver/params.StatusResult.Data方法的典型用法代码示例。如果您正苦于以下问题:Golang StatusResult.Data方法的具体用法?Golang StatusResult.Data怎么用?Golang StatusResult.Data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/juju/juju/apiserver/params.StatusResult
的用法示例。
在下文中一共展示了StatusResult.Data方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: 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
}
示例2: MachinesWithTransientErrors
// MachinesWithTransientErrors returns status data for machines with provisioning
// errors which are transient.
func (p *ProvisionerAPI) MachinesWithTransientErrors() (params.StatusResults, error) {
var 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
}
var result params.StatusResult
statusInfo, err := machine.Status()
if err != nil {
continue
}
result.Status = statusInfo.Status.String()
result.Info = statusInfo.Message
result.Data = statusInfo.Data
if statusInfo.Status != status.Error {
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
}