Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

Add binding type to NICs #248

Merged
merged 1 commit into from
Apr 2, 2019
Merged
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
28 changes: 17 additions & 11 deletions frontend/public/kubevirt/components/nic.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Kebab, LoadingInline } from './utils/okdutils';
import { List, ColHead, ListHeader, ResourceRow } from './factory/okdfactory';
import { DASHES, BUS_VIRTIO, NIC } from './utils/constants';
import { deleteDeviceModal } from './modals/delete-device-modal';
import { getNetworks, CreateNicRow, getAddNicPatch, POD_NETWORK, settingsValue, getResource, addPrefixToPatch } from 'kubevirt-web-ui-components';
import { getNetworks, CreateNicRow, getAddNicPatch, POD_NETWORK, settingsValue, getResource, addPrefixToPatch, getInterfaceBinding } from 'kubevirt-web-ui-components';
import { NetworkAttachmentDefinitionModel, VirtualMachineModel, VmTemplateModel } from '../models';
import { WithResources } from './utils/withResources';
import { k8sPatch } from '../module/okdk8s';
Expand Down Expand Up @@ -39,32 +39,36 @@ const getActions = (vm, nic, vmTemplate, patchPrefix) => {
return actions.map(a => a(vm, nic, vmTemplate, patchPrefix));
};

const visibleRowStyle = 'col-lg-3 col-md-3 col-sm-3 col-xs-4';
const hiddenRowStyle = 'col-lg-3 col-md-3 col-sm-3 hidden-xs';
const mainRowStyle = 'col-lg-3';
const otherRowStyle = 'col-lg-2';

const getVmNicModel = vm => {
const networks = getNetworks(vm);
return networks.length > 0 ? _.get(networks[0], 'model', BUS_VIRTIO) : BUS_VIRTIO;
};

const NicHeader = props => <ListHeader>
<ColHead {...props} className={visibleRowStyle} sortField="name">Name</ColHead>
<ColHead {...props} className={visibleRowStyle} sortField="model">Model</ColHead>
<ColHead {...props} className={visibleRowStyle} sortField="network">Network</ColHead>
<ColHead {...props} className={hiddenRowStyle} sortField="macAddress">MAC Address</ColHead>
<ColHead {...props} className={mainRowStyle} sortField="name">Name</ColHead>
<ColHead {...props} className={mainRowStyle} sortField="model">Model</ColHead>
<ColHead {...props} className={otherRowStyle} sortField="network">Network</ColHead>
<ColHead {...props} className={otherRowStyle} sortField="macAddress">Binding Method</ColHead>
<ColHead {...props} className={otherRowStyle} sortField="macAddress">MAC Address</ColHead>
</ListHeader>;

export const VmNicRow = ({ nic }) => <ResourceRow obj={nic}>
<div className={visibleRowStyle}>
<div className={mainRowStyle}>
{nic.name}
</div>
<div className={visibleRowStyle}>
<div className={mainRowStyle}>
{nic.model || BUS_VIRTIO}
</div>
<div className={visibleRowStyle}>
<div className={otherRowStyle}>
{getNetworkName(nic.network)}
</div>
<div className={hiddenRowStyle}>
<div className={otherRowStyle}>
{nic.binding || DASHES}
</div>
<div className={otherRowStyle}>
{nic.macAddress || DASHES}
</div>
<div className="dropdown-kebab-pf">
Expand Down Expand Up @@ -135,6 +139,7 @@ export class Nic extends React.Component {
nicType: NIC_TYPE_VM,
vmTemplate: this.props.vmTemplate,
patchPrefix: this.props.patchPrefix,
binding: getInterfaceBinding(nic),
};
}));
return nics;
Expand Down Expand Up @@ -173,6 +178,7 @@ export class Nic extends React.Component {
model: settingsValue(newNic, 'model'),
network: settingsValue(newNic, 'network'),
mac: settingsValue(newNic, 'mac'),
binding: settingsValue(newNic, 'binding'),
};

const addNicPatch = getAddNicPatch(vm, nic).map(patch => addPrefixToPatch(patchPrefix, patch));
Expand Down