mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-07 17:23:56 -05:00
revert the notebook background execution (#7984)
This commit is contained in:
@@ -15,10 +15,9 @@ import { ClusterSettingsPage } from './pages/clusterSettingsPage';
|
||||
import { ServiceSettingsPage } from './pages/serviceSettingsPage';
|
||||
import { TargetClusterContextPage } from './pages/targetClusterPage';
|
||||
import { IKubeService } from '../../services/kubeService';
|
||||
import { IAzdataService, BdcEndpoint } from '../../services/azdataService';
|
||||
import { IAzdataService } from '../../services/azdataService';
|
||||
import { DeploymentProfilePage } from './pages/deploymentProfilePage';
|
||||
import { INotebookService } from '../../services/notebookService';
|
||||
import { getErrorMessage, getDateTimeString } from '../../utils';
|
||||
import { DeployClusterWizardModel, AuthenticationMode } from './deployClusterWizardModel';
|
||||
import * as VariableNames from './constants';
|
||||
import * as os from 'os';
|
||||
@@ -28,7 +27,6 @@ const localize = nls.loadMessageBundle();
|
||||
|
||||
export class DeployClusterWizard extends WizardBase<DeployClusterWizard, DeployClusterWizardModel> {
|
||||
private _saveConfigButton: azdata.window.Button;
|
||||
private _scriptToNotebookButton: azdata.window.Button;
|
||||
|
||||
public get kubeService(): IKubeService {
|
||||
return this._kubeService;
|
||||
@@ -42,24 +40,20 @@ export class DeployClusterWizard extends WizardBase<DeployClusterWizard, DeployC
|
||||
return this._notebookService;
|
||||
}
|
||||
|
||||
public get saveConfigButton(): azdata.window.Button {
|
||||
return this._saveConfigButton;
|
||||
public showCustomButtons(): void {
|
||||
this._saveConfigButton.hidden = false;
|
||||
}
|
||||
|
||||
public get scriptToNotebookButton(): azdata.window.Button {
|
||||
return this._scriptToNotebookButton;
|
||||
public hideCustomButtons(): void {
|
||||
this._saveConfigButton.hidden = true;
|
||||
}
|
||||
|
||||
constructor(private wizardInfo: WizardInfo, private _kubeService: IKubeService, private _azdataService: IAzdataService, private _notebookService: INotebookService) {
|
||||
super(DeployClusterWizard.getTitle(wizardInfo.type), new DeployClusterWizardModel(wizardInfo.type));
|
||||
this._saveConfigButton = azdata.window.createButton(localize('deployCluster.SaveConfigFiles', "Save config files"), 'left');
|
||||
this._saveConfigButton.hidden = true;
|
||||
this._scriptToNotebookButton = azdata.window.createButton(localize('deployCluster.ScriptToNotebook', "Script to Notebook"), 'left');
|
||||
this._scriptToNotebookButton.hidden = true;
|
||||
this.addButton(this._saveConfigButton);
|
||||
this.addButton(this._scriptToNotebookButton);
|
||||
this.registerDisposable(this._saveConfigButton.onClick(() => this.saveConfigFiles()));
|
||||
this.registerDisposable(this._scriptToNotebookButton.onClick(() => this.scriptToNotebook()));
|
||||
}
|
||||
|
||||
public get deploymentType(): BdcDeploymentType {
|
||||
@@ -69,80 +63,14 @@ export class DeployClusterWizard extends WizardBase<DeployClusterWizard, DeployC
|
||||
protected initialize(): void {
|
||||
this.setPages(this.getPages());
|
||||
this.wizardObject.generateScriptButton.hidden = true;
|
||||
this.wizardObject.doneButton.label = localize('deployCluster.Deploy', "Deploy");
|
||||
this.wizardObject.doneButton.label = localize('deployCluster.ScriptToNotebook', "Script to Notebook");
|
||||
}
|
||||
|
||||
protected onCancel(): void {
|
||||
}
|
||||
|
||||
protected onOk(): void {
|
||||
const taskName = localize('resourceDeployment.DeployBDCTask', "Deploy SQL Server Big Data Cluster \"{0}\"", this.model.getStringValue(VariableNames.ClusterName_VariableName));
|
||||
azdata.tasks.startBackgroundOperation({
|
||||
displayName: taskName,
|
||||
description: taskName,
|
||||
isCancelable: false,
|
||||
operation: async op => {
|
||||
op.updateStatus(azdata.TaskStatus.InProgress);
|
||||
const env: NodeJS.ProcessEnv = {};
|
||||
this.setEnvironmentVariables(env);
|
||||
const notebook = await this.notebookService.getNotebook(this.wizardInfo.azdata_notebook);
|
||||
notebook.cells.splice(3, 0, {
|
||||
cell_type: 'code',
|
||||
source: this.model.getCodeCellContentForNotebook(),
|
||||
metadata: {},
|
||||
execution_count: 0,
|
||||
outputs: []
|
||||
});
|
||||
const result = await this.notebookService.executeNotebook(notebook, env);
|
||||
if (result.succeeded) {
|
||||
op.updateStatus(azdata.TaskStatus.Succeeded);
|
||||
const connectToMasterSql = localize('resourceDeployment.ConnectToMasterSQLServer', "Connect to Master SQL Server");
|
||||
const selectedOption = await vscode.window.showInformationMessage(localize('resourceDeployment.DeploymentSucceeded', "Successfully deployed SQL Server Big Data Cluster: {0}",
|
||||
this.model.getStringValue(VariableNames.ClusterName_VariableName)),
|
||||
connectToMasterSql);
|
||||
if (selectedOption === connectToMasterSql) {
|
||||
let endpoints: BdcEndpoint[];
|
||||
try {
|
||||
endpoints = await this.azdataService.getEndpoints(this.model.getStringValue(VariableNames.ClusterName_VariableName)!,
|
||||
this.model.getStringValue(VariableNames.AdminUserName_VariableName)!,
|
||||
this.model.getStringValue(VariableNames.AdminPassword_VariableName)!);
|
||||
} catch (error) {
|
||||
vscode.window.showErrorMessage(localize('resourceDeployment.ErroRetrievingEndpoints', "Failed to retrieve the endpoint list. {0}{1}", os.EOL, getErrorMessage(error)));
|
||||
return;
|
||||
}
|
||||
const sqlEndpoint = endpoints.find(endpoint => endpoint.name === 'sql-server-master');
|
||||
if (sqlEndpoint) {
|
||||
vscode.commands.executeCommand('azdata.connect', {
|
||||
serverName: sqlEndpoint.endpoint,
|
||||
providerName: 'MSSQL',
|
||||
authenticationType: 'SqlLogin',
|
||||
userName: this.model.getStringValue(VariableNames.AdminUserName_VariableName)!,
|
||||
password: this.model.getStringValue(VariableNames.AdminPassword_VariableName)!
|
||||
});
|
||||
} else {
|
||||
vscode.window.showErrorMessage(localize('resourceDeployment.NoSQLEndpointFound', "Master SQL Server endpoint is not found."));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
op.updateStatus(azdata.TaskStatus.Failed, result.errorMessage);
|
||||
if (result.outputNotebook) {
|
||||
const viewErrorDetail = localize('resourceDeployment.ViewErrorDetail', "View error detail");
|
||||
const selectedOption = await vscode.window.showErrorMessage(localize('resourceDeployment.DeployFailed', "Failed to deploy SQL Server Big Data Cluster \"{0}\".",
|
||||
this.model.getStringValue(VariableNames.ClusterName_VariableName)),
|
||||
viewErrorDetail);
|
||||
if (selectedOption === viewErrorDetail) {
|
||||
try {
|
||||
this.notebookService.launchNotebookWithContent(`deploy-${getDateTimeString()}`, result.outputNotebook);
|
||||
} catch (error) {
|
||||
vscode.window.showErrorMessage(localize('resourceDeployment.FailedToOpenNotebook', "An error occured launching the output notebook. {1}{2}.", os.EOL, getErrorMessage(error)));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
vscode.window.showErrorMessage(localize('resourceDeployment.DeployFailedNoOutputNotebook', "Failed to deploy SQL Server Big Data Cluster and no output notebook was generated."));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
this.scriptToNotebook();
|
||||
}
|
||||
|
||||
private getPages(): WizardPageBase<DeployClusterWizard>[] {
|
||||
|
||||
Reference in New Issue
Block a user