use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.
the class EffectiveHostNetworkQosTest method testGetQosWhenNetworkAttachmentDoesNotHaveOverriddenQos.
@Test
public void testGetQosWhenNetworkAttachmentDoesNotHaveOverriddenQos() throws Exception {
HostNetworkQos hostNetworkQos = createHostNetworkQos();
Network network = createNetworkWithQos(hostNetworkQos);
NetworkAttachment networkAttachment = createNetworkAttachmentWithoutOverriddenQos();
when(hostNetworkQosDao.get(network.getQosId())).thenReturn(hostNetworkQos);
assertThat(effectiveHostNetworkQos.getQos(networkAttachment, network), is(hostNetworkQos));
verify(hostNetworkQosDao).get(eq(network.getQosId()));
verifyNoMoreInteractions(hostNetworkQosDao);
}
use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.
the class EffectiveHostNetworkQosTest method createNetworkAttachentWithOverriddenQos.
private NetworkAttachment createNetworkAttachentWithOverriddenQos() {
NetworkAttachment networkAttachment = new NetworkAttachment();
HostNetworkQos hostNetworkQos = createHostNetworkQos();
networkAttachment.setHostNetworkQos(AnonymousHostNetworkQos.fromHostNetworkQos(hostNetworkQos));
return networkAttachment;
}
use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.
the class LogicalNetworkModelParametersHelper method createAttachmentWhenAttachingTo.
private NetworkAttachment createAttachmentWhenAttachingTo(VdsNetworkInterface targetNic) {
NetworkAttachment networkAttachment = new NetworkAttachment(targetNic, networkModel.getNetwork(), NetworkCommonUtils.createDefaultIpConfiguration());
NetworkParameters netParams = networkModel.getSetupModel().getNetworkToLastDetachParams().get(networkModel.getName());
if (netParams != null) {
applyOnAttachmentParamsFrom(netParams, networkAttachment);
} else {
VdsNetworkInterface nicToTakeParamsFrom = null;
if (networkModel.hasVlan()) {
nicToTakeParamsFrom = getPotentialVlanDevice(targetNic);
} else {
nicToTakeParamsFrom = targetNic;
}
boolean newlyCreatedBond = nicToTakeParamsFrom != null && nicToTakeParamsFrom.getId() == null;
if (nicToTakeParamsFrom != null && !newlyCreatedBond) {
InterfacePropertiesAccessor.FromNic interfacePropertiesAccessor = new InterfacePropertiesAccessor.FromNic(nicToTakeParamsFrom, null);
applyOnAttachmentParamsFrom(interfacePropertiesAccessor, networkAttachment);
}
fixBootProtocolOfMgmtNetworkIfNeeded(networkAttachment);
}
return networkAttachment;
}
use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.
the class HostNetworkAttachmentsPersister method updateReportedNetworkAttachmentsNotMentionedInRequest.
/**
* Adds new network attachments for reported networks from the host which weren't associated to a user attachment.
* Updates existing network attachments which network get reported on different nic.
* <br/>
* The network attachment's attributes will be inherited from the network interface on which it is configured.
* @param networkAttachments already existing or newly created network attachments
*/
private void updateReportedNetworkAttachmentsNotMentionedInRequest(List<NetworkAttachment> networkAttachments) {
for (VdsNetworkInterface nic : nicsByName.values()) {
String networkName = nic.getNetworkName();
if (networkName != null && clusterNetworks.containsKey(networkName)) {
NetworkAttachment networkAttachmentRelatedToNetwork = getNetworkAttachmentRelatedToNetwork(networkAttachments, clusterNetworks.get(networkName));
boolean networkAttachmentRelatedToNetworkExist = networkAttachmentRelatedToNetwork != null;
if (networkAttachmentRelatedToNetworkExist) {
VdsNetworkInterface baseInterfaceNicOrThis = getBaseInterfaceNicOrThis(nic);
boolean networkMovedToDifferentNic = !baseInterfaceNicOrThis.getId().equals(networkAttachmentRelatedToNetwork.getNicId());
if (networkMovedToDifferentNic) {
networkAttachmentRelatedToNetwork.setNicId(baseInterfaceNicOrThis.getId());
networkAttachmentRelatedToNetwork.setNicName(baseInterfaceNicOrThis.getName());
networkAttachmentDao.update(networkAttachmentRelatedToNetwork);
}
} else {
if (!nic.isPartOfBond()) {
createNetworkAttachmentForReportedNetworksNotHavingOne(nic, networkName);
}
}
}
}
}
use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.
the class HostNetworkAttachmentsPersister method persistOrUpdateUserNetworkAttachments.
/**
* User provided network attachments, which relates to network configured on host, are inserted or updated
* into database and used to update passed in <code>networkAttachments</code> collection.
*/
private void persistOrUpdateUserNetworkAttachments(List<NetworkAttachment> networkAttachments) {
Map<Guid, NetworkAttachment> validDbAttachmentsById = Entities.businessEntitiesById(networkAttachments);
for (NetworkAttachment networkAttachment : userNetworkAttachments) {
if (networkConfiguredOnHost(networkAttachment.getNetworkId())) {
VdsNetworkInterface reportedNicToWhichIsNetworkAttached = reportedNicsByNetworkId.get(networkAttachment.getNetworkId());
Guid reportedNicId = baseInterfaceOfNic(reportedNicToWhichIsNetworkAttached).getId();
/*this is needed for attaching network to newly created bond, where network attachment
does not have nicId set and that nic id is known only after vdsm call.
* */
if (networkAttachment.getNicId() == null) {
networkAttachment.setNicId(reportedNicId);
} else {
if (!networkAttachment.getNicId().equals(reportedNicId)) {
throw new IllegalStateException(INCONSISTENCY_NETWORK_IS_REPORTED_ON_DIFFERENT_NIC_THAN_WAS_SPECIFIED);
}
}
boolean alreadyExistingAttachment = validDbAttachmentsById.containsKey(networkAttachment.getId());
if (alreadyExistingAttachment) {
networkAttachmentDao.update(networkAttachment);
networkAttachments.remove(validDbAttachmentsById.get(networkAttachment.getId()));
networkAttachments.add(networkAttachment);
} else {
networkAttachment.setId(Guid.newGuid());
networkAttachmentDao.save(networkAttachment);
networkAttachments.add(networkAttachment);
}
}
}
}
Aggregations