예제 #1
0
        public static StorApiStatus Initialize()
        {
            StorApiStatus storApiStatus = StorApiStatusEnum.STOR_NO_ERROR;

            if (Storage.initialized)
            {
                return(storApiStatus);
            }
            storApiStatus = MarvellUtil.Initialize();
            if (storApiStatus != StorApiStatusEnum.STOR_NO_ERROR)
            {
                Storage.Debug("Marvell initialization failed: {0}", new object[]
                {
                    storApiStatus
                });
            }
            storApiStatus = SpacesUtil.Initialize();
            if (storApiStatus != StorApiStatusEnum.STOR_NO_ERROR)
            {
                Storage.Debug("Storage Spaces initialization failed: {0}", new object[]
                {
                    storApiStatus
                });
            }
            return(StorApiStatusEnum.STOR_NO_ERROR);
        }
예제 #2
0
        public override StorApiStatus UpdateVolumes()
        {
            StorApiStatus result = StorApiStatusEnum.STOR_NO_ERROR;

            if (this.volumes != null)
            {
                this.volumes.Clear();
            }
            List <VirtualDisk> list         = new List <VirtualDisk>();
            SpacesApiError     virtualDisks = SpacesApi.SpacesApi.GetVirtualDisks(ref list);

            if (virtualDisks != SpacesApiError.Success)
            {
                Logger.Error("GetVirtualDisks returned error: {0}", new object[]
                {
                    virtualDisks
                });
                return(SpacesUtil.ToStorApiStatus(virtualDisks));
            }
            foreach (VirtualDisk d in list)
            {
                this.volumes.Add(this.MakeVolume(d));
            }
            return(result);
        }
예제 #3
0
        public virtual StorApiStatus GetDrivePool(Drive drive, ref SpacesPool pool)
        {
            StorApiStatus  storApiStatus  = StorApiStatusEnum.STOR_NO_ERROR;
            SpacesApiError spacesApiError = SpacesApiError.Success;

            if (drive == null)
            {
                return(StorApiStatusEnum.STOR_INVALID_PARAM);
            }
            StoragePool storagePool = null;

            spacesApiError = SpacesApi.SpacesApi.GetPhysicalDiskPool(drive.Id, ref storagePool);
            if (spacesApiError == SpacesApiError.Success && storagePool != null)
            {
                foreach (SpacesPool spacesPool in this.pools)
                {
                    if (string.Equals(spacesPool.Id, storagePool.ObjectId, StringComparison.OrdinalIgnoreCase))
                    {
                        pool = spacesPool;
                        break;
                    }
                }
            }
            return(SpacesUtil.ToStorApiStatus(spacesApiError));
        }
예제 #4
0
        public override StorApiStatus UpdateDrives()
        {
            StorApiStatus result = StorApiStatusEnum.STOR_NO_ERROR;

            if (this.drives != null)
            {
                this.drives.Clear();
            }
            List <PhysicalDisk> list          = new List <PhysicalDisk>();
            SpacesApiError      physicalDisks = SpacesApi.SpacesApi.GetPhysicalDisks(ref list);

            if (physicalDisks != SpacesApiError.Success)
            {
                Logger.Error("GetPhysicalDiskDisks returned error: {0}", new object[]
                {
                    physicalDisks
                });
                return(SpacesUtil.ToStorApiStatus(physicalDisks));
            }
            foreach (PhysicalDisk pd in list)
            {
                SpacesDrive item = this.MakeDrive(pd);
                this.drives.Add(item);
            }
            return(result);
        }
예제 #5
0
        public static StorApiStatus Initialize()
        {
            SpacesApiError spacesApiError = SpacesApiError.Success;

            if (!SpacesUtil.apiInitialized)
            {
                spacesApiError = SpacesApi.SpacesApi.Initialize();
                if (spacesApiError == SpacesApiError.Success)
                {
                    SpacesUtil.apiInitialized = true;
                }
            }
            return(SpacesUtil.ToStorApiStatus(spacesApiError));
        }
예제 #6
0
        public StorApiStatus GetSpacesDrive(string serial, ref SpacesDrive drive)
        {
            StorApiStatus  result        = StorApiStatusEnum.STOR_NO_ERROR;
            PhysicalDisk   physicalDisk  = null;
            SpacesApiError physicalDisk2 = SpacesApi.SpacesApi.GetPhysicalDisk(serial, ref physicalDisk);

            if (physicalDisk2 != SpacesApiError.Success)
            {
                return(SpacesUtil.ToStorApiStatus(physicalDisk2));
            }
            if (physicalDisk != null)
            {
                drive = this.MakeDrive(physicalDisk);
            }
            return(result);
        }
예제 #7
0
        public static StorApiStatus Finalize()
        {
            StorApiStatus storApiStatus = MarvellUtil.Finalize();

            if (storApiStatus != StorApiStatusEnum.STOR_NO_ERROR)
            {
                Storage.Debug("Marvell finalize failed: {0}", new object[]
                {
                    storApiStatus
                });
            }
            storApiStatus = SpacesUtil.Finalize();
            if (storApiStatus != StorApiStatusEnum.STOR_NO_ERROR)
            {
                Storage.Debug("Storage Spaces finalize failed: {0}", new object[]
                {
                    storApiStatus
                });
            }
            return(StorApiStatusEnum.STOR_NO_ERROR);
        }
