func (p *Provisioner) setupAuthentication(m *state.Machine) (*state.Info, *api.Info, error) { password, err := utils.RandomPassword() if err != nil { return nil, nil, fmt.Errorf("cannot make password for machine %v: %v", m, err) } if err := m.SetMongoPassword(password); err != nil { return nil, nil, fmt.Errorf("cannot set password for machine %v: %v", m, err) } stateInfo := *p.stateInfo stateInfo.Tag = m.Tag() stateInfo.Password = password apiInfo := *p.apiInfo apiInfo.Tag = m.Tag() apiInfo.Password = password return &stateInfo, &apiInfo, nil }
func (auth *simpleAuth) SetupAuthentication(machine *state.Machine) (*state.Info, *api.Info, error) { password, err := utils.RandomPassword() if err != nil { return nil, nil, fmt.Errorf("cannot make password for machine %v: %v", machine, err) } if err := machine.SetPassword(password); err != nil { return nil, nil, fmt.Errorf("cannot set API password for machine %v: %v", machine, err) } if err := machine.SetMongoPassword(password); err != nil { return nil, nil, fmt.Errorf("cannot set mongo password for machine %v: %v", machine, err) } stateInfo := *auth.stateInfo stateInfo.Tag = machine.Tag() stateInfo.Password = password apiInfo := *auth.apiInfo apiInfo.Tag = machine.Tag() apiInfo.Password = password return &stateInfo, &apiInfo, nil }