Search in sources :

Example 86 with DomainRouterVO

use of com.cloud.vm.DomainRouterVO 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 87 with DomainRouterVO

use of com.cloud.vm.DomainRouterVO in project cloudstack by apache.

the class DomainRouterDaoImpl method persist.

@Override
@DB
public DomainRouterVO persist(final DomainRouterVO router, final List<Network> guestNetworks) {
    final TransactionLegacy txn = TransactionLegacy.currentTxn();
    txn.start();
    // 1) create network
    final DomainRouterVO newRouter = super.persist(router);
    if (guestNetworks != null && !guestNetworks.isEmpty()) {
        // 2) add router to the network
        for (final Network guestNetwork : guestNetworks) {
            addRouterToGuestNetwork(router, guestNetwork);
        }
    }
    txn.commit();
    return newRouter;
}
Also used : TransactionLegacy(com.cloud.utils.db.TransactionLegacy) Network(com.cloud.network.Network) DomainRouterVO(com.cloud.vm.DomainRouterVO) DB(com.cloud.utils.db.DB)

Example 88 with DomainRouterVO

use of com.cloud.vm.DomainRouterVO in project cloudstack by apache.

the class DomainRouterDaoImpl method remove.

@Override
public boolean remove(final Long id) {
    final TransactionLegacy txn = TransactionLegacy.currentTxn();
    txn.start();
    final DomainRouterVO router = createForUpdate();
    router.setPublicIpAddress(null);
    final UpdateBuilder ub = getUpdateBuilder(router);
    ub.set(router, "state", State.Destroyed);
    update(id, ub, router);
    final boolean result = super.remove(id);
    txn.commit();
    return result;
}
Also used : TransactionLegacy(com.cloud.utils.db.TransactionLegacy) UpdateBuilder(com.cloud.utils.db.UpdateBuilder) DomainRouterVO(com.cloud.vm.DomainRouterVO)

Example 89 with DomainRouterVO

use of com.cloud.vm.DomainRouterVO in project cloudstack by apache.

the class DomainRouterDaoImpl method listIsolatedByHostId.

@Override
public List<DomainRouterVO> listIsolatedByHostId(final Long hostId) {
    final SearchCriteria<DomainRouterVO> sc = HostUpSearch.create();
    if (hostId != null) {
        sc.setParameters("host", hostId);
    }
    sc.setJoinParameters("networkRouter", "type", Network.GuestType.Isolated);
    final List<DomainRouterVO> routerIds = listBy(sc);
    final List<DomainRouterVO> routers = new ArrayList<DomainRouterVO>();
    for (final DomainRouterVO router : routerIds) {
        CollectionUtils.addIgnoreNull(routers, findById(router.getId()));
    }
    return routers;
}
Also used : ArrayList(java.util.ArrayList) DomainRouterVO(com.cloud.vm.DomainRouterVO)

Example 90 with DomainRouterVO

use of com.cloud.vm.DomainRouterVO in project cloudstack by apache.

the class DomainRouterDaoImpl method listByStateAndNetworkType.

@Override
public List<DomainRouterVO> listByStateAndNetworkType(final State state, final Network.GuestType type, final long mgmtSrvrId) {
    final SearchCriteria<DomainRouterVO> sc = StateNetworkTypeSearch.create();
    sc.setParameters("state", state);
    sc.setJoinParameters("networkRouter", "type", type);
    sc.setJoinParameters("host", "mgmtServerId", mgmtSrvrId);
    final List<DomainRouterVO> routerIds = listBy(sc);
    final List<DomainRouterVO> routers = new ArrayList<DomainRouterVO>();
    for (final DomainRouterVO router : routerIds) {
        routers.add(findById(router.getId()));
    }
    return routers;
}
Also used : ArrayList(java.util.ArrayList) DomainRouterVO(com.cloud.vm.DomainRouterVO)

Aggregations

DomainRouterVO (com.cloud.vm.DomainRouterVO)148 ArrayList (java.util.ArrayList)39 DataCenterVO (com.cloud.dc.DataCenterVO)33 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)33 NetworkTopology (org.apache.cloudstack.network.topology.NetworkTopology)27 Test (org.junit.Test)26 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)24 Network (com.cloud.network.Network)20 NicProfile (com.cloud.vm.NicProfile)17 Account (com.cloud.user.Account)12 NetworkVO (com.cloud.network.dao.NetworkVO)11 Answer (com.cloud.agent.api.Answer)10 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)10 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)10 VirtualMachineProfile (com.cloud.vm.VirtualMachineProfile)10 UserVmVO (com.cloud.vm.UserVmVO)9 Vpc (com.cloud.network.vpc.Vpc)8 ServiceOfferingVO (com.cloud.service.ServiceOfferingVO)8 UserVO (com.cloud.user.UserVO)8 HashMap (java.util.HashMap)8