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