use of org.ovirt.engine.core.common.action.PersistentHostSetupNetworksParameters in project ovirt-engine by oVirt.
the class PersistentHostSetupNetworksParametersFactory method create.
/**
* @param hostId host on which networks to be updated reside
* @param networks networks to be updated; it is assumed, that all those networks belongs to given host.
*
* @return PersistentHostSetupNetworksParameters to refresh all given networks.
*/
public PersistentHostSetupNetworksParameters create(Guid hostId, List<Network> networks) {
Map<Network, NetworkAttachment> networksToSync = getNetworksToSync(hostId, networks);
PersistentHostSetupNetworksParameters parameters = new PersistentHostSetupNetworksParameters(hostId);
parameters.setRollbackOnFailure(true);
parameters.setShouldBeLogged(false);
parameters.setNetworkNames(getNetworkNames(networksToSync.keySet()));
parameters.setNetworkAttachments(new ArrayList<>(networksToSync.values()));
return parameters;
}
use of org.ovirt.engine.core.common.action.PersistentHostSetupNetworksParameters in project ovirt-engine by oVirt.
the class RefreshNetworksParametersFactory method create.
/**
* @param networks networks to be refreshed.
* @return list of PersistentHostSetupNetworksParameters instances to update all given networks on all hosts where
* they are used.
*/
public ArrayList<ActionParametersBase> create(List<Network> networks) {
Map<Guid, List<Network>> vdsIdToNetworksOfAlteredQos = mapNetworksByAttachedHosts(networks);
ArrayList<ActionParametersBase> parameters = new ArrayList<>();
for (Map.Entry<Guid, List<Network>> entry : vdsIdToNetworksOfAlteredQos.entrySet()) {
Guid hostId = entry.getKey();
List<Network> networksOfAlteredQos = entry.getValue();
PersistentHostSetupNetworksParameters setupNetworkParams = persistentHostSetupNetworksParametersFactory.create(hostId, networksOfAlteredQos);
parameters.add(setupNetworkParams);
}
return parameters;
}
use of org.ovirt.engine.core.common.action.PersistentHostSetupNetworksParameters in project ovirt-engine by oVirt.
the class SyncAllHostNetworksCommand method executeCommand.
@Override
protected void executeCommand() {
PersistentHostSetupNetworksParameters parameters = generateSyncAllHostNetworksParameters();
ActionReturnValue retVal = runInternalAction(ActionType.PersistentHostSetupNetworks, parameters, cloneContextAndDetachFromParent());
if (!retVal.getSucceeded()) {
propagateFailure(retVal);
} else {
setSucceeded(true);
}
}
use of org.ovirt.engine.core.common.action.PersistentHostSetupNetworksParameters in project ovirt-engine by oVirt.
the class PersistentHostSetupNetworksParametersFactoryTest method testCreate.
@Test
public void testCreate() {
when(networkAttachmentDao.getAllForHost(hostId)).thenReturn(Arrays.asList(networkAttachmentA, networkAttachmentB));
PersistentHostSetupNetworksParameters parameters = underTest.create(hostId, Arrays.asList(networkA, networkB));
assertThat(parameters.getShouldBeLogged(), is(false));
assertThat(parameters.rollbackOnFailure(), is(true));
String expectedSubstitutedNetworkNames = networkB.getName();
assertThat(parameters.getNetworkNames(), is(expectedSubstitutedNetworkNames));
assertThat(parameters.getNetworkAttachments(), hasSize(1));
NetworkAttachment soleAttachment = parameters.getNetworkAttachments().iterator().next();
assertThat(soleAttachment.getId(), is(networkAttachmentB.getId()));
assertThat(soleAttachment.isOverrideConfiguration(), is(true));
}
use of org.ovirt.engine.core.common.action.PersistentHostSetupNetworksParameters 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;
}
Aggregations