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);
}
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);
}
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());
}
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);
}
}
}
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;
}
Aggregations