Search in sources :

Example 11 with NetworkTopology

use of org.apache.cloudstack.network.topology.NetworkTopology in project cloudstack by apache.

the class VirtualNetworkApplianceManagerImpl method finalizeStop.

@Override
public void finalizeStop(final VirtualMachineProfile profile, final Answer answer) {
    if (answer != null) {
        final VirtualMachine vm = profile.getVirtualMachine();
        final DomainRouterVO domR = _routerDao.findById(vm.getId());
        processStopOrRebootAnswer(domR, answer);
        final List<? extends Nic> routerNics = _nicDao.listByVmId(profile.getId());
        for (final Nic nic : routerNics) {
            final Network network = _networkModel.getNetwork(nic.getNetworkId());
            final DataCenterVO dcVO = _dcDao.findById(network.getDataCenterId());
            if (network.getTrafficType() == TrafficType.Guest && nic.getBroadcastUri() != null && nic.getBroadcastUri().getScheme().equals("pvlan")) {
                final NicProfile nicProfile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(), 0, false, "pvlan-nic");
                final NetworkTopology networkTopology = _networkTopologyContext.retrieveNetworkTopology(dcVO);
                try {
                    networkTopology.setupDhcpForPvlan(false, domR, domR.getHostId(), nicProfile);
                } catch (final ResourceUnavailableException e) {
                    s_logger.debug("ERROR in finalizeStop: ", e);
                }
            }
        }
    }
}
Also used : DataCenterVO(com.cloud.dc.DataCenterVO) Network(com.cloud.network.Network) NetworkTopology(org.apache.cloudstack.network.topology.NetworkTopology) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) Nic(com.cloud.vm.Nic) NicProfile(com.cloud.vm.NicProfile) DomainRouterVO(com.cloud.vm.DomainRouterVO) VirtualMachine(com.cloud.vm.VirtualMachine)

Example 12 with NetworkTopology

use of org.apache.cloudstack.network.topology.NetworkTopology in project cloudstack by apache.

the class OvsElement method applyLBRules.

@Override
public boolean applyLBRules(final Network network, final List<LoadBalancingRule> rules) throws ResourceUnavailableException {
    boolean result = true;
    if (canHandle(network, Service.Lb)) {
        if (!canHandleLbRules(rules)) {
            return false;
        }
        final List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(network.getId(), Role.VIRTUAL_ROUTER);
        if (routers == null || routers.isEmpty()) {
            s_logger.debug("Virtual router elemnt doesn't need to apply firewall rules on the backend; virtual " + "router doesn't exist in the network " + network.getId());
            return true;
        }
        final DataCenterVO dcVO = _dcDao.findById(network.getDataCenterId());
        final NetworkTopology networkTopology = _networkTopologyContext.retrieveNetworkTopology(dcVO);
        for (final DomainRouterVO domainRouterVO : routers) {
            result = result && networkTopology.applyLoadBalancingRules(network, rules, domainRouterVO);
            if (!result) {
                s_logger.debug("Failed to apply load balancing rules in network " + network.getId());
            }
        }
    }
    return result;
}
Also used : DataCenterVO(com.cloud.dc.DataCenterVO) NetworkTopology(org.apache.cloudstack.network.topology.NetworkTopology) DomainRouterVO(com.cloud.vm.DomainRouterVO)

Example 13 with NetworkTopology

use of org.apache.cloudstack.network.topology.NetworkTopology in project cloudstack by apache.

the class OvsElement method applyStaticNats.

