Esempio n. 1
0
        /// <inheritdoc cref="ComputeApi.WaitForVolumeStatusAsync{TVolume,TStatus}(string,TStatus,TimeSpan?,TimeSpan?,IProgress{bool},CancellationToken)" />
        /// <exception cref="InvalidOperationException">When the instance was not constructed by the <see cref="ComputeService"/>, as it is missing the appropriate internal state to execute service calls.</exception>
        public async Task WaitForStatusAsync(VolumeStatus status, TimeSpan?refreshDelay = null, TimeSpan?timeout = null, IProgress <bool> progress = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            var owner  = this.GetOwnerOrThrow <ComputeApi>();
            var result = await owner.WaitForVolumeStatusAsync <Volume, VolumeStatus>(Id, status, refreshDelay, timeout, progress, cancellationToken).ConfigureAwait(false);

            result.CopyProperties(this);
        }
Esempio n. 2
0
 public Volume(int id, int number, int titleId, Title title, VolumeStatus volumeStatus)
 {
     Id           = id;
     Number       = number;
     TitleId      = titleId;
     Title        = title;
     VolumeStatus = volumeStatus;
     Image        = Title.Name + Number;
 }
Esempio n. 3
0
        public async Task <VolumeStatus> GetVolumeAsync()
        {
            var cmd    = "amixer get PCM|grep -o [0-9]*%";
            var result = new VolumeStatus()
            {
                Volume = await cmd.Bash().StripNewlineCharacters()
            };

            return(result);
        }
Esempio n. 4
0
        internal static string ToSerializedValue(this VolumeStatus value)
        {
            switch (value)
            {
            case VolumeStatus.Online:
                return("Online");

            case VolumeStatus.Offline:
                return("Offline");
            }
            return(null);
        }
Esempio n. 5
0
 /// <summary>
 /// Initializes a new instance of the Volume class.
 /// </summary>
 /// <param name="sizeInBytes">The size of the volume in bytes.</param>
 /// <param name="volumeType">The type of the volume. Possible values
 /// include: 'Tiered', 'Archival', 'LocallyPinned'</param>
 /// <param name="accessControlRecordIds">The IDs of the access control
 /// records, associated with the volume.</param>
 /// <param name="volumeStatus">The volume status. Possible values
 /// include: 'Online', 'Offline'</param>
 /// <param name="monitoringStatus">The monitoring status of the volume.
 /// Possible values include: 'Enabled', 'Disabled'</param>
 /// <param name="id">The path ID that uniquely identifies the
 /// object.</param>
 /// <param name="name">The name of the object.</param>
 /// <param name="type">The hierarchical type of the object.</param>
 /// <param name="kind">The Kind of the object. Currently only
 /// Series8000 is supported. Possible values include:
 /// 'Series8000'</param>
 /// <param name="volumeContainerId">The ID of the volume container, in
 /// which this volume is created.</param>
 /// <param name="operationStatus">The operation status on the volume.
 /// Possible values include: 'None', 'Updating', 'Deleting',
 /// 'Restoring'</param>
 /// <param name="backupStatus">The backup status of the volume.
 /// Possible values include: 'Enabled', 'Disabled'</param>
 /// <param name="backupPolicyIds">The IDs of the backup policies, in
 /// which this volume is part of.</param>
 public Volume(long sizeInBytes, VolumeType volumeType, IList <string> accessControlRecordIds, VolumeStatus volumeStatus, MonitoringStatus monitoringStatus, string id = default(string), string name = default(string), string type = default(string), Kind?kind = default(Kind?), string volumeContainerId = default(string), OperationStatus?operationStatus = default(OperationStatus?), BackupStatus?backupStatus = default(BackupStatus?), IList <string> backupPolicyIds = default(IList <string>))
     : base(id, name, type, kind)
 {
     SizeInBytes            = sizeInBytes;
     VolumeType             = volumeType;
     VolumeContainerId      = volumeContainerId;
     AccessControlRecordIds = accessControlRecordIds;
     VolumeStatus           = volumeStatus;
     OperationStatus        = operationStatus;
     BackupStatus           = backupStatus;
     MonitoringStatus       = monitoringStatus;
     BackupPolicyIds        = backupPolicyIds;
 }
