@Override public void releaseDedicatedGuestVlans(Long dedicatedGuestVlanRangeId) { SearchCriteria<DataCenterVnetVO> sc = DedicatedGuestVlanRangeSearch.create(); sc.setParameters("dedicatedGuestVlanRangeId", dedicatedGuestVlanRangeId); List<DataCenterVnetVO> vnets = listBy(sc); for (DataCenterVnetVO vnet : vnets) { vnet.setAccountGuestVlanMapId(null); update(vnet.getId(), vnet); } }
List<DataCenterVnetVO> dataCenterVnet = _datacneterVnet.findVnet(physicalNetwork.getDataCenterId(), physicalNetworkId, Integer.toString(i)); dataCenterVnet.get(0).setAccountGuestVlanMapId(accountGuestVlanMapVO.getId()); _datacneterVnet.update(dataCenterVnet.get(0).getId(), dataCenterVnet.get(0));
@Override @DB public DataCenterVnetVO take(long physicalNetworkId, long accountId, String reservationId, List<Long> vlanDbIds) { SearchCriteria<DataCenterVnetVO> sc; if (vlanDbIds != null) { sc = FreeDedicatedVnetSearch.create(); sc.setParameters("accountGuestVlanMapId", vlanDbIds.toArray()); } else { sc = FreeVnetSearch.create(); } sc.setParameters("physicalNetworkId", physicalNetworkId); Date now = new Date(); TransactionLegacy txn = TransactionLegacy.currentTxn(); txn.start(); DataCenterVnetVO vo = lockOneRandomRow(sc, true); if (vo == null) { return null; } vo.setTakenAt(now); vo.setAccountId(accountId); vo.setReservationId(reservationId); update(vo.getId(), vo); txn.commit(); return vo; }
@Override public void release(String vnet, long physicalNetworkId, long accountId, String reservationId) { SearchCriteria<DataCenterVnetVO> sc = VnetDcSearchAllocated.create(); sc.setParameters("vnet", vnet); sc.setParameters("physicalNetworkId", physicalNetworkId); sc.setParameters("account", accountId); sc.setParameters("reservation", reservationId); DataCenterVnetVO vo = findOneIncludingRemovedBy(sc); if (vo == null) { return; } vo.setTakenAt(null); vo.setAccountId(null); vo.setReservationId(null); update(vo.getId(), vo); }
@Override public boolean configure(String name, Map<String, Object> params) throws ConfigurationException { boolean result = super.configure(name, params); countVnetsDedicatedToAccount = createSearchBuilder(Integer.class); countVnetsDedicatedToAccount.and("dc", countVnetsDedicatedToAccount.entity().getDataCenterId(), SearchCriteria.Op.EQ); countVnetsDedicatedToAccount.and("accountGuestVlanMapId", countVnetsDedicatedToAccount.entity().getAccountGuestVlanMapId(), Op.NNULL); AccountGuestVlanMapSearch = _accountGuestVlanMapDao.createSearchBuilder(); AccountGuestVlanMapSearch.and("accountId", AccountGuestVlanMapSearch.entity().getAccountId(), SearchCriteria.Op.EQ); countVnetsDedicatedToAccount.join("AccountGuestVlanMapSearch", AccountGuestVlanMapSearch, countVnetsDedicatedToAccount.entity().getAccountGuestVlanMapId(), AccountGuestVlanMapSearch.entity().getId(), JoinBuilder.JoinType.INNER); countVnetsDedicatedToAccount.select(null, Func.COUNT, countVnetsDedicatedToAccount.entity().getId()); countVnetsDedicatedToAccount.done(); AccountGuestVlanMapSearch.done(); return result; }
countZoneVlans.select(null, Func.COUNT, countZoneVlans.entity().getId()); countZoneVlans.and("dc", countZoneVlans.entity().getDataCenterId(), Op.EQ); countZoneVlans.done(); countAllocatedZoneVlans.select(null, Func.COUNT, countAllocatedZoneVlans.entity().getId()); countAllocatedZoneVlans.and("dc", countAllocatedZoneVlans.entity().getDataCenterId(), Op.EQ); countAllocatedZoneVlans.and("allocated", countAllocatedZoneVlans.entity().getTakenAt(), SearchCriteria.Op.NNULL); countVnetsAllocatedToAccount.and("dc", countVnetsAllocatedToAccount.entity().getDataCenterId(), SearchCriteria.Op.EQ); countVnetsAllocatedToAccount.and("accountId", countVnetsAllocatedToAccount.entity().getAccountId(), SearchCriteria.Op.EQ); countVnetsAllocatedToAccount.select(null, Func.COUNT, countVnetsAllocatedToAccount.entity().getId()); countVnetsAllocatedToAccount.done();