本文整理汇总了Golang中github.com/juju/juju/container/kvm.IsKVMSupported函数的典型用法代码示例。如果您正苦于以下问题:Golang IsKVMSupported函数的具体用法?Golang IsKVMSupported怎么用?Golang IsKVMSupported使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IsKVMSupported函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestIsKVMSupportedKvmOkNotFound
// Test the output when no binary can be found.
func (s *KVMSuite) TestIsKVMSupportedKvmOkNotFound(c *gc.C) {
// With no path, and no backup directory, we should fail.
s.PatchEnvironment("PATH", "")
s.PatchValue(kvm.KVMPath, "")
supported, err := kvm.IsKVMSupported()
c.Check(supported, jc.IsFalse)
c.Assert(err, gc.ErrorMatches, "kvm-ok executable not found")
}
示例2: TestIsKVMSupportedOnlyPath
// Test the case that kvm-ok is found in the path.
func (s *KVMSuite) TestIsKVMSupportedOnlyPath(c *gc.C) {
// Create a mocked binary so that this test does not fail for
// developers without kvm-ok.
tmpDir := c.MkDir()
err := ioutil.WriteFile(filepath.Join(tmpDir, "kvm-ok"), []byte("#!/bin/bash"), 0777)
s.PatchEnvironment("PATH", tmpDir)
supported, err := kvm.IsKVMSupported()
c.Check(supported, jc.IsTrue)
c.Assert(err, jc.ErrorIsNil)
}
示例3: TestIsKVMSupportedBinaryErrorsOut
// Test the output when the binary is found, but errors out.
func (s *KVMSuite) TestIsKVMSupportedBinaryErrorsOut(c *gc.C) {
// Clear path so real binary is not found.
s.PatchEnvironment("PATH", "")
// Create mocked binary which returns an error and give the test access.
tmpDir := c.MkDir()
err := ioutil.WriteFile(filepath.Join(tmpDir, "kvm-ok"), []byte("#!/bin/bash\nexit 127"), 0777)
c.Assert(err, jc.ErrorIsNil)
s.PatchValue(kvm.KVMPath, tmpDir)
supported, err := kvm.IsKVMSupported()
c.Check(supported, jc.IsFalse)
c.Assert(err, gc.ErrorMatches, "exit status 127")
}
示例4: setupContainerSupport
// setupContainerSupport determines what containers can be run on this machine and
// initialises suitable infrastructure to support such containers.
func (a *MachineAgent) setupContainerSupport(runner worker.Runner, st *api.State, entity *apiagent.Entity, agentConfig agent.Config) error {
var supportedContainers []instance.ContainerType
// We don't yet support nested lxc containers but anything else can run an LXC container.
if entity.ContainerType() != instance.LXC {
supportedContainers = append(supportedContainers, instance.LXC)
}
supportsKvm, err := kvm.IsKVMSupported()
if err != nil {
logger.Warningf("determining kvm support: %v\nno kvm containers possible", err)
}
if err == nil && supportsKvm {
supportedContainers = append(supportedContainers, instance.KVM)
}
return a.updateSupportedContainers(runner, st, entity.Tag(), supportedContainers, agentConfig)
}