use of org.ovirt.engine.core.common.action.CreateOrUpdateBond in project ovirt-engine by oVirt.
the class NicNameNicIdCompleterTest method testProperBondBindingToNicNameAndNicIdAccessors.
@Test
public void testProperBondBindingToNicNameAndNicIdAccessors() {
CreateOrUpdateBond createOrUpdateBond = new CreateOrUpdateBond();
createOrUpdateBond.setName("nic name");
createOrUpdateBond.setId(Guid.newGuid());
NicNameAndNicIdAccessors accessors = new NicNameAndNicIdAccessors.FromCreateOrUpdateBondData(createOrUpdateBond);
assertThat(accessors.getId(), is(createOrUpdateBond.getId()));
assertThat(accessors.getName(), is(createOrUpdateBond.getName()));
accessors.setId(Guid.newGuid());
accessors.setName("another name");
assertThat(createOrUpdateBond.getId(), is(accessors.getId()));
assertThat(createOrUpdateBond.getName(), is(accessors.getName()));
}
use of org.ovirt.engine.core.common.action.CreateOrUpdateBond 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.action.CreateOrUpdateBond in project ovirt-engine by oVirt.
the class HostSetupNetworksValidatorTest method testValidModifiedBondsFailsWhenReferencingExistingNonBondInterface.
@Test
public void testValidModifiedBondsFailsWhenReferencingExistingNonBondInterface() throws Exception {
CreateOrUpdateBond createOrUpdateBond = createNewCreateOrUpdateBondWithNameAndId();
final EngineMessage engineMessage = EngineMessage.NETWORK_INTERFACE_IS_NOT_BOND;
ValidationResult notABondValidationResult = new ValidationResult(engineMessage, ReplacementUtils.getVariableAssignmentString(engineMessage, createOrUpdateBond.getName()));
doTestValidModifiedBonds(createOrUpdateBond, notABondValidationResult, notABondValidationResult, ValidationResult.VALID);
}
use of org.ovirt.engine.core.common.action.CreateOrUpdateBond in project ovirt-engine by oVirt.
the class NicLabelValidatorTest method labelBeingAttachedToNonVlanNonSlaveInterfaceAttachToNewSlave.
@Test
public void labelBeingAttachedToNonVlanNonSlaveInterfaceAttachToNewSlave() {
HostSetupNetworksParameters params = createHostSetupNetworksParams();
VdsNetworkInterface slave = createNic();
CreateOrUpdateBond createOrUpdateBond = new CreateOrUpdateBond();
createOrUpdateBond.setName("bond");
createOrUpdateBond.setSlaves(Collections.singleton(slave.getName()));
params.setCreateOrUpdateBonds(Collections.singletonList(createOrUpdateBond));
assertLabelBeingAttachedToNonVlanNonSlaveInterfaceFailed(params, slave);
}
use of org.ovirt.engine.core.common.action.CreateOrUpdateBond 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);
}
Aggregations