use of org.ovirt.engine.core.common.businessentities.network.Network in project ovirt-engine by oVirt.
the class ReportedConfigurationsFiller method getNicToWhichIsNetworkAttached.
private VdsNetworkInterface getNicToWhichIsNetworkAttached(Map<String, VdsNetworkInterface> networkNameToNicMap, BusinessEntityMap<Network> networkMap, NetworkAttachment networkAttachment) {
Guid networkId = networkAttachment.getNetworkId();
Network network = networkMap.get(networkId);
return networkNameToNicMap.get(network.getName());
}
use of org.ovirt.engine.core.common.businessentities.network.Network in project ovirt-engine by oVirt.
the class ReportedConfigurationsFiller method fillReportedConfigurations.
private void fillReportedConfigurations(Map<String, VdsNetworkInterface> networkNameToNicMap, BusinessEntityMap<Network> networkMap, NetworkAttachment networkAttachment, DnsResolverConfiguration reportedDnsResolverConfiguration, Cluster cluster) {
Network network = networkMap.get(networkAttachment.getNetworkId());
VdsNetworkInterface nic = getNicToWhichIsNetworkAttached(networkNameToNicMap, networkMap, networkAttachment);
if (nic != null) {
NetworkInSyncWithVdsNetworkInterface isInSync = createNetworkInSyncWithVdsNetworkInterface(networkAttachment, nic, network, reportedDnsResolverConfiguration, cluster);
ReportedConfigurations reportedConfigurations = isInSync.reportConfigurationsOnHost();
networkAttachment.setReportedConfigurations(reportedConfigurations);
}
}
use of org.ovirt.engine.core.common.businessentities.network.Network in project ovirt-engine by oVirt.
the class UpdateVmInterfaceCommand method executeVmCommand.
@Override
protected void executeVmCommand() {
addCustomValue("InterfaceType", VmInterfaceType.forValue(getInterface().getType()).getDescription().toString());
boolean succeeded = false;
boolean macAddedToPool = false;
try {
if (isVnicProfileChanged(oldIface, getInterface())) {
Network newNetwork = networkHelper.getNetworkByVnicProfileId(getInterface().getVnicProfileId());
Network oldNetwork = networkHelper.getNetworkByVnicProfileId(oldIface.getVnicProfileId());
if (!Objects.equals(oldNetwork, newNetwork)) {
externalNetworkManagerFactory.create(oldIface).deallocateIfExternal();
}
}
macAddedToPool = allocateMacFromRequest();
if (mustChangeAddress(oldIface.getType(), getInterface().getType())) {
vmDeviceDao.clearDeviceAddress(getInterface().getId());
}
getInterface().setSpeed(VmInterfaceType.forValue(getInterface().getType()).getSpeed());
TransactionSupport.executeInNewTransaction(() -> {
bumpVmVersion();
updatePassthoughDeviceIfNeeded();
getCompensationContext().snapshotEntity(oldIface);
vmNicDao.update(getInterface());
saveNetworkFilterParameters();
getCompensationContext().stateChanged();
return null;
});
succeeded = updateHost();
} finally {
setSucceeded(succeeded);
macPoolCleanupAfterExecution(macAddedToPool);
}
}
use of org.ovirt.engine.core.common.businessentities.network.Network in project ovirt-engine by oVirt.
the class VnicProfileHelper method updateNicWithVnicProfile.
/**
* Updates the vnic profile id of a given {@code VmNic} by a network name and vnic profile name.
*
* @param iface
* The vm network interface to be updated
* @param user
* The user which performs the action
* @return {@code true} if the vnic profile id is updated, else {@code false}
*/
private boolean updateNicWithVnicProfile(VmNetworkInterface iface, DbUser user) {
if (iface.getNetworkName() == null) {
iface.setVnicProfileId(null);
return true;
}
Network network = getNetworksInCluster().get(iface.getNetworkName());
if (network == null || !network.isVmNetwork()) {
return false;
}
VnicProfile vnicProfile = getVnicProfileForNetwork(network, iface.getVnicProfileName());
if (vnicProfile == null) {
vnicProfile = findVnicProfileForUser(user, network);
if (vnicProfile == null) {
return false;
}
}
iface.setVnicProfileId(vnicProfile.getId());
return true;
}
use of org.ovirt.engine.core.common.businessentities.network.Network in project ovirt-engine by oVirt.
the class NetworkPolicyUnit method filter.
@Override
public List<VDS> filter(Cluster cluster, List<VDS> hosts, VM vm, Map<String, String> parameters, PerHostMessages messages) {
if (hosts == null || hosts.isEmpty()) {
return Collections.emptyList();
}
List<VDS> toRemoveHostList = new ArrayList<>();
List<VmNetworkInterface> vmNICs = vmNetworkInterfaceDao.getAllForVm(vm.getId());
Guid clusterId = hosts.get(0).getClusterId();
List<Network> clusterNetworks = networkDao.getAllForCluster(clusterId);
Map<String, Network> networksByName = Entities.entitiesByName(clusterNetworks);
Map<Guid, List<String>> hostNics = interfaceDao.getHostNetworksByCluster(clusterId);
Network displayNetwork = NetworkUtils.getDisplayNetwork(clusterNetworks);
Map<Guid, VdsNetworkInterface> hostDisplayNics = getDisplayNics(displayNetwork);
for (VDS host : hosts) {
ValidationResult result = validateRequiredNetworksAvailable(host, vm, vmNICs, displayNetwork, networksByName, hostNics.get(host.getId()), hostDisplayNics.get(host.getId()));
if (result.isValid()) {
result = validatePassthroughVnics(vm.getId(), host, vmNICs);
}
if (!result.isValid()) {
toRemoveHostList.add(host);
messages.addMessages(host.getId(), result.getVariableReplacements());
messages.addMessages(host.getId(), result.getMessagesAsStrings());
}
}
hosts.removeAll(toRemoveHostList);
return hosts;
}
Aggregations