public override void ExecuteCmdlet() { ConfirmAction(Force.IsPresent, Resources.RemoveWarningACR, Resources.RemoveConfirmationACR, string.Empty, () => { try { AccessControlRecord existingAcr = null; string acrName = null; switch (ParameterSetName) { case StorSimpleCmdletParameterSet.IdentifyByName: var allACRs = StorSimpleClient.GetAllAccessControlRecords(); existingAcr = allACRs.Where(x => x.Name.Equals(ACRName, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault(); acrName = ACRName; break; case StorSimpleCmdletParameterSet.IdentifyByObject: existingAcr = ACR; acrName = ACR.Name; break; } if (existingAcr == null) { throw new ArgumentException(string.Format(Resources.NotFoundMessageACR, acrName)); } var serviceConfig = new ServiceConfiguration() { AcrChangeList = new AcrChangeList() { Added = new List <AccessControlRecord>(), Deleted = new[] { existingAcr.InstanceId }, Updated = new List <AccessControlRecord>() }, CredentialChangeList = new SacChangeList(), }; if (WaitForComplete.IsPresent) { WriteVerbose("About to run a task to remove your ACR!"); var taskStatus = StorSimpleClient.ConfigureService(serviceConfig); HandleSyncTaskResponse(taskStatus, "delete"); } else { WriteVerbose("About to create a task to remove your ACR!"); var taskResponse = StorSimpleClient.ConfigureServiceAsync(serviceConfig); HandleAsyncTaskResponse(taskResponse, "delete"); } } catch (Exception exception) { this.HandleException(exception); } }); }
public override void ExecuteCmdlet() { try { var allACRs = StorSimpleClient.GetAllAccessControlRecords(); if (ACRName == null) { WriteObject(allACRs); WriteVerbose(string.Format(Resources.ACRGet_StatusMessage, allACRs.Count, allACRs.Count > 1 ? "s" : string.Empty)); return; } var acr = allACRs.Where(x => x.Name.Equals(ACRName, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault(); if (acr == null) { throw new ArgumentException(string.Format(Resources.NotFoundMessageACR, ACRName)); } else { WriteObject(acr); WriteVerbose(string.Format(Resources.FoundMessageACR, ACRName)); } } catch (Exception exception) { this.HandleException(exception); } }
public override void ExecuteCmdlet() { try { var allACRs = StorSimpleClient.GetAllAccessControlRecords(); var existingAcr = allACRs.Where(x => x.Name.Equals(ACRName, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault(); if (existingAcr == null) { WriteVerbose(string.Format(Resources.NotFoundMessageACR, ACRName)); return; } var serviceConfig = new ServiceConfiguration() { AcrChangeList = new AcrChangeList() { Added = new List <AccessControlRecord>(), Deleted = new List <string>(), Updated = new [] { new AccessControlRecord() { GlobalId = existingAcr.GlobalId, InitiatorName = IQNInitiatorName, InstanceId = existingAcr.InstanceId, Name = existingAcr.Name, VolumeCount = existingAcr.VolumeCount }, } }, CredentialChangeList = new SacChangeList(), }; if (WaitForComplete.IsPresent) { WriteVerbose("About to run a task to update your Access Control Record!"); var taskStatus = StorSimpleClient.ConfigureService(serviceConfig); HandleSyncTaskResponse(taskStatus, "update"); if (taskStatus.AsyncTaskAggregatedResult == AsyncTaskAggregatedResult.Succeeded) { var updatedAcr = StorSimpleClient.GetAllAccessControlRecords() .Where(x => x.Name.Equals(ACRName, StringComparison.InvariantCultureIgnoreCase)); WriteObject(updatedAcr); } } else { WriteVerbose("About to create a task to update your Access Control Record!"); var taskResponse = StorSimpleClient.ConfigureServiceAsync(serviceConfig); HandleAsyncTaskResponse(taskResponse, "update"); } } catch (Exception exception) { this.HandleException(exception); } }
public override void ExecuteCmdlet() { try { var serviceConfig = new ServiceConfiguration() { AcrChangeList = new AcrChangeList() { Added = new[] { new AccessControlRecord() { GlobalId = null, InitiatorName = IQNInitiatorName, InstanceId = null, Name = ACRName, VolumeCount = 0 }, }, Deleted = new List <string>(), Updated = new List <AccessControlRecord>() }, CredentialChangeList = new SacChangeList(), }; if (WaitForComplete.IsPresent) { var taskStatus = StorSimpleClient.ConfigureService(serviceConfig); HandleSyncTaskResponse(taskStatus, "create"); if (taskStatus.AsyncTaskAggregatedResult == AsyncTaskAggregatedResult.Succeeded) { var createdAcr = StorSimpleClient.GetAllAccessControlRecords() .Where(x => x.Name.Equals(ACRName, StringComparison.InvariantCultureIgnoreCase)); WriteObject(createdAcr); } } else { var taskResponse = StorSimpleClient.ConfigureServiceAsync(serviceConfig); HandleAsyncTaskResponse(taskResponse, "create"); } } catch (Exception exception) { this.HandleException(exception); } }