@Override
public boolean applyStaticNats(final Network network, final List<? extends StaticNat> rules) throws ResourceUnavailableException {
    if (!canHandle(network, Service.StaticNat)) {
        return false;
    }
    final List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(network.getId(), Role.VIRTUAL_ROUTER);
    if (routers == null || routers.isEmpty()) {
        s_logger.debug("Ovs element doesn't need to apply static nat on the backend; virtual " + "router doesn't exist in the network " + network.getId());
        return true;
    }
    final DataCenterVO dcVO = _dcDao.findById(network.getDataCenterId());
    final NetworkTopology networkTopology = _networkTopologyContext.retrieveNetworkTopology(dcVO);
    boolean result = true;
    for (final DomainRouterVO domainRouterVO : routers) {
        result = result && networkTopology.applyStaticNats(network, rules, domainRouterVO);
    }
    return result;
}
Also used : DataCenterVO(com.cloud.dc.DataCenterVO) NetworkTopology(org.apache.cloudstack.network.topology.NetworkTopology) DomainRouterVO(com.cloud.vm.DomainRouterVO)

Example 14 with NetworkTopology

use of org.apache.cloudstack.network.topology.NetworkTopology in project cloudstack by apache.

the class VirtualRouterElement 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 = getRouters(network);
        if (routers == null || routers.isEmpty()) {
            s_logger.debug("Virtual router elemnt doesn't need to associate ip addresses on the backend; virtual " + "router doesn't exist in the network " + network.getId());
            return true;
        }
        final DataCenterVO dcVO = _dcDao.findById(network.getDataCenterId());
        final NetworkTopology networkTopology = networkTopologyContext.retrieveNetworkTopology(dcVO);
        for (final DomainRouterVO domainRouterVO : routers) {
            result = result && networkTopology.associatePublicIP(network, ipAddress, domainRouterVO);
        }
    }
    return result;
}
Also used : DataCenterVO(com.cloud.dc.DataCenterVO) NetworkTopology(org.apache.cloudstack.network.topology.NetworkTopology) Service(com.cloud.network.Network.Service) DomainRouterVO(com.cloud.vm.DomainRouterVO)

Example 15 with NetworkTopology

use of org.apache.cloudstack.network.topology.NetworkTopology in project cloudstack by apache.

the class VirtualRouterElement method applyVpnUsers.

@Override
public String[] applyVpnUsers(final RemoteAccessVpn vpn, final List<? extends VpnUser> users) throws ResourceUnavailableException {
    if (vpn.getNetworkId() == null) {
        return null;
    }
    final Network network = _networksDao.findById(vpn.getNetworkId());
    if (canHandle(network, Service.Vpn)) {
        final List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(network.getId(), Role.VIRTUAL_ROUTER);
        if (routers == null || routers.isEmpty()) {
            s_logger.debug("Virtual router elemnt doesn't need to apply vpn users on the backend; virtual router" + " doesn't exist in the network " + network.getId());
            return null;
        }
        final DataCenterVO dcVO = _dcDao.findById(network.getDataCenterId());
        final NetworkTopology networkTopology = networkTopologyContext.retrieveNetworkTopology(dcVO);
        return networkTopology.applyVpnUsers(network, users, routers);
    } else {
        s_logger.debug("Element " + getName() + " doesn't handle applyVpnUsers command");
        return null;
    }
}
Also used : DataCenterVO(com.cloud.dc.DataCenterVO) Network(com.cloud.network.Network) NetworkTopology(org.apache.cloudstack.network.topology.NetworkTopology) DomainRouterVO(com.cloud.vm.DomainRouterVO)

Aggregations

DataCenterVO (com.cloud.dc.DataCenterVO)27 DomainRouterVO (com.cloud.vm.DomainRouterVO)27 NetworkTopology (org.apache.cloudstack.network.topology.NetworkTopology)27 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)10 VirtualMachineProfile (com.cloud.vm.VirtualMachineProfile)6 Network (com.cloud.network.Network)5 UserVmVO (com.cloud.vm.UserVmVO)4 Service (com.cloud.network.Network.Service)3 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)3 NicProfile (com.cloud.vm.NicProfile)3 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)2 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)2 Nic (com.cloud.vm.Nic)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 GetRouterAlertsAnswer (com.cloud.agent.api.GetRouterAlertsAnswer)1