本文整理匯總了Golang中github.com/juju/juju/cloudconfig/instancecfg.InstanceConfig.SetTools方法的典型用法代碼示例。如果您正苦於以下問題:Golang InstanceConfig.SetTools方法的具體用法?Golang InstanceConfig.SetTools怎麽用?Golang InstanceConfig.SetTools使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/juju/juju/cloudconfig/instancecfg.InstanceConfig
的用法示例。
在下文中一共展示了InstanceConfig.SetTools方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: TestWindowsUserdataEncoding
func (s *CloudInitSuite) TestWindowsUserdataEncoding(c *gc.C) {
series := "win8"
metricsSpoolDir := must(paths.MetricsSpoolDir("win8"))
toolsList := tools.List{
&tools.Tools{
URL: "http://foo.com/tools/released/juju1.2.3-win8-amd64.tgz",
Version: version.MustParseBinary("1.2.3-win8-amd64"),
Size: 10,
SHA256: "1234",
},
}
dataDir, err := paths.DataDir(series)
c.Assert(err, jc.ErrorIsNil)
logDir, err := paths.LogDir(series)
c.Assert(err, jc.ErrorIsNil)
cfg := instancecfg.InstanceConfig{
ControllerTag: testing.ControllerTag,
MachineId: "10",
AgentEnvironment: map[string]string{agent.ProviderType: "dummy"},
Series: series,
Jobs: []multiwatcher.MachineJob{multiwatcher.JobHostUnits},
MachineNonce: "FAKE_NONCE",
APIInfo: &api.Info{
Addrs: []string{"state-addr.testing.invalid:54321"},
Password: "bletch",
CACert: "CA CERT\n" + testing.CACert,
Tag: names.NewMachineTag("10"),
ModelTag: testing.ModelTag,
},
MachineAgentServiceName: "jujud-machine-10",
DataDir: dataDir,
LogDir: path.Join(logDir, "juju"),
MetricsSpoolDir: metricsSpoolDir,
CloudInitOutputLog: path.Join(logDir, "cloud-init-output.log"),
}
err = cfg.SetTools(toolsList)
c.Assert(err, jc.ErrorIsNil)
ci, err := cloudinit.New("win8")
c.Assert(err, jc.ErrorIsNil)
udata, err := cloudconfig.NewUserdataConfig(&cfg, ci)
c.Assert(err, jc.ErrorIsNil)
err = udata.Configure()
c.Assert(err, jc.ErrorIsNil)
data, err := ci.RenderYAML()
c.Assert(err, jc.ErrorIsNil)
cicompose, err := cloudinit.New("win8")
c.Assert(err, jc.ErrorIsNil)
base64Data := base64.StdEncoding.EncodeToString(utils.Gzip(data))
got := []byte(fmt.Sprintf(cloudconfig.UserDataScript, base64Data))
expected, err := providerinit.ComposeUserData(&cfg, cicompose, openstack.OpenstackRenderer{})
c.Assert(err, jc.ErrorIsNil)
c.Assert(string(got), gc.Equals, string(expected))
}
示例3: TestAgentVersion
func (*instancecfgSuite) TestAgentVersion(c *gc.C) {
var icfg instancecfg.InstanceConfig
list := coretools.List{
&coretools.Tools{Version: version.MustParseBinary("2.3.4-trusty-amd64")},
}
err := icfg.SetTools(list)
c.Assert(err, jc.ErrorIsNil)
c.Assert(icfg.AgentVersion(), gc.Equals, list[0].Version)
}
示例4: TestSetToolsDifferentVersions
func (*instancecfgSuite) TestSetToolsDifferentVersions(c *gc.C) {
var icfg instancecfg.InstanceConfig
list := coretools.List{
&coretools.Tools{Version: version.MustParseBinary("2.3.4-trusty-amd64")},
&coretools.Tools{Version: version.MustParseBinary("2.3.5-trusty-amd64")},
}
err := icfg.SetTools(list)
c.Assert(err, gc.ErrorMatches, `tools info mismatch.*2\.3\.4.*2\.3\.5.*`)
c.Assert(icfg.ToolsList(), gc.HasLen, 0)
}
示例5: TestSetToolsSameVersions
func (*instancecfgSuite) TestSetToolsSameVersions(c *gc.C) {
var icfg instancecfg.InstanceConfig
list := coretools.List{
&coretools.Tools{Version: version.MustParseBinary("2.3.4-trusty-amd64")},
&coretools.Tools{Version: version.MustParseBinary("2.3.4-trusty-amd64")},
}
err := icfg.SetTools(list)
c.Assert(err, jc.ErrorIsNil)
c.Assert(icfg.ToolsList(), jc.DeepEquals, list)
}