예제 #8
0
        public virtual StorApiStatus UpdatePools()
        {
            StorApiStatus result = StorApiStatusEnum.STOR_NO_ERROR;

            if (this.pools != null)
            {
                this.pools.Clear();
            }
            List <StoragePool> list         = new List <StoragePool>();
            SpacesApiError     storagePools = SpacesApi.SpacesApi.GetStoragePools(ref list);

            if (storagePools != SpacesApiError.Success)
            {
                return(SpacesUtil.ToStorApiStatus(storagePools));
            }
            foreach (StoragePool d in list)
            {
                this.pools.Add(this.MakePool(d));
            }
            return(result);
        }
예제 #9
0
        public SpacesVolume MakeVolume(VirtualDisk d)
        {
            SpacesVolume spacesVolume = new SpacesVolume(d.ObjectId, this);

            spacesVolume.Name                = d.FriendlyName;
            spacesVolume.StripeSize          = d.Interleave;
            spacesVolume.RaidLevel           = SpacesUtil.DetermineVirtualDiskRaidLevel(d);
            spacesVolume.Progress            = 0f;
            spacesVolume.Status              = SpacesUtil.ToStorApiVolumeStatus(d);
            spacesVolume.IsSystem            = false;
            spacesVolume.Health              = d.HealthStatus;
            spacesVolume.OperationalStatuses = d.OperationalStatus;
            List <Drive>  drives       = new List <Drive>();
            StorApiStatus volumeDrives = this.GetVolumeDrives(spacesVolume, ref drives);

            if (volumeDrives == StorApiStatusEnum.STOR_NO_ERROR)
            {
                spacesVolume.Drives = drives;
            }
            return(spacesVolume);
        }
예제 #10
0
        public SpacesDrive MakeDrive(PhysicalDisk pd)
        {
            SpacesDrive spacesDrive = new SpacesDrive(pd.ObjectId, this);

            spacesDrive.Port        = this.GetDrivePort(pd);
            spacesDrive.Model       = pd.Model;
            spacesDrive.Serial      = pd.SerialNumber;
            spacesDrive.Revision    = pd.FirmwareVersion;
            spacesDrive.SectorSize  = pd.LogicalSectorSize;
            spacesDrive.SectorCount = 0UL;
            if (pd.LogicalSectorSize != 0UL)
            {
                spacesDrive.SectorCount = pd.Size / pd.LogicalSectorSize;
            }
            spacesDrive.IsSmartEnabled      = false;
            spacesDrive.IsSystem            = SpacesApi.SpacesApi.IsPhysicalDiskSystem(pd);
            spacesDrive.Status              = SpacesUtil.ToStorApiDriveStatus(pd);
            spacesDrive.Temperature         = 0;
            spacesDrive.Health              = pd.HealthStatus;
            spacesDrive.OperationalStatuses = pd.OperationalStatus;
            return(spacesDrive);
        }
예제 #11
0
        public virtual StorApiStatus GetVolumeDrives(Volume volume, ref List <Drive> voldrives)
        {
            StorApiStatus  storApiStatus  = StorApiStatusEnum.STOR_NO_ERROR;
            SpacesApiError spacesApiError = SpacesApiError.Success;

            if (volume == null)
            {
                return(StorApiStatusEnum.STOR_INVALID_PARAM);
            }
            List <PhysicalDisk> list = new List <PhysicalDisk>();

            spacesApiError = SpacesApi.SpacesApi.GetPhysicalDisksForVirtualDisk(volume.Id, ref list);
            if (spacesApiError == SpacesApiError.Success)
            {
                foreach (PhysicalDisk pd in list)
                {
                    SpacesDrive item = this.MakeDrive(pd);
                    voldrives.Add(item);
                }
            }
            return(SpacesUtil.ToStorApiStatus(spacesApiError));
        }
예제 #12
0
        public virtual StorApiStatus IsDriveConfiguredForSpaces(Drive drive, ref bool configured)
        {
            StorApiStatus storApiStatus = StorApiStatusEnum.STOR_NO_ERROR;

            if (drive == null)
            {
                return(StorApiStatusEnum.STOR_INVALID_PARAM);
            }
            StoragePool    storagePool      = null;
            SpacesApiError physicalDiskPool = SpacesApi.SpacesApi.GetPhysicalDiskPool(drive.Id, ref storagePool);

            if (physicalDiskPool == SpacesApiError.Success)
            {
                if (storagePool == null)
                {
                    configured = false;
                }
                else
                {
                    configured = !storagePool.IsPrimordial;
                }
            }
            return(SpacesUtil.ToStorApiStatus(physicalDiskPool));
        }
예제 #13
0
 public static StorApiStatus Finalize()
 {
     return(SpacesUtil.ToStorApiStatus(SpacesApi.SpacesApi.Finalize()));
 }