Skip to content

Commit ac0332a

Browse files
committed
Add Huawei MO Tree CM parser
1 parent a95dff0 commit ac0332a

File tree

5 files changed

+108
-8
lines changed

5 files changed

+108
-8
lines changed

background/background-process.html

Lines changed: 103 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,32 @@ <h1>Background process</h1>
345345
}
346346

347347

348+
349+
/**
350+
* Clean Huawei GExport files.
351+
*
352+
* sed -i -r "
353+
* s/<MO className="(BSC6900GSM|BSC6900UMTS|BSC6900GU|BSC6910GSM|BSC6910UMTS|BSC6910GU)(.*)/<MO className="\1/ig;
354+
* " /mediation/data/cm/huawei/raw/motree/*.xml
355+
*
356+
* @exportFolder String Folder with the MO Tree dump XML files to be cleaned
357+
*/
358+
cleanHuaweiMOTreeFiles = async (exportFolder) => {
359+
const replaceOptions = {
360+
files: path.join(exportFolder,'*'),
361+
from: [
362+
/<MO className="(BSC6900GSM|BSC6900UMTS|BSC6900GU|BSC6910GSM|BSC6910UMTS|BSC6910GU)/g
363+
],
364+
to: [
365+
"<MO className=\""
366+
],
367+
};
368+
369+
return await replace.sync(replaceOptions)
370+
}
371+
372+
373+
348374
/*Use gnu sed.exe on windows
349375
*
350376
*/
@@ -379,6 +405,42 @@ <h1>Background process</h1>
379405

380406
}
381407

