Compare commits

..

3 Commits

Author SHA1 Message Date
Florent Beauchamp
9797e6aecf test(xo-vmdk-to-vhd): fix reference file path
the xsd is not bundled in dist, the tests are run from
the dist folder
2024-02-22 15:36:29 +00:00
mathieuRA
aefcce45ff feat(xo-server/pusb): implement methods for USB passthrough 2024-02-22 14:58:55 +01:00
mathieuRA
367fb4d8a6 feat(xo-server): implement PUSB in xapi-object-to-xo 2024-02-22 14:58:55 +01:00
5 changed files with 47 additions and 24 deletions

View File

@@ -282,33 +282,20 @@ export default class Esxi extends EventEmitter {
const networks = []
for (const key of Object.keys(vmx)) {
const matches = key.match(/^(scsi|ide|ethernet)[0-9]+$/)
if (matches === null) {
continue
}
const channelType = matches[1]
if (channelType === 'ide' || channelType === 'scsi') {
const diskChannel = vmx[key]
for (const diskIndex in Object.values(diskChannel)) {
const disk = diskChannel[diskIndex]
if (typeof disk !== 'object') {
if (key.match('^scsi([0-9]+)$') !== null) {
const scsiChannel = vmx[key]
for (const diskIndex in Object.values(scsiChannel)) {
const disk = scsiChannel[diskIndex]
if (typeof disk !== 'object' || disk.deviceType !== 'scsi-hardDisk') {
continue
}
// can be something other than a disk, like a controller card
if (channelType === 'scsi' && disk.deviceType !== 'scsi-hardDisk') {
continue
}
// ide hard disk don't have deviceType, but cdroms have one
if (channelType === 'ide' && disk.deviceType === 'atapi-cdrom') {
continue
}
disks.push({
...(await this.#inspectVmdk(dataStores, dataStore, dirname(vmxPath), disk.fileName)),
node: `${key}:${diskIndex}`,
})
}
} else if (channelType === 'ethernet') {
}
if (key.match('^ethernet([0-9]+)$') !== null) {
const ethernet = vmx[key]
networks.push({
@@ -328,7 +315,7 @@ export default class Esxi extends EventEmitter {
for (const diskIndex in snapshot.disks) {
const fileName = snapshot.disks[diskIndex].fileName
snapshot.disks[diskIndex] = {
node: snapshot.disks[diskIndex]?.node, // 'scsi0:0' , 'ide0:0', ...,
node: snapshot.disks[diskIndex]?.node, // 'scsi0:0',
...(await this.#inspectVmdk(dataStores, dataStore, dirname(vmxPath), fileName)),
}
}

View File

@@ -23,7 +23,6 @@
- [Remotes] Correctly clear error when the remote is tested with success
- [Import/VMWare] Fix importing last snapshot (PR [#7370](https://github.com/vatesfr/xen-orchestra/pull/7370))
- [Host/Reboot] Fix false positive warning when restarting an host after updates (PR [#7366](https://github.com/vatesfr/xen-orchestra/pull/7366))
- [Import/VMWare] Handle VMs with IDE disks
### Packages to release
@@ -43,7 +42,6 @@
- @xen-orchestra/backups patch
- @xen-orchestra/fs patch
- @xen-orchestra/vmware-explorer patch
- @xen-orchestra/xapi patch
- vhd-lib patch
- xo-server minor

View File

@@ -0,0 +1,27 @@
export async function scan({ host }) {
await this.getXapi(host).call('PUSB.scan', host._xapiRef)
}
scan.params = {
host: { type: 'string' },
}
scan.resolve = {
host: ['host', 'host', 'operate'],
}
export async function set({ pusb, enabled }) {
const xapi = this.getXapi(pusb)
if (enabled !== undefined && enabled !== pusb.passthroughEnabled) {
await xapi.call('PUSB.set_passthrough_enabled', pusb._xapiRef, enabled)
}
}
set.params = {
id: { type: 'string' },
enabled: { type: 'boolean', optional: true },
}
set.resolve = {
pusb: ['id', 'PUSB', 'administrate'],
}

View File

@@ -889,6 +889,17 @@ const TRANSFORMS = {
vm: link(obj, 'VM'),
}
},
pusb(obj) {
return {
type: 'PUSB',
description: obj.description,
host: link(obj, 'host'),
passthroughEnabled: obj.passthrough_enabled,
usbGroup: link(obj, 'USB_group'),
}
},
}
// ===================================================================

View File

@@ -99,7 +99,7 @@ test('An ova file is generated correctly', async () => {
try {
await execXmllint(xml, [
'--schema',
path.join(__dirname, 'ova-schema', 'dsp8023_1.1.1.xsd'),
path.join(__dirname, '..', 'src', 'ova-schema', 'dsp8023_1.1.1.xsd'),
'--noout',
'--nonet',
'-',