Search in sources :

Example 61 with NetworkElement

use of com.cloud.network.element.NetworkElement in project cloudstack by apache.

the class NetworkServiceImpl method addDefaultOvsToPhysicalNetwork.

private PhysicalNetworkServiceProvider addDefaultOvsToPhysicalNetwork(long physicalNetworkId) {
    PhysicalNetworkServiceProvider nsp = addProviderToPhysicalNetwork(physicalNetworkId, Network.Provider.Ovs.getName(), null, null);
    NetworkElement networkElement = _networkModel.getElementImplementingProvider(Network.Provider.Ovs.getName());
    if (networkElement == null) {
        throw new CloudRuntimeException("Unable to find the Network Element implementing the Ovs Provider");
    }
    OvsProviderVO element = _ovsProviderDao.findByNspId(nsp.getId());
    if (element != null) {
        s_logger.debug("There is already a Ovs element with service provider id " + nsp.getId());
        return nsp;
    }
    element = new OvsProviderVO(nsp.getId());
    _ovsProviderDao.persist(element);
    return nsp;
}
Also used : NetworkElement(com.cloud.network.element.NetworkElement) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) OvsProviderVO(com.cloud.network.element.OvsProviderVO)

Example 62 with NetworkElement

use of com.cloud.network.element.NetworkElement in project cloudstack by apache.

the class NetworkServiceImpl method addDefaultVirtualRouterToPhysicalNetwork.

protected PhysicalNetworkServiceProvider addDefaultVirtualRouterToPhysicalNetwork(long physicalNetworkId) {
    PhysicalNetworkServiceProvider nsp = addProviderToPhysicalNetwork(physicalNetworkId, Network.Provider.VirtualRouter.getName(), null, null);
    // add instance of the provider
    NetworkElement networkElement = _networkModel.getElementImplementingProvider(Network.Provider.VirtualRouter.getName());
    if (networkElement == null) {
        throw new CloudRuntimeException("Unable to find the Network Element implementing the VirtualRouter Provider");
    }
    VirtualRouterElement element = (VirtualRouterElement) networkElement;
    element.addElement(nsp.getId(), Type.VirtualRouter);
    return nsp;
}
Also used : NetworkElement(com.cloud.network.element.NetworkElement) VpcVirtualRouterElement(com.cloud.network.element.VpcVirtualRouterElement) VirtualRouterElement(com.cloud.network.element.VirtualRouterElement) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException)

Example 63 with NetworkElement

use of com.cloud.network.element.NetworkElement in project cloudstack by apache.

the class NetworkServiceImpl method deleteNetworkServiceProvider.

@Override
@ActionEvent(eventType = EventTypes.EVENT_SERVICE_PROVIDER_DELETE, eventDescription = "Deleting physical network ServiceProvider", async = true)
public boolean deleteNetworkServiceProvider(Long id) throws ConcurrentOperationException, ResourceUnavailableException {
    PhysicalNetworkServiceProviderVO provider = _pNSPDao.findById(id);
    if (provider == null) {
        throw new InvalidParameterValueException("Network Service Provider id=" + id + "doesn't exist in the system");
    }
    // check if there are networks using this provider
    List<NetworkVO> networks = _networksDao.listByPhysicalNetworkAndProvider(provider.getPhysicalNetworkId(), provider.getProviderName());
    if (networks != null && !networks.isEmpty()) {
        throw new CloudRuntimeException("Provider is not deletable because there are active networks using this provider, please upgrade these networks to new network offerings");
    }
    User callerUser = _accountMgr.getActiveUser(CallContext.current().getCallingUserId());
    Account callerAccount = _accountMgr.getActiveAccountById(callerUser.getAccountId());
    // shutdown the provider instances
    ReservationContext context = new ReservationContextImpl(null, null, callerUser, callerAccount);
    if (s_logger.isDebugEnabled()) {
        s_logger.debug("Shutting down the service provider id=" + id + " on physical network: " + provider.getPhysicalNetworkId());
    }
    NetworkElement element = _networkModel.getElementImplementingProvider(provider.getProviderName());
    if (element == null) {
        throw new InvalidParameterValueException("Unable to find the Network Element implementing the Service Provider '" + provider.getProviderName() + "'");
    }
    if (element != null && element.shutdownProviderInstances(provider, context)) {
        provider.setState(PhysicalNetworkServiceProvider.State.Shutdown);
    }
    return _pNSPDao.remove(id);
}
Also used : Account(com.cloud.user.Account) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) NetworkVO(com.cloud.network.dao.NetworkVO) User(com.cloud.user.User) NetworkElement(com.cloud.network.element.NetworkElement) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) PhysicalNetworkServiceProviderVO(com.cloud.network.dao.PhysicalNetworkServiceProviderVO) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ReservationContextImpl(com.cloud.vm.ReservationContextImpl) ReservationContext(com.cloud.vm.ReservationContext) ActionEvent(com.cloud.event.ActionEvent)

