本文整理匯總了Golang中github.com/juju/juju/cloudconfig/instancecfg.InstanceConfig.APIInfo方法的典型用法代碼示例。如果您正苦於以下問題:Golang InstanceConfig.APIInfo方法的具體用法?Golang InstanceConfig.APIInfo怎麽用?Golang InstanceConfig.APIInfo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/juju/juju/cloudconfig/instancecfg.InstanceConfig
的用法示例。
在下文中一共展示了InstanceConfig.APIInfo方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: getCloudConfig
func (s *configureSuite) getCloudConfig(c *gc.C, controller bool, vers version.Binary) cloudinit.CloudConfig {
var icfg *instancecfg.InstanceConfig
var err error
modelConfig := testConfig(c, controller, vers)
if controller {
icfg, err = instancecfg.NewBootstrapInstanceConfig(
coretesting.FakeControllerConfig(),
constraints.Value{}, constraints.Value{},
vers.Series, "",
)
c.Assert(err, jc.ErrorIsNil)
icfg.APIInfo = &api.Info{
Password: "password",
CACert: coretesting.CACert,
ModelTag: coretesting.ModelTag,
}
icfg.Controller.MongoInfo = &mongo.MongoInfo{
Password: "password", Info: mongo.Info{CACert: coretesting.CACert},
}
icfg.Bootstrap.ControllerModelConfig = modelConfig
icfg.Bootstrap.BootstrapMachineInstanceId = "instance-id"
icfg.Bootstrap.HostedModelConfig = map[string]interface{}{
"name": "hosted-model",
}
icfg.Bootstrap.StateServingInfo = params.StateServingInfo{
Cert: coretesting.ServerCert,
PrivateKey: coretesting.ServerKey,
CAPrivateKey: coretesting.CAKey,
StatePort: 123,
APIPort: 456,
}
icfg.Jobs = []multiwatcher.MachineJob{multiwatcher.JobManageModel, multiwatcher.JobHostUnits}
icfg.Bootstrap.StateServingInfo = params.StateServingInfo{
Cert: coretesting.ServerCert,
PrivateKey: coretesting.ServerKey,
CAPrivateKey: coretesting.CAKey,
StatePort: 123,
APIPort: 456,
}
} else {
icfg, err = instancecfg.NewInstanceConfig(coretesting.ControllerTag, "0", "ya", imagemetadata.ReleasedStream, vers.Series, nil)
c.Assert(err, jc.ErrorIsNil)
icfg.Jobs = []multiwatcher.MachineJob{multiwatcher.JobHostUnits}
}
err = icfg.SetTools(tools.List{
&tools.Tools{
Version: vers,
URL: "http://testing.invalid/tools.tar.gz",
},
})
err = instancecfg.FinishInstanceConfig(icfg, modelConfig)
c.Assert(err, jc.ErrorIsNil)
cloudcfg, err := cloudinit.New(icfg.Series)
c.Assert(err, jc.ErrorIsNil)
udata, err := cloudconfig.NewUserdataConfig(icfg, cloudcfg)
c.Assert(err, jc.ErrorIsNil)
err = udata.Configure()
c.Assert(err, jc.ErrorIsNil)
return cloudcfg
}
示例2: finalizeInstanceBootstrapConfig
func finalizeInstanceBootstrapConfig(
ctx environs.BootstrapContext,
icfg *instancecfg.InstanceConfig,
args BootstrapParams,
cfg *config.Config,
customImageMetadata []*imagemetadata.ImageMetadata,
) error {
if icfg.APIInfo != nil || icfg.Controller.MongoInfo != nil {
return errors.New("machine configuration already has api/state info")
}
controllerCfg := icfg.Controller.Config
caCert, hasCACert := controllerCfg.CACert()
if !hasCACert {
return errors.New("controller configuration has no ca-cert")
}
icfg.APIInfo = &api.Info{
Password: args.AdminSecret,
CACert: caCert,
ModelTag: names.NewModelTag(cfg.UUID()),
}
icfg.Controller.MongoInfo = &mongo.MongoInfo{
Password: args.AdminSecret,
Info: mongo.Info{CACert: caCert},
}
// These really are directly relevant to running a controller.
// Initially, generate a controller certificate with no host IP
// addresses in the SAN field. Once the controller is up and the
// NIC addresses become known, the certificate can be regenerated.
cert, key, err := controller.GenerateControllerCertAndKey(caCert, args.CAPrivateKey, nil)
if err != nil {
return errors.Annotate(err, "cannot generate controller certificate")
}
icfg.Bootstrap.StateServingInfo = params.StateServingInfo{
StatePort: controllerCfg.StatePort(),
APIPort: controllerCfg.APIPort(),
Cert: string(cert),
PrivateKey: string(key),
CAPrivateKey: args.CAPrivateKey,
}
if _, ok := cfg.AgentVersion(); !ok {
return errors.New("controller model configuration has no agent-version")
}
icfg.Bootstrap.ControllerModelConfig = cfg
icfg.Bootstrap.CustomImageMetadata = customImageMetadata
icfg.Bootstrap.ControllerCloudName = args.CloudName
icfg.Bootstrap.ControllerCloud = args.Cloud
icfg.Bootstrap.ControllerCloudRegion = args.CloudRegion
icfg.Bootstrap.ControllerCloudCredential = args.CloudCredential
icfg.Bootstrap.ControllerCloudCredentialName = args.CloudCredentialName
icfg.Bootstrap.ControllerConfig = args.ControllerConfig
icfg.Bootstrap.ControllerInheritedConfig = args.ControllerInheritedConfig
icfg.Bootstrap.RegionInheritedConfig = args.Cloud.RegionConfig
icfg.Bootstrap.HostedModelConfig = args.HostedModelConfig
icfg.Bootstrap.Timeout = args.DialOpts.Timeout
icfg.Bootstrap.GUI = guiArchive(args.GUIDataSourceBaseURL, func(msg string) {
ctx.Infof(msg)
})
return nil
}