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

Bug 1869620: kubevirt support only e1000e and virtio #6479

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -257,15 +257,17 @@ export const NICModal = withHandlePromise((props: NICModalProps) => {
isDisabled={isDisabled('model') || interfaceType === NetworkInterfaceType.SRIOV}
>
<FormSelectPlaceholderOption isDisabled placeholder="--- Select Model ---" />
{NetworkInterfaceModel.getAll().map((ifaceModel) => {
return (
<FormSelectOption
key={ifaceModel.getValue()}
value={ifaceModel.getValue()}
label={ifaceModel.toString()}
/>
);
})}
{NetworkInterfaceModel.getAll()
.filter((ifaceModel) => !ifaceModel.isDeprecated())
.map((ifaceModel) => {
return (
<FormSelectOption
key={ifaceModel.getValue()}
value={ifaceModel.getValue()}
label={ifaceModel.toString()}
/>
);
})}
</FormSelect>
</FormRow>
<Network
Expand Down
Expand Up @@ -4,11 +4,21 @@ import { READABLE_VIRTIO } from '../constants';

export class NetworkInterfaceModel extends ObjectEnum<string> {
static readonly VIRTIO = new NetworkInterfaceModel('virtio');
static readonly E1000 = new NetworkInterfaceModel('e1000');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they are still valid values (you can still have a VM with these models). Can you please just mark them as not supported? Similar to what we do in DiskType enum? And filter them in places where we use them.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using the deprecation logic like in disks :-)

static readonly E1000 = new NetworkInterfaceModel('e1000', { isDeprecated: true });
static readonly E1000E = new NetworkInterfaceModel('e1000e');
static readonly NE2kPCI = new NetworkInterfaceModel('ne2kPCI');
static readonly PCNET = new NetworkInterfaceModel('pcnet');
static readonly RTL8139 = new NetworkInterfaceModel('rtl8139');
static readonly NE2kPCI = new NetworkInterfaceModel('ne2kPCI', { isDeprecated: true });
static readonly PCNET = new NetworkInterfaceModel('pcnet', { isDeprecated: true });
static readonly RTL8139 = new NetworkInterfaceModel('rtl8139', { isDeprecated: true });

private readonly deprecated: boolean;

protected constructor(
value: string,
{ isDeprecated = false }: NetworkInterfaceModelConstructorOpts = {},
) {
super(value);
this.deprecated = isDeprecated;
}

private static readonly ALL = Object.freeze(
ObjectEnum.getAllClassEnumProperties<NetworkInterfaceModel>(NetworkInterfaceModel),
Expand All @@ -27,10 +37,16 @@ export class NetworkInterfaceModel extends ObjectEnum<string> {
static fromString = (model: string): NetworkInterfaceModel =>
NetworkInterfaceModel.stringMapper[model];

isDeprecated = () => this.deprecated;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we rather call it isSupported since the value still can be used (but shouldn't in the UI)? This is a probably different semantic than floppy.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok :-)


toString() {
if (this === NetworkInterfaceModel.VIRTIO) {
return READABLE_VIRTIO;
}
return this.value;
}
}

type NetworkInterfaceModelConstructorOpts = {
isDeprecated?: boolean;
};