Skip to content

Commit

Permalink
Get PVC recomended size from template
Browse files Browse the repository at this point in the history
  • Loading branch information
yaacov committed Jan 20, 2021
1 parent 16ef2d5 commit 632944a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,10 @@ export const UploadPVCForm: React.FC<UploadPVCFormProps> = ({
if (operatingSystem?.baseImageNamespace) {
setNamespace(operatingSystem.baseImageNamespace);
}
if (operatingSystem?.baseImageRecomendedSize) {
setRequestSizeValue(operatingSystem?.baseImageRecomendedSize[0]);
setRequestSizeUnit(operatingSystem?.baseImageRecomendedSize[1]);
}
};

React.useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ export const resolveDefaultVMTemplate = (params: DefaultVMLikeEntityParams): Tem
}),
)
.removeStorage('rootdisk')
// eslint-disable-next-line no-template-curly-in-string
.removeStorage('${NAME}')
.removeStorage(VM_TEMPLATE_NAME_PARAMETER)
.prependStorage({
disk: new DiskWrapper()
.init({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as _ from 'lodash';
import { TemplateKind } from '@console/internal/module/k8s';
import { getLabel } from '@console/shared';
import { getLabel, getName } from '@console/shared';
import {
CloudInitDataHelper,
CloudInitDataFormKeys,
Expand Down Expand Up @@ -36,9 +36,11 @@ import { convertToBaseValue, humanizeBinaryBytes } from '@console/internal/compo
import { isTemplateSourceError, TemplateSourceStatus } from '../../statuses/template/types';
import { vCPUCount } from '../vm/cpu';
import { BootSourceState } from '../../components/create-vm/forms/boot-source-form-reducer';
import { stringValueUnitSplit } from '../../components/form/size-unit-utils';
import { VMWrapper } from '../../k8s/wrapper/vm/vm-wrapper';
import { DiskWrapper } from '../../k8s/wrapper/vm/disk-wrapper';
import { getDataVolumeStorageSize } from '../dv/selectors';
import { VM_TEMPLATE_NAME_PARAMETER } from '../../constants';

export const getTemplatesWithLabels = (templates: TemplateKind[], labels: string[]) => {
const requiredLabels = labels.filter((label) => label);
Expand Down Expand Up @@ -108,12 +110,16 @@ export const getTemplateOperatingSystems = (templates: TemplateKind[]) => {
(t) =>
!!Object.keys(getAnnotations(t, {})).find((annotation) => annotation === nameAnnotation),
);
const vm = selectVM(template);
const dvTemplates = getDataVolumeTemplates(vm);
const dv = dvTemplates.find((dvt) => getName(dvt) === VM_TEMPLATE_NAME_PARAMETER);

return {
id: osId,
name: getAnnotation(template, nameAnnotation),
baseImageName: getParameterValue(template, TEMPLATE_BASE_IMAGE_NAME_PARAMETER),
baseImageNamespace: getParameterValue(template, TEMPLATE_BASE_IMAGE_NAMESPACE_PARAMETER),
baseImageRecomendedSize: dv && stringValueUnitSplit(getDataVolumeStorageSize(dv)),
};
}),
);
Expand Down
1 change: 1 addition & 0 deletions frontend/packages/kubevirt-plugin/src/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ export type OperatingSystemRecord = {
name: string;
baseImageName?: string;
baseImageNamespace?: string;
baseImageRecomendedSize?: any;
};

0 comments on commit 632944a

Please sign in to comment.