use of org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface in project ovirt-engine by oVirt.
the class NetworkPolicyUnit method validateRequiredNetworksAvailable.
/**
* Determine whether all required Networks are attached to the Host's Nics. A required Network, depending on
* ConfigValue.OnlyRequiredNetworksMandatoryForVdsSelection, is defined as: 1. false: any network that is defined on
* an Active vNic of the VM or the cluster's display network. 2. true: a Cluster-Required Network that is defined on
* an Active vNic of the VM.
* Vnic configured for 'passthrough' will skip the network existence check for the host and will be validated later by
* {@code validatePassthroughVnics(...)}
*
* @param vds
* the Host
* @param vm
* the VM
* @param hostNetworks
* the Host network names
* @param displayNic
* the interface on top the display network is configured
* @return the result of network compatibility check
*/
private ValidationResult validateRequiredNetworksAvailable(VDS vds, VM vm, List<VmNetworkInterface> vmNICs, Network displayNetwork, Map<String, Network> networksByName, List<String> hostNetworks, VdsNetworkInterface displayNic) {
List<String> missingIfs = new ArrayList<>();
boolean onlyRequiredNetworks = Config.<Boolean>getValue(ConfigValues.OnlyRequiredNetworksMandatoryForVdsSelection);
for (final VmNetworkInterface vmIf : vmNICs) {
boolean found = false;
boolean skipNetworkExistenceCheckForVnicPassthrough = vmIf.isPassthrough();
if (vmIf.getNetworkName() == null) {
found = true;
} else {
for (String networkName : hostNetworks) {
if (skipNetworkExistenceCheckForVnicPassthrough || !networkRequiredOnVds(vmIf, networksByName, onlyRequiredNetworks) || StringUtils.equals(vmIf.getNetworkName(), networkName)) {
found = true;
break;
}
}
}
if (!found) {
missingIfs.add(vmIf.getNetworkName());
}
}
if (!missingIfs.isEmpty()) {
String nics = StringUtils.join(missingIfs, ", ");
log.warn("host {} is missing networks required by VM nics {}", vds.getName(), nics);
return new ValidationResult(EngineMessage.VAR__DETAIL__NETWORK_MISSING, String.format("$networkNames %1$s", nics));
}
return validateDisplayNetworkAvailability(vds, onlyRequiredNetworks, displayNic, displayNetwork);
}
use of org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface in project ovirt-engine by oVirt.
the class SnapshotVmConfigurationHelper method getVmWithoutConfiguration.
/**
* Build a VM entity when configuration is not available, This method is required to create a VM entity for
* snapshots which were taken in old engine where full OVF snapshot metadata was not supported.
*
* See also {@link VmHandler#updateDisksForVm(VM, java.util.List)}
*
* @return a VM
*/
protected VM getVmWithoutConfiguration(Guid vmId, Guid snapshotId) {
VM vm = vmDao.get(vmId);
List<VmNetworkInterface> interfaces = vmNetworkInterfaceDao.getAllForVm(vm.getId());
vm.setInterfaces(interfaces);
List<DiskImage> disks = diskImageDao.getAllSnapshotsForVmSnapshot(snapshotId);
vm.setImages(new ArrayList<>(disks));
// VM disks.
for (DiskImage currDisk : disks) {
currDisk.setActive(true);
}
return vm;
}
use of org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface in project ovirt-engine by oVirt.
the class MatchUserMappingToOvfVnicTest method test.
private void test(Object[] dataPoint, int count) {
// Translate input to human readable
VmNetworkInterface ovfVnicUnderTest = (VmNetworkInterface) dataPoint[0];
ExternalVnicProfileMapping userMappingUnderTest = (ExternalVnicProfileMapping) dataPoint[1];
Boolean expectedIsMatch = (Boolean) dataPoint[2];
// Arrange
MapVnicsContext ctx = new MapVnicsContext("test");
ctx.setOvfVnics(singletonList(ovfVnicUnderTest));
ctx.setUserMappings(singletonList(userMappingUnderTest));
// Act
matcher.handle(ctx);
// Assert
print(ovfVnicUnderTest, ctx, count);
ExternalVnicProfileMapping expectedMatchingMapping = expectedIsMatch ? userMappingUnderTest : null;
assertEquals(expectedMatchingMapping, ctx.getMatched().get(ovfVnicUnderTest));
assertTrue(ctx.getMatched().size() > 0);
assertTrue(ctx.getException() == null);
}
use of org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface in project ovirt-engine by oVirt.
the class VirtualMachineModule method getVmInterfaceListProvider.
@Provides
@Singleton
public SearchableDetailModelProvider<VmNetworkInterface, VmListModel<Void>, VmInterfaceListModel> getVmInterfaceListProvider(EventBus eventBus, Provider<DefaultConfirmationPopupPresenterWidget> defaultConfirmPopupProvider, final Provider<VmInterfacePopupPresenterWidget> popupProvider, final Provider<RemoveConfirmationPopupPresenterWidget> removeConfirmPopupProvider, final Provider<VmListModel<Void>> mainModelProvider, final Provider<VmInterfaceListModel> modelProvider) {
SearchableDetailTabModelProvider<VmNetworkInterface, VmListModel<Void>, VmInterfaceListModel> result = new SearchableDetailTabModelProvider<VmNetworkInterface, VmListModel<Void>, VmInterfaceListModel>(eventBus, defaultConfirmPopupProvider) {
@Override
public AbstractModelBoundPopupPresenterWidget<? extends Model, ?> getModelPopup(VmInterfaceListModel source, UICommand lastExecutedCommand, Model windowModel) {
VmInterfaceListModel model = getModel();
if (lastExecutedCommand == model.getNewCommand() || lastExecutedCommand == model.getEditCommand()) {
return popupProvider.get();
} else {
return super.getModelPopup(source, lastExecutedCommand, windowModel);
}
}
@Override
public AbstractModelBoundPopupPresenterWidget<? extends ConfirmationModel, ?> getConfirmModelPopup(VmInterfaceListModel source, UICommand lastExecutedCommand) {
if (lastExecutedCommand == getModel().getRemoveCommand()) {
return removeConfirmPopupProvider.get();
} else {
return super.getConfirmModelPopup(source, lastExecutedCommand);
}
}
};
result.setMainModelProvider(mainModelProvider);
result.setModelProvider(modelProvider);
return result;
}
use of org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface in project ovirt-engine by oVirt.
the class VfSchedulerImplTest method validLabelInSriovConfig.
@Test
public void validLabelInSriovConfig() {
VmNetworkInterface vnic = mockVnic(true);
initHostWithOneVfsConfig(Collections.singletonList(vnic), 1, false, false, true, true);
assertHostValid(Collections.singletonList(vnic));
}
Aggregations