예제 #1
0
 public void Run(
     [Values(cpu1, cpu2, cpu3, cpu4)] string featureSet1,
     [Values(cpu1, cpu2, cpu3, cpu4)] string featureSet2
     )
 {
     System.Console.WriteLine("Asserting {0} < {1}", featureSet1, featureSet2);
     Assert.AreEqual(
         Expected(featureSet1, featureSet2),
         PoolJoinRules.FewerFeatures(featureSet1, featureSet2), string.Format("Assertion failed on {0} < {1}", featureSet1, featureSet2));
 }
        public static bool VmCpuFeaturesIncompatibleWithHost(Host targetHost, VM vm)
        {
            // check the CPU feature compatibility for Dundee and higher hosts
            if (!Helpers.DundeeOrGreater(targetHost))
            {
                return(false);
            }

            Host home = vm.Home();

            if (home != null && !Helpers.DundeeOrGreater(home))
            {
                return(false);
            }

            if (home == null && !Helpers.DundeeOrGreater(vm.Connection))
            {
                return(false);
            }

            // only for running or suspended VMs
            if (vm.power_state != vm_power_state.Running && vm.power_state != vm_power_state.Suspended)
            {
                return(false);
            }

            if (vm.last_boot_CPU_flags == null || !vm.last_boot_CPU_flags.ContainsKey("vendor") || !vm.last_boot_CPU_flags.ContainsKey("features") ||
                targetHost.cpu_info == null || !targetHost.cpu_info.ContainsKey("vendor"))
            {
                return(false);
            }

            if (vm.last_boot_CPU_flags["vendor"] != targetHost.cpu_info["vendor"])
            {
                return(true);
            }

            if (vm.IsHVM() && targetHost.cpu_info.ContainsKey("features_hvm"))
            {
                return(PoolJoinRules.FewerFeatures(targetHost.cpu_info["features_hvm"], vm.last_boot_CPU_flags["features"]));
            }

            if (!vm.IsHVM() && targetHost.cpu_info.ContainsKey("features_pv"))
            {
                return(PoolJoinRules.FewerFeatures(targetHost.cpu_info["features_pv"], vm.last_boot_CPU_flags["features"]));
            }

            return(false);
        }
예제 #3
0
 public bool Run(string featureSet1, string featureSet2)
 {
     return(PoolJoinRules.FewerFeatures(featureSet1, featureSet2));
 }