use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.
the class HostSetupNetworksValidatorTest method testValidRemovedBondsWhenBondIsRequired.
@Test
public void testValidRemovedBondsWhenBondIsRequired() throws Exception {
String nicName = "nicName";
bond.setName(nicName);
HostSetupNetworksValidator validator = new HostSetupNetworksValidatorBuilder().setParams(new ParametersBuilder().addRemovedBonds(bond.getId())).addExistingInterfaces(Collections.singletonList(bond)).build();
NetworkAttachment requiredNetworkAttachment = new NetworkAttachment();
requiredNetworkAttachment.setNicName(nicName);
List<String> replacements = new ArrayList<>();
EngineMessage engineMessage = EngineMessage.BOND_USED_BY_NETWORK_ATTACHMENTS;
replacements.add(ReplacementUtils.getVariableAssignmentString(engineMessage, nicName));
// null -- new network attachment with null id.
replacements.addAll(replaceWith(HostSetupNetworksValidator.VAR_ATTACHMENT_IDS, Collections.<Guid>singletonList(null)));
assertThat(validator.validRemovedBonds(Collections.singletonList(requiredNetworkAttachment)), failsWith(engineMessage, replacements));
}
use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.
the class HostSetupNetworksValidatorTest method modifiedAttachmentNotRemovedAttachmentModifiedAndRemoved.
@Test
public void modifiedAttachmentNotRemovedAttachmentModifiedAndRemoved() {
NetworkAttachment modifiedAttachment = createNetworkAttachment(new Network());
HostSetupNetworksValidator validator = new HostSetupNetworksValidatorBuilder().setParams(new ParametersBuilder().addRemovedNetworkAttachments(modifiedAttachment)).build();
assertThat(validator.modifiedAttachmentNotRemoved(modifiedAttachment), failsWith(EngineMessage.NETWORK_ATTACHMENT_IN_BOTH_LISTS, ReplacementUtils.createSetVariableString("NETWORK_ATTACHMENT_IN_BOTH_LISTS_ENTITY", modifiedAttachment.getId().toString())));
}
use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.
the class HostSetupNetworksValidatorTest method createValidatorForTestingValidateQosOverridden.
private HostSetupNetworksValidator createValidatorForTestingValidateQosOverridden(Network network) {
NetworkAttachment networkAttachment = new NetworkAttachment();
networkAttachment.setNetworkId(network.getId());
networkAttachment.setHostNetworkQos(new AnonymousHostNetworkQos());
return new HostSetupNetworksValidatorBuilder().setParams(new ParametersBuilder().addNetworkAttachments(networkAttachment)).addNetworks(network).build();
}
use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.
the class HostSetupNetworksValidatorTest method testAddNetworkToNicAlongWithAddingItIntoBond.
// TODO MM: same test for vlan.
@Test
public void testAddNetworkToNicAlongWithAddingItIntoBond() {
Network networkA = createNetworkWithName("networkA");
VdsNetworkInterface nicA = createNic("nicA");
VdsNetworkInterface nicB = createNic("nicB");
NetworkAttachment networkAttachment = createNetworkAttachment(networkA, (Guid) null);
networkAttachment.setNicId(nicA.getId());
networkAttachment.setNicName(nicA.getName());
networkAttachment.setNetworkId(networkA.getId());
networkAttachment.setNetworkName(networkA.getName());
CreateOrUpdateBond createOrUpdateBond = createNewCreateOrUpdateBond(Guid.newGuid(), "bond1", nicA.getName(), nicB.getName());
addNetworkIdToNetworkDaoMock(networkA);
addNetworkToClusterDaoMock(networkA.getId());
HostSetupNetworksValidator validator = new HostSetupNetworksValidatorBuilder().setParams(new ParametersBuilder().addNetworkAttachments(networkAttachment).addBonds(createOrUpdateBond).build()).addExistingInterfaces(nicA, nicB).addNetworks(networkA).build();
ValidationResult validate = validator.validate();
assertThat(validate, not(isValid()));
EngineMessage engineMessage = EngineMessage.NETWORK_INTERFACE_ADDED_TO_BOND_AND_NETWORK_IS_ATTACHED_TO_IT_AT_THE_SAME_TIME;
assertThat(validate, failsWith(engineMessage, ReplacementUtils.getVariableAssignmentString(engineMessage, nicA.getName()), ReplacementUtils.createSetVariableString(HostSetupNetworksValidator.VAR_NETWORK_NAME, networkA.getName())));
}
use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.
the class HostSetupNetworksValidatorTest method testInvalidNetworkAttachmentIpConfiguration.
@Test
public void testInvalidNetworkAttachmentIpConfiguration() {
HostSetupNetworksValidator validator = initValidator();
NetworkAttachment networkAttachment = validator.getAttachmentsToConfigure().iterator().next();
Collection<String> replacements = createReplacement(networkAttachment);
EngineMessage engineMessage = EngineMessage.NETWORK_ATTACHMENT_MISSING_IP_CONFIGURATION;
initMockNetworkAttachmentIpConfigurationValidator(engineMessage, replacements);
assertThat(validator.validNewOrModifiedNetworkAttachments(), failsWith(engineMessage, replacements));
}
Aggregations