本文整理汇总了Golang中launchpad/net/juju-core/state.Machine.HardwareCharacteristics方法的典型用法代码示例。如果您正苦于以下问题:Golang Machine.HardwareCharacteristics方法的具体用法?Golang Machine.HardwareCharacteristics怎么用?Golang Machine.HardwareCharacteristics使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类launchpad/net/juju-core/state.Machine
的用法示例。
在下文中一共展示了Machine.HardwareCharacteristics方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: checkStartInstanceCustom
func (s *CommonProvisionerSuite) checkStartInstanceCustom(c *C, m *state.Machine, secret string, cons constraints.Value) (inst instance.Instance) {
s.State.StartSync()
for {
select {
case o := <-s.op:
switch o := o.(type) {
case dummy.OpStartInstance:
inst = o.Instance
s.waitInstanceId(c, m, inst.Id())
// Check the instance was started with the expected params.
c.Assert(o.MachineId, Equals, m.Id())
nonceParts := strings.SplitN(o.MachineNonce, ":", 2)
c.Assert(nonceParts, HasLen, 2)
c.Assert(nonceParts[0], Equals, state.MachineTag("0"))
c.Assert(nonceParts[1], checkers.Satisfies, utils.IsValidUUIDString)
c.Assert(o.Secret, Equals, secret)
c.Assert(o.Constraints, DeepEquals, cons)
// Check we can connect to the state with
// the machine's entity name and password.
info := s.StateInfo(c)
info.Tag = m.Tag()
c.Assert(o.Info.Password, Not(HasLen), 0)
info.Password = o.Info.Password
c.Assert(o.Info, DeepEquals, info)
// Check we can connect to the state with
// the machine's entity name and password.
st, err := state.Open(o.Info, state.DefaultDialOpts())
c.Assert(err, IsNil)
// All provisioned machines in this test suite have their hardware characteristics
// attributes set to the same values as the constraints due to the dummy environment being used.
hc, err := m.HardwareCharacteristics()
c.Assert(err, IsNil)
c.Assert(*hc, DeepEquals, instance.HardwareCharacteristics{
Arch: cons.Arch,
Mem: cons.Mem,
CpuCores: cons.CpuCores,
CpuPower: cons.CpuPower,
})
st.Close()
return
default:
c.Logf("ignoring unexpected operation %#v", o)
}
case <-time.After(2 * time.Second):
c.Fatalf("provisioner did not start an instance")
return
}
}
return
}
示例2: makeMachineStatus
func (context *statusContext) makeMachineStatus(machine *state.Machine) (status machineStatus) {
status.Id = machine.Id()
status.Life,
status.AgentVersion,
status.AgentState,
status.AgentStateInfo,
status.Err = processAgent(machine)
status.Series = machine.Series()
instid, err := machine.InstanceId()
if err == nil {
status.InstanceId = instid
inst, ok := context.instances[instid]
if ok {
status.DNSName, _ = inst.DNSName()
} else {
// Double plus ungood. There is an instance id recorded
// for this machine in the state, yet the environ cannot
// find that id.
status.InstanceState = "missing"
}
} else {
if state.IsNotProvisionedError(err) {
status.InstanceId = "pending"
} else {
status.InstanceId = "error"
}
// There's no point in reporting a pending agent state
// if the machine hasn't been provisioned. This
// also makes unprovisioned machines visually distinct
// in the output.
status.AgentState = ""
}
hc, err := machine.HardwareCharacteristics()
if err != nil {
if !errors.IsNotFoundError(err) {
status.Hardware = "error"
}
} else {
status.Hardware = hc.String()
}
status.Containers = make(map[string]machineStatus)
return
}