本文整理汇总了Golang中github.com/juju/juju/agent.ConfigSetter.SetPassword方法的典型用法代码示例。如果您正苦于以下问题:Golang ConfigSetter.SetPassword方法的具体用法?Golang ConfigSetter.SetPassword怎么用?Golang ConfigSetter.SetPassword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/juju/juju/agent.ConfigSetter
的用法示例。
在下文中一共展示了ConfigSetter.SetPassword方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: initBootstrapMachine
// initBootstrapMachine initializes the initial bootstrap machine in state.
func initBootstrapMachine(c agent.ConfigSetter, st *state.State, args InitializeStateParams) (*state.Machine, error) {
logger.Infof("initialising bootstrap machine with config: %+v", args)
jobs := make([]state.MachineJob, len(args.BootstrapMachineJobs))
for i, job := range args.BootstrapMachineJobs {
machineJob, err := machineJobFromParams(job)
if err != nil {
return nil, errors.Errorf("invalid bootstrap machine job %q: %v", job, err)
}
jobs[i] = machineJob
}
var hardware instance.HardwareCharacteristics
if args.BootstrapMachineHardwareCharacteristics != nil {
hardware = *args.BootstrapMachineHardwareCharacteristics
}
m, err := st.AddOneMachine(state.MachineTemplate{
Addresses: args.BootstrapMachineAddresses,
Series: series.HostSeries(),
Nonce: agent.BootstrapNonce,
Constraints: args.BootstrapMachineConstraints,
InstanceId: args.BootstrapMachineInstanceId,
HardwareCharacteristics: hardware,
Jobs: jobs,
})
if err != nil {
return nil, errors.Errorf("cannot create bootstrap machine in state: %v", err)
}
if m.Id() != agent.BootstrapMachineId {
return nil, errors.Errorf("bootstrap machine expected id 0, got %q", m.Id())
}
// Read the machine agent's password and change it to
// a new password (other agents will change their password
// via the API connection).
logger.Debugf("create new random password for machine %v", m.Id())
newPassword, err := utils.RandomPassword()
if err != nil {
return nil, err
}
if err := m.SetPassword(newPassword); err != nil {
return nil, err
}
if err := m.SetMongoPassword(newPassword); err != nil {
return nil, err
}
c.SetPassword(newPassword)
return m, nil
}