Exemple #1
0
        public async Task WatchVirtualSystemSettingDataCreation_ExpectTheSameConfigurationIDInObjectResultedAsTheOneDefined()
        {
            var watcherTask = Task.Run(() =>
            {
                var sut = EventWatcherFactory.GetWatcher(Scope.Virtualization.ScopeObject, InstanceCreationEvent.ClassName, new TimeSpan(0, 0, 100), VirtualSystemSettingData.ClassName);

                var moInstanceCreationEvent = sut.WaitForNextEvent();

                sut.Stop();

                return(moInstanceCreationEvent);
            }).ConfigureAwait(true);

            using (var viridianUtils = new ViridianUtils())
            {
                viridianUtils.SUT_ComputerSystemMO(
                    ViridianUtils.GetCurrentMethod(),
                    out uint ReturnValue,
                    out ManagementPath Job,
                    out ManagementPath ResultingSystem);

                using (var instanceCreationEvent = new InstanceCreationEvent(await watcherTask))
                    using (var virtualSystemSettingDataFromEvent = new VirtualSystemSettingData(instanceCreationEvent.TargetInstance))
                        using (var computerSystemAsDefineSystemResult = new ComputerSystem(ResultingSystem))
                            using (var virtualSystemSettingDataFromResultingSystem = ViridianUtils.GetVirtualSystemSettingDataListThroughSettingsDefineState(computerSystemAsDefineSystemResult).First())
                            {
                                Assert.IsNotNull(virtualSystemSettingDataFromEvent);
                                Assert.IsTrue(string.Compare(virtualSystemSettingDataFromResultingSystem.ConfigurationID, virtualSystemSettingDataFromEvent.ConfigurationID, false, CultureInfo.InvariantCulture) == 0);
                            }

                Assert.AreEqual(0U, ReturnValue);
            }
        }
Exemple #2
0
 public static List <ProcessorSettingData> GetProcessorSettingDataList(VirtualSystemSettingData VirtualSystemSettingData)
 {
     return
         (VirtualSystemSettingDataComponent.GetInstances()
          .Cast <VirtualSystemSettingDataComponent>()
          .Where((sds) =>
                 string.Compare(sds.GroupComponent.Path, VirtualSystemSettingData.Path.Path, true, CultureInfo.InvariantCulture) == 0 &&
                 string.Compare(sds.PartComponent.ClassName, $"Msvm_{nameof(ProcessorSettingData)}", true, CultureInfo.InvariantCulture) == 0)
          .Select((sds) => new ProcessorSettingData(sds.PartComponent))
          .ToList());
 }
Exemple #3
0
        public void SUT_VirtualSystemSettingDataMO(string ElementName, ManagementPath AffectedSystem, out uint ReturnValue, out ManagementPath Job, out ManagementPath ResultingSnapshot)
        {
            using (var SnapshotSettingsInstance = VirtualSystemSettingData.CreateInstance())
            {
                SnapshotSettingsInstance.LateBoundObject["ElementName"]       = ElementName;
                SnapshotSettingsInstance.LateBoundObject["SnapshotDataRoot"]  = VSSS_SnapshotDataRoot;
                SnapshotSettingsInstance.LateBoundObject["VirtualSystemType"] = 5;

                ResultingSnapshot = null;
                string SnapshotSettings = SnapshotSettingsInstance.LateBoundObject.GetText(TextFormat.CimDtd20);
                ushort SnapshotType     = 2;
                ReturnValue = VSSS.CreateSnapshot(AffectedSystem, ref ResultingSnapshot, SnapshotSettings, SnapshotType, out Job);
            }
        }
Exemple #4
0
        public void SUT_ComputerSystemMO(string ElementName, out uint ReturnValue, out ManagementPath Job, out ManagementPath ResultingSystem)
        {
            using (var virtualSystemSettingData = VirtualSystemSettingData.CreateInstance())
            {
                virtualSystemSettingData.LateBoundObject["ElementName"]           = ElementName;
                virtualSystemSettingData.LateBoundObject["ConfigurationDataRoot"] = VSSD_ConfigurationDataRoot;
                virtualSystemSettingData.LateBoundObject["VirtualSystemSubtype"]  = VSSD_VirtualSystemSubtype;

                ManagementPath ReferenceConfiguration = null;
                string[]       ResourceSettings       = null;
                string         SystemSettings         = virtualSystemSettingData.LateBoundObject.GetText(TextFormat.WmiDtd20);

                ReturnValue = VSMS.DefineSystem(ReferenceConfiguration, ResourceSettings, SystemSettings, out Job, out ResultingSystem);

                VSSD_ToDestroy.Add(ResultingSystem);
            }
        }
Exemple #5
0
 public static List <EthernetPortAllocationSettingData> GetEthernetPortAllocationSettingData(VirtualSystemSettingData VirtualSystemSettingData, ushort ResourceType, string ResourceSubType)
 {
     return
         (VirtualSystemSettingDataComponent.GetInstances()
          .Cast <VirtualSystemSettingDataComponent>()
          .Where((sds) =>
                 string.Compare(sds.GroupComponent.Path, VirtualSystemSettingData.Path.Path, true, CultureInfo.InvariantCulture) == 0 &&
                 string.Compare(sds.PartComponent.ClassName, $"Msvm_{nameof(EthernetPortAllocationSettingData)}", true, CultureInfo.InvariantCulture) == 0)
          .Select((sds) => new EthernetPortAllocationSettingData(sds.PartComponent))
          .ToList()
          .Where((rasd) =>
                 rasd.ResourceType == ResourceType &&
                 string.Compare(rasd.ResourceSubType, ResourceSubType, true, CultureInfo.InvariantCulture) == 0)
          .ToList());
 }
Exemple #6
0
 public static GuestServiceInterfaceComponentSettingData GetGuestServiceInterfaceComponentSettingData(VirtualSystemSettingData VirtualSystemSettingData)
 {
     return
         (VirtualSystemSettingDataComponent.GetInstances()
          .Cast <VirtualSystemSettingDataComponent>()
          .Where((sds) =>
                 string.Compare(sds.GroupComponent.Path, VirtualSystemSettingData.Path.Path, true, CultureInfo.InvariantCulture) == 0 &&
                 string.Compare(sds.PartComponent.ClassName, $"Msvm_{nameof(GuestServiceInterfaceComponentSettingData)}", true, CultureInfo.InvariantCulture) == 0)
          .Select((sds) => new GuestServiceInterfaceComponentSettingData(sds.PartComponent))
          .ToList()
          .First());
 }
Exemple #7
0
        static public void GetVirtualSystemSettingData(Dictionary <string, string> args, string AssociationObjectName, out VirtualSystemSettingData VirtualSystemSettingData)
        {
            switch (AssociationObjectName)
            {
            case nameof(SettingsDefineState):
                VirtualSystemSettingData = SettingsDefineState.GetInstances()
                                           .Cast <SettingsDefineState>()
                                           .Where(sds =>
                {
                    return(args.ToList().All(pair =>
                    {
                        var propertyName = pair.Key;
                        var propertyValue = pair.Value;

                        switch (propertyName)
                        {
                        case nameof(sds.ManagedElement):
                            return string.Compare(sds.ManagedElement.Path, propertyValue, true, CultureInfo.InvariantCulture) == 0;

                        default:
                            throw new Exception("Property value not handled or invalid!");
                        }
                    }));
                })
                                           .Select((sds) => new VirtualSystemSettingData(sds.SettingData))
                                           .ToList()
                                           .First();
                break;

            default:
                throw new Exception("Property value not handled or invalid!");
            }
        }