本文整理汇总了Golang中github.com/juju/juju/environs.StartInstanceParams.InstanceConfig方法的典型用法代码示例。如果您正苦于以下问题:Golang StartInstanceParams.InstanceConfig方法的具体用法?Golang StartInstanceParams.InstanceConfig怎么用?Golang StartInstanceParams.InstanceConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/juju/juju/environs.StartInstanceParams
的用法示例。
在下文中一共展示了StartInstanceParams.InstanceConfig方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: StartInstanceWithParams
// StartInstanceWithParams is a test helper function that starts an instance
// with the given parameters, and a plausible but invalid configuration, and
// returns the result of Environ.StartInstance. The provided params's
// InstanceConfig and Tools field values will be ignored.
func StartInstanceWithParams(
env environs.Environ, machineId string,
params environs.StartInstanceParams,
networks []string,
) (
*environs.StartInstanceResult, error,
) {
preferredSeries := config.PreferredSeries(env.Config())
agentVersion, ok := env.Config().AgentVersion()
if !ok {
return nil, errors.New("missing agent version in model config")
}
filter := coretools.Filter{
Number: agentVersion,
Series: preferredSeries,
}
if params.Constraints.Arch != nil {
filter.Arch = *params.Constraints.Arch
}
stream := tools.PreferredStream(&agentVersion, env.Config().Development(), env.Config().AgentStream())
possibleTools, err := tools.FindTools(env, -1, -1, stream, filter)
if err != nil {
return nil, errors.Trace(err)
}
if params.ImageMetadata == nil {
if err := SetImageMetadata(
env,
possibleTools.AllSeries(),
possibleTools.Arches(),
¶ms.ImageMetadata,
); err != nil {
return nil, errors.Trace(err)
}
}
machineNonce := "fake_nonce"
stateInfo := FakeStateInfo(machineId)
apiInfo := FakeAPIInfo(machineId)
instanceConfig, err := instancecfg.NewInstanceConfig(
machineId,
machineNonce,
imagemetadata.ReleasedStream,
preferredSeries,
"",
true,
networks,
stateInfo,
apiInfo,
)
if err != nil {
return nil, errors.Trace(err)
}
eUUID, _ := env.Config().UUID()
instanceConfig.Tags[tags.JujuModel] = eUUID
params.Tools = possibleTools
params.InstanceConfig = instanceConfig
return env.StartInstance(params)
}
示例2: maintainMachines
func (task *provisionerTask) maintainMachines(machines []*apiprovisioner.Machine) error {
for _, m := range machines {
logger.Infof("maintainMachines: %v", m)
startInstanceParams := environs.StartInstanceParams{}
startInstanceParams.InstanceConfig = &instancecfg.InstanceConfig{}
startInstanceParams.InstanceConfig.MachineId = m.Id()
if err := task.broker.MaintainInstance(startInstanceParams); err != nil {
return errors.Annotatef(err, "cannot maintain machine %v", m)
}
}
return nil
}
示例3: StartInstanceWithParams
// StartInstanceWithParams is a test helper function that starts an instance
// with the given parameters, and a plausible but invalid configuration, and
// returns the result of Environ.StartInstance. The provided params's
// InstanceConfig and Tools field values will be ignored.
func StartInstanceWithParams(
env environs.Environ, machineId string,
params environs.StartInstanceParams,
networks []string,
) (
*environs.StartInstanceResult, error,
) {
series := config.PreferredSeries(env.Config())
agentVersion, ok := env.Config().AgentVersion()
if !ok {
return nil, errors.New("missing agent version in environment config")
}
filter := coretools.Filter{
Number: agentVersion,
Series: series,
}
if params.Constraints.Arch != nil {
filter.Arch = *params.Constraints.Arch
}
possibleTools, err := tools.FindTools(env, -1, -1, filter)
if err != nil {
return nil, errors.Trace(err)
}
machineNonce := "fake_nonce"
stateInfo := FakeStateInfo(machineId)
apiInfo := FakeAPIInfo(machineId)
instanceConfig, err := instancecfg.NewInstanceConfig(
machineId,
machineNonce,
imagemetadata.ReleasedStream,
series,
true,
networks,
stateInfo,
apiInfo,
)
if err != nil {
return nil, errors.Trace(err)
}
params.Tools = possibleTools
params.InstanceConfig = instanceConfig
return env.StartInstance(params)
}
示例4: fillinStartInstanceParams
func fillinStartInstanceParams(env environs.Environ, machineId string, isController bool, params *environs.StartInstanceParams) error {
if params.ControllerUUID == "" {
return errors.New("missing controller UUID in start instance parameters")
}
preferredSeries := config.PreferredSeries(env.Config())
agentVersion, ok := env.Config().AgentVersion()
if !ok {
return errors.New("missing agent version in model config")
}
filter := coretools.Filter{
Number: agentVersion,
Series: preferredSeries,
}
if params.Constraints.Arch != nil {
filter.Arch = *params.Constraints.Arch
}
stream := tools.PreferredStream(&agentVersion, env.Config().Development(), env.Config().AgentStream())
possibleTools, err := tools.FindTools(env, -1, -1, stream, filter)
if err != nil {
return errors.Trace(err)
}
if params.ImageMetadata == nil {
if err := SetImageMetadata(
env,
possibleTools.AllSeries(),
possibleTools.Arches(),
¶ms.ImageMetadata,
); err != nil {
return errors.Trace(err)
}
}
machineNonce := "fake_nonce"
apiInfo := FakeAPIInfo(machineId)
instanceConfig, err := instancecfg.NewInstanceConfig(
testing.ControllerTag,
machineId,
machineNonce,
imagemetadata.ReleasedStream,
preferredSeries,
apiInfo,
)
if err != nil {
return errors.Trace(err)
}
if isController {
instanceConfig.Controller = &instancecfg.ControllerConfig{
Config: testing.FakeControllerConfig(),
MongoInfo: &mongo.MongoInfo{
Info: mongo.Info{
Addrs: []string{"127.0.0.1:1234"},
CACert: "CA CERT\n" + testing.CACert,
},
Password: "mongosecret",
Tag: names.NewMachineTag(machineId),
},
}
instanceConfig.Jobs = []multiwatcher.MachineJob{multiwatcher.JobHostUnits, multiwatcher.JobManageModel}
}
cfg := env.Config()
instanceConfig.Tags = instancecfg.InstanceTags(env.Config().UUID(), params.ControllerUUID, cfg, nil)
params.Tools = possibleTools
params.InstanceConfig = instanceConfig
return nil
}