use of org.ovirt.engine.core.common.businessentities.network.VnicProfile in project ovirt-engine by oVirt.
the class InternalImportExternalNetworkCommandTest method setUp.
@Before
public void setUp() {
prepareNetwork(commandNoCluster.getParameters().getExternalNetwork());
prepareNetwork(commandCluster.getParameters().getExternalNetwork());
when(backend.runInternalAction(eq(ActionType.AddNetwork), any(), any())).thenReturn(getAddNetworkReturnValue());
when(networkHelper.createVnicProfile(any())).thenReturn(new VnicProfile());
ActionReturnValue returnValue = new ActionReturnValue();
returnValue.setSucceeded(true);
when(networkHelper.attachNetworkToClusters(eq(NETWORK_ID), any())).thenReturn(returnValue);
QueryReturnValue queryReturnValue = new QueryReturnValue();
queryReturnValue.setReturnValue(getClusters());
queryReturnValue.setSucceeded(true);
when(backend.runInternalQuery(eq(QueryType.GetClustersByStoragePoolId), any(), any())).thenReturn(queryReturnValue);
}
use of org.ovirt.engine.core.common.businessentities.network.VnicProfile in project ovirt-engine by oVirt.
the class VnicProfileValidatorTest method mockVnicProfilePortMirroringChange.
private void mockVnicProfilePortMirroringChange(boolean portMirroring) {
VnicProfile vnicProfile = mock(VnicProfile.class);
when(this.vnicProfile.isPortMirroring()).thenReturn(portMirroring);
when(vnicProfile.isPortMirroring()).thenReturn(!portMirroring);
when(vnicProfileDao.get(any())).thenReturn(vnicProfile);
}
use of org.ovirt.engine.core.common.businessentities.network.VnicProfile in project ovirt-engine by oVirt.
the class VnicProfileModel method updateNetworks.
protected void updateNetworks(Collection<Network> networks) {
VnicProfile profile = getProfile();
if (profile != null && profile.getNetworkId() != null) {
Network selected = networks.stream().filter(net -> Objects.equals(profile.getNetworkId(), net.getId())).findFirst().get();
getNetwork().setSelectedItem(selected);
getNetwork().setIsChangeable(false);
}
}
use of org.ovirt.engine.core.common.businessentities.network.VnicProfile in project ovirt-engine by oVirt.
the class VnicProfileModel method flush.
public void flush() {
if (vnicProfile == null) {
vnicProfile = new VnicProfile();
}
vnicProfile.setName(getName().getEntity());
Network network = getNetwork().getSelectedItem();
vnicProfile.setNetworkId(network != null ? network.getId() : null);
NetworkQoS networkQoS = getNetworkQoS().getSelectedItem();
vnicProfile.setNetworkQosId(networkQoS != null && networkQoS.getId() != null && !networkQoS.getId().equals(Guid.Empty) ? networkQoS.getId() : null);
NetworkFilter networkFilter = getNetworkFilter().getSelectedItem();
vnicProfile.setNetworkFilterId(networkFilter != null ? networkFilter.getId() : null);
vnicProfile.setPortMirroring(getPortMirroring().getEntity());
vnicProfile.setPassthrough(getPassthrough().getEntity());
if (vnicProfile.isPassthrough()) {
vnicProfile.setMigratable(getMigratable().getEntity());
}
if (customPropertiesVisible) {
vnicProfile.setCustomProperties(KeyValueModel.convertProperties(getCustomPropertySheet().serialize()));
} else {
vnicProfile.setCustomProperties(null);
}
vnicProfile.setDescription(getDescription().getEntity());
}
use of org.ovirt.engine.core.common.businessentities.network.VnicProfile in project ovirt-engine by oVirt.
the class SyncNetworkProviderCommand method disconnectVms.
private void disconnectVms(Guid networkId) {
Map<Guid, VnicProfile> profiles = vnicProfileDao.getAllForNetwork(networkId).stream().collect(Collectors.toConcurrentMap(VnicProfile::getId, Function.identity()));
for (VM vm : vmDao.getAllForNetwork(networkId)) {
vmHandler.updateNetworkInterfacesFromDb(vm);
for (VmNetworkInterface iface : vm.getInterfaces()) {
if (profiles.get(iface.getVnicProfileId()) != null) {
log.warn("External network '{}' disappeared from provider '{}', disconnecting interface '{}' of VM '{}'.", networkId, getProvider().getName(), iface.getName(), vm.getName());
iface.setVnicProfileId(null);
iface.setPlugged(false);
propagateReturnValue(runInternalAction(ActionType.UpdateVmInterface, new AddVmInterfaceParameters(vm.getId(), iface), getInternalCommandContext()));
}
}
}
}
Aggregations