use of org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface in project ovirt-engine by oVirt.
the class RunVmCommandBase method initParametersForExternalNetworks.
protected void initParametersForExternalNetworks(VDS vds, boolean isMigration) {
for (VmNetworkInterface iface : getVm().getInterfaces()) {
VnicProfile vnicProfile = vnicProfileDao.get(iface.getVnicProfileId());
Network network = networkHelper.getNetworkByVnicProfile(vnicProfile);
if (network != null && network.isExternal() && iface.isPlugged()) {
Provider<?> provider = providerDao.get(network.getProvidedBy().getProviderId());
NetworkProviderProxy providerProxy = providerProxyFactory.create(provider);
Map<String, String> deviceProperties = providerProxy.allocate(network, vnicProfile, iface, vds, isMigration);
getVm().getRuntimeDeviceCustomProperties().put(new VmDeviceId(iface.getId(), getVmId()), deviceProperties);
}
}
}
use of org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface in project ovirt-engine by oVirt.
the class ExternalVmMacsFinder method findExternalMacAddresses.
public Set<String> findExternalMacAddresses(VM vm) {
final List<VmNetworkInterface> interfaces = vm.getInterfaces();
if (interfaces == null) {
return Collections.emptySet();
}
final ReadMacPool readMacPool = macPoolPerCluster.getMacPoolForCluster(vm.getClusterId());
return interfaces.stream().map(VmNetworkInterface::getMacAddress).filter(Objects::nonNull).filter(((Predicate<String>) readMacPool::isMacInRange).negate()).collect(Collectors.toSet());
}
use of org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface in project ovirt-engine by oVirt.
the class RemoveVmTemplateInterfaceCommand method executeCommand.
@Override
protected void executeCommand() {
VmNetworkInterface iface = vmNetworkInterfaceDao.get(getParameters().getInterfaceId());
if (iface != null) {
addCustomValue("InterfaceName", iface.getName());
addCustomValue("InterfaceType", VmInterfaceType.forValue(iface.getType()).getDescription());
}
vmDeviceDao.remove(new VmDeviceId(getParameters().getInterfaceId(), getParameters().getVmTemplateId()));
vmNicDao.remove(getParameters().getInterfaceId());
setSucceeded(true);
}
use of org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface in project ovirt-engine by oVirt.
the class GetVmsAndNetworkInterfacesByNetworkIdQuery method executeQueryCommand.
@Override
protected void executeQueryCommand() {
List<VM> vmList = vmDao.getAllForNetwork(getParameters().getId());
List<VmNetworkInterface> vmNetworkInterfaceList = vmNetworkInterfaceDao.getAllForNetwork(getParameters().getId());
final Map<Guid, VM> vmsById = Entities.businessEntitiesById(vmList);
List<PairQueryable<VmNetworkInterface, VM>> vmInterfaceVmPairs = new ArrayList<>();
for (VmNetworkInterface vmNetworkInterface : vmNetworkInterfaceList) {
VM vm = vmsById.get(vmNetworkInterface.getVmId());
if (getParameters().getRunningVms() == null || getParameters().getRunningVms().equals(vm.isRunning())) {
vmInterfaceVmPairs.add(new PairQueryable<>(vmNetworkInterface, vm));
}
}
getQueryReturnValue().setReturnValue(vmInterfaceVmPairs);
}
use of org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface 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