408+
409+
/*
410+
* Clean Huawei MO Tree XML files.
411+
* @param string inputFolder
412+
*/
413+
cleanHuaweiMOTreeWithSed = (inputFolder) => {
414+
let libPath = app.getAppPath();
415+
416+
if (!isDev) {
417+
libPath = process.resourcesPath;
418+
}
419+
420+
let files = fs.readdirSync(inputFolder, { withFileTypes: true }).filter(dirent => !dirent.isDirectory()).map(dirent => dirent.name);
421+
422+
const sedScript = path.join(libPath,'libraries', 'motree_cleanup.sed');
423+
const sed = path.join(libPath,'libraries','sed.exe');
424+
425+
for (let i=0; i<files.length; i++) {
426+
f = files[i];
427+
inputFile = path.join(inputFolder,f);
428+
429+
log.info(`Cleaning ${f}...`);
430+
sendLogToUI('parse_data','info', `Cleaning ${f}...`);
431+
432+
const child = spawnSync(sed, ['-i', '-r', '-f', sedScript, inputFile]);
433+
log.info(`${sed} -i -r -f ${sedScript} ${inputFile}`);
434+
435+
if(child.error){
436+
log.info(`[parse_cm_job] error:${child.error.toString()}`);
437+
throw child.error.toString();
438+
}
439+
}
440+
441+
}
442+
443+
382444
/*
383445
* Take the latest file when there is more than one file from the same node .
384446
*
@@ -460,7 +522,7 @@ <h1>Background process</h1>
460522
removeDublicateHuaweiGExportFiles(inputFolder)
461523

462524
log.info(`[parse_cm_job] Uncompressing files GExport XML files...`)
463-
sendLogToUI('parse_data','info',`Uncompressing files GExport XML files...` );
525+
sendLogToUI('parse_data','info',"Uncompressing files GExport XML files...");
464526

465527
uncompressFolder(inputFolder);
466528

@@ -488,17 +550,53 @@ <h1>Background process</h1>
488550
}
489551

490552
}
553+
554+
//Clean Huawei MOTree files
555+
else if(vendor === 'HUAWEI' && format === 'MOTREE_XML'){
556+
try{
557+
558+
log.info(`Uncompressing files MOTree XML files...`);
559+
sendLogToUI('parse_data','info', "Uncompressing files MOTree XML files...");
560+
561+
uncompressFolder(inputFolder);
562+
563+
log.info(`Uncompressing files MOTree XML files...`)
564+
sendLogToUI('parse_data','info',"Cleaning MOTree XML files...");
565+
566+
if(process.platform === "win32"){
567+
//If windows test, with sed.exe
568+
cleanHuaweiMOTreeWithSed(inputFolder);
569+
}else{
570+
await cleanHuaweiMOTreeFiles(inputFolder);
571+
}
572+
573+
log.info(`Cleanup of MOTree XML files completed.`);
574+
sendLogToUI('parse_data','info',"Cleanup of MOTree XML files completed.");
575+
576+
}catch(error){
577+
log.error('Error occurred:', error);
578+
if(typeof error === 'undefined'){
579+
sendLogToUI('parse_data','error', 'Error occured.');
580+
return;
581+
}
582+
sendLogToUI('parse_data','error',error.toString());
583+
return;
584+
}
585+
586+
}
587+
588+
491589
//Uncompress files for other vendor format combinations except huawei gexport
492590
//The reason for this is we want to first remove the duplicates in the dumps, before wasting time
493591
//uncompressing what does not need to be uncompressed
494-
//else if(vendor !== 'HUAWEI' && format !== 'GEXPORT_XML'){
592+
//else if(vendor !== 'HUAWEI' && (format !== 'GEXPORT_XML' || format !== 'MOTREE_XML')){
495593
else{
496-
sendLogToUI('parse_data','info',`Uncompressing files...` );
497-
log.info(`Uncompressing files...`)
594+
sendLogToUI('parse_data','info',"Uncompressing files...");
595+
log.info("Uncompressing files...")
498596
uncompressFolder(inputFolder);
499597
}
500598

501-
sendLogToUI('parse_data','info', `Parsing files...`);
599+
sendLogToUI('parse_data','info', "Parsing files...");
502600
log.info("Parsing files...")
503601

504602

background/vendor-formats.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const VENDOR_CM_FORMATS = {
22
'ERICSSON': ['BULKCM','CNAIV2','BSM','EAW'],
3-
'HUAWEI': ['GEXPORT_XML','NBI_XML','CFGMML', 'AUTOBAK_XML'],
3+
'HUAWEI': ['GEXPORT_XML','NBI_XML','CFGMML', 'AUTOBAK_XML', 'MOTREE_XML'],
44
'ZTE': ['BULKCM','XLS'],
55
'NOKIA': ['RAML'],
66
'BODASTAGE': ['BCF_CSV']
@@ -35,7 +35,8 @@ const VENDOR_CM_PARSERS = {
3535
'GEXPORT_XML': 'boda-huaweicmobjectparser.jar',
3636
'CFGMML': 'boda-huaweimmlparser.jar',
3737
'NBI_XML': 'boda-huaweicmxmlparser.jar',
38-
'AUTOBAK_XML': 'boda-huaweicfgsynparser.jar'
38+
'AUTOBAK_XML': 'boda-huaweicfgsynparser.jar',
39+
'MOTREE_XML': 'boda-huaweicmmotreeparser.jar'
3940
},
4041
'ZTE': {
4142
'BULKCM': 'boda-bulkcmparser.jar',
748 KB
Binary file not shown.

libraries/motree_cleanup.sed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
s/<MO className="(BSC6900GSM|BSC6900UMTS|BSC6900GU|BSC6910GSM|BSC6910UMTS|BSC6910GU)(.*)/<MO className="\2/g;

src/modules/cm/VendorFormats.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export const VENDOR_CM_FORMATS = {
22
'ERICSSON': ['BULKCM','CNAIV2','BSM','EAW'],
3-
'HUAWEI': ['GEXPORT_XML','NBI_XML','CFGMML', 'AUTOBAK_XML'],
3+
'HUAWEI': ['GEXPORT_XML','NBI_XML','CFGMML', 'AUTOBAK_XML', "MOTREE_XML"],
44
'ZTE': ['BULKCM','XLS'],
55
'NOKIA': ['RAML'],
66
'MOTOROLA': ['CELL_X_EXPORT'],

0 commit comments

Comments
 (0)