Пример #1
0
// VerifyKVMEnabled makes sure that the host OS is Ubuntu, and that the required
// packages are installed, and that the host CPU is able to support KVM.
func VerifyKVMEnabled() error {
	pacman, err := getPackageManager()
	if err != nil {
		return err
	}

	if !utils.IsUbuntu() {
		return fmt.Errorf(kvmNeedsUbuntu)
	}
	supported, err := IsKVMSupported()
	if err != nil {
		// Missing the kvm-ok package.
		return fmt.Errorf(needToInstallKVMOk)
	}
	if !supported {
		return fmt.Errorf(kvmNotSupported)
	}
	// Check for other packages needed.
	toInstall := []string{}
	for _, pkg := range requiredPackages {
		if !pacman.IsInstalled(pkg) {
			toInstall = append(toInstall, pkg)
		}
	}
	if len(toInstall) > 0 {
		return fmt.Errorf(missingKVMDeps, strings.Join(toInstall, " "))
	}
	return nil
}
Пример #2
0
func (s *IsUbuntuSuite) TestIsNotUbuntu(c *gc.C) {
	s.patchLsbRelease(c, "Windows NT")
	c.Assert(utils.IsUbuntu(), jc.IsFalse)
}
Пример #3
0
func (s *IsUbuntuSuite) TestIsNotUbuntuLsbReleaseNotFound(c *gc.C) {
	if runtime.GOOS != "windows" {
		s.patchLsbRelease(c, "exit 127")
	}
	c.Assert(utils.IsUbuntu(), jc.IsFalse)
}
Пример #4
0
func (s *IsUbuntuSuite) TestIsUbuntu(c *gc.C) {
	s.patchLsbRelease(c, "Ubuntu")
	c.Assert(utils.IsUbuntu(), jc.IsTrue)
}
Пример #5
0
func wrapLxcNotFound(err error) error {
	if utils.IsUbuntu() {
		return fmt.Errorf("%v\n%s", err, installLxcUbuntu)
	}
	return fmt.Errorf("%v\n%s", err, installLxcGeneric)
}