Search in sources :

Example 66 with VmNetworkInterface

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);
}
Also used : VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) ArrayList(java.util.ArrayList) ValidationResult(org.ovirt.engine.core.bll.ValidationResult)

Example 67 with VmNetworkInterface

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;
}
Also used : VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) VM(org.ovirt.engine.core.common.businessentities.VM) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 68 with VmNetworkInterface

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);
}
Also used : VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) ExternalVnicProfileMapping(org.ovirt.engine.core.common.businessentities.network.ExternalVnicProfileMapping)

Example 69 with VmNetworkInterface

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;
}
Also used : VmListModel(org.ovirt.engine.ui.uicommonweb.models.vms.VmListModel) VmInterfaceListModel(org.ovirt.engine.ui.uicommonweb.models.vms.VmInterfaceListModel) VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) VmListModel(org.ovirt.engine.ui.uicommonweb.models.vms.VmListModel) VmDevicesListModel(org.ovirt.engine.ui.uicommonweb.models.vms.VmDevicesListModel) VmAffinityGroupListModel(org.ovirt.engine.ui.uicommonweb.models.configure.scheduling.affinity_groups.list.VmAffinityGroupListModel) VmErrataCountModel(org.ovirt.engine.ui.uicommonweb.models.VmErrataCountModel) VmGuestInfoModel(org.ovirt.engine.ui.uicommonweb.models.vms.VmGuestInfoModel) AttachDiskModel(org.ovirt.engine.ui.uicommonweb.models.vms.AttachDiskModel) NewDiskModel(org.ovirt.engine.ui.uicommonweb.models.vms.NewDiskModel) VmInterfaceListModel(org.ovirt.engine.ui.uicommonweb.models.vms.VmInterfaceListModel) ImportVmsModel(org.ovirt.engine.ui.uicommonweb.models.vms.ImportVmsModel) VmHighPerformanceConfigurationModel(org.ovirt.engine.ui.uicommonweb.models.vms.VmHighPerformanceConfigurationModel) VncInfoModel(org.ovirt.engine.ui.uicommonweb.models.vms.VncInfoModel) ImportVmFromExportDomainModel(org.ovirt.engine.ui.uicommonweb.models.vms.ImportVmFromExportDomainModel) VmDiskListModel(org.ovirt.engine.ui.uicommonweb.models.vms.VmDiskListModel) VmAffinityLabelListModel(org.ovirt.engine.ui.uicommonweb.models.configure.labels.list.VmAffinityLabelListModel) VmAppListModel(org.ovirt.engine.ui.uicommonweb.models.vms.VmAppListModel) PermissionListModel(org.ovirt.engine.ui.uicommonweb.models.configure.PermissionListModel) EditDiskModel(org.ovirt.engine.ui.uicommonweb.models.vms.EditDiskModel) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel) VmSnapshotListModel(org.ovirt.engine.ui.uicommonweb.models.vms.VmSnapshotListModel) VmEventListModel(org.ovirt.engine.ui.uicommonweb.models.vms.VmEventListModel) VmGeneralModel(org.ovirt.engine.ui.uicommonweb.models.vms.VmGeneralModel) Model(org.ovirt.engine.ui.uicommonweb.models.Model) VmGuestContainerListModel(org.ovirt.engine.ui.uicommonweb.models.vms.VmGuestContainerListModel) VmHostDeviceListModel(org.ovirt.engine.ui.uicommonweb.models.vms.hostdev.VmHostDeviceListModel) ImportVmFromExternalProviderModel(org.ovirt.engine.ui.uicommonweb.models.vms.ImportVmFromExternalProviderModel) VmNextRunConfigurationModel(org.ovirt.engine.ui.uicommonweb.models.vms.VmNextRunConfigurationModel) VmErrataListModel(org.ovirt.engine.ui.uicommonweb.models.VmErrataListModel) VmImportGeneralModel(org.ovirt.engine.ui.uicommonweb.models.vms.VmImportGeneralModel) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) SearchableDetailTabModelProvider(org.ovirt.engine.ui.common.uicommon.model.SearchableDetailTabModelProvider) Singleton(com.google.inject.Singleton) Provides(com.google.inject.Provides)

Example 70 with VmNetworkInterface

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));
}
Also used : VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) Test(org.junit.Test)

Aggregations

VmNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface)115 Test (org.junit.Test)27 ArrayList (java.util.ArrayList)25 Guid (org.ovirt.engine.core.compat.Guid)19 VM (org.ovirt.engine.core.common.businessentities.VM)16 HashMap (java.util.HashMap)11 List (java.util.List)9 Map (java.util.Map)9 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)6 PairQueryable (org.ovirt.engine.core.common.utils.PairQueryable)6 MapVnicsContext (org.ovirt.engine.core.bll.exportimport.vnics.MapVnicsContext)5 VmDevice (org.ovirt.engine.core.common.businessentities.VmDevice)5 HostNicVfsConfig (org.ovirt.engine.core.common.businessentities.network.HostNicVfsConfig)5 VmNetworkStatistics (org.ovirt.engine.core.common.businessentities.network.VmNetworkStatistics)5 Nic (org.ovirt.engine.api.model.Nic)4 VnicProfileHelper (org.ovirt.engine.core.bll.network.vm.VnicProfileHelper)4 VmTemplate (org.ovirt.engine.core.common.businessentities.VmTemplate)4 Network (org.ovirt.engine.core.common.businessentities.network.Network)4 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)4 Collection (java.util.Collection)3