use of org.ovirt.engine.core.common.businessentities.network.Bond in project ovirt-engine by oVirt.
the class NicLabelValidatorTest method labelBeingAttachedToValidBondAttachedBondBecomingNotValid.
@Test
public void labelBeingAttachedToValidBondAttachedBondBecomingNotValid() {
Bond existingBond = new Bond("bond");
existingBond.setSlaves(Arrays.asList("slave1", "slave2"));
HostSetupNetworksParameters params = createHostSetupNetworksParams();
CreateOrUpdateBond updatedBond = new CreateOrUpdateBond();
updatedBond.setName(existingBond.getName());
updatedBond.setSlaves(new HashSet<>());
params.getCreateOrUpdateBonds().add(updatedBond);
assertLabelBeingAttachedToValidBondFailed(params, existingBond);
}
use of org.ovirt.engine.core.common.businessentities.network.Bond in project ovirt-engine by oVirt.
the class HostSetupNetworksValidatorTest method validateBondModeForLabeledVmNetwork.
private void validateBondModeForLabeledVmNetwork(BondMode bondMode) {
String bondName = "bondName";
String networkName = "vmNetwork";
String label = "label";
Bond bond = createBond(bondName, networkName, null);
bond.setLabels(new HashSet<>(Collections.singletonList(label)));
bond.setBondOptions(bondMode.getConfigurationValue());
Network vmNetwork = createNetworkWithName(networkName);
vmNetwork.setVmNetwork(true);
vmNetwork.setLabel(label);
NetworkAttachment vmNetworkNetworkAttachment = createNetworkAttachment(vmNetwork, bond);
HostSetupNetworksValidator validator = new HostSetupNetworksValidatorBuilder().setParams(new ParametersBuilder().addBonds(CreateOrUpdateBond.fromBond(bond))).addNetworks(vmNetwork).addExistingInterfaces(bond).build();
List<NetworkAttachment> attachmentsToConfigure = Collections.singletonList(vmNetworkNetworkAttachment);
ValidationResult result = validator.validateBondModeVsNetworksAttachedToIt(attachmentsToConfigure);
if (bondMode.isBondModeValidForVmNetwork()) {
collector.checkThat(result, isValid());
} else {
collector.checkThat(result, failsWith(EngineMessage.INVALID_BOND_MODE_FOR_BOND_WITH_LABELED_VM_NETWORK, ReplacementUtils.createSetVariableString(HostSetupNetworksValidator.VAR_BOND_NAME, bondName), ReplacementUtils.createSetVariableString(HostSetupNetworksValidator.VAR_NETWORK_NAME, networkName), ReplacementUtils.createSetVariableString(HostSetupNetworksValidator.VAR_LABEL, label)));
}
}
use of org.ovirt.engine.core.common.businessentities.network.Bond in project ovirt-engine by oVirt.
the class CreateOrUpdateBond method toBond.
public Bond toBond() {
Bond bond = new Bond();
bond.setId(getId());
bond.setName(getName());
bond.setSlaves(new ArrayList<>(getSlaves()));
bond.setBondOptions(getBondOptions());
return bond;
}
use of org.ovirt.engine.core.common.businessentities.network.Bond in project ovirt-engine by oVirt.
the class HostNicMapperTest method testBondMapping.
@Test
public void testBondMapping() {
HostNic model = new HostNic();
model.setId(Guid.newGuid().toString());
model.setName(RandomUtils.instance().nextString(10));
model.setBonding(new Bonding());
model.getBonding().setSlaves(new HostNics());
HostNic slaveA = new HostNic();
slaveA.setName(RandomUtils.instance().nextString(10));
model.getBonding().getSlaves().getHostNics().add(slaveA);
Bond entity = HostNicMapper.map(model, null);
assertNotNull(entity);
assertEquals(model.getId(), entity.getId().toString());
assertEquals(model.getName(), entity.getName());
assertEquals(model.getBonding().getSlaves().getHostNics().size(), entity.getSlaves().size());
for (HostNic slave : model.getBonding().getSlaves().getHostNics()) {
assertTrue(entity.getSlaves().contains(slave.getName()));
}
}
use of org.ovirt.engine.core.common.businessentities.network.Bond in project ovirt-engine by oVirt.
the class HostSetupNetworksModel method initCreateOrUpdateBondParameters.
private void initCreateOrUpdateBondParameters() {
NetworkCommonUtils.fillBondSlaves(allExistingNics);
for (VdsNetworkInterface nic : allExistingNics) {
if (nic.isBond()) {
getHostSetupNetworksParametersData().getBonds().add(CreateOrUpdateBond.fromBond((Bond) nic));
}
}
hostSetupNetworksParametersData.setOriginalBondsByName(Entities.entitiesByName(hostSetupNetworksParametersData.getBonds()));
}
Aggregations