예제 #1
0
        public override void ExecuteCmdlet()
        {
            try
            {
                var deviceId = StorSimpleClient.GetDeviceId(DeviceName);
                if (deviceId == null)
                {
                    WriteVerbose(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName));
                    WriteObject(null);
                    return;
                }

                switch (ParameterSetName)
                {
                case StorSimpleCmdletParameterSet.IdentifyByParentObject:
                    var volumeInfoList = StorSimpleClient.GetAllVolumesFordataContainer(deviceId, VolumeContainer.InstanceId);
                    WriteObject(volumeInfoList.ListofVirtualDisks);
                    WriteVerbose(string.Format(Resources.ReturnedCountVolumeMessage, volumeInfoList.ListofVirtualDisks.Count, volumeInfoList.ListofVirtualDisks.Count > 1 ? "s" : string.Empty));
                    break;

                case StorSimpleCmdletParameterSet.IdentifyByName:
                    var volumeInfo = StorSimpleClient.GetVolumeByName(deviceId, VolumeName);
                    if (volumeInfo != null &&
                        volumeInfo.VirtualDiskInfo != null &&
                        volumeInfo.VirtualDiskInfo.InstanceId != null)
                    {
                        WriteObject(volumeInfo.VirtualDiskInfo);
                        WriteVerbose(string.Format(Resources.FoundVolumeMessage, VolumeName));
                    }
                    else
                    {
                        WriteVerbose(string.Format(Resources.NotFoundVolumeMessage, VolumeName));
                    }
                    break;
                }
            }
            catch (Exception exception)
            {
                this.HandleException(exception);
            }
        }