Update load license
This commit is contained in:
parent
38b6cb4981
commit
f6620edc35
|
|
@ -13,6 +13,7 @@ import {
|
|||
mapErrorsToRows,
|
||||
mapToLineFormat,
|
||||
normalizeInterface,
|
||||
parseLicenseReport,
|
||||
sendMessageToMail,
|
||||
sleep,
|
||||
TestSession,
|
||||
|
|
@ -204,7 +205,7 @@ export default class LineConnection {
|
|||
}
|
||||
if (this.outputLoadIosLicense) {
|
||||
if (this.outputLoadIosLicense === true) this.outputLoadIosLicense = ''
|
||||
this.outputLoadIosLicense += message
|
||||
this.outputLoadIosLicense += cleanData(data.toString())
|
||||
}
|
||||
if (this.config.runningPhysical) {
|
||||
this.outputPhysicalTest += message
|
||||
|
|
@ -1217,7 +1218,7 @@ export default class LineConnection {
|
|||
IOS : <b>${nameIos}</b> <br/>
|
||||
Started At : ${startTime}<br/>
|
||||
Finished At : ${dataFormat}<br/>
|
||||
────────────────────────────────<br/>
|
||||
<br/>
|
||||
`.trim()
|
||||
|
||||
await sendMessageToMail(
|
||||
|
|
@ -1238,6 +1239,10 @@ export default class LineConnection {
|
|||
async sendEmailLoadLicense(nameLicense: string, startTime: string) {
|
||||
const timeZone = process.env.TIME_ZONE || 'Australia/Sydney'
|
||||
const dataFormat = momentTZ().tz(timeZone).format('YYYY/MM/DD, HH:mm:ss')
|
||||
const report = parseLicenseReport(
|
||||
typeof this.outputLoadIosLicense === 'string' ? this.outputLoadIosLicense : ''
|
||||
)
|
||||
|
||||
const body = `
|
||||
Load License Report<br/>
|
||||
────────────────────────────────<br/>
|
||||
|
|
@ -1247,6 +1252,11 @@ export default class LineConnection {
|
|||
Started At : ${startTime}<br/>
|
||||
Finished At : ${dataFormat}<br/>
|
||||
────────────────────────────────<br/>
|
||||
Summary licenses: <b>${report.summary.join(', ')}</b><br/>
|
||||
Successful: <b>${report.imported.join(', ')}</b><br/>
|
||||
Exist: <b>${report.exist.join(', ')}</b><br/>
|
||||
Failed: <b>${report.failed.join(', ')}</b><br/>
|
||||
<br/>
|
||||
`.trim()
|
||||
|
||||
await sendMessageToMail(
|
||||
|
|
|
|||
|
|
@ -892,7 +892,7 @@ export function buildBody(
|
|||
repeat: '1',
|
||||
note: '',
|
||||
},
|
||||
{ expect: '', send: ``, delay: '1', repeat: '1', note: '' },
|
||||
{ expect: '', send: ``, delay: '4', repeat: '1', note: '' },
|
||||
{
|
||||
expect: '#',
|
||||
send: listDeviceIos?.includes(fileName) ? '' : `copy tftp: flash:`,
|
||||
|
|
@ -1073,7 +1073,7 @@ export function buildBody(
|
|||
{
|
||||
expect: '',
|
||||
send: ``,
|
||||
delay: '2',
|
||||
delay: '4',
|
||||
repeat: '1',
|
||||
note: '',
|
||||
},
|
||||
|
|
@ -1234,7 +1234,7 @@ export function buildBody(
|
|||
{
|
||||
expect: '',
|
||||
send: ``,
|
||||
delay: '2',
|
||||
delay: '4',
|
||||
repeat: '1',
|
||||
note: '',
|
||||
},
|
||||
|
|
@ -1337,3 +1337,52 @@ export function buildBody(
|
|||
return []
|
||||
}
|
||||
}
|
||||
|
||||
export function parseLicenseReport(output: string) {
|
||||
const summary = []
|
||||
const imported = []
|
||||
const exist = []
|
||||
const failed = []
|
||||
|
||||
// lấy toàn bộ feature
|
||||
const allFeatureRegex = /Feature:([a-z0-9_]+)/gi
|
||||
let match
|
||||
while ((match = allFeatureRegex.exec(output))) {
|
||||
summary.push(match[1])
|
||||
}
|
||||
|
||||
// split theo từng dòng install
|
||||
const lines = output.split('\n')
|
||||
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
const line = lines[i]
|
||||
|
||||
// success
|
||||
const successMatch = line.match(/Feature:([a-z0-9_]+)\.\.\.Successful/i)
|
||||
if (successMatch) {
|
||||
imported.push(successMatch[1])
|
||||
continue
|
||||
}
|
||||
|
||||
// failed
|
||||
const failedMatch = line.match(/Feature:([a-z0-9_]+)\.\.\.Failed:/i)
|
||||
if (failedMatch) {
|
||||
const feature = failedMatch[1]
|
||||
|
||||
// check duplicate ở dòng sau
|
||||
const nextLine = lines[i + 1] || ''
|
||||
if (/Duplicate license/i.test(nextLine)) {
|
||||
exist.push(feature)
|
||||
} else {
|
||||
failed.push(feature)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
summary: [...summary],
|
||||
imported: [...imported],
|
||||
exist: [...exist],
|
||||
failed: [...failed],
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue