Search in sources :

Example 1 with NetworkProviderProxy

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);
        }
    }
}
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 2 with NetworkProviderProxy

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;
}
Also used : NonTransactiveCommandAttribute(org.ovirt.engine.core.bll.NonTransactiveCommandAttribute) LockProperties(org.ovirt.engine.core.common.action.LockProperties) Guid(org.ovirt.engine.core.compat.Guid) ProviderDao(org.ovirt.engine.core.dao.provider.ProviderDao) Provider(org.ovirt.engine.core.common.businessentities.Provider) ActionReturnValue(org.ovirt.engine.core.common.action.ActionReturnValue) Inject(javax.inject.Inject) CommandContext(org.ovirt.engine.core.bll.context.CommandContext) ActionType(org.ovirt.engine.core.common.action.ActionType) ImportExternalNetworkParameters(org.ovirt.engine.core.common.action.ImportExternalNetworkParameters) Map(java.util.Map) NetworkProviderProxy(org.ovirt.engine.core.bll.provider.network.NetworkProviderProxy) Network(org.ovirt.engine.core.common.businessentities.network.Network) NetworkLocking(org.ovirt.engine.core.bll.NetworkLocking) Pair(org.ovirt.engine.core.common.utils.Pair) ProviderProxyFactory(org.ovirt.engine.core.bll.provider.ProviderProxyFactory) NetworkValidator(org.ovirt.engine.core.bll.validator.NetworkValidator) NetworkProviderValidator(org.ovirt.engine.core.bll.provider.NetworkProviderValidator) InternalImportExternalNetworkParameters(org.ovirt.engine.core.common.action.InternalImportExternalNetworkParameters) EngineMessage(org.ovirt.engine.core.common.errors.EngineMessage) CommandBase(org.ovirt.engine.core.bll.CommandBase) List(java.util.List) PermissionSubject(org.ovirt.engine.core.bll.utils.PermissionSubject) AuditLogType(org.ovirt.engine.core.common.AuditLogType) VdcObjectType(org.ovirt.engine.core.common.VdcObjectType) Collections(java.util.Collections) NetworkProviderProxy(org.ovirt.engine.core.bll.provider.network.NetworkProviderProxy)

Example 3 with NetworkProviderProxy

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);
        }
    }
}
Also used : AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) EngineException(org.ovirt.engine.core.common.errors.EngineException) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl) NetworkProviderProxy(org.ovirt.engine.core.bll.provider.network.NetworkProviderProxy)

Example 4 with NetworkProviderProxy

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());
}
Also used : NetworkProviderProxy(org.ovirt.engine.core.bll.provider.network.NetworkProviderProxy)

Aggregations

NetworkProviderProxy (org.ovirt.engine.core.bll.provider.network.NetworkProviderProxy)4 Network (org.ovirt.engine.core.common.businessentities.network.Network)2 Collections (java.util.Collections)1 List (java.util.List)1 Map (java.util.Map)1 Inject (javax.inject.Inject)1 CommandBase (org.ovirt.engine.core.bll.CommandBase)1 NetworkLocking (org.ovirt.engine.core.bll.NetworkLocking)1 NonTransactiveCommandAttribute (org.ovirt.engine.core.bll.NonTransactiveCommandAttribute)1 CommandContext (org.ovirt.engine.core.bll.context.CommandContext)1 NetworkProviderValidator (org.ovirt.engine.core.bll.provider.NetworkProviderValidator)1 ProviderProxyFactory (org.ovirt.engine.core.bll.provider.ProviderProxyFactory)1 PermissionSubject (org.ovirt.engine.core.bll.utils.PermissionSubject)1 NetworkValidator (org.ovirt.engine.core.bll.validator.NetworkValidator)1 AuditLogType (org.ovirt.engine.core.common.AuditLogType)1 VdcObjectType (org.ovirt.engine.core.common.VdcObjectType)1 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)1 ActionType (org.ovirt.engine.core.common.action.ActionType)1 ImportExternalNetworkParameters (org.ovirt.engine.core.common.action.ImportExternalNetworkParameters)1 InternalImportExternalNetworkParameters (org.ovirt.engine.core.common.action.InternalImportExternalNetworkParameters)1