示例#1
0
        public static SpacesApiError GetPhysicalDiskPool(string pdid, ref StoragePool pool)
        {
            SpacesApiError     spacesApiError = SpacesApiError.Success;
            List <StoragePool> list           = null;

            pool           = null;
            spacesApiError = SpacesApi.GetPhysicalDiskPools(pdid, ref list);
            if (spacesApiError == SpacesApiError.Success)
            {
                if (list.Count == 1)
                {
                    pool = list[0];
                }
                else
                {
                    foreach (StoragePool storagePool in list)
                    {
                        if (!storagePool.IsPrimordial)
                        {
                            pool = storagePool;
                            break;
                        }
                    }
                }
            }
            return(spacesApiError);
        }
示例#2
0
        public static SpacesApiError GetStoragePools(ref List <StoragePool> pools)
        {
            SpacesApiError spacesApiError = SpacesApiError.Success;

            try
            {
                ManagementObjectCollection managementObjectCollection = null;
                spacesApiError = SpacesApi.GetStorageObjectsByQuery("Select * From MSFT_StoragePool", ref managementObjectCollection);
                if (spacesApiError != SpacesApiError.Success)
                {
                    return(spacesApiError);
                }
                foreach (ManagementBaseObject managementBaseObject in managementObjectCollection)
                {
                    ManagementObject m           = (ManagementObject)managementBaseObject;
                    StoragePool      storagePool = new StoragePool();
                    storagePool.FromManagementObject(m);
                    pools.Add(storagePool);
                }
            }
            catch (Exception ex)
            {
                spacesApiError = SpacesApiError.Failed;
                if (SpacesApi.DebugOn)
                {
                    SpacesApi.Debug("Failed to get storage pools: {0}", new object[]
                    {
                        ex
                    });
                }
            }
            return(spacesApiError);
        }