mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Mount delete, refresh and default to new folder for mount create (#7702)
* Mount delete, refresh and default to new folder for mount create - Delete mount action added - Refresh mount action added - Added "mymount" to theend of existing path so that we don't use already-existing HDFS folder. The call fails unless folder doesn't exist
This commit is contained in:
@@ -49,6 +49,14 @@
|
|||||||
{
|
{
|
||||||
"command": "bigDataClusters.command.mount",
|
"command": "bigDataClusters.command.mount",
|
||||||
"when": "false"
|
"when": "false"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "bigDataClusters.command.refreshmount",
|
||||||
|
"when": "false"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "bigDataClusters.command.deletemount",
|
||||||
|
"when": "false"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"view/title": [
|
"view/title": [
|
||||||
@@ -80,6 +88,16 @@
|
|||||||
"command": "bigDataClusters.command.mount",
|
"command": "bigDataClusters.command.mount",
|
||||||
"when": "nodeType=~/^mssqlCluster/ && nodeType!=mssqlCluster:message && nodeSubType=~/^(?!:mount).*$/",
|
"when": "nodeType=~/^mssqlCluster/ && nodeType!=mssqlCluster:message && nodeSubType=~/^(?!:mount).*$/",
|
||||||
"group": "1mssqlCluster@10"
|
"group": "1mssqlCluster@10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "bigDataClusters.command.refreshmount",
|
||||||
|
"when": "nodeType == mssqlCluster:folder && nodeSubType==:mount:",
|
||||||
|
"group": "1mssqlCluster@11"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "bigDataClusters.command.deletemount",
|
||||||
|
"when": "nodeType == mssqlCluster:folder && nodeSubType==:mount:",
|
||||||
|
"group": "1mssqlCluster@12"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -112,6 +130,14 @@
|
|||||||
{
|
{
|
||||||
"command": "bigDataClusters.command.mount",
|
"command": "bigDataClusters.command.mount",
|
||||||
"title": "%command.mount.title%"
|
"title": "%command.mount.title%"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "bigDataClusters.command.refreshmount",
|
||||||
|
"title": "%command.refreshmount.title%"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "bigDataClusters.command.deletemount",
|
||||||
|
"title": "%command.deletemount.title%"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -5,5 +5,7 @@
|
|||||||
"command.deleteController.title" : "Delete",
|
"command.deleteController.title" : "Delete",
|
||||||
"command.refreshController.title" : "Refresh",
|
"command.refreshController.title" : "Refresh",
|
||||||
"command.manageController.title" : "Manage",
|
"command.manageController.title" : "Manage",
|
||||||
"command.mount.title" : "Mount HDFS"
|
"command.mount.title" : "Mount HDFS",
|
||||||
|
"command.refreshmount.title" : "Refresh Mount",
|
||||||
|
"command.deletemount.title" : "Delete Mount"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -214,6 +214,37 @@ export class ClusterController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async refreshMount(mountPath: string): Promise<MountResponse> {
|
||||||
|
let auth = await this.authPromise;
|
||||||
|
const api = new DefaultApiWrapper(this.username, this.password, this._url, auth);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const mountStatus = await api.refreshMount('', '', mountPath);
|
||||||
|
return {
|
||||||
|
response: mountStatus.response,
|
||||||
|
status: mountStatus.body
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
// TODO handle 401 by reauthenticating
|
||||||
|
throw new ControllerError(error, localize('bdc.error.refreshHdfs', "Error refreshing mount"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async deleteMount(mountPath: string): Promise<MountResponse> {
|
||||||
|
let auth = await this.authPromise;
|
||||||
|
const api = new DefaultApiWrapper(this.username, this.password, this._url, auth);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const mountStatus = await api.deleteMount('', '', mountPath);
|
||||||
|
return {
|
||||||
|
response: mountStatus.response,
|
||||||
|
status: mountStatus.body
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
// TODO handle 401 by reauthenticating
|
||||||
|
throw new ControllerError(error, localize('bdc.error.deleteHdfs', "Error deleting mount"));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Fixes missing protocol and wrong character for port entered by user
|
* Fixes missing protocol and wrong character for port entered by user
|
||||||
|
|||||||
@@ -6,13 +6,15 @@
|
|||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
import * as azdata from 'azdata';
|
import * as azdata from 'azdata';
|
||||||
import * as nls from 'vscode-nls';
|
import * as nls from 'vscode-nls';
|
||||||
import { ClusterController, ControllerError, MountInfo, MountState } from '../controller/clusterControllerApi';
|
import { ClusterController, ControllerError, MountInfo, MountState, IEndPointsResponse } from '../controller/clusterControllerApi';
|
||||||
import { AuthType } from '../constants';
|
import { AuthType } from '../constants';
|
||||||
|
|
||||||
const localize = nls.loadMessageBundle();
|
const localize = nls.loadMessageBundle();
|
||||||
|
|
||||||
const basicAuthDisplay = localize('basicAuthName', "Basic");
|
const basicAuthDisplay = localize('basicAuthName', "Basic");
|
||||||
const integratedAuthDisplay = localize('integratedAuthName', "Windows Authentication");
|
const integratedAuthDisplay = localize('integratedAuthName', "Windows Authentication");
|
||||||
|
const mountConfigutationTitle = localize('mount.main.section', "Mount Configuration");
|
||||||
|
const hdfsPathTitle = localize('mount.hdfsPath', "HDFS Path");
|
||||||
|
|
||||||
function getAuthCategory(name: AuthType): azdata.CategoryValue {
|
function getAuthCategory(name: AuthType): azdata.CategoryValue {
|
||||||
if (name === 'basic') {
|
if (name === 'basic') {
|
||||||
@@ -125,6 +127,31 @@ abstract class HdfsDialogModelBase<T extends DialogProperties> {
|
|||||||
return new ClusterController(this.props.url, this.props.auth, this.props.username, this.props.password, true);
|
return new ClusterController(this.props.url, this.props.auth, this.props.username, this.props.password, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected async createAndVerifyControllerConnection(): Promise<ClusterController> {
|
||||||
|
// We pre-fetch the endpoints here to verify that the information entered is correct (the user is able to connect)
|
||||||
|
let controller = this.createController();
|
||||||
|
let response: IEndPointsResponse;
|
||||||
|
try {
|
||||||
|
response = await controller.getEndPoints();
|
||||||
|
if (!response || !response.endPoints) {
|
||||||
|
throw new Error(localize('mount.hdfs.loginerror1', "Login to controller failed"));
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
throw new Error(localize('mount.hdfs.loginerror2', "Login to controller failed: {0}", err.message));
|
||||||
|
}
|
||||||
|
return controller;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected throwIfMissingUsernamePassword(): void {
|
||||||
|
if (this.props.auth === 'basic') {
|
||||||
|
// Verify username and password as we can't make them required in the UI
|
||||||
|
if (!this.props.username) {
|
||||||
|
throw new Error(localize('err.controller.username.required', "Username is required"));
|
||||||
|
} else if (!this.props.password) {
|
||||||
|
throw new Error(localize('err.controller.password.required', "Password is required"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class MountHdfsDialogModel extends HdfsDialogModelBase<MountHdfsProperties> {
|
export class MountHdfsDialogModel extends HdfsDialogModelBase<MountHdfsProperties> {
|
||||||
@@ -135,25 +162,15 @@ export class MountHdfsDialogModel extends HdfsDialogModelBase<MountHdfsPropertie
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected async handleCompleted(): Promise<void> {
|
protected async handleCompleted(): Promise<void> {
|
||||||
if (this.props.auth === 'basic') {
|
this.throwIfMissingUsernamePassword();
|
||||||
// Verify username and password as we can't make them required in the UI
|
|
||||||
if (!this.props.username) {
|
|
||||||
throw new Error(localize('err.controller.username.required', "Username is required"));
|
|
||||||
} else if (!this.props.password) {
|
|
||||||
throw new Error(localize('err.controller.password.required', "Password is required"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Validate credentials
|
// Validate credentials
|
||||||
this.credentials = convertCredsToJson(this.props.credentials);
|
this.credentials = convertCredsToJson(this.props.credentials);
|
||||||
|
|
||||||
// We pre-fetch the endpoints here to verify that the information entered is correct (the user is able to connect)
|
// We pre-fetch the endpoints here to verify that the information entered is correct (the user is able to connect)
|
||||||
let controller = this.createController();
|
let controller = await this.createAndVerifyControllerConnection();
|
||||||
let response = await controller.getEndPoints();
|
|
||||||
if (response && response.endPoints) {
|
|
||||||
if (this._canceled) {
|
if (this._canceled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//
|
|
||||||
azdata.tasks.startBackgroundOperation(
|
azdata.tasks.startBackgroundOperation(
|
||||||
{
|
{
|
||||||
connection: undefined,
|
connection: undefined,
|
||||||
@@ -166,7 +183,6 @@ export class MountHdfsDialogModel extends HdfsDialogModelBase<MountHdfsPropertie
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private async onSubmit(controller: ClusterController, op: azdata.BackgroundOperation): Promise<void> {
|
private async onSubmit(controller: ClusterController, op: azdata.BackgroundOperation): Promise<void> {
|
||||||
try {
|
try {
|
||||||
@@ -295,9 +311,9 @@ abstract class HdfsDialogBase<T extends DialogProperties> {
|
|||||||
this.getMainSection(),
|
this.getMainSection(),
|
||||||
connectionSection
|
connectionSection
|
||||||
]).withLayout({ width: '100%' }).component();
|
]).withLayout({ width: '100%' }).component();
|
||||||
this.onAuthChanged();
|
|
||||||
|
|
||||||
await view.initializeModel(formModel);
|
await view.initializeModel(formModel);
|
||||||
|
this.onAuthChanged();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.dialog.registerCloseValidator(async () => await this.validate());
|
this.dialog.registerCloseValidator(async () => await this.validate());
|
||||||
@@ -329,6 +345,16 @@ abstract class HdfsDialogBase<T extends DialogProperties> {
|
|||||||
await this.model.onCancel();
|
await this.model.onCancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected async reportError(error: any): Promise<void> {
|
||||||
|
this.dialog.message = {
|
||||||
|
text: (typeof error === 'string') ? error : error.message,
|
||||||
|
level: azdata.window.MessageLevel.Error
|
||||||
|
};
|
||||||
|
if (this.model && this.model.onError) {
|
||||||
|
await this.model.onError(error as ControllerError);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
export class MountHdfsDialog extends HdfsDialogBase<MountHdfsProperties> {
|
export class MountHdfsDialog extends HdfsDialogBase<MountHdfsProperties> {
|
||||||
private pathInputBox: azdata.InputBoxComponent;
|
private pathInputBox: azdata.InputBoxComponent;
|
||||||
@@ -340,9 +366,12 @@ export class MountHdfsDialog extends HdfsDialogBase<MountHdfsProperties> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected getMainSection(): azdata.FormComponentGroup {
|
protected getMainSection(): azdata.FormComponentGroup {
|
||||||
|
const newMountName = '/mymount';
|
||||||
|
let pathVal = this.model.props.hdfsPath;
|
||||||
|
pathVal = (!pathVal || pathVal === '/') ? newMountName : (pathVal + newMountName);
|
||||||
this.pathInputBox = this.uiModelBuilder.inputBox()
|
this.pathInputBox = this.uiModelBuilder.inputBox()
|
||||||
.withProperties<azdata.InputBoxProperties>({
|
.withProperties<azdata.InputBoxProperties>({
|
||||||
value: this.model.props.hdfsPath
|
value: pathVal
|
||||||
}).component();
|
}).component();
|
||||||
this.remoteUriInputBox = this.uiModelBuilder.inputBox()
|
this.remoteUriInputBox = this.uiModelBuilder.inputBox()
|
||||||
.withProperties<azdata.InputBoxProperties>({
|
.withProperties<azdata.InputBoxProperties>({
|
||||||
@@ -360,7 +389,7 @@ export class MountHdfsDialog extends HdfsDialogBase<MountHdfsProperties> {
|
|||||||
components: [
|
components: [
|
||||||
{
|
{
|
||||||
component: this.pathInputBox,
|
component: this.pathInputBox,
|
||||||
title: localize('mount.hdfsPath', "HDFS Path"),
|
title: hdfsPathTitle,
|
||||||
required: true
|
required: true
|
||||||
}, {
|
}, {
|
||||||
component: this.remoteUriInputBox,
|
component: this.remoteUriInputBox,
|
||||||
@@ -372,7 +401,7 @@ export class MountHdfsDialog extends HdfsDialogBase<MountHdfsProperties> {
|
|||||||
required: false
|
required: false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
title: localize('mount.main.section', "Mount Configuration")
|
title: mountConfigutationTitle
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -389,14 +418,168 @@ export class MountHdfsDialog extends HdfsDialogBase<MountHdfsProperties> {
|
|||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.dialog.message = {
|
await this.reportError(error);
|
||||||
text: (typeof error === 'string') ? error : error.message,
|
|
||||||
level: azdata.window.MessageLevel.Error
|
|
||||||
};
|
|
||||||
if (this.model && this.model.onError) {
|
|
||||||
await this.model.onError(error as ControllerError);
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class RefreshMountDialog extends HdfsDialogBase<MountHdfsProperties> {
|
||||||
|
private pathInputBox: azdata.InputBoxComponent;
|
||||||
|
|
||||||
|
constructor(model: RefreshMountModel) {
|
||||||
|
super(localize('refreshmount.dialog.title', "Refresh Mount"), model);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected getMainSection(): azdata.FormComponentGroup {
|
||||||
|
this.pathInputBox = this.uiModelBuilder.inputBox()
|
||||||
|
.withProperties<azdata.InputBoxProperties>({
|
||||||
|
value: this.model.props.hdfsPath
|
||||||
|
}).component();
|
||||||
|
return {
|
||||||
|
components: [
|
||||||
|
{
|
||||||
|
component: this.pathInputBox,
|
||||||
|
title: hdfsPathTitle,
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
title: mountConfigutationTitle
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async validate(): Promise<boolean> {
|
||||||
|
try {
|
||||||
|
await this.model.onComplete({
|
||||||
|
url: this.urlInputBox && this.urlInputBox.value,
|
||||||
|
auth: this.authValue,
|
||||||
|
username: this.usernameInputBox && this.usernameInputBox.value,
|
||||||
|
password: this.passwordInputBox && this.passwordInputBox.value,
|
||||||
|
hdfsPath: this.pathInputBox && this.pathInputBox.value
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
} catch (error) {
|
||||||
|
await this.reportError(error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class RefreshMountModel extends HdfsDialogModelBase<MountHdfsProperties> {
|
||||||
|
|
||||||
|
constructor(props: MountHdfsProperties) {
|
||||||
|
super(props);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async handleCompleted(): Promise<void> {
|
||||||
|
this.throwIfMissingUsernamePassword();
|
||||||
|
|
||||||
|
// We pre-fetch the endpoints here to verify that the information entered is correct (the user is able to connect)
|
||||||
|
let controller = await this.createAndVerifyControllerConnection();
|
||||||
|
if (this._canceled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
azdata.tasks.startBackgroundOperation(
|
||||||
|
{
|
||||||
|
connection: undefined,
|
||||||
|
displayName: localize('refreshmount.task.name', "Refreshing HDFS Mount on path {0}", this.props.hdfsPath),
|
||||||
|
description: '',
|
||||||
|
isCancelable: false,
|
||||||
|
operation: op => {
|
||||||
|
this.onSubmit(controller, op);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async onSubmit(controller: ClusterController, op: azdata.BackgroundOperation): Promise<void> {
|
||||||
|
try {
|
||||||
|
await controller.refreshMount(this.props.hdfsPath);
|
||||||
|
op.updateStatus(azdata.TaskStatus.Succeeded, localize('refreshmount.task.submitted', "Refresh mount request submitted"));
|
||||||
|
} catch (error) {
|
||||||
|
const errMsg = (error instanceof Error) ? error.message : error;
|
||||||
|
vscode.window.showErrorMessage(errMsg);
|
||||||
|
op.updateStatus(azdata.TaskStatus.Failed, errMsg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class DeleteMountDialog extends HdfsDialogBase<MountHdfsProperties> {
|
||||||
|
private pathInputBox: azdata.InputBoxComponent;
|
||||||
|
|
||||||
|
constructor(model: DeleteMountModel) {
|
||||||
|
super(localize('deleteMount.dialog.title', "Delete Mount"), model);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected getMainSection(): azdata.FormComponentGroup {
|
||||||
|
this.pathInputBox = this.uiModelBuilder.inputBox()
|
||||||
|
.withProperties<azdata.InputBoxProperties>({
|
||||||
|
value: this.model.props.hdfsPath
|
||||||
|
}).component();
|
||||||
|
return {
|
||||||
|
components: [
|
||||||
|
{
|
||||||
|
component: this.pathInputBox,
|
||||||
|
title: hdfsPathTitle,
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
title: mountConfigutationTitle
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async validate(): Promise<boolean> {
|
||||||
|
try {
|
||||||
|
await this.model.onComplete({
|
||||||
|
url: this.urlInputBox && this.urlInputBox.value,
|
||||||
|
auth: this.authValue,
|
||||||
|
username: this.usernameInputBox && this.usernameInputBox.value,
|
||||||
|
password: this.passwordInputBox && this.passwordInputBox.value,
|
||||||
|
hdfsPath: this.pathInputBox && this.pathInputBox.value
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
} catch (error) {
|
||||||
|
await this.reportError(error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class DeleteMountModel extends HdfsDialogModelBase<MountHdfsProperties> {
|
||||||
|
|
||||||
|
constructor(props: MountHdfsProperties) {
|
||||||
|
super(props);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected async handleCompleted(): Promise<void> {
|
||||||
|
this.throwIfMissingUsernamePassword();
|
||||||
|
|
||||||
|
// We pre-fetch the endpoints here to verify that the information entered is correct (the user is able to connect)
|
||||||
|
let controller = await this.createAndVerifyControllerConnection();
|
||||||
|
if (this._canceled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
azdata.tasks.startBackgroundOperation(
|
||||||
|
{
|
||||||
|
connection: undefined,
|
||||||
|
displayName: localize('deletemount.task.name', "Deleting HDFS Mount on path {0}", this.props.hdfsPath),
|
||||||
|
description: '',
|
||||||
|
isCancelable: false,
|
||||||
|
operation: op => {
|
||||||
|
this.onSubmit(controller, op);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async onSubmit(controller: ClusterController, op: azdata.BackgroundOperation): Promise<void> {
|
||||||
|
try {
|
||||||
|
await controller.deleteMount(this.props.hdfsPath);
|
||||||
|
op.updateStatus(azdata.TaskStatus.Succeeded, localize('deletemount.task.submitted', "Delete mount request submitted"));
|
||||||
|
} catch (error) {
|
||||||
|
const errMsg = (error instanceof Error) ? error.message : error;
|
||||||
|
vscode.window.showErrorMessage(errMsg);
|
||||||
|
op.updateStatus(azdata.TaskStatus.Failed, errMsg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import { AddControllerDialogModel, AddControllerDialog } from './bigDataCluster/
|
|||||||
import { ControllerNode } from './bigDataCluster/tree/controllerTreeNode';
|
import { ControllerNode } from './bigDataCluster/tree/controllerTreeNode';
|
||||||
import { BdcDashboard } from './bigDataCluster/dialog/bdcDashboard';
|
import { BdcDashboard } from './bigDataCluster/dialog/bdcDashboard';
|
||||||
import { BdcDashboardModel } from './bigDataCluster/dialog/bdcDashboardModel';
|
import { BdcDashboardModel } from './bigDataCluster/dialog/bdcDashboardModel';
|
||||||
import { MountHdfsDialogModel, MountHdfsProperties, MountHdfsDialog } from './bigDataCluster/dialog/mountHdfsDialog';
|
import { MountHdfsDialogModel as MountHdfsModel, MountHdfsProperties, MountHdfsDialog, DeleteMountDialog, DeleteMountModel, RefreshMountDialog, RefreshMountModel } from './bigDataCluster/dialog/mountHdfsDialog';
|
||||||
import { getControllerEndpoint } from './bigDataCluster/utils';
|
import { getControllerEndpoint } from './bigDataCluster/utils';
|
||||||
|
|
||||||
const localize = nls.loadMessageBundle();
|
const localize = nls.loadMessageBundle();
|
||||||
@@ -25,6 +25,8 @@ const DeleteControllerCommand = 'bigDataClusters.command.deleteController';
|
|||||||
const RefreshControllerCommand = 'bigDataClusters.command.refreshController';
|
const RefreshControllerCommand = 'bigDataClusters.command.refreshController';
|
||||||
const ManageControllerCommand = 'bigDataClusters.command.manageController';
|
const ManageControllerCommand = 'bigDataClusters.command.manageController';
|
||||||
const MountHdfsCommand = 'bigDataClusters.command.mount';
|
const MountHdfsCommand = 'bigDataClusters.command.mount';
|
||||||
|
const RefreshMountCommand = 'bigDataClusters.command.refreshmount';
|
||||||
|
const DeleteMountCommand = 'bigDataClusters.command.deletemount';
|
||||||
|
|
||||||
const endpointNotFoundError = localize('mount.error.endpointNotFound', "Controller endpoint information was not found");
|
const endpointNotFoundError = localize('mount.error.endpointNotFound', "Controller endpoint information was not found");
|
||||||
|
|
||||||
@@ -69,13 +71,43 @@ function registerCommands(context: vscode.ExtensionContext, treeDataProvider: Co
|
|||||||
vscode.commands.registerCommand(MountHdfsCommand, e => mountHdfs(e).catch(error => {
|
vscode.commands.registerCommand(MountHdfsCommand, e => mountHdfs(e).catch(error => {
|
||||||
vscode.window.showErrorMessage(error instanceof Error ? error.message : error);
|
vscode.window.showErrorMessage(error instanceof Error ? error.message : error);
|
||||||
}));
|
}));
|
||||||
|
vscode.commands.registerCommand(RefreshMountCommand, e => refreshMount(e).catch(error => {
|
||||||
|
vscode.window.showErrorMessage(error instanceof Error ? error.message : error);
|
||||||
|
}));
|
||||||
|
vscode.commands.registerCommand(DeleteMountCommand, e => deleteMount(e).catch(error => {
|
||||||
|
vscode.window.showErrorMessage(error instanceof Error ? error.message : error);
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
async function mountHdfs(explorerContext?: azdata.ObjectExplorerContext): Promise<void> {
|
async function mountHdfs(explorerContext?: azdata.ObjectExplorerContext): Promise<void> {
|
||||||
|
let mountProps = await getMountProps(explorerContext);
|
||||||
|
if (mountProps) {
|
||||||
|
let dialog = new MountHdfsDialog(new MountHdfsModel(mountProps));
|
||||||
|
dialog.showDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function refreshMount(explorerContext?: azdata.ObjectExplorerContext): Promise<void> {
|
||||||
|
let mountProps = await getMountProps(explorerContext);
|
||||||
|
if (mountProps) {
|
||||||
|
let dialog = new RefreshMountDialog(new RefreshMountModel(mountProps));
|
||||||
|
dialog.showDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function deleteMount(explorerContext?: azdata.ObjectExplorerContext): Promise<void> {
|
||||||
|
let mountProps = await getMountProps(explorerContext);
|
||||||
|
if (mountProps) {
|
||||||
|
let dialog = new DeleteMountDialog(new DeleteMountModel(mountProps));
|
||||||
|
dialog.showDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getMountProps(explorerContext?: azdata.ObjectExplorerContext): Promise<MountHdfsProperties | undefined> {
|
||||||
let endpoint = await lookupController(explorerContext);
|
let endpoint = await lookupController(explorerContext);
|
||||||
if (!endpoint) {
|
if (!endpoint) {
|
||||||
vscode.window.showErrorMessage(endpointNotFoundError);
|
vscode.window.showErrorMessage(endpointNotFoundError);
|
||||||
return;
|
return undefined;
|
||||||
}
|
}
|
||||||
let profile = explorerContext.connectionProfile;
|
let profile = explorerContext.connectionProfile;
|
||||||
let mountProps: MountHdfsProperties = {
|
let mountProps: MountHdfsProperties = {
|
||||||
@@ -85,8 +117,7 @@ async function mountHdfs(explorerContext?: azdata.ObjectExplorerContext): Promis
|
|||||||
password: profile.password,
|
password: profile.password,
|
||||||
hdfsPath: getHdsfPath(explorerContext.nodeInfo.nodePath)
|
hdfsPath: getHdsfPath(explorerContext.nodeInfo.nodePath)
|
||||||
};
|
};
|
||||||
let dialog = new MountHdfsDialog(new MountHdfsDialogModel(mountProps));
|
return mountProps;
|
||||||
dialog.showDialog();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getHdsfPath(nodePath: string): string {
|
function getHdsfPath(nodePath: string): string {
|
||||||
|
|||||||
Reference in New Issue
Block a user