@xen-orchestra/rest-api 0.21.1 → 0.21.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs
CHANGED
|
@@ -12,6 +12,7 @@ const swaggerOpenApiSpec = require('../open-api/spec/swagger.json');
|
|
|
12
12
|
export const BASE_URL = '/rest/v0';
|
|
13
13
|
const SWAGGER_UI_OPTIONS = {
|
|
14
14
|
swaggerOptions: {
|
|
15
|
+
url: `${BASE_URL}/docs/swagger.json`,
|
|
15
16
|
displayRequestDuration: true,
|
|
16
17
|
docExpansion: 'none', // collapse all tags by default
|
|
17
18
|
filter: true, // add a tags searchbar,
|
|
@@ -40,7 +41,7 @@ export default function setupRestApi(express, xoApp) {
|
|
|
40
41
|
});
|
|
41
42
|
// do not register the doc at the root level, or it may lead to unwanted behaviour
|
|
42
43
|
express.get('/rest/v0', (_req, res) => res.redirect('/rest/v0/docs'));
|
|
43
|
-
express.use(`${BASE_URL}/docs`, swaggerUi.
|
|
44
|
+
express.use(`${BASE_URL}/docs`, swaggerUi.serveFiles(undefined, SWAGGER_UI_OPTIONS), swaggerUi.setup(null, SWAGGER_UI_OPTIONS));
|
|
44
45
|
express.use(BASE_URL, tsoaToXoErrorHandler);
|
|
45
46
|
express.use(BASE_URL, genericErrorHandler);
|
|
46
47
|
}
|
|
@@ -105,7 +105,7 @@ const models = {
|
|
|
105
105
|
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
|
|
106
106
|
"XoGuiRoutes": {
|
|
107
107
|
"dataType": "refAlias",
|
|
108
|
-
"type": { "dataType": "nestedObjectLiteral", "nestedProperties": { "xo6": { "dataType": "
|
|
108
|
+
"type": { "dataType": "nestedObjectLiteral", "nestedProperties": { "xo6": { "dataType": "string" }, "xo5": { "dataType": "string" } }, "validators": {} },
|
|
109
109
|
},
|
|
110
110
|
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
|
|
111
111
|
"Record_string.string_": {
|
|
@@ -350,7 +350,7 @@ const models = {
|
|
|
350
350
|
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
|
|
351
351
|
"UnbrandedVmDashboard": {
|
|
352
352
|
"dataType": "refAlias",
|
|
353
|
-
"type": { "dataType": "nestedObjectLiteral", "nestedProperties": { "backupsInfo": { "dataType": "nestedObjectLiteral", "nestedProperties": { "backupArchives": { "dataType": "array", "array": { "dataType": "refAlias", "ref": "Unbrand_VmDashboardBackupArchive_" }, "required": true }, "replication": { "ref": "Unbrand_VmDashboard-at-backupsInfo_91_replication_93__" }, "
|
|
353
|
+
"type": { "dataType": "nestedObjectLiteral", "nestedProperties": { "backupsInfo": { "dataType": "nestedObjectLiteral", "nestedProperties": { "backupArchives": { "dataType": "array", "array": { "dataType": "refAlias", "ref": "Unbrand_VmDashboardBackupArchive_" }, "required": true }, "replication": { "ref": "Unbrand_VmDashboard-at-backupsInfo_91_replication_93__" }, "vmProtection": { "dataType": "union", "subSchemas": [{ "dataType": "enum", "enums": ["protected"] }, { "dataType": "enum", "enums": ["unprotected"] }, { "dataType": "enum", "enums": ["not-in-job"] }], "required": true }, "lastRuns": { "dataType": "array", "array": { "dataType": "refAlias", "ref": "Unbrand_VmDashboardRun_" }, "required": true } }, "required": true }, "alarms": { "dataType": "array", "array": { "dataType": "string" }, "required": true }, "quickInfo": { "dataType": "intersection", "subSchemas": [{ "ref": "Omit_Unbrand_VmDashboard-at-quickInfo_.creation_" }, { "dataType": "nestedObjectLiteral", "nestedProperties": { "creation": { "ref": "Unbrand_VmDashboard-at-quickInfo_91_creation_93__", "required": true } } }], "required": true } }, "validators": {} },
|
|
354
354
|
},
|
|
355
355
|
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
|
|
356
356
|
"Partial_Unbrand_XoVmTemplate__": {
|
package/dist/vms/vm.service.mjs
CHANGED
|
@@ -239,29 +239,32 @@ export class VmService {
|
|
|
239
239
|
status,
|
|
240
240
|
};
|
|
241
241
|
});
|
|
242
|
-
let
|
|
242
|
+
let vmProtection = 'not-in-job';
|
|
243
243
|
if (!vmContainsNoBakTag(vm)) {
|
|
244
244
|
const backupLogsByJob = groupBy(backupLogs, 'jobId');
|
|
245
245
|
for (const backupJob of relevantJobsWithSchedule) {
|
|
246
|
-
if (
|
|
246
|
+
if (vmProtection === 'protected') {
|
|
247
247
|
break;
|
|
248
248
|
}
|
|
249
|
+
vmProtection = 'unprotected';
|
|
249
250
|
// can be undefined if the backup did run for now
|
|
250
251
|
const jobLogs = backupLogsByJob[backupJob.id]
|
|
251
252
|
?.filter(log => log.status !== 'pending')
|
|
252
253
|
.slice(-3);
|
|
253
254
|
if (jobLogs !== undefined) {
|
|
254
|
-
|
|
255
|
+
vmProtection = jobLogs.every(log => {
|
|
255
256
|
if (log.status === 'success') {
|
|
256
257
|
return true;
|
|
257
258
|
}
|
|
258
259
|
const vmTaskLog = this.#backupLogService.getVmBackupTaskLog(log, id);
|
|
259
260
|
return vmTaskLog?.status === 'success';
|
|
260
|
-
})
|
|
261
|
+
})
|
|
262
|
+
? 'protected'
|
|
263
|
+
: 'unprotected';
|
|
261
264
|
}
|
|
262
265
|
}
|
|
263
266
|
}
|
|
264
|
-
return { lastRuns: lastBackupRuns,
|
|
267
|
+
return { lastRuns: lastBackupRuns, vmProtection };
|
|
265
268
|
}
|
|
266
269
|
async #getLastVmBackupArchives(id) {
|
|
267
270
|
const vm = this.#restApi.getObject(id, 'VM');
|
|
@@ -274,7 +277,7 @@ export class VmService {
|
|
|
274
277
|
.map(ba => ({ id: ba.id, timestamp: ba.timestamp, backupRepository: ba.backupRepository, size: ba.size }));
|
|
275
278
|
}
|
|
276
279
|
async getVmDashboard(id, { stream } = {}) {
|
|
277
|
-
const [quickInfo, alarms, lastReplication, { lastRuns,
|
|
280
|
+
const [quickInfo, alarms, lastReplication, { lastRuns, vmProtection }, lastBackupArchives] = await Promise.all([
|
|
278
281
|
promiseWriteInStream({ maybePromise: this.#getDashboardQuickInfo(id), path: 'quickInfo', stream }),
|
|
279
282
|
promiseWriteInStream({ maybePromise: Object.keys(this.getVmAlarms(id)), path: 'alarms', stream }),
|
|
280
283
|
promiseWriteInStream({ maybePromise: this.#getLastReplication(id), path: 'backupsInfo.replication', stream }),
|
|
@@ -290,7 +293,7 @@ export class VmService {
|
|
|
290
293
|
alarms: alarms,
|
|
291
294
|
backupsInfo: {
|
|
292
295
|
lastRuns,
|
|
293
|
-
|
|
296
|
+
vmProtection,
|
|
294
297
|
replication: lastReplication,
|
|
295
298
|
backupArchives: lastBackupArchives,
|
|
296
299
|
},
|
|
@@ -17,10 +17,13 @@ import { badRequestResp, unauthorizedResp } from '../open-api/common/response.co
|
|
|
17
17
|
import { xoaDashboard } from '../open-api/oa-examples/xoa.oa-example.mjs';
|
|
18
18
|
import { XoaService } from './xoa.service.mjs';
|
|
19
19
|
import { NDJSON_CONTENT_TYPE } from '../helpers/utils.helper.mjs';
|
|
20
|
+
import { RestApi } from '../rest-api/rest-api.mjs';
|
|
20
21
|
let XoaController = class XoaController extends Controller {
|
|
22
|
+
#restApi;
|
|
21
23
|
#xoaService;
|
|
22
|
-
constructor(xoaService) {
|
|
24
|
+
constructor(restApi, xoaService) {
|
|
23
25
|
super();
|
|
26
|
+
this.#restApi = restApi;
|
|
24
27
|
this.#xoaService = xoaService;
|
|
25
28
|
}
|
|
26
29
|
async getDashboard(req, ndjson) {
|
|
@@ -45,8 +48,12 @@ let XoaController = class XoaController extends Controller {
|
|
|
45
48
|
timestamp: Date.now(),
|
|
46
49
|
};
|
|
47
50
|
}
|
|
48
|
-
getGuiRoutes() {
|
|
49
|
-
|
|
51
|
+
async getGuiRoutes() {
|
|
52
|
+
const { xo5, xo6 } = await this.#restApi.xoApp.config.getGuiRoutes();
|
|
53
|
+
return {
|
|
54
|
+
xo5: xo5.url,
|
|
55
|
+
xo6: xo6.url,
|
|
56
|
+
};
|
|
50
57
|
}
|
|
51
58
|
};
|
|
52
59
|
__decorate([
|
|
@@ -72,6 +79,7 @@ XoaController = __decorate([
|
|
|
72
79
|
Security('*'),
|
|
73
80
|
Tags('xoa'),
|
|
74
81
|
provide(XoaController),
|
|
75
|
-
__param(0, inject(
|
|
82
|
+
__param(0, inject(RestApi)),
|
|
83
|
+
__param(1, inject(XoaService))
|
|
76
84
|
], XoaController);
|
|
77
85
|
export { XoaController };
|
package/dist/xoa/xoa.service.mjs
CHANGED
|
@@ -484,21 +484,4 @@ export class XoaService {
|
|
|
484
484
|
vmsStatus,
|
|
485
485
|
};
|
|
486
486
|
}
|
|
487
|
-
getGuiRoutes() {
|
|
488
|
-
const mounts = this.#restApi.xoApp.config.getOptional('http.mounts') ?? {};
|
|
489
|
-
let xo5Mount;
|
|
490
|
-
let xo6Mount;
|
|
491
|
-
for (const [key, value] of Object.entries(mounts)) {
|
|
492
|
-
if (value.includes('xo-web/dist')) {
|
|
493
|
-
xo5Mount = key;
|
|
494
|
-
}
|
|
495
|
-
else if (value.includes('@xen-orchestra/web/dist')) {
|
|
496
|
-
xo6Mount = key;
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
return {
|
|
500
|
-
xo5: xo5Mount,
|
|
501
|
-
xo6: xo6Mount,
|
|
502
|
-
};
|
|
503
|
-
}
|
|
504
487
|
}
|
|
@@ -2597,8 +2597,13 @@
|
|
|
2597
2597
|
"replication": {
|
|
2598
2598
|
"$ref": "#/components/schemas/Unbrand_VmDashboard-at-backupsInfo_91_replication_93__"
|
|
2599
2599
|
},
|
|
2600
|
-
"
|
|
2601
|
-
"type": "
|
|
2600
|
+
"vmProtection": {
|
|
2601
|
+
"type": "string",
|
|
2602
|
+
"enum": [
|
|
2603
|
+
"protected",
|
|
2604
|
+
"unprotected",
|
|
2605
|
+
"not-in-job"
|
|
2606
|
+
]
|
|
2602
2607
|
},
|
|
2603
2608
|
"lastRuns": {
|
|
2604
2609
|
"items": {
|
|
@@ -2609,7 +2614,7 @@
|
|
|
2609
2614
|
},
|
|
2610
2615
|
"required": [
|
|
2611
2616
|
"backupArchives",
|
|
2612
|
-
"
|
|
2617
|
+
"vmProtection",
|
|
2613
2618
|
"lastRuns"
|
|
2614
2619
|
],
|
|
2615
2620
|
"type": "object"
|
|
@@ -12004,7 +12009,7 @@
|
|
|
12004
12009
|
},
|
|
12005
12010
|
"info": {
|
|
12006
12011
|
"title": "@xen-orchestra/rest-api",
|
|
12007
|
-
"version": "0.21.
|
|
12012
|
+
"version": "0.21.2",
|
|
12008
12013
|
"description": "REST API to manage your XOA",
|
|
12009
12014
|
"license": {
|
|
12010
12015
|
"name": "AGPL-3.0-or-later"
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"main": "./dist/index.mjs",
|
|
7
7
|
"name": "@xen-orchestra/rest-api",
|
|
8
8
|
"homepage": "https://github.com/vatesfr/xen-orchestra/tree/master/@xen-orchestra/rest-api",
|
|
9
|
-
"version": "0.21.
|
|
9
|
+
"version": "0.21.2",
|
|
10
10
|
"description": "REST API to manage your XOA",
|
|
11
11
|
"license": "AGPL-3.0-or-later",
|
|
12
12
|
"private": false,
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@vates/async-each": "^1.0.1",
|
|
37
37
|
"@vates/task": "^0.6.1",
|
|
38
38
|
"@vates/types": "^1.15.0",
|
|
39
|
-
"@xen-orchestra/backups": "^0.67.
|
|
39
|
+
"@xen-orchestra/backups": "^0.67.1",
|
|
40
40
|
"@xen-orchestra/log": "^0.7.1",
|
|
41
41
|
"@xen-orchestra/xapi": "^8.6.1",
|
|
42
42
|
"complex-matcher": "^1.0.0",
|