use direct db connection datasource name for provisioning, #614
This commit is contained in:
@@ -15,17 +15,22 @@ export default class DBConnector {
|
||||
}
|
||||
|
||||
loadDBDataSource() {
|
||||
let ds = _.find(this.datasourceSrv.getAll(), {'id': this.datasourceId});
|
||||
if (ds) {
|
||||
return this.datasourceSrv.loadDatasource(ds.name)
|
||||
if (!this.datasourceName && this.datasourceId !== undefined) {
|
||||
let ds = _.find(this.datasourceSrv.getAll(), {'id': this.datasourceId});
|
||||
if (!ds) {
|
||||
return Promise.reject(`SQL Data Source with ID ${this.datasourceId} not found`);
|
||||
}
|
||||
this.datasourceName = ds.name;
|
||||
}
|
||||
if (this.datasourceName) {
|
||||
return this.datasourceSrv.loadDatasource(this.datasourceName)
|
||||
.then(ds => {
|
||||
this.datasourceName = ds.name;
|
||||
this.datasourceTypeId = ds.meta.id;
|
||||
this.datasourceTypeName = ds.meta.name;
|
||||
return ds;
|
||||
});
|
||||
} else {
|
||||
return Promise.reject(`SQL Data Source with ID ${this.datasourceId} not found`);
|
||||
return Promise.reject(`SQL Data Source name should be specified`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,8 @@ export class Zabbix {
|
||||
withCredentials,
|
||||
cacheTTL,
|
||||
enableDirectDBConnection,
|
||||
datasourceId
|
||||
dbConnectionDatasourceId,
|
||||
dbConnectionDatasourceName,
|
||||
} = options;
|
||||
|
||||
this.enableDirectDBConnection = enableDirectDBConnection;
|
||||
@@ -45,7 +46,10 @@ export class Zabbix {
|
||||
this.zabbixAPI = new ZabbixAPIConnector(url, username, password, basicAuth, withCredentials, backendSrv);
|
||||
|
||||
if (enableDirectDBConnection) {
|
||||
let dbConnectorOptions = { datasourceId };
|
||||
let dbConnectorOptions = {
|
||||
datasourceId: dbConnectionDatasourceId,
|
||||
datasourceName: dbConnectionDatasourceName
|
||||
};
|
||||
this.dbConnector = new SQLConnector(dbConnectorOptions, backendSrv, datasourceSrv);
|
||||
this.getHistoryDB = this.cachingProxy.proxyfyWithCache(this.dbConnector.getHistory, 'getHistory', this.dbConnector);
|
||||
this.getTrendsDB = this.cachingProxy.proxyfyWithCache(this.dbConnector.getTrends, 'getTrends', this.dbConnector);
|
||||
|
||||
Reference in New Issue
Block a user