Skip to content

Commit

Permalink
deprecate none suported network cards
Browse files Browse the repository at this point in the history
  • Loading branch information
yaacov committed Aug 31, 2020
1 parent bdfbf9b commit a43cde8
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 13 deletions.
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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');
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;

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

type NetworkInterfaceModelConstructorOpts = {
isDeprecated?: boolean;
};

0 comments on commit a43cde8

Please sign in to comment.