@xen-orchestra/rest-api 0.9.0 → 0.10.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.
@@ -3,8 +3,8 @@ import { Readable } from 'node:stream';
3
3
  import { BASE_URL } from '../index.mjs';
4
4
  import { makeNdJsonStream } from '../helpers/stream.helper.mjs';
5
5
  import { makeObjectMapper } from '../helpers/object-wrapper.helper.mjs';
6
+ import { NDJSON_CONTENT_TYPE } from '../helpers/utils.helper.mjs';
6
7
  const noop = () => { };
7
- const NDJSON_CONTENT_TYPE = 'application/x-ndjson';
8
8
  export class BaseController extends Controller {
9
9
  restApi;
10
10
  constructor(restApi) {
@@ -46,4 +46,7 @@ export class BaseController extends Controller {
46
46
  return location;
47
47
  }
48
48
  }
49
+ getXapi(maybeId) {
50
+ return this.restApi.xoApp.getXapi(maybeId);
51
+ }
49
52
  }
@@ -1,3 +1,4 @@
1
+ export const NDJSON_CONTENT_TYPE = 'application/x-ndjson';
1
2
  export const isSrWritable = (sr) => sr.content_type !== 'iso' && sr.size > 0;
2
3
  export const isReplicaVm = (vm) => 'start' in vm.blockedOperations && vm.other['xo:backup:job'] !== undefined;
3
4
  export const vmContainsNoBakTag = (vm) => vm.tags.some(t => t.split('=', 1)[0] === 'xo:no-bak');
package/dist/ioc/ioc.mjs CHANGED
@@ -2,6 +2,7 @@ import { buildProviderModule } from 'inversify-binding-decorators';
2
2
  import { Container, decorate, injectable } from 'inversify';
3
3
  import { Controller } from 'tsoa';
4
4
  import { RestApi } from '../rest-api/rest-api.mjs';
5
+ import { VmService } from '../vms/vm.service.mjs';
5
6
  import { XoaService } from '../xoa/xoa.service.mjs';
6
7
  const iocContainer = new Container();
7
8
  decorate(injectable(), Controller);
@@ -21,5 +22,12 @@ export function setupContainer(xoApp) {
21
22
  return new XoaService(restApi);
22
23
  })
23
24
  .inSingletonScope();
25
+ iocContainer
26
+ .bind(VmService)
27
+ .toDynamicValue(ctx => {
28
+ const restApi = ctx.container.get(RestApi);
29
+ return new VmService(restApi);
30
+ })
31
+ .inSingletonScope();
24
32
  }
25
33
  export { iocContainer };
@@ -68,3 +68,7 @@ export const pool = {
68
68
  $poolId: '355ee47d-ff4c-4924-3db2-fd86ae629676',
69
69
  _xapiRef: 'OpaqueRef:1c3f19c8-f80a-464d-9c48-a2c19d4e4fc3',
70
70
  };
71
+ export const importVm = { id: '9fe12ca3-d75d-cfb0-492e-cfd2bc6c568f' };
72
+ export const createVm = {
73
+ id: '8279e670-cb58-c048-7007-230f075becfb',
74
+ };
@@ -0,0 +1,58 @@
1
+ export const smIds = [
2
+ '/rest/v0/sms/5bfb2f8a-70f3-8cff-1748-3cd4de2153da',
3
+ '/rest/v0/sms/d3df5d0f-bac8-ed31-22e9-b7d89fb39e0e',
4
+ ];
5
+ export const partialSms = [
6
+ {
7
+ uuid: '5bfb2f8a-70f3-8cff-1748-3cd4de2153da',
8
+ name_label: 'Local EXT4 VHD and QCOW2',
9
+ SM_type: 'ext',
10
+ href: '/rest/v0/sms/5bfb2f8a-70f3-8cff-1748-3cd4de2153da',
11
+ },
12
+ {
13
+ uuid: '0d48516d-f7ad-1c36-39ea-17cfb16e04ab',
14
+ name_label: 'Local EXT4 VHD and QCOW2',
15
+ SM_type: 'ext',
16
+ href: '/rest/v0/sms/0d48516d-f7ad-1c36-39ea-17cfb16e04ab',
17
+ },
18
+ ];
19
+ export const sm = {
20
+ type: 'SM',
21
+ uuid: '5bfb2f8a-70f3-8cff-1748-3cd4de2153da',
22
+ name_description: 'SR plugin which represents disks as VHD and QCOW2 files stored on a local EXT4 filesystem, created inside an LVM volume',
23
+ name_label: 'Local EXT4 VHD and QCOW2',
24
+ SM_type: 'ext',
25
+ configuration: {
26
+ device: 'local device path (required) (e.g. /dev/sda3)',
27
+ },
28
+ vendor: 'Citrix Systems Inc',
29
+ features: {
30
+ SR_PROBE: 1,
31
+ SR_SUPPORTS_LOCAL_CACHING: 1,
32
+ SR_UPDATE: 1,
33
+ THIN_PROVISIONING: 1,
34
+ VDI_ACTIVATE: 1,
35
+ VDI_ATTACH: 1,
36
+ VDI_CLONE: 1,
37
+ VDI_CONFIG_CBT: 1,
38
+ VDI_CREATE: 1,
39
+ VDI_DEACTIVATE: 1,
40
+ VDI_DELETE: 1,
41
+ VDI_DETACH: 1,
42
+ VDI_GENERATE_CONFIG: 1,
43
+ VDI_MIRROR: 1,
44
+ VDI_READ_CACHING: 1,
45
+ VDI_RESET_ON_BOOT: 2,
46
+ VDI_RESIZE: 1,
47
+ VDI_SNAPSHOT: 1,
48
+ VDI_UPDATE: 1,
49
+ },
50
+ driver_filename: '/opt/xensource/sm/EXTSR',
51
+ required_cluster_stack: [],
52
+ supported_image_formats: [],
53
+ id: '5bfb2f8a-70f3-8cff-1748-3cd4de2153da',
54
+ pool: 'd6ba2603-7f16-0261-a33f-6e91d3aa0ec7',
55
+ poolId: 'd6ba2603-7f16-0261-a33f-6e91d3aa0ec7',
56
+ _xapiRef: 'OpaqueRef:27086ace-74d7-9f68-7465-346c7249b799',
57
+ href: '/rest/v0/sms/5bfb2f8a-70f3-8cff-1748-3cd4de2153da',
58
+ };