Search in sources :

Example 21 with Provider

use of com.cloud.legacymodel.network.Network.Provider in project cosmic by MissionCriticalCloud.

the class ApiResponseHelper method getProviderResponses.

private List<ProviderResponse> getProviderResponses(final Set<Provider> srvc_providers) {
    final List<ProviderResponse> providers = new ArrayList<>();
    for (final Provider provider : srvc_providers) {
        if (provider != null) {
            final ProviderResponse providerRsp = new ProviderResponse();
            providerRsp.setName(provider.getName());
            providers.add(providerRsp);
        }
    }
    return providers;
}
Also used : VirtualRouterProviderResponse(com.cloud.api.response.VirtualRouterProviderResponse) ProviderResponse(com.cloud.api.response.ProviderResponse) ArrayList(java.util.ArrayList) VirtualRouterProvider(com.cloud.network.VirtualRouterProvider) Provider(com.cloud.legacymodel.network.Network.Provider) PhysicalNetworkServiceProvider(com.cloud.network.PhysicalNetworkServiceProvider)

Example 22 with Provider

use of com.cloud.legacymodel.network.Network.Provider in project cosmic by MissionCriticalCloud.

the class ApiResponseHelper method createNetworkServiceProviderResponse.

@Override
public ProviderResponse createNetworkServiceProviderResponse(final PhysicalNetworkServiceProvider result) {
    final ProviderResponse response = new ProviderResponse();
    response.setId(result.getUuid());
    response.setName(result.getProviderName());
    final PhysicalNetwork pnw = ApiDBUtils.findPhysicalNetworkById(result.getPhysicalNetworkId());
    if (pnw != null) {
        response.setPhysicalNetworkId(pnw.getUuid());
    }
    final PhysicalNetwork dnw = ApiDBUtils.findPhysicalNetworkById(result.getDestinationPhysicalNetworkId());
    if (dnw != null) {
        response.setDestinationPhysicalNetworkId(dnw.getUuid());
    }
    response.setState(result.getState().toString());
    // set enabled services
    final List<String> services = new ArrayList<>();
    for (final Service service : result.getEnabledServices()) {
        services.add(service.getName());
    }
    response.setServices(services);
    final Provider serviceProvider = Provider.getProvider(result.getProviderName());
    final boolean canEnableIndividualServices = ApiDBUtils.canElementEnableIndividualServices(serviceProvider);
    response.setCanEnableIndividualServices(canEnableIndividualServices);
    response.setObjectName("networkserviceprovider");
    return response;
}
Also used : VirtualRouterProviderResponse(com.cloud.api.response.VirtualRouterProviderResponse) ProviderResponse(com.cloud.api.response.ProviderResponse) PhysicalNetwork(com.cloud.network.PhysicalNetwork) ArrayList(java.util.ArrayList) Service(com.cloud.legacymodel.network.Network.Service) VirtualRouterProvider(com.cloud.network.VirtualRouterProvider) Provider(com.cloud.legacymodel.network.Network.Provider) PhysicalNetworkServiceProvider(com.cloud.network.PhysicalNetworkServiceProvider)

Example 23 with Provider

use of com.cloud.legacymodel.network.Network.Provider in project cosmic by MissionCriticalCloud.

the class VirtualNetworkApplianceManagerImpl method finalizeCommandsOnStart.

@Override
public boolean finalizeCommandsOnStart(final Commands cmds, final VirtualMachineProfile profile) {
    final DomainRouterVO router = _routerDao.findById(profile.getId());
    final NicProfile controlNic = getControlNic(profile);
    if (controlNic == null) {
        s_logger.error("Control network doesn't exist for the router " + router);
        return false;
    }
    finalizeSshAndVersionAndNetworkUsageOnStart(cmds, profile, router, controlNic);
    // restart network if restartNetwork = false is not specified in profile
    // parameters
    final boolean reprogramGuestNtwks = profile.getParameter(Param.ReProgramGuestNetworks) == null || (Boolean) profile.getParameter(Param.ReProgramGuestNetworks);
    final VirtualRouterProvider vrProvider = _vrProviderDao.findById(router.getElementId());
    if (vrProvider == null) {
        throw new CloudRuntimeException("Cannot find related virtual router provider of router: " + router.getHostName());
    }
    final Provider provider = Network.Provider.getProvider(vrProvider.getType().toString());
    if (provider == null) {
        throw new CloudRuntimeException("Cannot find related provider of virtual router provider: " + vrProvider.getType().toString());
    }
    final List<Long> routerGuestNtwkIds = _routerDao.getRouterNetworks(router.getId());
    for (final Long guestNetworkId : routerGuestNtwkIds) {
        final AggregationControlCommand startCmd = new AggregationControlCommand(Action.Start, router.getInstanceName(), controlNic.getIPv4Address(), _routerControlHelper.getRouterIpInNetwork(guestNetworkId, router.getId()));
        cmds.addCommand(startCmd);
        if (reprogramGuestNtwks) {
            finalizeNetworkRulesForNetwork(cmds, router, provider, guestNetworkId);
        }
        final AggregationControlCommand finishCmd = new AggregationControlCommand(Action.Finish, router.getInstanceName(), controlNic.getIPv4Address(), _routerControlHelper.getRouterIpInNetwork(guestNetworkId, router.getId()));
        cmds.addCommand(finishCmd);
    }
    return true;
}
Also used : VirtualRouterProvider(com.cloud.network.VirtualRouterProvider) CloudRuntimeException(com.cloud.legacymodel.exceptions.CloudRuntimeException) AggregationControlCommand(com.cloud.legacymodel.communication.command.AggregationControlCommand) NicProfile(com.cloud.vm.NicProfile) DomainRouterVO(com.cloud.vm.DomainRouterVO) VirtualRouterProvider(com.cloud.network.VirtualRouterProvider) Provider(com.cloud.legacymodel.network.Network.Provider)

