当前位置: 首页>>代码示例>>Golang>>正文


Golang kvm.IsKVMSupported函数代码示例

本文整理汇总了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")
}
开发者ID:claudiu-coblis,项目名称:juju,代码行数:10,代码来源:kvm_test.go

示例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)
}
开发者ID:claudiu-coblis,项目名称:juju,代码行数:12,代码来源:kvm_test.go

示例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")
}
开发者ID:claudiu-coblis,项目名称:juju,代码行数:15,代码来源:kvm_test.go

示例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)
}
开发者ID:zhouqt,项目名称:juju,代码行数:17,代码来源:machine.go


注:本文中的github.com/juju/juju/container/kvm.IsKVMSupported函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。