Exemple #1
0
        public StorApiStatus AddDrive(SpacesDrive drive)
        {
            StorApiStatus result = StorApiStatusEnum.STOR_NO_ERROR;

            if (this.drives == null)
            {
                this.drives = new List <Drive>();
            }
            int i;

            for (i = 0; i < this.drives.Count; i++)
            {
                Drive drive2 = this.drives[i];
                if (drive2.Serial == drive.Serial)
                {
                    this.drives[i] = drive;
                    break;
                }
            }
            if (i == this.drives.Count)
            {
                this.drives.Add(drive);
            }
            return(result);
        }
Exemple #2
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);
        }
Exemple #3
0
        public new static bool CompareInfo(Drive v1, Drive v2)
        {
            bool flag = Drive.CompareInfo(v1, v2);

            if (flag)
            {
                SpacesDrive spacesDrive  = (SpacesDrive)v1;
                SpacesDrive spacesDrive2 = (SpacesDrive)v2;
                ListComparer <OperationalStatusEnum> listComparer = new ListComparer <OperationalStatusEnum>();
                if (spacesDrive.Health != spacesDrive2.Health || listComparer.Compare(spacesDrive.operationalStatuses, spacesDrive2.operationalStatuses, new Func <OperationalStatusEnum, OperationalStatusEnum, bool>(SpacesUtil.CompareOperationalStatus)))
                {
                    flag = false;
                }
            }
            return(flag);
        }
Exemple #4
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);
        }
 protected void UpdateVolumeDrives()
 {
     foreach (Volume volume in this.volumes)
     {
         MarvellVolume marvellVolume = (MarvellVolume)volume;
         foreach (short blkid in marvellVolume.BlockIds)
         {
             short driveIdFromBlockId = this.GetDriveIdFromBlockId(blkid);
             if (driveIdFromBlockId != -1)
             {
                 Drive drive = this.FindDrive(driveIdFromBlockId.ToString());
                 if (drive != null)
                 {
                     drive.Domain = DriveDomain.DRIVE_DOMAIN_RAID;
                     marvellVolume.Drives.Add(drive);
                 }
             }
         }
     }
     foreach (Drive drive2 in this.drives)
     {
         MarvellDrive marvellDrive = (MarvellDrive)drive2;
         if (marvellDrive.Domain == DriveDomain.DRIVE_DOMAIN_UNKNOWN)
         {
             StorApiStatus    a = StorApiStatusEnum.STOR_NO_ERROR;
             SpacesController spacesController = SpacesController.GetSpacesController();
             SpacesDrive      spacesDrive      = null;
             a = spacesController.GetSpacesDrive(marvellDrive.Serial, ref spacesDrive);
             if (a == StorApiStatusEnum.STOR_NO_ERROR && spacesDrive != null)
             {
                 bool flag = false;
                 a = spacesController.IsDriveConfiguredForSpaces(spacesDrive, ref flag);
                 if (a == StorApiStatusEnum.STOR_NO_ERROR && flag)
                 {
                     marvellDrive.Domain = DriveDomain.DRIVE_DOMAIN_SPACES;
                 }
             }
         }
     }
 }
Exemple #6
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);
        }
Exemple #7
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));
        }
Exemple #8
0
 public static bool CompareAndPreserve(Drive d1, Drive d2)
 {
     if (string.IsNullOrEmpty(d2.Model))
     {
         d2.Model = d1.Model;
     }
     if (string.IsNullOrEmpty(d2.Serial))
     {
         d2.Serial = d1.Serial;
     }
     if (string.IsNullOrEmpty(d2.Revision))
     {
         d2.Revision = d1.Revision;
     }
     if (d2.SectorCount == 0UL)
     {
         d2.SectorCount = d1.SectorCount;
     }
     if (d2.SectorSize == 0UL)
     {
         d2.SectorSize = d1.SectorSize;
     }
     return(SpacesDrive.CompareInfo(d1, d2));
 }