use of org.ovirt.engine.core.common.action.PersistentHostSetupNetworksParameters in project ovirt-engine by oVirt.
the class ManageNetworksParametersBuilderImpl method combine.
private PersistentHostSetupNetworksParameters combine(PersistentHostSetupNetworksParameters addSetupNetworksParameters, PersistentHostSetupNetworksParameters removeSetupNetworksParameters) {
Guid hostId = addSetupNetworksParameters.getVdsId();
final PersistentHostSetupNetworksParameters resultParam = createHostSetupNetworksParameters(hostId);
extendParameters(resultParam, addSetupNetworksParameters);
extendParameters(resultParam, removeSetupNetworksParameters);
return resultParam;
}
use of org.ovirt.engine.core.common.action.PersistentHostSetupNetworksParameters in project ovirt-engine by oVirt.
the class AddNetworkParametersBuilder method buildParameters.
public ArrayList<ActionParametersBase> buildParameters(Network network, List<VdsNetworkInterface> nics) {
ArrayList<ActionParametersBase> parameters = new ArrayList<>();
for (VdsNetworkInterface nic : nics) {
PersistentHostSetupNetworksParameters setupNetworkParams = createHostSetupNetworksParameters(nic.getVdsId());
setupNetworkParams.setNetworkNames(network.getName());
VdsNetworkInterface nicToConfigure = getNicToConfigure(getNics(nic.getVdsId()), nic.getId());
if (nicToConfigure == null) {
throw new EngineException(EngineError.LABELED_NETWORK_INTERFACE_NOT_FOUND);
}
NetworkAttachment networkAttachment = new NetworkAttachment(nicToConfigure, network, NetworkUtils.createIpConfigurationFromVdsNetworkInterface(getVlanDevice(nicToConfigure, network.getVlanId())));
setupNetworkParams.getNetworkAttachments().add(networkAttachment);
addBootProtocolForRoleNetworkAttachment(nicToConfigure, network, networkAttachment);
parameters.add(setupNetworkParams);
}
return parameters;
}
use of org.ovirt.engine.core.common.action.PersistentHostSetupNetworksParameters in project ovirt-engine by oVirt.
the class RemoveNetworksByLabelParametersBuilder method buildParameters.
/**
* Removes a given list of labeled networks from a host
*/
public PersistentHostSetupNetworksParameters buildParameters(Guid hostId, List<Network> networksToRemove) {
PersistentHostSetupNetworksParameters parameters = createHostSetupNetworksParameters(hostId);
Map<String, VdsNetworkInterface> nicByNetwork = NetworkUtils.hostInterfacesByNetworkName(getNics(hostId));
Map<String, VdsNetworkInterface> nicByName = Entities.entitiesByName(getNics(hostId));
for (Network networkToRemove : networksToRemove) {
VdsNetworkInterface nicWithNetwork = nicByNetwork.get(networkToRemove.getName());
if (nicWithNetwork != null) {
VdsNetworkInterface baseNicWithNetwork = nicByName.get(NetworkCommonUtils.stripVlan(nicWithNetwork));
if (NetworkUtils.isLabeled(networkToRemove) && NetworkUtils.isLabeled(baseNicWithNetwork) && baseNicWithNetwork.getLabels().contains(networkToRemove.getLabel())) {
NetworkAttachment networkAttachment = getNetworkIdToAttachmentMap(hostId).get(networkToRemove.getId());
if (networkAttachment == null) {
parameters.getRemovedUnmanagedNetworks().add(networkToRemove.getName());
} else {
parameters.getRemovedNetworkAttachments().add(networkAttachment.getId());
}
}
}
}
return parameters;
}
use of org.ovirt.engine.core.common.action.PersistentHostSetupNetworksParameters in project ovirt-engine by oVirt.
the class ChangeVDSClusterCommand method configureNetworks.
private void configureNetworks() {
final PersistentHostSetupNetworksParameters params;
try {
params = changeClusterParametersBuilder.buildParameters(getVdsId(), getSourceCluster().getId(), getTargetCluster().getId());
} catch (EngineException e) {
auditLogDirector.log(this, AuditLogType.CONFIGURE_NETWORK_BY_LABELS_WHEN_CHANGING_CLUSTER_FAILED);
return;
}
ThreadPoolUtil.execute(() -> runInternalAction(ActionType.PersistentHostSetupNetworks, params, cloneContextAndDetachFromParent()));
}
use of org.ovirt.engine.core.common.action.PersistentHostSetupNetworksParameters in project ovirt-engine by oVirt.
the class NetworkClustersToSetupNetworksParametersTransformerImpl method createSetupNetworksParameters.
private List<PersistentHostSetupNetworksParameters> createSetupNetworksParameters(Map<Guid, List<Network>> attachNetworksByHost, Map<Guid, Map<String, VdsNetworkInterface>> labelsToNicsByHost, Map<Guid, List<Network>> detachNetworksByHost, Map<Guid, List<Network>> updates) {
final List<PersistentHostSetupNetworksParameters> parameters = new ArrayList<>(attachNetworksByHost.size());
final ManageNetworksParametersBuilder builder = manageNetworksParametersBuilderFactory.create(commandContext, interfaceDao, vdsStaticDao, networkClusterDao, networkAttachmentDao);
Set<Guid> hostIds = Stream.of(attachNetworksByHost, detachNetworksByHost, updates).flatMap(e -> e.keySet().stream()).collect(Collectors.toSet());
for (Guid hostId : hostIds) {
final Map<String, VdsNetworkInterface> nicsByLabel = labelsToNicsByHost.get(hostId);
parameters.add(builder.buildParameters(hostId, nullToEmptyList(attachNetworksByHost.get(hostId)), nullToEmptyList(detachNetworksByHost.get(hostId)), nicsByLabel == null ? Collections.emptyMap() : nicsByLabel, nullToEmptyList(updates.get(hostId))));
}
return parameters;
}
Aggregations