public override void ExecuteCmdlet()
        {
            ConfirmAction(Force.IsPresent,
                          Resources.RemoveWarningVolume,
                          Resources.RemoveConfirmationVolume,
                          string.Empty,
                          () =>
            {
                try
                {
                    var deviceid = StorSimpleClient.GetDeviceId(DeviceName);

                    if (deviceid == null)
                    {
                        WriteVerbose(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName));
                        WriteObject(null);
                        return;
                    }

                    string volumeId = string.Empty;
                    switch (ParameterSetName)
                    {
                    case StorSimpleCmdletParameterSet.IdentifyByObject:
                        volumeId = Volume.InstanceId;
                        break;

                    case StorSimpleCmdletParameterSet.IdentifyByName:
                        var volumeInfo = StorSimpleClient.GetVolumeByName(deviceid, VolumeName);
                        if (volumeInfo == null)
                        {
                            WriteVerbose(Resources.NotFoundMessageVirtualDisk);
                            return;
                        }
                        volumeId = volumeInfo.VirtualDiskInfo.InstanceId;
                        break;
                    }

                    if (WaitForComplete.IsPresent)
                    {
                        WriteVerbose("About to run a task to remove your volume!");
                        var taskstatus = StorSimpleClient.RemoveVolume(deviceid, volumeId);
                        HandleSyncTaskResponse(taskstatus, "delete");
                    }
                    else
                    {
                        WriteVerbose("About to run a task to remove your volume!");
                        var taskresponse = StorSimpleClient.RemoveVolumeAsync(deviceid, volumeId);
                        HandleAsyncTaskResponse(taskresponse, "delete");
                    }
                }
                catch (Exception exception)
                {
                    this.HandleException(exception);
                }
            });
        }
Exemple #2
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;
                }

                VirtualDisk diskDetails = StorSimpleClient.GetVolumeByName(deviceId, VolumeName).VirtualDiskInfo;
                if (diskDetails == null)
                {
                    WriteVerbose(Resources.NotFoundMessageVirtualDisk);
                    WriteObject(null);
                    return;
                }

                if (Online != null)
                {
                    diskDetails.Online = Online.GetValueOrDefault();
                }
                if (VolumeSizeInBytes != null)
                {
                    diskDetails.SizeInBytes = VolumeSizeInBytes.GetValueOrDefault();
                }
                if (VolumeAppType != null)
                {
                    diskDetails.AppType = VolumeAppType.GetValueOrDefault();
                }
                if (AccessControlRecords != null)
                {
                    diskDetails.AcrList = AccessControlRecords;
                }

                if (WaitForComplete.IsPresent)
                {
                    var taskstatus = StorSimpleClient.UpdateVolume(deviceId, diskDetails.InstanceId, diskDetails);
                    HandleSyncTaskResponse(taskstatus, "update");
                    var updatedVolume = StorSimpleClient.GetVolumeByName(deviceId, VolumeName);
                    WriteObject(updatedVolume.VirtualDiskInfo);
                }
                else
                {
                    var taskresult = StorSimpleClient.UpdateVolumeAsync(deviceId, diskDetails.InstanceId, diskDetails);

                    HandleAsyncTaskResponse(taskresult, "update");
                }
            }
            catch (Exception exception)
            {
                this.HandleException(exception);
            }
        }
        public override void ExecuteCmdlet()
        {
            try
            {
                string deviceid = null;
                deviceid = StorSimpleClient.GetDeviceId(DeviceName);

                if (deviceid == null)
                {
                    WriteVerbose(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName));
                    WriteObject(null);
                    return;
                }

                //Virtual disk create request object
                var virtualDiskToCreate = new VirtualDiskRequest()
                {
                    Name                   = VolumeName,
                    AccessType             = AccessType.ReadWrite,
                    AcrList                = AccessControlRecords,
                    AppType                = VolumeAppType,
                    IsDefaultBackupEnabled = EnableDefaultBackup,
                    SizeInBytes            = VolumeSizeInBytes,
                    DataContainer          = VolumeContainer,
                    Online                 = Online,
                    IsMonitoringEnabled    = EnableMonitoring
                };

                if (WaitForComplete.IsPresent)
                {
                    var taskStatus = StorSimpleClient.CreateVolume(deviceid, virtualDiskToCreate);;
                    HandleSyncTaskResponse(taskStatus, "create");
                    if (taskStatus.AsyncTaskAggregatedResult == AsyncTaskAggregatedResult.Succeeded)
                    {
                        var createdVolume = StorSimpleClient.GetVolumeByName(deviceid, VolumeName);
                        WriteObject(createdVolume.VirtualDiskInfo);
                    }
                }

                else
                {
                    var taskstatus = StorSimpleClient.CreateVolumeAsync(deviceid, virtualDiskToCreate);;
                    HandleAsyncTaskResponse(taskstatus, "create");
                }
            }
            catch (Exception exception)
            {
                this.HandleException(exception);
            }
        }
Exemple #4
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);
            }
        }
Exemple #5
0
        public override void ExecuteCmdlet()
        {
            try
            {
                var deviceId = StorSimpleClient.GetDeviceId(DeviceName);
                if (deviceId == null)
                {
                    throw new ArgumentException(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName));
                }

                VirtualDisk diskDetails = null;

                switch (ParameterSetName)
                {
                case StorSimpleCmdletParameterSet.IdentifyByObject:
                    diskDetails = Volume;
                    break;

                case StorSimpleCmdletParameterSet.IdentifyByName:
                    diskDetails = StorSimpleClient.GetVolumeByName(deviceId, VolumeName).VirtualDiskInfo;
                    break;

                default:
                    break;
                }

                if (diskDetails == null)
                {
                    throw new ArgumentException(Resources.NotFoundMessageVirtualDisk);
                }

                if (Online != null)
                {
                    diskDetails.Online = Online.GetValueOrDefault();
                }
                if (VolumeSizeInBytes != null)
                {
                    diskDetails.SizeInBytes = VolumeSizeInBytes.GetValueOrDefault();
                }
                if (VolumeAppType != null)
                {
                    diskDetails.AppType = VolumeAppType.GetValueOrDefault();
                }
                if (AccessControlRecords != null)
                {
                    diskDetails.AcrList = AccessControlRecords;
                }

                if (!string.IsNullOrWhiteSpace(NewName))
                {
                    diskDetails.Name = NewName;
                }

                if (WaitForComplete.IsPresent)
                {
                    var taskstatus = StorSimpleClient.UpdateVolume(deviceId, diskDetails.InstanceId, diskDetails);
                    HandleSyncTaskResponse(taskstatus, "update");
                    var updatedVolume = StorSimpleClient.GetVolumeByName(deviceId, diskDetails.Name);
                    WriteObject(updatedVolume.VirtualDiskInfo);
                }
                else
                {
                    var taskresult = StorSimpleClient.UpdateVolumeAsync(deviceId, diskDetails.InstanceId, diskDetails);

                    HandleAsyncTaskResponse(taskresult, "update");
                }
            }
            catch (Exception exception)
            {
                this.HandleException(exception);
            }
        }