Search in sources :

Example 6 with VnicProfile

use of org.ovirt.engine.core.common.businessentities.network.VnicProfile in project ovirt-engine by oVirt.

the class VnicProfileValidatorTest method getSingletonNamedVnicProfileList.

private static List<VnicProfile> getSingletonNamedVnicProfileList(String vnicProfileName, Guid vnicProfileId) {
    VnicProfile vnicProfile = mock(VnicProfile.class);
    when(vnicProfile.getName()).thenReturn(vnicProfileName);
    when(vnicProfile.getId()).thenReturn(vnicProfileId);
    return Collections.singletonList(vnicProfile);
}
Also used : VnicProfile(org.ovirt.engine.core.common.businessentities.network.VnicProfile)

Example 7 with VnicProfile

use of org.ovirt.engine.core.common.businessentities.network.VnicProfile in project ovirt-engine by oVirt.

the class VnicProfileValidatorTest method mockVnicProfileNetworkChange.

private void mockVnicProfileNetworkChange(Guid vnicProfileId, Guid oldVnicProfileId) {
    VnicProfile vnicProfile = mock(VnicProfile.class);
    when(this.vnicProfile.getNetworkId()).thenReturn(vnicProfileId);
    when(vnicProfile.getNetworkId()).thenReturn(oldVnicProfileId);
    when(vnicProfileDao.get(any())).thenReturn(vnicProfile);
}
Also used : VnicProfile(org.ovirt.engine.core.common.businessentities.network.VnicProfile)

Example 8 with VnicProfile

use of org.ovirt.engine.core.common.businessentities.network.VnicProfile in project ovirt-engine by oVirt.

the class VmInfoBuildUtilsTest method setUp.

@Before
public void setUp() {
    injectorRule.bind(AuditLogDirector.class, auditLogDirector);
    diskImage.setDiskProfileId(Guid.newGuid());
    qos = new StorageQos();
    qos.setId(Guid.newGuid());
    vmDevice = new VmDevice();
    VnicProfile vnicProfile = new VnicProfile();
    vnicProfile.setNetworkFilterId(NETWORK_FILTER_ID);
    when(vnicProfileDao.get(VNIC_PROFILE_ID)).thenReturn(vnicProfile);
    NetworkFilter networkFilter = new NetworkFilter();
    networkFilter.setName(NETWORK_FILTER_NAME);
    when(networkFilterDao.getNetworkFilterById(NETWORK_FILTER_ID)).thenReturn(networkFilter);
    when(vmNicFilterParameterDao.getAllForVmNic(VM_NIC_ID)).thenReturn(createVmNicFilterParameters());
}
Also used : StorageQos(org.ovirt.engine.core.common.businessentities.qos.StorageQos) VmDevice(org.ovirt.engine.core.common.businessentities.VmDevice) NetworkFilter(org.ovirt.engine.core.common.businessentities.network.NetworkFilter) VnicProfile(org.ovirt.engine.core.common.businessentities.network.VnicProfile) Before(org.junit.Before)

Example 9 with VnicProfile

use of org.ovirt.engine.core.common.businessentities.network.VnicProfile 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);
        }
    }
}
Also used : VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) Network(org.ovirt.engine.core.common.businessentities.network.Network) VnicProfile(org.ovirt.engine.core.common.businessentities.network.VnicProfile) NetworkProviderProxy(org.ovirt.engine.core.bll.provider.network.NetworkProviderProxy) VmDeviceId(org.ovirt.engine.core.common.businessentities.VmDeviceId)

Example 10 with VnicProfile

use of org.ovirt.engine.core.common.businessentities.network.VnicProfile 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;
}
Also used : Network(org.ovirt.engine.core.common.businessentities.network.Network) VnicProfile(org.ovirt.engine.core.common.businessentities.network.VnicProfile)

Aggregations

VnicProfile (org.ovirt.engine.core.common.businessentities.network.VnicProfile)31 Network (org.ovirt.engine.core.common.businessentities.network.Network)12 NetworkFilter (org.ovirt.engine.core.common.businessentities.network.NetworkFilter)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Test (org.junit.Test)3 VmNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface)3 Guid (org.ovirt.engine.core.compat.Guid)3 HashMap (java.util.HashMap)2 Before (org.junit.Before)2 ValidationResult (org.ovirt.engine.core.bll.ValidationResult)2 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)2 AddVnicProfileParameters (org.ovirt.engine.core.common.action.AddVnicProfileParameters)2 VM (org.ovirt.engine.core.common.businessentities.VM)2 NewVnicProfileModel (org.ovirt.engine.ui.uicommonweb.models.profiles.NewVnicProfileModel)2 Collections (java.util.Collections)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Inject (javax.inject.Inject)1