Example 24 with Provider

use of com.cloud.legacymodel.network.Network.Provider in project cosmic by MissionCriticalCloud.

the class VirtualNetworkApplianceManagerImpl method getPublicIpsToApply.

protected ArrayList<? extends PublicIpAddress> getPublicIpsToApply(final VirtualRouter router, final Provider provider, final Long guestNetworkId, final com.cloud.network.IpAddress.State... skipInStates) {
    final long ownerId = router.getAccountId();
    final List<? extends IpAddress> userIps;
    final Network guestNetwork = _networkDao.findById(guestNetworkId);
    if (guestNetwork.getGuestType() == GuestType.Shared) {
        // ignore the account id for the shared network
        userIps = _networkModel.listPublicIpsAssignedToGuestNtwk(guestNetworkId, null);
    } else {
        userIps = _networkModel.listPublicIpsAssignedToGuestNtwk(ownerId, guestNetworkId, null);
    }
    final List<PublicIp> allPublicIps = new ArrayList<>();
    if (userIps != null && !userIps.isEmpty()) {
        boolean addIp = true;
        for (final IpAddress userIp : userIps) {
            if (skipInStates != null) {
                for (final IpAddress.State stateToSkip : skipInStates) {
                    if (userIp.getState() == stateToSkip) {
                        s_logger.debug("Skipping ip address " + userIp + " in state " + userIp.getState());
                        addIp = false;
                        break;
                    }
                }
            }
            if (addIp) {
                final IPAddressVO ipVO = _ipAddressDao.findById(userIp.getId());
                final PublicIp publicIp = PublicIp.createFromAddrAndVlan(ipVO, _vlanDao.findById(userIp.getVlanId()));
                allPublicIps.add(publicIp);
            }
        }
    }
    // Get public Ips that should be handled by router
    final Network network = _networkDao.findById(guestNetworkId);
    final Map<PublicIpAddress, Set<Service>> ipToServices = _networkModel.getIpToServices(allPublicIps, false, true);
    final Map<Provider, ArrayList<PublicIpAddress>> providerToIpList = _networkModel.getProviderToIpList(network, ipToServices);
    return providerToIpList.get(provider);
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) PublicIp(com.cloud.network.addr.PublicIp) ArrayList(java.util.ArrayList) VirtualRouterProvider(com.cloud.network.VirtualRouterProvider) Provider(com.cloud.legacymodel.network.Network.Provider) PublicIpAddress(com.cloud.network.PublicIpAddress) Network(com.cloud.legacymodel.network.Network) IpAddress(com.cloud.network.IpAddress) PublicIpAddress(com.cloud.network.PublicIpAddress) IPAddressVO(com.cloud.network.dao.IPAddressVO)

Example 25 with Provider

use of com.cloud.legacymodel.network.Network.Provider in project cosmic by MissionCriticalCloud.

the class VpcVirtualNetworkApplianceManagerImpl method sendNetworkRulesToRouter.

protected boolean sendNetworkRulesToRouter(final long routerId, final long networkId) throws ResourceUnavailableException {
    final DomainRouterVO router = _routerDao.findById(routerId);
    final Commands cmds = new Commands(OnError.Continue);
    final VirtualRouterProvider vrProvider = _vrProviderDao.findById(router.getElementId());
    if (vrProvider == null) {
        throw new CloudRuntimeException("Cannot find related virtual router provider of router: " + router.getHostName());
    }
    final Provider provider = Network.Provider.getProvider(vrProvider.getType().toString());
    if (provider == null) {
        throw new CloudRuntimeException("Cannot find related provider of virtual router provider: " + vrProvider.getType().toString());
    }
    finalizeNetworkRulesForNetwork(cmds, router, provider, networkId);
    return _nwHelper.sendCommandsToRouter(router, cmds);
}
Also used : VirtualRouterProvider(com.cloud.network.VirtualRouterProvider) CloudRuntimeException(com.cloud.legacymodel.exceptions.CloudRuntimeException) Commands(com.cloud.agent.manager.Commands) DomainRouterVO(com.cloud.vm.DomainRouterVO) Provider(com.cloud.legacymodel.network.Network.Provider) VirtualRouterProvider(com.cloud.network.VirtualRouterProvider)

Aggregations

Provider (com.cloud.legacymodel.network.Network.Provider)55 Service (com.cloud.legacymodel.network.Network.Service)29 HashSet (java.util.HashSet)25 UserDataServiceProvider (com.cloud.network.element.UserDataServiceProvider)22 HashMap (java.util.HashMap)22 Set (java.util.Set)22 ArrayList (java.util.ArrayList)21 NetworkElement (com.cloud.network.element.NetworkElement)19 LoadBalancingServiceProvider (com.cloud.network.element.LoadBalancingServiceProvider)15 InvalidParameterValueException (com.cloud.legacymodel.exceptions.InvalidParameterValueException)14 StaticNatServiceProvider (com.cloud.network.element.StaticNatServiceProvider)14 CloudRuntimeException (com.cloud.legacymodel.exceptions.CloudRuntimeException)13 DhcpServiceProvider (com.cloud.network.element.DhcpServiceProvider)13 NetworkOrchestrationService (com.cloud.engine.orchestration.service.NetworkOrchestrationService)12 ResourceLimitService (com.cloud.user.ResourceLimitService)12 Network (com.cloud.legacymodel.network.Network)11 VpcProvider (com.cloud.network.element.VpcProvider)10 NicProfile (com.cloud.vm.NicProfile)10 SortedSet (java.util.SortedSet)10 NetworkVO (com.cloud.network.dao.NetworkVO)8