Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose qemu machine type read-only in VM/Template Details tab #669

Merged
merged 1 commit into from
Jun 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions locales/en/plugin__kubevirt-plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@
"Local storage (LSO)": "Local storage (LSO)",
"MAC address": "MAC address",
"MAC Address": "MAC Address",
"Machine type": "Machine type",
"Make sure to have clone permissions in the destination namespace. <2>Learn more <1></1></2>": "Make sure to have clone permissions in the destination namespace. <2>Learn more <1></1></2>",
"Manual Connection": "Manual Connection",
"Map of string keys and values that can be used to organize and categorize (scope and select) objects": "Map of string keys and values that can be used to organize and categorize (scope and select) objects",
Expand Down
8 changes: 8 additions & 0 deletions src/utils/resources/vm/utils/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,11 @@ export const getBootDisk = (vm: V1VirtualMachine): V1Disk =>
.reduce((acc, disk) => {
return acc.bootOrder < disk.bootOrder ? acc : disk;
}, getDisks(vm)?.[0]);

/**
* A selector for the QEMU machine's type
* @param {V1VirtualMachine} vm the virtual machine
* @returns {string} the machine type
*/
export const getMachineType = (vm: V1VirtualMachine): string =>
vm?.spec?.template?.spec?.domain?.machine?.type;
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import Owner from 'src/views/templates/details/tabs/details/components/Owner';
import { TemplateDetailsGridProps } from 'src/views/templates/details/tabs/details/TemplateDetailsPage';

import { useKubevirtTranslation } from '@kubevirt-utils/hooks/useKubevirtTranslation';
import { getTemplateVirtualMachineObject } from '@kubevirt-utils/resources/template';
import { getMachineType } from '@kubevirt-utils/resources/vm';
import { NO_DATA_DASH } from '@kubevirt-utils/resources/vm/utils/constants';
import { getOperatingSystemName } from '@kubevirt-utils/resources/vm/utils/operation-system/operationSystem';
import { DescriptionList } from '@patternfly/react-core';

Expand All @@ -21,6 +24,7 @@ import WorkloadProfile from './WorkloadProfile';

const TemplateDetailsLeftGrid: React.FC<TemplateDetailsGridProps> = ({ template, editable }) => {
const { t } = useKubevirtTranslation();
const machineType = getMachineType(getTemplateVirtualMachineObject(template)) || NO_DATA_DASH;

return (
<DescriptionList>
Expand All @@ -33,6 +37,7 @@ const TemplateDetailsLeftGrid: React.FC<TemplateDetailsGridProps> = ({ template,
<DescriptionItem title={t('Operating system')} content={getOperatingSystemName(template)} />
<WorkloadProfile template={template} editable={editable} />
<CPUMemory template={template} />
<DescriptionItem title={t('Machine type')} content={machineType} />
<BootMethod template={template} />
<BaseTemplate template={template} />
<CreatedAt template={template} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ import { asAccessReview, getAnnotation, getLabel } from '@kubevirt-utils/resourc
import { LABEL_USED_TEMPLATE_NAMESPACE } from '@kubevirt-utils/resources/template';
import {
DESCRIPTION_ANNOTATION,
getMachineType,
useVMIAndPodsForVM,
VM_TEMPLATE_ANNOTATION,
} from '@kubevirt-utils/resources/vm';
import { NO_DATA_DASH } from '@kubevirt-utils/resources/vm/utils/constants';
import { useGuestOS } from '@kubevirt-utils/resources/vmi';
import {
k8sPatch,
Expand Down Expand Up @@ -227,6 +229,10 @@ const VirtualMachineDetailsLeftGrid: React.FC<VirtualMachineDetailsLeftGridProps
}
data-test-id={`${vm?.metadata?.name}-cpu-memory`}
/>
<VirtualMachineDescriptionItem
descriptionData={getMachineType(vm) || NO_DATA_DASH}
descriptionHeader={t('Machine type')}
/>
<VirtualMachineDescriptionItem
descriptionData={
!canUpdateVM ? (
Expand Down