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);
}
}
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();
}
}
}
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();
}
}
}
Aggregations