Skip to content

Commit

Permalink
Merge pull request #7205 from rawagner/vmt_clone_boot
Browse files Browse the repository at this point in the history
Show 'Clone and boot' if VMT disk will be cloned
  • Loading branch information
openshift-merge-robot committed Nov 25, 2020
2 parents e20029f + c98f4ba commit c3a6a76
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 18 deletions.
Expand Up @@ -196,7 +196,7 @@
"No Active Users": "No Active Users",
"Pending changes": "Pending changes",
"No virtual machines found": "No virtual machines found",
"See the <1>templates tab</1> to quickly create a virtual machine from the available templates.": "See the <1>templates tab</1> to quickly create a virtual machine from the available templates.",
"See the <2>templates tab</2> to quickly create a virtual machine from the available templates.": "See the <2>templates tab</2> to quickly create a virtual machine from the available templates.",
"Create virtual machine": "Create virtual machine",
"Virtual Machine Instance {{name}}": "Virtual Machine Instance {{name}}",
"Consider using a Virtual Machine that will provide additional management capabilities to a VirtualMachineInstance inside the cluster.": "Consider using a Virtual Machine that will provide additional management capabilities to a VirtualMachineInstance inside the cluster.",
Expand Down
Expand Up @@ -177,6 +177,7 @@ export const CreateVMForm: React.FC<CreateVMFormProps> = ({
name={customSource.pvcName?.value}
namespace={customSource.pvcNamespace?.value}
isCDRom={cdRom}
clone
/>
);
break;
Expand Down
Expand Up @@ -94,11 +94,14 @@ const DeleteSourceButton: React.FC<DeleteSourceButtonProps> = ({ template, sourc
type ContainerSourceProps = {
container: string;
isCDRom: boolean;
clone?: boolean;
};

export const ContainerSource: React.FC<ContainerSourceProps> = ({ container, isCDRom }) => (
export const ContainerSource: React.FC<ContainerSourceProps> = ({ container, isCDRom, clone }) => (
<Stack>
<StackItem className="text-secondary">Boot from {isCDRom ? 'CD-ROM' : 'disk'}</StackItem>
<StackItem className="text-secondary">
{clone ? 'Clone and boot' : 'Boot'} from {isCDRom ? 'CD-ROM' : 'disk'}
</StackItem>
<StackItem>Container {container}</StackItem>
</Stack>
);
Expand All @@ -121,11 +124,14 @@ type PVCSourceProps = {
name: string;
namespace: string;
isCDRom: boolean;
clone?: boolean;
};

export const PVCSource: React.FC<PVCSourceProps> = ({ name, namespace, isCDRom }) => (
export const PVCSource: React.FC<PVCSourceProps> = ({ name, namespace, isCDRom, clone }) => (
<Stack>
<StackItem className="text-secondary">Boot from {isCDRom ? 'CD-ROM' : 'disk'}</StackItem>
<StackItem className="text-secondary">
{clone ? 'Clone and boot' : 'Boot'} from {isCDRom ? 'CD-ROM' : 'disk'}
</StackItem>
<StackItem>
<ResourceLink kind={PersistentVolumeClaimModel.kind} name={name} namespace={namespace} />
</StackItem>
Expand Down Expand Up @@ -161,6 +167,14 @@ export const SourceDescription: React.FC<SourceDescriptionProps> = ({ sourceStat
const { pvc, source, container, dvTemplate, pxe, isCDRom } = sourceStatus;
switch (source) {
case SOURCE_TYPE.BASE_IMAGE:
return (
<PVCSource
name={pvc.metadata.name}
namespace={pvc.metadata.namespace}
isCDRom={isCDRom}
clone
/>
);
case SOURCE_TYPE.PVC:
case SOURCE_TYPE.DATA_VOLUME:
return (
Expand All @@ -184,6 +198,7 @@ export const SourceDescription: React.FC<SourceDescriptionProps> = ({ sourceStat
name={dvWrapper.getPesistentVolumeClaimName()}
namespace={dvWrapper.getPesistentVolumeClaimNamespace()}
isCDRom={isCDRom}
clone
/>
);
default:
Expand Down
7 changes: 5 additions & 2 deletions frontend/packages/kubevirt-plugin/src/components/vms/vm.tsx
Expand Up @@ -193,8 +193,11 @@ const VMListEmpty: React.FC = () => {
</Title>
<EmptyStateBody>
<Trans ns="kubevirt-plugin">
See the <Link to={`${location.pathname}/templates`}>templates tab</Link> to quickly create
a virtual machine from the available templates.
See the{' '}
<Link to={`${location.pathname}${location.pathname.endsWith('/') ? '' : '/'}templates`}>
templates tab
</Link>{' '}
to quickly create a virtual machine from the available templates.
</Trans>
</EmptyStateBody>
<Button
Expand Down
Expand Up @@ -152,20 +152,13 @@ export const getTemplateSizeRequirement = (
? convertToBaseValue(customSource.pvcSize?.value)
: convertToBaseValue(`${customSource.size?.value}${customSource.size?.value.unit}`);
isCDRom = customSource.cdRom?.value;
} else if (
isCommonTemplate(template) &&
!isTemplateSourceError(templateSource) &&
templateSource?.pvc
) {
} else if (!isTemplateSourceError(templateSource) && templateSource?.pvc) {
sourceSize = convertToBaseValue(templateSource.pvc.spec.resources.requests.storage);
isCDRom =
isCommonTemplate(template) &&
(templateSource.dataVolume || templateSource.pvc)?.metadata.labels?.[LABEL_CDROM_SOURCE] ===
'true';
} else if (
!isCommonTemplate(template) &&
!isTemplateSourceError(templateSource) &&
templateSource.dvTemplate
) {
'true';
} else if (!isTemplateSourceError(templateSource) && templateSource.dvTemplate) {
sourceSize = convertToBaseValue(getDataVolumeStorageSize(templateSource.dvTemplate));
}

Expand Down

0 comments on commit c3a6a76

Please sign in to comment.