mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-17 01:25:36 -05:00
Adding support for sql vm and some target page UI fixes. (#14571)
* Added SQL VM dropdown Fixed the icons in cards * Added a better api for sql vms * Making some PR related changes 1. Using map instead of foreach
This commit is contained in:
@@ -7,10 +7,12 @@ import * as azdata from 'azdata';
|
||||
import { azureResource } from 'azureResource';
|
||||
import * as vscode from 'vscode';
|
||||
import * as mssql from '../../../mssql';
|
||||
import { getAvailableManagedInstanceProducts, getAvailableStorageAccounts, getBlobContainers, getFileShares, getMigrationControllers, getSubscriptions, SqlMigrationController, SqlManagedInstance, startDatabaseMigration, StartDatabaseMigrationRequest, StorageAccount } from '../api/azure';
|
||||
import { getAvailableManagedInstanceProducts, getAvailableStorageAccounts, getBlobContainers, getFileShares, getMigrationControllers, getSubscriptions, SqlMigrationController, SqlManagedInstance, startDatabaseMigration, StartDatabaseMigrationRequest, StorageAccount, getAvailableSqlVMs, SqlVMServer } from '../api/azure';
|
||||
import { SKURecommendations } from './externalContract';
|
||||
import * as constants from '../constants/strings';
|
||||
import { MigrationLocalStorage } from './migrationLocalStorage';
|
||||
import * as nls from 'vscode-nls';
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
export enum State {
|
||||
INIT,
|
||||
@@ -82,8 +84,8 @@ export class MigrationStateModel implements Model, vscode.Disposable {
|
||||
|
||||
public _targetSubscription!: azureResource.AzureResourceSubscription;
|
||||
public _targetManagedInstances!: SqlManagedInstance[];
|
||||
public _targetManagedInstance!: SqlManagedInstance;
|
||||
|
||||
public _targetSqlVirtualMachines!: SqlVMServer[];
|
||||
public _targetServerInstance!: SqlManagedInstance;
|
||||
public _databaseBackup!: DatabaseBackupModel;
|
||||
public _migrationDbs: string[] = [];
|
||||
public _storageAccounts!: StorageAccount[];
|
||||
@@ -266,6 +268,41 @@ export class MigrationStateModel implements Model, vscode.Disposable {
|
||||
return this._targetManagedInstances[index];
|
||||
}
|
||||
|
||||
public async getSqlVirtualMachineValues(subscription: azureResource.AzureResourceSubscription): Promise<azdata.CategoryValue[]> {
|
||||
let virtualMachineValues: azdata.CategoryValue[] = [];
|
||||
try {
|
||||
this._targetSqlVirtualMachines = await getAvailableSqlVMs(this._azureAccount, subscription);
|
||||
virtualMachineValues = this._targetSqlVirtualMachines.map((virtualMachine) => {
|
||||
return {
|
||||
name: virtualMachine.id,
|
||||
displayName: `${virtualMachine.name}`
|
||||
};
|
||||
});
|
||||
|
||||
if (virtualMachineValues.length === 0) {
|
||||
virtualMachineValues = [
|
||||
{
|
||||
displayName: constants.NO_VIRTUAL_MACHINE_FOUND,
|
||||
name: ''
|
||||
}
|
||||
];
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
virtualMachineValues = [
|
||||
{
|
||||
displayName: constants.NO_VIRTUAL_MACHINE_FOUND,
|
||||
name: ''
|
||||
}
|
||||
];
|
||||
}
|
||||
return virtualMachineValues;
|
||||
}
|
||||
|
||||
public getVirtualMachine(index: number): SqlVMServer {
|
||||
return this._targetSqlVirtualMachines[index];
|
||||
}
|
||||
|
||||
public async getStorageAccountValues(subscription: azureResource.AzureResourceSubscription): Promise<azdata.CategoryValue[]> {
|
||||
let storageAccountValues: azdata.CategoryValue[] = [];
|
||||
try {
|
||||
@@ -441,7 +478,7 @@ export class MigrationStateModel implements Model, vscode.Disposable {
|
||||
Username: currentConnection?.userName!,
|
||||
Password: connectionPassword.password
|
||||
},
|
||||
Scope: this._targetManagedInstance.id
|
||||
Scope: this._targetServerInstance.id
|
||||
}
|
||||
};
|
||||
|
||||
@@ -452,10 +489,9 @@ export class MigrationStateModel implements Model, vscode.Disposable {
|
||||
const response = await startDatabaseMigration(
|
||||
this._azureAccount,
|
||||
this._targetSubscription,
|
||||
this._targetManagedInstance.resourceGroup!,
|
||||
this._migrationController?.properties.location!,
|
||||
this._targetManagedInstance.name,
|
||||
currentConnection?.databaseName!,
|
||||
this._targetServerInstance,
|
||||
db,
|
||||
requestBody
|
||||
);
|
||||
|
||||
@@ -463,12 +499,12 @@ export class MigrationStateModel implements Model, vscode.Disposable {
|
||||
MigrationLocalStorage.saveMigration(
|
||||
currentConnection!,
|
||||
response.databaseMigration,
|
||||
this._targetManagedInstance,
|
||||
this._targetServerInstance,
|
||||
this._azureAccount,
|
||||
this._targetSubscription,
|
||||
this._migrationController
|
||||
);
|
||||
vscode.window.showInformationMessage(`Starting migration for database ${db} to ${this._targetManagedInstance.name}`);
|
||||
vscode.window.showInformationMessage(localize("sql.migration.starting.migration.message", 'Starting migration for database {0} to {1}', db, this._targetServerInstance.name));
|
||||
}
|
||||
} catch (e) {
|
||||
vscode.window.showInformationMessage(e);
|
||||
|
||||
Reference in New Issue
Block a user