private bool ProcessParameters() { deviceId = StorSimpleClient.GetDeviceId(DeviceName); if (deviceId == null) { throw new ArgumentException(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName)); } ProcessAddSchedules(); ProcessUpdateSchedules(); ProcessDeleteScheduleIds(); ProcessUpdateVolumeIds(); return(true); }
public override void ExecuteCmdlet() { try { string deviceid = null; switch (ParameterSetName) { case StorSimpleCmdletParameterSet.IdentifyById: if (StorSimpleClient.IsValidDeviceId(DeviceId)) { deviceid = DeviceId; } else { throw new ArgumentException(string.Format(Resources.NoDeviceFoundWithGivenIdInResourceMessage, StorSimpleContext.ResourceName, DeviceId)); } break; case StorSimpleCmdletParameterSet.IdentifyByName: deviceid = StorSimpleClient.GetDeviceId(DeviceName); if (deviceid == null) { throw new ArgumentException(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName)); } break; default: break; } if (string.IsNullOrEmpty(deviceid)) { WriteObject(null); return; } var dcgroupList = StorSimpleClient.GetFaileoverDataContainerGroups(deviceid).DataContainerGroupResponse.DCGroups; WriteObject(dcgroupList); WriteVerbose(string.Format(Resources.ReturnedCountDataContainerGroupMessage, dcgroupList.Count, dcgroupList.Count > 1 ? "s" : string.Empty)); } catch (Exception exception) { this.HandleException(exception); } }
public override void ExecuteCmdlet() { try { string deviceid = null; deviceid = StorSimpleClient.GetDeviceId(DeviceName); if (deviceid == null) { throw new ArgumentException(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName)); } //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); } }
private bool ProcessParameters() { deviceId = StorSimpleClient.GetDeviceId(DeviceName); if (deviceId == null) { WriteVerbose(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName)); WriteObject(null); return(false); } ProcessAddSchedules(); ProcessUpdateSchedules(); ProcessDeleteScheduleIds(); ProcessUpdateVolumeIds(); return(true); }
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); } }
public override void ExecuteCmdlet() { try { // Make sure params were supplied appropriately. ProcessParameters(); // Get the current device details. var deviceDetails = StorSimpleClient.GetDeviceDetails(DeviceId); if (deviceDetails == null) { throw new ArgumentException(string.Format(Resources.NoDeviceFoundWithGivenIdInResourceMessage, StorSimpleContext.ResourceName, DeviceId)); } // If the device is being configured for the first time, validate that mandatory params // for first setup have been provided if (!deviceDetails.DeviceProperties.IsConfigUpdated && !ValidParamsForFirstDeviceConfiguration(StorSimpleNetworkConfig, TimeZone, SecondaryDnsServer)) { throw new ArgumentException(Resources.MandatoryParamsMissingForInitialDeviceConfiguration); } // Validate Network configs - this method throws an exception if any validation fails ValidateNetworkConfigs(deviceDetails, StorSimpleNetworkConfig); WriteVerbose(string.Format(Resources.BeginningDeviceConfiguration, deviceDetails.DeviceProperties.FriendlyName)); // Update device details objects with the details provided to the cmdlet // and make request with updated data var taskStatusInfo = StorSimpleClient.UpdateDeviceDetails(deviceDetails, this.NewName, this.TimeZone, this.secondaryDnsServer, this.StorSimpleNetworkConfig); HandleSyncTaskResponse(taskStatusInfo, "Setup"); if (taskStatusInfo.AsyncTaskAggregatedResult == AsyncTaskAggregatedResult.Succeeded) { var updatedDetails = StorSimpleClient.GetDeviceDetails(DeviceId.ToString()); WriteObject(updatedDetails); WriteVerbose(string.Format(Resources.StorSimpleDeviceUpdatedSuccessfully, updatedDetails.DeviceProperties.FriendlyName, updatedDetails.DeviceProperties.DeviceId)); } } catch (Exception exception) { this.HandleException(exception); } }
public override void ExecuteCmdlet() { try { var confirmMigrationRequest = new MigrationConfirmStatusRequest(); confirmMigrationRequest.Operation = (MigrationOperation)Enum.Parse(typeof(MigrationOperation), MigrationOperation, true); confirmMigrationRequest.DataContainerNameList = (null != LegacyContainerNames) ? new List <string>(LegacyContainerNames.ToList().Distinct(StringComparer.InvariantCultureIgnoreCase)) : new List <string>(); var status = StorSimpleClient.ConfirmLegacyVolumeContainerStatus(LegacyConfigId, confirmMigrationRequest); MigrationCommonModelFormatter opFormatter = new MigrationCommonModelFormatter(); WriteObject(opFormatter.GetResultMessage(Resources.ConfirmMigrationSuccessMessage, status)); } catch (Exception except) { this.HandleException(except); } }
public override void ExecuteCmdlet() { try { var importDataContainerRequest = new MigrationImportDataContainerRequest(); switch (ParameterSetName) { case StorSimpleCmdletParameterSet.MigrateAllContainer: { importDataContainerRequest.DataContainerNames = new List <string>(); break; } case StorSimpleCmdletParameterSet.MigrateSpecificContainer: { importDataContainerRequest.DataContainerNames = new List <string>(LegacyContainerNames.ToList().Distinct( StringComparer.InvariantCultureIgnoreCase)); break; } default: { // unexpected code path. throw new ParameterBindingException( string.Format(Resources.MigrationParameterSetNotFound, ParameterSetName)); } } importDataContainerRequest.ForceOnOtherDevice = Force.IsPresent; importDataContainerRequest.SkipACRs = SkipACRs.IsPresent; var migrationJobStatus = StorSimpleClient.MigrationImportDataContainer(LegacyConfigId, importDataContainerRequest); MigrationCommonModelFormatter opFormatter = new MigrationCommonModelFormatter(); WriteObject(opFormatter.GetResultMessage(Resources.MigrationImportDataContainerSuccessMessage, migrationJobStatus)); } catch (Exception except) { this.HandleException(except); } }
public override void ExecuteCmdlet() { try { var startMigrationPlanRequest = new MigrationPlanStartRequest(); startMigrationPlanRequest.ConfigId = LegacyConfigId; startMigrationPlanRequest.DataContainerNameList = (null != LegacyContainerNames) ? new List <string>(LegacyContainerNames.ToList().Distinct(StringComparer.InvariantCultureIgnoreCase)) : new List <string>(); var status = StorSimpleClient.StartLegacyVolumeContainerMigrationPlan(startMigrationPlanRequest); MigrationCommonModelFormatter opFormatter = new MigrationCommonModelFormatter(); WriteObject(opFormatter.GetResultMessage(Resources.StartMigrationPlanSuccessMessage, status)); } catch (Exception except) { this.HandleException(except); } }
public override void ExecuteCmdlet() { try { updateConfig = new UpdateBackupPolicyConfig(); if (!ProcessParameters()) { return; } updateConfig.InstanceId = BackupPolicyId; updateConfig.Name = BackupPolicyName; updateConfig.IsPolicyRenamed = true; updateConfig.BackupSchedulesToBeAdded = schedulesToAdd; updateConfig.BackupSchedulesToBeUpdated = schedulesToUpdate; updateConfig.BackupSchedulesToBeDeleted = scheduleIdsTodelete; updateConfig.VolumeIds = volumeIdsToUpdate; if (WaitForComplete.IsPresent) { WriteVerbose("About to run a task to update your backuppolicy!"); var taskStatusInfo = StorSimpleClient.UpdateBackupPolicy(deviceId, BackupPolicyId, updateConfig); HandleSyncTaskResponse(taskStatusInfo, "update"); if (taskStatusInfo.AsyncTaskAggregatedResult == AsyncTaskAggregatedResult.Succeeded) { var updatedBackupPolicy = StorSimpleClient.GetBackupPolicyByName(deviceId, BackupPolicyName); WriteObject(updatedBackupPolicy.BackupPolicyDetails); } } else { WriteVerbose("About to create a task to update your backuppolicy!"); var taskresult = StorSimpleClient.UpdateBackupPolicyAsync(deviceId, BackupPolicyId, updateConfig); HandleAsyncTaskResponse(taskresult, "Update"); } } catch (Exception exception) { this.HandleException(exception); } }
/// <summary> /// ProcessRecord of the command. /// </summary> public override void ExecuteCmdlet() { try { this.WriteVerbose(Resources.ResourceContextInitializeMessage); var resCred = StorSimpleClient.GetResourceDetails(ResourceName); if (resCred == null) { this.WriteVerbose(Resources.NotFoundMessageResource); throw GetGenericException(Resources.NotFoundMessageResource, null); } StorSimpleClient.SetResourceContext(resCred); var deviceInfos = StorSimpleClient.GetAllDevices(); if (!deviceInfos.Any()) { StorSimpleClient.ResetResourceContext(); throw base.GetGenericException(Resources.DeviceNotRegisteredMessage, null); } //now check for the key if (string.IsNullOrEmpty(RegistrationKey)) { this.WriteVerbose(Resources.RegistrationKeyNotPassedMessage); } else { this.WriteVerbose(Resources.RegistrationKeyPassedMessage); EncryptionCmdLetHelper.PersistCIK(this, resCred.ResourceId, StorSimpleClient.ParseCIKFromRegistrationKey(RegistrationKey)); } EncryptionCmdLetHelper.ValidatePersistedCIK(this, resCred.ResourceId); this.WriteVerbose(Resources.SecretsValidationCompleteMessage); this.WriteVerbose(Resources.SuccessMessageSetResourceContext); var currentContext = StorSimpleClient.GetResourceContext(); this.WriteObject(currentContext); } catch (Exception exception) { this.HandleException(exception); } }
public override void ExecuteCmdlet() { try { BackupScheduleBase newScheduleObject = new BackupScheduleBase(); newScheduleObject.BackupType = (BackupType)Enum.Parse(typeof(BackupType), BackupType); newScheduleObject.Status = Enabled ? ScheduleStatus.Enabled : ScheduleStatus.Disabled; newScheduleObject.RetentionCount = RetentionCount; newScheduleObject.StartTime = StartFromDateTime; newScheduleObject.Recurrence = new ScheduleRecurrence(); newScheduleObject.Recurrence.RecurrenceType = (RecurrenceType)Enum.Parse(typeof(RecurrenceType), RecurrenceType); newScheduleObject.Recurrence.RecurrenceValue = RecurrenceValue; StorSimpleClient.ValidateBackupScheduleBase(newScheduleObject); WriteObject(newScheduleObject); } catch (Exception exception) { this.HandleException(exception); } }
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); } }
public override void ExecuteCmdlet() { try { if (!ProcessParameters()) { return; } GetBackupResponse backupList = null; backupList = StorSimpleClient.GetAllBackups(deviceId, filterType, isAllSelected, IdToPass, FromDateTime.ToString(), ToDateTime.ToString(), Skip == null ? "0" : Skip.ToString(), First == null ? null : First.ToString()); WriteObject(backupList.BackupSetsList, true); WriteVerbose(string.Format(Resources.BackupsReturnedCount, backupList.BackupSetsList.Count)); if (backupList.NextPageUri != null && backupList.NextPageStartIdentifier != "1") { if (First != null) { //user has provided First(Top) parameter while calling the commandlet //so we need to provide it to him for calling the next page WriteVerbose(string.Format(Resources.BackupNextPageFormatMessage, First, backupList.NextPageStartIdentifier)); } else { //user has NOT provided First(Top) parameter while calling the commandlet //so we DONT need to provide it to him for calling the next page WriteVerbose(string.Format(Resources.BackupNextPagewithNoFirstMessage, backupList.NextPageStartIdentifier)); } } else { WriteVerbose(Resources.BackupNoMorePagesMessage); } } catch (Exception exception) { this.HandleException(exception); } }
public override void ExecuteCmdlet() { try { ProcessParameters(); if (WaitForComplete.IsPresent) { var taskStatusInfo = StorSimpleClient.DoBackup(deviceId, BackupPolicyId, backupNowRequest); HandleSyncTaskResponse(taskStatusInfo, "start"); } else { var taskresult = StorSimpleClient.DoBackupAsync(deviceId, BackupPolicyId, backupNowRequest); HandleAsyncTaskResponse(taskresult, "start"); } } catch (Exception exception) { this.HandleException(exception); } }
public override void ExecuteCmdlet() { try { var confirmMigrationRequest = new MigrationConfirmStatusRequest(); confirmMigrationRequest.Operation = (MigrationOperation)Enum.Parse(typeof(MigrationOperation), MigrationOperation, true); switch (ParameterSetName) { case StorSimpleCmdletParameterSet.MigrateAllContainer: { confirmMigrationRequest.DataContainerNameList = new List <string>(); break; } case StorSimpleCmdletParameterSet.MigrateSpecificContainer: { confirmMigrationRequest.DataContainerNameList = new List <string>(LegacyContainerNames.ToList().Distinct( StringComparer.InvariantCultureIgnoreCase)); break; } default: { // unexpected code path hit. throw new ParameterBindingException( string.Format(Resources.MigrationParameterSetNotFound, ParameterSetName)); } } var status = StorSimpleClient.ConfirmLegacyVolumeContainerStatus(LegacyConfigId, confirmMigrationRequest); MigrationCommonModelFormatter opFormatter = new MigrationCommonModelFormatter(); WriteObject(opFormatter.GetResultMessage(Resources.ConfirmMigrationSuccessMessage, status)); } catch (Exception except) { this.HandleException(except); } }
public override void ExecuteCmdlet() { try { var deviceid = StorSimpleClient.GetDeviceId(DeviceName); if (deviceid == null) { WriteVerbose(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName)); WriteObject(null); return; } if (VolumeContainerName == null) { var dataContainerList = StorSimpleClient.GetAllDataContainers(deviceid); WriteObject(dataContainerList.DataContainers); WriteVerbose(string.Format(Resources.ReturnedCountDataContainerMessage, dataContainerList.DataContainers.Count, dataContainerList.DataContainers.Count > 1 ? "s" : string.Empty)); } else { var dataContainer = StorSimpleClient.GetDataContainer(deviceid, VolumeContainerName); if (dataContainer != null && dataContainer.DataContainerInfo != null && dataContainer.DataContainerInfo.InstanceId != null) { WriteObject(dataContainer.DataContainerInfo); WriteVerbose(string.Format(Resources.FoundDataContainerMessage, VolumeContainerName)); } else { WriteVerbose(string.Format(Resources.NotFoundDataContainerMessage, VolumeContainerName)); } } } catch (Exception exception) { this.HandleException(exception); } }
public override void ExecuteCmdlet() { try { ConfirmAction( Force.IsPresent, string.Format(Resources.StopAzureStorSimpleJobWarningMessage, InstanceId), string.Format(Resources.StopAzureStorSimpleJobMessage, InstanceId), InstanceId, () => { // Get details of the job being cancelled. var deviceJobDetails = StorSimpleClient.GetDeviceJobById(InstanceId); if (deviceJobDetails == null) { throw new ArgumentException(string.Format(Resources.NoDeviceJobFoundWithGivenIdMessage, InstanceId)); } // Make sure the job is running and cancellable, else fail. if (!(deviceJobDetails.IsJobCancellable && deviceJobDetails.Status == "Running")) { throw new ArgumentException(string.Format(Resources.JobNotRunningOrCancellable, InstanceId)); } // issue call to cancel the job. WriteVerbose(string.Format(Resources.StoppingDeviceJob, InstanceId)); var taskStatusInfo = StorSimpleClient.StopDeviceJob(deviceJobDetails.Device.InstanceId, InstanceId); HandleSyncTaskResponse(taskStatusInfo, "stop"); if (taskStatusInfo.AsyncTaskAggregatedResult == AsyncTaskAggregatedResult.Succeeded) { WriteVerbose(Resources.StopDeviceJobSucceeded); WriteObject(deviceJobDetails); } }); } catch (Exception exception) { HandleException(exception); } }
public override void ExecuteCmdlet() { try { // Make sure params were supplied appropriately. ProcessParameters(); // Make call to get device jobs. var response = StorSimpleClient.GetDeviceJobs(deviceId, Type, Status, InstanceId, fromDateTimeIsoString, toDateTimeIsoString, (int)Skip, (int)First); WriteObject(response.DeviceJobList, true); WriteVerbose(string.Format(Resources.DeviceJobsReturnedCount, response.DeviceJobList.Count, response.DeviceJobList.Count > 1 ? "s" : string.Empty)); if (response.NextPageUri != null && response.NextPageStartIdentifier != "-1") { if (First != null) { //user has provided First(Top) parameter while calling the commandlet //so we need to provide it to him for calling the next page WriteVerbose(string.Format(Resources.DeviceJobsNextPageFormatMessage, First, response.NextPageStartIdentifier)); } else { //user has NOT provided First(Top) parameter while calling the commandlet //so we DONT need to provide it to him for calling the next page WriteVerbose(string.Format(Resources.DeviceJobsNextPagewithNoFirstMessage, response.NextPageStartIdentifier)); } } else { WriteVerbose(Resources.DeviceJobsNoMorePagesMessage); } } catch (Exception exception) { HandleException(exception); } }
public override void ExecuteCmdlet() { try { ValidateParams(); // Make sure we have a device for supplied name and get its device id. var deviceId = StorSimpleClient.GetDeviceId(DeviceName); if (deviceId == null) { throw new ArgumentException(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName)); } // Get the current device details. ( If we found id from the name, this call is bound to succeed) var deviceDetails = StorSimpleClient.GetDeviceDetails(deviceId); // The cik also needs to be sent to the service. string cik = EncryptionCmdLetHelper.RetrieveCIK(this, StorSimpleContext.ResourceId); // Update device details. var cryptoManager = new StorSimpleCryptoManager(StorSimpleClient); StorSimpleClient.UpdateVirtualDeviceDetails(deviceDetails, TimeZone, SecretKey, AdministratorPassword, SnapshotManagerPassword, cik, cryptoManager); // Make request with updated data WriteVerbose(string.Format(Resources.BeginningDeviceConfiguration, deviceDetails.DeviceProperties.FriendlyName)); var taskStatusInfo = StorSimpleClient.UpdateDeviceDetails(deviceDetails); HandleSyncTaskResponse(taskStatusInfo, "Setup"); if (taskStatusInfo.AsyncTaskAggregatedResult == AsyncTaskAggregatedResult.Succeeded) { var updatedDetails = StorSimpleClient.GetDeviceDetails(deviceId); WriteObject(updatedDetails); WriteVerbose(string.Format(Resources.StorSimpleDeviceUpdatedSuccessfully, updatedDetails.DeviceProperties.FriendlyName, updatedDetails.DeviceProperties.DeviceId)); } } catch (Exception exception) { this.HandleException(exception); } }
private bool ProcessParameters() { deviceId = StorSimpleClient.GetDeviceId(DeviceName); if (deviceId == null) { WriteVerbose(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName)); WriteObject(null); return(false); } switch (ParameterSetName) { case StorSimpleCmdletParameterSet.IdentifyById: Guid backuppolicyIdGuid; bool isIdValidGuid = Guid.TryParse(BackupPolicyId, out backuppolicyIdGuid); if (string.IsNullOrEmpty(BackupPolicyId) || !isIdValidGuid) { throw new ArgumentException(Resources.InvalidBackupPolicyIdParameter); } else { backupPolicyIdFinal = BackupPolicyId; } break; case StorSimpleCmdletParameterSet.IdentifyByObject: if (BackupPolicy == null || string.IsNullOrEmpty(BackupPolicy.InstanceId)) { throw new ArgumentException(Resources.InvalidBackupPolicyObjectParameter); } else { backupPolicyIdFinal = BackupPolicy.InstanceId; } break; } return(true); }
public override void ExecuteCmdlet() { try { var importDataContainerRequest = new MigrationImportDataContainerRequest(); importDataContainerRequest.DataContainerNames = (null != LegacyContainerNames) ? new List <string>(LegacyContainerNames.ToList().Distinct(StringComparer.InvariantCultureIgnoreCase)) : new List <string>(); importDataContainerRequest.ForceOnOtherDevice = Force.IsPresent; importDataContainerRequest.SkipACRs = SkipACRs.IsPresent; var migrationJobStatus = StorSimpleClient.MigrationImportDataContainer(LegacyConfigId, importDataContainerRequest); MigrationCommonModelFormatter opFormatter = new MigrationCommonModelFormatter(); WriteObject(opFormatter.GetResultMessage(Resources.MigrationImportDataContainerSuccessMessage, migrationJobStatus)); } catch (Exception except) { this.HandleException(except); } }
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; } if (WaitForComplete.IsPresent) { WriteVerbose("About to run a task to remove your Volume container!"); var taskstatusInfo = StorSimpleClient.DeleteDataContainer(deviceid, VolumeContainer.InstanceId); HandleSyncTaskResponse(taskstatusInfo, "delete"); } else { WriteVerbose("About to create a task to remove your Volume container!"); var taskresult = StorSimpleClient.DeleteDataContainerAsync(deviceid, VolumeContainer.InstanceId); HandleAsyncTaskResponse(taskresult, "delete"); } } catch (Exception exception) { this.HandleException(exception); } }); }
private void ProcessParameters() { // Default values for first and skip are 0 First = First ?? 0; Skip = Skip ?? 0; // Need to use xml convert because we want ISO 8601 formatting - which is a mandatory requirement from the backend. fromDateTimeIsoString = From.HasValue ? XmlConvert.ToString(From.Value) : null; toDateTimeIsoString = To.HasValue ? XmlConvert.ToString(To.Value) : null; deviceId = null; if (DeviceName != null) { deviceId = StorSimpleClient.GetDeviceId(DeviceName); if (deviceId == null) { throw new ArgumentException(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName)); } } }
private void ProcessParameters() { deviceId = StorSimpleClient.GetDeviceId(DeviceName); if (deviceId == null) { throw new ArgumentException(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName)); } BackupType backupTypeSelected = Management.StorSimple.Models.BackupType.Invalid; switch (ParameterSetName) { case StorSimpleCmdletParameterSet.Empty: backupTypeSelected = Microsoft.WindowsAzure.Management.StorSimple.Models.BackupType.LocalSnapshot; break; case PARAMETERSET_BACKUPTYPE: backupTypeSelected = (BackupType)Enum.Parse(typeof(BackupType), BackupType); break; } backupNowRequest = new BackupNowRequest(); backupNowRequest.Type = backupTypeSelected; }
private void ProcessParameters() { // Make sure that atleast one of the settings has been provided. // Its no use making a request when the user didnt specify any of // the settings. if (string.IsNullOrEmpty(NewName) && TimeZone == null && string.IsNullOrEmpty(SecondaryDnsServer) && (StorSimpleNetworkConfig == null || StorSimpleNetworkConfig.Count() < 1)) { throw new ArgumentException(Resources.SetAzureStorSimpleDeviceNoSettingsProvided); } // Make sure that the DeviceId property has the appropriate value irrespective of the parameter set if (ParameterSetName == StorSimpleCmdletParameterSet.IdentifyByName) { var deviceId = StorSimpleClient.GetDeviceId(DeviceName); if (deviceId == null) { throw new ArgumentException(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName)); } DeviceId = deviceId; } TrySetIPAddress(SecondaryDnsServer, out secondaryDnsServer, "SecondaryDnsServer"); }
public override void ExecuteCmdlet() { try { if (!ProcessParameters()) { return; } this.ConfirmAction( Force.IsPresent, string.Format(Resources.StartAzureStorSimpleBackupCloneJobWarningMessage, BackupId), string.Format(Resources.StartAzureStorSimpleBackupCloneJobMessage, BackupId), BackupId, () => { JobResponse response = null; var request = new TriggerCloneRequest() { TargetDeviceId = targetDeviceId, BackupSetId = BackupId, SourceSnapshot = Snapshot, ReturnWorkflowId = true, TargetVolName = CloneVolumeName, TargetACRList = TargetAccessControlRecords ?? new List <AccessControlRecord>() }; response = StorSimpleClient.CloneVolume(sourceDeviceId, request); HandleDeviceJobResponse(response, "start"); } ); } catch (Exception ex) { this.HandleException(ex); } }
private void ProcessParameters() { deviceId = StorSimpleClient.GetDeviceId(DeviceName); if (deviceId == null) { WriteVerbose(Resources.NotFoundMessageDevice); } BackupType backupTypeSelected = Management.StorSimple.Models.BackupType.Invalid; switch (ParameterSetName) { case StorSimpleCmdletParameterSet.Empty: backupTypeSelected = Microsoft.WindowsAzure.Management.StorSimple.Models.BackupType.LocalSnapshot; break; case PARAMETERSET_BACKUPTYPE: backupTypeSelected = (BackupType)Enum.Parse(typeof(BackupType), BackupType); break; } backupNowRequest = new BackupNowRequest(); backupNowRequest.Type = backupTypeSelected; }
public override void ExecuteCmdlet() { try { string deviceid = StorSimpleClient.GetDeviceId(DeviceName); if (deviceid == null) { WriteVerbose(string.Format(Resources.NoDeviceFoundWithGivenNameInResourceMessage, StorSimpleContext.ResourceName, DeviceName)); WriteObject(null); return; } if (EncryptionEnabled == true && string.IsNullOrEmpty(EncryptionKey)) { throw new ArgumentNullException("EncryptionKey"); } string encryptedKey = null; StorSimpleCryptoManager storSimpleCryptoManager = new StorSimpleCryptoManager(StorSimpleClient); if (EncryptionEnabled == true) { WriteVerbose(Resources.EncryptionInProgressMessage); storSimpleCryptoManager.EncryptSecretWithRakPub(EncryptionKey, out encryptedKey); } if (string.IsNullOrEmpty(PrimaryStorageAccountCredential.InstanceId)) { //The SAC needs to be created inline WriteVerbose(Resources.InlineSacCreationMessage); var sac = PrimaryStorageAccountCredential; //validate storage account credentials bool storageAccountPresent; string encryptedPassword; string thumbprint; string endpoint = GetEndpointFromHostname(sac.Hostname); string location = GetStorageAccountLocation(sac.Name, out storageAccountPresent); if (!storageAccountPresent || !ValidateAndEncryptStorageCred(sac.Name, sac.Password, endpoint, out encryptedPassword, out thumbprint)) { return; } sac.Password = encryptedPassword; sac.PasswordEncryptionCertThumbprint = thumbprint; sac.Location = location; } var dc = new DataContainerRequest { IsDefault = false, Name = VolumeContainerName, BandwidthRate = BandWidthRateInMbps, IsEncryptionEnabled = EncryptionEnabled ?? false, EncryptionKey = encryptedKey, VolumeCount = 0, PrimaryStorageAccountCredential = PrimaryStorageAccountCredential, SecretsEncryptionThumbprint = storSimpleCryptoManager.GetSecretsEncryptionThumbprint() }; if (WaitForComplete.IsPresent) { var taskStatus = StorSimpleClient.CreateDataContainer(deviceid, dc); HandleSyncTaskResponse(taskStatus, "create"); if (taskStatus.AsyncTaskAggregatedResult == AsyncTaskAggregatedResult.Succeeded) { var createdDataContainer = StorSimpleClient.GetDataContainer(deviceid, VolumeContainerName); WriteObject(createdDataContainer.DataContainerInfo); } } else { var taskstatus = StorSimpleClient.CreateDataContainerAsync(deviceid, dc); HandleAsyncTaskResponse(taskstatus, "create"); } } catch (Exception exception) { this.HandleException(exception); } }
public override void ExecuteCmdlet() { ConfirmAction(Force.IsPresent, Resources.RemoveWarningACR, Resources.RemoveConfirmationACR, string.Empty, () => { try { StorageAccountCredentialResponse existingSac = null; string sacName = null; switch (ParameterSetName) { case StorSimpleCmdletParameterSet.IdentifyByName: var allSACs = StorSimpleClient.GetAllStorageAccountCredentials(); existingSac = allSACs.Where(x => x.Name.Equals(StorageAccountName, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault(); sacName = StorageAccountName; break; case StorSimpleCmdletParameterSet.IdentifyByObject: existingSac = SAC; sacName = SAC.Name; break; } if (existingSac == null) { WriteObject(null); WriteVerbose(string.Format(Resources.SACNotFoundWithName, sacName)); return; } var serviceConfig = new ServiceConfiguration() { AcrChangeList = new AcrChangeList(), CredentialChangeList = new SacChangeList() { Added = new List <StorageAccountCredential>(), Deleted = new[] { existingSac.InstanceId }, Updated = new List <StorageAccountCredential>() } }; if (WaitForComplete.IsPresent) { WriteVerbose("About to run a task to remove your Storage Access Credential!"); var taskStatus = StorSimpleClient.ConfigureService(serviceConfig); HandleSyncTaskResponse(taskStatus, "delete"); } else { WriteVerbose("About to create a task to remove your Storage Access Credential!"); var taskResponse = StorSimpleClient.ConfigureServiceAsync(serviceConfig); HandleAsyncTaskResponse(taskResponse, "delete"); } } catch (Exception exception) { this.HandleException(exception); } }); }
/// <summary> /// Constructs the encryptor to encrypt the secrets like password/key before sharing with service /// </summary> /// <param name="client"></param> public ServiceSecretEncryptor(StorSimpleClient client) { this.storSimpleCryptoManager = new StorSimpleCryptoManager(client); }
public StorSimpleCryptoManager(StorSimpleClient storSimpleClient) { this.StorSimpleClient = storSimpleClient; }