use of org.ovirt.engine.core.common.action.PersistentHostSetupNetworksParameters 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.action.PersistentHostSetupNetworksParameters in project ovirt-engine by oVirt.
the class AddNetworksByLabelParametersBuilder method buildParameters.
/**
* Adds a list of labeled networks to a host
*/
public PersistentHostSetupNetworksParameters buildParameters(Guid hostId, List<Network> labeledNetworks, Map<String, VdsNetworkInterface> nicsByLabel) {
PersistentHostSetupNetworksParameters parameters = createHostSetupNetworksParameters(hostId);
Set<Network> networksToAdd = getNetworksToConfigure(getNics(hostId), labeledNetworks);
for (Network network : networksToAdd) {
VdsNetworkInterface labeledNic = nicsByLabel.get(network.getLabel());
VdsNetworkInterface nicToConfigure = getNicToConfigure(getNics(hostId), labeledNic.getId());
if (nicToConfigure == null) {
throw new EngineException(EngineError.LABELED_NETWORK_INTERFACE_NOT_FOUND);
}
// configure the network on the nic
addAttachmentToParameters(nicToConfigure, network, parameters);
}
parameters.setNetworkNames(networksToAdd.stream().map(Network::getName).collect(Collectors.joining(", ")));
return parameters;
}
use of org.ovirt.engine.core.common.action.PersistentHostSetupNetworksParameters in project ovirt-engine by oVirt.
the class SyncAllHostNetworksCommand method generateSyncAllHostNetworksParameters.
private PersistentHostSetupNetworksParameters generateSyncAllHostNetworksParameters() {
PersistentHostSetupNetworksParameters parameters = new PersistentHostSetupNetworksParameters(getVdsId());
QueryReturnValue returnValue = runInternalQuery(QueryType.GetNetworkAttachmentsByHostId, new IdQueryParameters(getVdsId()));
List<NetworkAttachment> networkAttachments = returnValue.getReturnValue();
List<NetworkAttachment> unSyncNetworkAttachments = networkAttachments.stream().filter(new NetworkNotInSyncPredicate()).collect(Collectors.toList());
for (NetworkAttachment networkAttachment : unSyncNetworkAttachments) {
networkAttachment.setOverrideConfiguration(true);
}
parameters.setNetworkAttachments(unSyncNetworkAttachments);
parameters.setSequence(parameters.getSequence() + 1);
parameters.setTotal(parameters.getTotal() + 1);
return parameters;
}
use of org.ovirt.engine.core.common.action.PersistentHostSetupNetworksParameters in project ovirt-engine by oVirt.
the class HostSetupNetworksParametersBuilder method updateParametersSequencing.
/**
* Update the given list of parameters to have sequencing according to their order, and have the total count. The
* updated parameters also will be set to log the command.
*
* @param parameters
* A list of parameters to update.
*/
public static void updateParametersSequencing(List<ActionParametersBase> parameters) {
for (int i = 0; i < parameters.size(); i++) {
PersistentHostSetupNetworksParameters setupNetworkParameters = (PersistentHostSetupNetworksParameters) parameters.get(i);
setupNetworkParameters.setSequence(i + 1);
setupNetworkParameters.setTotal(parameters.size());
setupNetworkParameters.setShouldBeLogged(true);
}
}
use of org.ovirt.engine.core.common.action.PersistentHostSetupNetworksParameters in project ovirt-engine by oVirt.
the class HostSetupNetworksParametersBuilder method createHostSetupNetworksParameters.
protected PersistentHostSetupNetworksParameters createHostSetupNetworksParameters(Guid hostId) {
PersistentHostSetupNetworksParameters parameters = new PersistentHostSetupNetworksParameters(hostId);
parameters.setRollbackOnFailure(true);
parameters.setShouldBeLogged(false);
return parameters;
}
Aggregations