本文整理汇总了Golang中github.com/juju/juju/cloudconfig/cloudinit.New函数的典型用法代码示例。如果您正苦于以下问题:Golang New函数的具体用法?Golang New怎么用?Golang New使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了New函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: 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))
}
开发者ID:bac,项目名称:juju,代码行数:60,代码来源:providerinit_test.go
示例2: TestCloudInitConfigureBootstrapLogging
func (*cloudinitSuite) TestCloudInitConfigureBootstrapLogging(c *gc.C) {
loggo.GetLogger("").SetLogLevel(loggo.INFO)
envConfig := minimalEnvironConfig(c)
instConfig := makeBootstrapConfig("quantal").maybeSetEnvironConfig(envConfig)
rendered := instConfig.render()
cloudcfg, err := cloudinit.New(rendered.Series)
c.Assert(err, jc.ErrorIsNil)
udata, err := cloudconfig.NewUserdataConfig(&rendered, cloudcfg)
c.Assert(err, jc.ErrorIsNil)
err = udata.Configure()
c.Assert(err, jc.ErrorIsNil)
data, err := cloudcfg.RenderYAML()
c.Assert(err, jc.ErrorIsNil)
configKeyValues := make(map[interface{}]interface{})
err = goyaml.Unmarshal(data, &configKeyValues)
c.Assert(err, jc.ErrorIsNil)
scripts := getScripts(configKeyValues)
for i, script := range scripts {
if strings.Contains(script, "bootstrap") {
c.Logf("scripts[%d]: %q", i, script)
}
}
expected := "jujud bootstrap-state --data-dir '.*' --env-config '.*'" +
" --instance-id '.*' --bootstrap-constraints 'mem=4096M'" +
" --environ-constraints 'mem=2048M' --show-log"
assertScriptMatch(c, scripts, expected, false)
}
开发者ID:imoapps,项目名称:juju,代码行数:29,代码来源:userdatacfg_test.go
示例3: TestWindowsCloudInit
func (*cloudinitSuite) TestWindowsCloudInit(c *gc.C) {
for i, test := range windowsCloudinitTests {
testConfig := test.cfg.render()
c.Logf("test %d", i)
ci, err := cloudinit.New("win8")
c.Assert(err, jc.ErrorIsNil)
udata, err := cloudconfig.NewUserdataConfig(&testConfig, ci)
c.Assert(err, jc.ErrorIsNil)
err = udata.Configure()
c.Assert(err, jc.ErrorIsNil)
c.Check(ci, gc.NotNil)
data, err := ci.RenderYAML()
c.Assert(err, jc.ErrorIsNil)
stringData := strings.Replace(string(data), "\r\n", "\n", -1)
stringData = strings.Replace(stringData, "\t", " ", -1)
stringData = strings.TrimSpace(stringData)
compareString := strings.Replace(string(test.expectScripts), "\r\n", "\n", -1)
compareString = strings.Replace(compareString, "\t", " ", -1)
compareString = strings.TrimSpace(compareString)
testing.CheckString(c, stringData, compareString)
}
}
开发者ID:imoapps,项目名称:juju,代码行数:27,代码来源:userdatacfg_test.go
示例4: 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
}
开发者ID:bac,项目名称:juju,代码行数:60,代码来源:renderscript_test.go
示例5: getCloudConfig
func (s *configureSuite) getCloudConfig(c *gc.C, stateServer bool, vers version.Binary) cloudinit.CloudConfig {
var icfg *instancecfg.InstanceConfig
var err error
if stateServer {
icfg, err = instancecfg.NewBootstrapInstanceConfig(constraints.Value{}, vers.Series)
c.Assert(err, jc.ErrorIsNil)
icfg.InstanceId = "instance-id"
icfg.Jobs = []multiwatcher.MachineJob{multiwatcher.JobManageEnviron, multiwatcher.JobHostUnits}
} else {
icfg, err = instancecfg.NewInstanceConfig("0", "ya", imagemetadata.ReleasedStream, vers.Series, true, nil, nil, nil)
c.Assert(err, jc.ErrorIsNil)
icfg.Jobs = []multiwatcher.MachineJob{multiwatcher.JobHostUnits}
}
icfg.Tools = &tools.Tools{
Version: vers,
URL: "http://testing.invalid/tools.tar.gz",
}
environConfig := testConfig(c, stateServer, vers)
err = instancecfg.FinishInstanceConfig(icfg, environConfig)
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
}
开发者ID:Pankov404,项目名称:juju,代码行数:28,代码来源:renderscript_test.go
示例6: ProvisioningScript
// ProvisioningScript generates a bash script that can be
// executed on a remote host to carry out the cloud-init
// configuration.
func ProvisioningScript(icfg *instancecfg.InstanceConfig) (string, error) {
cloudcfg, err := cloudinit.New(icfg.Series)
if err != nil {
return "", errors.Annotate(err, "error generating cloud-config")
}
cloudcfg.SetSystemUpdate(icfg.EnableOSRefreshUpdate)
cloudcfg.SetSystemUpgrade(icfg.EnableOSUpgrade)
udata, err := cloudconfig.NewUserdataConfig(icfg, cloudcfg)
if err != nil {
return "", errors.Annotate(err, "error generating cloud-config")
}
if err := udata.ConfigureJuju(); err != nil {
return "", errors.Annotate(err, "error generating cloud-config")
}
configScript, err := cloudcfg.RenderScript()
if err != nil {
return "", errors.Annotate(err, "error converting cloud-config to script")
}
var buf bytes.Buffer
// Always remove the cloud-init-output.log file first, if it exists.
fmt.Fprintf(&buf, "rm -f %s\n", utils.ShQuote(icfg.CloudInitOutputLog))
// If something goes wrong, dump cloud-init-output.log to stderr.
buf.WriteString(shell.DumpFileOnErrorScript(icfg.CloudInitOutputLog))
buf.WriteString(configScript)
return buf.String(), nil
}
开发者ID:imoapps,项目名称:juju,代码行数:32,代码来源:provisioner.go
示例7: ComposeUserData
// ComposeUserData fills out the provided cloudinit configuration structure
// so it is suitable for initialising a machine with the given configuration,
// and then renders it and encodes it using the supplied renderer.
// When calling ComposeUserData a encoding implementation must be chosen from
// the providerinit/encoders package according to the need of the provider.
//
// If the provided cloudcfg is nil, a new one will be created internally.
func ComposeUserData(icfg *instancecfg.InstanceConfig, cloudcfg cloudinit.CloudConfig, renderer renderers.ProviderRenderer) ([]byte, error) {
if cloudcfg == nil {
var err error
cloudcfg, err = cloudinit.New(icfg.Series)
if err != nil {
return nil, errors.Trace(err)
}
}
_, err := configureCloudinit(icfg, cloudcfg)
if err != nil {
return nil, errors.Trace(err)
}
operatingSystem, err := series.GetOSFromSeries(icfg.Series)
if err != nil {
return nil, errors.Trace(err)
}
// This might get replaced by a renderer.RenderUserdata which will either
// render it as YAML or Bash since some CentOS images might ship without cloudnit
udata, err := cloudcfg.RenderYAML()
if err != nil {
return nil, errors.Trace(err)
}
udata, err = renderer.EncodeUserdata(udata, operatingSystem)
if err != nil {
return nil, errors.Trace(err)
}
logger.Tracef("Generated cloud init:\n%s", string(udata))
return udata, err
}
开发者ID:kakamessi99,项目名称:juju,代码行数:36,代码来源:providerinit.go
示例8: TestSetOutput
func (S) TestSetOutput(c *gc.C) {
type test struct {
kind cloudinit.OutputKind
stdout string
stderr string
}
tests := []test{{
cloudinit.OutAll, "a", "",
}, {
cloudinit.OutAll, "", "b",
}, {
cloudinit.OutInit, "a", "b",
}, {
cloudinit.OutAll, "a", "b",
}, {
cloudinit.OutAll, "", "",
}}
cfg, err := cloudinit.New("trusty")
c.Assert(err, jc.ErrorIsNil)
stdout, stderr := cfg.Output(cloudinit.OutAll)
c.Assert(stdout, gc.Equals, "")
c.Assert(stderr, gc.Equals, "")
for i, t := range tests {
c.Logf("test %d: %+v", i, t)
cfg.SetOutput(t.kind, t.stdout, t.stderr)
stdout, stderr = cfg.Output(t.kind)
c.Assert(stdout, gc.Equals, t.stdout)
c.Assert(stderr, gc.Equals, t.stderr)
}
}
开发者ID:imoapps,项目名称:juju,代码行数:31,代码来源:cloudinit_test.go
示例9: TestSetUbuntuUserPreciseNoKeys
func (*cloudinitSuite) TestSetUbuntuUserPreciseNoKeys(c *gc.C) {
ci, err := cloudinit.New("precise")
c.Assert(err, jc.ErrorIsNil)
cloudconfig.SetUbuntuUser(ci, "")
data, err := ci.RenderYAML()
c.Assert(err, jc.ErrorIsNil)
c.Assert(string(data), jc.YAMLEquals, map[string]interface{}{})
}
开发者ID:imoapps,项目名称:juju,代码行数:8,代码来源:userdatacfg_test.go
示例10: TestCloudInit
// TestCloudInit checks that the output from the various tests
// in cloudinitTests is well formed.
func (*cloudinitSuite) TestCloudInit(c *gc.C) {
for i, test := range cloudinitTests {
c.Logf("test %d", i)
var envConfig *config.Config
if test.setEnvConfig {
envConfig = minimalEnvironConfig(c)
}
testConfig := test.cfg.maybeSetEnvironConfig(envConfig).render()
ci, err := cloudinit.New(testConfig.Series)
c.Assert(err, jc.ErrorIsNil)
udata, err := cloudconfig.NewUserdataConfig(&testConfig, ci)
c.Assert(err, jc.ErrorIsNil)
err = udata.Configure()
c.Assert(err, jc.ErrorIsNil)
c.Check(ci, gc.NotNil)
// render the cloudinit config to bytes, and then
// back to a map so we can introspect it without
// worrying about internal details of the cloudinit
// package.
data, err := ci.RenderYAML()
c.Assert(err, jc.ErrorIsNil)
configKeyValues := make(map[interface{}]interface{})
err = goyaml.Unmarshal(data, &configKeyValues)
c.Assert(err, jc.ErrorIsNil)
if testConfig.EnableOSRefreshUpdate {
c.Check(configKeyValues["package_update"], jc.IsTrue)
} else {
c.Check(configKeyValues["package_update"], jc.IsFalse)
}
if testConfig.EnableOSUpgrade {
c.Check(configKeyValues["package_upgrade"], jc.IsTrue)
} else {
c.Check(configKeyValues["package_upgrade"], jc.IsFalse)
}
scripts := getScripts(configKeyValues)
assertScriptMatch(c, scripts, test.expectScripts, !test.inexactMatch)
if testConfig.Config != nil {
checkEnvConfig(c, testConfig.Config, configKeyValues, scripts)
}
// curl should always be installed, since it's required by jujud.
checkPackage(c, configKeyValues, "curl", true)
tag := names.NewMachineTag(testConfig.MachineId).String()
acfg := getAgentConfig(c, tag, scripts)
c.Assert(acfg, jc.Contains, "AGENT_SERVICE_NAME: jujud-"+tag)
c.Assert(acfg, jc.Contains, "upgradedToVersion: 1.2.3\n")
source := "deb http://ubuntu-cloud.archive.canonical.com/ubuntu precise-updates/cloud-tools main"
needCloudArchive := testConfig.Series == "precise"
checkAptSource(c, configKeyValues, source, pacconf.UbuntuCloudArchiveSigningKey, needCloudArchive)
}
}
开发者ID:imoapps,项目名称:juju,代码行数:60,代码来源:userdatacfg_test.go
示例11: TestPackages
func (S) TestPackages(c *gc.C) {
cfg, err := cloudinit.New("precise")
c.Assert(err, jc.ErrorIsNil)
c.Assert(cfg.Packages(), gc.HasLen, 0)
cfg.AddPackage("a b c")
cfg.AddPackage("d!")
expectedPackages := []string{"a b c", "d!"}
c.Assert(cfg.Packages(), gc.DeepEquals, expectedPackages)
}
开发者ID:imoapps,项目名称:juju,代码行数:9,代码来源:cloudinit_test.go
示例12: GetCloudConfig
// GetCloudConfig implements ProviderConfigurator interface.
func (c *rackspaceConfigurator) GetCloudConfig(args environs.StartInstanceParams) (cloudinit.CloudConfig, error) {
cloudcfg, err := cloudinit.New(args.Tools.OneSeries())
if err != nil {
return nil, errors.Trace(err)
}
// Additional package required for sshInstanceConfigurator, to save
// iptables state between restarts.
cloudcfg.AddPackage("iptables-persistent")
return cloudcfg, nil
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:11,代码来源:provider_configurator.go
示例13: TestWindowsRender
func (S) TestWindowsRender(c *gc.C) {
compareOutput := "#ps1_sysnative\r\n\r\npowershell"
cfg, err := cloudinit.New("win8")
c.Assert(err, jc.ErrorIsNil)
cfg.AddRunCmd("powershell")
data, err := cfg.RenderYAML()
c.Assert(err, jc.ErrorIsNil)
c.Assert(data, gc.NotNil)
c.Assert(string(data), gc.Equals, compareOutput, gc.Commentf("test %q output differs", "windows renderer"))
}
开发者ID:imoapps,项目名称:juju,代码行数:10,代码来源:cloudinit_test.go
示例14: TestRunCmds
func (S) TestRunCmds(c *gc.C) {
cfg, err := cloudinit.New("precise")
c.Assert(err, jc.ErrorIsNil)
c.Assert(cfg.RunCmds(), gc.HasLen, 0)
cfg.AddScripts("a", "b")
cfg.AddRunCmd("e")
c.Assert(cfg.RunCmds(), gc.DeepEquals, []string{
"a", "b", "e",
})
}
开发者ID:imoapps,项目名称:juju,代码行数:10,代码来源:cloudinit_test.go
示例15: TestSetUbuntuUserCentOS
func (*cloudinitSuite) TestSetUbuntuUserCentOS(c *gc.C) {
ci, err := cloudinit.New("centos7")
c.Assert(err, jc.ErrorIsNil)
cloudconfig.SetUbuntuUser(ci, "akey\n#also\nbkey")
data, err := ci.RenderYAML()
c.Assert(err, jc.ErrorIsNil)
keys := []string{"akey", "bkey"}
expected := expectedUbuntuUser(cloudconfig.CentOSGroups, keys)
c.Assert(string(data), jc.YAMLEquals, expected)
}
开发者ID:imoapps,项目名称:juju,代码行数:10,代码来源:userdatacfg_test.go
示例16: TestSetUbuntuUserQuantal
func (*cloudinitSuite) TestSetUbuntuUserQuantal(c *gc.C) {
ci, err := cloudinit.New("quantal")
c.Assert(err, jc.ErrorIsNil)
cloudconfig.SetUbuntuUser(ci, "akey")
data, err := ci.RenderYAML()
c.Assert(err, jc.ErrorIsNil)
keys := []string{"akey"}
expected := expectedUbuntuUser(cloudconfig.UbuntuGroups, keys)
c.Assert(string(data), jc.YAMLEquals, expected)
}
开发者ID:imoapps,项目名称:juju,代码行数:10,代码来源:userdatacfg_test.go
示例17: TestCloudInitVerify
// TestCloudInitVerify checks that required fields are appropriately
// checked for by NewCloudInit.
func (*cloudinitSuite) TestCloudInitVerify(c *gc.C) {
cfg := &instancecfg.InstanceConfig{
Bootstrap: true,
StateServingInfo: stateServingInfo,
MachineId: "99",
Tools: newSimpleTools("9.9.9-quantal-arble"),
AuthorizedKeys: "sshkey1",
Series: "quantal",
AgentEnvironment: map[string]string{agent.ProviderType: "dummy"},
MongoInfo: &mongo.MongoInfo{
Info: mongo.Info{
Addrs: []string{"host:98765"},
CACert: testing.CACert,
},
Password: "password",
},
APIInfo: &api.Info{
Addrs: []string{"host:9999"},
CACert: testing.CACert,
ModelTag: testing.ModelTag,
},
Config: minimalModelConfig(c),
HostedModelConfig: map[string]interface{}{"name": "hosted-model"},
DataDir: jujuDataDir("quantal"),
LogDir: jujuLogDir("quantal"),
MetricsSpoolDir: metricsSpoolDir("quantal"),
Jobs: normalMachineJobs,
CloudInitOutputLog: cloudInitOutputLog("quantal"),
InstanceId: "i-bootstrap",
MachineNonce: "FAKE_NONCE",
MachineAgentServiceName: "jujud-machine-99",
}
// check that the base configuration does not give an error
ci, err := cloudinit.New("quantal")
c.Assert(err, jc.ErrorIsNil)
for i, test := range verifyTests {
// check that the base configuration does not give an error
// and that a previous test hasn't mutated it accidentially.
udata, err := cloudconfig.NewUserdataConfig(cfg, ci)
c.Assert(err, jc.ErrorIsNil)
err = udata.Configure()
c.Assert(err, jc.ErrorIsNil)
c.Logf("test %d. %s", i, test.err)
cfg1 := *cfg
test.mutate(&cfg1)
udata, err = cloudconfig.NewUserdataConfig(&cfg1, ci)
c.Assert(err, jc.ErrorIsNil)
err = udata.Configure()
c.Check(err, gc.ErrorMatches, "invalid machine configuration: "+test.err)
}
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:57,代码来源:userdatacfg_test.go
示例18: TemplateUserData
// TemplateUserData returns a minimal user data necessary for the template.
// This should have the authorized keys, base packages, the cloud archive if
// necessary, initial apt proxy config, and it should do the apt-get
// update/upgrade initially.
func TemplateUserData(
series string,
authorizedKeys string,
aptProxy proxy.Settings,
aptMirror string,
enablePackageUpdates bool,
enableOSUpgrades bool,
networkConfig *container.NetworkConfig,
) ([]byte, error) {
var config cloudinit.CloudConfig
var err error
if networkConfig != nil {
config, err = newCloudInitConfigWithNetworks(series, networkConfig)
if err != nil {
return nil, errors.Trace(err)
}
} else {
config, err = cloudinit.New(series)
if err != nil {
return nil, errors.Trace(err)
}
}
cloudconfig.SetUbuntuUser(config, authorizedKeys)
config.AddScripts(
"set -xe", // ensure we run all the scripts or abort.
)
// For LTS series which need support for the cloud-tools archive,
// we need to enable apt-get update regardless of the environ
// setting, otherwise provisioning will fail.
if series == "precise" && !enablePackageUpdates {
logger.Warningf("series %q requires cloud-tools archive: enabling updates", series)
enablePackageUpdates = true
}
if enablePackageUpdates && config.RequiresCloudArchiveCloudTools() {
config.AddCloudArchiveCloudTools()
}
config.AddPackageCommands(aptProxy, aptMirror, enablePackageUpdates, enableOSUpgrades)
initSystem, err := service.VersionInitSystem(series)
if err != nil {
return nil, errors.Trace(err)
}
cmds, err := shutdownInitCommands(initSystem, series)
if err != nil {
return nil, errors.Trace(err)
}
config.AddScripts(strings.Join(cmds, "\n"))
data, err := config.RenderYAML()
if err != nil {
return nil, err
}
return data, nil
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:59,代码来源:container_userdata.go
示例19: TestWriteCommands
func (*formatSuite) TestWriteCommands(c *gc.C) {
cloudcfg, err := cloudinit.New("quantal")
c.Assert(err, jc.ErrorIsNil)
config := newTestConfig(c)
commands, err := config.WriteCommands(cloudcfg.ShellRenderer())
c.Assert(err, jc.ErrorIsNil)
c.Assert(commands, gc.HasLen, 3)
c.Assert(commands[0], gc.Matches, `mkdir -p '\S+/agents/machine-1'`)
c.Assert(commands[1], gc.Matches, `cat > '\S+/agents/machine-1/agent.conf' << 'EOF'\n(.|\n)*\nEOF`)
c.Assert(commands[2], gc.Matches, `chmod 0600 '\S+/agents/machine-1/agent.conf'`)
}
开发者ID:exekias,项目名称:juju,代码行数:11,代码来源:format_whitebox_test.go
示例20: TestSetUbuntuUserPrecise
func (*cloudinitSuite) TestSetUbuntuUserPrecise(c *gc.C) {
ci, err := cloudinit.New("precise")
c.Assert(err, jc.ErrorIsNil)
cloudconfig.SetUbuntuUser(ci, "akey")
data, err := ci.RenderYAML()
c.Assert(err, jc.ErrorIsNil)
expected := map[string]interface{}{"ssh_authorized_keys": []string{
"akey",
}}
c.Assert(string(data), jc.YAMLEquals, expected)
}
开发者ID:imoapps,项目名称:juju,代码行数:11,代码来源:userdatacfg_test.go
注:本文中的github.com/juju/juju/cloudconfig/cloudinit.New函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论