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 { var startMigrationPlanRequest = new MigrationPlanStartRequest(); startMigrationPlanRequest.ConfigId = LegacyConfigId; switch (ParameterSetName) { case StorSimpleCmdletParameterSet.MigrateAllContainer: { startMigrationPlanRequest.DataContainerNameList = new List<string>(); break; } case StorSimpleCmdletParameterSet.MigrateSpecificContainer: { startMigrationPlanRequest.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.StartLegacyVolumeContainerMigrationPlan(startMigrationPlanRequest); MigrationCommonModelFormatter opFormatter = new MigrationCommonModelFormatter(); WriteObject(opFormatter.GetResultMessage(Resources.StartMigrationPlanSuccessMessage, status)); } catch (Exception except) { this.HandleException(except); } }
public MigrationJobStatus StartLegacyVolumeContainerMigrationPlan(MigrationPlanStartRequest request) { return this.GetStorSimpleClient().MigrateLegacyAppliance.StartMigrationPlan(request, this.GetCustomRequestHeaders()); }
/// <summary> /// Hydra spec for start migration plan rest APIThe rest api starts the /// estimation of time taken by migration for all/specific volume /// container(s) in the given config /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.StorSimple.IMigrationOperations. /// </param> /// <param name='startPlanRequest'> /// Required. Start migration plan request model. The object passes the /// list of volume container(s) whose migration ETA needs to calculated /// </param> /// <param name='customRequestHeaders'> /// Required. The Custom Request Headers which client must use. /// </param> /// <returns> /// The response model for migration job status. /// </returns> public static Task<MigrationJobStatus> StartMigrationPlanAsync(this IMigrationOperations operations, MigrationPlanStartRequest startPlanRequest, CustomRequestHeaders customRequestHeaders) { return operations.StartMigrationPlanAsync(startPlanRequest, customRequestHeaders, CancellationToken.None); }
/// <summary> /// Hydra spec for start migration plan rest APIThe rest api starts the /// estimation of time taken by migration for all/specific volume /// container(s) in the given config /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.StorSimple.IMigrationOperations. /// </param> /// <param name='startPlanRequest'> /// Required. Start migration plan request model. The object passes the /// list of volume container(s) whose migration ETA needs to calculated /// </param> /// <param name='customRequestHeaders'> /// Required. The Custom Request Headers which client must use. /// </param> /// <returns> /// The response model for migration job status. /// </returns> public static MigrationJobStatus StartMigrationPlan(this IMigrationOperations operations, MigrationPlanStartRequest startPlanRequest, CustomRequestHeaders customRequestHeaders) { return Task.Factory.StartNew((object s) => { return ((IMigrationOperations)s).StartMigrationPlanAsync(startPlanRequest, customRequestHeaders); } , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); }
public void VerifyMigration() { using (var context = UndoContext.Current) { context.Start(); var client = GetServiceClient<StorSimpleManagementClient>(); LegacyApplianceConfig config = CreateConfig(); List<MigrationDataContainer> dcList = new List<MigrationDataContainer>(config.CloudConfigurations); List<string> dcNameList = dcList.Select(migrationDC => migrationDC.Name).ToList(); // Import legacy appliance config returns void, other than http status code. An exception from hydra spec if the http response code is not expected client.MigrateLegacyAppliance.ImportLegacyApplianceConfig(config.InstanceId, config, GetCustomRequestHeaders()); MigrationPlanStartRequest startMigrationPlanRequest = new MigrationPlanStartRequest() { ConfigId = config.InstanceId, DataContainerNameList = dcNameList}; client.MigrateLegacyAppliance.StartMigrationPlan(startMigrationPlanRequest, GetCustomRequestHeaders()); client.MigrateLegacyAppliance.UpdateMigrationPlan(config.InstanceId, GetCustomRequestHeaders()); var getmigrationPlanResponse = client.MigrateLegacyAppliance.GetMigrationPlan(config.InstanceId, GetCustomRequestHeaders()); Assert.NotNull(getmigrationPlanResponse); Assert.NotNull(getmigrationPlanResponse.MigrationPlans); Assert.True(1 == getmigrationPlanResponse.MigrationPlans.Count); Assert.NotNull(getmigrationPlanResponse.MigrationPlans[0].MigrationPlanInfo); Assert.True(dcList.Count == getmigrationPlanResponse.MigrationPlans[0].MigrationPlanInfo.Count); List<MigrationPlanInfo> migrationPlanInfoList = new List<MigrationPlanInfo>(getmigrationPlanResponse.MigrationPlans[0].MigrationPlanInfo); Assert.True(0 == migrationPlanInfoList.FindAll(plan=>!dcNameList.Contains(plan.DataContainerName)).Count); var getmigrationAllPlanResponse = client.MigrateLegacyAppliance.GetAllMigrationPlan(GetCustomRequestHeaders()); Assert.NotNull(getmigrationAllPlanResponse); Assert.NotNull(getmigrationAllPlanResponse.MigrationPlans); Assert.True(0 < getmigrationAllPlanResponse.MigrationPlans.Count); List<MigrationPlan> allPlans = new List<MigrationPlan>(getmigrationAllPlanResponse.MigrationPlans); Assert.True(null != allPlans.Find(plan => plan.ConfigId == config.InstanceId)); MigrationImportDataContainerRequest importDCRequest = new MigrationImportDataContainerRequest() { DataContainerNames = new List<string>() }; client.MigrateLegacyAppliance.MigrationImportDataContainer(config.InstanceId, importDCRequest, GetCustomRequestHeaders()); client.MigrateLegacyAppliance.UpdateDataContainerMigrationStatus(config.InstanceId, GetCustomRequestHeaders()); var getMigrationStatus = client.MigrateLegacyAppliance.GetDataContainerMigrationStatus(config.InstanceId, GetCustomRequestHeaders()); Assert.NotNull(getMigrationStatus); Assert.NotNull(getMigrationStatus.MigrationDataContainerStatuses); List<MigrationDataContainerStatus> migrationStatusList = new List<MigrationDataContainerStatus>(getMigrationStatus.MigrationDataContainerStatuses); Assert.True(dcList.Count == migrationStatusList.Count); Assert.True(0 == migrationStatusList.FindAll(status=>!dcNameList.Contains(status.CloudConfigurationName)).Count); // Migration will start only after 12mins and will take roughly around 14mins to complete for single dc. TestUtilities.Wait(14 * 60 * 1000); DateTime timeOutTime = DateTime.UtcNow.AddMinutes(6); while (true) { if(0 <= DateTime.UtcNow.CompareTo(timeOutTime)) { throw new System.TimeoutException("Import DC did not completed in expected time"); } client.MigrateLegacyAppliance.UpdateDataContainerMigrationStatus(config.InstanceId, GetCustomRequestHeaders()); var migrationStatus = client.MigrateLegacyAppliance.GetDataContainerMigrationStatus(config.InstanceId, GetCustomRequestHeaders()); List<MigrationDataContainerStatus> statusList = new List<MigrationDataContainerStatus>(migrationStatus.MigrationDataContainerStatuses); if(dcList.Count != statusList.FindAll(status=>MigrationStatus.Completed == status.Status || MigrationStatus.Failed == status.Status).Count) { TestUtilities.Wait(30 * 1000); } else { break; } } MigrationConfirmStatusRequest confirmRequest = new MigrationConfirmStatusRequest() { DataContainerNameList = new List<string>(), Operation = MigrationOperation.Commit }; client.MigrateLegacyAppliance.ConfirmMigration(config.InstanceId, confirmRequest, GetCustomRequestHeaders()); client.MigrateLegacyAppliance.UpdateMigrationConfirmStatus(config.InstanceId, GetCustomRequestHeaders()); var getConfirmStatus = client.MigrateLegacyAppliance.GetMigrationConfirmStatus(config.InstanceId, GetCustomRequestHeaders()); Assert.NotNull(getConfirmStatus); Assert.NotNull(getConfirmStatus.ContainerConfirmStatus); List<MigrationContainerConfirmStatus> confirmStatusList = new List<MigrationContainerConfirmStatus>(getConfirmStatus.ContainerConfirmStatus); Assert.True(dcList.Count == confirmStatusList.Count); Assert.True(0 == confirmStatusList.FindAll(status => !dcNameList.Contains(status.CloudConfigurationName)).Count); } }