mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Remove all Big Data Cluster features (#21369)
This commit is contained in:
@@ -1,75 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import * as path from 'path';
|
||||
import { IPlatformService } from './platformService';
|
||||
import { BigDataClusterDeploymentProfile } from './bigDataClusterDeploymentProfile';
|
||||
import { BdcDeploymentType } from '../interfaces';
|
||||
|
||||
interface BdcConfigListOutput {
|
||||
result: string[];
|
||||
}
|
||||
|
||||
export interface BdcEndpoint {
|
||||
endpoint: string;
|
||||
name: 'sql-server-master';
|
||||
}
|
||||
|
||||
export interface IAzdataService {
|
||||
getDeploymentProfiles(deploymentType: BdcDeploymentType): Promise<BigDataClusterDeploymentProfile[]>;
|
||||
}
|
||||
|
||||
export class AzdataService implements IAzdataService {
|
||||
constructor(private platformService: IPlatformService) {
|
||||
}
|
||||
|
||||
public async getDeploymentProfiles(deploymentType: BdcDeploymentType): Promise<BigDataClusterDeploymentProfile[]> {
|
||||
let profilePrefix: string;
|
||||
switch (deploymentType) {
|
||||
case BdcDeploymentType.NewAKS:
|
||||
case BdcDeploymentType.ExistingAKS:
|
||||
profilePrefix = 'aks';
|
||||
break;
|
||||
case BdcDeploymentType.ExistingKubeAdm:
|
||||
profilePrefix = 'kubeadm';
|
||||
break;
|
||||
case BdcDeploymentType.ExistingARO:
|
||||
profilePrefix = 'aro';
|
||||
break;
|
||||
case BdcDeploymentType.ExistingOpenShift:
|
||||
profilePrefix = 'openshift';
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Unknown deployment type: ${deploymentType}`);
|
||||
}
|
||||
const profileNames = await this.getDeploymentProfileNames();
|
||||
return await Promise.all(profileNames.filter(profile => profile.startsWith(profilePrefix)).map(profile => this.getDeploymentProfileInfo(profile)));
|
||||
}
|
||||
|
||||
private async getDeploymentProfileNames(): Promise<string[]> {
|
||||
const env: NodeJS.ProcessEnv = {};
|
||||
// azdata requires this environment variables to be set
|
||||
env['ACCEPT_EULA'] = 'yes';
|
||||
const cmd = 'azdata bdc config list -o json';
|
||||
const stdout = await this.platformService.runCommand(cmd, { additionalEnvironmentVariables: env });
|
||||
const output = <BdcConfigListOutput>JSON.parse(stdout);
|
||||
return output.result;
|
||||
}
|
||||
|
||||
private async getDeploymentProfileInfo(profileName: string): Promise<BigDataClusterDeploymentProfile> {
|
||||
const env: NodeJS.ProcessEnv = {};
|
||||
// azdata requires this environment variables to be set
|
||||
env['ACCEPT_EULA'] = 'yes';
|
||||
await this.platformService.runCommand(`azdata bdc config init --source ${profileName} --path ${profileName} --force`, { workingDirectory: this.platformService.storagePath(), additionalEnvironmentVariables: env });
|
||||
const configObjects = await Promise.all([
|
||||
this.getJsonObjectFromFile(path.join(this.platformService.storagePath(), profileName, 'bdc.json')),
|
||||
this.getJsonObjectFromFile(path.join(this.platformService.storagePath(), profileName, 'control.json'))
|
||||
]);
|
||||
return new BigDataClusterDeploymentProfile(profileName, configObjects[0], configObjects[1]);
|
||||
}
|
||||
|
||||
private async getJsonObjectFromFile(path: string): Promise<any> {
|
||||
return JSON.parse(await this.platformService.readTextFile(path));
|
||||
}
|
||||
}
|
||||
@@ -1,349 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { AuthenticationMode } from '../ui/deployClusterWizard/deployClusterWizardModel';
|
||||
export const SqlServerMasterResource = 'master';
|
||||
export const DataResource = 'data-0';
|
||||
export const HdfsResource = 'storage-0';
|
||||
export const ComputeResource = 'compute-0';
|
||||
export const NameNodeResource = 'nmnode-0';
|
||||
export const SparkHeadResource = 'sparkhead';
|
||||
export const ZooKeeperResource = 'zookeeper';
|
||||
export const SparkResource = 'spark-0';
|
||||
|
||||
interface ServiceEndpoint {
|
||||
port: number;
|
||||
serviceType: ServiceType;
|
||||
name: EndpointName;
|
||||
dnsName?: string;
|
||||
}
|
||||
type ServiceType = 'NodePort' | 'LoadBalancer';
|
||||
type EndpointName = 'Controller' | 'Master' | 'Knox' | 'MasterSecondary' | 'AppServiceProxy' | 'ServiceProxy';
|
||||
|
||||
export interface ActiveDirectorySettings {
|
||||
organizationalUnit: string;
|
||||
domainControllerFQDNs: string;
|
||||
dnsIPAddresses: string;
|
||||
domainDNSName: string;
|
||||
realm?: string;
|
||||
clusterUsers: string;
|
||||
clusterAdmins: string;
|
||||
appReaders?: string;
|
||||
appOwners?: string;
|
||||
subdomain?: string;
|
||||
accountPrefix?: string;
|
||||
}
|
||||
|
||||
export class BigDataClusterDeploymentProfile {
|
||||
constructor(private _profileName: string, private _bdcConfig: any, private _controlConfig: any) {
|
||||
// TODO: add validation logic for these 2 objects
|
||||
// https://github.com/microsoft/azuredatastudio/issues/7344
|
||||
}
|
||||
|
||||
public get profileName(): string {
|
||||
return this._profileName;
|
||||
}
|
||||
|
||||
public get clusterName(): string {
|
||||
return this._bdcConfig.metadata.name;
|
||||
}
|
||||
|
||||
public set clusterName(value: string) {
|
||||
this._bdcConfig.metadata.name = value;
|
||||
}
|
||||
|
||||
public get registry(): string {
|
||||
return this._controlConfig.spec.docker.registry;
|
||||
}
|
||||
|
||||
public set registry(value: string) {
|
||||
this._controlConfig.spec.docker.registry = value;
|
||||
}
|
||||
|
||||
public get repository(): string {
|
||||
return this._controlConfig.spec.docker.repository;
|
||||
}
|
||||
|
||||
public set repository(value: string) {
|
||||
this._controlConfig.spec.docker.repository = value;
|
||||
}
|
||||
|
||||
public get imageTag(): string {
|
||||
return this._controlConfig.spec.docker.imageTag;
|
||||
}
|
||||
|
||||
public set imageTag(value: string) {
|
||||
this._controlConfig.spec.docker.imageTag = value;
|
||||
}
|
||||
|
||||
public get bdcConfig(): any {
|
||||
return this._bdcConfig;
|
||||
}
|
||||
|
||||
public get controlConfig(): any {
|
||||
return this._controlConfig;
|
||||
}
|
||||
|
||||
public get sqlServerReplicas(): number {
|
||||
return this.getReplicas(SqlServerMasterResource);
|
||||
}
|
||||
|
||||
public set sqlServerReplicas(replicas: number) {
|
||||
this.setReplicas(SqlServerMasterResource, replicas);
|
||||
}
|
||||
|
||||
public get hdfsNameNodeReplicas(): number {
|
||||
return this.getReplicas(NameNodeResource);
|
||||
}
|
||||
|
||||
public set hdfsNameNodeReplicas(replicas: number) {
|
||||
this.setReplicas(NameNodeResource, replicas);
|
||||
}
|
||||
|
||||
public get sparkHeadReplicas(): number {
|
||||
return this.getReplicas(SparkHeadResource);
|
||||
}
|
||||
|
||||
public set sparkHeadReplicas(replicas: number) {
|
||||
this.setReplicas(SparkHeadResource, replicas);
|
||||
}
|
||||
|
||||
public get dataReplicas(): number {
|
||||
return this.getReplicas(DataResource);
|
||||
}
|
||||
|
||||
public set dataReplicas(replicas: number) {
|
||||
this.setReplicas(SparkHeadResource, replicas);
|
||||
}
|
||||
|
||||
public get hdfsReplicas(): number {
|
||||
return this.getReplicas(HdfsResource);
|
||||
}
|
||||
|
||||
public set hdfsReplicas(replicas: number) {
|
||||
this.setReplicas(HdfsResource, replicas);
|
||||
}
|
||||
|
||||
public get zooKeeperReplicas(): number {
|
||||
return this.getReplicas(ZooKeeperResource);
|
||||
}
|
||||
|
||||
public set zooKeeperReplicas(replicas: number) {
|
||||
this.setReplicas(ZooKeeperResource, replicas);
|
||||
}
|
||||
|
||||
public get computeReplicas(): number {
|
||||
return this.getReplicas(ComputeResource);
|
||||
}
|
||||
|
||||
public set computeReplicas(replicas: number) {
|
||||
this.setReplicas(ComputeResource, replicas);
|
||||
}
|
||||
|
||||
public get sparkReplicas(): number {
|
||||
return this._bdcConfig.spec.resources[SparkResource] ? this.getReplicas(SparkResource) : 0;
|
||||
}
|
||||
|
||||
public get includeSpark(): boolean {
|
||||
return <boolean>this._bdcConfig.spec.resources[HdfsResource].spec.settings.spark.includeSpark;
|
||||
}
|
||||
|
||||
public set includeSpark(value: boolean) {
|
||||
this._bdcConfig.spec.resources[HdfsResource].spec.settings.spark.includeSpark = value;
|
||||
}
|
||||
|
||||
public get controllerDataStorageClass(): string {
|
||||
return <string>this._controlConfig.spec.storage.data.className;
|
||||
}
|
||||
|
||||
public set controllerDataStorageClass(value: string) {
|
||||
this._controlConfig.spec.storage.data.className = value;
|
||||
}
|
||||
|
||||
public get controllerDataStorageSize(): number {
|
||||
return <number>this._controlConfig.spec.storage.data.size.replace('Gi', '');
|
||||
}
|
||||
|
||||
public set controllerDataStorageSize(value: number) {
|
||||
this._controlConfig.spec.storage.data.size = `${value}Gi`;
|
||||
}
|
||||
|
||||
public get controllerLogsStorageClass(): string {
|
||||
return <string>this._controlConfig.spec.storage.logs.className;
|
||||
}
|
||||
|
||||
public set controllerLogsStorageClass(value: string) {
|
||||
this._controlConfig.spec.storage.logs.className = value;
|
||||
}
|
||||
|
||||
public get controllerLogsStorageSize(): number {
|
||||
return <number>this._controlConfig.spec.storage.logs.size.replace('Gi', '');
|
||||
}
|
||||
|
||||
public set controllerLogsStorageSize(value: number) {
|
||||
this._controlConfig.spec.storage.logs.size = `${value}Gi`;
|
||||
}
|
||||
|
||||
public setResourceStorage(resourceName: 'data-0' | 'master' | 'storage-0', dataStorageClass: string, dataStorageSize: number, logsStorageClass: string, logsStorageSize: number) {
|
||||
this.bdcConfig.spec.resources[resourceName].spec.storage = {
|
||||
data: {
|
||||
size: `${dataStorageSize}Gi`,
|
||||
className: dataStorageClass,
|
||||
accessMode: 'ReadWriteOnce'
|
||||
},
|
||||
logs: {
|
||||
size: `${logsStorageSize}Gi`,
|
||||
className: logsStorageClass,
|
||||
accessMode: 'ReadWriteOnce'
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public get controllerPort(): number {
|
||||
return this.getEndpointPort(this._controlConfig.spec.endpoints, 'Controller', 30080);
|
||||
}
|
||||
|
||||
public setControllerEndpoint(port: number, dnsName?: string) {
|
||||
this.setEndpoint(this._controlConfig.spec.endpoints, 'Controller', port, dnsName);
|
||||
}
|
||||
|
||||
public get serviceProxyPort(): number {
|
||||
return this.getEndpointPort(this._controlConfig.spec.endpoints, 'ServiceProxy', 30080);
|
||||
}
|
||||
|
||||
public setServiceProxyEndpoint(port: number, dnsName?: string) {
|
||||
this.setEndpoint(this._controlConfig.spec.endpoints, 'ServiceProxy', port, dnsName);
|
||||
}
|
||||
|
||||
public get appServiceProxyPort(): number {
|
||||
return this.getEndpointPort(this._bdcConfig.spec.resources.appproxy.spec.endpoints, 'AppServiceProxy', 30777);
|
||||
}
|
||||
|
||||
public setAppServiceProxyEndpoint(port: number, dnsName?: string) {
|
||||
this.setEndpoint(this._bdcConfig.spec.resources.appproxy.spec.endpoints, 'AppServiceProxy', port, dnsName);
|
||||
}
|
||||
|
||||
public get sqlServerPort(): number {
|
||||
return this.getEndpointPort(this._bdcConfig.spec.resources.master.spec.endpoints, 'Master', 31433);
|
||||
}
|
||||
|
||||
public setSqlServerEndpoint(port: number, dnsName?: string) {
|
||||
this.setEndpoint(this._bdcConfig.spec.resources.master.spec.endpoints, 'Master', port, dnsName);
|
||||
}
|
||||
|
||||
public get sqlServerReadableSecondaryPort(): number {
|
||||
return this.getEndpointPort(this._bdcConfig.spec.resources.master.spec.endpoints, 'MasterSecondary', 31436);
|
||||
}
|
||||
|
||||
public setSqlServerReadableSecondaryEndpoint(port: number, dnsName?: string) {
|
||||
this.setEndpoint(this._bdcConfig.spec.resources.master.spec.endpoints, 'MasterSecondary', port, dnsName);
|
||||
}
|
||||
|
||||
public get gatewayPort(): number {
|
||||
return this.getEndpointPort(this._bdcConfig.spec.resources.gateway.spec.endpoints, 'Knox', 30443);
|
||||
}
|
||||
|
||||
public setGatewayEndpoint(port: number, dnsName?: string) {
|
||||
this.setEndpoint(this._bdcConfig.spec.resources.gateway.spec.endpoints, 'Knox', port, dnsName);
|
||||
}
|
||||
|
||||
public addSparkResource(replicas: number): void {
|
||||
this._bdcConfig.spec.resources[SparkResource] = {
|
||||
metadata: {
|
||||
kind: 'Pool',
|
||||
name: 'default'
|
||||
},
|
||||
spec: {
|
||||
type: 'Spark',
|
||||
replicas: replicas
|
||||
}
|
||||
};
|
||||
|
||||
this._bdcConfig.spec.services.spark.resources.push(SparkResource);
|
||||
this._bdcConfig.spec.services.hdfs.resources.push(SparkResource);
|
||||
}
|
||||
|
||||
public get activeDirectorySupported(): boolean {
|
||||
// The profiles that highlight the AD authentication feature will have a security secion in the control.json for the AD settings.
|
||||
return 'security' in this._controlConfig;
|
||||
}
|
||||
|
||||
public setAuthenticationMode(mode: string): void {
|
||||
// If basic authentication is picked, the activeDirectory security section must be removed
|
||||
// otherwise azdata will throw validation error
|
||||
if (mode === AuthenticationMode.Basic && 'security' in this._controlConfig && 'activeDirectory' in this._controlConfig.security) {
|
||||
delete this._controlConfig.security.activeDirectory;
|
||||
}
|
||||
}
|
||||
|
||||
public setActiveDirectorySettings(adSettings: ActiveDirectorySettings): void {
|
||||
const activeDirectoryObject: any = {};
|
||||
activeDirectoryObject.ouDistinguishedName = adSettings.organizationalUnit;
|
||||
activeDirectoryObject.dnsIpAddresses = this.splitByComma(adSettings.dnsIPAddresses);
|
||||
activeDirectoryObject.domainControllerFullyQualifiedDns = this.splitByComma(adSettings.domainControllerFQDNs.toLowerCase());
|
||||
activeDirectoryObject.domainDnsName = adSettings.domainDNSName;
|
||||
activeDirectoryObject.subdomain = adSettings.subdomain;
|
||||
activeDirectoryObject.accountPrefix = adSettings.accountPrefix;
|
||||
activeDirectoryObject.realm = adSettings.realm ?? adSettings.domainDNSName.toUpperCase();
|
||||
activeDirectoryObject.clusterAdmins = this.splitByComma(adSettings.clusterAdmins);
|
||||
activeDirectoryObject.clusterUsers = this.splitByComma(adSettings.clusterUsers);
|
||||
if (adSettings.appReaders) {
|
||||
activeDirectoryObject.appReaders = this.splitByComma(adSettings.appReaders);
|
||||
}
|
||||
if (adSettings.appOwners) {
|
||||
activeDirectoryObject.appOwners = this.splitByComma(adSettings.appOwners);
|
||||
}
|
||||
|
||||
this._controlConfig.security.activeDirectory = activeDirectoryObject;
|
||||
}
|
||||
|
||||
public getBdcJson(readable: boolean = true): string {
|
||||
return this.stringifyJson(this._bdcConfig, readable);
|
||||
}
|
||||
|
||||
public getControlJson(readable: boolean = true): string {
|
||||
return this.stringifyJson(this._controlConfig, readable);
|
||||
}
|
||||
|
||||
private stringifyJson(obj: any, readable: boolean): string {
|
||||
return JSON.stringify(obj, undefined, readable ? 4 : 0);
|
||||
}
|
||||
|
||||
private getReplicas(resourceName: string): number {
|
||||
return <number>this._bdcConfig.spec.resources[resourceName].spec.replicas;
|
||||
}
|
||||
|
||||
private setReplicas(resourceName: string, replicas: number): void {
|
||||
this._bdcConfig.spec.resources[resourceName].spec.replicas = replicas;
|
||||
}
|
||||
|
||||
private getEndpointPort(endpoints: ServiceEndpoint[], name: EndpointName, defaultValue: number): number {
|
||||
const endpoint = endpoints.find(endpoint => endpoint.name === name);
|
||||
return endpoint ? endpoint.port : defaultValue;
|
||||
}
|
||||
|
||||
private setEndpoint(endpoints: ServiceEndpoint[], name: EndpointName, port: number, dnsName?: string): void {
|
||||
const endpoint = endpoints.find(endpoint => endpoint.name === name);
|
||||
if (endpoint) {
|
||||
endpoint.port = port;
|
||||
endpoint.dnsName = dnsName;
|
||||
} else {
|
||||
const newEndpoint: ServiceEndpoint = {
|
||||
name: name,
|
||||
serviceType: 'NodePort',
|
||||
port: port
|
||||
};
|
||||
// for newly added endpoint, we cannot have blank value for the dnsName, only set it if it is not empty
|
||||
if (dnsName) {
|
||||
newEndpoint.dnsName = dnsName;
|
||||
}
|
||||
endpoints.push(newEndpoint);
|
||||
}
|
||||
}
|
||||
|
||||
private splitByComma(value: string): string[] {
|
||||
// split by comma, then remove trailing spaces for each item and finally remove the empty values.
|
||||
return value.split(',').map(v => v && v.trim()).filter(v => v !== '' && v !== undefined);
|
||||
}
|
||||
}
|
||||
@@ -9,8 +9,7 @@ import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
import * as vscode from 'vscode';
|
||||
import * as nls from 'vscode-nls';
|
||||
import { DeploymentProvider, instanceOfAzureSQLVMDeploymentProvider, instanceOfAzureSQLDBDeploymentProvider, instanceOfCommandDeploymentProvider, instanceOfDialogDeploymentProvider, instanceOfDownloadDeploymentProvider, instanceOfNotebookBasedDialogInfo, instanceOfNotebookDeploymentProvider, instanceOfNotebookWizardDeploymentProvider, instanceOfWebPageDeploymentProvider, instanceOfWizardDeploymentProvider, NotebookInfo, NotebookPathInfo, ResourceType, ResourceTypeOption, ResourceSubType, AgreementInfo, HelpText, InitialVariableValues } from '../interfaces';
|
||||
import { AzdataService } from './azdataService';
|
||||
import { DeploymentProvider, instanceOfAzureSQLVMDeploymentProvider, instanceOfAzureSQLDBDeploymentProvider, instanceOfCommandDeploymentProvider, instanceOfDialogDeploymentProvider, instanceOfDownloadDeploymentProvider, instanceOfNotebookBasedDialogInfo, instanceOfNotebookDeploymentProvider, instanceOfNotebookWizardDeploymentProvider, instanceOfWebPageDeploymentProvider, NotebookInfo, NotebookPathInfo, ResourceType, ResourceTypeOption, ResourceSubType, AgreementInfo, HelpText, InitialVariableValues } from '../interfaces';
|
||||
import { KubeService } from './kubeService';
|
||||
import { INotebookService } from './notebookService';
|
||||
import { IPlatformService } from './platformService';
|
||||
@@ -116,9 +115,6 @@ export class ResourceTypeService implements IResourceTypeService {
|
||||
} else if (instanceOfDialogDeploymentProvider(provider) && instanceOfNotebookBasedDialogInfo(provider.dialog)) {
|
||||
this.updateNotebookPath(provider.dialog, extensionPath);
|
||||
}
|
||||
else if ('bdcWizard' in provider) {
|
||||
this.updateNotebookPath(provider.bdcWizard, extensionPath);
|
||||
}
|
||||
else if ('notebookWizard' in provider) {
|
||||
this.updateNotebookPath(provider.notebookWizard, extensionPath);
|
||||
}
|
||||
@@ -245,8 +241,7 @@ export class ResourceTypeService implements IResourceTypeService {
|
||||
let providerIndex = 1;
|
||||
resourceType.providers.forEach(provider => {
|
||||
const providerPositionInfo = `${positionInfo}, provider index: ${providerIndex} `;
|
||||
if (!instanceOfWizardDeploymentProvider(provider)
|
||||
&& !instanceOfNotebookWizardDeploymentProvider(provider)
|
||||
if (!instanceOfNotebookWizardDeploymentProvider(provider)
|
||||
&& !instanceOfDialogDeploymentProvider(provider)
|
||||
&& !instanceOfNotebookDeploymentProvider(provider)
|
||||
&& !instanceOfDownloadDeploymentProvider(provider)
|
||||
@@ -328,7 +323,7 @@ export class ResourceTypeService implements IResourceTypeService {
|
||||
}
|
||||
|
||||
public startDeployment(resourceType: ResourceType, optionValuesFilter?: OptionValuesFilter, initialVariableValues?: InitialVariableValues): void {
|
||||
const wizard = new ResourceTypeWizard(resourceType, new KubeService(), new AzdataService(this.platformService), this.notebookService, this.toolsService, this.platformService, this, optionValuesFilter, initialVariableValues);
|
||||
const wizard = new ResourceTypeWizard(resourceType, new KubeService(), this.notebookService, this.toolsService, this.platformService, this, optionValuesFilter, initialVariableValues);
|
||||
wizard.open();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,182 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { EOL } from 'os';
|
||||
import * as path from 'path';
|
||||
import { SemVer } from 'semver';
|
||||
import * as vscode from 'vscode';
|
||||
import * as nls from 'vscode-nls';
|
||||
import { AzdataInstallLocationKey, DeploymentConfigurationKey } from '../../constants';
|
||||
import { Command, OsDistribution, ToolType } from '../../interfaces';
|
||||
import { IPlatformService } from '../platformService';
|
||||
import { dependencyType, ToolBase } from './toolBase';
|
||||
import { SemVerProxy } from './SemVerProxy';
|
||||
|
||||
const localize = nls.loadMessageBundle();
|
||||
export const AzdataToolName = 'azdata';
|
||||
const win32InstallationRoot = `${process.env['ProgramFiles(x86)']}\\Microsoft SDKs\\Azdata\\CLI\\wbin`;
|
||||
const macInstallationRoot = '/usr/local/bin';
|
||||
const debianInstallationRoot = '/usr/local/bin';
|
||||
|
||||
export class AzdataTool extends ToolBase {
|
||||
constructor(platformService: IPlatformService) {
|
||||
super(platformService);
|
||||
}
|
||||
|
||||
get name(): string {
|
||||
return AzdataToolName;
|
||||
}
|
||||
|
||||
get description(): string {
|
||||
return localize('resourceDeployment.AzdataDescription', "Azure Data command line interface");
|
||||
}
|
||||
|
||||
get type(): ToolType {
|
||||
return ToolType.Azdata;
|
||||
}
|
||||
|
||||
get displayName(): string {
|
||||
return localize('resourceDeployment.AzdataDisplayName', "Azure Data CLI");
|
||||
}
|
||||
|
||||
get homePage(): string {
|
||||
return 'https://docs.microsoft.com/sql/big-data-cluster/deploy-install-azdata';
|
||||
}
|
||||
|
||||
protected get versionCommand(): Command {
|
||||
return {
|
||||
command: 'azdata -v'
|
||||
};
|
||||
}
|
||||
|
||||
protected get discoveryCommand(): Command {
|
||||
return {
|
||||
command: this.discoveryCommandString('azdata')
|
||||
};
|
||||
}
|
||||
|
||||
protected getVersionFromOutput(output: string): SemVer | undefined {
|
||||
let version: SemVer | undefined = undefined;
|
||||
if (output && output.split(EOL).length > 0) {
|
||||
version = new SemVerProxy(output.split(EOL)[0].replace(/ /g, ''));
|
||||
}
|
||||
return version;
|
||||
}
|
||||
protected override async getSearchPaths(): Promise<string[]> {
|
||||
switch (this.osDistribution) {
|
||||
case OsDistribution.win32:
|
||||
return [win32InstallationRoot];
|
||||
case OsDistribution.darwin:
|
||||
return [macInstallationRoot];
|
||||
case OsDistribution.debian:
|
||||
return [debianInstallationRoot];
|
||||
default:
|
||||
const azdataCliInstallLocation = await this.getPip3InstallLocation('azdata-cli');
|
||||
if (azdataCliInstallLocation) {
|
||||
return [path.join(azdataCliInstallLocation, '..', 'Scripts'), path.join(azdataCliInstallLocation, '..', '..', '..', 'bin')];
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected get allInstallationCommands(): Map<OsDistribution, Command[]> {
|
||||
return new Map<OsDistribution, Command[]>([
|
||||
[OsDistribution.debian, this.debianInstallationCommands],
|
||||
[OsDistribution.win32, this.win32InstallationCommands],
|
||||
[OsDistribution.darwin, this.macOsInstallationCommands],
|
||||
[OsDistribution.others, []]
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
private get azdataInstallLocation(): string {
|
||||
return vscode.workspace.getConfiguration(DeploymentConfigurationKey)[AzdataInstallLocationKey] || this.defaultInstallLocationByDistribution.get(this.osDistribution);
|
||||
}
|
||||
|
||||
private defaultInstallLocationByDistribution: Map<OsDistribution, string> = new Map<OsDistribution, string>([
|
||||
[OsDistribution.debian, 'https://packages.microsoft.com/config/ubuntu/16.04/mssql-server-2019.list'],
|
||||
[OsDistribution.win32, 'https://aka.ms/azdata-msi'],
|
||||
[OsDistribution.darwin, 'microsoft/azdata-cli-release'],
|
||||
[OsDistribution.others, '']
|
||||
]);
|
||||
|
||||
protected override dependenciesByOsType: Map<OsDistribution, dependencyType[]> = new Map<OsDistribution, dependencyType[]>([
|
||||
[OsDistribution.debian, []],
|
||||
[OsDistribution.win32, []],
|
||||
[OsDistribution.darwin, [dependencyType.Brew]],
|
||||
[OsDistribution.others, []]
|
||||
]);
|
||||
|
||||
private get win32InstallationCommands() {
|
||||
return [
|
||||
{
|
||||
comment: localize('resourceDeployment.Azdata.DeletingPreviousAzdata.msi', "deleting previously downloaded Azdata.msi if one exists …"),
|
||||
command: `IF EXIST .\\Azdata.msi DEL /F .\\Azdata.msi`
|
||||
},
|
||||
{
|
||||
sudo: true,
|
||||
comment: localize('resourceDeployment.Azdata.DownloadingAndInstallingAzdata', "downloading Azdata.msi and installing azdata-cli …"),
|
||||
command: `powershell -NoLogo -NonInteractive -NoProfile -Command "& {try {(New-Object System.Net.WebClient).DownloadFile('${this.azdataInstallLocation}', 'Azdata.msi'); Start-Process msiexec.exe -Wait -ArgumentList '/I Azdata.msi /passive /quiet /lvx ADS_AzdataInstall.log'} catch { Write-Error $_.Exception; exit 1 }}"`
|
||||
},
|
||||
{
|
||||
comment: localize('resourceDeployment.Azdata.DisplayingInstallationLog', "displaying the installation log …"),
|
||||
command: `type ADS_AzdataInstall.log | findstr /i /v ^MSI"`,
|
||||
ignoreError: true
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
private get macOsInstallationCommands() {
|
||||
return [
|
||||
{
|
||||
comment: localize('resourceDeployment.Azdata.TappingBrewRepository', "tapping into the brew repository for azdata-cli …"),
|
||||
command: `brew tap ${this.azdataInstallLocation}`
|
||||
},
|
||||
{
|
||||
comment: localize('resourceDeployment.Azdata.UpdatingBrewRepository', "updating the brew repository for azdata-cli installation …"),
|
||||
command: 'brew update'
|
||||
},
|
||||
{
|
||||
comment: localize('resourceDeployment.Azdata.InstallingAzdata', "installing azdata …"),
|
||||
command: 'brew install azdata-cli'
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
private get debianInstallationCommands() {
|
||||
return [
|
||||
{
|
||||
sudo: true,
|
||||
comment: localize('resourceDeployment.Azdata.AptGetUpdate', "updating repository information …"),
|
||||
command: 'apt-get update'
|
||||
},
|
||||
{
|
||||
sudo: true,
|
||||
comment: localize('resourceDeployment.Azdata.AptGetPackages', "getting packages needed for azdata installation …"),
|
||||
command: 'apt-get install gnupg ca-certificates curl apt-transport-https lsb-release -y'
|
||||
},
|
||||
{
|
||||
sudo: true,
|
||||
comment: localize('resourceDeployment.Azdata.DownloadAndInstallingSigningKey', "downloading and installing the signing key for azdata …"),
|
||||
command: 'wget -qO- https://packages.microsoft.com/keys/microsoft.asc | apt-key add -'
|
||||
},
|
||||
{
|
||||
sudo: true,
|
||||
comment: localize('resourceDeployment.Azdata.AddingAzdataRepositoryInformation', "adding the azdata repository information …"),
|
||||
command: `add-apt-repository "$(wget -qO- ${this.azdataInstallLocation})"`
|
||||
},
|
||||
{
|
||||
sudo: true,
|
||||
comment: localize('resourceDeployment.Azdata.AptGetUpdate', "updating repository information …"),
|
||||
command: 'apt-get update'
|
||||
},
|
||||
{
|
||||
sudo: true,
|
||||
comment: localize('resourceDeployment.Azdata.InstallingAzdata', "installing azdata …"),
|
||||
command: 'apt-get install -y azdata-cli'
|
||||
}
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,6 @@ import { DockerTool } from './tools/dockerTool';
|
||||
import { AzCliTool } from './tools/azCliTool';
|
||||
import { KubeCtlTool } from './tools/kubeCtlTool';
|
||||
import { IPlatformService } from './platformService';
|
||||
import { AzdataTool } from './tools/azdataTool';
|
||||
|
||||
export interface IToolsService {
|
||||
getToolByName(toolName: string): ITool | undefined;
|
||||
@@ -23,7 +22,6 @@ export class ToolsService implements IToolsService {
|
||||
[
|
||||
new DockerTool(this._platformService),
|
||||
new AzCliTool(this._platformService),
|
||||
new AzdataTool(this._platformService),
|
||||
new KubeCtlTool(this._platformService)
|
||||
].map<[string, ITool]>((tool: ITool) => [tool.name, tool])
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user