use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.
the class NetworkAttachmentDaoImplTest method testSave.
/**
* Ensures that the save is working correctly
*/
@Test
public void testSave() {
dao.save(networkAttachment);
NetworkAttachment result = dao.get(networkAttachment.getId());
assertNotNull(result);
assertNetworkAttachmentEquals(networkAttachment, result);
}
use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.
the class NetworkAttachmentDaoImplTest method testRemove.
/**
* Ensures that the remove is working correctly
*/
@Test
public void testRemove() {
dao.save(networkAttachment);
NetworkAttachment result = dao.get(networkAttachment.getId());
assertNotNull(result);
dao.remove(networkAttachment.getId());
assertNull(dao.get(networkAttachment.getId()));
assertNull(dnsResolverConfigurationDao.get(networkAttachment.getDnsResolverConfiguration().getId()));
}
use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.
the class ManageNetworksParametersBuilderImpl method buildParameters.
@Override
public PersistentHostSetupNetworksParameters buildParameters(Guid vdsId, List<Network> labeledNetworksToBeAdded, List<Network> labeledNetworksToBeRemoved, Map<String, VdsNetworkInterface> nicsByLabel, List<Network> updatedNetworks) {
final PersistentHostSetupNetworksParameters addSetupNetworksParameters = addNetworksByLabelParametersBuilder.buildParameters(vdsId, labeledNetworksToBeAdded, nicsByLabel);
final PersistentHostSetupNetworksParameters removeSetupNetworksParameters = removeNetworksByLabelParametersBuilder.buildParameters(vdsId, labeledNetworksToBeRemoved);
PersistentHostSetupNetworksParameters updatedNetworksParams = createHostSetupNetworksParameters(vdsId);
Map<Guid, NetworkAttachment> networkIdToAttachmentMap = getNetworkIdToAttachmentMap(vdsId);
List<NetworkAttachment> updatedNetworkAttachments = updatedNetworks.stream().map(Network::getId).map(networkIdToAttachmentMap::get).collect(Collectors.toList());
updatedNetworkAttachments.forEach(networkAttachment -> networkAttachment.setOverrideConfiguration(true));
updatedNetworksParams.getNetworkAttachments().addAll(updatedNetworkAttachments);
final PersistentHostSetupNetworksParameters combinedParams = combine(combine(addSetupNetworksParameters, removeSetupNetworksParameters), updatedNetworksParams);
combinedParams.setNetworkNames(commaSeparateNetworkNames(Arrays.asList(labeledNetworksToBeAdded.stream(), labeledNetworksToBeRemoved.stream(), updatedNetworks.stream())));
return combinedParams;
}
use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.
the class RemoveNetworkParametersBuilder method buildParameters.
public ArrayList<ActionParametersBase> buildParameters(Network network, List<VdsNetworkInterface> labeledNics) {
ArrayList<ActionParametersBase> parameters = new ArrayList<>();
if (managementNetworkUtil.isManagementNetwork(network.getId())) {
return parameters;
}
for (VdsNetworkInterface nic : labeledNics) {
PersistentHostSetupNetworksParameters setupNetworkParams = createHostSetupNetworksParameters(nic.getVdsId());
setupNetworkParams.setNetworkNames(network.getName());
Map<String, VdsNetworkInterface> nicByNetworkName = NetworkUtils.hostInterfacesByNetworkName(getNics(nic.getVdsId()));
VdsNetworkInterface nicToConfigure = getNicToConfigure(getNics(nic.getVdsId()), nic.getId());
if (nicToConfigure == null) {
throw new EngineException(EngineError.LABELED_NETWORK_INTERFACE_NOT_FOUND);
}
NetworkAttachment networkAttachment = getNetworkIdToAttachmentMap(nic.getVdsId()).get(network.getId());
if (networkAttachment != null) {
if (networkAttachment.getNicId().equals(nicToConfigure.getId())) {
setupNetworkParams.getRemovedNetworkAttachments().add(networkAttachment.getId());
}
} else {
VdsNetworkInterface nicWithNetwork = nicByNetworkName.get(network.getName());
if (nicWithNetwork != null && NetworkCommonUtils.stripVlan(nicWithNetwork).equals(nic.getName())) {
setupNetworkParams.getRemovedUnmanagedNetworks().add(network.getName());
}
}
parameters.add(setupNetworkParams);
}
return parameters;
}
use of org.ovirt.engine.core.common.businessentities.network.NetworkAttachment in project ovirt-engine by oVirt.
the class HostSetupNetworksModel method initNetworkIdToExistingAttachmentMap.
private void initNetworkIdToExistingAttachmentMap() {
Map<Guid, Guid> networkIdToExistingAttachmentId = new HashMap<>();
for (NetworkAttachment attachment : hostSetupNetworksParametersData.getNetworkAttachments()) {
networkIdToExistingAttachmentId.put(attachment.getNetworkId(), attachment.getId());
}
hostSetupNetworksParametersData.setNetworkIdToExistingAttachmentId(networkIdToExistingAttachmentId);
}
Aggregations