mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-25 09:35:37 -05:00
Modifying the migration extension to use its own service. (#21781)
* Adding migration service to sql migrations * enabling auto flush log * Adding support for env variable * Adding TDE Migration service * code cleanup * updating service downloader * Removing custom output channel * remove unnecessary await * Updated service version to get latest code * Consolidate TDE into migration service * Sync to latest main * Update sql-migration package version * Fix merge conflict error * Fixing all merge conflicts * Fixing stuff * removing extra whitespace * Cleaning up --------- Co-authored-by: Akshay Mata <akma@microsoft.com>
This commit is contained in:
@@ -11,6 +11,20 @@ import { formatNumber, ParallelCopyTypeCodes, PipelineStatusCodes } from './help
|
||||
import { ValidationError } from '../api/azure';
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
export const serviceName = 'Sql Migration Service';
|
||||
export const providerId = 'SqlMigration';
|
||||
export const extensionConfigSectionName = 'sqlMigration';
|
||||
export const sqlConfigSectionName = 'sql';
|
||||
export const configLogDebugInfo = 'logDebugInfo';
|
||||
export function serviceCrashMessage(error: string): string {
|
||||
return localize('serviceCrashMessage', "Migration service component could not start. {0}", error);
|
||||
}
|
||||
export const serviceCrashed = localize('serviceCrashed', "Service component crashed.");
|
||||
export function waitingForService(serviceName: string): string {
|
||||
return localize('waitingForService', "Waiting for {0} component to start.", serviceName);
|
||||
}
|
||||
export const serviceProviderInitializationError = localize('serviceProviderIntializationError', "Service provider could not be initialized.");
|
||||
|
||||
// mirrors MigrationState as defined in RP
|
||||
export enum MigrationState {
|
||||
Canceled = 'Canceled',
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
import * as vscode from 'vscode';
|
||||
import * as mssql from 'mssql';
|
||||
import { promises as fs } from 'fs';
|
||||
import { DatabaseMigration, getMigrationDetails } from '../api/azure';
|
||||
import { MenuCommands, SqlMigrationExtensionId } from '../api/utils';
|
||||
@@ -26,6 +25,8 @@ import { DashboardStatusBar, ErrorEvent } from './DashboardStatusBar';
|
||||
import { DashboardTab } from './dashboardTab';
|
||||
import { MigrationsTab, MigrationsTabId } from './migrationsTab';
|
||||
import { AdsMigrationStatus, MigrationDetailsEvent, ServiceContextChangeEvent } from './tabBase';
|
||||
import { migrationServiceProvider } from '../service/provider';
|
||||
import { ApiType, SqlMigrationService } from '../service/features';
|
||||
import { getSourceConnectionId, getSourceConnectionProfile } from '../api/sqlUtils';
|
||||
|
||||
export interface MenuCommandArgs {
|
||||
@@ -438,9 +439,10 @@ export class DashboardWidget {
|
||||
serverName = activeConnection.serverName;
|
||||
}
|
||||
if (serverName) {
|
||||
const api = (await vscode.extensions.getExtension(mssql.extension.name)?.activate()) as mssql.IExtension;
|
||||
if (api) {
|
||||
this.stateModel = new MigrationStateModel(this._context, api.sqlMigration, api.tdeMigration);
|
||||
const migrationService = <SqlMigrationService>await migrationServiceProvider.getService(ApiType.SqlMigrationProvider);
|
||||
|
||||
if (migrationService) {
|
||||
this.stateModel = new MigrationStateModel(this._context, migrationService);
|
||||
this._context.subscriptions.push(this.stateModel);
|
||||
const savedInfo = this.checkSavedInfo(serverName);
|
||||
if (savedInfo) {
|
||||
@@ -474,9 +476,9 @@ export class DashboardWidget {
|
||||
serverName = activeConnection.serverName;
|
||||
}
|
||||
if (serverName) {
|
||||
const api = (await vscode.extensions.getExtension(mssql.extension.name)?.activate()) as mssql.IExtension;
|
||||
if (api) {
|
||||
this.stateModel = new MigrationStateModel(this._context, api.sqlMigration, api.tdeMigration);
|
||||
const migrationService = <SqlMigrationService>await migrationServiceProvider.getService(ApiType.SqlMigrationProvider);
|
||||
if (migrationService) {
|
||||
this.stateModel = new MigrationStateModel(this._context, migrationService);
|
||||
this._context.subscriptions.push(this.stateModel);
|
||||
const wizardController = new WizardController(
|
||||
this._context,
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
import * as vscode from 'vscode';
|
||||
import * as mssql from 'mssql';
|
||||
import * as features from '../../service/features';
|
||||
import { azureResource } from 'azurecore';
|
||||
import { getLocations, getResourceGroupFromId, getBlobContainerId, getFullResourceGroupFromId, getResourceName, DatabaseMigration, getMigrationTargetInstance } from '../../api/azure';
|
||||
import { MigrationMode, MigrationStateModel, NetworkContainerType, SavedInfo } from '../../models/stateMachine';
|
||||
@@ -14,6 +14,7 @@ import { WizardController } from '../../wizard/wizardController';
|
||||
import { getMigrationModeEnum, getMigrationTargetTypeEnum } from '../../constants/helper';
|
||||
import * as constants from '../../constants/strings';
|
||||
import { ServiceContextChangeEvent } from '../../dashboard/tabBase';
|
||||
import { migrationServiceProvider } from '../../service/provider';
|
||||
import { getSourceConnectionProfile } from '../../api/sqlUtils';
|
||||
|
||||
export class RetryMigrationDialog {
|
||||
@@ -29,10 +30,10 @@ export class RetryMigrationDialog {
|
||||
serviceContext: MigrationServiceContext,
|
||||
migration: DatabaseMigration,
|
||||
serverName: string,
|
||||
api: mssql.IExtension,
|
||||
migrationService: features.SqlMigrationService,
|
||||
location: azureResource.AzureLocation): Promise<MigrationStateModel> {
|
||||
|
||||
const stateModel = new MigrationStateModel(this._context, api.sqlMigration, api.tdeMigration);
|
||||
const stateModel = new MigrationStateModel(this._context, migrationService);
|
||||
const sourceDatabaseName = migration.properties.sourceDatabaseName;
|
||||
const savedInfo: SavedInfo = {
|
||||
closedPage: 0,
|
||||
@@ -160,8 +161,8 @@ export class RetryMigrationDialog {
|
||||
serverName = activeConnection.serverName;
|
||||
}
|
||||
|
||||
const api = (await vscode.extensions.getExtension(mssql.extension.name)?.activate()) as mssql.IExtension;
|
||||
const stateModel = await this.createMigrationStateModel(this._serviceContext, this._migration, serverName, api, location!);
|
||||
const migrationService = <features.SqlMigrationService>await migrationServiceProvider.getService(features.ApiType.SqlMigrationProvider)!;
|
||||
const stateModel = await this.createMigrationStateModel(this._serviceContext, this._migration, serverName, migrationService, location!);
|
||||
|
||||
if (await stateModel.loadSavedInfo()) {
|
||||
const wizardController = new WizardController(
|
||||
|
||||
@@ -7,8 +7,8 @@ import * as azdata from 'azdata';
|
||||
import * as vscode from 'vscode';
|
||||
import { MigrationStateModel, MigrationTargetType } from '../../models/stateMachine';
|
||||
import * as constants from '../../constants/strings';
|
||||
import * as contracts from '../../service/contracts';
|
||||
import * as styles from '../../constants/styles';
|
||||
import * as mssql from 'mssql';
|
||||
import * as utils from '../../api/utils';
|
||||
import * as fs from 'fs';
|
||||
import path = require('path');
|
||||
@@ -29,8 +29,8 @@ export class SkuRecommendationResultsDialog {
|
||||
public targetName?: string;
|
||||
private _saveButton!: azdata.window.Button;
|
||||
|
||||
public targetRecommendations?: mssql.SkuRecommendationResultItem[];
|
||||
public instanceRequirements?: mssql.SqlInstanceRequirements;
|
||||
public targetRecommendations?: contracts.SkuRecommendationResultItem[];
|
||||
public instanceRequirements?: contracts.SqlInstanceRequirements;
|
||||
|
||||
constructor(public model: MigrationStateModel, public _targetType: MigrationTargetType) {
|
||||
switch (this._targetType) {
|
||||
@@ -90,9 +90,9 @@ export class SkuRecommendationResultsDialog {
|
||||
return container;
|
||||
}
|
||||
|
||||
private createRecommendation(_view: azdata.ModelView, recommendationItem: mssql.SkuRecommendationResultItem): azdata.FlexContainer {
|
||||
private createRecommendation(_view: azdata.ModelView, recommendationItem: contracts.SkuRecommendationResultItem): azdata.FlexContainer {
|
||||
|
||||
let recommendation: mssql.IaaSSkuRecommendationResultItem | mssql.PaaSSkuRecommendationResultItem;
|
||||
let recommendation: contracts.IaaSSkuRecommendationResultItem | contracts.PaaSSkuRecommendationResultItem;
|
||||
|
||||
let configuration = constants.NA;
|
||||
let storageSection = _view.modelBuilder.flexContainer().withLayout({
|
||||
@@ -100,7 +100,7 @@ export class SkuRecommendationResultsDialog {
|
||||
}).component();
|
||||
switch (this._targetType) {
|
||||
case MigrationTargetType.SQLVM:
|
||||
recommendation = <mssql.IaaSSkuRecommendationResultItem>recommendationItem;
|
||||
recommendation = <contracts.IaaSSkuRecommendationResultItem>recommendationItem;
|
||||
|
||||
if (recommendation.targetSku) {
|
||||
configuration = constants.VM_CONFIGURATION(
|
||||
@@ -113,18 +113,18 @@ export class SkuRecommendationResultsDialog {
|
||||
|
||||
case MigrationTargetType.SQLMI:
|
||||
case MigrationTargetType.SQLDB:
|
||||
recommendation = <mssql.PaaSSkuRecommendationResultItem>recommendationItem;
|
||||
recommendation = <contracts.PaaSSkuRecommendationResultItem>recommendationItem;
|
||||
|
||||
if (recommendation.targetSku) {
|
||||
const serviceTier = recommendation.targetSku.category?.sqlServiceTier === mssql.AzureSqlPaaSServiceTier.GeneralPurpose
|
||||
const serviceTier = recommendation.targetSku.category?.sqlServiceTier === contracts.AzureSqlPaaSServiceTier.GeneralPurpose
|
||||
? constants.GENERAL_PURPOSE
|
||||
: recommendation.targetSku.category?.sqlServiceTier === mssql.AzureSqlPaaSServiceTier.HyperScale
|
||||
: recommendation.targetSku.category?.sqlServiceTier === contracts.AzureSqlPaaSServiceTier.HyperScale
|
||||
? constants.HYPERSCALE
|
||||
: constants.BUSINESS_CRITICAL;
|
||||
|
||||
const hardwareType = recommendation.targetSku.category?.hardwareType === mssql.AzureSqlPaaSHardwareType.Gen5
|
||||
const hardwareType = recommendation.targetSku.category?.hardwareType === contracts.AzureSqlPaaSHardwareType.Gen5
|
||||
? constants.GEN5
|
||||
: recommendation.targetSku.category?.hardwareType === mssql.AzureSqlPaaSHardwareType.PremiumSeries
|
||||
: recommendation.targetSku.category?.hardwareType === contracts.AzureSqlPaaSHardwareType.PremiumSeries
|
||||
? constants.PREMIUM_SERIES
|
||||
: constants.PREMIUM_SERIES_MEMORY_OPTIMIZED;
|
||||
|
||||
@@ -240,7 +240,7 @@ export class SkuRecommendationResultsDialog {
|
||||
return recommendationContainer;
|
||||
}
|
||||
|
||||
private createSqlVmTargetStorageSection(_view: azdata.ModelView, recommendation: mssql.IaaSSkuRecommendationResultItem): azdata.FlexContainer {
|
||||
private createSqlVmTargetStorageSection(_view: azdata.ModelView, recommendation: contracts.IaaSSkuRecommendationResultItem): azdata.FlexContainer {
|
||||
const recommendedTargetStorageSection = _view.modelBuilder.text()
|
||||
.withProps({
|
||||
value: constants.RECOMMENDED_TARGET_STORAGE_CONFIGURATION,
|
||||
@@ -348,18 +348,18 @@ export class SkuRecommendationResultsDialog {
|
||||
return container;
|
||||
}
|
||||
|
||||
private getCachingText(caching: mssql.AzureManagedDiskCaching): string {
|
||||
private getCachingText(caching: contracts.AzureManagedDiskCaching): string {
|
||||
switch (caching) {
|
||||
case mssql.AzureManagedDiskCaching.NotApplicable:
|
||||
case contracts.AzureManagedDiskCaching.NotApplicable:
|
||||
return constants.CACHING_NA;
|
||||
|
||||
case mssql.AzureManagedDiskCaching.None:
|
||||
case contracts.AzureManagedDiskCaching.None:
|
||||
return constants.CACHING_NONE;
|
||||
|
||||
case mssql.AzureManagedDiskCaching.ReadOnly:
|
||||
case contracts.AzureManagedDiskCaching.ReadOnly:
|
||||
return constants.CACHING_READ_ONLY;
|
||||
|
||||
case mssql.AzureManagedDiskCaching.ReadWrite:
|
||||
case contracts.AzureManagedDiskCaching.ReadWrite:
|
||||
return constants.CACHING_READ_WRITE;
|
||||
}
|
||||
}
|
||||
@@ -460,7 +460,7 @@ export class SkuRecommendationResultsDialog {
|
||||
return container;
|
||||
}
|
||||
|
||||
public async openDialog(dialogName?: string, recommendations?: mssql.SkuRecommendationResult) {
|
||||
public async openDialog(dialogName?: string, recommendations?: contracts.SkuRecommendationResult) {
|
||||
if (!this._isOpen) {
|
||||
this._isOpen = true;
|
||||
this.instanceRequirements = recommendations?.instanceRequirements;
|
||||
|
||||
@@ -5,10 +5,23 @@
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import { DashboardWidget } from './dashboard/sqlServerDashboard';
|
||||
import * as constants from './constants/strings';
|
||||
import { ServiceClient } from './service/serviceClient';
|
||||
import { migrationServiceProvider } from './service/provider';
|
||||
import { TelemetryReporter } from './telemetry';
|
||||
|
||||
let widget: DashboardWidget;
|
||||
export async function activate(context: vscode.ExtensionContext): Promise<DashboardWidget> {
|
||||
if (!migrationServiceProvider) {
|
||||
await vscode.window.showErrorMessage(constants.serviceProviderInitializationError);
|
||||
}
|
||||
// asynchronously starting the service
|
||||
const outputChannel = vscode.window.createOutputChannel(constants.serviceName);
|
||||
const serviceClient = new ServiceClient(outputChannel);
|
||||
serviceClient.startService(context).catch((e) => {
|
||||
console.error(e);
|
||||
});
|
||||
|
||||
widget = new DashboardWidget(context);
|
||||
await widget.register();
|
||||
context.subscriptions.push(TelemetryReporter);
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
import * as azdata from 'azdata';
|
||||
import * as azurecore from 'azurecore';
|
||||
import * as vscode from 'vscode';
|
||||
import * as mssql from 'mssql';
|
||||
import * as contracts from '../service/contracts';
|
||||
import * as features from '../service/features';
|
||||
import { SqlMigrationService, SqlManagedInstance, startDatabaseMigration, StartDatabaseMigrationRequest, StorageAccount, SqlVMServer, getLocationDisplayName, getSqlManagedInstanceDatabases, AzureSqlDatabaseServer, VirtualMachineInstanceView } from '../api/azure';
|
||||
import * as constants from '../constants/strings';
|
||||
import * as nls from 'vscode-nls';
|
||||
@@ -222,7 +223,7 @@ export class MigrationStateModel implements Model, vscode.Disposable {
|
||||
public _assessmentResults!: ServerAssessment;
|
||||
public _assessedDatabaseList!: string[];
|
||||
public _runAssessments: boolean = true;
|
||||
private _assessmentApiResponse!: mssql.AssessmentResult;
|
||||
private _assessmentApiResponse!: contracts.AssessmentResult;
|
||||
public _assessmentReportFilePath: string;
|
||||
public mementoString: string;
|
||||
|
||||
@@ -241,7 +242,7 @@ export class MigrationStateModel implements Model, vscode.Disposable {
|
||||
|
||||
public _skuRecommendationResults!: SkuRecommendation;
|
||||
public _skuRecommendationPerformanceDataSource!: PerformanceDataSourceOptions;
|
||||
private _skuRecommendationApiResponse!: mssql.SkuRecommendationResult;
|
||||
private _skuRecommendationApiResponse!: contracts.SkuRecommendationResult;
|
||||
public _skuRecommendationReportFilePaths: string[];
|
||||
public _skuRecommendationPerformanceLocation!: string;
|
||||
|
||||
@@ -254,7 +255,7 @@ export class MigrationStateModel implements Model, vscode.Disposable {
|
||||
|
||||
public _loginsForMigration!: LoginTableInfo[];
|
||||
public _aadDomainName!: string;
|
||||
public _loginMigrationsResult!: mssql.StartLoginMigrationResult;
|
||||
public _loginMigrationsResult!: contracts.StartLoginMigrationResult;
|
||||
public _loginMigrationsError: any;
|
||||
public _loginMigrationModel: LoginMigrationModel;
|
||||
|
||||
@@ -288,16 +289,15 @@ export class MigrationStateModel implements Model, vscode.Disposable {
|
||||
private _currentState: State;
|
||||
private _gatheringInformationError: string | undefined;
|
||||
private _skuRecommendationRecommendedDatabaseList!: string[];
|
||||
private _startPerfDataCollectionApiResponse!: mssql.StartPerfDataCollectionResult;
|
||||
private _stopPerfDataCollectionApiResponse!: mssql.StopPerfDataCollectionResult;
|
||||
private _refreshPerfDataCollectionApiResponse!: mssql.RefreshPerfDataCollectionResult;
|
||||
private _startPerfDataCollectionApiResponse!: contracts.StartPerfDataCollectionResult;
|
||||
private _stopPerfDataCollectionApiResponse!: contracts.StopPerfDataCollectionResult;
|
||||
private _refreshPerfDataCollectionApiResponse!: contracts.RefreshPerfDataCollectionResult;
|
||||
private _autoRefreshPerfDataCollectionHandle!: NodeJS.Timeout;
|
||||
private _autoRefreshGetSkuRecommendationHandle!: NodeJS.Timeout;
|
||||
|
||||
constructor(
|
||||
public extensionContext: vscode.ExtensionContext,
|
||||
public readonly migrationService: mssql.ISqlMigrationService,
|
||||
public readonly tdeMigrationService: mssql.ITdeMigrationService
|
||||
public readonly migrationService: features.SqlMigrationService,
|
||||
) {
|
||||
this._currentState = State.INIT;
|
||||
this._databaseBackup = {} as DatabaseBackupModel;
|
||||
@@ -398,10 +398,10 @@ export class MigrationStateModel implements Model, vscode.Disposable {
|
||||
}
|
||||
|
||||
public async getDatabaseAssessments(targetType: MigrationTargetType[]): Promise<ServerAssessment> {
|
||||
const ownerUri = await getSourceConnectionUri();
|
||||
const connectionString = await getSourceConnectionString();
|
||||
try {
|
||||
const xEventsFilesFolderPath = ''; // to-do: collect by prompting the user in the UI - for now, blank = disabled
|
||||
const response = (await this.migrationService.getAssessments(ownerUri, this._databasesForAssessment, xEventsFilesFolderPath))!;
|
||||
const response = (await this.migrationService.getAssessments(connectionString, this._databasesForAssessment, xEventsFilesFolderPath))!;
|
||||
this._assessmentApiResponse = response;
|
||||
this._assessedDatabaseList = this._databasesForAssessment.slice();
|
||||
|
||||
@@ -548,7 +548,7 @@ export class MigrationStateModel implements Model, vscode.Disposable {
|
||||
return this._targetServerName;
|
||||
}
|
||||
|
||||
private updateLoginMigrationResults(newResult: mssql.StartLoginMigrationResult): void {
|
||||
private updateLoginMigrationResults(newResult: contracts.StartLoginMigrationResult): void {
|
||||
if (this._loginMigrationsResult && this._loginMigrationsResult.exceptionMap) {
|
||||
for (var key in newResult.exceptionMap) {
|
||||
this._loginMigrationsResult.exceptionMap[key] = [...this._loginMigrationsResult.exceptionMap[key] || [], newResult.exceptionMap[key]]
|
||||
@@ -781,9 +781,9 @@ export class MigrationStateModel implements Model, vscode.Disposable {
|
||||
page: SKURecommendationPage): Promise<boolean> {
|
||||
try {
|
||||
if (!this.performanceCollectionInProgress()) {
|
||||
const ownerUri = await getSourceConnectionUri();
|
||||
const connectionString = await getSourceConnectionString();
|
||||
const response = await this.migrationService.startPerfDataCollection(
|
||||
ownerUri,
|
||||
connectionString,
|
||||
dataFolder,
|
||||
perfQueryIntervalInSec,
|
||||
staticQueryIntervalInSec,
|
||||
@@ -1106,7 +1106,7 @@ export class MigrationStateModel implements Model, vscode.Disposable {
|
||||
|
||||
try {
|
||||
|
||||
const migrationResult = await this.tdeMigrationService.migrateCertificate(
|
||||
const migrationResult = await this.migrationService.migrateCertificate(
|
||||
tdeEnabledDatabases,
|
||||
connectionString,
|
||||
this._targetSubscription?.id,
|
||||
@@ -1116,11 +1116,11 @@ export class MigrationStateModel implements Model, vscode.Disposable {
|
||||
accessToken,
|
||||
reportUpdate);
|
||||
|
||||
opResult.errors = migrationResult.migrationStatuses
|
||||
opResult.errors = migrationResult!.migrationStatuses
|
||||
.filter(entry => !entry.success)
|
||||
.map(entry => constants.TDE_MIGRATION_ERROR_DB(entry.dbName, entry.message));
|
||||
|
||||
opResult.result = migrationResult.migrationStatuses.map(m => ({
|
||||
opResult.result = migrationResult!.migrationStatuses.map(m => ({
|
||||
name: m.dbName,
|
||||
success: m.success,
|
||||
message: m.message
|
||||
@@ -1477,18 +1477,18 @@ export class MigrationStateModel implements Model, vscode.Disposable {
|
||||
}
|
||||
|
||||
export interface ServerAssessment {
|
||||
issues: mssql.SqlMigrationAssessmentResultItem[];
|
||||
issues: contracts.SqlMigrationAssessmentResultItem[];
|
||||
databaseAssessments: {
|
||||
name: string;
|
||||
issues: mssql.SqlMigrationAssessmentResultItem[];
|
||||
errors?: mssql.ErrorModel[];
|
||||
issues: contracts.SqlMigrationAssessmentResultItem[];
|
||||
errors?: contracts.ErrorModel[];
|
||||
}[];
|
||||
errors?: mssql.ErrorModel[];
|
||||
errors?: contracts.ErrorModel[];
|
||||
assessmentError?: Error;
|
||||
}
|
||||
|
||||
export interface SkuRecommendation {
|
||||
recommendations?: mssql.SkuRecommendationResult;
|
||||
recommendations?: contracts.SkuRecommendationResult;
|
||||
recommendationError?: Error;
|
||||
}
|
||||
|
||||
|
||||
550
extensions/sql-migration/src/service/contracts.ts
Normal file
550
extensions/sql-migration/src/service/contracts.ts
Normal file
@@ -0,0 +1,550 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { RequestType, NotificationType } from 'vscode-languageclient';
|
||||
import * as azdata from 'azdata';
|
||||
|
||||
export interface IMessage {
|
||||
jsonrpc: string;
|
||||
}
|
||||
|
||||
export interface SqlMigrationAssessmentParams {
|
||||
connectionString: string;
|
||||
databases: string[];
|
||||
xEventsFilesFolderPath: string;
|
||||
}
|
||||
|
||||
export interface SqlMigrationImpactedObjectInfo {
|
||||
name: string;
|
||||
impactDetail: string;
|
||||
objectType: string;
|
||||
}
|
||||
|
||||
export interface SqlMigrationAssessmentResultItem {
|
||||
rulesetVersion: string;
|
||||
rulesetName: string;
|
||||
ruleId: string;
|
||||
targetType: string;
|
||||
checkId: string;
|
||||
tags: string[];
|
||||
displayName: string;
|
||||
description: string;
|
||||
helpLink: string;
|
||||
level: string;
|
||||
timestamp: string;
|
||||
kind: azdata.sqlAssessment.SqlAssessmentResultItemKind;
|
||||
message: string;
|
||||
appliesToMigrationTargetPlatform: string;
|
||||
issueCategory: string;
|
||||
databaseName: string;
|
||||
impactedObjects: SqlMigrationImpactedObjectInfo[];
|
||||
databaseRestoreFails: boolean;
|
||||
}
|
||||
|
||||
export interface ServerTargetReadiness {
|
||||
numberOfDatabasesReadyForMigration: number;
|
||||
numberOfNonOnlineDatabases: number;
|
||||
totalNumberOfDatabases: number;
|
||||
}
|
||||
|
||||
export interface ErrorModel {
|
||||
errorId: number;
|
||||
message: string;
|
||||
errorSummary: string;
|
||||
possibleCauses: string;
|
||||
guidance: string;
|
||||
}
|
||||
|
||||
export interface DatabaseTargetReadiness {
|
||||
noSelectionForMigration: boolean;
|
||||
numOfBlockerIssues: number;
|
||||
}
|
||||
|
||||
export interface DatabaseAssessmentProperties {
|
||||
compatibilityLevel: string;
|
||||
databaseSize: number;
|
||||
isReplicationEnabled: boolean;
|
||||
assessmentTimeInMilliseconds: number;
|
||||
items: SqlMigrationAssessmentResultItem[];
|
||||
errors: ErrorModel[];
|
||||
sqlManagedInstanceTargetReadiness: DatabaseTargetReadiness;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface ServerAssessmentProperties {
|
||||
cpuCoreCount: number;
|
||||
physicalServerMemory: number;
|
||||
serverHostPlatform: string;
|
||||
serverVersion: string;
|
||||
serverEngineEdition: string;
|
||||
serverEdition: string;
|
||||
isClustered: boolean;
|
||||
numberOfUserDatabases: number;
|
||||
sqlAssessmentStatus: number;
|
||||
assessedDatabaseCount: number;
|
||||
sqlManagedInstanceTargetReadiness: ServerTargetReadiness;
|
||||
items: SqlMigrationAssessmentResultItem[];
|
||||
errors: ErrorModel[];
|
||||
databases: DatabaseAssessmentProperties[];
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface AssessmentResult {
|
||||
startTime: string;
|
||||
endedTime: string;
|
||||
assessmentResult: ServerAssessmentProperties;
|
||||
rawAssessmentResult: any;
|
||||
errors: ErrorModel[];
|
||||
assessmentReportPath: string;
|
||||
}
|
||||
|
||||
export namespace GetSqlMigrationAssessmentItemsRequest {
|
||||
export const type = new RequestType<SqlMigrationAssessmentParams, AssessmentResult, void, void>('migration/getassessments');
|
||||
}
|
||||
|
||||
export interface SqlMigrationSkuRecommendationsParams {
|
||||
dataFolder: string;
|
||||
perfQueryIntervalInSec: number;
|
||||
targetPlatforms: string[];
|
||||
targetSqlInstance: string;
|
||||
targetPercentile: number;
|
||||
scalingFactor: number;
|
||||
startTime: string;
|
||||
endTime: string;
|
||||
includePreviewSkus: boolean;
|
||||
databaseAllowList: string[];
|
||||
}
|
||||
|
||||
export interface AzureSqlSkuCategory {
|
||||
sqlTargetPlatform: AzureSqlTargetPlatform;
|
||||
computeTier: ComputeTier;
|
||||
}
|
||||
|
||||
export interface AzureSqlSkuPaaSCategory extends AzureSqlSkuCategory {
|
||||
sqlPurchasingModel: AzureSqlPurchasingModel;
|
||||
sqlServiceTier: AzureSqlPaaSServiceTier;
|
||||
hardwareType: AzureSqlPaaSHardwareType;
|
||||
}
|
||||
|
||||
export interface AzureSqlSkuIaaSCategory extends AzureSqlSkuCategory {
|
||||
virtualMachineFamilyType: VirtualMachineFamilyType;
|
||||
}
|
||||
|
||||
export interface AzureManagedDiskSku {
|
||||
tier: AzureManagedDiskTier;
|
||||
size: string;
|
||||
caching: AzureManagedDiskCaching;
|
||||
}
|
||||
|
||||
export interface AzureVirtualMachineSku {
|
||||
virtualMachineFamily: VirtualMachineFamily;
|
||||
sizeName: string;
|
||||
computeSize: number;
|
||||
azureSkuName: string;
|
||||
vCPUsAvailable: number;
|
||||
}
|
||||
|
||||
export interface AzureSqlSkuMonthlyCost {
|
||||
computeCost: number;
|
||||
storageCost: number;
|
||||
totalCost: number;
|
||||
}
|
||||
|
||||
export interface AzureSqlSku {
|
||||
category: AzureSqlSkuPaaSCategory | AzureSqlSkuIaaSCategory;
|
||||
computeSize: number;
|
||||
predictedDataSizeInMb: number;
|
||||
predictedLogSizeInMb: number;
|
||||
}
|
||||
|
||||
export interface AzureSqlPaaSSku extends AzureSqlSku {
|
||||
category: AzureSqlSkuPaaSCategory;
|
||||
storageMaxSizeInMb: number;
|
||||
}
|
||||
|
||||
export interface AzureSqlIaaSSku extends AzureSqlSku {
|
||||
category: AzureSqlSkuIaaSCategory;
|
||||
virtualMachineSize: AzureVirtualMachineSku;
|
||||
dataDiskSizes: AzureManagedDiskSku[];
|
||||
logDiskSizes: AzureManagedDiskSku[];
|
||||
tempDbDiskSizes: AzureManagedDiskSku[];
|
||||
}
|
||||
|
||||
export interface SkuRecommendationResultItem {
|
||||
sqlInstanceName: string;
|
||||
databaseName: string;
|
||||
targetSku: AzureSqlIaaSSku | AzureSqlPaaSSku;
|
||||
monthlyCost: AzureSqlSkuMonthlyCost;
|
||||
ranking: number;
|
||||
positiveJustifications: string[];
|
||||
negativeJustifications: string[];
|
||||
}
|
||||
|
||||
export interface SqlInstanceRequirements {
|
||||
cpuRequirementInCores: number;
|
||||
dataStorageRequirementInMB: number;
|
||||
logStorageRequirementInMB: number;
|
||||
memoryRequirementInMB: number;
|
||||
dataIOPSRequirement: number;
|
||||
logIOPSRequirement: number;
|
||||
ioLatencyRequirementInMs: number;
|
||||
ioThroughputRequirementInMBps: number;
|
||||
tempDBSizeInMB: number;
|
||||
dataPointsStartTime: string;
|
||||
dataPointsEndTime: string;
|
||||
aggregationTargetPercentile: number;
|
||||
perfDataCollectionIntervalInSeconds: number;
|
||||
databaseLevelRequirements: SqlDatabaseRequirements[];
|
||||
numberOfDataPointsAnalyzed: number;
|
||||
}
|
||||
|
||||
export interface SqlDatabaseRequirements {
|
||||
cpuRequirementInCores: number;
|
||||
dataIOPSRequirement: number;
|
||||
logIOPSRequirement: number;
|
||||
ioLatencyRequirementInMs: number;
|
||||
ioThroughputRequirementInMBps: number;
|
||||
dataStorageRequirementInMB: number;
|
||||
logStorageRequirementInMB: number;
|
||||
databaseName: string;
|
||||
memoryRequirementInMB: number;
|
||||
cpuRequirementInPercentageOfTotalInstance: number;
|
||||
numberOfDataPointsAnalyzed: number;
|
||||
fileLevelRequirements: SqlFileRequirements[];
|
||||
}
|
||||
|
||||
export interface SqlFileRequirements {
|
||||
fileName: string;
|
||||
fileType: DatabaseFileType;
|
||||
sizeInMB: number;
|
||||
readLatencyInMs: number;
|
||||
writeLatencyInMs: number;
|
||||
iopsRequirement: number;
|
||||
ioThroughputRequirementInMBps: number;
|
||||
numberOfDataPointsAnalyzed: number;
|
||||
}
|
||||
|
||||
export interface PaaSSkuRecommendationResultItem extends SkuRecommendationResultItem {
|
||||
targetSku: AzureSqlPaaSSku;
|
||||
}
|
||||
|
||||
export interface IaaSSkuRecommendationResultItem extends SkuRecommendationResultItem {
|
||||
targetSku: AzureSqlIaaSSku;
|
||||
}
|
||||
|
||||
export interface SkuRecommendationResult {
|
||||
sqlDbRecommendationResults: PaaSSkuRecommendationResultItem[];
|
||||
sqlDbRecommendationDurationInMs: number;
|
||||
sqlMiRecommendationResults: PaaSSkuRecommendationResultItem[];
|
||||
sqlMiRecommendationDurationInMs: number;
|
||||
sqlVmRecommendationResults: IaaSSkuRecommendationResultItem[];
|
||||
sqlVmRecommendationDurationInMs: number;
|
||||
elasticSqlDbRecommendationResults: PaaSSkuRecommendationResultItem[];
|
||||
elasticSqlDbRecommendationDurationInMs: number;
|
||||
elasticSqlMiRecommendationResults: PaaSSkuRecommendationResultItem[];
|
||||
elasticSqlMiRecommendationDurationInMs: number;
|
||||
elasticSqlVmRecommendationResults: IaaSSkuRecommendationResultItem[];
|
||||
elasticSqlVmRecommendationDurationInMs: number;
|
||||
instanceRequirements: SqlInstanceRequirements;
|
||||
skuRecommendationReportPaths: string[];
|
||||
elasticSkuRecommendationReportPaths: string[];
|
||||
}
|
||||
|
||||
// SKU recommendation enums, mirrored from Microsoft.SqlServer.Migration.SkuRecommendation
|
||||
export const enum DatabaseFileType {
|
||||
Rows = 0,
|
||||
Log = 1,
|
||||
Filestream = 2,
|
||||
NotSupported = 3,
|
||||
Fulltext = 4
|
||||
}
|
||||
|
||||
export const enum AzureSqlTargetPlatform {
|
||||
AzureSqlDatabase = 0,
|
||||
AzureSqlManagedInstance = 1,
|
||||
AzureSqlVirtualMachine = 2
|
||||
}
|
||||
|
||||
export const enum ComputeTier {
|
||||
Provisioned = 0,
|
||||
ServerLess = 1
|
||||
}
|
||||
|
||||
export const enum AzureManagedDiskTier {
|
||||
Standard = 0,
|
||||
Premium = 1,
|
||||
Ultra = 2
|
||||
}
|
||||
|
||||
export const enum AzureManagedDiskCaching {
|
||||
NotApplicable = 0,
|
||||
None = 1,
|
||||
ReadOnly = 2,
|
||||
ReadWrite = 3
|
||||
}
|
||||
|
||||
export const enum AzureSqlPurchasingModel {
|
||||
vCore = 0,
|
||||
}
|
||||
|
||||
export const enum AzureSqlPaaSServiceTier {
|
||||
GeneralPurpose = 0,
|
||||
BusinessCritical,
|
||||
HyperScale,
|
||||
}
|
||||
|
||||
export const enum AzureSqlPaaSHardwareType {
|
||||
Gen5 = 0,
|
||||
PremiumSeries,
|
||||
PremiumSeriesMemoryOptimized
|
||||
}
|
||||
|
||||
export const enum VirtualMachineFamilyType {
|
||||
GeneralPurpose,
|
||||
ComputeOptimized,
|
||||
MemoryOptimized,
|
||||
StorageOptimized,
|
||||
GPU,
|
||||
HighPerformanceCompute
|
||||
}
|
||||
|
||||
export const enum VirtualMachineFamily {
|
||||
basicAFamily,
|
||||
standardA0_A7Family,
|
||||
standardAv2Family,
|
||||
standardBSFamily,
|
||||
standardDFamily,
|
||||
standardDv2Family,
|
||||
standardDv2PromoFamily,
|
||||
standardDADSv5Family,
|
||||
standardDASv4Family,
|
||||
standardDASv5Family,
|
||||
standardDAv4Family,
|
||||
standardDDSv4Family,
|
||||
standardDDSv5Family,
|
||||
standardDDv4Family,
|
||||
standardDDv5Family,
|
||||
standardDSv3Family,
|
||||
standardDSv4Family,
|
||||
standardDSv5Family,
|
||||
standardDv3Family,
|
||||
standardDv4Family,
|
||||
standardDv5Family,
|
||||
standardDCADSv5Family,
|
||||
standardDCASv5Family,
|
||||
standardDCSv2Family,
|
||||
standardDSFamily,
|
||||
standardDSv2Family,
|
||||
standardDSv2PromoFamily,
|
||||
standardEIDSv5Family,
|
||||
standardEIDv5Family,
|
||||
standardEISv5Family,
|
||||
standardEIv5Family,
|
||||
standardEADSv5Family,
|
||||
standardEASv4Family,
|
||||
standardEASv5Family,
|
||||
standardEDSv4Family,
|
||||
standardEDSv5Family,
|
||||
standardEBDSv5Family,
|
||||
standardESv3Family,
|
||||
standardESv4Family,
|
||||
standardESv5Family,
|
||||
standardEBSv5Family,
|
||||
standardEAv4Family,
|
||||
standardEDv4Family,
|
||||
standardEDv5Family,
|
||||
standardEv3Family,
|
||||
standardEv4Family,
|
||||
standardEv5Family,
|
||||
standardEISv3Family,
|
||||
standardEIv3Family,
|
||||
standardXEIDSv4Family,
|
||||
standardXEISv4Family,
|
||||
standardECADSv5Family,
|
||||
standardECASv5Family,
|
||||
standardECIADSv5Family,
|
||||
standardECIASv5Family,
|
||||
standardFFamily,
|
||||
standardFSFamily,
|
||||
standardFSv2Family,
|
||||
standardGFamily,
|
||||
standardGSFamily,
|
||||
standardHFamily,
|
||||
standardHPromoFamily,
|
||||
standardLSFamily,
|
||||
standardLSv2Family,
|
||||
standardMSFamily,
|
||||
standardMDSMediumMemoryv2Family,
|
||||
standardMSMediumMemoryv2Family,
|
||||
standardMIDSMediumMemoryv2Family,
|
||||
standardMISMediumMemoryv2Family,
|
||||
standardMSv2Family,
|
||||
standardNCSv3Family,
|
||||
StandardNCASv3_T4Family,
|
||||
standardNVSv2Family,
|
||||
standardNVSv3Family,
|
||||
standardNVSv4Family
|
||||
}
|
||||
|
||||
export namespace GetSqlMigrationSkuRecommendationsRequest {
|
||||
export const type = new RequestType<SqlMigrationSkuRecommendationsParams, SkuRecommendationResult, void, void>('migration/getskurecommendations');
|
||||
}
|
||||
|
||||
export interface SqlMigrationStartPerfDataCollectionParams {
|
||||
connectionString: string,
|
||||
dataFolder: string,
|
||||
perfQueryIntervalInSec: number,
|
||||
staticQueryIntervalInSec: number,
|
||||
numberOfIterations: number
|
||||
}
|
||||
|
||||
export interface StartPerfDataCollectionResult {
|
||||
dateTimeStarted: Date;
|
||||
}
|
||||
|
||||
export namespace SqlMigrationStartPerfDataCollectionRequest {
|
||||
export const type = new RequestType<SqlMigrationStartPerfDataCollectionParams, StartPerfDataCollectionResult, void, void>('migration/startperfdatacollection');
|
||||
}
|
||||
|
||||
export interface SqlMigrationStopPerfDataCollectionParams {
|
||||
}
|
||||
|
||||
export interface StopPerfDataCollectionResult {
|
||||
dateTimeStopped: Date;
|
||||
}
|
||||
|
||||
export namespace SqlMigrationStopPerfDataCollectionRequest {
|
||||
export const type = new RequestType<SqlMigrationStopPerfDataCollectionParams, StopPerfDataCollectionResult, void, void>('migration/stopperfdatacollection');
|
||||
}
|
||||
|
||||
export interface SqlMigrationRefreshPerfDataCollectionParams {
|
||||
lastRefreshTime: Date
|
||||
}
|
||||
export interface RefreshPerfDataCollectionResult {
|
||||
isCollecting: boolean;
|
||||
messages: string[];
|
||||
errors: string[];
|
||||
refreshTime: Date;
|
||||
}
|
||||
|
||||
export namespace SqlMigrationRefreshPerfDataCollectionRequest {
|
||||
export const type = new RequestType<SqlMigrationRefreshPerfDataCollectionParams, RefreshPerfDataCollectionResult, void, void>('migration/refreshperfdatacollection');
|
||||
}
|
||||
|
||||
export interface StartLoginMigrationsParams {
|
||||
sourceConnectionString: string;
|
||||
targetConnectionString: string;
|
||||
loginList: string[];
|
||||
aadDomainName: string;
|
||||
}
|
||||
|
||||
export enum LoginMigrationStep {
|
||||
StartValidations = 0,
|
||||
MigrateLogins = 1,
|
||||
EstablishUserMapping = 2,
|
||||
MigrateServerRoles = 3,
|
||||
EstablishServerRoleMapping = 4,
|
||||
SetLoginPermissions = 5,
|
||||
SetServerRolePermissions = 6,
|
||||
}
|
||||
|
||||
export interface StartLoginMigrationResult {
|
||||
exceptionMap: { [login: string]: any };
|
||||
completedStep: LoginMigrationStep;
|
||||
elapsedTime: string;
|
||||
}
|
||||
|
||||
export namespace StartLoginMigrationRequest {
|
||||
export const type = new RequestType<StartLoginMigrationsParams, StartLoginMigrationResult, void, void>('migration/startloginmigration');
|
||||
}
|
||||
|
||||
export namespace ValidateLoginMigrationRequest {
|
||||
export const type = new RequestType<StartLoginMigrationsParams, StartLoginMigrationResult, void, void>('migration/validateloginmigration');
|
||||
}
|
||||
|
||||
export namespace MigrateLoginsRequest {
|
||||
export const type = new RequestType<StartLoginMigrationsParams, StartLoginMigrationResult, void, void>('migration/migratelogins');
|
||||
}
|
||||
|
||||
export namespace EstablishUserMappingRequest {
|
||||
export const type = new RequestType<StartLoginMigrationsParams, StartLoginMigrationResult, void, void>('migration/establishusermapping');
|
||||
}
|
||||
|
||||
export namespace MigrateServerRolesAndSetPermissionsRequest {
|
||||
export const type = new RequestType<StartLoginMigrationsParams, StartLoginMigrationResult, void, void>('migration/migrateserverrolesandsetpermissions');
|
||||
}
|
||||
|
||||
export namespace LoginMigrationNotification {
|
||||
export const type = new NotificationType<StartLoginMigrationResult, void>('migration/loginmigrationnotification"');
|
||||
}
|
||||
|
||||
export interface ISqlMigrationService {
|
||||
providerId: string;
|
||||
getAssessments(ownerUri: string, databases: string[], xEventsFilesFolderPath: string): Thenable<AssessmentResult | undefined>;
|
||||
getSkuRecommendations(dataFolder: string, perfQueryIntervalInSec: number, targetPlatforms: string[], targetSqlInstance: string, targetPercentile: number, scalingFactor: number, startTime: string, endTime: string, includePreviewSkus: boolean, databaseAllowList: string[]): Promise<SkuRecommendationResult | undefined>;
|
||||
startPerfDataCollection(ownerUri: string, dataFolder: string, perfQueryIntervalInSec: number, staticQueryIntervalInSec: number, numberOfIterations: number): Promise<StartPerfDataCollectionResult | undefined>;
|
||||
stopPerfDataCollection(): Promise<StopPerfDataCollectionResult | undefined>;
|
||||
refreshPerfDataCollection(lastRefreshedTime: Date): Promise<RefreshPerfDataCollectionResult | undefined>;
|
||||
startLoginMigration(sourceConnectionString: string, targetConnectionString: string, loginList: string[], aadDomainName: string): Promise<StartLoginMigrationResult | undefined>;
|
||||
validateLoginMigration(sourceConnectionString: string, targetConnectionString: string, loginList: string[], aadDomainName: string): Promise<StartLoginMigrationResult | undefined>;
|
||||
migrateLogins(sourceConnectionString: string, targetConnectionString: string, loginList: string[], aadDomainName: string): Promise<StartLoginMigrationResult | undefined>;
|
||||
establishUserMapping(sourceConnectionString: string, targetConnectionString: string, loginList: string[], aadDomainName: string): Promise<StartLoginMigrationResult | undefined>;
|
||||
migrateServerRolesAndSetPermissions(sourceConnectionString: string, targetConnectionString: string, loginList: string[], aadDomainName: string): Promise<StartLoginMigrationResult | undefined>;
|
||||
migrateCertificate(
|
||||
encryptedDatabases: string[],
|
||||
sourceSqlConnectionString: string,
|
||||
targetSubscriptionId: string,
|
||||
targetResourceGroupName: string,
|
||||
targetManagedInstanceName: string,
|
||||
networkSharePath: string,
|
||||
accessToken: string,
|
||||
reportUpdate: (dbName: string, succeeded: boolean, message: string) => void): Promise<TdeMigrationResult | undefined>;
|
||||
}
|
||||
|
||||
export interface TdeMigrationRequest {
|
||||
encryptedDatabases: string[];
|
||||
sourceSqlConnectionString: string;
|
||||
targetSubscriptionId: string;
|
||||
targetResourceGroupName: string;
|
||||
targetManagedInstanceName: string;
|
||||
}
|
||||
|
||||
export interface TdeMigrationEntryResult {
|
||||
dbName: string;
|
||||
success: boolean;
|
||||
message: string;
|
||||
}
|
||||
|
||||
export interface TdeMigrationResult {
|
||||
migrationStatuses: TdeMigrationEntryResult[];
|
||||
}
|
||||
|
||||
export namespace TdeMigrateRequest {
|
||||
export const type = new RequestType<TdeMigrationParams, TdeMigrationResult, void, void>('migration/tdemigration');
|
||||
}
|
||||
|
||||
export interface TdeMigrationParams {
|
||||
encryptedDatabases: string[];
|
||||
sourceSqlConnectionString: string;
|
||||
targetSubscriptionId: string;
|
||||
targetResourceGroupName: string;
|
||||
targetManagedInstanceName: string;
|
||||
networkSharePath: string;
|
||||
networkShareDomain: string;
|
||||
networkShareUserName: string;
|
||||
networkSharePassword: string;
|
||||
accessToken: string;
|
||||
}
|
||||
|
||||
export namespace TdeMigrateProgressEvent {
|
||||
export const type = new NotificationType<TdeMigrateProgressParams, void>('migration/tdemigrationprogress');
|
||||
}
|
||||
|
||||
|
||||
export interface TdeMigrateProgressParams {
|
||||
name: string;
|
||||
success: boolean;
|
||||
message: string;
|
||||
}
|
||||
320
extensions/sql-migration/src/service/features.ts
Normal file
320
extensions/sql-migration/src/service/features.ts
Normal file
@@ -0,0 +1,320 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { SqlOpsDataClient, SqlOpsFeature } from 'dataprotocol-client';
|
||||
import {
|
||||
ClientCapabilities,
|
||||
RPCMessageType,
|
||||
ServerCapabilities,
|
||||
} from 'vscode-languageclient';
|
||||
|
||||
import * as UUID from 'vscode-languageclient/lib/utils/uuid';
|
||||
import { Disposable } from 'vscode';
|
||||
|
||||
import * as contracts from './contracts';
|
||||
import { migrationServiceProvider } from './provider';
|
||||
|
||||
export enum ApiType {
|
||||
SqlMigrationProvider = 'SqlMigrationProvider',
|
||||
}
|
||||
|
||||
|
||||
export abstract class MigrationExtensionService extends SqlOpsFeature<undefined> {
|
||||
abstract providerId: ApiType;
|
||||
}
|
||||
|
||||
export class SqlMigrationService extends MigrationExtensionService implements contracts.ISqlMigrationService {
|
||||
private _reportUpdate: ((dbName: string, succeeded: boolean, error: string) => void) | undefined = undefined;
|
||||
|
||||
override providerId = ApiType.SqlMigrationProvider;
|
||||
|
||||
private static readonly messagesTypes: RPCMessageType[] = [
|
||||
contracts.GetSqlMigrationAssessmentItemsRequest.type,
|
||||
contracts.GetSqlMigrationSkuRecommendationsRequest.type,
|
||||
contracts.SqlMigrationStartPerfDataCollectionRequest.type,
|
||||
contracts.SqlMigrationRefreshPerfDataCollectionRequest.type,
|
||||
contracts.SqlMigrationStopPerfDataCollectionRequest.type,
|
||||
contracts.StartLoginMigrationRequest.type,
|
||||
contracts.ValidateLoginMigrationRequest.type,
|
||||
contracts.MigrateLoginsRequest.type,
|
||||
contracts.EstablishUserMappingRequest.type,
|
||||
contracts.MigrateServerRolesAndSetPermissionsRequest.type,
|
||||
contracts.TdeMigrateRequest.type
|
||||
];
|
||||
|
||||
constructor(client: SqlOpsDataClient) {
|
||||
super(client, SqlMigrationService.messagesTypes);
|
||||
}
|
||||
|
||||
public initialize(capabilities: ServerCapabilities): void {
|
||||
this.register(this.messages, {
|
||||
id: UUID.generateUuid(),
|
||||
registerOptions: undefined
|
||||
});
|
||||
|
||||
this._client.onNotification(contracts.TdeMigrateProgressEvent.type, e => {
|
||||
if (this._reportUpdate === undefined) {
|
||||
return;
|
||||
}
|
||||
this._reportUpdate(e.name, e.success, e.message);
|
||||
});
|
||||
}
|
||||
|
||||
protected registerProvider(options: undefined): Disposable {
|
||||
migrationServiceProvider.addService(this);
|
||||
return this;
|
||||
}
|
||||
|
||||
public fillClientCapabilities(capabilities: ClientCapabilities): void {
|
||||
// this isn't explicitly necessary
|
||||
}
|
||||
|
||||
async getAssessments(connectionString: string, databases: string[], xEventsFilesFolderPath: string): Promise<contracts.AssessmentResult | undefined> {
|
||||
let params: contracts.SqlMigrationAssessmentParams = { connectionString: connectionString, databases: databases, xEventsFilesFolderPath: xEventsFilesFolderPath };
|
||||
try {
|
||||
return this._client.sendRequest(contracts.GetSqlMigrationAssessmentItemsRequest.type, params);
|
||||
}
|
||||
catch (e) {
|
||||
this._client.logFailedRequest(contracts.GetSqlMigrationAssessmentItemsRequest.type, e);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
async getSkuRecommendations(
|
||||
dataFolder: string,
|
||||
perfQueryIntervalInSec: number,
|
||||
targetPlatforms: string[],
|
||||
targetSqlInstance: string,
|
||||
targetPercentile: number,
|
||||
scalingFactor: number,
|
||||
startTime: string,
|
||||
endTime: string,
|
||||
includePreviewSkus: boolean,
|
||||
databaseAllowList: string[]): Promise<contracts.SkuRecommendationResult | undefined> {
|
||||
let params: contracts.SqlMigrationSkuRecommendationsParams = {
|
||||
dataFolder,
|
||||
perfQueryIntervalInSec,
|
||||
targetPlatforms,
|
||||
targetSqlInstance,
|
||||
targetPercentile,
|
||||
scalingFactor,
|
||||
startTime,
|
||||
endTime,
|
||||
includePreviewSkus,
|
||||
databaseAllowList
|
||||
};
|
||||
|
||||
try {
|
||||
return this._client.sendRequest(contracts.GetSqlMigrationSkuRecommendationsRequest.type, params);
|
||||
}
|
||||
catch (e) {
|
||||
this._client.logFailedRequest(contracts.GetSqlMigrationSkuRecommendationsRequest.type, e);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
async startPerfDataCollection(
|
||||
connectionString: string,
|
||||
dataFolder: string,
|
||||
perfQueryIntervalInSec: number,
|
||||
staticQueryIntervalInSec: number,
|
||||
numberOfIterations: number): Promise<contracts.StartPerfDataCollectionResult | undefined> {
|
||||
let params: contracts.SqlMigrationStartPerfDataCollectionParams = {
|
||||
connectionString: connectionString,
|
||||
dataFolder,
|
||||
perfQueryIntervalInSec,
|
||||
staticQueryIntervalInSec,
|
||||
numberOfIterations
|
||||
};
|
||||
|
||||
try {
|
||||
return this._client.sendRequest(contracts.SqlMigrationStartPerfDataCollectionRequest.type, params);
|
||||
}
|
||||
catch (e) {
|
||||
this._client.logFailedRequest(contracts.SqlMigrationStartPerfDataCollectionRequest.type, e);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
async stopPerfDataCollection(): Promise<contracts.StopPerfDataCollectionResult | undefined> {
|
||||
let params: contracts.SqlMigrationStopPerfDataCollectionParams = {};
|
||||
|
||||
try {
|
||||
return this._client.sendRequest(contracts.SqlMigrationStopPerfDataCollectionRequest.type, params);
|
||||
}
|
||||
catch (e) {
|
||||
this._client.logFailedRequest(contracts.SqlMigrationStopPerfDataCollectionRequest.type, e);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
async refreshPerfDataCollection(lastRefreshedTime: Date): Promise<contracts.RefreshPerfDataCollectionResult | undefined> {
|
||||
let params: contracts.SqlMigrationStopPerfDataCollectionParams = {
|
||||
lastRefreshedTime
|
||||
};
|
||||
|
||||
try {
|
||||
return this._client.sendRequest(contracts.SqlMigrationRefreshPerfDataCollectionRequest.type, params);
|
||||
}
|
||||
catch (e) {
|
||||
this._client.logFailedRequest(contracts.SqlMigrationRefreshPerfDataCollectionRequest.type, e);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
async startLoginMigration(
|
||||
sourceConnectionString: string,
|
||||
targetConnectionString: string,
|
||||
loginList: string[],
|
||||
aadDomainName: string): Promise<contracts.StartLoginMigrationResult | undefined> {
|
||||
let params: contracts.StartLoginMigrationsParams = {
|
||||
sourceConnectionString,
|
||||
targetConnectionString,
|
||||
loginList,
|
||||
aadDomainName
|
||||
};
|
||||
|
||||
try {
|
||||
return this._client.sendRequest(contracts.StartLoginMigrationRequest.type, params);
|
||||
}
|
||||
catch (e) {
|
||||
this._client.logFailedRequest(contracts.StartLoginMigrationRequest.type, e);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
async validateLoginMigration(
|
||||
sourceConnectionString: string,
|
||||
targetConnectionString: string,
|
||||
loginList: string[],
|
||||
aadDomainName: string): Promise<contracts.StartLoginMigrationResult | undefined> {
|
||||
let params: contracts.StartLoginMigrationsParams = {
|
||||
sourceConnectionString,
|
||||
targetConnectionString,
|
||||
loginList,
|
||||
aadDomainName
|
||||
};
|
||||
|
||||
try {
|
||||
return this._client.sendRequest(contracts.ValidateLoginMigrationRequest.type, params);
|
||||
|
||||
}
|
||||
catch (e) {
|
||||
this._client.logFailedRequest(contracts.ValidateLoginMigrationRequest.type, e);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
async migrateLogins(
|
||||
sourceConnectionString: string,
|
||||
targetConnectionString: string,
|
||||
loginList: string[],
|
||||
aadDomainName: string): Promise<contracts.StartLoginMigrationResult | undefined> {
|
||||
let params: contracts.StartLoginMigrationsParams = {
|
||||
sourceConnectionString,
|
||||
targetConnectionString,
|
||||
loginList,
|
||||
aadDomainName
|
||||
};
|
||||
|
||||
try {
|
||||
return this._client.sendRequest(contracts.MigrateLoginsRequest.type, params);
|
||||
}
|
||||
catch (e) {
|
||||
this._client.logFailedRequest(contracts.MigrateLoginsRequest.type, e);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
async establishUserMapping(
|
||||
sourceConnectionString: string,
|
||||
targetConnectionString: string,
|
||||
loginList: string[],
|
||||
aadDomainName: string): Promise<contracts.StartLoginMigrationResult | undefined> {
|
||||
let params: contracts.StartLoginMigrationsParams = {
|
||||
sourceConnectionString,
|
||||
targetConnectionString,
|
||||
loginList,
|
||||
aadDomainName
|
||||
};
|
||||
|
||||
try {
|
||||
return this._client.sendRequest(contracts.EstablishUserMappingRequest.type, params);
|
||||
}
|
||||
catch (e) {
|
||||
this._client.logFailedRequest(contracts.EstablishUserMappingRequest.type, e);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
async migrateServerRolesAndSetPermissions(
|
||||
sourceConnectionString: string,
|
||||
targetConnectionString: string,
|
||||
loginList: string[],
|
||||
aadDomainName: string): Promise<contracts.StartLoginMigrationResult | undefined> {
|
||||
let params: contracts.StartLoginMigrationsParams = {
|
||||
sourceConnectionString,
|
||||
targetConnectionString,
|
||||
loginList,
|
||||
aadDomainName
|
||||
};
|
||||
|
||||
try {
|
||||
return this._client.sendRequest(contracts.MigrateServerRolesAndSetPermissionsRequest.type, params);
|
||||
}
|
||||
catch (e) {
|
||||
this._client.logFailedRequest(contracts.MigrateServerRolesAndSetPermissionsRequest.type, e);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
async migrateCertificate(
|
||||
tdeEnabledDatabases: string[],
|
||||
sourceSqlConnectionString: string,
|
||||
targetSubscriptionId: string,
|
||||
targetResourceGroupName: string,
|
||||
targetManagedInstanceName: string,
|
||||
networkSharePath: string,
|
||||
accessToken: string,
|
||||
reportUpdate: (dbName: string, succeeded: boolean, message: string) => void): Promise<contracts.TdeMigrationResult | undefined> {
|
||||
|
||||
this._reportUpdate = reportUpdate;
|
||||
let params: contracts.TdeMigrationParams = {
|
||||
encryptedDatabases: tdeEnabledDatabases,
|
||||
sourceSqlConnectionString: sourceSqlConnectionString,
|
||||
targetSubscriptionId: targetSubscriptionId,
|
||||
targetResourceGroupName: targetResourceGroupName,
|
||||
targetManagedInstanceName: targetManagedInstanceName,
|
||||
networkSharePath: networkSharePath,
|
||||
networkShareDomain: 'a', // Will remove this on the next STS version
|
||||
networkShareUserName: 'b',
|
||||
networkSharePassword: 'c',
|
||||
accessToken: accessToken
|
||||
};
|
||||
|
||||
try {
|
||||
// This call needs to be awaited so, the updates are sent during the execution of the task.
|
||||
// If the task is not await, the finally block will execute and no update will be sent.
|
||||
const result = await this._client.sendRequest(contracts.TdeMigrateRequest.type, params);
|
||||
return result;
|
||||
}
|
||||
catch (e) {
|
||||
this._client.logFailedRequest(contracts.TdeMigrateRequest.type, e);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
46
extensions/sql-migration/src/service/provider.ts
Normal file
46
extensions/sql-migration/src/service/provider.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { ApiType, MigrationExtensionService } from './features';
|
||||
import * as constants from '../constants/strings';
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
export class MigrationServiceProvider {
|
||||
private services: Map<ApiType, MigrationExtensionService> = new Map();
|
||||
|
||||
constructor() {
|
||||
}
|
||||
|
||||
public addService(service: MigrationExtensionService) {
|
||||
this.services.set(service.providerId, service);
|
||||
}
|
||||
|
||||
public async getService(serviceId: ApiType): Promise<MigrationExtensionService> {
|
||||
if (this.services.has(serviceId)) {
|
||||
return this.services.get(serviceId)!;
|
||||
}
|
||||
return this.waitUntilProviderReady(serviceId);
|
||||
}
|
||||
|
||||
public async waitUntilProviderReady(serviceId: ApiType): Promise<MigrationExtensionService> {
|
||||
const service = await vscode.window.withProgress({
|
||||
location: vscode.ProgressLocation.Notification,
|
||||
title: constants.waitingForService(serviceId),
|
||||
cancellable: false
|
||||
}, (progress, token) => {
|
||||
return new Promise<MigrationExtensionService>(resolve => {
|
||||
const interval = setInterval(() => {
|
||||
if (this.services.has(serviceId)) {
|
||||
clearInterval(interval);
|
||||
resolve(this.services.get(serviceId)!);
|
||||
}
|
||||
}, 250);
|
||||
});
|
||||
});
|
||||
return service;
|
||||
}
|
||||
}
|
||||
|
||||
export const migrationServiceProvider = new MigrationServiceProvider();
|
||||
230
extensions/sql-migration/src/service/serviceClient.ts
Normal file
230
extensions/sql-migration/src/service/serviceClient.ts
Normal file
@@ -0,0 +1,230 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { SqlOpsDataClient, ClientOptions } from 'dataprotocol-client';
|
||||
import { ServerProvider, Events, LogLevel, IConfig } from '@microsoft/ads-service-downloader';
|
||||
import { ServerOptions, TransportKind } from 'vscode-languageclient';
|
||||
import * as vscode from 'vscode';
|
||||
import * as nls from 'vscode-nls';
|
||||
const localize = nls.loadMessageBundle();
|
||||
import * as path from 'path';
|
||||
import { EventAndListener } from 'eventemitter2';
|
||||
import { SqlMigrationService } from './features';
|
||||
import { promises as fs } from 'fs';
|
||||
import * as constants from '../constants/strings';
|
||||
import { IMessage } from './contracts';
|
||||
import { ErrorAction, CloseAction } from 'vscode-languageclient';
|
||||
import { env } from 'process';
|
||||
import { exists } from './utils';
|
||||
import { logError, TelemetryViews } from '../telemetry';
|
||||
|
||||
export class ServiceClient {
|
||||
private statusView: vscode.StatusBarItem;
|
||||
|
||||
constructor(
|
||||
private outputChannel: vscode.OutputChannel,
|
||||
) {
|
||||
this.statusView = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left);
|
||||
}
|
||||
|
||||
public async startService(context: vscode.ExtensionContext): Promise<SqlOpsDataClient | undefined> {
|
||||
const rawConfig = await fs.readFile(path.join(context.extensionPath, 'config.json'));
|
||||
let clientOptions: ClientOptions = this.createClientOptions();
|
||||
try {
|
||||
let client: SqlOpsDataClient;
|
||||
let serviceBinary: string = '';
|
||||
let downloadBinary = true;
|
||||
if (env['ADS_MIGRATIONSERVICE']) {
|
||||
const config = <IConfig>JSON.parse(rawConfig.toString());
|
||||
for (let executableFile of config.executableFiles) {
|
||||
const executableFilePath = path.join(env['ADS_MIGRATIONSERVICE'], executableFile);
|
||||
if (await exists(executableFilePath)) {
|
||||
downloadBinary = false;
|
||||
serviceBinary = executableFilePath;
|
||||
}
|
||||
}
|
||||
if (!downloadBinary) {
|
||||
vscode.window.showInformationMessage('Using Migration service found at: ' + serviceBinary).then((v) => { }, (r) => { });
|
||||
} else {
|
||||
vscode.window.showErrorMessage('Failed to find migration service binary falling back to downloaded binary').then((v) => { }, (r) => { });
|
||||
}
|
||||
}
|
||||
if (downloadBinary) {
|
||||
serviceBinary = await this.downloadBinaries(context, rawConfig);
|
||||
}
|
||||
let serverOptions = this.generateServerOptions(serviceBinary, context);
|
||||
client = new SqlOpsDataClient(constants.serviceName, serverOptions, clientOptions);
|
||||
client.onReady().then(() => {
|
||||
this.statusView.text = localize('serviceStarted', "{0} Started", constants.serviceName);
|
||||
setTimeout(() => {
|
||||
this.statusView.hide();
|
||||
}, 1500);
|
||||
}).catch(e => {
|
||||
console.error(e);
|
||||
});
|
||||
this.statusView.show();
|
||||
this.statusView.text = localize('serviceStarting', "Starting {0}", constants.serviceName);
|
||||
let disposable = client.start();
|
||||
context.subscriptions.push(disposable);
|
||||
return client;
|
||||
}
|
||||
catch (error) {
|
||||
await vscode.window.showErrorMessage(localize('flatFileImport.serviceStartFailed', "Failed to start {0}: {1}", constants.serviceName, error.stack.toString()));
|
||||
logError(TelemetryViews.SqlServerDashboard, error.stack.toString(), error);
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
public async downloadBinaries(context: vscode.ExtensionContext, rawConfig: Buffer): Promise<string> {
|
||||
const config = JSON.parse(rawConfig.toString());
|
||||
config.installDirectory = path.join(context.extensionPath, config.installDirectory);
|
||||
config.proxy = vscode.workspace.getConfiguration('http').get('proxy');
|
||||
config.strictSSL = vscode.workspace.getConfiguration('http').get('proxyStrictSSL') || true;
|
||||
const serverdownloader = new ServerProvider(config);
|
||||
serverdownloader.eventEmitter.onAny(this.generateHandleServerProviderEvent());
|
||||
return serverdownloader.getOrDownloadServer();
|
||||
}
|
||||
|
||||
private createClientOptions(): ClientOptions {
|
||||
return {
|
||||
providerId: constants.providerId,
|
||||
errorHandler: new LanguageClientErrorHandler(),
|
||||
synchronize: {
|
||||
configurationSection: [constants.extensionConfigSectionName, constants.sqlConfigSectionName]
|
||||
},
|
||||
features: [
|
||||
// we only want to add new features
|
||||
SqlMigrationService,
|
||||
],
|
||||
outputChannel: this.outputChannel
|
||||
};
|
||||
}
|
||||
|
||||
private generateServerOptions(executablePath: string, context: vscode.ExtensionContext): ServerOptions {
|
||||
let launchArgs = [];
|
||||
launchArgs.push(`--locale`, vscode.env.language);
|
||||
launchArgs.push('--log-file', path.join(context.logUri.fsPath));
|
||||
launchArgs.push('--tracing-level', this.getConfigTracingLevel());
|
||||
launchArgs.push('--autoflush-log');
|
||||
return { command: executablePath, args: launchArgs, transport: TransportKind.stdio };
|
||||
}
|
||||
|
||||
private getConfigTracingLevel(): TracingLevel {
|
||||
let config = vscode.workspace.getConfiguration('mssql');
|
||||
if (config) {
|
||||
return config['tracingLevel'];
|
||||
} else {
|
||||
return TracingLevel.Critical;
|
||||
}
|
||||
}
|
||||
|
||||
private generateHandleServerProviderEvent(): EventAndListener {
|
||||
let dots = 0;
|
||||
return (e: string | string[], ...args: any[]) => {
|
||||
switch (e) {
|
||||
case Events.INSTALL_START:
|
||||
this.outputChannel.show(true);
|
||||
this.statusView.show();
|
||||
this.outputChannel.appendLine(localize('installingServiceDetailed', "Installing {0} to {1}", constants.serviceName, args[0]));
|
||||
this.statusView.text = localize('installingService', "Installing {0} Service", constants.serviceName);
|
||||
break;
|
||||
case Events.INSTALL_END:
|
||||
this.outputChannel.appendLine(localize('serviceInstalled', "Installed {0}", constants.serviceName));
|
||||
break;
|
||||
case Events.DOWNLOAD_START:
|
||||
this.outputChannel.appendLine(localize('downloadingService', "Downloading {0}", args[0]));
|
||||
this.outputChannel.append(localize('downloadingServiceSize', "({0} KB)", Math.ceil(args[1] / 1024).toLocaleString(vscode.env.language)));
|
||||
this.statusView.text = localize('downloadingServiceStatus', "Downloading {0}", constants.serviceName);
|
||||
break;
|
||||
case Events.DOWNLOAD_PROGRESS:
|
||||
let newDots = Math.ceil(args[0] / 5);
|
||||
if (newDots > dots) {
|
||||
this.outputChannel.append('.'.repeat(newDots - dots));
|
||||
dots = newDots;
|
||||
}
|
||||
break;
|
||||
case Events.DOWNLOAD_END:
|
||||
this.outputChannel.appendLine(localize('downloadingServiceComplete', "Done downloading {0}", constants.serviceName));
|
||||
break;
|
||||
case Events.ENTRY_EXTRACTED:
|
||||
this.outputChannel.appendLine(localize('entryExtractedChannelMsg', "Extracted {0} ({1}/{2})", args[0], args[1], args[2]));
|
||||
break;
|
||||
case Events.LOG_EMITTED:
|
||||
if (args[0] >= LogLevel.Warning) {
|
||||
this.outputChannel.appendLine(args[1]);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle Language Service client errors
|
||||
*/
|
||||
class LanguageClientErrorHandler {
|
||||
|
||||
/**
|
||||
* Creates an instance of LanguageClientErrorHandler.
|
||||
* @memberOf LanguageClientErrorHandler
|
||||
*/
|
||||
constructor() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Show an error message prompt with a link to known issues wiki page
|
||||
* @memberOf LanguageClientErrorHandler
|
||||
*/
|
||||
showOnErrorPrompt(error: Error): void {
|
||||
// TODO add telemetry
|
||||
// Telemetry.sendTelemetryEvent('SqlToolsServiceCrash');
|
||||
console.log(error);
|
||||
vscode.window.showErrorMessage(
|
||||
constants.serviceCrashMessage(error.message),
|
||||
).then(() => { }, () => { });
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for language service client error
|
||||
*
|
||||
* @memberOf LanguageClientErrorHandler
|
||||
*/
|
||||
error(error: Error, message: IMessage, count: number): ErrorAction {
|
||||
this.showOnErrorPrompt(error);
|
||||
|
||||
// we don't retry running the service since crashes leave the extension
|
||||
// in a bad, unrecovered state
|
||||
return ErrorAction.Shutdown;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for language service client closed
|
||||
*
|
||||
* @memberOf LanguageClientErrorHandler
|
||||
*/
|
||||
closed(): CloseAction {
|
||||
this.showOnErrorPrompt({ name: 'Service crashed', message: constants.serviceCrashed });
|
||||
|
||||
// we don't retry running the service since crashes leave the extension
|
||||
// in a bad, unrecovered state
|
||||
return CloseAction.DoNotRestart;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The tracing level defined in the package.json
|
||||
*/
|
||||
enum TracingLevel {
|
||||
All = 'All',
|
||||
Off = 'Off',
|
||||
Critical = 'Critical',
|
||||
Error = 'Error',
|
||||
Warning = 'Warning',
|
||||
Information = 'Information',
|
||||
Verbose = 'Verbose'
|
||||
}
|
||||
16
extensions/sql-migration/src/service/utils.ts
Normal file
16
extensions/sql-migration/src/service/utils.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { promises as fs } from 'fs';
|
||||
|
||||
|
||||
export async function exists(path: string): Promise<boolean> {
|
||||
try {
|
||||
await fs.access(path);
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
import * as azdata from 'azdata';
|
||||
import * as vscode from 'vscode';
|
||||
import * as utils from '../api/utils';
|
||||
import * as mssql from 'mssql';
|
||||
import * as contracts from '../service/contracts';
|
||||
import { MigrationWizardPage } from '../models/migrationWizardPage';
|
||||
import { MigrationStateModel, MigrationTargetType, PerformanceDataSourceOptions, StateChangeEvent, AssessmentRuleId } from '../models/stateMachine';
|
||||
import { AssessmentResultsDialog } from '../dialog/assessmentResults/assessmentResultsDialog';
|
||||
@@ -708,12 +708,12 @@ export class SKURecommendationPage extends MigrationWizardPage {
|
||||
constants.SKU_RECOMMENDATION_NO_RECOMMENDATION;
|
||||
}
|
||||
else {
|
||||
const serviceTier = recommendation.targetSku.category?.sqlServiceTier === mssql.AzureSqlPaaSServiceTier.GeneralPurpose
|
||||
const serviceTier = recommendation.targetSku.category?.sqlServiceTier === contracts.AzureSqlPaaSServiceTier.GeneralPurpose
|
||||
? constants.GENERAL_PURPOSE
|
||||
: constants.BUSINESS_CRITICAL;
|
||||
const hardwareType = recommendation.targetSku.category?.hardwareType === mssql.AzureSqlPaaSHardwareType.Gen5
|
||||
const hardwareType = recommendation.targetSku.category?.hardwareType === contracts.AzureSqlPaaSHardwareType.Gen5
|
||||
? constants.GEN5
|
||||
: recommendation.targetSku.category?.hardwareType === mssql.AzureSqlPaaSHardwareType.PremiumSeries
|
||||
: recommendation.targetSku.category?.hardwareType === contracts.AzureSqlPaaSHardwareType.PremiumSeries
|
||||
? constants.PREMIUM_SERIES
|
||||
: constants.PREMIUM_SERIES_MEMORY_OPTIMIZED;
|
||||
this._rbg.cards[index].descriptions[CardDescriptionIndex.SKU_RECOMMENDATION].textValue =
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import * as azdata from 'azdata';
|
||||
import * as vscode from 'vscode';
|
||||
import * as mssql from 'mssql';
|
||||
import { MigrationStateModel, NetworkContainerType, Page } from '../models/stateMachine';
|
||||
import * as loc from '../constants/strings';
|
||||
import { MigrationWizardPage } from '../models/migrationWizardPage';
|
||||
@@ -35,19 +34,13 @@ export class WizardController {
|
||||
}
|
||||
|
||||
public async openWizard(): Promise<void> {
|
||||
const api = (await vscode.extensions.getExtension(mssql.extension.name)?.activate()) as mssql.IExtension;
|
||||
if (api) {
|
||||
this.extensionContext.subscriptions.push(this._model);
|
||||
await this.createWizard(this._model);
|
||||
}
|
||||
this.extensionContext.subscriptions.push(this._model);
|
||||
await this.createWizard(this._model);
|
||||
}
|
||||
|
||||
public async openLoginWizard(): Promise<void> {
|
||||
const api = (await vscode.extensions.getExtension(mssql.extension.name)?.activate()) as mssql.IExtension;
|
||||
if (api) {
|
||||
this.extensionContext.subscriptions.push(this._model);
|
||||
await this.createLoginWizard(this._model);
|
||||
}
|
||||
this.extensionContext.subscriptions.push(this._model);
|
||||
await this.createLoginWizard(this._model);
|
||||
}
|
||||
|
||||
private async createWizard(stateModel: MigrationStateModel): Promise<void> {
|
||||
|
||||
Reference in New Issue
Block a user