本文整理汇总了Golang中github.com/juju/juju/service.VersionInitSystem函数的典型用法代码示例。如果您正苦于以下问题:Golang VersionInitSystem函数的具体用法?Golang VersionInitSystem怎么用?Golang VersionInitSystem使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了VersionInitSystem函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestVersionInitSystem
func (s *discoverySuite) TestVersionInitSystem(c *gc.C) {
for _, test := range discoveryTests {
test.log(c)
initSystem, err := service.VersionInitSystem(test.series)
test.checkInitSystem(c, initSystem, err)
}
}
示例2: 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
}
示例3: TestVersionInitSystemNoLegacyUpstart
func (s *discoverySuite) TestVersionInitSystemNoLegacyUpstart(c *gc.C) {
s.unsetLegacyUpstart(c)
test := discoveryTest{
os: jujuos.Ubuntu,
series: "vivid",
expected: service.InitSystemSystemd,
}
vers := test.setVersion(s)
initSystem, err := service.VersionInitSystem(vers.Series)
test.checkInitSystem(c, initSystem, err)
}
示例4: ConfigureBasic
// ConfigureBasic updates the provided cloudinit.Config with
// basic configuration to initialise an OS image, such that it can
// be connected to via SSH, and log to a standard location.
//
// Any potentially failing operation should not be added to the
// configuration, but should instead be done in ConfigureJuju.
//
// Note: we don't do apt update/upgrade here so as not to have to wait on
// apt to finish when performing the second half of image initialisation.
// Doing it later brings the benefit of feedback in the face of errors,
// but adds to the running time of initialisation due to lack of activity
// between image bringup and start of agent installation.
func (w *unixConfigure) ConfigureBasic() error {
w.conf.AddScripts(
"set -xe", // ensure we run all the scripts or abort.
)
switch w.os {
case os.Ubuntu:
w.conf.AddSSHAuthorizedKeys(w.icfg.AuthorizedKeys)
if w.icfg.Tools != nil {
initSystem, err := service.VersionInitSystem(w.icfg.Series)
if err != nil {
return errors.Trace(err)
}
w.addCleanShutdownJob(initSystem)
}
// On unix systems that are not ubuntu we create an ubuntu user so that we
// are able to ssh in the machine and have all the functionality dependant
// on having an ubuntu user there.
// Hopefully in the future we are going to move all the distirbutions to
// having a "juju" user
case os.CentOS:
w.conf.AddScripts(
fmt.Sprintf(initUbuntuScript, utils.ShQuote(w.icfg.AuthorizedKeys)),
// Mask and stop firewalld, if enabled, so it cannot start. See
// http://pad.lv/1492066. firewalld might be missing, in which case
// is-enabled and is-active prints an error, which is why the output
// is surpressed.
"systemctl is-enabled firewalld &> /dev/null && systemctl mask firewalld || true",
"systemctl is-active firewalld &> /dev/null && systemctl stop firewalld || true",
`sed -i "s/^.*requiretty/#Defaults requiretty/" /etc/sudoers`,
)
w.addCleanShutdownJob(service.InitSystemSystemd)
}
w.conf.SetOutput(cloudinit.OutAll, "| tee -a "+w.icfg.CloudInitOutputLog, "")
// Create a file in a well-defined location containing the machine's
// nonce. The presence and contents of this file will be verified
// during bootstrap.
//
// Note: this must be the last runcmd we do in ConfigureBasic, as
// the presence of the nonce file is used to gate the remainder
// of synchronous bootstrap.
noncefile := path.Join(w.icfg.DataDir, NonceFile)
w.conf.AddRunTextFile(noncefile, w.icfg.MachineNonce, 0644)
return nil
}
示例5: ConfigureBasic
// ConfigureBasic updates the provided cloudinit.Config with
// basic configuration to initialise an OS image, such that it can
// be connected to via SSH, and log to a standard location.
//
// Any potentially failing operation should not be added to the
// configuration, but should instead be done in ConfigureJuju.
//
// Note: we don't do apt update/upgrade here so as not to have to wait on
// apt to finish when performing the second half of image initialisation.
// Doing it later brings the benefit of feedback in the face of errors,
// but adds to the running time of initialisation due to lack of activity
// between image bringup and start of agent installation.
func (w *unixConfigure) ConfigureBasic() error {
w.conf.AddScripts(
"set -xe", // ensure we run all the scripts or abort.
)
switch w.os {
case os.Ubuntu:
if (w.icfg.AgentVersion() != version.Binary{}) {
initSystem, err := service.VersionInitSystem(w.icfg.Series)
if err != nil {
return errors.Trace(err)
}
w.addCleanShutdownJob(initSystem)
}
case os.CentOS:
w.conf.AddScripts(
// Mask and stop firewalld, if enabled, so it cannot start. See
// http://pad.lv/1492066. firewalld might be missing, in which case
// is-enabled and is-active prints an error, which is why the output
// is surpressed.
"systemctl is-enabled firewalld &> /dev/null && systemctl mask firewalld || true",
"systemctl is-active firewalld &> /dev/null && systemctl stop firewalld || true",
`sed -i "s/^.*requiretty/#Defaults requiretty/" /etc/sudoers`,
)
w.addCleanShutdownJob(service.InitSystemSystemd)
}
SetUbuntuUser(w.conf, w.icfg.AuthorizedKeys)
w.conf.SetOutput(cloudinit.OutAll, "| tee -a "+w.icfg.CloudInitOutputLog, "")
// Create a file in a well-defined location containing the machine's
// nonce. The presence and contents of this file will be verified
// during bootstrap.
//
// Note: this must be the last runcmd we do in ConfigureBasic, as
// the presence of the nonce file is used to gate the remainder
// of synchronous bootstrap.
noncefile := path.Join(w.icfg.DataDir, NonceFile)
w.conf.AddRunTextFile(noncefile, w.icfg.MachineNonce, 0644)
return nil
}
示例6: TestDiscoverServiceLocalHost
func (s *discoverySuite) TestDiscoverServiceLocalHost(c *gc.C) {
var localInitSystem string
var err error
switch runtime.GOOS {
case "windows":
localInitSystem = service.InitSystemWindows
case "linux":
localInitSystem, err = service.VersionInitSystem(series.HostSeries())
}
c.Assert(err, gc.IsNil)
test := discoveryTest{
os: jujuos.HostOS(),
series: series.HostSeries(),
expected: localInitSystem,
}
test.disableVersionDiscovery(s)
svc, err := service.DiscoverService(s.name, s.conf)
c.Assert(err, jc.ErrorIsNil)
test.checkService(c, svc, err, s.name, s.conf)
}