本文整理汇总了Golang中github.com/juju/juju/state/api/provisioner.Machine.ProvisioningInfo方法的典型用法代码示例。如果您正苦于以下问题:Golang Machine.ProvisioningInfo方法的具体用法?Golang Machine.ProvisioningInfo怎么用?Golang Machine.ProvisioningInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/juju/juju/state/api/provisioner.Machine
的用法示例。
在下文中一共展示了Machine.ProvisioningInfo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: provisioningInfo
func (task *provisionerTask) provisioningInfo(machine *apiprovisioner.Machine) (*provisioningInfo, error) {
stateInfo, apiInfo, err := task.auth.SetupAuthentication(machine)
if err != nil {
logger.Errorf("failed to setup authentication: %v", err)
return nil, err
}
// Generated a nonce for the new instance, with the format: "machine-#:UUID".
// The first part is a badge, specifying the tag of the machine the provisioner
// is running on, while the second part is a random UUID.
uuid, err := utils.NewUUID()
if err != nil {
return nil, err
}
// ProvisioningInfo is new in 1.20; wait for the API server to be upgraded
// so we don't spew errors on upgrade.
var pInfo *params.ProvisioningInfo
for {
if pInfo, err = machine.ProvisioningInfo(); err == nil {
break
}
if params.IsCodeNotImplemented(err) {
logger.Infof("waiting for state server to be upgraded")
select {
case <-task.tomb.Dying():
return nil, tomb.ErrDying
case <-time.After(15 * time.Second):
continue
}
}
return nil, err
}
nonce := fmt.Sprintf("%s:%s", task.machineTag, uuid.String())
machineConfig := environs.NewMachineConfig(machine.Id(), nonce, pInfo.Networks, stateInfo, apiInfo)
return &provisioningInfo{
Constraints: pInfo.Constraints,
Series: pInfo.Series,
Placement: pInfo.Placement,
MachineConfig: machineConfig,
}, nil
}