Search in sources :

Example 6 with NetworkTopology

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

the class VirtualRouterElement method saveUserData.

@Override
public boolean saveUserData(final Network network, final NicProfile nic, final VirtualMachineProfile vm) throws ResourceUnavailableException {
    if (!canHandle(network, null)) {
        return false;
    }
    final List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(network.getId(), Role.VIRTUAL_ROUTER);
    if (routers == null || routers.isEmpty()) {
        s_logger.debug("Can't find virtual router element in network " + network.getId());
        return true;
    }
    final VirtualMachineProfile uservm = vm;
    final Zone zone = zoneRepository.findOne(network.getDataCenterId());
    final NetworkTopology networkTopology = networkTopologyContext.retrieveNetworkTopology(zone);
    boolean result = true;
    for (final DomainRouterVO domainRouterVO : routers) {
        result = result && networkTopology.saveUserDataToRouter(network, nic, uservm, domainRouterVO);
    }
    return result;
}
Also used : Zone(com.cloud.db.model.Zone) NetworkTopology(com.cloud.network.topology.NetworkTopology) VirtualMachineProfile(com.cloud.vm.VirtualMachineProfile) DomainRouterVO(com.cloud.vm.DomainRouterVO)

Example 7 with NetworkTopology

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

the class VirtualRouterElement method rollbackMigration.

@Override
public void rollbackMigration(final NicProfile nic, final Network network, final VirtualMachineProfile vm, final ReservationContext src, final ReservationContext dst) {
    if (nic.getBroadcastType() != Networks.BroadcastDomainType.Pvlan) {
        return;
    }
    if (vm.getType() == VirtualMachine.Type.DomainRouter) {
        assert vm instanceof DomainRouterVO;
        final DomainRouterVO router = (DomainRouterVO) vm.getVirtualMachine();
        final Zone zone = zoneRepository.findOne(network.getDataCenterId());
        final NetworkTopology networkTopology = networkTopologyContext.retrieveNetworkTopology(zone);
        try {
            networkTopology.setupDhcpForPvlan(true, router, router.getHostId(), nic);
        } catch (final ResourceUnavailableException e) {
            s_logger.warn("Timed Out", e);
        }
    } else if (vm.getType() == VirtualMachine.Type.User) {
        assert vm instanceof UserVmVO;
        final UserVmVO userVm = (UserVmVO) vm.getVirtualMachine();
        _userVmMgr.setupVmForPvlan(true, userVm.getHostId(), nic);
    }
}
Also used : UserVmVO(com.cloud.vm.UserVmVO) Zone(com.cloud.db.model.Zone) NetworkTopology(com.cloud.network.topology.NetworkTopology) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) DomainRouterVO(com.cloud.vm.DomainRouterVO)

Example 8 with NetworkTopology

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

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 = _routerDao.listByNetworkAndRole(network.getId(), Role.VIRTUAL_ROUTER);
        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 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 9 with NetworkTopology

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

the class VirtualRouterElement method addPasswordAndUserdata.

@Override
public boolean addPasswordAndUserdata(final Network network, final NicProfile nic, final VirtualMachineProfile vm, final DeployDestination dest, final ReservationContext context) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException {
    boolean result = true;
    if (canHandle(network, Service.UserData)) {
        if (vm.getType() != VirtualMachine.Type.User) {
            return false;
        }
        if (network.getIp6Gateway() != null) {
            s_logger.info("Skip password and userdata service setup for IPv6 VM");
            return true;
        }
        final VirtualMachineProfile uservm = vm;
        final List<DomainRouterVO> routers = getRouters(network, dest);
        if (routers == null || routers.size() == 0) {
            throw new ResourceUnavailableException("Can't find at least one router!", DataCenter.class, network.getDataCenterId());
        }
        final Zone zone = zoneRepository.findOne(network.getDataCenterId());
        final NetworkTopology networkTopology = networkTopologyContext.retrieveNetworkTopology(zone);
        for (final DomainRouterVO domainRouterVO : routers) {
            result = result && networkTopology.applyUserData(network, nic, uservm, dest, domainRouterVO);
        }
    }
    return result;
}
Also used : Zone(com.cloud.db.model.Zone) NetworkTopology(com.cloud.network.topology.NetworkTopology) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) VirtualMachineProfile(com.cloud.vm.VirtualMachineProfile) DomainRouterVO(com.cloud.vm.DomainRouterVO)

Example 10 with NetworkTopology

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

the class VirtualRouterElement method configDhcpSupportForSubnet.

@Override
public boolean configDhcpSupportForSubnet(final Network network, final NicProfile nic, final VirtualMachineProfile vm, final DeployDestination dest, final ReservationContext context) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException {
    if (canHandle(network, Service.Dhcp)) {
        if (vm.getType() != VirtualMachine.Type.User) {
            return false;
        }
        final VirtualMachineProfile uservm = vm;
        final List<DomainRouterVO> routers = getRouters(network, dest);
        if (routers == null || routers.size() == 0) {
            throw new ResourceUnavailableException("Can't find at least one router!", DataCenter.class, network.getDataCenterId());
        }
        final Zone zone = zoneRepository.findOne(network.getDataCenterId());
        final NetworkTopology networkTopology = networkTopologyContext.retrieveNetworkTopology(zone);
        return networkTopology.configDhcpForSubnet(network, nic, uservm, dest, routers);
    }
    return false;
}
Also used : Zone(com.cloud.db.model.Zone) NetworkTopology(com.cloud.network.topology.NetworkTopology) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) VirtualMachineProfile(com.cloud.vm.VirtualMachineProfile) 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