本文整理汇总了Golang中github.com/juju/juju/container/lxc.RestartSymlink函数的典型用法代码示例。如果您正苦于以下问题:Golang RestartSymlink函数的具体用法?Golang RestartSymlink怎么用?Golang RestartSymlink使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RestartSymlink函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestCreateContainerWithBlockStorage
func (s *LxcSuite) TestCreateContainerWithBlockStorage(c *gc.C) {
err := os.Remove(s.RestartDir)
c.Assert(err, jc.ErrorIsNil)
manager := s.makeManager(c, "test")
machineConfig, err := containertesting.MockMachineConfig("1/lxc/0")
c.Assert(err, jc.ErrorIsNil)
storageConfig := &container.StorageConfig{AllowMount: true}
networkConfig := container.BridgeNetworkConfig("nic42", 4321, nil)
instance := containertesting.CreateContainerWithMachineAndNetworkAndStorageConfig(c, manager, machineConfig, networkConfig, storageConfig)
name := string(instance.Id())
autostartLink := lxc.RestartSymlink(name)
config, err := ioutil.ReadFile(lxc.ContainerConfigFilename(name))
c.Assert(err, jc.ErrorIsNil)
expected := fmt.Sprintf(`
# network config
# interface "eth0"
lxc.network.type = veth
lxc.network.link = nic42
lxc.network.flags = up
lxc.network.mtu = 4321
lxc.start.auto = 1
lxc.mount.entry = %s var/log/juju none defaults,bind 0 0
lxc.aa_profile = lxc-container-default-with-mounting
lxc.cgroup.devices.allow = b 7:* rwm
lxc.cgroup.devices.allow = c 10:237 rwm
`, s.logDir)
c.Assert(string(config), gc.Equals, expected)
c.Assert(autostartLink, jc.DoesNotExist)
}
示例2: TestDestroyContainerRemovesAutostartLink
func (s *LxcSuite) TestDestroyContainerRemovesAutostartLink(c *gc.C) {
manager := s.makeManager(c, "test")
instance := containertesting.CreateContainer(c, manager, "1/lxc/0")
err := manager.DestroyContainer(instance.Id())
c.Assert(err, gc.IsNil)
autostartLink := lxc.RestartSymlink(string(instance.Id()))
c.Assert(autostartLink, jc.SymlinkDoesNotExist)
}
示例3: createTemplate
func (s *LxcSuite) createTemplate(c *gc.C) golxc.Container {
name := "juju-quantal-lxc-template"
ch := s.ensureTemplateStopped(name)
defer func() { <-ch }()
network := container.BridgeNetworkConfig("nic42", 4321, nil)
authorizedKeys := "authorized keys list"
aptProxy := proxy.Settings{}
aptMirror := "http://my.archive.ubuntu.com/ubuntu"
callback := func(containerStatus status.Status, info string, data map[string]interface{}) error { return nil }
template, err := lxc.EnsureCloneTemplate(
"ext4",
"quantal",
network,
authorizedKeys,
aptProxy,
aptMirror,
true,
true,
&containertesting.MockURLGetter{},
false,
callback,
)
c.Assert(err, jc.ErrorIsNil)
c.Assert(template.Name(), gc.Equals, name)
createEvent := <-s.events
c.Assert(createEvent.Action, gc.Equals, mock.Created)
c.Assert(createEvent.InstanceId, gc.Equals, name)
argsSet := set.NewStrings(createEvent.TemplateArgs...)
c.Assert(argsSet.Contains("imageURL"), jc.IsTrue)
s.AssertEvent(c, <-s.events, mock.Started, name)
s.AssertEvent(c, <-s.events, mock.Stopped, name)
autostartLink := lxc.RestartSymlink(name)
config, err := ioutil.ReadFile(lxc.ContainerConfigFilename(name))
c.Assert(err, jc.ErrorIsNil)
expected := `
# network config
# interface "eth0"
lxc.network.type = veth
lxc.network.link = nic42
lxc.network.flags = up
lxc.network.mtu = 4321
`
// NOTE: no autostart, no mounting the log dir
c.Assert(string(config), gc.Equals, expected)
c.Assert(autostartLink, jc.DoesNotExist)
return template
}
示例4: TestCreateContainerWithCloneMountsAndAutostarts
func (s *LxcSuite) TestCreateContainerWithCloneMountsAndAutostarts(c *gc.C) {
s.createTemplate(c)
s.PatchValue(&s.useClone, true)
manager := s.makeManager(c, "test")
instance := containertesting.CreateContainer(c, manager, "1")
name := string(instance.Id())
autostartLink := lxc.RestartSymlink(name)
config, err := ioutil.ReadFile(lxc.ContainerConfigFilename(name))
c.Assert(err, gc.IsNil)
mountLine := "lxc.mount.entry=/var/log/juju var/log/juju none defaults,bind 0 0"
c.Assert(string(config), jc.Contains, mountLine)
c.Assert(autostartLink, jc.IsSymlink)
}
示例5: TestCreateContainerNoRestartDir
func (s *LxcSuite) TestCreateContainerNoRestartDir(c *gc.C) {
err := os.Remove(s.RestartDir)
c.Assert(err, gc.IsNil)
manager := s.makeManager(c, "test")
instance := containertesting.CreateContainer(c, manager, "1/lxc/0")
name := string(instance.Id())
autostartLink := lxc.RestartSymlink(name)
config, err := ioutil.ReadFile(lxc.ContainerConfigFilename(name))
c.Assert(err, gc.IsNil)
expected := `
lxc.network.type = veth
lxc.network.link = nic42
lxc.network.flags = up
lxc.start.auto = 1
lxc.mount.entry=/var/log/juju var/log/juju none defaults,bind 0 0
`
c.Assert(string(config), gc.Equals, expected)
c.Assert(autostartLink, jc.DoesNotExist)
}
示例6: TestCreateContainerAutostarts
func (s *LxcSuite) TestCreateContainerAutostarts(c *gc.C) {
manager := s.makeManager(c, "test")
instance := containertesting.CreateContainer(c, manager, "1/lxc/0")
autostartLink := lxc.RestartSymlink(string(instance.Id()))
c.Assert(autostartLink, jc.IsSymlink)
}