Add DMS values to migration extension save and close feature (#17375)

This commit is contained in:
Rachel Kim
2021-10-15 16:09:43 -07:00
committed by GitHub
parent 2e677dbda6
commit 4ed4e5f39c
4 changed files with 64 additions and 29 deletions

View File

@@ -358,6 +358,10 @@ export function getResourceGroupFromId(id: string): string {
return id.replace(RegExp('^(.*?)/resourceGroups/'), '').replace(RegExp('/providers/.*'), '').toLowerCase(); return id.replace(RegExp('^(.*?)/resourceGroups/'), '').replace(RegExp('/providers/.*'), '').toLowerCase();
} }
export function getFullResourceGroupFromId(id: string): string {
return id.replace(RegExp('/providers/.*'), '').toLowerCase();
}
export interface SqlMigrationServiceProperties { export interface SqlMigrationServiceProperties {
name: string; name: string;
subscriptionId: string; subscriptionId: string;

View File

@@ -68,6 +68,11 @@ export enum Page {
Summary Summary
} }
export enum WizardEntryPoint {
Default = 'Default',
SaveAndClose = 'SaveAndClose',
}
export interface DatabaseBackupModel { export interface DatabaseBackupModel {
migrationMode: MigrationMode; migrationMode: MigrationMode;
networkContainerType: NetworkContainerType; networkContainerType: NetworkContainerType;
@@ -127,6 +132,7 @@ export interface SavedInfo {
targetSubscription: azureResource.AzureResourceSubscription | null; targetSubscription: azureResource.AzureResourceSubscription | null;
blobs: Blob[]; blobs: Blob[];
targetDatabaseNames: string[]; targetDatabaseNames: string[];
migrationServiceId: string | null;
} }
@@ -987,6 +993,10 @@ export class MigrationStateModel implements Model, vscode.Disposable {
response.databaseMigration.properties.backupConfiguration = requestBody.properties.backupConfiguration!; response.databaseMigration.properties.backupConfiguration = requestBody.properties.backupConfiguration!;
response.databaseMigration.properties.offlineConfiguration = requestBody.properties.offlineConfiguration!; response.databaseMigration.properties.offlineConfiguration = requestBody.properties.offlineConfiguration!;
let wizardEntryPoint = WizardEntryPoint.Default;
if (this.resumeAssessment) {
wizardEntryPoint = WizardEntryPoint.SaveAndClose;
}
if (response.status === 201 || response.status === 200) { if (response.status === 201 || response.status === 200) {
sendSqlMigrationActionEvent( sendSqlMigrationActionEvent(
TelemetryViews.MigrationWizardSummaryPage, TelemetryViews.MigrationWizardSummaryPage,
@@ -1005,7 +1015,8 @@ export class MigrationStateModel implements Model, vscode.Disposable {
'targetDatabaseName': this._targetDatabaseNames[i], 'targetDatabaseName': this._targetDatabaseNames[i],
'serverName': this._targetServerInstance.name, 'serverName': this._targetServerInstance.name,
'sqlMigrationServiceId': Buffer.from(this._sqlMigrationService?.id!).toString('base64'), 'sqlMigrationServiceId': Buffer.from(this._sqlMigrationService?.id!).toString('base64'),
'irRegistered': (this._nodeNames.length > 0).toString() 'irRegistered': (this._nodeNames.length > 0).toString(),
'wizardEntryPoint': wizardEntryPoint,
}, },
{ {
} }
@@ -1054,12 +1065,14 @@ export class MigrationStateModel implements Model, vscode.Disposable {
networkShare: null, networkShare: null,
targetSubscription: null, targetSubscription: null,
blobs: [], blobs: [],
targetDatabaseNames: [] targetDatabaseNames: [],
migrationServiceId: null,
}; };
switch (currentPage) { switch (currentPage) {
case Page.Summary: case Page.Summary:
case Page.IntegrationRuntime: case Page.IntegrationRuntime:
saveInfo.migrationServiceId = this._sqlMigrationService?.id!;
case Page.DatabaseBackup: case Page.DatabaseBackup:
saveInfo.networkContainerType = this._databaseBackup.networkContainerType; saveInfo.networkContainerType = this._databaseBackup.networkContainerType;

View File

@@ -621,7 +621,6 @@ export class DatabaseBackupPage extends MigrationWizardPage {
.withProps({ .withProps({
value: constants.SUBSCRIPTION, value: constants.SUBSCRIPTION,
width: WIZARD_INPUT_COMPONENT_WIDTH, width: WIZARD_INPUT_COMPONENT_WIDTH,
// requiredIndicator: true,
CSSStyles: { CSSStyles: {
...styles.LABEL_CSS, ...styles.LABEL_CSS,
'margin': '0' 'margin': '0'
@@ -632,8 +631,7 @@ export class DatabaseBackupPage extends MigrationWizardPage {
enabled: false, enabled: false,
width: WIZARD_INPUT_COMPONENT_WIDTH, width: WIZARD_INPUT_COMPONENT_WIDTH,
CSSStyles: { CSSStyles: {
// ...styles.BODY_CSS, 'margin': '0'
// 'margin-top': '-1em'
} }
}).component(); }).component();
@@ -641,7 +639,6 @@ export class DatabaseBackupPage extends MigrationWizardPage {
.withProps({ .withProps({
value: constants.LOCATION, value: constants.LOCATION,
width: WIZARD_INPUT_COMPONENT_WIDTH, width: WIZARD_INPUT_COMPONENT_WIDTH,
// requiredIndicator: true,
CSSStyles: { CSSStyles: {
...styles.LABEL_CSS, ...styles.LABEL_CSS,
'margin': '12px 0 0' 'margin': '12px 0 0'
@@ -851,6 +848,8 @@ export class DatabaseBackupPage extends MigrationWizardPage {
})); }));
if (this.migrationStateModel.resumeAssessment && this.migrationStateModel.savedInfo.closedPage >= Page.DatabaseBackup) { if (this.migrationStateModel.resumeAssessment && this.migrationStateModel.savedInfo.closedPage >= Page.DatabaseBackup) {
targetDatabaseInput.value = this.migrationStateModel.savedInfo.targetDatabaseNames[index]; targetDatabaseInput.value = this.migrationStateModel.savedInfo.targetDatabaseNames[index];
} else {
targetDatabaseInput.value = this.migrationStateModel._targetDatabaseNames[index];
} }
this._networkShareTargetDatabaseNames.push(targetDatabaseInput); this._networkShareTargetDatabaseNames.push(targetDatabaseInput);
@@ -877,6 +876,8 @@ export class DatabaseBackupPage extends MigrationWizardPage {
})); }));
if (this.migrationStateModel.resumeAssessment && this.migrationStateModel.savedInfo.closedPage >= Page.DatabaseBackup) { if (this.migrationStateModel.resumeAssessment && this.migrationStateModel.savedInfo.closedPage >= Page.DatabaseBackup) {
blobTargetDatabaseInput.value = this.migrationStateModel.savedInfo.targetDatabaseNames[index]; blobTargetDatabaseInput.value = this.migrationStateModel.savedInfo.targetDatabaseNames[index];
} else {
targetDatabaseInput.value = this.migrationStateModel._targetDatabaseNames[index];
} }
this._blobContainerTargetDatabaseNames.push(blobTargetDatabaseInput); this._blobContainerTargetDatabaseNames.push(blobTargetDatabaseInput);
@@ -1133,10 +1134,6 @@ export class DatabaseBackupPage extends MigrationWizardPage {
if (this.migrationStateModel.resumeAssessment && this.migrationStateModel.savedInfo.closedPage >= Page.DatabaseBackup) { if (this.migrationStateModel.resumeAssessment && this.migrationStateModel.savedInfo.closedPage >= Page.DatabaseBackup) {
this.migrationStateModel._targetDatabaseNames = this.migrationStateModel.savedInfo.targetDatabaseNames; this.migrationStateModel._targetDatabaseNames = this.migrationStateModel.savedInfo.targetDatabaseNames;
} }
this.migrationStateModel._targetDatabaseNames?.forEach((v, index) => {
this._networkShareTargetDatabaseNames[index].value = v;
this._blobContainerTargetDatabaseNames[index].value = v;
});
await this._windowsUserAccountText.updateProperties({ await this._windowsUserAccountText.updateProperties({
required: containerType === NetworkContainerType.NETWORK_SHARE required: containerType === NetworkContainerType.NETWORK_SHARE
@@ -1201,7 +1198,7 @@ export class DatabaseBackupPage extends MigrationWizardPage {
this._networkShareStorageAccountResourceGroupDropdown.values = await this.migrationStateModel.getAzureResourceGroupDropdownValues(this.migrationStateModel._databaseBackup.subscription); this._networkShareStorageAccountResourceGroupDropdown.values = await this.migrationStateModel.getAzureResourceGroupDropdownValues(this.migrationStateModel._databaseBackup.subscription);
if (this.migrationStateModel.resumeAssessment && this.migrationStateModel.savedInfo.closedPage >= Page.DatabaseBackup && this._networkShareStorageAccountResourceGroupDropdown.values) { if (this.migrationStateModel.resumeAssessment && this.migrationStateModel.savedInfo.closedPage >= Page.DatabaseBackup && this._networkShareStorageAccountResourceGroupDropdown.values) {
this._networkShareStorageAccountResourceGroupDropdown.values.forEach((resource, index) => { this._networkShareStorageAccountResourceGroupDropdown.values.forEach((resource, index) => {
if ((<azdata.CategoryValue>resource).name === this.migrationStateModel.savedInfo?.networkShare?.resourceGroup.id) { if ((<azdata.CategoryValue>resource).name.toLowerCase() === this.migrationStateModel.savedInfo?.networkShare?.resourceGroup?.id?.toLowerCase()) {
selectDropDownIndex(this._networkShareStorageAccountResourceGroupDropdown, index); selectDropDownIndex(this._networkShareStorageAccountResourceGroupDropdown, index);
} }
}); });
@@ -1235,9 +1232,9 @@ export class DatabaseBackupPage extends MigrationWizardPage {
this._blobContainerResourceGroupDropdowns.forEach((dropDown, index) => { this._blobContainerResourceGroupDropdowns.forEach((dropDown, index) => {
dropDown.values = resourceGroupValues; dropDown.values = resourceGroupValues;
if (this.migrationStateModel.resumeAssessment && this.migrationStateModel.savedInfo.closedPage >= Page.DatabaseBackup && dropDown.values) { if (this.migrationStateModel.resumeAssessment && this.migrationStateModel.savedInfo.closedPage >= Page.DatabaseBackup && dropDown.values) {
dropDown.values.forEach((resource, index) => { dropDown.values.forEach((resource, resourceIndex) => {
if ((<azdata.CategoryValue>resource).name === this.migrationStateModel.savedInfo?.blobs[index]?.resourceGroup.id) { if ((<azdata.CategoryValue>resource).name.toLowerCase() === this.migrationStateModel.savedInfo?.blobs[index]?.resourceGroup?.id?.toLowerCase()) {
selectDropDownIndex(dropDown, index); selectDropDownIndex(dropDown, resourceIndex);
} }
}); });
} else { } else {
@@ -1256,9 +1253,9 @@ export class DatabaseBackupPage extends MigrationWizardPage {
try { try {
this._blobContainerStorageAccountDropdowns[index].values = await this.migrationStateModel.getStorageAccountValues(this.migrationStateModel._databaseBackup.subscription, this.migrationStateModel._databaseBackup.blobs[index].resourceGroup); this._blobContainerStorageAccountDropdowns[index].values = await this.migrationStateModel.getStorageAccountValues(this.migrationStateModel._databaseBackup.subscription, this.migrationStateModel._databaseBackup.blobs[index].resourceGroup);
if (this.migrationStateModel.resumeAssessment && this.migrationStateModel.savedInfo.closedPage >= Page.DatabaseBackup && this._blobContainerStorageAccountDropdowns[index].values && this.migrationStateModel.savedInfo.blobs[index].storageAccount) { if (this.migrationStateModel.resumeAssessment && this.migrationStateModel.savedInfo.closedPage >= Page.DatabaseBackup && this._blobContainerStorageAccountDropdowns[index].values && this.migrationStateModel.savedInfo.blobs[index].storageAccount) {
this._blobContainerStorageAccountDropdowns[index].values!.forEach((resource, index) => { this._blobContainerStorageAccountDropdowns[index].values!.forEach((resource, resourceIndex) => {
if ((<azdata.CategoryValue>resource).name === this.migrationStateModel.savedInfo?.blobs[index]?.storageAccount.id) { if ((<azdata.CategoryValue>resource).name.toLowerCase() === this.migrationStateModel.savedInfo?.blobs[index]?.storageAccount?.id?.toLowerCase()) {
selectDropDownIndex(this._blobContainerStorageAccountDropdowns[index], index); selectDropDownIndex(this._blobContainerStorageAccountDropdowns[index], resourceIndex);
} }
}); });
} else { } else {
@@ -1277,9 +1274,9 @@ export class DatabaseBackupPage extends MigrationWizardPage {
const blobContainerValues = await this.migrationStateModel.getBlobContainerValues(this.migrationStateModel._databaseBackup.subscription, this.migrationStateModel._databaseBackup.blobs[index].storageAccount); const blobContainerValues = await this.migrationStateModel.getBlobContainerValues(this.migrationStateModel._databaseBackup.subscription, this.migrationStateModel._databaseBackup.blobs[index].storageAccount);
this._blobContainerDropdowns[index].values = blobContainerValues; this._blobContainerDropdowns[index].values = blobContainerValues;
if (this.migrationStateModel.resumeAssessment && this.migrationStateModel.savedInfo.closedPage >= Page.DatabaseBackup && this._blobContainerDropdowns[index].values && this.migrationStateModel.savedInfo.blobs[index].blobContainer) { if (this.migrationStateModel.resumeAssessment && this.migrationStateModel.savedInfo.closedPage >= Page.DatabaseBackup && this._blobContainerDropdowns[index].values && this.migrationStateModel.savedInfo.blobs[index].blobContainer) {
this._blobContainerDropdowns[index].values!.forEach((resource, index) => { this._blobContainerDropdowns[index].values!.forEach((resource, resourceIndex) => {
if ((<azdata.CategoryValue>resource).name === this.migrationStateModel.savedInfo?.blobs[index]?.blobContainer.id) { if ((<azdata.CategoryValue>resource).name.toLowerCase() === this.migrationStateModel.savedInfo?.blobs[index]?.blobContainer?.id?.toLowerCase()) {
selectDropDownIndex(this._blobContainerDropdowns[index], index); selectDropDownIndex(this._blobContainerDropdowns[index], resourceIndex);
} }
}); });
} else { } else {
@@ -1298,9 +1295,9 @@ export class DatabaseBackupPage extends MigrationWizardPage {
const blobLastBackupFileValues = await this.migrationStateModel.getBlobLastBackupFileNameValues(this.migrationStateModel._databaseBackup.subscription, this.migrationStateModel._databaseBackup.blobs[index].storageAccount, this.migrationStateModel._databaseBackup.blobs[index].blobContainer); const blobLastBackupFileValues = await this.migrationStateModel.getBlobLastBackupFileNameValues(this.migrationStateModel._databaseBackup.subscription, this.migrationStateModel._databaseBackup.blobs[index].storageAccount, this.migrationStateModel._databaseBackup.blobs[index].blobContainer);
this._blobContainerLastBackupFileDropdowns[index].values = blobLastBackupFileValues; this._blobContainerLastBackupFileDropdowns[index].values = blobLastBackupFileValues;
if (this.migrationStateModel.resumeAssessment && this.migrationStateModel.savedInfo.closedPage >= Page.DatabaseBackup && this._blobContainerLastBackupFileDropdowns[index].values && this.migrationStateModel.savedInfo.blobs[index].lastBackupFile) { if (this.migrationStateModel.resumeAssessment && this.migrationStateModel.savedInfo.closedPage >= Page.DatabaseBackup && this._blobContainerLastBackupFileDropdowns[index].values && this.migrationStateModel.savedInfo.blobs[index].lastBackupFile) {
this._blobContainerLastBackupFileDropdowns[index].values!.forEach((resource, index) => { this._blobContainerLastBackupFileDropdowns[index].values!.forEach((resource, resourceIndex) => {
if ((<azdata.CategoryValue>resource).name === this.migrationStateModel.savedInfo?.blobs[index]?.lastBackupFile) { if ((<azdata.CategoryValue>resource).name.toLowerCase() === this.migrationStateModel.savedInfo?.blobs[index]?.lastBackupFile!.toLowerCase()) {
selectDropDownIndex(this._blobContainerLastBackupFileDropdowns[index], index); selectDropDownIndex(this._blobContainerLastBackupFileDropdowns[index], resourceIndex);
} }
}); });
} else { } else {

View File

@@ -5,14 +5,15 @@
import * as azdata from 'azdata'; import * as azdata from 'azdata';
import * as vscode from 'vscode'; import * as vscode from 'vscode';
import { azureResource } from 'azureResource';
import { MigrationWizardPage } from '../models/migrationWizardPage'; import { MigrationWizardPage } from '../models/migrationWizardPage';
import { MigrationStateModel, NetworkContainerType, StateChangeEvent } from '../models/stateMachine'; import { MigrationStateModel, NetworkContainerType, Page, StateChangeEvent } from '../models/stateMachine';
import { CreateSqlMigrationServiceDialog } from '../dialog/createSqlMigrationService/createSqlMigrationServiceDialog'; import { CreateSqlMigrationServiceDialog } from '../dialog/createSqlMigrationService/createSqlMigrationServiceDialog';
import * as constants from '../constants/strings'; import * as constants from '../constants/strings';
import { WIZARD_INPUT_COMPONENT_WIDTH } from './wizardController'; import { WIZARD_INPUT_COMPONENT_WIDTH } from './wizardController';
import { getLocationDisplayName, getSqlMigrationService, getSqlMigrationServiceAuthKeys, getSqlMigrationServiceMonitoringData, SqlManagedInstance } from '../api/azure'; import { getFullResourceGroupFromId, getLocationDisplayName, getSqlMigrationService, getSqlMigrationServiceAuthKeys, getSqlMigrationServiceMonitoringData, SqlManagedInstance, SqlVMServer } from '../api/azure';
import { IconPathHelper } from '../constants/iconPathHelper'; import { IconPathHelper } from '../constants/iconPathHelper';
import { findDropDownItemIndex } from '../api/utils'; import { findDropDownItemIndex, selectDropDownIndex } from '../api/utils';
import * as styles from '../constants/styles'; import * as styles from '../constants/styles';
export class IntergrationRuntimePage extends MigrationWizardPage { export class IntergrationRuntimePage extends MigrationWizardPage {
@@ -85,6 +86,10 @@ export class IntergrationRuntimePage extends MigrationWizardPage {
} }
public async onPageEnter(pageChangeInfo: azdata.window.WizardPageChangeInfo): Promise<void> { public async onPageEnter(pageChangeInfo: azdata.window.WizardPageChangeInfo): Promise<void> {
if (this.migrationStateModel.resumeAssessment && this.migrationStateModel.savedInfo.closedPage >= Page.IntegrationRuntime) {
this.migrationStateModel._targetSubscription = <azureResource.AzureResourceSubscription>this.migrationStateModel.savedInfo.targetSubscription;
this.migrationStateModel._targetServerInstance = <SqlManagedInstance | SqlVMServer>this.migrationStateModel.savedInfo.targetServerInstance;
}
this._subscription.value = this.migrationStateModel._targetSubscription.name; this._subscription.value = this.migrationStateModel._targetSubscription.name;
this._location.value = await getLocationDisplayName(this.migrationStateModel._targetServerInstance.location); this._location.value = await getLocationDisplayName(this.migrationStateModel._targetServerInstance.location);
@@ -386,6 +391,14 @@ export class IntergrationRuntimePage extends MigrationWizardPage {
this._resourceGroupDropdown.loading = true; this._resourceGroupDropdown.loading = true;
try { try {
this._resourceGroupDropdown.values = await this.migrationStateModel.getAzureResourceGroupDropdownValues(this.migrationStateModel._targetSubscription); this._resourceGroupDropdown.values = await this.migrationStateModel.getAzureResourceGroupDropdownValues(this.migrationStateModel._targetSubscription);
if (this.migrationStateModel.resumeAssessment && this.migrationStateModel.savedInfo.closedPage >= Page.IntegrationRuntime && this._resourceGroupDropdown.values) {
this._resourceGroupDropdown.values.forEach((resource, resourceIndex) => {
const resourceId = this.migrationStateModel.savedInfo?.migrationServiceId?.toLowerCase();
if (resourceId && (<azdata.CategoryValue>resource).name.toLowerCase() === getFullResourceGroupFromId(resourceId)) {
selectDropDownIndex(this._resourceGroupDropdown, resourceIndex);
}
});
}
} finally { } finally {
this._resourceGroupDropdown.loading = false; this._resourceGroupDropdown.loading = false;
} }
@@ -395,12 +408,20 @@ export class IntergrationRuntimePage extends MigrationWizardPage {
this._dmsDropdown.loading = true; this._dmsDropdown.loading = true;
try { try {
this._dmsDropdown.values = await this.migrationStateModel.getSqlMigrationServiceValues(this.migrationStateModel._targetSubscription, <SqlManagedInstance>this.migrationStateModel._targetServerInstance, resourceGroupName); this._dmsDropdown.values = await this.migrationStateModel.getSqlMigrationServiceValues(this.migrationStateModel._targetSubscription, <SqlManagedInstance>this.migrationStateModel._targetServerInstance, resourceGroupName);
const selectedSqlMigrationService = this._dmsDropdown.values.find(v => v.displayName.toLowerCase() === this.migrationStateModel._sqlMigrationService?.name.toLowerCase()); const selectedSqlMigrationService = this._dmsDropdown.values.find(v => v.displayName.toLowerCase() === this.migrationStateModel._sqlMigrationService?.name?.toLowerCase());
this._dmsDropdown.value = (selectedSqlMigrationService) ? selectedSqlMigrationService : this._dmsDropdown.values[0];
if (this.migrationStateModel.resumeAssessment && this.migrationStateModel.savedInfo.closedPage >= Page.IntegrationRuntime && this._dmsDropdown.values) {
this._dmsDropdown.values.forEach((resource, resourceIndex) => {
if ((<azdata.CategoryValue>resource).name.toLowerCase() === this.migrationStateModel.savedInfo?.migrationServiceId?.toLowerCase()) {
selectDropDownIndex(this._dmsDropdown, resourceIndex);
}
});
} else {
this._dmsDropdown.value = (selectedSqlMigrationService) ? selectedSqlMigrationService : this._dmsDropdown.values[0];
}
} finally { } finally {
this._dmsDropdown.loading = false; this._dmsDropdown.loading = false;
} }
} }
private async loadMigrationServiceStatus(): Promise<void> { private async loadMigrationServiceStatus(): Promise<void> {