Search in sources :

Example 1 with RouterNetworkVO

use of com.cloud.network.dao.RouterNetworkVO in project cloudstack by apache.

the class NetworkMigrationManagerImpl method assignRouterNicsToNewNetwork.

private void assignRouterNicsToNewNetwork(long srcNetworkId, long dstNetworkId) {
    final List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(srcNetworkId, VirtualRouter.Role.VIRTUAL_ROUTER);
    for (DomainRouterVO domainRouter : routers) {
        NicVO vrNic = _nicDao.findByNetworkIdAndType(srcNetworkId, VirtualMachine.Type.DomainRouter);
        vrNic.setNetworkId(dstNetworkId);
        _nicDao.update(vrNic.getId(), vrNic);
        RouterNetworkVO routerNetwork = _routerNetworkDao.findByRouterAndNetwork(domainRouter.getId(), srcNetworkId);
        routerNetwork.setNetworkId(dstNetworkId);
        _routerNetworkDao.persist(routerNetwork);
    }
}
Also used : RouterNetworkVO(com.cloud.network.dao.RouterNetworkVO) NicVO(com.cloud.vm.NicVO) DomainRouterVO(com.cloud.vm.DomainRouterVO)

Example 2 with RouterNetworkVO

use of com.cloud.network.dao.RouterNetworkVO in project cosmic by MissionCriticalCloud.

the class DomainRouterDaoImpl method addRouterToGuestNetwork.

@Override
@DB
public void addRouterToGuestNetwork(final VirtualRouter router, final Network guestNetwork) {
    if (_routerNetworkDao.findByRouterAndNetwork(router.getId(), guestNetwork.getId()) == null) {
        final NetworkOffering off = _offDao.findById(guestNetwork.getNetworkOfferingId());
        if (!Network.GuestType.Private.equals(off.getGuestType())) {
            final TransactionLegacy txn = TransactionLegacy.currentTxn();
            txn.start();
            // 1) add router to network
            final RouterNetworkVO routerNtwkMap = new RouterNetworkVO(router.getId(), guestNetwork.getId(), guestNetwork.getGuestType());
            _routerNetworkDao.persist(routerNtwkMap);
            // 2) create user stats entry for the network
            UserStatisticsVO stats = _userStatsDao.findBy(router.getAccountId(), router.getDataCenterId(), guestNetwork.getId(), null, router.getId(), router.getType().toString());
            if (stats == null) {
                stats = new UserStatisticsVO(router.getAccountId(), router.getDataCenterId(), null, router.getId(), router.getType().toString(), guestNetwork.getId());
                _userStatsDao.persist(stats);
            }
            txn.commit();
        }
    }
}
Also used : TransactionLegacy(com.cloud.utils.db.TransactionLegacy) NetworkOffering(com.cloud.offering.NetworkOffering) RouterNetworkVO(com.cloud.network.dao.RouterNetworkVO) UserStatisticsVO(com.cloud.user.UserStatisticsVO) DB(com.cloud.utils.db.DB)

Example 3 with RouterNetworkVO

use of com.cloud.network.dao.RouterNetworkVO in project cloudstack by apache.

the class DomainRouterDaoImpl method addRouterToGuestNetwork.

@Override
@DB
public void addRouterToGuestNetwork(final VirtualRouter router, final Network guestNetwork) {
    if (_routerNetworkDao.findByRouterAndNetwork(router.getId(), guestNetwork.getId()) == null) {
        final NetworkOffering off = _offDao.findById(guestNetwork.getNetworkOfferingId());
        if (!off.getName().equalsIgnoreCase(NetworkOffering.SystemPrivateGatewayNetworkOffering)) {
            final TransactionLegacy txn = TransactionLegacy.currentTxn();
            txn.start();
            // 1) add router to network
            final RouterNetworkVO routerNtwkMap = new RouterNetworkVO(router.getId(), guestNetwork.getId(), guestNetwork.getGuestType());
            _routerNetworkDao.persist(routerNtwkMap);
            // 2) create user stats entry for the network
            if (router.getVpcId() == null) {
                UserStatisticsVO stats = _userStatsDao.findBy(router.getAccountId(), router.getDataCenterId(), guestNetwork.getId(), null, router.getId(), router.getType().toString());
                if (stats == null) {
                    stats = new UserStatisticsVO(router.getAccountId(), router.getDataCenterId(), null, router.getId(), router.getType().toString(), guestNetwork.getId());
                    _userStatsDao.persist(stats);
                }
            }
            txn.commit();
        }
    }
}
Also used : TransactionLegacy(com.cloud.utils.db.TransactionLegacy) NetworkOffering(com.cloud.offering.NetworkOffering) RouterNetworkVO(com.cloud.network.dao.RouterNetworkVO) UserStatisticsVO(com.cloud.user.UserStatisticsVO) DB(com.cloud.utils.db.DB)

Aggregations

RouterNetworkVO (com.cloud.network.dao.RouterNetworkVO)3 NetworkOffering (com.cloud.offering.NetworkOffering)2 UserStatisticsVO (com.cloud.user.UserStatisticsVO)2 DB (com.cloud.utils.db.DB)2 TransactionLegacy (com.cloud.utils.db.TransactionLegacy)2 DomainRouterVO (com.cloud.vm.DomainRouterVO)1 NicVO (com.cloud.vm.NicVO)1