use of org.ovirt.engine.core.bll.provider.network.NetworkProviderProxy 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.bll.provider.network.NetworkProviderProxy in project ovirt-engine by oVirt.
the class ImportExternalNetworkCommand method getNetwork.
protected Network getNetwork() {
if (network == null) {
NetworkProviderProxy proxy = providerProxyFactory.create(getProvider());
String networkId = getParameters().getNetworkExternalId();
network = proxy.getAll().stream().filter(network -> networkId.equals(network.getProvidedBy().getExternalId())).findFirst().orElse(null);
}
return network;
}
use of org.ovirt.engine.core.bll.provider.network.NetworkProviderProxy in project ovirt-engine by oVirt.
the class ExternalNetworkManager method deallocateIfExternal.
/**
* Deallocate the vNIC from the external network, if it's attached to a network and the network is indeed an
* external network (otherwise, nothing is done).
*/
public void deallocateIfExternal() {
if (getNetwork() != null && getNetwork().isExternal()) {
Provider<?> provider = providerDao.get(getNetwork().getProvidedBy().getProviderId());
NetworkProviderProxy providerProxy = providerProxyFactory.create(provider);
try {
providerProxy.deallocate(nic);
} catch (EngineException e) {
AuditLogable removePortFailureEvent = new AuditLogableImpl();
removePortFailureEvent.addCustomValue("NicName", nic.getName());
removePortFailureEvent.addCustomValue("NicId", nic.getId().toString());
removePortFailureEvent.addCustomValue("ProviderName", provider.getName());
auditLogDirector.log(removePortFailureEvent, AuditLogType.REMOVE_PORT_FROM_EXTERNAL_PROVIDER_FAILED);
}
}
}
use of org.ovirt.engine.core.bll.provider.network.NetworkProviderProxy in project ovirt-engine by oVirt.
the class RemoveNetworkCommand method removeExternalNetwork.
private void removeExternalNetwork() {
NetworkProviderProxy proxy = providerProxyFactory.create(getProvider());
proxy.remove(getNetwork().getProvidedBy().getExternalId());
}
Aggregations