@xen-orchestra/rest-api 0.24.1 → 0.26.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.
@@ -9,8 +9,10 @@ import { NDJSON_CONTENT_TYPE, safeParseComplexMatcher } from '../helpers/utils.h
9
9
  const noop = () => { };
10
10
  export class BaseController extends Controller {
11
11
  restApi;
12
- constructor(restApi) {
12
+ type;
13
+ constructor(type, restApi) {
13
14
  super();
15
+ this.type = type;
14
16
  this.restApi = restApi;
15
17
  }
16
18
  sendObjects(objects, req, path) {
@@ -51,6 +53,7 @@ export class BaseController extends Controller {
51
53
  async createAction(cb, { statusCode = 200, sync = false, taskProperties, }) {
52
54
  taskProperties.name = 'REST API: ' + taskProperties.name;
53
55
  taskProperties.type = 'xo:rest-api:action';
56
+ taskProperties.objectType = this.type;
54
57
  const task = this.restApi.tasks.create(taskProperties);
55
58
  const pResult = task.run(() => cb(task));
56
59
  if (sync) {
@@ -2,19 +2,17 @@ import { BaseController } from './base-controller.mjs';
2
2
  import { escapeUnsafeComplexMatcher } from '../helpers/utils.helper.mjs';
3
3
  import { RAW_ALARM_FILTER } from '../alarms/alarm.service.mjs';
4
4
  export class XapiXoController extends BaseController {
5
- #type;
6
5
  constructor(type, restApi) {
7
- super(restApi);
8
- this.#type = type;
6
+ super(type, restApi);
9
7
  }
10
8
  getObjects(opts) {
11
- return this.restApi.getObjectsByType(this.#type, opts);
9
+ return this.restApi.getObjectsByType(this.type, opts);
12
10
  }
13
11
  getObject(id) {
14
- return this.restApi.getObject(id, this.#type);
12
+ return this.restApi.getObject(id, this.type);
15
13
  }
16
14
  getXapiObject(maybeId) {
17
- return this.restApi.getXapiObject(maybeId, this.#type);
15
+ return this.restApi.getXapiObject(maybeId, this.type);
18
16
  }
19
17
  getMessagesForObject(id, { filter, limit } = {}) {
20
18
  const object = this.getObject(id);
@@ -1,19 +1,8 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- var __param = (this && this.__param) || function (paramIndex, decorator) {
8
- return function (target, key) { decorator(target, key, paramIndex); }
9
- };
10
- import { inject } from 'inversify';
11
1
  import { BaseController } from './base-controller.mjs';
12
- import { RestApi } from '../rest-api/rest-api.mjs';
13
2
  import { limitAndFilterArray } from '../helpers/utils.helper.mjs';
14
- let XoController = class XoController extends BaseController {
15
- constructor(restApi) {
16
- super(restApi);
3
+ export class XoController extends BaseController {
4
+ constructor(type, restApi) {
5
+ super(type, restApi);
17
6
  }
18
7
  async getObjects(opts = {}) {
19
8
  let objects = await this.getAllCollectionObjects(opts);
@@ -27,8 +16,4 @@ let XoController = class XoController extends BaseController {
27
16
  async getObject(id) {
28
17
  return this.getCollectionObject(id);
29
18
  }
30
- };
31
- XoController = __decorate([
32
- __param(0, inject(RestApi))
33
- ], XoController);
34
- export { XoController };
19
+ }
@@ -8,14 +8,19 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
8
8
  return function (target, key) { decorator(target, key, paramIndex); }
9
9
  };
10
10
  import { Example, Get, Path, Query, Request, Response, Route, Security, Tags } from 'tsoa';
11
+ import { inject } from 'inversify';
11
12
  import { noSuchObject } from 'xo-common/api-errors.js';
12
13
  import { provide } from 'inversify-binding-decorators';
13
14
  import { badRequestResp, notFoundResp, unauthorizedResp } from '../open-api/common/response.common.mjs';
14
15
  import { XoController } from '../abstract-classes/xo-controller.mjs';
16
+ import { RestApi } from '../rest-api/rest-api.mjs';
15
17
  import { backupArchive, backupArchiveIds, partialBackupArchives, } from '../open-api/oa-examples/backup-archive.oa-example.mjs';
16
18
  // BR uuid/xo-vm-backups/VM uuid/(ISO 8601 compact).json
17
19
  const BACKUP_ARCHIVE_ID_REGEX = /^([0-9a-fA-F-]{36})\/+xo-vm-backups\/+([0-9a-fA-F-]{36})\/+(\d{8}T\d{6}Z)\.json$/;
18
20
  let BackupArchiveController = class BackupArchiveController extends XoController {
21
+ constructor(restApi) {
22
+ super('backup-archive', restApi);
23
+ }
19
24
  async getAllCollectionObjects({ backupRepositories = [], } = {}) {
20
25
  const backupRepositoryIds = [];
21
26
  if (backupRepositories.includes('*')) {
@@ -92,6 +97,7 @@ BackupArchiveController = __decorate([
92
97
  Response(badRequestResp.status, badRequestResp.description),
93
98
  Response(unauthorizedResp.status, unauthorizedResp.description),
94
99
  Tags('backup-archives'),
95
- provide(BackupArchiveController)
100
+ provide(BackupArchiveController),
101
+ __param(0, inject(RestApi))
96
102
  ], BackupArchiveController);
97
103
  export { BackupArchiveController };
@@ -25,7 +25,7 @@ const log = createLogger('xo:rest-api:backupJob-controller');
25
25
  let BackupJobController = class BackupJobController extends XoController {
26
26
  #backupJobService;
27
27
  constructor(restApi, backupJobService) {
28
- super(restApi);
28
+ super('backup-job', restApi);
29
29
  this.#backupJobService = backupJobService;
30
30
  }
31
31
  async getAllCollectionObjects() {
@@ -89,7 +89,7 @@ let DeprecatedBackupController = class DeprecatedBackupController extends XoCont
89
89
  #backupLogService;
90
90
  #backupJobService;
91
91
  constructor(restApi, backupLogService, backupJobService) {
92
- super(restApi);
92
+ super('backup', restApi);
93
93
  this.#backupLogService = backupLogService;
94
94
  this.#backupJobService = backupJobService;
95
95
  }
@@ -19,7 +19,7 @@ import { XoController } from '../abstract-classes/xo-controller.mjs';
19
19
  let BackupLogController = class BackupLogController extends XoController {
20
20
  #backupLogService;
21
21
  constructor(restApi, backupLogService) {
22
- super(restApi);
22
+ super('backup-log', restApi);
23
23
  this.#backupLogService = backupLogService;
24
24
  }
25
25
  getAllCollectionObjects() {
@@ -8,11 +8,16 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
8
8
  return function (target, key) { decorator(target, key, paramIndex); }
9
9
  };
10
10
  import { Example, Get, Path, Query, Request, Response, Route, Security, Tags } from 'tsoa';
11
+ import { inject } from 'inversify';
11
12
  import { provide } from 'inversify-binding-decorators';
12
13
  import { badRequestResp, notFoundResp, unauthorizedResp } from '../open-api/common/response.common.mjs';
13
14
  import { backupRepositoryIds, partialBackupRepositories, backupRepository, } from '../open-api/oa-examples/backup-repository.oa-example.mjs';
14
15
  import { XoController } from '../abstract-classes/xo-controller.mjs';
16
+ import { RestApi } from '../rest-api/rest-api.mjs';
15
17
  let BackupRepositoryController = class BackupRepositoryController extends XoController {
18
+ constructor(restApi) {
19
+ super('backup-repository', restApi);
20
+ }
16
21
  // --- abstract methods
17
22
  getAllCollectionObjects() {
18
23
  return this.restApi.xoApp.getAllRemotes();
@@ -57,6 +62,7 @@ BackupRepositoryController = __decorate([
57
62
  Response(badRequestResp.status, badRequestResp.description),
58
63
  Response(unauthorizedResp.status, unauthorizedResp.description),
59
64
  Tags('backup-repositories'),
60
- provide(BackupRepositoryController)
65
+ provide(BackupRepositoryController),
66
+ __param(0, inject(RestApi))
61
67
  ], BackupRepositoryController);
62
68
  export { BackupRepositoryController };
@@ -23,7 +23,7 @@ import { partialTasks, taskIds } from '../open-api/oa-examples/task.oa-example.m
23
23
  let GroupController = class GroupController extends XoController {
24
24
  #userService;
25
25
  constructor(restApi, userService) {
26
- super(restApi);
26
+ super('group', restApi);
27
27
  this.#userService = userService;
28
28
  }
29
29
  // --- abstract methods
package/dist/index.mjs CHANGED
@@ -5,6 +5,7 @@ import tsoaToXoErrorHandler from './middlewares/tsoa-to-xo-error.middleware.mjs'
5
5
  import { RegisterRoutes } from './open-api/routes/routes.js';
6
6
  import { setupContainer } from './ioc/ioc.mjs';
7
7
  import { setupApiContext } from './middlewares/authentication.middleware.mjs';
8
+ import { logMiddleware } from './middlewares/log.middleware.mjs';
8
9
  // Avoid using "import from" to import a json file as this requires assert/with and will break compatibility with recent node versions
9
10
  // https://github.com/nodejs/node/issues/51622
10
11
  const require = createRequire(import.meta.url);
@@ -34,6 +35,7 @@ const SWAGGER_UI_OPTIONS = {
34
35
  export default function setupRestApi(express, xoApp) {
35
36
  setupContainer(xoApp);
36
37
  express.use(BASE_URL, setupApiContext(xoApp));
38
+ express.use(BASE_URL, logMiddleware);
37
39
  RegisterRoutes(express);
38
40
  express.get(`${BASE_URL}/docs/swagger.json`, (_req, res) => {
39
41
  res.setHeader('Content-Type', 'application/json');
@@ -0,0 +1,12 @@
1
+ import { createLogger } from '@xen-orchestra/log';
2
+ const log = createLogger('xo:rest-api');
3
+ export function logMiddleware(req, res, next) {
4
+ const start = Date.now();
5
+ res.on('finish', () => {
6
+ const duration = Date.now() - start;
7
+ const { method, originalUrl } = req;
8
+ const { statusCode } = res;
9
+ log.debug(`[${new Date().toISOString()}] ${method} ${originalUrl} ${statusCode} ${duration}ms`);
10
+ });
11
+ next();
12
+ }
@@ -335,12 +335,12 @@ const models = {
335
335
  // 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
336
336
  "XoTask": {
337
337
  "dataType": "refAlias",
338
- "type": { "dataType": "nestedObjectLiteral", "nestedProperties": { "warnings": { "dataType": "array", "array": { "dataType": "nestedObjectLiteral", "nestedProperties": { "message": { "dataType": "string", "required": true }, "data": { "dataType": "any", "required": true } } } }, "updatedAt": { "dataType": "double" }, "tasks": { "dataType": "array", "array": { "dataType": "refAlias", "ref": "XoTask" } }, "status": { "dataType": "union", "subSchemas": [{ "dataType": "enum", "enums": ["failure"] }, { "dataType": "enum", "enums": ["interrupted"] }, { "dataType": "enum", "enums": ["pending"] }, { "dataType": "enum", "enums": ["success"] }], "required": true }, "start": { "dataType": "double", "required": true }, "result": { "ref": "Record_string.unknown_", "required": true }, "properties": { "dataType": "nestedObjectLiteral", "nestedProperties": { "userId": { "dataType": "string" }, "type": { "dataType": "string" }, "progress": { "dataType": "double" }, "params": { "ref": "Record_string.unknown_" }, "objectId": { "dataType": "string" }, "name": { "dataType": "string" }, "method": { "dataType": "string" } }, "additionalProperties": { "dataType": "union", "subSchemas": [{ "dataType": "any" }, { "dataType": "undefined" }] }, "required": true }, "progress": { "dataType": "double" }, "infos": { "dataType": "array", "array": { "dataType": "nestedObjectLiteral", "nestedProperties": { "message": { "dataType": "string", "required": true }, "data": { "dataType": "any", "required": true } } } }, "id": { "ref": "Branded_task_", "required": true }, "end": { "dataType": "double" }, "data": { "ref": "Record_string.string_" }, "abortionRequestedAt": { "dataType": "double" } }, "validators": {} },
338
+ "type": { "dataType": "nestedObjectLiteral", "nestedProperties": { "warnings": { "dataType": "array", "array": { "dataType": "nestedObjectLiteral", "nestedProperties": { "message": { "dataType": "string", "required": true }, "data": { "dataType": "any", "required": true } } } }, "updatedAt": { "dataType": "double" }, "tasks": { "dataType": "array", "array": { "dataType": "refAlias", "ref": "XoTask" } }, "status": { "dataType": "union", "subSchemas": [{ "dataType": "enum", "enums": ["failure"] }, { "dataType": "enum", "enums": ["interrupted"] }, { "dataType": "enum", "enums": ["pending"] }, { "dataType": "enum", "enums": ["success"] }], "required": true }, "start": { "dataType": "double", "required": true }, "result": { "ref": "Record_string.unknown_", "required": true }, "properties": { "dataType": "nestedObjectLiteral", "nestedProperties": { "userId": { "dataType": "string" }, "type": { "dataType": "string" }, "progress": { "dataType": "double" }, "params": { "ref": "Record_string.unknown_" }, "objectType": { "dataType": "union", "subSchemas": [{ "dataType": "union", "subSchemas": [{ "dataType": "enum", "enums": ["pool"] }, { "dataType": "enum", "enums": ["VBD"] }, { "dataType": "enum", "enums": ["host"] }, { "dataType": "enum", "enums": ["VIF"] }, { "dataType": "enum", "enums": ["VTPM"] }, { "dataType": "enum", "enums": ["VM"] }, { "dataType": "enum", "enums": ["VM-snapshot"] }, { "dataType": "enum", "enums": ["SR"] }, { "dataType": "enum", "enums": ["message"] }, { "dataType": "enum", "enums": ["vgpu"] }, { "dataType": "enum", "enums": ["gpuGroup"] }, { "dataType": "enum", "enums": ["network"] }, { "dataType": "enum", "enums": ["PBD"] }, { "dataType": "enum", "enums": ["PCI"] }, { "dataType": "enum", "enums": ["PGPU"] }, { "dataType": "enum", "enums": ["PIF"] }, { "dataType": "enum", "enums": ["VDI"] }, { "dataType": "enum", "enums": ["VDI-snapshot"] }, { "dataType": "enum", "enums": ["VDI-unmanaged"] }, { "dataType": "enum", "enums": ["vgpuType"] }, { "dataType": "enum", "enums": ["VM-controller"] }, { "dataType": "enum", "enums": ["VM-template"] }, { "dataType": "enum", "enums": ["SM"] }] }, { "dataType": "enum", "enums": ["backup"] }, { "dataType": "enum", "enums": ["backup-archive"] }, { "dataType": "enum", "enums": ["backup-job"] }, { "dataType": "enum", "enums": ["backup-log"] }, { "dataType": "enum", "enums": ["backup-repository"] }, { "dataType": "enum", "enums": ["group"] }, { "dataType": "enum", "enums": ["proxy"] }, { "dataType": "enum", "enums": ["restore"] }, { "dataType": "enum", "enums": ["restore-log"] }, { "dataType": "enum", "enums": ["schedule"] }, { "dataType": "enum", "enums": ["server"] }, { "dataType": "enum", "enums": ["task"] }, { "dataType": "enum", "enums": ["user"] }] }, "objectId": { "dataType": "string" }, "name": { "dataType": "string" }, "method": { "dataType": "string" } }, "additionalProperties": { "dataType": "union", "subSchemas": [{ "dataType": "any" }, { "dataType": "undefined" }] }, "required": true }, "progress": { "dataType": "double" }, "infos": { "dataType": "array", "array": { "dataType": "nestedObjectLiteral", "nestedProperties": { "message": { "dataType": "string", "required": true }, "data": { "dataType": "any", "required": true } } } }, "id": { "ref": "Branded_task_", "required": true }, "end": { "dataType": "double" }, "data": { "ref": "Record_string.string_" }, "abortionRequestedAt": { "dataType": "double" } }, "validators": {} },
339
339
  },
340
340
  // 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
341
341
  "Partial_Unbrand_XoTask__": {
342
342
  "dataType": "refAlias",
343
- "type": { "dataType": "nestedObjectLiteral", "nestedProperties": { "abortionRequestedAt": { "dataType": "union", "subSchemas": [{ "dataType": "double" }, { "dataType": "undefined" }] }, "data": { "dataType": "union", "subSchemas": [{ "ref": "Record_string.string_" }, { "dataType": "undefined" }] }, "end": { "dataType": "union", "subSchemas": [{ "dataType": "double" }, { "dataType": "undefined" }] }, "id": { "dataType": "union", "subSchemas": [{ "dataType": "string" }, { "dataType": "undefined" }] }, "infos": { "dataType": "union", "subSchemas": [{ "dataType": "array", "array": { "dataType": "nestedObjectLiteral", "nestedProperties": { "message": { "dataType": "string", "required": true }, "data": { "dataType": "any", "required": true } } } }, { "dataType": "undefined" }] }, "progress": { "dataType": "union", "subSchemas": [{ "dataType": "double" }, { "dataType": "undefined" }] }, "properties": { "dataType": "union", "subSchemas": [{ "dataType": "nestedObjectLiteral", "nestedProperties": { "userId": { "dataType": "union", "subSchemas": [{ "dataType": "string" }, { "dataType": "undefined" }] }, "type": { "dataType": "union", "subSchemas": [{ "dataType": "string" }, { "dataType": "undefined" }] }, "progress": { "dataType": "union", "subSchemas": [{ "dataType": "double" }, { "dataType": "undefined" }] }, "params": { "dataType": "union", "subSchemas": [{ "ref": "Record_string.unknown_" }, { "dataType": "undefined" }] }, "objectId": { "dataType": "union", "subSchemas": [{ "dataType": "string" }, { "dataType": "undefined" }] }, "name": { "dataType": "union", "subSchemas": [{ "dataType": "string" }, { "dataType": "undefined" }] }, "method": { "dataType": "union", "subSchemas": [{ "dataType": "string" }, { "dataType": "undefined" }] } }, "additionalProperties": { "dataType": "any" } }, { "dataType": "undefined" }] }, "result": { "dataType": "union", "subSchemas": [{ "ref": "Record_string.unknown_" }, { "dataType": "undefined" }] }, "start": { "dataType": "union", "subSchemas": [{ "dataType": "double" }, { "dataType": "undefined" }] }, "status": { "dataType": "union", "subSchemas": [{ "dataType": "enum", "enums": ["failure"] }, { "dataType": "enum", "enums": ["interrupted"] }, { "dataType": "enum", "enums": ["pending"] }, { "dataType": "enum", "enums": ["success"] }, { "dataType": "undefined" }] }, "tasks": { "dataType": "union", "subSchemas": [{ "dataType": "array", "array": { "dataType": "refAlias", "ref": "XoTask" } }, { "dataType": "undefined" }] }, "updatedAt": { "dataType": "union", "subSchemas": [{ "dataType": "double" }, { "dataType": "undefined" }] }, "warnings": { "dataType": "union", "subSchemas": [{ "dataType": "array", "array": { "dataType": "nestedObjectLiteral", "nestedProperties": { "message": { "dataType": "string", "required": true }, "data": { "dataType": "any", "required": true } } } }, { "dataType": "undefined" }] } }, "validators": {} },
343
+ "type": { "dataType": "nestedObjectLiteral", "nestedProperties": { "abortionRequestedAt": { "dataType": "union", "subSchemas": [{ "dataType": "double" }, { "dataType": "undefined" }] }, "data": { "dataType": "union", "subSchemas": [{ "ref": "Record_string.string_" }, { "dataType": "undefined" }] }, "end": { "dataType": "union", "subSchemas": [{ "dataType": "double" }, { "dataType": "undefined" }] }, "id": { "dataType": "union", "subSchemas": [{ "dataType": "string" }, { "dataType": "undefined" }] }, "infos": { "dataType": "union", "subSchemas": [{ "dataType": "array", "array": { "dataType": "nestedObjectLiteral", "nestedProperties": { "message": { "dataType": "string", "required": true }, "data": { "dataType": "any", "required": true } } } }, { "dataType": "undefined" }] }, "progress": { "dataType": "union", "subSchemas": [{ "dataType": "double" }, { "dataType": "undefined" }] }, "properties": { "dataType": "union", "subSchemas": [{ "dataType": "nestedObjectLiteral", "nestedProperties": { "userId": { "dataType": "union", "subSchemas": [{ "dataType": "string" }, { "dataType": "undefined" }] }, "type": { "dataType": "union", "subSchemas": [{ "dataType": "string" }, { "dataType": "undefined" }] }, "progress": { "dataType": "union", "subSchemas": [{ "dataType": "double" }, { "dataType": "undefined" }] }, "params": { "dataType": "union", "subSchemas": [{ "ref": "Record_string.unknown_" }, { "dataType": "undefined" }] }, "objectType": { "dataType": "union", "subSchemas": [{ "dataType": "enum", "enums": ["backup"] }, { "dataType": "enum", "enums": ["pool"] }, { "dataType": "enum", "enums": ["VBD"] }, { "dataType": "enum", "enums": ["host"] }, { "dataType": "enum", "enums": ["VIF"] }, { "dataType": "enum", "enums": ["VTPM"] }, { "dataType": "enum", "enums": ["VM"] }, { "dataType": "enum", "enums": ["VM-snapshot"] }, { "dataType": "enum", "enums": ["SR"] }, { "dataType": "enum", "enums": ["message"] }, { "dataType": "enum", "enums": ["vgpu"] }, { "dataType": "enum", "enums": ["gpuGroup"] }, { "dataType": "enum", "enums": ["network"] }, { "dataType": "enum", "enums": ["PBD"] }, { "dataType": "enum", "enums": ["PCI"] }, { "dataType": "enum", "enums": ["PGPU"] }, { "dataType": "enum", "enums": ["PIF"] }, { "dataType": "enum", "enums": ["VDI"] }, { "dataType": "enum", "enums": ["VDI-snapshot"] }, { "dataType": "enum", "enums": ["VDI-unmanaged"] }, { "dataType": "enum", "enums": ["vgpuType"] }, { "dataType": "enum", "enums": ["VM-controller"] }, { "dataType": "enum", "enums": ["VM-template"] }, { "dataType": "enum", "enums": ["SM"] }, { "dataType": "enum", "enums": ["user"] }, { "dataType": "enum", "enums": ["proxy"] }, { "dataType": "enum", "enums": ["task"] }, { "dataType": "enum", "enums": ["backup-archive"] }, { "dataType": "enum", "enums": ["backup-job"] }, { "dataType": "enum", "enums": ["backup-log"] }, { "dataType": "enum", "enums": ["backup-repository"] }, { "dataType": "enum", "enums": ["group"] }, { "dataType": "enum", "enums": ["restore"] }, { "dataType": "enum", "enums": ["restore-log"] }, { "dataType": "enum", "enums": ["schedule"] }, { "dataType": "enum", "enums": ["server"] }, { "dataType": "undefined" }] }, "objectId": { "dataType": "union", "subSchemas": [{ "dataType": "string" }, { "dataType": "undefined" }] }, "name": { "dataType": "union", "subSchemas": [{ "dataType": "string" }, { "dataType": "undefined" }] }, "method": { "dataType": "union", "subSchemas": [{ "dataType": "string" }, { "dataType": "undefined" }] } }, "additionalProperties": { "dataType": "any" } }, { "dataType": "undefined" }] }, "result": { "dataType": "union", "subSchemas": [{ "ref": "Record_string.unknown_" }, { "dataType": "undefined" }] }, "start": { "dataType": "union", "subSchemas": [{ "dataType": "double" }, { "dataType": "undefined" }] }, "status": { "dataType": "union", "subSchemas": [{ "dataType": "enum", "enums": ["failure"] }, { "dataType": "enum", "enums": ["interrupted"] }, { "dataType": "enum", "enums": ["pending"] }, { "dataType": "enum", "enums": ["success"] }, { "dataType": "undefined" }] }, "tasks": { "dataType": "union", "subSchemas": [{ "dataType": "array", "array": { "dataType": "refAlias", "ref": "XoTask" } }, { "dataType": "undefined" }] }, "updatedAt": { "dataType": "union", "subSchemas": [{ "dataType": "double" }, { "dataType": "undefined" }] }, "warnings": { "dataType": "union", "subSchemas": [{ "dataType": "array", "array": { "dataType": "nestedObjectLiteral", "nestedProperties": { "message": { "dataType": "string", "required": true }, "data": { "dataType": "any", "required": true } } } }, { "dataType": "undefined" }] } }, "validators": {} },
344
344
  },
345
345
  // 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
346
346
  "WithHref_Partial_Unbrand_XoTask___": {
@@ -518,6 +518,21 @@ const models = {
518
518
  "type": { "dataType": "nestedObjectLiteral", "nestedProperties": { "$pool": { "dataType": "string", "required": true }, "$poolId": { "dataType": "string", "required": true }, "_xapiRef": { "dataType": "string", "required": true }, "uuid": { "dataType": "string", "required": true }, "$SR": { "dataType": "string", "required": true }, "$VBDs": { "dataType": "array", "array": { "dataType": "string" }, "required": true }, "VDI_type": { "ref": "VDI_TYPE", "required": true }, "cbt_enabled": { "dataType": "union", "subSchemas": [{ "dataType": "boolean" }, { "dataType": "undefined" }] }, "current_operations": { "ref": "Record_string.VDI_OPERATIONS_", "required": true }, "missing": { "dataType": "boolean", "required": true }, "name_description": { "dataType": "string", "required": true }, "name_label": { "dataType": "string", "required": true }, "other_config": { "ref": "Record_string.string_", "required": true }, "parent": { "dataType": "union", "subSchemas": [{ "dataType": "string" }, { "dataType": "undefined" }] }, "image_format": { "dataType": "union", "subSchemas": [{ "dataType": "string" }, { "dataType": "undefined" }] }, "size": { "dataType": "double", "required": true }, "snapshots": { "dataType": "array", "array": { "dataType": "string" }, "required": true }, "tags": { "dataType": "array", "array": { "dataType": "string" }, "required": true }, "usage": { "dataType": "double", "required": true }, "id": { "dataType": "string", "required": true }, "type": { "dataType": "enum", "enums": ["VDI"], "required": true } }, "validators": {} },
519
519
  },
520
520
  // 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
521
+ "Pick_CreateVdiParams_91_0_93_.Exclude_keyofCreateVdiParams_91_0_93_.SR__": {
522
+ "dataType": "refAlias",
523
+ "type": { "dataType": "nestedObjectLiteral", "nestedProperties": { "name_description": { "dataType": "union", "subSchemas": [{ "dataType": "string" }, { "dataType": "undefined" }] }, "name_label": { "dataType": "union", "subSchemas": [{ "dataType": "string" }, { "dataType": "undefined" }] }, "tags": { "dataType": "union", "subSchemas": [{ "dataType": "array", "array": { "dataType": "string" } }, { "dataType": "undefined" }] }, "type": { "dataType": "union", "subSchemas": [{ "ref": "VDI_TYPE" }, { "dataType": "undefined" }] }, "other_config": { "dataType": "union", "subSchemas": [{ "ref": "Record_string.string_" }, { "dataType": "undefined" }] }, "read_only": { "dataType": "union", "subSchemas": [{ "dataType": "boolean" }, { "dataType": "undefined" }] }, "sharable": { "dataType": "union", "subSchemas": [{ "dataType": "boolean" }, { "dataType": "undefined" }] }, "virtual_size": { "dataType": "double", "required": true }, "xenstore_data": { "dataType": "union", "subSchemas": [{ "ref": "Record_string.string_" }, { "dataType": "undefined" }] } }, "validators": {} },
524
+ },
525
+ // 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
526
+ "Omit_CreateVdiParams_91_0_93_.SR_": {
527
+ "dataType": "refAlias",
528
+ "type": { "ref": "Pick_CreateVdiParams_91_0_93_.Exclude_keyofCreateVdiParams_91_0_93_.SR__", "validators": {} },
529
+ },
530
+ // 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
531
+ "CreateVdiBody": {
532
+ "dataType": "refAlias",
533
+ "type": { "dataType": "intersection", "subSchemas": [{ "ref": "Omit_CreateVdiParams_91_0_93_.SR_" }, { "dataType": "nestedObjectLiteral", "nestedProperties": { "srId": { "dataType": "string", "required": true } } }, { "dataType": "union", "subSchemas": [{ "dataType": "nestedObjectLiteral", "nestedProperties": { "sm_config": { "ref": "Record_string.string_" } } }, { "dataType": "undefined" }] }], "validators": {} },
534
+ },
535
+ // 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
521
536
  "CreateActionReturnType__id-Unbrand_XoVdi__91_id_93___": {
522
537
  "dataType": "refAlias",
523
538
  "type": { "dataType": "union", "subSchemas": [{ "dataType": "nestedObjectLiteral", "nestedProperties": { "taskId": { "dataType": "string", "required": true } } }, { "dataType": "nestedObjectLiteral", "nestedProperties": { "id": { "dataType": "string", "required": true } } }], "validators": {} },
@@ -626,7 +641,7 @@ const models = {
626
641
  // 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
627
642
  "Unbrand_XoTask_": {
628
643
  "dataType": "refAlias",
629
- "type": { "dataType": "nestedObjectLiteral", "nestedProperties": { "abortionRequestedAt": { "dataType": "union", "subSchemas": [{ "dataType": "double" }, { "dataType": "undefined" }] }, "data": { "dataType": "union", "subSchemas": [{ "ref": "Record_string.string_" }, { "dataType": "undefined" }] }, "end": { "dataType": "union", "subSchemas": [{ "dataType": "double" }, { "dataType": "undefined" }] }, "id": { "dataType": "string", "required": true }, "infos": { "dataType": "union", "subSchemas": [{ "dataType": "array", "array": { "dataType": "nestedObjectLiteral", "nestedProperties": { "message": { "dataType": "string", "required": true }, "data": { "dataType": "any", "required": true } } } }, { "dataType": "undefined" }] }, "progress": { "dataType": "union", "subSchemas": [{ "dataType": "double" }, { "dataType": "undefined" }] }, "properties": { "dataType": "nestedObjectLiteral", "nestedProperties": { "userId": { "dataType": "union", "subSchemas": [{ "dataType": "string" }, { "dataType": "undefined" }] }, "type": { "dataType": "union", "subSchemas": [{ "dataType": "string" }, { "dataType": "undefined" }] }, "progress": { "dataType": "union", "subSchemas": [{ "dataType": "double" }, { "dataType": "undefined" }] }, "params": { "dataType": "union", "subSchemas": [{ "ref": "Record_string.unknown_" }, { "dataType": "undefined" }] }, "objectId": { "dataType": "union", "subSchemas": [{ "dataType": "string" }, { "dataType": "undefined" }] }, "name": { "dataType": "union", "subSchemas": [{ "dataType": "string" }, { "dataType": "undefined" }] }, "method": { "dataType": "union", "subSchemas": [{ "dataType": "string" }, { "dataType": "undefined" }] } }, "additionalProperties": { "dataType": "any" }, "required": true }, "result": { "ref": "Record_string.unknown_", "required": true }, "start": { "dataType": "double", "required": true }, "status": { "dataType": "union", "subSchemas": [{ "dataType": "enum", "enums": ["failure"] }, { "dataType": "enum", "enums": ["interrupted"] }, { "dataType": "enum", "enums": ["pending"] }, { "dataType": "enum", "enums": ["success"] }], "required": true }, "tasks": { "dataType": "union", "subSchemas": [{ "dataType": "array", "array": { "dataType": "refAlias", "ref": "XoTask" } }, { "dataType": "undefined" }] }, "updatedAt": { "dataType": "union", "subSchemas": [{ "dataType": "double" }, { "dataType": "undefined" }] }, "warnings": { "dataType": "union", "subSchemas": [{ "dataType": "array", "array": { "dataType": "nestedObjectLiteral", "nestedProperties": { "message": { "dataType": "string", "required": true }, "data": { "dataType": "any", "required": true } } } }, { "dataType": "undefined" }] } }, "validators": {} },
644
+ "type": { "dataType": "nestedObjectLiteral", "nestedProperties": { "abortionRequestedAt": { "dataType": "union", "subSchemas": [{ "dataType": "double" }, { "dataType": "undefined" }] }, "data": { "dataType": "union", "subSchemas": [{ "ref": "Record_string.string_" }, { "dataType": "undefined" }] }, "end": { "dataType": "union", "subSchemas": [{ "dataType": "double" }, { "dataType": "undefined" }] }, "id": { "dataType": "string", "required": true }, "infos": { "dataType": "union", "subSchemas": [{ "dataType": "array", "array": { "dataType": "nestedObjectLiteral", "nestedProperties": { "message": { "dataType": "string", "required": true }, "data": { "dataType": "any", "required": true } } } }, { "dataType": "undefined" }] }, "progress": { "dataType": "union", "subSchemas": [{ "dataType": "double" }, { "dataType": "undefined" }] }, "properties": { "dataType": "nestedObjectLiteral", "nestedProperties": { "userId": { "dataType": "union", "subSchemas": [{ "dataType": "string" }, { "dataType": "undefined" }] }, "type": { "dataType": "union", "subSchemas": [{ "dataType": "string" }, { "dataType": "undefined" }] }, "progress": { "dataType": "union", "subSchemas": [{ "dataType": "double" }, { "dataType": "undefined" }] }, "params": { "dataType": "union", "subSchemas": [{ "ref": "Record_string.unknown_" }, { "dataType": "undefined" }] }, "objectType": { "dataType": "union", "subSchemas": [{ "dataType": "enum", "enums": ["backup"] }, { "dataType": "enum", "enums": ["pool"] }, { "dataType": "enum", "enums": ["VBD"] }, { "dataType": "enum", "enums": ["host"] }, { "dataType": "enum", "enums": ["VIF"] }, { "dataType": "enum", "enums": ["VTPM"] }, { "dataType": "enum", "enums": ["VM"] }, { "dataType": "enum", "enums": ["VM-snapshot"] }, { "dataType": "enum", "enums": ["SR"] }, { "dataType": "enum", "enums": ["message"] }, { "dataType": "enum", "enums": ["vgpu"] }, { "dataType": "enum", "enums": ["gpuGroup"] }, { "dataType": "enum", "enums": ["network"] }, { "dataType": "enum", "enums": ["PBD"] }, { "dataType": "enum", "enums": ["PCI"] }, { "dataType": "enum", "enums": ["PGPU"] }, { "dataType": "enum", "enums": ["PIF"] }, { "dataType": "enum", "enums": ["VDI"] }, { "dataType": "enum", "enums": ["VDI-snapshot"] }, { "dataType": "enum", "enums": ["VDI-unmanaged"] }, { "dataType": "enum", "enums": ["vgpuType"] }, { "dataType": "enum", "enums": ["VM-controller"] }, { "dataType": "enum", "enums": ["VM-template"] }, { "dataType": "enum", "enums": ["SM"] }, { "dataType": "enum", "enums": ["user"] }, { "dataType": "enum", "enums": ["proxy"] }, { "dataType": "enum", "enums": ["task"] }, { "dataType": "enum", "enums": ["backup-archive"] }, { "dataType": "enum", "enums": ["backup-job"] }, { "dataType": "enum", "enums": ["backup-log"] }, { "dataType": "enum", "enums": ["backup-repository"] }, { "dataType": "enum", "enums": ["group"] }, { "dataType": "enum", "enums": ["restore"] }, { "dataType": "enum", "enums": ["restore-log"] }, { "dataType": "enum", "enums": ["schedule"] }, { "dataType": "enum", "enums": ["server"] }, { "dataType": "undefined" }] }, "objectId": { "dataType": "union", "subSchemas": [{ "dataType": "string" }, { "dataType": "undefined" }] }, "name": { "dataType": "union", "subSchemas": [{ "dataType": "string" }, { "dataType": "undefined" }] }, "method": { "dataType": "union", "subSchemas": [{ "dataType": "string" }, { "dataType": "undefined" }] } }, "additionalProperties": { "dataType": "any" }, "required": true }, "result": { "ref": "Record_string.unknown_", "required": true }, "start": { "dataType": "double", "required": true }, "status": { "dataType": "union", "subSchemas": [{ "dataType": "enum", "enums": ["failure"] }, { "dataType": "enum", "enums": ["interrupted"] }, { "dataType": "enum", "enums": ["pending"] }, { "dataType": "enum", "enums": ["success"] }], "required": true }, "tasks": { "dataType": "union", "subSchemas": [{ "dataType": "array", "array": { "dataType": "refAlias", "ref": "XoTask" } }, { "dataType": "undefined" }] }, "updatedAt": { "dataType": "union", "subSchemas": [{ "dataType": "double" }, { "dataType": "undefined" }] }, "warnings": { "dataType": "union", "subSchemas": [{ "dataType": "array", "array": { "dataType": "nestedObjectLiteral", "nestedProperties": { "message": { "dataType": "string", "required": true }, "data": { "dataType": "any", "required": true } } } }, { "dataType": "undefined" }] } }, "validators": {} },
630
645
  },
631
646
  // 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
632
647
  "Record_string.STORAGE_OPERATIONS_": {
@@ -2075,6 +2090,35 @@ export function RegisterRoutes(app) {
2075
2090
  }
2076
2091
  });
2077
2092
  // 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
2093
+ const argsVmController_migrateVm = {
2094
+ id: { "in": "path", "name": "id", "required": true, "dataType": "string" },
2095
+ body: { "in": "body", "name": "body", "required": true, "dataType": "union", "subSchemas": [{ "dataType": "nestedObjectLiteral", "nestedProperties": { "migrationNetworkId": { "dataType": "string" }, "hostId": { "dataType": "string", "required": true } } }, { "dataType": "nestedObjectLiteral", "nestedProperties": { "networkIdByVifId": { "dataType": "nestedObjectLiteral", "nestedProperties": {}, "additionalProperties": { "dataType": "string" } }, "srIdByVdiId": { "dataType": "nestedObjectLiteral", "nestedProperties": {}, "additionalProperties": { "dataType": "string" } }, "srId": { "dataType": "string" }, "migrationNetworkId": { "dataType": "string" }, "hostId": { "dataType": "string", "required": true } } }] },
2096
+ sync: { "in": "query", "name": "sync", "dataType": "boolean" },
2097
+ };
2098
+ app.post('/rest/v0/vms/:id/actions/migrate', authenticateMiddleware([{ "*": [] }]), ...(fetchMiddlewares(VmController)), ...(fetchMiddlewares(VmController.prototype.migrateVm)), async function VmController_migrateVm(request, response, next) {
2099
+ // 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
2100
+ let validatedArgs = [];
2101
+ try {
2102
+ validatedArgs = templateService.getValidatedArgs({ args: argsVmController_migrateVm, request, response });
2103
+ const container = typeof iocContainer === 'function' ? iocContainer(request) : iocContainer;
2104
+ const controller = await container.get(VmController);
2105
+ if (typeof controller['setStatus'] === 'function') {
2106
+ controller.setStatus(undefined);
2107
+ }
2108
+ await templateService.apiHandler({
2109
+ methodName: 'migrateVm',
2110
+ controller,
2111
+ response,
2112
+ next,
2113
+ validatedArgs,
2114
+ successStatus: 202,
2115
+ });
2116
+ }
2117
+ catch (err) {
2118
+ return next(err);
2119
+ }
2120
+ });
2121
+ // 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
2078
2122
  const argsVmTemplateController_getVmTemplates = {
2079
2123
  req: { "in": "request", "name": "req", "required": true, "dataType": "object" },
2080
2124
  fields: { "in": "query", "name": "fields", "dataType": "string" },
@@ -3271,6 +3315,33 @@ export function RegisterRoutes(app) {
3271
3315
  }
3272
3316
  });
3273
3317
  // 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
3318
+ const argsVdiController_createVdi = {
3319
+ body: { "in": "body", "name": "body", "required": true, "ref": "CreateVdiBody" },
3320
+ };
3321
+ app.post('/rest/v0/vdis', authenticateMiddleware([{ "*": [] }]), ...(fetchMiddlewares(VdiController)), ...(fetchMiddlewares(VdiController.prototype.createVdi)), async function VdiController_createVdi(request, response, next) {
3322
+ // 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
3323
+ let validatedArgs = [];
3324
+ try {
3325
+ validatedArgs = templateService.getValidatedArgs({ args: argsVdiController_createVdi, request, response });
3326
+ const container = typeof iocContainer === 'function' ? iocContainer(request) : iocContainer;
3327
+ const controller = await container.get(VdiController);
3328
+ if (typeof controller['setStatus'] === 'function') {
3329
+ controller.setStatus(undefined);
3330
+ }
3331
+ await templateService.apiHandler({
3332
+ methodName: 'createVdi',
3333
+ controller,
3334
+ response,
3335
+ next,
3336
+ validatedArgs,
3337
+ successStatus: 201,
3338
+ });
3339
+ }
3340
+ catch (err) {
3341
+ return next(err);
3342
+ }
3343
+ });
3344
+ // 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
3274
3345
  const argsVdiController_deleteVdi = {
3275
3346
  id: { "in": "path", "name": "id", "required": true, "dataType": "string" },
3276
3347
  };
@@ -4648,6 +4719,62 @@ export function RegisterRoutes(app) {
4648
4719
  }
4649
4720
  });
4650
4721
  // 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
4722
+ const argsSrController_reclaimSpaceSr = {
4723
+ id: { "in": "path", "name": "id", "required": true, "dataType": "string" },
4724
+ sync: { "in": "query", "name": "sync", "dataType": "boolean" },
4725
+ };
4726
+ app.post('/rest/v0/srs/:id/actions/reclaim_space', authenticateMiddleware([{ "*": [] }]), ...(fetchMiddlewares(SrController)), ...(fetchMiddlewares(SrController.prototype.reclaimSpaceSr)), async function SrController_reclaimSpaceSr(request, response, next) {
4727
+ // 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
4728
+ let validatedArgs = [];
4729
+ try {
4730
+ validatedArgs = templateService.getValidatedArgs({ args: argsSrController_reclaimSpaceSr, request, response });
4731
+ const container = typeof iocContainer === 'function' ? iocContainer(request) : iocContainer;
4732
+ const controller = await container.get(SrController);
4733
+ if (typeof controller['setStatus'] === 'function') {
4734
+ controller.setStatus(undefined);
4735
+ }
4736
+ await templateService.apiHandler({
4737
+ methodName: 'reclaimSpaceSr',
4738
+ controller,
4739
+ response,
4740
+ next,
4741
+ validatedArgs,
4742
+ successStatus: 202,
4743
+ });
4744
+ }
4745
+ catch (err) {
4746
+ return next(err);
4747
+ }
4748
+ });
4749
+ // 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
4750
+ const argsSrController_scanSr = {
4751
+ id: { "in": "path", "name": "id", "required": true, "dataType": "string" },
4752
+ sync: { "in": "query", "name": "sync", "dataType": "boolean" },
4753
+ };
4754
+ app.post('/rest/v0/srs/:id/actions/scan', authenticateMiddleware([{ "*": [] }]), ...(fetchMiddlewares(SrController)), ...(fetchMiddlewares(SrController.prototype.scanSr)), async function SrController_scanSr(request, response, next) {
4755
+ // 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
4756
+ let validatedArgs = [];
4757
+ try {
4758
+ validatedArgs = templateService.getValidatedArgs({ args: argsSrController_scanSr, request, response });
4759
+ const container = typeof iocContainer === 'function' ? iocContainer(request) : iocContainer;
4760
+ const controller = await container.get(SrController);
4761
+ if (typeof controller['setStatus'] === 'function') {
4762
+ controller.setStatus(undefined);
4763
+ }
4764
+ await templateService.apiHandler({
4765
+ methodName: 'scanSr',
4766
+ controller,
4767
+ response,
4768
+ next,
4769
+ validatedArgs,
4770
+ successStatus: 202,
4771
+ });
4772
+ }
4773
+ catch (err) {
4774
+ return next(err);
4775
+ }
4776
+ });
4777
+ // 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
4651
4778
  const argsSmController_getSrs = {
4652
4779
  req: { "in": "request", "name": "req", "required": true, "dataType": "object" },
4653
4780
  fields: { "in": "query", "name": "fields", "dataType": "string" },
@@ -5988,6 +6115,62 @@ export function RegisterRoutes(app) {
5988
6115
  }
5989
6116
  });
5990
6117
  // 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
6118
+ const argsPbdController_plugPbd = {
6119
+ id: { "in": "path", "name": "id", "required": true, "dataType": "string" },
6120
+ sync: { "in": "query", "name": "sync", "dataType": "boolean" },
6121
+ };
6122
+ app.post('/rest/v0/pbds/:id/actions/plug', authenticateMiddleware([{ "*": [] }]), ...(fetchMiddlewares(PbdController)), ...(fetchMiddlewares(PbdController.prototype.plugPbd)), async function PbdController_plugPbd(request, response, next) {
6123
+ // 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
6124
+ let validatedArgs = [];
6125
+ try {
6126
+ validatedArgs = templateService.getValidatedArgs({ args: argsPbdController_plugPbd, request, response });
6127
+ const container = typeof iocContainer === 'function' ? iocContainer(request) : iocContainer;
6128
+ const controller = await container.get(PbdController);
6129
+ if (typeof controller['setStatus'] === 'function') {
6130
+ controller.setStatus(undefined);
6131
+ }
6132
+ await templateService.apiHandler({
6133
+ methodName: 'plugPbd',
6134
+ controller,
6135
+ response,
6136
+ next,
6137
+ validatedArgs,
6138
+ successStatus: 202,
6139
+ });
6140
+ }
6141
+ catch (err) {
6142
+ return next(err);
6143
+ }
6144
+ });
6145
+ // 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
6146
+ const argsPbdController_unplugPbd = {
6147
+ id: { "in": "path", "name": "id", "required": true, "dataType": "string" },
6148
+ sync: { "in": "query", "name": "sync", "dataType": "boolean" },
6149
+ };
6150
+ app.post('/rest/v0/pbds/:id/actions/unplug', authenticateMiddleware([{ "*": [] }]), ...(fetchMiddlewares(PbdController)), ...(fetchMiddlewares(PbdController.prototype.unplugPbd)), async function PbdController_unplugPbd(request, response, next) {
6151
+ // 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
6152
+ let validatedArgs = [];
6153
+ try {
6154
+ validatedArgs = templateService.getValidatedArgs({ args: argsPbdController_unplugPbd, request, response });
6155
+ const container = typeof iocContainer === 'function' ? iocContainer(request) : iocContainer;
6156
+ const controller = await container.get(PbdController);
6157
+ if (typeof controller['setStatus'] === 'function') {
6158
+ controller.setStatus(undefined);
6159
+ }
6160
+ await templateService.apiHandler({
6161
+ methodName: 'unplugPbd',
6162
+ controller,
6163
+ response,
6164
+ next,
6165
+ validatedArgs,
6166
+ successStatus: 202,
6167
+ });
6168
+ }
6169
+ catch (err) {
6170
+ return next(err);
6171
+ }
6172
+ });
6173
+ // 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
5991
6174
  const argsNetworkController_getNetworks = {
5992
6175
  req: { "in": "request", "name": "req", "required": true, "dataType": "object" },
5993
6176
  fields: { "in": "query", "name": "fields", "dataType": "string" },
@@ -9,11 +9,12 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
9
9
  };
10
10
  import { inject } from 'inversify';
11
11
  import { provide } from 'inversify-binding-decorators';
12
- import { Route, Security, Request, Response, Get, Query, Path, Tags, Example } from 'tsoa';
13
- import { badRequestResp, unauthorizedResp } from '../open-api/common/response.common.mjs';
12
+ import { Route, Security, Request, Response, Get, Query, Path, Tags, Example, Post, SuccessResponse } from 'tsoa';
13
+ import { asynchronousActionResp, badRequestResp, internalServerErrorResp, invalidParameters as invalidParametersResp, noContentResp, notFoundResp, unauthorizedResp, } from '../open-api/common/response.common.mjs';
14
14
  import { RestApi } from '../rest-api/rest-api.mjs';
15
15
  import { XapiXoController } from '../abstract-classes/xapi-xo-controller.mjs';
16
16
  import { partialPbds, pbd, pbdIds } from '../open-api/oa-examples/pbd.oa-example.mjs';
17
+ import { taskLocation } from '../open-api/oa-examples/task.oa-example.mjs';
17
18
  let PbdController = class PbdController extends XapiXoController {
18
19
  constructor(restApi) {
19
20
  super('PBD', restApi);
@@ -32,6 +33,42 @@ let PbdController = class PbdController extends XapiXoController {
32
33
  getPbd(id) {
33
34
  return this.getObject(id);
34
35
  }
36
+ /**
37
+ * @example id "b61a5c92-700e-4966-a13b-00633f03eea8"
38
+ */
39
+ async plugPbd(id, sync) {
40
+ const pbdId = id;
41
+ const action = async () => {
42
+ const pbd = this.getXapiObject(pbdId);
43
+ await pbd.$xapi.callAsync('PBD.plug', pbd.$ref);
44
+ };
45
+ return this.createAction(action, {
46
+ sync,
47
+ statusCode: noContentResp.status,
48
+ taskProperties: {
49
+ name: 'plug pbd',
50
+ objectId: pbdId,
51
+ },
52
+ });
53
+ }
54
+ /**
55
+ * @example id "b61a5c92-700e-4966-a13b-00633f03eea8"
56
+ */
57
+ async unplugPbd(id, sync) {
58
+ const pbdId = id;
59
+ const action = async () => {
60
+ const pbd = this.getXapiObject(pbdId);
61
+ await pbd.$xapi.callAsync('PBD.unplug', pbd.$ref);
62
+ };
63
+ return this.createAction(action, {
64
+ sync,
65
+ statusCode: noContentResp.status,
66
+ taskProperties: {
67
+ name: 'unplug pbd',
68
+ objectId: pbdId,
69
+ },
70
+ });
71
+ }
35
72
  };
36
73
  __decorate([
37
74
  Example(pbdIds),
@@ -48,6 +85,28 @@ __decorate([
48
85
  Get('{id}'),
49
86
  __param(0, Path())
50
87
  ], PbdController.prototype, "getPbd", null);
88
+ __decorate([
89
+ Example(taskLocation),
90
+ Post('{id}/actions/plug'),
91
+ SuccessResponse(asynchronousActionResp.status, asynchronousActionResp.description),
92
+ Response(noContentResp.status, noContentResp.description),
93
+ Response(notFoundResp.status, notFoundResp.description),
94
+ Response(invalidParametersResp.status, invalidParametersResp.description),
95
+ Response(internalServerErrorResp.status, internalServerErrorResp.description),
96
+ __param(0, Path()),
97
+ __param(1, Query())
98
+ ], PbdController.prototype, "plugPbd", null);
99
+ __decorate([
100
+ Example(taskLocation),
101
+ Post('{id}/actions/unplug'),
102
+ SuccessResponse(asynchronousActionResp.status, asynchronousActionResp.description),
103
+ Response(noContentResp.status, noContentResp.description),
104
+ Response(notFoundResp.status, notFoundResp.description),
105
+ Response(invalidParametersResp.status, invalidParametersResp.description),
106
+ Response(internalServerErrorResp.status, internalServerErrorResp.description),
107
+ __param(0, Path()),
108
+ __param(1, Query())
109
+ ], PbdController.prototype, "unplugPbd", null);
51
110
  PbdController = __decorate([
52
111
  Route('pbds'),
53
112
  Security('*'),
@@ -4,7 +4,7 @@ import { HOST_POWER_STATE, VM_POWER_STATE, } from '@vates/types';
4
4
  import { HostService } from '../hosts/host.service.mjs';
5
5
  import { VmService } from '../vms/vm.service.mjs';
6
6
  import { AlarmService } from '../alarms/alarm.service.mjs';
7
- import { getTopPerProperty, isSrWritableOrIso, promiseWriteInStream } from '../helpers/utils.helper.mjs';
7
+ import { getTopPerProperty, isSrWritable, promiseWriteInStream } from '../helpers/utils.helper.mjs';
8
8
  import { getFromAsyncCache } from '../helpers/cache.helper.mjs';
9
9
  const log = createLogger('xo:rest-api:pool-service');
10
10
  export class PoolService {
@@ -61,7 +61,7 @@ export class PoolService {
61
61
  }
62
62
  #getTopFiveSrsUsage(poolId) {
63
63
  const srs = Object.values(this.#restApi.getObjectsByType('SR', {
64
- filter: sr => sr.$pool === poolId && isSrWritableOrIso(sr),
64
+ filter: sr => sr.$pool === poolId && isSrWritable(sr) && sr.SR_type !== 'udev',
65
65
  }));
66
66
  const topFive = getTopPerProperty(srs.map(({ name_label, id, physical_usage, size }) => ({
67
67
  name_label,