Пример #1
0
 @Override
 public void removeRouterFromGuestNetwork(long routerId, long guestNetworkId) {
   RouterNetworkVO routerNtwkMap =
       _routerNetworkDao.findByRouterAndNetwork(routerId, guestNetworkId);
   if (routerNtwkMap != null) {
     _routerNetworkDao.remove(routerNtwkMap.getId());
   }
 }
Пример #2
0
 @Override
 @DB
 public void addRouterToGuestNetwork(VirtualRouter router, Network guestNetwork) {
   if (_routerNetworkDao.findByRouterAndNetwork(router.getId(), guestNetwork.getId()) == null) {
     NetworkOffering off = _offDao.findById(guestNetwork.getNetworkOfferingId());
     if (!(off.getName().equalsIgnoreCase(NetworkOffering.SystemPrivateGatewayNetworkOffering))) {
       TransactionLegacy txn = TransactionLegacy.currentTxn();
       txn.start();
       // 1) add router to network
       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();
     }
   }
 }
Пример #3
0
  @PostConstruct
  protected void init() {
    AllFieldsSearch = createSearchBuilder();
    AllFieldsSearch.and("dc", AllFieldsSearch.entity().getDataCenterId(), Op.EQ);
    AllFieldsSearch.and("account", AllFieldsSearch.entity().getAccountId(), Op.EQ);
    AllFieldsSearch.and("role", AllFieldsSearch.entity().getRole(), Op.EQ);
    AllFieldsSearch.and("domainId", AllFieldsSearch.entity().getDomainId(), Op.EQ);
    AllFieldsSearch.and("host", AllFieldsSearch.entity().getHostId(), Op.EQ);
    AllFieldsSearch.and("lastHost", AllFieldsSearch.entity().getLastHostId(), Op.EQ);
    AllFieldsSearch.and("state", AllFieldsSearch.entity().getState(), Op.EQ);
    AllFieldsSearch.and("states", AllFieldsSearch.entity().getState(), Op.IN);
    SearchBuilder<RouterNetworkVO> joinRouterNetwork = _routerNetworkDao.createSearchBuilder();
    joinRouterNetwork.and("networkId", joinRouterNetwork.entity().getNetworkId(), Op.EQ);
    AllFieldsSearch.join(
        "networkRouter",
        joinRouterNetwork,
        joinRouterNetwork.entity().getRouterId(),
        AllFieldsSearch.entity().getId(),
        JoinType.INNER);
    AllFieldsSearch.and("podId", AllFieldsSearch.entity().getPodIdToDeployIn(), Op.EQ);
    AllFieldsSearch.and("elementId", AllFieldsSearch.entity().getElementId(), Op.EQ);
    AllFieldsSearch.and("vpcId", AllFieldsSearch.entity().getVpcId(), Op.EQ);
    AllFieldsSearch.done();

    VpcSearch = createSearchBuilder();
    VpcSearch.and("role", VpcSearch.entity().getRole(), Op.EQ);
    VpcSearch.and("vpcId", VpcSearch.entity().getVpcId(), Op.EQ);
    VpcSearch.done();

    IdNetworkIdStatesSearch = createSearchBuilder();
    IdNetworkIdStatesSearch.and("id", IdNetworkIdStatesSearch.entity().getId(), Op.EQ);
    SearchBuilder<RouterNetworkVO> joinRouterNetwork1 = _routerNetworkDao.createSearchBuilder();
    joinRouterNetwork1.and("networkId", joinRouterNetwork1.entity().getNetworkId(), Op.EQ);
    IdNetworkIdStatesSearch.join(
        "networkRouter",
        joinRouterNetwork1,
        joinRouterNetwork1.entity().getRouterId(),
        IdNetworkIdStatesSearch.entity().getId(),
        JoinType.INNER);
    IdNetworkIdStatesSearch.and("states", IdNetworkIdStatesSearch.entity().getState(), Op.IN);
    IdNetworkIdStatesSearch.done();

    HostUpSearch = createSearchBuilder();
    HostUpSearch.select(null, Func.DISTINCT, HostUpSearch.entity().getId());
    HostUpSearch.and("host", HostUpSearch.entity().getHostId(), Op.EQ);
    HostUpSearch.and("states", HostUpSearch.entity().getState(), Op.NIN);
    SearchBuilder<RouterNetworkVO> joinRouterNetwork3 = _routerNetworkDao.createSearchBuilder();
    joinRouterNetwork3.and("networkId", joinRouterNetwork3.entity().getNetworkId(), Op.EQ);
    joinRouterNetwork3.and("type", joinRouterNetwork3.entity().getGuestType(), Op.EQ);
    HostUpSearch.join(
        "networkRouter",
        joinRouterNetwork3,
        joinRouterNetwork3.entity().getRouterId(),
        HostUpSearch.entity().getId(),
        JoinType.INNER);
    HostUpSearch.done();

    StateNetworkTypeSearch = createSearchBuilder();
    StateNetworkTypeSearch.select(null, Func.DISTINCT, StateNetworkTypeSearch.entity().getId());
    StateNetworkTypeSearch.and("state", StateNetworkTypeSearch.entity().getState(), Op.EQ);
    SearchBuilder<RouterNetworkVO> joinRouterNetwork4 = _routerNetworkDao.createSearchBuilder();
    joinRouterNetwork4.and("networkId", joinRouterNetwork4.entity().getNetworkId(), Op.EQ);
    joinRouterNetwork4.and("type", joinRouterNetwork4.entity().getGuestType(), Op.EQ);
    StateNetworkTypeSearch.join(
        "networkRouter",
        joinRouterNetwork4,
        joinRouterNetwork4.entity().getRouterId(),
        StateNetworkTypeSearch.entity().getId(),
        JoinType.INNER);

    SearchBuilder<HostVO> joinHost = _hostsDao.createSearchBuilder();
    joinHost.and("mgmtServerId", joinHost.entity().getManagementServerId(), Op.EQ);
    StateNetworkTypeSearch.join(
        "host",
        joinHost,
        joinHost.entity().getId(),
        StateNetworkTypeSearch.entity().getHostId(),
        JoinType.INNER);
    StateNetworkTypeSearch.done();

    SearchByStateAndManagementServerId = createSearchBuilder();
    SearchByStateAndManagementServerId.and(
        "state", SearchByStateAndManagementServerId.entity().getState(), Op.EQ);

    SearchBuilder<HostVO> joinHost2 = _hostsDao.createSearchBuilder();
    joinHost2.and("mgmtServerId", joinHost2.entity().getManagementServerId(), Op.EQ);
    SearchByStateAndManagementServerId.join(
        "host",
        joinHost2,
        joinHost2.entity().getId(),
        SearchByStateAndManagementServerId.entity().getHostId(),
        JoinType.INNER);
    SearchByStateAndManagementServerId.done();

    OutsidePodSearch = createSearchBuilder();
    SearchBuilder<RouterNetworkVO> joinRouterNetwork2 = _routerNetworkDao.createSearchBuilder();
    joinRouterNetwork2.and("networkId", joinRouterNetwork2.entity().getNetworkId(), Op.EQ);
    OutsidePodSearch.join(
        "networkRouter",
        joinRouterNetwork2,
        joinRouterNetwork2.entity().getRouterId(),
        OutsidePodSearch.entity().getId(),
        JoinType.INNER);
    OutsidePodSearch.and("podId", OutsidePodSearch.entity().getPodIdToDeployIn(), Op.NEQ);
    OutsidePodSearch.and("state", OutsidePodSearch.entity().getState(), Op.EQ);
    OutsidePodSearch.and("role", OutsidePodSearch.entity().getRole(), Op.EQ);
    OutsidePodSearch.done();

    clusterSearch = createSearchBuilder();
    clusterSearch.and("state", clusterSearch.entity().getState(), Op.EQ);
    SearchBuilder<HostVO> clusterHost = _hostsDao.createSearchBuilder();
    clusterHost.and("clusterId", clusterHost.entity().getClusterId(), Op.EQ);
    clusterSearch.join(
        "host",
        clusterHost,
        clusterSearch.entity().getHostId(),
        clusterHost.entity().getId(),
        JoinType.INNER);
    clusterSearch.done();

    RunningSearch = createSearchBuilder();
    RunningSearch.and("dc", RunningSearch.entity().getDataCenterId(), Op.EQ);
    RunningSearch.and("account", RunningSearch.entity().getAccountId(), Op.EQ);
    RunningSearch.and("domainId", RunningSearch.entity().getDomainId(), Op.EQ);
    RunningSearch.and("state", RunningSearch.entity().getState(), Op.EQ);
    RunningSearch.and("podId", RunningSearch.entity().getPodIdToDeployIn(), Op.EQ);
    RunningSearch.done();
  }
Пример #4
0
 @Override
 public List<Long> getRouterNetworks(long routerId) {
   return _routerNetworkDao.getRouterNetworks(routerId);
 }