本文整理汇总了Golang中github.com/juju/juju/environs/manual.ProvisioningScript函数的典型用法代码示例。如果您正苦于以下问题:Golang ProvisioningScript函数的具体用法?Golang ProvisioningScript怎么用?Golang ProvisioningScript使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ProvisioningScript函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestProvisioningScript
func (s *provisionerSuite) TestProvisioningScript(c *gc.C) {
const series = "precise"
const arch = "amd64"
defer fakeSSH{
Series: series,
Arch: arch,
InitUbuntuUser: true,
}.install(c).Restore()
machineId, err := manual.ProvisionMachine(s.getArgs(c))
c.Assert(err, gc.IsNil)
mcfg, err := client.MachineConfig(s.State, machineId, agent.BootstrapNonce, "/var/lib/juju")
c.Assert(err, gc.IsNil)
script, err := manual.ProvisioningScript(mcfg)
c.Assert(err, gc.IsNil)
cloudcfg := coreCloudinit.New()
err = cloudinit.ConfigureJuju(mcfg, cloudcfg)
c.Assert(err, gc.IsNil)
cloudcfg.SetAptUpgrade(false)
sshinitScript, err := sshinit.ConfigureScript(cloudcfg)
c.Assert(err, gc.IsNil)
removeLogFile := "rm -f '/var/log/cloud-init-output.log'\n"
expectedScript := removeLogFile + shell.DumpFileOnErrorScript("/var/log/cloud-init-output.log") + sshinitScript
c.Assert(script, gc.Equals, expectedScript)
}
开发者ID:jiasir,项目名称:juju,代码行数:27,代码来源:provisioner_test.go
示例2: ProvisioningScript
// ProvisioningScript returns a shell script that, when run,
// provisions a machine agent on the machine executing the script.
func (c *Client) ProvisioningScript(args params.ProvisioningScriptParams) (params.ProvisioningScriptResult, error) {
var result params.ProvisioningScriptResult
icfg, err := InstanceConfig(c.api.state, args.MachineId, args.Nonce, args.DataDir)
if err != nil {
return result, err
}
// Until DisablePackageCommands is retired, for backwards
// compatibility, we must respect the client's request and
// override any environment settings the user may have specified.
// If the client does specify this setting, it will only ever be
// true. False indicates the client doesn't care and we should use
// what's specified in the environments.yaml file.
if args.DisablePackageCommands {
icfg.EnableOSRefreshUpdate = false
icfg.EnableOSUpgrade = false
} else if cfg, err := c.api.state.EnvironConfig(); err != nil {
return result, err
} else {
icfg.EnableOSUpgrade = cfg.EnableOSUpgrade()
icfg.EnableOSRefreshUpdate = cfg.EnableOSRefreshUpdate()
}
result.Script, err = manual.ProvisioningScript(icfg)
return result, err
}
开发者ID:mhilton,项目名称:juju,代码行数:28,代码来源:client.go
示例3: TestProvisioningScript
func (s *clientSuite) TestProvisioningScript(c *gc.C) {
// Inject a machine and then call the ProvisioningScript API.
// The result should be the same as when calling MachineConfig,
// converting it to a cloudinit.MachineConfig, and disabling
// apt_upgrade.
apiParams := params.AddMachineParams{
Jobs: []multiwatcher.MachineJob{multiwatcher.JobHostUnits},
InstanceId: instance.Id("1234"),
Nonce: "foo",
HardwareCharacteristics: instance.MustParseHardware("arch=amd64"),
}
machines, err := s.APIState.Client().AddMachines([]params.AddMachineParams{apiParams})
c.Assert(err, jc.ErrorIsNil)
c.Assert(len(machines), gc.Equals, 1)
machineId := machines[0].Machine
// Call ProvisioningScript. Normally ProvisioningScript and
// MachineConfig are mutually exclusive; both of them will
// allocate a api password for the machine agent.
script, err := s.APIState.Client().ProvisioningScript(params.ProvisioningScriptParams{
MachineId: machineId,
Nonce: apiParams.Nonce,
})
c.Assert(err, jc.ErrorIsNil)
icfg, err := client.InstanceConfig(s.State, machineId, apiParams.Nonce, "")
c.Assert(err, jc.ErrorIsNil)
provisioningScript, err := manual.ProvisioningScript(icfg)
c.Assert(err, jc.ErrorIsNil)
// ProvisioningScript internally calls MachineConfig,
// which allocates a new, random password. Everything
// about the scripts should be the same other than
// the line containing "oldpassword" from agent.conf.
scriptLines := strings.Split(script, "\n")
provisioningScriptLines := strings.Split(provisioningScript, "\n")
c.Assert(scriptLines, gc.HasLen, len(provisioningScriptLines))
for i, line := range scriptLines {
if strings.Contains(line, "oldpassword") {
continue
}
c.Assert(line, gc.Equals, provisioningScriptLines[i])
}
}
开发者ID:bac,项目名称:juju,代码行数:41,代码来源:client_test.go
示例4: ProvisioningScript
// ProvisioningScript returns a shell script that, when run,
// provisions a machine agent on the machine executing the script.
func (c *Client) ProvisioningScript(args params.ProvisioningScriptParams) (params.ProvisioningScriptResult, error) {
if err := c.checkCanWrite(); err != nil {
return params.ProvisioningScriptResult{}, err
}
var result params.ProvisioningScriptResult
icfg, err := InstanceConfig(c.api.state(), args.MachineId, args.Nonce, args.DataDir)
if err != nil {
return result, common.ServerError(errors.Annotate(
err, "getting instance config",
))
}
// Until DisablePackageCommands is retired, for backwards
// compatibility, we must respect the client's request and
// override any model settings the user may have specified.
// If the client does specify this setting, it will only ever be
// true. False indicates the client doesn't care and we should use
// what's specified in the environment config.
if args.DisablePackageCommands {
icfg.EnableOSRefreshUpdate = false
icfg.EnableOSUpgrade = false
} else if cfg, err := c.api.stateAccessor.ModelConfig(); err != nil {
return result, common.ServerError(errors.Annotate(
err, "getting model config",
))
} else {
icfg.EnableOSUpgrade = cfg.EnableOSUpgrade()
icfg.EnableOSRefreshUpdate = cfg.EnableOSRefreshUpdate()
}
result.Script, err = manual.ProvisioningScript(icfg)
if err != nil {
return result, common.ServerError(errors.Annotate(
err, "getting provisioning script",
))
}
return result, nil
}
开发者ID:bac,项目名称:juju,代码行数:41,代码来源:client.go
示例5: TestProvisioningScript
func (s *provisionerSuite) TestProvisioningScript(c *gc.C) {
var series = series.LatestLts()
const arch = "amd64"
defer fakeSSH{
Series: series,
Arch: arch,
InitUbuntuUser: true,
}.install(c).Restore()
machineId, err := manual.ProvisionMachine(s.getArgs(c))
c.Assert(err, jc.ErrorIsNil)
err = s.State.UpdateModelConfig(
map[string]interface{}{
"enable-os-upgrade": false,
}, nil, nil)
c.Assert(err, jc.ErrorIsNil)
icfg, err := client.InstanceConfig(s.State, machineId, agent.BootstrapNonce, "/var/lib/juju")
c.Assert(err, jc.ErrorIsNil)
script, err := manual.ProvisioningScript(icfg)
c.Assert(err, jc.ErrorIsNil)
cloudcfg, err := cloudinit.New(series)
c.Assert(err, jc.ErrorIsNil)
udata, err := cloudconfig.NewUserdataConfig(icfg, cloudcfg)
c.Assert(err, jc.ErrorIsNil)
err = udata.ConfigureJuju()
c.Assert(err, jc.ErrorIsNil)
cloudcfg.SetSystemUpgrade(false)
provisioningScript, err := cloudcfg.RenderScript()
c.Assert(err, jc.ErrorIsNil)
removeLogFile := "rm -f '/var/log/cloud-init-output.log'\n"
expectedScript := removeLogFile + shell.DumpFileOnErrorScript("/var/log/cloud-init-output.log") + provisioningScript
c.Assert(script, gc.Equals, expectedScript)
}
开发者ID:bac,项目名称:juju,代码行数:38,代码来源:provisioner_test.go
示例6: TestProvisioningScript
func (s *provisionerSuite) TestProvisioningScript(c *gc.C) {
const series = coretesting.FakeDefaultSeries
const arch = "amd64"
defer fakeSSH{
Series: series,
Arch: arch,
InitUbuntuUser: true,
}.install(c).Restore()
machineId, err := manual.ProvisionMachine(s.getArgs(c))
c.Assert(err, gc.IsNil)
err = s.State.UpdateEnvironConfig(
map[string]interface{}{
"enable-os-upgrade": false,
}, nil, nil)
c.Assert(err, gc.IsNil)
mcfg, err := client.MachineConfig(s.State, machineId, agent.BootstrapNonce, "/var/lib/juju")
c.Assert(err, gc.IsNil)
script, err := manual.ProvisioningScript(mcfg)
c.Assert(err, gc.IsNil)
cloudcfg := coreCloudinit.New()
udata, err := cloudinit.NewUserdataConfig(mcfg, cloudcfg)
c.Assert(err, gc.IsNil)
err = udata.ConfigureJuju()
c.Assert(err, gc.IsNil)
cloudcfg.SetAptUpgrade(false)
sshinitScript, err := sshinit.ConfigureScript(cloudcfg)
c.Assert(err, gc.IsNil)
removeLogFile := "rm -f '/var/log/cloud-init-output.log'\n"
expectedScript := removeLogFile + shell.DumpFileOnErrorScript("/var/log/cloud-init-output.log") + sshinitScript
c.Assert(script, gc.Equals, expectedScript)
}
开发者ID:zhouqt,项目名称:juju,代码行数:37,代码来源:provisioner_test.go
注:本文中的github.com/juju/juju/environs/manual.ProvisioningScript函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论