Esempio n. 6
0
        public static VolumeStatus ToStorApiVolumeStatus(VirtualDisk vd)
        {
            VolumeStatus volumeStatus = VolumeStatus.VOLUME_UNKNOWN;

            foreach (OperationalStatusEnum operationalStatusEnum in vd.OperationalStatus)
            {
                if (operationalStatusEnum == OperationalStatusEnum.OK)
                {
                    volumeStatus = VolumeStatus.VOLUME_NORMAL;
                }
                else if (operationalStatusEnum == OperationalStatusEnum.Degraded)
                {
                    volumeStatus = VolumeStatus.VOLUME_DEGRADED;
                }
                else if (operationalStatusEnum == OperationalStatusEnum.InService)
                {
                    volumeStatus = VolumeStatus.VOLUME_REBUILDING;
                }
                else if (operationalStatusEnum == OperationalStatusEnum.Incomplete)
                {
                    volumeStatus = VolumeStatus.VOLUME_FAILED;
                }
                if (volumeStatus != VolumeStatus.VOLUME_UNKNOWN)
                {
                    break;
                }
            }
            if (volumeStatus == VolumeStatus.VOLUME_UNKNOWN)
            {
                switch (vd.HealthStatus)
                {
                case HealthStatusEnum.Healthy:
                    volumeStatus = VolumeStatus.VOLUME_NORMAL;
                    break;

                case HealthStatusEnum.Warning:
                    volumeStatus = VolumeStatus.VOLUME_DEGRADED;
                    break;

                case HealthStatusEnum.Unhealthy:
                    volumeStatus = VolumeStatus.VOLUME_FAILED;
                    break;

                default:
                    volumeStatus = VolumeStatus.VOLUME_UNKNOWN;
                    break;
                }
            }
            return(volumeStatus);
        }
Esempio n. 7
0
        public Task <VolumeStatus> SetVolumeAsync(int percent)
        {
            if (percent < 0 || percent > 100)
            {
                throw new ArgumentException("Percent integer must be between 0 and 100");
            }

            var cmd    = $"sudo amixer set PCM -- {percent.ToString()}% | grep -o [0-9]*%";
            var output = cmd.Bash();

            var res = new VolumeStatus()
            {
                Volume = output
            };

            return(Task.FromResult(res));
        }
