本文整理汇总了Golang中github.com/juju/juju/environs.StartInstanceParams.MachineConfig方法的典型用法代码示例。如果您正苦于以下问题:Golang StartInstanceParams.MachineConfig方法的具体用法?Golang StartInstanceParams.MachineConfig怎么用?Golang StartInstanceParams.MachineConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/juju/juju/environs.StartInstanceParams
的用法示例。
在下文中一共展示了StartInstanceParams.MachineConfig方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
// MachineConfig and Tools field values will be ignored.
func StartInstanceWithParams(
env environs.Environ, machineId string,
params environs.StartInstanceParams,
networks []string,
) (
instance.Instance, *instance.HardwareCharacteristics, []network.Info, error,
) {
series := config.PreferredSeries(env.Config())
agentVersion, ok := env.Config().AgentVersion()
if !ok {
return nil, nil, nil, fmt.Errorf("missing agent version in environment config")
}
possibleTools, err := tools.FindInstanceTools(
env, agentVersion, series, params.Constraints.Arch,
)
if err != nil {
return nil, nil, nil, err
}
machineNonce := "fake_nonce"
stateInfo := FakeStateInfo(machineId)
apiInfo := FakeAPIInfo(machineId)
machineConfig := environs.NewMachineConfig(
machineId, machineNonce,
networks,
stateInfo, apiInfo)
params.Tools = possibleTools
params.MachineConfig = machineConfig
return env.StartInstance(params)
}
示例2: 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
// MachineConfig and Tools field values will be ignored.
func StartInstanceWithParams(
env environs.Environ, machineId string,
params environs.StartInstanceParams,
networks []string,
) (
instance.Instance, *instance.HardwareCharacteristics, []network.Info, error,
) {
series := config.PreferredSeries(env.Config())
agentVersion, ok := env.Config().AgentVersion()
if !ok {
return nil, nil, nil, fmt.Errorf("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, tools.DoNotAllowRetry,
)
if err != nil {
return nil, nil, nil, err
}
machineNonce := "fake_nonce"
stateInfo := FakeStateInfo(machineId)
apiInfo := FakeAPIInfo(machineId)
machineConfig, err := environs.NewMachineConfig(
machineId,
machineNonce,
imagemetadata.ReleasedStream,
series,
networks,
stateInfo,
apiInfo,
)
if err != nil {
return nil, nil, nil, err
}
params.Tools = possibleTools
params.MachineConfig = machineConfig
return env.StartInstance(params)
}