本文整理汇总了Golang中github.com/juju/utils/series.HostSeries函数的典型用法代码示例。如果您正苦于以下问题:Golang HostSeries函数的具体用法?Golang HostSeries怎么用?Golang HostSeries使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了HostSeries函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestMissingAttributes
func (s *format_1_18Suite) TestMissingAttributes(c *gc.C) {
logDir, err := paths.LogDir(series.HostSeries())
c.Assert(err, jc.ErrorIsNil)
realDataDir, err := paths.DataDir(series.HostSeries())
c.Assert(err, jc.ErrorIsNil)
realDataDir = filepath.FromSlash(realDataDir)
logPath := filepath.Join(logDir, "juju")
logPath = filepath.FromSlash(logPath)
dataDir := c.MkDir()
configPath := filepath.Join(dataDir, agentConfigFilename)
err = utils.AtomicWriteFile(configPath, []byte(configData1_18WithoutUpgradedToVersion), 0600)
c.Assert(err, jc.ErrorIsNil)
readConfig, err := ReadConfig(configPath)
c.Assert(err, jc.ErrorIsNil)
c.Assert(readConfig.UpgradedToVersion(), gc.Equals, version.MustParse("1.16.0"))
configLogDir := filepath.FromSlash(readConfig.LogDir())
configDataDir := filepath.FromSlash(readConfig.DataDir())
c.Assert(configLogDir, gc.Equals, logPath)
c.Assert(configDataDir, gc.Equals, realDataDir)
c.Assert(readConfig.PreferIPv6(), jc.IsFalse)
// The api info doesn't have the environment tag set.
apiInfo, ok := readConfig.APIInfo()
c.Assert(ok, jc.IsTrue)
c.Assert(apiInfo.EnvironTag.Id(), gc.Equals, "")
}
示例2: TestMissingAttributes
func (s *format_1_16Suite) TestMissingAttributes(c *gc.C) {
logDir, err := paths.LogDir(series.HostSeries())
c.Assert(err, jc.ErrorIsNil)
realDataDir, err := paths.DataDir(series.HostSeries())
c.Assert(err, jc.ErrorIsNil)
realDataDir = filepath.FromSlash(realDataDir)
logPath := filepath.Join(logDir, "juju")
logPath = filepath.FromSlash(logPath)
dataDir := c.MkDir()
formatPath := filepath.Join(dataDir, legacyFormatFilename)
err = utils.AtomicWriteFile(formatPath, []byte(legacyFormatFileContents), 0600)
c.Assert(err, jc.ErrorIsNil)
configPath := filepath.Join(dataDir, agentConfigFilename)
err = utils.AtomicWriteFile(configPath, []byte(configDataWithoutNewAttributes), 0600)
c.Assert(err, jc.ErrorIsNil)
readConfig, err := ReadConfig(configPath)
c.Assert(err, jc.ErrorIsNil)
c.Assert(readConfig.UpgradedToVersion(), gc.Equals, version.MustParse("1.16.0"))
configLogDir := filepath.FromSlash(readConfig.LogDir())
configDataDir := filepath.FromSlash(readConfig.DataDir())
c.Assert(configLogDir, gc.Equals, logPath)
c.Assert(configDataDir, gc.Equals, realDataDir)
// Test data doesn't include a StateServerKey so StateServingInfo
// should *not* be available
_, available := readConfig.StateServingInfo()
c.Assert(available, jc.IsFalse)
}
示例3: Bootstrap
// Bootstrap is specified in the Environ interface.
func (env *localEnviron) Bootstrap(ctx environs.BootstrapContext, args environs.BootstrapParams) (*environs.BootstrapResult, error) {
if err := ensureNotRoot(); err != nil {
return nil, err
}
// Make sure there are tools available for the
// host's architecture and series.
if _, err := args.AvailableTools.Match(tools.Filter{
Arch: arch.HostArch(),
Series: series.HostSeries(),
}); err != nil {
return nil, err
}
cfg, err := env.Config().Apply(map[string]interface{}{
// Record the bootstrap IP, so the containers know where to go for storage.
"bootstrap-ip": env.bridgeAddress,
})
if err == nil {
err = env.SetConfig(cfg)
}
if err != nil {
logger.Errorf("failed to apply bootstrap-ip to config: %v", err)
return nil, err
}
result := &environs.BootstrapResult{
Arch: arch.HostArch(),
Series: series.HostSeries(),
Finalize: env.finishBootstrap,
}
return result, nil
}
示例4: testFindToolsExact
func (s *toolsSuite) testFindToolsExact(c *gc.C, t common.ToolsStorageGetter, inStorage bool, develVersion bool) {
var called bool
s.PatchValue(common.EnvtoolsFindTools, func(e environs.Environ, major, minor int, stream string, filter coretools.Filter) (list coretools.List, err error) {
called = true
c.Assert(filter.Number, gc.Equals, version.Current)
c.Assert(filter.Series, gc.Equals, series.HostSeries())
c.Assert(filter.Arch, gc.Equals, arch.HostArch())
if develVersion {
c.Assert(stream, gc.Equals, "devel")
} else {
c.Assert(stream, gc.Equals, "released")
}
return nil, errors.NotFoundf("tools")
})
toolsFinder := common.NewToolsFinder(s.State, t, sprintfURLGetter("tools:%s"))
result, err := toolsFinder.FindTools(params.FindToolsParams{
Number: version.Current,
MajorVersion: -1,
MinorVersion: -1,
Series: series.HostSeries(),
Arch: arch.HostArch(),
})
c.Assert(err, jc.ErrorIsNil)
if inStorage {
c.Assert(result.Error, gc.IsNil)
c.Assert(called, jc.IsFalse)
} else {
c.Assert(result.Error, gc.ErrorMatches, "tools not found")
c.Assert(called, jc.IsTrue)
}
}
示例5: TestUploadFakeSeries
func (s *uploadSuite) TestUploadFakeSeries(c *gc.C) {
seriesToUpload := "precise"
if seriesToUpload == series.HostSeries() {
seriesToUpload = "raring"
}
t, err := sync.Upload(s.targetStorage, "released", nil, "quantal", seriesToUpload)
c.Assert(err, jc.ErrorIsNil)
s.assertUploadedTools(c, t, []string{seriesToUpload, "quantal", series.HostSeries()}, "released")
}
示例6: TestSyncToolsFakeSeries
func (s *uploadSuite) TestSyncToolsFakeSeries(c *gc.C) {
seriesToUpload := "precise"
if seriesToUpload == series.HostSeries() {
seriesToUpload = "raring"
}
builtTools, err := sync.BuildToolsTarball(nil, "testing")
c.Assert(err, jc.ErrorIsNil)
t, err := sync.SyncBuiltTools(s.targetStorage, "testing", builtTools, "quantal", seriesToUpload)
c.Assert(err, jc.ErrorIsNil)
s.assertUploadedTools(c, t, []string{seriesToUpload, "quantal", series.HostSeries()}, "testing")
}
示例7: AddDefaultToolsToState
// AddDefaultToolsToState adds tools to tools storage for
// {Number: jujuversion.Current.Number, Arch: amd64}, for the
// "precise" series and the environment's preferred series.
// The preferred series is default-series if specified,
// otherwise the latest LTS.
func (s *JujuConnSuite) AddDefaultToolsToState(c *gc.C) {
preferredVersion := version.Binary{
Number: jujuversion.Current,
Arch: "amd64",
Series: series.HostSeries(),
}
current := version.Binary{
Number: jujuversion.Current,
Arch: arch.HostArch(),
Series: series.HostSeries(),
}
versions := PreferredDefaultVersions(s.Environ.Config(), preferredVersion)
versions = append(versions, current)
s.AddToolsToState(c, versions...)
}
示例8: SetUpTest
func (s *syslogSuite) SetUpTest(c *gc.C) {
if runtime.GOOS != "linux" {
c.Skip(fmt.Sprintf("this test requires a controller, therefore does not support %q", runtime.GOOS))
}
currentSeries := series.HostSeries()
osFromSeries, err := series.GetOSFromSeries(currentSeries)
c.Assert(err, jc.ErrorIsNil)
if osFromSeries != os.Ubuntu {
c.Skip(fmt.Sprintf("this test requires a controller, therefore does not support OS %q only Ubuntu", osFromSeries.String()))
}
s.AgentSuite.SetUpTest(c)
// TODO(perrito666) 200160701:
// This needs to be done to stop the test from trying to install mongo
// while running, but it is a huge footprint for such little benefit.
// This test should not need JujuConnSuite or AgentSuite.
s.fakeEnsureMongo = agenttest.InstallFakeEnsureMongo(s)
done := make(chan struct{})
s.received = make(chan rfc5424test.Message)
addr := s.createSyslogServer(c, s.received, done)
// Leave log forwarding disabled initially, it will be enabled
// via a model config update in the test.
err = s.State.UpdateModelConfig(map[string]interface{}{
"syslog-host": addr,
"syslog-ca-cert": coretesting.CACert,
"syslog-client-cert": coretesting.ServerCert,
"syslog-client-key": coretesting.ServerKey,
}, nil, nil)
c.Assert(err, jc.ErrorIsNil)
s.logsCh, err = logsender.InstallBufferedLogWriter(1000)
c.Assert(err, jc.ErrorIsNil)
}
示例9: SetUpTest
func (s *UpgradeSuite) SetUpTest(c *gc.C) {
s.StateSuite.SetUpTest(c)
s.preUpgradeError = false
// Most of these tests normally finish sub-second on a fast machine.
// If any given test hits a minute, we have almost certainly become
// wedged, so dump the logs.
coretesting.DumpTestLogsAfter(time.Minute, c, s)
s.oldVersion = version.Binary{
Number: version.Current,
Arch: arch.HostArch(),
Series: series.HostSeries(),
}
s.oldVersion.Major = 1
s.oldVersion.Minor = 16
// Don't wait so long in tests.
s.PatchValue(&UpgradeStartTimeoutMaster, time.Duration(time.Millisecond*50))
s.PatchValue(&UpgradeStartTimeoutSecondary, time.Duration(time.Millisecond*60))
// Allow tests to make the API connection appear to be dead.
s.connectionDead = false
s.PatchValue(&cmdutil.ConnectionIsDead, func(loggo.Logger, cmdutil.Pinger) bool {
return s.connectionDead
})
s.machineIsMaster = true
fakeIsMachineMaster := func(*state.State, string) (bool, error) {
return s.machineIsMaster, nil
}
s.PatchValue(&IsMachineMaster, fakeIsMachineMaster)
}
示例10: TestSetTools
func (s *upgraderSuite) TestSetTools(c *gc.C) {
current := version.Binary{
Number: jujuversion.Current,
Arch: arch.HostArch(),
Series: series.HostSeries(),
}
_, err := s.rawMachine.AgentTools()
c.Assert(err, jc.Satisfies, errors.IsNotFound)
args := params.EntitiesVersion{
AgentTools: []params.EntityVersion{{
Tag: s.rawMachine.Tag().String(),
Tools: ¶ms.Version{
Version: current,
}},
},
}
results, err := s.upgrader.SetTools(args)
c.Assert(err, jc.ErrorIsNil)
c.Assert(results.Results, gc.HasLen, 1)
c.Assert(results.Results[0].Error, gc.IsNil)
// Check that the new value actually got set, we must Refresh because
// it was set on a different Machine object
err = s.rawMachine.Refresh()
c.Assert(err, jc.ErrorIsNil)
realTools, err := s.rawMachine.AgentTools()
c.Assert(err, jc.ErrorIsNil)
c.Check(realTools.Version, gc.Equals, current)
c.Check(realTools.URL, gc.Equals, "")
}
示例11: TestLxcContainerUsesImageURL
func (s *ContainerSetupSuite) TestLxcContainerUsesImageURL(c *gc.C) {
// create a machine to host the container.
m, err := s.BackingState.AddOneMachine(state.MachineTemplate{
Series: series.LatestLts(),
Jobs: []state.MachineJob{state.JobHostUnits},
Constraints: s.defaultConstraints,
})
c.Assert(err, jc.ErrorIsNil)
err = m.SetSupportedContainers([]instance.ContainerType{instance.LXC, instance.KVM})
c.Assert(err, jc.ErrorIsNil)
current := version.Binary{
Number: jujuversion.Current,
Arch: arch.HostArch(),
Series: series.HostSeries(),
}
err = m.SetAgentVersion(current)
c.Assert(err, jc.ErrorIsNil)
brokerCalled := false
newlxcbroker := func(api provisioner.APICalls, agentConfig agent.Config, managerConfig container.ManagerConfig,
imageURLGetter container.ImageURLGetter, enableNAT bool, defaultMTU int) (environs.InstanceBroker, error) {
imageURL, err := imageURLGetter.ImageURL(instance.LXC, "trusty", "amd64")
c.Assert(err, jc.ErrorIsNil)
c.Assert(imageURL, gc.Equals, "imageURL")
c.Assert(imageURLGetter.CACert(), gc.DeepEquals, []byte("cert"))
brokerCalled = true
return nil, fmt.Errorf("lxc broker error")
}
s.PatchValue(&provisioner.NewLxcBroker, newlxcbroker)
s.createContainer(c, m, instance.LXC)
c.Assert(brokerCalled, jc.IsTrue)
}
示例12: assertAgentSetsToolsVersion
func (s *MachineSuite) assertAgentSetsToolsVersion(c *gc.C, job state.MachineJob) {
vers := version.Binary{
Number: jujuversion.Current,
Arch: arch.HostArch(),
Series: series.HostSeries(),
}
vers.Minor++
m, _, _ := s.primeAgentVersion(c, vers, job)
a := s.newAgent(c, m)
go func() { c.Check(a.Run(nil), jc.ErrorIsNil) }()
defer func() { c.Check(a.Stop(), jc.ErrorIsNil) }()
timeout := time.After(coretesting.LongWait)
for done := false; !done; {
select {
case <-timeout:
c.Fatalf("timeout while waiting for agent version to be set")
case <-time.After(coretesting.ShortWait):
c.Log("Refreshing")
err := m.Refresh()
c.Assert(err, jc.ErrorIsNil)
c.Log("Fetching agent tools")
agentTools, err := m.AgentTools()
c.Assert(err, jc.ErrorIsNil)
c.Logf("(%v vs. %v)", agentTools.Version, jujuversion.Current)
if agentTools.Version.Minor != jujuversion.Current.Minor {
continue
}
c.Assert(agentTools.Version.Number, gc.DeepEquals, jujuversion.Current)
done = true
}
}
}
示例13: TestDefaultMTUPropagatedToNewLXCBroker
func (s *LXCDefaultMTUSuite) TestDefaultMTUPropagatedToNewLXCBroker(c *gc.C) {
// create a machine to host the container.
m, err := s.BackingState.AddOneMachine(state.MachineTemplate{
Series: coretesting.FakeDefaultSeries,
Jobs: []state.MachineJob{state.JobHostUnits},
Constraints: s.defaultConstraints,
})
c.Assert(err, jc.ErrorIsNil)
err = m.SetSupportedContainers([]instance.ContainerType{instance.LXC, instance.KVM})
c.Assert(err, jc.ErrorIsNil)
current := version.Binary{
Number: version.Current,
Arch: arch.HostArch(),
Series: series.HostSeries(),
}
err = m.SetAgentVersion(current)
c.Assert(err, jc.ErrorIsNil)
brokerCalled := false
newlxcbroker := func(api provisioner.APICalls, agentConfig agent.Config, managerConfig container.ManagerConfig, imageURLGetter container.ImageURLGetter, enableNAT bool, defaultMTU int) (environs.InstanceBroker, error) {
brokerCalled = true
c.Assert(defaultMTU, gc.Equals, 9000)
return nil, fmt.Errorf("lxc broker error")
}
s.PatchValue(&provisioner.NewLxcBroker, newlxcbroker)
s.createContainer(c, m, instance.LXC)
c.Assert(brokerCalled, jc.IsTrue)
}
示例14: getContainerInstance
func getContainerInstance() (cont []ContainerInstance, err error) {
current_os, err := series.GetOSFromSeries(series.HostSeries())
if err != nil {
return nil, err
}
switch current_os {
case jujuos.CentOS:
cont = []ContainerInstance{
{instance.LXC, [][]string{
{"lxc"},
{"cloud-image-utils"},
}},
{instance.KVM, [][]string{
{"uvtool-libvirt"},
{"uvtool"},
}},
}
default:
cont = []ContainerInstance{
{instance.LXC, [][]string{
{"--target-release", "precise-updates/cloud-tools", "lxc"},
{"--target-release", "precise-updates/cloud-tools", "cloud-image-utils"},
}},
{instance.KVM, [][]string{
{"uvtool-libvirt"},
{"uvtool"},
}},
}
}
return cont, nil
}
示例15: TestContainerInitLockError
func (s *ContainerSetupSuite) TestContainerInitLockError(c *gc.C) {
m, err := s.BackingState.AddOneMachine(state.MachineTemplate{
Series: coretesting.FakeDefaultSeries,
Jobs: []state.MachineJob{state.JobHostUnits},
Constraints: s.defaultConstraints,
})
c.Assert(err, jc.ErrorIsNil)
current := version.Binary{
Number: version.Current,
Arch: arch.HostArch(),
Series: series.HostSeries(),
}
err = m.SetAgentVersion(current)
c.Assert(err, jc.ErrorIsNil)
err = os.RemoveAll(s.initLockDir)
c.Assert(err, jc.ErrorIsNil)
handler, runner := s.setupContainerWorker(c, m.Tag().(names.MachineTag))
runner.Kill()
err = runner.Wait()
c.Assert(err, jc.ErrorIsNil)
_, err = handler.SetUp()
c.Assert(err, jc.ErrorIsNil)
err = handler.Handle([]string{"0/lxc/0"})
c.Assert(err, gc.ErrorMatches, ".*failed to acquire initialization lock:.*")
}