本文整理汇总了Golang中github.com/juju/juju/state.Machine.Status方法的典型用法代码示例。如果您正苦于以下问题:Golang Machine.Status方法的具体用法?Golang Machine.Status怎么用?Golang Machine.Status使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/juju/juju/state.Machine
的用法示例。
在下文中一共展示了Machine.Status方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: buildMachineMatcherShims
func buildMachineMatcherShims(m *state.Machine, patterns []string) (shims []closurePredicate, _ error) {
// Look at machine status.
statusInfo, err := m.Status()
if err != nil {
return nil, err
}
shims = append(shims, func() (bool, bool, error) { return matchAgentStatus(patterns, statusInfo.Status) })
// Look at machine addresses. WARNING: Avoid the temptation to
// bring the append into the loop. The value we would close over
// will continue to change after the closure is created, and we'd
// only examine the last element of the loop for all closures.
var addrs []string
for _, a := range m.Addresses() {
addrs = append(addrs, a.Value)
}
shims = append(shims, func() (bool, bool, error) { return matchSubnet(patterns, addrs...) })
// If the machine hosts a unit that matches any of the given
// criteria, consider the machine a match as well.
unitShims, err := buildShimsForUnit(m.Units, patterns...)
if err != nil {
return nil, err
}
shims = append(shims, unitShims...)
// Units may be able to match the pattern. Ultimately defer to
// that logic, and guard against breaking the predicate-chain.
if len(unitShims) <= 0 {
shims = append(shims, func() (bool, bool, error) { return false, true, nil })
}
return
}
示例2: assertRetryProvisioning
func (s *clientSuite) assertRetryProvisioning(c *gc.C, machine *state.Machine) {
_, err := s.APIState.Client().RetryProvisioning(machine.Tag().(names.MachineTag))
c.Assert(err, jc.ErrorIsNil)
statusInfo, err := machine.Status()
c.Assert(err, jc.ErrorIsNil)
c.Assert(statusInfo.Status, gc.Equals, status.Error)
c.Assert(statusInfo.Message, gc.Equals, "error")
c.Assert(statusInfo.Data["transient"], jc.IsTrue)
}
示例3: waitMachineStatus
func (s *MachinerStateSuite) waitMachineStatus(c *gc.C, m *state.Machine, expectStatus state.Status) {
timeout := time.After(worstCase)
for {
select {
case <-timeout:
c.Fatalf("timeout while waiting for machine status to change")
case <-time.After(10 * time.Millisecond):
statusInfo, err := m.Status()
c.Assert(err, jc.ErrorIsNil)
if statusInfo.Status != expectStatus {
c.Logf("machine %q status is %s, still waiting", m, statusInfo.Status)
continue
}
return
}
}
}