Search in sources :

Example 21 with NetworkTopology

use of com.cloud.network.topology.NetworkTopology in project cosmic by MissionCriticalCloud.

the class VpcVirtualRouterElement method applyVpnUsers.

@Override
public String[] applyVpnUsers(final RemoteAccessVpn vpn, final List<? extends VpnUser> users) throws ResourceUnavailableException {
    final Long vpcId = vpn.getVpcId();
    if (vpcId == null) {
        return null;
    }
    final List<DomainRouterVO> routers = _vpcRouterMgr.getVpcRouters(vpcId);
    if (routers == null) {
        s_logger.debug("Cannot apply vpn users on the backend; virtual router doesn't exist in the network " + vpcId);
        return null;
    }
    final Vpc vpc = _entityMgr.findById(Vpc.class, vpcId);
    final Zone zone = zoneRepository.findOne(vpc.getZoneId());
    final NetworkTopology networkTopology = networkTopologyContext.retrieveNetworkTopology(zone);
    String[] result;
    final List<String> combinedResults = new ArrayList<>();
    for (final DomainRouterVO domainRouterVO : routers) {
        result = networkTopology.applyVpnUsers(vpn, users, domainRouterVO);
        combinedResults.addAll(Arrays.asList(result));
    }
    result = new String[combinedResults.size()];
    final Object[] resultCast = combinedResults.toArray();
    System.arraycopy(resultCast, 0, result, 0, resultCast.length);
    return result;
}
Also used : Zone(com.cloud.db.model.Zone) NetworkTopology(com.cloud.network.topology.NetworkTopology) Vpc(com.cloud.network.vpc.Vpc) ArrayList(java.util.ArrayList) DomainRouterVO(com.cloud.vm.DomainRouterVO)

Example 22 with NetworkTopology

use of com.cloud.network.topology.NetworkTopology in project cosmic by MissionCriticalCloud.

the class VpcVirtualRouterElement method applyIps.

@Override
public boolean applyIps(final Network network, final List<? extends PublicIpAddress> ipAddress, final Set<Service> services) throws ResourceUnavailableException {
    boolean canHandle = true;
    for (final Service service : services) {
        if (!canHandle(network, service)) {
            canHandle = false;
            break;
        }
    }
    boolean result = true;
    if (canHandle) {
        final List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(network.getId(), Role.VIRTUAL_ROUTER);
        if (routers == null || routers.isEmpty()) {
            s_logger.debug(getName() + " element doesn't need to associate ip addresses on the backend; VPC virtual router doesn't exist in the network " + network.getId());
            return false;
        }
        final Zone zone = zoneRepository.findOne(network.getDataCenterId());
        final NetworkTopology networkTopology = networkTopologyContext.retrieveNetworkTopology(zone);
        for (final DomainRouterVO domainRouterVO : routers) {
            result = result && networkTopology.associatePublicIP(network, ipAddress, domainRouterVO);
        }
    }
    return result;
}
Also used : Zone(com.cloud.db.model.Zone) NetworkTopology(com.cloud.network.topology.NetworkTopology) Service(com.cloud.network.Network.Service) DomainRouterVO(com.cloud.vm.DomainRouterVO)

Example 23 with NetworkTopology

use of com.cloud.network.topology.NetworkTopology in project cosmic by MissionCriticalCloud.

the class VpcVirtualRouterElement method applyACLItemsToPublicIp.

@Override
public boolean applyACLItemsToPublicIp(final IpAddress publicIp, final List<? extends NetworkACLItem> rules) throws ResourceUnavailableException {
    final List<DomainRouterVO> routers = _vpcRouterMgr.getVpcRouters(publicIp.getVpcId());
    if (routers == null || routers.isEmpty()) {
        s_logger.debug("Virtual router element doesn't need to apply network acl rules on the backend; virtual router doesn't exist for the public ip " + publicIp.getId());
        return true;
    }
    final Zone zone = zoneRepository.findOne(publicIp.getDataCenterId());
    final NetworkTopology networkTopology = networkTopologyContext.retrieveNetworkTopology(zone);
    final Network publicNetwork = _networkModel.getNetwork(publicIp.getNetworkId());
    boolean result = true;
    for (final DomainRouterVO domainRouterVO : routers) {
        final NicProfile nicProfile = _networkModel.getNicProfile(domainRouterVO, publicNetwork.getId(), null);
        if (nicProfile != null) {
            result = result && networkTopology.applyPublicIpACLs(publicNetwork, publicIp, rules, domainRouterVO);
        } else {
            s_logger.warn("Nic Profile for router '" + domainRouterVO + "' has already been removed. Router is redundant = " + domainRouterVO.getIsRedundantRouter());
        }
    }
    return result;
}
Also used : Zone(com.cloud.db.model.Zone) NetworkTopology(com.cloud.network.topology.NetworkTopology) Network(com.cloud.network.Network) NicProfile(com.cloud.vm.NicProfile) DomainRouterVO(com.cloud.vm.DomainRouterVO)

Aggregations

Zone (com.cloud.db.model.Zone)23 NetworkTopology (com.cloud.network.topology.NetworkTopology)23 DomainRouterVO (com.cloud.vm.DomainRouterVO)23 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)9 VirtualMachineProfile (com.cloud.vm.VirtualMachineProfile)6 Network (com.cloud.network.Network)5 UserVmVO (com.cloud.vm.UserVmVO)4 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)3 NicProfile (com.cloud.vm.NicProfile)3 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)2 IllegalVirtualMachineException (com.cloud.exception.IllegalVirtualMachineException)2 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)2 Service (com.cloud.network.Network.Service)2 ArrayList (java.util.ArrayList)2 AgentControlAnswer (com.cloud.agent.api.AgentControlAnswer)1 Answer (com.cloud.agent.api.Answer)1 CheckRouterAnswer (com.cloud.agent.api.CheckRouterAnswer)1 CheckS2SVpnConnectionsAnswer (com.cloud.agent.api.CheckS2SVpnConnectionsAnswer)1 GetDomRVersionAnswer (com.cloud.agent.api.GetDomRVersionAnswer)1 NetworkUsageAnswer (com.cloud.agent.api.NetworkUsageAnswer)1