Exemplo n.º 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 {
	if !utils.IsUbuntu() {
		return fmt.Errorf(kvmNeedsUbuntu)
	}
	supported, err := IsKVMSupported()
	if err != nil {
		// Missing the kvm-ok package.
		return fmt.Errorf(neetToInstallKVMOk)
	}
	if !supported {
		return fmt.Errorf(kvmNotSupported)
	}
	// Check for other packages needed.
	toInstall := []string{}
	for _, pkg := range requiredPackages {
		if !utils.IsPackageInstalled(pkg) {
			toInstall = append(toInstall, pkg)
		}
	}
	if len(toInstall) > 0 {
		return fmt.Errorf(missingKVMDeps, strings.Join(toInstall, " "))
	}
	return nil
}
Exemplo n.º 2
0
func (s *AptSuite) TestIsPackageNotInstalled(c *gc.C) {
	s.patchDpkgQuery(c, false)
	c.Assert(utils.IsPackageInstalled("foo-bar"), jc.IsFalse)
}