Esempio n. 8
0
		public VolumeRecord(byte[] buffer, int offset)
		{
			byte[] temp = new byte[2];
			BootIndicator = (VolumeStatus)buffer[offset];
			StartingHead = buffer[offset + 1];
			StartingSector = (byte)((buffer[offset + 2] & (byte)0xFC) >> 2);
			// not sure if this stuff is right, but not really used atm.
			temp[0] = (byte)((byte)((byte)buffer[offset + 2] & (byte)0x03) << 6);
			temp[1] = buffer[offset + 3];
			StartingCylinder = (ushort)(BitConverter.ToUInt16(temp, 0) >> 6);
			VolumeType = (VolumeType)buffer[offset + 4];
			EndingHead = buffer[offset + 5];
			EndingSector = (byte)((buffer[offset + 6] & (byte)0xFC) >> 2);
			temp[0] = (byte)((byte)((byte)buffer[offset + 6] & (byte)0x03) << 6);
			temp[1] = buffer[offset + 7];
			EndingCylinder = (ushort)(BitConverter.ToUInt16(temp, 0) >> 6);
			FirstSector = BitConverter.ToUInt32(buffer, offset + 8);
			TotalSectors = BitConverter.ToUInt32(buffer, offset + 12);
		}
        /// <summary>
        /// Creates Volume.
        /// </summary>
        private Volume CreateVolume(string deviceName, string volumeContainerName, string volumeName, VolumeType volumeType, VolumeStatus volumeStatus, string acrName)
        {
            var acr = this.Client.AccessControlRecords.Get(acrName.GetDoubleEncoded(), this.ResourceGroupName, this.ManagerName);

            Assert.True(acr != null && acr.Name.Equals(acrName), "Access control record name passed for use in volume doesn't exists.");

            var volumeToCreate = new Volume()
            {
                AccessControlRecordIds = new List <string>()
                {
                    acr.Id
                },
                MonitoringStatus = MonitoringStatus.Enabled,
                SizeInBytes      = (long)5 * 1024 * 1024 * 1024, //5 Gb
                VolumeType       = volumeType,
                VolumeStatus     = volumeStatus
            };

            var volume = this.Client.Volumes.CreateOrUpdate(deviceName.GetDoubleEncoded(),
                                                            volumeContainerName.GetDoubleEncoded(),
                                                            volumeName.GetDoubleEncoded(),
                                                            volumeToCreate,
                                                            this.ResourceGroupName,
                                                            this.ManagerName);

            Assert.True(volume != null && volume.Name.Equals(volumeName) &&
                        volume.MonitoringStatus.Equals(MonitoringStatus.Enabled) &&
                        volume.VolumeType.Equals(volumeType) &&
                        volume.VolumeStatus.Equals(volumeStatus),
                        "Creation of Volume was not successful");

            return(volume);
        }
Esempio n. 10
0
 /// <inheritdoc cref="ComputeApi.WaitForVolumeStatusAsync{TVolume,TStatus}(string,TStatus,TimeSpan?,TimeSpan?,IProgress{bool},CancellationToken)" />
 /// <exception cref="InvalidOperationException">When the instance was not constructed by the <see cref="ComputeService"/>, as it is missing the appropriate internal state to execute service calls.</exception>
 public async Task WaitForStatusAsync(VolumeStatus status, TimeSpan? refreshDelay = null, TimeSpan? timeout = null, IProgress<bool> progress = null, CancellationToken cancellationToken = default(CancellationToken))
 {
     var owner = this.GetOwnerOrThrow<ComputeApi>();
     var result = await owner.WaitForVolumeStatusAsync<Volume, VolumeStatus>(Id, status, refreshDelay, timeout, progress, cancellationToken).ConfigureAwait(false);
     result.CopyProperties(this);
 }
Esempio n. 11
0
 /// <inheritdoc cref="Volume.WaitForStatusAsync(VolumeStatus,TimeSpan?,TimeSpan?,IProgress{bool},System.Threading.CancellationToken)"/>
 public static void WaitForStatus(this Volume volume, VolumeStatus status, TimeSpan?refreshDelay = null, TimeSpan?timeout = null, IProgress <bool> progress = null)
 {
     volume.WaitForStatusAsync(status, refreshDelay, timeout, progress).ForceSynchronous();
 }
