fix(all): TRUE multicloud.
This commit is contained in:
parent
c2bdbbe140
commit
21ed20dcf0
3 changed files with 72 additions and 73 deletions
|
@ -291,7 +291,6 @@ export class GBVMService extends GBService {
|
||||||
}
|
}
|
||||||
|
|
||||||
connections.forEach(async con => {
|
connections.forEach(async con => {
|
||||||
|
|
||||||
const connectionName = con['name'];
|
const connectionName = con['name'];
|
||||||
|
|
||||||
const dialect = con['storageDriver'];
|
const dialect = con['storageDriver'];
|
||||||
|
@ -1124,7 +1123,7 @@ export class GBVMService extends GBService {
|
||||||
let result;
|
let result;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (GBConfigService.get('GBVM') === 'false') {
|
if (!GBConfigService.get('GBVM')) {
|
||||||
return await (async () => {
|
return await (async () => {
|
||||||
return await new Promise((resolve, reject) => {
|
return await new Promise((resolve, reject) => {
|
||||||
sandbox['resolve'] = resolve;
|
sandbox['resolve'] = resolve;
|
||||||
|
@ -1145,6 +1144,7 @@ export class GBVMService extends GBService {
|
||||||
});
|
});
|
||||||
const s = new VMScript(code, { filename: scriptPath });
|
const s = new VMScript(code, { filename: scriptPath });
|
||||||
result = vm1.run(s);
|
result = vm1.run(s);
|
||||||
|
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
} else {
|
} else {
|
||||||
|
@ -1167,7 +1167,7 @@ export class GBVMService extends GBService {
|
||||||
cpu: 100,
|
cpu: 100,
|
||||||
memory: 50000,
|
memory: 50000,
|
||||||
time: 60 * 60 * 24 * 14,
|
time: 60 * 60 * 24 * 14,
|
||||||
cwd: gbdialogPath,
|
cwd: scriptPath,
|
||||||
script: runnerPath
|
script: runnerPath
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ export class GBConfigService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static get(key: string): string | undefined {
|
public static get(key: string) {
|
||||||
let value = GBConfigService.tryGet(key);
|
let value = GBConfigService.tryGet(key);
|
||||||
|
|
||||||
if (!value) {
|
if (!value) {
|
||||||
|
@ -84,6 +84,9 @@ export class GBConfigService {
|
||||||
case 'PORT':
|
case 'PORT':
|
||||||
value = this.getServerPort();
|
value = this.getServerPort();
|
||||||
break;
|
break;
|
||||||
|
case 'GBVM':
|
||||||
|
value = false;
|
||||||
|
break;
|
||||||
case 'STORAGE_NAME':
|
case 'STORAGE_NAME':
|
||||||
value = null;
|
value = null;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -314,7 +314,6 @@ export class GBDeployer implements IGBDeployer {
|
||||||
instance.marketplacePassword,
|
instance.marketplacePassword,
|
||||||
subscriptionId
|
subscriptionId
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Saves final instance object and returns it.
|
// Saves final instance object and returns it.
|
||||||
|
@ -424,17 +423,16 @@ export class GBDeployer implements IGBDeployer {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public async loadParamsFromTabular(min: GBMinInstance, filePath: string): Promise<any> {
|
public async loadParamsFromTabular(min: GBMinInstance, filePath: string): Promise<any> {
|
||||||
if (!Fs.existsSync(filePath)) {
|
const xls = Path.join(filePath, 'Config.xlsx');
|
||||||
return [];
|
const csv = Path.join(filePath, 'config.csv');
|
||||||
}
|
|
||||||
|
|
||||||
const ext = Path.extname(filePath).toLowerCase();
|
|
||||||
let rows: any[] = [];
|
let rows: any[] = [];
|
||||||
|
let obj: any = {};
|
||||||
|
|
||||||
const workbook = new Excel.Workbook();
|
const workbook = new Excel.Workbook();
|
||||||
|
|
||||||
if (ext === '.xlsx') {
|
if (Fs.existsSync(xls)) {
|
||||||
await workbook.xlsx.readFile(filePath);
|
await workbook.xlsx.readFile(xls);
|
||||||
let worksheet: any;
|
let worksheet: any;
|
||||||
for (let t = 0; t < workbook.worksheets.length; t++) {
|
for (let t = 0; t < workbook.worksheets.length; t++) {
|
||||||
worksheet = workbook.worksheets[t];
|
worksheet = workbook.worksheets[t];
|
||||||
|
@ -443,29 +441,30 @@ export class GBDeployer implements IGBDeployer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rows = worksheet.getSheetValues();
|
rows = worksheet.getSheetValues();
|
||||||
} else if (ext === '.csv') {
|
|
||||||
await workbook.csv.readFile(filePath);
|
|
||||||
let worksheet = workbook.worksheets[0]; // Assuming the CSV file has only one sheet
|
|
||||||
rows = worksheet.getSheetValues();
|
|
||||||
} else {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
GBLogEx.info(min, `Processing ${rows.length} rows from Config file ${filePath}...`);
|
|
||||||
|
|
||||||
// Skips the header lines.
|
// Skips the header lines.
|
||||||
for (let index = 0; index < 6; index++) {
|
for (let index = 0; index < 6; index++) {
|
||||||
rows.shift();
|
rows.shift();
|
||||||
}
|
}
|
||||||
|
} else if (Fs.existsSync(csv)) {
|
||||||
|
await workbook.csv.readFile(filePath);
|
||||||
|
let worksheet = workbook.worksheets[0]; // Assuming the CSV file has only one sheet
|
||||||
|
rows = worksheet.getSheetValues();
|
||||||
|
|
||||||
let obj: any = {};
|
// Skips the header lines.
|
||||||
|
|
||||||
|
rows.shift();
|
||||||
|
} else {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
await asyncPromise.eachSeries(rows, async (line: any) => {
|
await asyncPromise.eachSeries(rows, async (line: any) => {
|
||||||
if (line && line._cells[0] && line._cells[1] && line._cells[0].text) {
|
if (line && line.length > 0) {
|
||||||
obj[line._cells[0].text] = line._cells[1].text;
|
obj[line[1]] = line[2];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
GBLogEx.info(min, GBUtil.toYAML(obj));
|
GBLogEx.info(min, `Processing ${rows.length} rows from ${filePath}...`);
|
||||||
|
rows = null;
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -624,13 +623,10 @@ export class GBDeployer implements IGBDeployer {
|
||||||
|
|
||||||
switch (packageType) {
|
switch (packageType) {
|
||||||
case '.gbot':
|
case '.gbot':
|
||||||
|
|
||||||
|
|
||||||
// Extracts configuration information from .gbot files.
|
// Extracts configuration information from .gbot files.
|
||||||
|
|
||||||
min.instance.params = await this.loadParamsFromTabular(min, localPath);
|
min.instance.params = await this.loadParamsFromTabular(min, localPath);
|
||||||
if (min.instance.params.length){
|
if (min.instance.params) {
|
||||||
|
|
||||||
let connections = [];
|
let connections = [];
|
||||||
|
|
||||||
// Find all tokens in .gbot Config.
|
// Find all tokens in .gbot Config.
|
||||||
|
@ -640,12 +636,12 @@ export class GBDeployer implements IGBDeployer {
|
||||||
const connectionName = t.replace(strFind, '');
|
const connectionName = t.replace(strFind, '');
|
||||||
let con = {};
|
let con = {};
|
||||||
con['name'] = connectionName;
|
con['name'] = connectionName;
|
||||||
(con['storageServer'] = min.core.getParam<string>(min.instance, `${connectionName} Server`, null)),
|
con['storageServer'] = min.core.getParam<string>(min.instance, `${connectionName} Server`, null);
|
||||||
(con['storageName'] = min.core.getParam<string>(min.instance, `${connectionName} Name`, null)),
|
con['storageUsername'] = min.core.getParam<string>(min.instance, `${connectionName} Username`, null);
|
||||||
(con['storageUsername'] = min.core.getParam<string>(min.instance, `${connectionName} Username`, null)),
|
con['storageName'] = min.core.getParam<string>(min.instance, `${connectionName} Name`, null);
|
||||||
(con['storagePort'] = min.core.getParam<string>(min.instance, `${connectionName} Port`, null)),
|
con['storagePort'] = min.core.getParam<string>(min.instance, `${connectionName} Port`, null);
|
||||||
(con['storagePassword'] = min.core.getParam<string>(min.instance, `${connectionName} Password`, null)),
|
con['storagePassword'] = min.core.getParam<string>(min.instance, `${connectionName} Password`, null);
|
||||||
(con['storageDriver'] = min.core.getParam<string>(min.instance, `${connectionName} Driver`, null));
|
con['storageDriver'] = min.core.getParam<string>(min.instance, `${connectionName} Driver`, null);
|
||||||
connections.push(con);
|
connections.push(con);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue