@xen-orchestra/rest-api 0.11.0 → 0.13.0
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/abstract-classes/base-controller.mjs +2 -2
- package/dist/alarms/alarm.controller.mjs +10 -60
- package/dist/alarms/alarm.service.mjs +67 -0
- package/dist/backup-repositories/backup-repositories.controller.mjs +61 -0
- package/dist/groups/group.controller.mjs +95 -3
- package/dist/groups/group.type.mjs +1 -0
- package/dist/helpers/object-wrapper.helper.mjs +8 -1
- package/dist/helpers/utils.helper.mjs +74 -1
- package/dist/hosts/host.controller.mjs +57 -2
- package/dist/hosts/host.service.mjs +78 -0
- package/dist/ioc/ioc.mjs +25 -1
- package/dist/messages/message.controller.mjs +1 -1
- package/dist/middlewares/generic-error-handler.middleware.mjs +4 -3
- package/dist/networks/network.controller.mjs +34 -2
- package/dist/open-api/common/response.common.mjs +4 -0
- package/dist/open-api/oa-examples/alarm.oa-example.mjs +12 -0
- package/dist/open-api/oa-examples/backup-repository.oa-example.mjs +31 -0
- package/dist/open-api/oa-examples/group.oa-example.mjs +3 -0
- package/dist/open-api/oa-examples/pool.oa-example.mjs +201 -0
- package/dist/open-api/oa-examples/user.oa-example.mjs +1 -0
- package/dist/open-api/routes/routes.js +943 -116
- package/dist/pifs/pif.controller.mjs +34 -2
- package/dist/pools/pool.controller.mjs +70 -3
- package/dist/pools/pool.service.mjs +212 -0
- package/dist/rest-api/rest-api.mjs +6 -1
- package/dist/srs/sr.controller.mjs +34 -2
- package/dist/users/user.controller.mjs +74 -3
- package/dist/users/user.type.mjs +1 -0
- package/dist/vbds/vbd.controller.mjs +34 -2
- package/dist/vdi-snapshots/vdi-snapshot.controller.mjs +34 -2
- package/dist/vdis/vdi.controller.mjs +34 -2
- package/dist/vifs/vif.controller.mjs +34 -2
- package/dist/vm-controller/vm-controller.controller.mjs +34 -2
- package/dist/vm-snapshots/vm-snapshot.controller.mjs +34 -2
- package/dist/vm-templates/vm-template.controller.mjs +34 -2
- package/dist/vms/vm.controller.mjs +34 -2
- package/dist/vms/vm.service.mjs +40 -0
- package/dist/xoa/xoa.service.mjs +96 -110
- package/open-api/spec/swagger.json +4302 -1417
- package/package.json +3 -3
|
@@ -12,7 +12,7 @@ import { Example, Get, Path, Query, Request, Response, Route, Security, Tags } f
|
|
|
12
12
|
import { inject } from 'inversify';
|
|
13
13
|
import { noSuchObject } from 'xo-common/api-errors.js';
|
|
14
14
|
import { provide } from 'inversify-binding-decorators';
|
|
15
|
-
import { alarmPredicate } from '../alarms/alarm.
|
|
15
|
+
import { alarmPredicate } from '../alarms/alarm.service.mjs';
|
|
16
16
|
import { message, messageIds, partialMessages } from '../open-api/oa-examples/message.oa-example.mjs';
|
|
17
17
|
import { RestApi } from '../rest-api/rest-api.mjs';
|
|
18
18
|
import { notFoundResp, unauthorizedResp } from '../open-api/common/response.common.mjs';
|
|
@@ -9,7 +9,10 @@ export default function genericErrorHandler(error, req, res, _next) {
|
|
|
9
9
|
res.status(500).json({ error });
|
|
10
10
|
return;
|
|
11
11
|
}
|
|
12
|
-
const responseError = {
|
|
12
|
+
const responseError = {
|
|
13
|
+
error: error.message,
|
|
14
|
+
data: 'data' in error ? error.data : undefined,
|
|
15
|
+
};
|
|
13
16
|
let statusCode;
|
|
14
17
|
if (noSuchObject.is(error)) {
|
|
15
18
|
statusCode = 404;
|
|
@@ -19,7 +22,6 @@ export default function genericErrorHandler(error, req, res, _next) {
|
|
|
19
22
|
}
|
|
20
23
|
else if (featureUnauthorized.is(error)) {
|
|
21
24
|
statusCode = 403;
|
|
22
|
-
responseError.data = error.data;
|
|
23
25
|
}
|
|
24
26
|
else if (invalidCredentials.is(error)) {
|
|
25
27
|
statusCode = 401;
|
|
@@ -35,7 +37,6 @@ export default function genericErrorHandler(error, req, res, _next) {
|
|
|
35
37
|
}
|
|
36
38
|
else if (incorrectState.is(error)) {
|
|
37
39
|
statusCode = 409;
|
|
38
|
-
responseError.data = error.data;
|
|
39
40
|
}
|
|
40
41
|
else {
|
|
41
42
|
if (error.name === 'XapiError') {
|
|
@@ -10,13 +10,18 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
10
10
|
import { Example, Get, Path, Query, Response, Request, Route, Security, Tags, Delete, SuccessResponse } from 'tsoa';
|
|
11
11
|
import { inject } from 'inversify';
|
|
12
12
|
import { provide } from 'inversify-binding-decorators';
|
|
13
|
+
import { AlarmService } from '../alarms/alarm.service.mjs';
|
|
14
|
+
import { escapeUnsafeComplexMatcher } from '../helpers/utils.helper.mjs';
|
|
15
|
+
import { genericAlarmsExample } from '../open-api/oa-examples/alarm.oa-example.mjs';
|
|
13
16
|
import { network, networkIds, partialNetworks } from '../open-api/oa-examples/network.oa-example.mjs';
|
|
14
17
|
import { noContentResp, notFoundResp, unauthorizedResp } from '../open-api/common/response.common.mjs';
|
|
15
18
|
import { RestApi } from '../rest-api/rest-api.mjs';
|
|
16
19
|
import { XapiXoController } from '../abstract-classes/xapi-xo-controller.mjs';
|
|
17
20
|
let NetworkController = class NetworkController extends XapiXoController {
|
|
18
|
-
|
|
21
|
+
#alarmService;
|
|
22
|
+
constructor(restApi, alarmService) {
|
|
19
23
|
super('network', restApi);
|
|
24
|
+
this.#alarmService = alarmService;
|
|
20
25
|
}
|
|
21
26
|
/**
|
|
22
27
|
* @example fields "nbd,name_label,id"
|
|
@@ -39,6 +44,20 @@ let NetworkController = class NetworkController extends XapiXoController {
|
|
|
39
44
|
const networkId = id;
|
|
40
45
|
await this.getXapiObject(networkId).$xapi.deleteNetwork(networkId);
|
|
41
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* @example id "9fe12ca3-d75d-cfb0-492e-cfd2bc6c568f"
|
|
49
|
+
* @example fields "id,time"
|
|
50
|
+
* @example filter "time:>1747053793"
|
|
51
|
+
* @example limit 42
|
|
52
|
+
*/
|
|
53
|
+
getNetworkAlarms(req, id, fields, ndjson, filter, limit) {
|
|
54
|
+
const network = this.getObject(id);
|
|
55
|
+
const alarms = this.#alarmService.getAlarms({
|
|
56
|
+
filter: `${escapeUnsafeComplexMatcher(filter) ?? ''} object:uuid:${network.uuid}`,
|
|
57
|
+
limit,
|
|
58
|
+
});
|
|
59
|
+
return this.sendObjects(Object.values(alarms), req, 'alarms');
|
|
60
|
+
}
|
|
42
61
|
};
|
|
43
62
|
__decorate([
|
|
44
63
|
Example(networkIds),
|
|
@@ -62,12 +81,25 @@ __decorate([
|
|
|
62
81
|
Response(notFoundResp.status, notFoundResp.description),
|
|
63
82
|
__param(0, Path())
|
|
64
83
|
], NetworkController.prototype, "deleteNetwork", null);
|
|
84
|
+
__decorate([
|
|
85
|
+
Example(genericAlarmsExample),
|
|
86
|
+
Get('{id}/alarms'),
|
|
87
|
+
Tags('alarms'),
|
|
88
|
+
Response(notFoundResp.status, notFoundResp.description),
|
|
89
|
+
__param(0, Request()),
|
|
90
|
+
__param(1, Path()),
|
|
91
|
+
__param(2, Query()),
|
|
92
|
+
__param(3, Query()),
|
|
93
|
+
__param(4, Query()),
|
|
94
|
+
__param(5, Query())
|
|
95
|
+
], NetworkController.prototype, "getNetworkAlarms", null);
|
|
65
96
|
NetworkController = __decorate([
|
|
66
97
|
Route('networks'),
|
|
67
98
|
Security('*'),
|
|
68
99
|
Response(unauthorizedResp.status, unauthorizedResp.description),
|
|
69
100
|
Tags('networks'),
|
|
70
101
|
provide(NetworkController),
|
|
71
|
-
__param(0, inject(RestApi))
|
|
102
|
+
__param(0, inject(RestApi)),
|
|
103
|
+
__param(1, inject(AlarmService))
|
|
72
104
|
], NetworkController);
|
|
73
105
|
export { NetworkController };
|
|
@@ -47,3 +47,15 @@ export const alarm = {
|
|
|
47
47
|
uuid: '3f607494-26f1-b328-b626-d81cf007de37',
|
|
48
48
|
},
|
|
49
49
|
};
|
|
50
|
+
export const genericAlarmsExample = [
|
|
51
|
+
{
|
|
52
|
+
id: '7e87b95e-8ebb-31c5-30ad-ff2eb079604b',
|
|
53
|
+
time: 1747053794,
|
|
54
|
+
href: '/rest/v0/alarms/7e87b95e-8ebb-31c5-30ad-ff2eb079604b',
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
id: '7e87b95e-8ebb-31c5-30ad-ff2eb079604c',
|
|
58
|
+
time: 1747053795,
|
|
59
|
+
href: '/rest/v0/alarms/7e87b95e-8ebb-31c5-30ad-ff2eb079604c',
|
|
60
|
+
},
|
|
61
|
+
];
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export const backupRepositoryIds = [
|
|
2
|
+
'/rest/v0/backup-repositories/7497c970-6780-4462-a452-fcb8a406ee64',
|
|
3
|
+
'/rest/v0/backup-repositories/f681cef1-617e-4650-ac31-ffdaead076bf',
|
|
4
|
+
];
|
|
5
|
+
export const partialBackupRepositories = [
|
|
6
|
+
{
|
|
7
|
+
id: '7497c970-6780-4462-a452-fcb8a406ee64',
|
|
8
|
+
name: 'test',
|
|
9
|
+
enabled: true,
|
|
10
|
+
href: '/rest/v0/backup-repositories/7497c970-6780-4462-a452-fcb8a406ee64',
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
id: 'f681cef1-617e-4650-ac31-ffdaead076bf',
|
|
14
|
+
name: 'S3_Remote',
|
|
15
|
+
enabled: true,
|
|
16
|
+
href: '/rest/v0/backup-repositories/f681cef1-617e-4650-ac31-ffdaead076bf',
|
|
17
|
+
},
|
|
18
|
+
];
|
|
19
|
+
export const backupRepository = {
|
|
20
|
+
enabled: true,
|
|
21
|
+
name: 'S3_Remote',
|
|
22
|
+
benchmarks: [
|
|
23
|
+
{
|
|
24
|
+
readRate: 7999965.197905305,
|
|
25
|
+
timestamp: 1751469269245,
|
|
26
|
+
writeRate: 7767798.704316632,
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
id: '677e50c5-8d8a-4c89-b1ac-e2f4593d0ebb',
|
|
30
|
+
url: 's3://FOIS5DY532RGXD62TJ52:obfuscated-q3oi6d9X8uenGvdLnHk2@s3.us-east-2.amazonaws.com/with-lock/backup?useVhdDirectory=true',
|
|
31
|
+
};
|
|
@@ -272,3 +272,204 @@ export const poolStats = {
|
|
|
272
272
|
},
|
|
273
273
|
},
|
|
274
274
|
};
|
|
275
|
+
export const poolDashboard = {
|
|
276
|
+
hosts: {
|
|
277
|
+
status: {
|
|
278
|
+
running: 3,
|
|
279
|
+
disabled: 0,
|
|
280
|
+
halted: 0,
|
|
281
|
+
total: 3,
|
|
282
|
+
},
|
|
283
|
+
topFiveUsage: {
|
|
284
|
+
ram: [
|
|
285
|
+
{
|
|
286
|
+
name_label: 'XCP XO 8.3.0 master',
|
|
287
|
+
id: 'b61a5c92-700e-4966-a13b-00633f03eea8',
|
|
288
|
+
size: 34359738368,
|
|
289
|
+
usage: 6254059520,
|
|
290
|
+
percent: 18.201708793640137,
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
name_label: 'XCP XO 8.3.0 slave',
|
|
294
|
+
id: '84e555d8-267a-4720-aa5f-fd19035aadae',
|
|
295
|
+
size: 34359738368,
|
|
296
|
+
usage: 3544117248,
|
|
297
|
+
percent: 10.314738750457764,
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
name_label: 'XCP XO 8.3.0 slave 2',
|
|
301
|
+
id: '669df518-4e5d-4d84-b93a-9be2cdcdfca1',
|
|
302
|
+
size: 34359738368,
|
|
303
|
+
usage: 3544117248,
|
|
304
|
+
percent: 10.314738750457764,
|
|
305
|
+
},
|
|
306
|
+
],
|
|
307
|
+
cpu: [
|
|
308
|
+
{
|
|
309
|
+
percent: 6.471593483001921,
|
|
310
|
+
id: 'b61a5c92-700e-4966-a13b-00633f03eea8',
|
|
311
|
+
name_label: 'XCP XO 8.3.0 master',
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
percent: 2.340522127838084,
|
|
315
|
+
id: '84e555d8-267a-4720-aa5f-fd19035aadae',
|
|
316
|
+
name_label: 'XCP XO 8.3.0 slave',
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
percent: 1.5935676943627188,
|
|
320
|
+
id: '669df518-4e5d-4d84-b93a-9be2cdcdfca1',
|
|
321
|
+
name_label: 'XCP XO 8.3.0 slave 2',
|
|
322
|
+
},
|
|
323
|
+
],
|
|
324
|
+
},
|
|
325
|
+
missingPatches: {
|
|
326
|
+
hasAuthorization: true,
|
|
327
|
+
missingPatches: [
|
|
328
|
+
{
|
|
329
|
+
url: 'http://www.xen.org',
|
|
330
|
+
version: '25.6.0',
|
|
331
|
+
name: 'xenopsd-xc',
|
|
332
|
+
license: 'LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception',
|
|
333
|
+
changelog: {
|
|
334
|
+
date: 1750852800,
|
|
335
|
+
description: '- Fix remote syslog configuration being broken on updates',
|
|
336
|
+
author: 'Andrii Sultanov <andriy.sultanov@vates.tech> - 25.6.0-1.9',
|
|
337
|
+
},
|
|
338
|
+
release: '1.9.xcpng8.3',
|
|
339
|
+
size: 5421696,
|
|
340
|
+
description: 'Xenopsd using xc',
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
url: 'http://www.xen.org',
|
|
344
|
+
version: '25.6.0',
|
|
345
|
+
name: 'forkexecd',
|
|
346
|
+
license: 'LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception',
|
|
347
|
+
changelog: {
|
|
348
|
+
date: 1750852800,
|
|
349
|
+
description: '- Fix remote syslog configuration being broken on updates',
|
|
350
|
+
author: 'Andrii Sultanov <andriy.sultanov@vates.tech> - 25.6.0-1.9',
|
|
351
|
+
},
|
|
352
|
+
release: '1.9.xcpng8.3',
|
|
353
|
+
size: 2498124,
|
|
354
|
+
description: 'A subprocess management service',
|
|
355
|
+
},
|
|
356
|
+
],
|
|
357
|
+
},
|
|
358
|
+
},
|
|
359
|
+
vms: {
|
|
360
|
+
status: {
|
|
361
|
+
running: 2,
|
|
362
|
+
halted: 38,
|
|
363
|
+
paused: 0,
|
|
364
|
+
total: 40,
|
|
365
|
+
suspended: 0,
|
|
366
|
+
},
|
|
367
|
+
topFiveUsage: {
|
|
368
|
+
ram: [
|
|
369
|
+
{
|
|
370
|
+
id: 'db822c15-6f7d-8920-10bd-68d40fb12ac6',
|
|
371
|
+
name_label: 'MRA alpine',
|
|
372
|
+
memory: 536858624,
|
|
373
|
+
memoryFree: 423256064,
|
|
374
|
+
percent: 21.160610060349892,
|
|
375
|
+
},
|
|
376
|
+
{
|
|
377
|
+
id: 'fe10b378-db7b-d2a4-eef6-0f1cde75d409',
|
|
378
|
+
name_label: 'pbt_test',
|
|
379
|
+
memory: 2147471360,
|
|
380
|
+
memoryFree: 1813676032,
|
|
381
|
+
percent: 15.54364515482991,
|
|
382
|
+
},
|
|
383
|
+
],
|
|
384
|
+
cpu: [
|
|
385
|
+
{
|
|
386
|
+
id: 'db822c15-6f7d-8920-10bd-68d40fb12ac6',
|
|
387
|
+
name_label: 'MRA alpine',
|
|
388
|
+
percent: 1.04830558411777,
|
|
389
|
+
},
|
|
390
|
+
{
|
|
391
|
+
id: 'fe10b378-db7b-d2a4-eef6-0f1cde75d409',
|
|
392
|
+
name_label: 'pbt_test',
|
|
393
|
+
percent: 0.3743608540389682,
|
|
394
|
+
},
|
|
395
|
+
],
|
|
396
|
+
},
|
|
397
|
+
},
|
|
398
|
+
srs: {
|
|
399
|
+
topFiveUsage: [
|
|
400
|
+
{
|
|
401
|
+
name_label: 'Local storage',
|
|
402
|
+
id: '4cb0d74e-a7c1-0b7d-46e3-09382c012abb',
|
|
403
|
+
percent: 45.51916716586373,
|
|
404
|
+
physical_usage: 33539653632,
|
|
405
|
+
size: 73682485248,
|
|
406
|
+
},
|
|
407
|
+
{
|
|
408
|
+
name_label: 'Local storage',
|
|
409
|
+
id: 'c4284e12-37c9-7967-b9e8-83ef229c3e03',
|
|
410
|
+
percent: 23.527768920458005,
|
|
411
|
+
physical_usage: 17335844864,
|
|
412
|
+
size: 73682485248,
|
|
413
|
+
},
|
|
414
|
+
{
|
|
415
|
+
name_label: 'XOSTOR NVME',
|
|
416
|
+
id: 'c787b75c-3e0d-70fa-d0c3-cbfd382d7e33',
|
|
417
|
+
percent: 18.56945625131877,
|
|
418
|
+
physical_usage: 95048891392,
|
|
419
|
+
size: 511856082944,
|
|
420
|
+
},
|
|
421
|
+
{
|
|
422
|
+
name_label: 'Local storage',
|
|
423
|
+
id: '8aa2fb4a-143e-c2bc-05d4-c68bbb101d41',
|
|
424
|
+
percent: 16.016159531372924,
|
|
425
|
+
physical_usage: 11801104384,
|
|
426
|
+
size: 73682485248,
|
|
427
|
+
},
|
|
428
|
+
],
|
|
429
|
+
},
|
|
430
|
+
alarms: [
|
|
431
|
+
{
|
|
432
|
+
name: 'ALARM',
|
|
433
|
+
time: 1749572297,
|
|
434
|
+
id: '71ef8836-56e4-97ca-02d1-e118ee1aad98',
|
|
435
|
+
type: 'message',
|
|
436
|
+
uuid: '71ef8836-56e4-97ca-02d1-e118ee1aad98',
|
|
437
|
+
$pool: 'b7569d99-30f8-178a-7d94-801de3e29b5b',
|
|
438
|
+
$poolId: 'b7569d99-30f8-178a-7d94-801de3e29b5b',
|
|
439
|
+
_xapiRef: 'OpaqueRef:fed2a9e5-6c72-dada-6f27-7475583ff3e7',
|
|
440
|
+
body: {
|
|
441
|
+
value: '1.054742',
|
|
442
|
+
name: 'mem_usage',
|
|
443
|
+
},
|
|
444
|
+
object: {
|
|
445
|
+
type: 'VM-controller',
|
|
446
|
+
uuid: '9b4775bd-9493-490a-9afa-f786a44caa4f',
|
|
447
|
+
href: '/rest/v0/vm-controllers/9b4775bd-9493-490a-9afa-f786a44caa4f',
|
|
448
|
+
},
|
|
449
|
+
},
|
|
450
|
+
{
|
|
451
|
+
name: 'ALARM',
|
|
452
|
+
time: 1748688413,
|
|
453
|
+
id: 'ef9008da-e244-9875-4b83-12de733c8aa9',
|
|
454
|
+
type: 'message',
|
|
455
|
+
uuid: 'ef9008da-e244-9875-4b83-12de733c8aa9',
|
|
456
|
+
$pool: 'b7569d99-30f8-178a-7d94-801de3e29b5b',
|
|
457
|
+
$poolId: 'b7569d99-30f8-178a-7d94-801de3e29b5b',
|
|
458
|
+
_xapiRef: 'OpaqueRef:d03c24dc-037d-ac8b-80ea-c5a1106cd678',
|
|
459
|
+
body: {
|
|
460
|
+
value: '0.962104',
|
|
461
|
+
name: 'mem_usage',
|
|
462
|
+
},
|
|
463
|
+
object: {
|
|
464
|
+
type: 'VM-controller',
|
|
465
|
+
uuid: '9b4775bd-9493-490a-9afa-f786a44caa4f',
|
|
466
|
+
href: '/rest/v0/vm-controllers/9b4775bd-9493-490a-9afa-f786a44caa4f',
|
|
467
|
+
},
|
|
468
|
+
},
|
|
469
|
+
],
|
|
470
|
+
cpuProvisioning: {
|
|
471
|
+
total: 48,
|
|
472
|
+
assigned: 4,
|
|
473
|
+
percent: 8.333333333333334,
|
|
474
|
+
},
|
|
475
|
+
};
|