use of org.ovirt.engine.core.common.businessentities.network.Bond in project ovirt-engine by oVirt.
the class VdsBrokerObjectsBuilder method addHostBondDevices.
private static void addHostBondDevices(VDS vds, Map<String, Object> struct) {
Map<String, Map<String, Object>> bonds = (Map<String, Map<String, Object>>) struct.get(VdsProperties.NETWORK_BONDINGS);
if (bonds != null) {
for (Entry<String, Map<String, Object>> entry : bonds.entrySet()) {
Bond bond = new Bond();
updateCommonInterfaceData(bond, vds, entry);
bond.setBonded(true);
Map<String, Object> bondProperties = entry.getValue();
if (bondProperties != null) {
bond.setMacAddress((String) bondProperties.get("hwaddr"));
if (bondProperties.get("slaves") != null) {
addBondDeviceToHost(vds, bond, (Object[]) bondProperties.get("slaves"));
}
bond.setBondOptions(parseBondOptions((Map<String, Object>) bondProperties.get("opts")));
bond.setAdPartnerMac((String) bondProperties.get("ad_partner_mac"));
bond.setActiveSlave((String) bondProperties.get("active_slave"));
}
}
}
}
use of org.ovirt.engine.core.common.businessentities.network.Bond in project ovirt-engine by oVirt.
the class HostInterfaceListModel method updateItems.
private void updateItems(Iterable<VdsNetworkInterface> source) {
ArrayList<HostInterfaceLineModel> items = new ArrayList<>();
setOriginalItems((ArrayList<VdsNetworkInterface>) source);
List<Bond> nonEmptyBonds = new ArrayList<>();
List<Nic> independentNics = new ArrayList<>();
Map<String, List<Nic>> bondToNics = new HashMap<>();
Map<String, List<Vlan>> nicToVlans = new HashMap<>();
sortNics();
classifyNics(nonEmptyBonds, independentNics, bondToNics, nicToVlans);
// create all bond models
for (Bond bond : nonEmptyBonds) {
HostInterfaceLineModel model = lineModelFromBond(bond);
items.add(model);
// add contained interface models - should exist, but check just in case
if (bondToNics.containsKey(bond.getName())) {
for (Nic nic : bondToNics.get(bond.getName())) {
model.getInterfaces().add(hostInterfaceFromNic(nic));
}
}
// add any corresponding VLAN bridge models
model.getVLans().addAll(gatherVlans(bond, nicToVlans));
}
// create all independent NIC models
for (Nic nic : independentNics) {
HostInterfaceLineModel model = lineModelFromInterface(nic);
model.getInterfaces().add(hostInterfaceFromNic(nic));
items.add(model);
// add any corresponding VLAN bridge models
model.getVLans().addAll(gatherVlans(nic, nicToVlans));
}
setItems(items);
updateActionAvailability();
}
use of org.ovirt.engine.core.common.businessentities.network.Bond in project ovirt-engine by oVirt.
the class HostInterfaceListModel method classifyNics.
private void classifyNics(List<Bond> nonEmptyBonds, List<Nic> independentNics, Map<String, List<Nic>> bondToNics, Map<String, List<Vlan>> nicToVlans) {
for (VdsNetworkInterface nic : getOriginalItems()) {
if (nic instanceof Bond) {
nonEmptyBonds.add((Bond) nic);
} else if (nic instanceof Nic) {
if (nic.getBondName() == null) {
independentNics.add((Nic) nic);
} else {
if (bondToNics.containsKey(nic.getBondName())) {
bondToNics.get(nic.getBondName()).add((Nic) nic);
} else {
List<Nic> nicList = new ArrayList<>();
nicList.add((Nic) nic);
bondToNics.put(nic.getBondName(), nicList);
}
}
} else if (nic instanceof Vlan) {
String nameWithoutVlan = nic.getBaseInterface();
if (nicToVlans.containsKey(nameWithoutVlan)) {
nicToVlans.get(nameWithoutVlan).add((Vlan) nic);
} else {
List<Vlan> vlanList = new ArrayList<>();
vlanList.add((Vlan) nic);
nicToVlans.put(nameWithoutVlan, vlanList);
}
}
}
}
use of org.ovirt.engine.core.common.businessentities.network.Bond in project ovirt-engine by oVirt.
the class ExecuteNetworkCommandInNetworkOperationTest method joinBondsTest.
/*
* At the beginning there were two bonds (one with NetworkAttachment), which, after being introduced to each other,
* formed a firm bond adopting NetworkAttachment as their own.
*/
private void joinBondsTest(boolean resusingName) {
addBondToParamsAndModel(existingBond, bondNetworkInterfaceModelA, Collections.emptyList());
NetworkAttachment networkAttachment = createAttachmentOnNetworkModelAndUpdateParams(bondNetworkInterfaceModelA, logicalNetworkModelOfNetworkA);
// $NON-NLS-1$
Bond bondB = createBond(Guid.newGuid(), "bondB", Arrays.asList(nicC, nicD)).toBond();
addBondToParamsAndModel(bondB, bondNetworkInterfaceModelB, Collections.singletonList(logicalNetworkModelOfNetworkA));
initOrginalBondNameToIdMap(bondNetworkInterfaceModelA.getCreateOrUpdateBond(), bondNetworkInterfaceModelB.getCreateOrUpdateBond());
when(bondNetworkInterfaceModelA.getItems()).thenReturn(Collections.singletonList(logicalNetworkModelOfNetworkA));
when(bondNetworkInterfaceModelA.getSlaves()).thenReturn(Arrays.asList(networkInterfaceModelOfNicA, networkInterfaceModelOfNicB));
when(bondNetworkInterfaceModelB.getItems()).thenReturn(Collections.emptyList());
when(bondNetworkInterfaceModelB.getSlaves()).thenReturn(Arrays.asList(networkInterfaceModelOfNicC, networkInterfaceModelOfNicD));
if (resusingName) {
newlyCreatedBond.setName(existingBondName);
}
NetworkOperation.JOIN_BONDS.getTarget().executeNetworkCommand(bondNetworkInterfaceModelA, bondNetworkInterfaceModelB, dataFromHostSetupNetworksModel, newlyCreatedBond);
// NetworkOperation.JOIN_BONDS only detaches the attachments, the attachments are being re-attached only in
// HostSetupNetworksModel (after clicking ok in the new bond dialog)
assertThat(dataFromHostSetupNetworksModel.getNetworkAttachments().size(), is(0));
assertThat(dataFromHostSetupNetworksModel.getRemovedNetworkAttachments().size(), is(1));
Guid removeNetworkAttachmentId = dataFromHostSetupNetworksModel.getRemovedNetworkAttachments().iterator().next();
// $NON-NLS-1$
assertThat("id mismatch", removeNetworkAttachmentId, is(networkAttachment.getId()));
assertThat(dataFromHostSetupNetworksModel.getBonds().size(), is(1));
CreateOrUpdateBond newOrModifiedBond = dataFromHostSetupNetworksModel.getBonds().iterator().next();
assertBond(newOrModifiedBond, resusingName ? existingBondId : null, Arrays.asList(nicA, nicB, nicC, nicD));
assertThat(dataFromHostSetupNetworksModel.getRemovedBonds().size(), is(resusingName ? 1 : 2));
// $NON-NLS-1$
assertThat("id mismatch", dataFromHostSetupNetworksModel.getRemovedBonds().contains(existingBondId), is(!resusingName));
// $NON-NLS-1$
assertThat("id mismatch", dataFromHostSetupNetworksModel.getRemovedBonds().contains(bondB.getId()), is(true));
}
use of org.ovirt.engine.core.common.businessentities.network.Bond in project ovirt-engine by oVirt.
the class HostNetworkInterfaceBondedListViewItem method createBondInterfaceStatusPanel.
protected IsWidget createBondInterfaceStatusPanel(boolean isUp, VDS host) {
Bond bond = (Bond) getEntity().getInterface();
if (!isAdPartnerMacValid(bond, host)) {
WidgetTooltip tooltip = new WidgetTooltip(new IconStatusPanel(PatternflyConstants.PFICON_WARNING_TRIANGLE_O, PatternflyConstants.PFICON));
tooltip.setHtml(templates.italicWordWrapMaxWidth(constants.bondInMode4HasNoPartnerMac()));
return tooltip;
} else {
return super.createInterfaceStatusPanel(isUp);
}
}
Aggregations