本文整理汇总了Golang中github.com/juju/juju/core/description.Machine.SetTools方法的典型用法代码示例。如果您正苦于以下问题:Golang Machine.SetTools方法的具体用法?Golang Machine.SetTools怎么用?Golang Machine.SetTools使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/juju/juju/core/description.Machine
的用法示例。
在下文中一共展示了Machine.SetTools方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: newMachine
func (e *exporter) newMachine(exParent description.Machine, machine *Machine, instances map[string]instanceData, portsData []portsDoc) (description.Machine, error) {
args := description.MachineArgs{
Id: machine.MachineTag(),
Nonce: machine.doc.Nonce,
PasswordHash: machine.doc.PasswordHash,
Placement: machine.doc.Placement,
Series: machine.doc.Series,
ContainerType: machine.doc.ContainerType,
}
if supported, ok := machine.SupportedContainers(); ok {
containers := make([]string, len(supported))
for i, containerType := range supported {
containers[i] = string(containerType)
}
args.SupportedContainers = &containers
}
for _, job := range machine.Jobs() {
args.Jobs = append(args.Jobs, job.MigrationValue())
}
// A null value means that we don't yet know which containers
// are supported. An empty slice means 'no containers are supported'.
var exMachine description.Machine
if exParent == nil {
exMachine = e.model.AddMachine(args)
} else {
exMachine = exParent.AddContainer(args)
}
exMachine.SetAddresses(
e.newAddressArgsSlice(machine.doc.MachineAddresses),
e.newAddressArgsSlice(machine.doc.Addresses))
exMachine.SetPreferredAddresses(
e.newAddressArgs(machine.doc.PreferredPublicAddress),
e.newAddressArgs(machine.doc.PreferredPrivateAddress))
// We fully expect the machine to have tools set, and that there is
// some instance data.
instData, found := instances[machine.doc.Id]
if !found {
return nil, errors.NotValidf("missing instance data for machine %s", machine.Id())
}
exMachine.SetInstance(e.newCloudInstanceArgs(instData))
// Find the current machine status.
globalKey := machine.globalKey()
statusArgs, err := e.statusArgs(globalKey)
if err != nil {
return nil, errors.Annotatef(err, "status for machine %s", machine.Id())
}
exMachine.SetStatus(statusArgs)
exMachine.SetStatusHistory(e.statusHistoryArgs(globalKey))
tools, err := machine.AgentTools()
if err != nil {
// This means the tools aren't set, but they should be.
return nil, errors.Trace(err)
}
exMachine.SetTools(description.AgentToolsArgs{
Version: tools.Version,
URL: tools.URL,
SHA256: tools.SHA256,
Size: tools.Size,
})
for _, args := range e.networkPortsArgsForMachine(machine.Id(), portsData) {
exMachine.AddNetworkPorts(args)
}
exMachine.SetAnnotations(e.getAnnotations(globalKey))
constraintsArgs, err := e.constraintsArgs(globalKey)
if err != nil {
return nil, errors.Trace(err)
}
exMachine.SetConstraints(constraintsArgs)
return exMachine, nil
}