Example 64 with NetworkElement

use of com.cloud.network.element.NetworkElement in project cloudstack by apache.

the class NetworkServiceImpl method addDefaultInternalLbProviderToPhysicalNetwork.

protected PhysicalNetworkServiceProvider addDefaultInternalLbProviderToPhysicalNetwork(long physicalNetworkId) {
    PhysicalNetworkServiceProvider nsp = addProviderToPhysicalNetwork(physicalNetworkId, Network.Provider.InternalLbVm.getName(), null, null);
    NetworkElement networkElement = _networkModel.getElementImplementingProvider(Network.Provider.InternalLbVm.getName());
    if (networkElement == null) {
        throw new CloudRuntimeException("Unable to find the Network Element implementing the " + Network.Provider.InternalLbVm.getName() + " Provider");
    }
    _internalLbElementSvc.addInternalLoadBalancerElement(nsp.getId());
    return nsp;
}
Also used : NetworkElement(com.cloud.network.element.NetworkElement) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException)

Example 65 with NetworkElement

use of com.cloud.network.element.NetworkElement in project cloudstack by apache.

the class ExternalLoadBalancerDeviceManagerImpl method getIpDeployerForInlineMode.

protected IpDeployer getIpDeployerForInlineMode(Network network) {
    // We won't deploy IP, instead the firewall in front of us would do it
    List<Provider> providers = _networkMgr.getProvidersForServiceInNetwork(network, Service.Firewall);
    // Only support one provider now
    if (providers == null) {
        s_logger.error("Cannot find firewall provider for network " + network.getId());
        return null;
    }
    if (providers.size() != 1) {
        s_logger.error("Found " + providers.size() + " firewall provider for network " + network.getId());
        return null;
    }
    NetworkElement element = _networkModel.getElementImplementingProvider(providers.get(0).getName());
    if (!(element instanceof IpDeployer)) {
        s_logger.error("The firewall provider for network " + network.getName() + " don't have ability to deploy IP address!");
        return null;
    }
    s_logger.info("Let " + element.getName() + " handle ip association for " + getName() + " in network " + network.getId());
    return (IpDeployer) element;
}
Also used : NetworkElement(com.cloud.network.element.NetworkElement) IpDeployer(com.cloud.network.element.IpDeployer) StaticNatServiceProvider(com.cloud.network.element.StaticNatServiceProvider) Provider(com.cloud.network.Network.Provider)

Aggregations

NetworkElement (com.cloud.network.element.NetworkElement)69 Provider (com.cloud.network.Network.Provider)43 UserDataServiceProvider (com.cloud.network.element.UserDataServiceProvider)33 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)33 Service (com.cloud.network.Network.Service)29 StaticNatServiceProvider (com.cloud.network.element.StaticNatServiceProvider)27 DhcpServiceProvider (com.cloud.network.element.DhcpServiceProvider)25 LoadBalancingServiceProvider (com.cloud.network.element.LoadBalancingServiceProvider)25 UnsupportedServiceException (com.cloud.exception.UnsupportedServiceException)20 HashMap (java.util.HashMap)20 Map (java.util.Map)20 PhysicalNetworkVO (com.cloud.network.dao.PhysicalNetworkVO)19 NetworkVO (com.cloud.network.dao.NetworkVO)17 ArrayList (java.util.ArrayList)17 ConfigDriveNetworkElement (com.cloud.network.element.ConfigDriveNetworkElement)16 NetworkGuru (com.cloud.network.guru.NetworkGuru)16 NicProfile (com.cloud.vm.NicProfile)16 Capability (com.cloud.network.Network.Capability)15 NicVO (com.cloud.vm.NicVO)13 NetworkOrchestrationService (org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService)13