diff --git a/pkg/harvester/config/harvester-cluster.js b/pkg/harvester/config/harvester-cluster.js index 74d3e6d9..4051f90f 100644 --- a/pkg/harvester/config/harvester-cluster.js +++ b/pkg/harvester/config/harvester-cluster.js @@ -419,6 +419,7 @@ export function init($plugin, store) { HCI.PCI_DEVICE, HCI.SR_IOVGPU_DEVICE, HCI.VGPU_DEVICE, + HCI.USB_DEVICE, HCI.ADD_ONS, HCI.SECRET, HCI.SETTING @@ -752,6 +753,32 @@ export function init($plugin, store) { ] }); + virtualType({ + labelKey: 'harvester.usb.label', + group: 'advanced', + weight: 11, + name: HCI.USB_DEVICE, + namespaced: false, + route: { + name: `${ PRODUCT_NAME }-c-cluster-resource`, + params: { resource: HCI.USB_DEVICE } + }, + exact: false, + }); + + configureType(HCI.USB_DEVICE, { + isCreatable: false, + hiddenNamespaceGroupButton: true, + listGroups: [ + { + value: 'node', + field: 'groupByNode', + hideColumn: 'node', + tooltipKey: 'resourceTable.groupBy.node' + } + ] + }); + configureType(HCI.ADD_ONS, { isCreatable: false, isRemovable: false, diff --git a/pkg/harvester/config/harvester-map.js b/pkg/harvester/config/harvester-map.js index 02cbfe25..db94abac 100644 --- a/pkg/harvester/config/harvester-map.js +++ b/pkg/harvester/config/harvester-map.js @@ -68,4 +68,5 @@ export const ADD_ONS = { RANCHER_LOGGING: 'rancher-logging', RANCHER_MONITORING: 'rancher-monitoring', VM_IMPORT_CONTROLLER: 'vm-import-controller', + USB_DEVICE_CONTROLLER: 'usbdevices-controller', }; diff --git a/pkg/harvester/edit/harvesterhci.io.addon/usbdevices-controller.vue b/pkg/harvester/edit/harvesterhci.io.addon/usbdevices-controller.vue new file mode 100644 index 00000000..104d3b04 --- /dev/null +++ b/pkg/harvester/edit/harvesterhci.io.addon/usbdevices-controller.vue @@ -0,0 +1,58 @@ + + + + + diff --git a/pkg/harvester/edit/kubevirt.io.virtualmachine/VirtualMachineUSBDevices/index.vue b/pkg/harvester/edit/kubevirt.io.virtualmachine/VirtualMachineUSBDevices/index.vue new file mode 100644 index 00000000..2c3c172c --- /dev/null +++ b/pkg/harvester/edit/kubevirt.io.virtualmachine/VirtualMachineUSBDevices/index.vue @@ -0,0 +1,65 @@ + + + diff --git a/pkg/harvester/edit/kubevirt.io.virtualmachine/index.vue b/pkg/harvester/edit/kubevirt.io.virtualmachine/index.vue index 6e32c10f..4be5fc98 100644 --- a/pkg/harvester/edit/kubevirt.io.virtualmachine/index.vue +++ b/pkg/harvester/edit/kubevirt.io.virtualmachine/index.vue @@ -15,6 +15,11 @@ import Labels from '@shell/components/form/Labels'; import NodeScheduling from '@shell/components/form/NodeScheduling'; import PodAffinity from '@shell/components/form/PodAffinity'; +import AccessCredentials from './VirtualMachineAccessCredentials'; +import PciDevices from './VirtualMachinePciDevices/index'; +import VGpuDevices from './VirtualMachineVGpuDevices/index'; +import UsbDevices from './VirtualMachineUSBDevices/index'; +import RestartVMDialog from '../../dialog/RestartVMDialog'; import KeyValue from '@shell/components/form/KeyValue'; import { clear } from '@shell/utils/array'; @@ -69,10 +74,11 @@ export default { PciDevices, RestartVMDialog, UnitInput, - VirtualMachineVGpuDevices, + VGpuDevices, KeyValue, Banner, - MessageLink + MessageLink, + UsbDevices, }, mixins: [CreateEditView, VM_MIXIN], @@ -652,10 +658,14 @@ export default { - + - + + + + + diff --git a/pkg/harvester/l10n/en-us.yaml b/pkg/harvester/l10n/en-us.yaml index 3e62b765..4a1a8156 100644 --- a/pkg/harvester/l10n/en-us.yaml +++ b/pkg/harvester/l10n/en-us.yaml @@ -241,6 +241,7 @@ harvester: accessCredentials: Access Credentials pciDevices: PCI Devices vGpuDevices: vGPU Devices + usbDevices: USB Devices vmScheduling: Virtual Machine Scheduling quotas: Quotas snapshots: Snapshots @@ -1221,6 +1222,9 @@ harvester: location: Driver Location parsingSpecError: The field 'spec.valuesContent' has invalid format. + usbController: + titles: + basic: Basic loadBalancer: label: Load Balancers @@ -1360,6 +1364,14 @@ harvester: howToUseDevice: 'Use the table below to enable vGPU devices you want to use in this virtual machine.' deviceInTheSameHost: 'You can only select devices on the same host.' + usb: + label: USB Devices + noPermission: Please contact system admin to add Harvester addons first + goSetting: + prefix: The usb addon is not enabled, click + middle: here + suffix: to enable it to manage your USB devices. + harvesterVlanConfigMigrateDialog: targetClusterNetwork: label: Target Cluster Network diff --git a/pkg/harvester/list/devices.harvesterhci.io.usbdevice.vue b/pkg/harvester/list/devices.harvesterhci.io.usbdevice.vue new file mode 100644 index 00000000..3c1fa3e3 --- /dev/null +++ b/pkg/harvester/list/devices.harvesterhci.io.usbdevice.vue @@ -0,0 +1,97 @@ + + + diff --git a/pkg/harvester/mixins/harvester-vm/index.js b/pkg/harvester/mixins/harvester-vm/index.js index 76b1d923..371f9645 100644 --- a/pkg/harvester/mixins/harvester-vm/index.js +++ b/pkg/harvester/mixins/harvester-vm/index.js @@ -119,12 +119,13 @@ export default { const hasPCISchema = !!this.$store.getters[`${ inStore }/schemaFor`](HCI.PCI_DEVICE); const hasSRIOVGPUSchema = !!this.$store.getters[`${ inStore }/schemaFor`](HCI.SR_IOVGPU_DEVICE); + const hasUSBSchema = !!this.$store.getters[`${ inStore }/schemaFor`](HCI.USB_DEVICE); - const hasPCIAddon = res.addons.find(addon => addon.name === ADD_ONS.PCI_DEVICE_CONTROLLER)?.spec?.enabled === true; - const hasSriovgpuAddon = res.addons.find(addon => addon.name === ADD_ONS.NVIDIA_DRIVER_TOOLKIT_CONTROLLER)?.spec?.enabled === true; + const enabledAddons = res.addons.reduce((acc, addon) => ({ ...acc, [addon.name]: addon.spec?.enabled }), {}); - this.enabledPCI = hasPCIAddon && hasPCISchema; - this.enabledSriovgpu = hasSriovgpuAddon && hasPCIAddon && hasSRIOVGPUSchema; + this.enabledPCI = hasPCISchema && enabledAddons[ADD_ONS.PCI_DEVICE_CONTROLLER]; + this.enabledSriovgpu = hasSRIOVGPUSchema && enabledAddons[ADD_ONS.PCI_DEVICE_CONTROLLER] && enabledAddons[ADD_ONS.NVIDIA_DRIVER_TOOLKIT_CONTROLLER]; + this.enabledUSB = hasUSBSchema && enabledAddons[ADD_ONS.USB_DEVICE_CONTROLLER]; }, data() { @@ -165,6 +166,7 @@ export default { saveNetworkDataAsClearText: false, enabledPCI: false, enabledSriovgpu: false, + enabledUSB: false, immutableMode: this.realMode === _CREATE ? _CREATE : _VIEW, terminationGracePeriodSeconds: '', cpuPinning: false, diff --git a/pkg/harvester/types.ts b/pkg/harvester/types.ts index df278670..89a85789 100644 --- a/pkg/harvester/types.ts +++ b/pkg/harvester/types.ts @@ -38,6 +38,7 @@ export const HCI = { SR_IOV: 'devices.harvesterhci.io.sriovnetworkdevice', VGPU_DEVICE: 'devices.harvesterhci.io.vgpudevice', SR_IOVGPU_DEVICE: 'devices.harvesterhci.io.sriovgpudevice', + USB_DEVICE: 'devices.harvesterhci.io.usbdevice', VLAN_CONFIG: 'network.harvesterhci.io.vlanconfig', VLAN_STATUS: 'network.harvesterhci.io.vlanstatus', ADD_ONS: 'harvesterhci.io.addon',