本文整理匯總了Golang中github.com/juju/juju/state/api/provisioner.Machine.Id方法的典型用法代碼示例。如果您正苦於以下問題:Golang Machine.Id方法的具體用法?Golang Machine.Id怎麽用?Golang Machine.Id使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/juju/juju/state/api/provisioner.Machine
的用法示例。
在下文中一共展示了Machine.Id方法的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
}