Compare commits
1 Commits
feat_s3_st
...
icinga2-te
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aa92f0fc93 |
@@ -272,7 +272,7 @@ class BackupReportsXoPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
async _metadataHandler(log, { name: jobName }, schedule, force) {
|
||||
async _metadataHandler(log, job, schedule, force) {
|
||||
const xo = this._xo
|
||||
|
||||
const formatDate = createDateFormatter(schedule?.timezone)
|
||||
@@ -290,7 +290,7 @@ class BackupReportsXoPlugin {
|
||||
`## Global status: ${log.status}`,
|
||||
'',
|
||||
`- **Job ID**: ${log.jobId}`,
|
||||
`- **Job name**: ${jobName}`,
|
||||
`- **Job name**: ${job.name}`,
|
||||
`- **Run ID**: ${log.id}`,
|
||||
...getTemporalDataMarkdown(log.end, log.start, formatDate),
|
||||
n !== 0 && `- **Successes**: ${nSuccesses} / ${n}`,
|
||||
@@ -349,10 +349,12 @@ class BackupReportsXoPlugin {
|
||||
markdown.push('---', '', `*${pkg.name} v${pkg.version}*`)
|
||||
|
||||
return this._sendReport({
|
||||
job,
|
||||
subject: `[Xen Orchestra] ${log.status} − Metadata backup report for ${
|
||||
log.jobName
|
||||
} ${STATUS_ICON[log.status]}`,
|
||||
markdown: toMarkdown(markdown),
|
||||
schedule,
|
||||
success: log.status === 'success',
|
||||
nagiosMarkdown:
|
||||
log.status === 'success'
|
||||
@@ -363,10 +365,10 @@ class BackupReportsXoPlugin {
|
||||
})
|
||||
}
|
||||
|
||||
async _ngVmHandler(log, { name: jobName, settings }, schedule, force) {
|
||||
async _ngVmHandler(log, job, schedule, force) {
|
||||
const xo = this._xo
|
||||
|
||||
const mailReceivers = get(() => settings[''].reportRecipients)
|
||||
const mailReceivers = get(() => job.settings[''].reportRecipients)
|
||||
const { reportWhen, mode } = log.data || {}
|
||||
|
||||
const formatDate = createDateFormatter(schedule?.timezone)
|
||||
@@ -385,12 +387,17 @@ class BackupReportsXoPlugin {
|
||||
'',
|
||||
`*${pkg.name} v${pkg.version}*`,
|
||||
]
|
||||
|
||||
const jobName = job.name
|
||||
|
||||
return this._sendReport({
|
||||
subject: `[Xen Orchestra] ${
|
||||
log.status
|
||||
} − Backup report for ${jobName} ${STATUS_ICON[log.status]}`,
|
||||
job,
|
||||
mailReceivers,
|
||||
markdown: toMarkdown(markdown),
|
||||
schedule,
|
||||
success: false,
|
||||
nagiosMarkdown: `[Xen Orchestra] [${
|
||||
log.status
|
||||
@@ -649,8 +656,10 @@ class BackupReportsXoPlugin {
|
||||
|
||||
markdown.push('---', '', `*${pkg.name} v${pkg.version}*`)
|
||||
return this._sendReport({
|
||||
job,
|
||||
mailReceivers,
|
||||
markdown: toMarkdown(markdown),
|
||||
schedule,
|
||||
subject: `[Xen Orchestra] ${log.status} − Backup report for ${jobName} ${
|
||||
STATUS_ICON[log.status]
|
||||
}`,
|
||||
@@ -724,7 +733,9 @@ class BackupReportsXoPlugin {
|
||||
markdown = markdown.join('\n')
|
||||
return this._sendReport({
|
||||
subject: `[Xen Orchestra] ${globalStatus} ${icon}`,
|
||||
job,
|
||||
markdown,
|
||||
schedule,
|
||||
success: false,
|
||||
nagiosMarkdown: `[Xen Orchestra] [${globalStatus}] Error : ${error.message}`,
|
||||
})
|
||||
@@ -913,6 +924,7 @@ class BackupReportsXoPlugin {
|
||||
markdown = markdown.join('\n')
|
||||
|
||||
return this._sendReport({
|
||||
job,
|
||||
markdown,
|
||||
subject: `[Xen Orchestra] ${globalStatus} − Backup report for ${tag} ${
|
||||
globalSuccess
|
||||
@@ -921,6 +933,7 @@ class BackupReportsXoPlugin {
|
||||
? ICON_FAILURE
|
||||
: ICON_SKIPPED
|
||||
}`,
|
||||
schedule,
|
||||
success: globalSuccess,
|
||||
nagiosMarkdown: globalSuccess
|
||||
? `[Xen Orchestra] [Success] Backup report for ${tag}`
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
import assert from 'assert'
|
||||
import assert, { match } from 'assert'
|
||||
import { URL } from 'url'
|
||||
|
||||
const RE = /(\\*)\{([^}]+)\}/
|
||||
const evalTemplate = (template, fn) =>
|
||||
template.replace(RE, ([, escape, key]) => {
|
||||
const n = escape.length
|
||||
const escaped = n % 2 !== 0
|
||||
return escaped ? match.slice(n - 1 / 2) : escaped.slice(n / 2) + fn(key)
|
||||
})
|
||||
|
||||
// =============================================================================
|
||||
|
||||
export const configurationSchema = {
|
||||
@@ -83,7 +91,14 @@ class XoServerIcinga2 {
|
||||
this._url = serverUrl.href
|
||||
|
||||
this._filter =
|
||||
configuration.filter !== undefined ? configuration.filter : ''
|
||||
configuration.filter !== undefined
|
||||
? compileTemplate(configuration.filter, {
|
||||
jobId: _ => _.job.id,
|
||||
jobName: _ => _.job.name,
|
||||
scheduleId: _ => _.schedule.id,
|
||||
scheduleName: _ => _.schedule.name,
|
||||
})
|
||||
: ''
|
||||
this._acceptUnauthorized = configuration.acceptUnauthorized
|
||||
}
|
||||
|
||||
|
||||
@@ -310,10 +310,7 @@ export default class Jobs {
|
||||
true
|
||||
)
|
||||
|
||||
app.emit('job:terminated', runJobId, {
|
||||
type: job.type,
|
||||
status,
|
||||
})
|
||||
app.emit('job:terminated', { job, runJobId, schedule, status })
|
||||
} finally {
|
||||
this.updateJob({ id, runId: null })::ignoreErrors()
|
||||
delete runningJobs[id]
|
||||
@@ -332,9 +329,7 @@ export default class Jobs {
|
||||
},
|
||||
true
|
||||
)
|
||||
app.emit('job:terminated', runJobId, {
|
||||
type: job.type,
|
||||
})
|
||||
app.emit('job:terminated', { job, runJobId, schedule })
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user