Esempio n. 12
0
        protected MarvellVolume MakeVolume(MvApi.MvApi.LD_Info ldInfo)
        {
            byte          b             = 0;
            MarvellVolume marvellVolume = new MarvellVolume(ldInfo.ID, this);

            marvellVolume.Name       = MarvellUtil.GetApiString(ldInfo.Name, 16);
            marvellVolume.RaidLevel  = MarvellUtil.ToStorApiRaidLevel(ldInfo.RaidMode);
            marvellVolume.StripeSize = (ulong)((long)(ldInfo.StripeBlockSize * 1024));
            marvellVolume.Status     = MarvellUtil.ToStorApiVolumeStatus(ldInfo.Status);
            marvellVolume.Capacity   = ldInfo.Size.ToUlong() * 1024UL;
            for (byte b2 = 0; b2 < ldInfo.HDCount; b2 += 1)
            {
                marvellVolume.BlockIds.Add(ldInfo.BlockIDs[(int)b2]);
            }
            short[] id = new short[]
            {
                ldInfo.ID
            };
            lock (MarvellUtil.mvApiLock)
            {
                try
                {
                    b = MvApi.MvApi.MV_DiskHasOS(this.AdapterId, 0, 1, id);
                }
                catch (Exception ex)
                {
                    Logger.Warn("MakeVolume MV_DiskHasOS exception: {0}", new object[]
                    {
                        ex
                    });
                    throw ex;
                }
            }
            if (b == 158)
            {
                marvellVolume.IsSystem = true;
            }
            if (ldInfo.BGAStatus != 0)
            {
                MvApi.MvApi.LD_Status_Request ld_Status_Request = default(MvApi.MvApi.LD_Status_Request);
                ld_Status_Request.header.Init();
                ld_Status_Request.header.requestType       = 2;
                ld_Status_Request.header.startingIndexOrId = ldInfo.ID;
                ld_Status_Request.header.numRequested      = 1;
                lock (MarvellUtil.mvApiLock)
                {
                    try
                    {
                        b = MvApi.MvApi.MV_LD_GetStatus(this.AdapterId, ref ld_Status_Request);
                    }
                    catch (Exception ex2)
                    {
                        Logger.Warn("MV_LD_GetStatus exception: {0}", new object[]
                        {
                            ex2
                        });
                        throw ex2;
                    }
                }
                if (b == 0)
                {
                    marvellVolume.Progress = (float)ld_Status_Request.ldStatus[0].BgaPercentage;
                    if (ld_Status_Request.ldStatus[0].Bga != 0 && marvellVolume.Status != VolumeStatus.VOLUME_FAILED)
                    {
                        VolumeStatus volumeStatus = MarvellUtil.ToStorApiVolumeStatusBGA(ld_Status_Request.ldStatus[0].Bga);
                        if (volumeStatus != VolumeStatus.VOLUME_UNKNOWN)
                        {
                            marvellVolume.Status = volumeStatus;
                        }
                    }
                    if (ld_Status_Request.ldStatus[0].Bga == 32)
                    {
                        MvApi.MvApi.LD_Info ld_Info = default(MvApi.MvApi.LD_Info);
                        lock (MarvellUtil.mvApiLock)
                        {
                            try
                            {
                                b = MvApi.MvApi.MV_LD_GetTargetLDInfo(this.AdapterId, ldInfo.ID, ref ld_Info);
                            }
                            catch (Exception ex3)
                            {
                                Logger.Warn("MV_LD_GetTargetLDInfo exception: {0}", new object[]
                                {
                                    ex3
                                });
                                throw ex3;
                            }
                        }
                        if (b == 0)
                        {
                            marvellVolume.RaidLevel  = MarvellUtil.ToStorApiRaidLevel(ld_Info.RaidMode);
                            marvellVolume.StripeSize = (ulong)ld_Info.StripeBlockSize;
                            marvellVolume.BlockIds.Clear();
                            for (byte b3 = 0; b3 < ld_Info.HDCount; b3 += 1)
                            {
                                marvellVolume.BlockIds.Add(ld_Info.BlockIDs[(int)b3]);
                            }
                        }
                    }
                }
            }
            return(marvellVolume);
        }
 /// <inheritdoc cref="Volume.WaitForStatusAsync(VolumeStatus,TimeSpan?,TimeSpan?,IProgress{bool},System.Threading.CancellationToken)"/>
 public static void WaitForStatus(this Volume volume, VolumeStatus status, TimeSpan? refreshDelay = null, TimeSpan? timeout = null, IProgress<bool> progress = null)
 {
     volume.WaitForStatusAsync(status, refreshDelay, timeout, progress).ForceSynchronous();
 }