use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.
the class HostNetworkAttachmentsPersisterTest method testPersistNetworkAttachmentsWhenNetworkMovedToDifferentNic.
@Test
public void testPersistNetworkAttachmentsWhenNetworkMovedToDifferentNic() throws Exception {
NetworkAttachment networkAttachmentForClusterNetworkA = createNetworkAttachment(clusterNetworkA);
// make network attachment out of sync, by setting different nicId and nicName
Guid notUpToDateNicId = Guid.newGuid();
networkAttachmentForClusterNetworkA.setNicId(notUpToDateNicId);
networkAttachmentForClusterNetworkA.setNicName("nonsense");
IpConfiguration ipConfiguration = NetworkUtils.createIpConfigurationFromVdsNetworkInterface(interfaceWithAttachedClusterNetworkA);
networkAttachmentForClusterNetworkA.setIpConfiguration(ipConfiguration);
networkAttachmentForClusterNetworkA.setProperties(customPropertiesForNics.getCustomPropertiesFor(interfaceWithAttachedClusterNetworkA));
callPersistNetworkAttachmentsAndVerifyThatNetworkAttachmentIsSynced(networkAttachmentForClusterNetworkA, createPersister(Collections.emptyList()));
}
use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.
the class ExecuteNetworkCommandInNetworkOperationTest method testDetachingPreexistingNetworkAttachment.
/*
* At the beginning there was a NetworkAttachment, and network gets detached from the nic.
*/
@Test
public void testDetachingPreexistingNetworkAttachment() throws Exception {
NetworkAttachment attachment = createAttachmentOnNetworkModelAndUpdateParams(networkInterfaceModelOfNicA, logicalNetworkModelOfNetworkA);
Guid attachmentId = attachment.getId();
NetworkOperation.DETACH_NETWORK.getTarget().executeNetworkCommand(logicalNetworkModelOfNetworkA, null, dataFromHostSetupNetworksModel);
assertThat(dataFromHostSetupNetworksModel.getNetworkAttachments().size(), is(0));
assertThat(dataFromHostSetupNetworksModel.getRemovedNetworkAttachments().size(), is(1));
Guid removedNetworkAttachmentId = dataFromHostSetupNetworksModel.getRemovedNetworkAttachments().iterator().next();
// $NON-NLS-1$
assertThat("id mismatch", removedNetworkAttachmentId, is(attachmentId));
}
use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.
the class ExecuteNetworkCommandInNetworkOperationTest method testAddingNewNicWithNetworkAttachmentToExistingBondWithoutAnyAttachment.
/*
* At the beginning there was bond without any network attachment. Then another nic showed up joining the family
* bringing his own network attachment along.
*/
@Test
public void testAddingNewNicWithNetworkAttachmentToExistingBondWithoutAnyAttachment() throws Exception {
addBondToParamsAndModel(existingBond, bondNetworkInterfaceModelA, Collections.emptyList());
NetworkAttachment networkAttachment = createAttachmentOnNetworkModelAndUpdateParams(networkInterfaceModelOfNicC, logicalNetworkModelOfNetworkC);
when(networkInterfaceModelOfNicC.getItems()).thenReturn(Collections.singletonList(logicalNetworkModelOfNetworkC));
initNetworkIdToExistingAttachmentIdMap(networkAttachment);
NetworkOperation.ADD_TO_BOND.getTarget().executeNetworkCommand(networkInterfaceModelOfNicC, bondNetworkInterfaceModelA, dataFromHostSetupNetworksModel);
// related network attachment will be updated, not removed and created new one.
assertThat(dataFromHostSetupNetworksModel.getNetworkAttachments().size(), is(1));
assertNetworkAttachment(dataFromHostSetupNetworksModel.getNetworkAttachments().iterator().next(), networkAttachment.getId(), networkC.getId(), existingBondId);
assertThat(dataFromHostSetupNetworksModel.getRemovedNetworkAttachments().size(), is(0));
assertThat(dataFromHostSetupNetworksModel.getBonds().size(), is(1));
CreateOrUpdateBond newOrModifiedBond = dataFromHostSetupNetworksModel.getBonds().iterator().next();
assertBond(newOrModifiedBond, existingBondId, Arrays.asList(nicA, nicB, nicC));
assertThat(dataFromHostSetupNetworksModel.getRemovedBonds().size(), is(0));
}
use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment 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.NetworkAttachment in project ovirt-engine by oVirt.
the class ExecuteNetworkCommandInNetworkOperationTest method testReattachingPreexistingNetworkAfterItsBeingDetached.
/*
* At the beginning there was a NetworkAttachment. Suddenly network was detached from the nic, but in the end,
* network was back attached to the nic unchanged.
*/
@Test
public void testReattachingPreexistingNetworkAfterItsBeingDetached() throws Exception {
NetworkAttachment attachment = createAttachmentOnNetworkModelAndUpdateParams(networkInterfaceModelOfNicA, logicalNetworkModelOfNetworkA);
initNetworkIdToExistingAttachmentIdMap(attachment);
NetworkOperation.DETACH_NETWORK.getTarget().executeNetworkCommand(logicalNetworkModelOfNetworkA, null, dataFromHostSetupNetworksModel);
NetworkOperation.ATTACH_NETWORK.getTarget().executeNetworkCommand(logicalNetworkModelOfNetworkA, networkInterfaceModelOfNicA, dataFromHostSetupNetworksModel);
assertThat(dataFromHostSetupNetworksModel.getNetworkAttachments().size(), is(1));
NetworkAttachment updatedNetworkAttachment = dataFromHostSetupNetworksModel.getNetworkAttachments().iterator().next();
assertNetworkAttachment(updatedNetworkAttachment, attachment.getId(), networkA.getId(), nicA.getId());
assertThat(dataFromHostSetupNetworksModel.getRemovedNetworkAttachments().size(), is(0));
}
Aggregations