예제 #1
0
        public ResourceAllocationSettingData GetScsiControllerSettings(VirtualSystemSettingData vmSettings)
        {
            var wmiObjCollection = GetResourceAllocationSettings(vmSettings);

            foreach (ResourceAllocationSettingData wmiObj in wmiObjCollection)
            {
                if (wmiObj.ResourceSubType == SCSI_CONTROLLER)
                {
                    return wmiObj;
                }
            }

            var errMsg = string.Format(
                                "Cannot find the Microsoft Synthetic SCSI Controller in VirtualSystemSettingData {1}",
                                vmSettings.Path.Path);
            var ex = new WmiException(errMsg);
            logger.Error(errMsg, ex);
            throw ex;
        }
예제 #2
0
        public ResourceAllocationSettingData GetIDEControllerSettings(VirtualSystemSettingData vmSettings, string cntrllerAddr)
        {
            var wmiObjCollection = GetResourceAllocationSettings(vmSettings);

            foreach (ResourceAllocationSettingData wmiObj in wmiObjCollection)
            {
                if (wmiObj.ResourceSubType == IDE_CONTROLLER && wmiObj.Address == cntrllerAddr)
                {
                    return wmiObj;
                }
            }

            var errMsg = string.Format(
                                "Cannot find the Microsoft Emulated IDE Controlle at address {0} in VirtualSystemSettingData {1}",
                                cntrllerAddr,
                                vmSettings.Path.Path);
            var ex = new WmiException(errMsg);
            logger.Error(errMsg, ex);
            throw ex;
        }
예제 #3
0
        /// <summary>
        /// VM resources, typically hardware a described by a generic MSVM_ResourceAllocationSettingData object.  The hardware type being 
        /// described is identified in two ways:  in general terms using an enum in the ResourceType field, and in terms of the implementation 
        /// using text in the ResourceSubType field.
        /// See http://msdn.microsoft.com/en-us/library/cc136877%28v=vs.85%29.aspx
        /// </summary>
        /// <param name="vmSettings"></param>
        /// <returns></returns>
        public ResourceAllocationSettingData.ResourceAllocationSettingDataCollection GetResourceAllocationSettings(VirtualSystemSettingData vmSettings)
        {
            // An ASSOCIATOR object provides the cross reference from the VirtualSystemSettingData and the
            // ResourceAllocationSettingData, but generated wrappers do not expose a ASSOCIATOR OF query as a method.
            // Instead, we use the System.Management to code the equivalant of
            //  string query = string.Format( "ASSOCIATORS OF {{{0}}} WHERE ResultClass = {1}", vmSettings.path, resultclassName);
            //
            var wmiObjQuery = new RelatedObjectQuery(vmSettings.Path.Path, ResourceAllocationSettingData.CreatedClassName);

            // NB: default scope of ManagementObjectSearcher is '\\.\root\cimv2', which does not contain
            // the virtualisation objects.
            var wmiObjectSearch = new ManagementObjectSearcher(vmSettings.Scope, wmiObjQuery);
            var wmiObjCollection = new ResourceAllocationSettingData.ResourceAllocationSettingDataCollection(wmiObjectSearch.Get());

            if (wmiObjCollection != null)
            {
                return wmiObjCollection;
            }

            var errMsg = string.Format("No ResourceAllocationSettingData in VirtualSystemSettingData {0}", vmSettings.Path.Path);
            var ex = new WmiException(errMsg);
            logger.Error(errMsg, ex);
            throw ex;
        }
예제 #4
0
        public ResourceAllocationSettingData GetDvdDriveSettings(VirtualSystemSettingData vmSettings)
        {
            var wmiObjCollection = GetResourceAllocationSettings(vmSettings);

            foreach (ResourceAllocationSettingData wmiObj in wmiObjCollection)
            {
                // DVD drive is '16', see http://msdn.microsoft.com/en-us/library/hh850200(v=vs.85).aspx
                if (wmiObj.ResourceType == 16)
                {
                    return wmiObj;
                }
            }

            var errMsg = string.Format(
                                "Cannot find the Dvd drive in VirtualSystemSettingData {0}",
                                vmSettings.Path.Path);
            var ex = new WmiException(errMsg);
            logger.Error(errMsg, ex);
            throw ex;
        }