@Override public String allocateVnet(long dataCenterId, long physicalNetworkId, long accountId, String reservationId, boolean canUseSystemGuestVlans) { ArrayList<Long> dedicatedVlanDbIds = new ArrayList<Long>(); boolean useDedicatedGuestVlans = false; List<AccountGuestVlanMapVO> maps = _accountGuestVlanMapDao.listAccountGuestVlanMapsByAccount(accountId); for (AccountGuestVlanMapVO map : maps) { dedicatedVlanDbIds.add(map.getId()); } if (dedicatedVlanDbIds != null && !dedicatedVlanDbIds.isEmpty()) { useDedicatedGuestVlans = true; DataCenterVnetVO vo = _vnetAllocDao.take(physicalNetworkId, accountId, reservationId, dedicatedVlanDbIds); if (vo != null) return vo.getVnet(); } if (!useDedicatedGuestVlans || (useDedicatedGuestVlans && canUseSystemGuestVlans)) { DataCenterVnetVO vo = _vnetAllocDao.take(physicalNetworkId, accountId, reservationId, null); if (vo != null) { return vo.getVnet(); } } return null; }
@Override @ActionEvent(eventType = EventTypes.EVENT_DEDICATED_GUEST_VLAN_RANGE_RELEASE, eventDescription = "releasing" + " dedicated guest vlan range", async = true) @DB public boolean releaseDedicatedGuestVlanRange(Long dedicatedGuestVlanRangeId) { // Verify dedicated range exists AccountGuestVlanMapVO dedicatedGuestVlan = _accountGuestVlanMapDao.findById(dedicatedGuestVlanRangeId); if (dedicatedGuestVlan == null) { throw new InvalidParameterValueException("Dedicated guest vlan with specified" + " id doesn't exist in the system"); } // Remove dedication for the guest vlan _datacneterVnet.releaseDedicatedGuestVlans(dedicatedGuestVlan.getId()); if (_accountGuestVlanMapDao.remove(dedicatedGuestVlanRangeId)) { return true; } else { return false; } }
public static Long getAccountIdForGuestVlan(long vlanDbId) { List<AccountGuestVlanMapVO> accountGuestVlanMaps = s_accountGuestVlanMapDao.listAccountGuestVlanMapsByVlan(vlanDbId); if (accountGuestVlanMaps.isEmpty()) { return null; } else { return accountGuestVlanMaps.get(0).getAccountId(); } }
List<AccountGuestVlanMapVO> guestVlanMaps = _accountGuestVlanMapDao.listAccountGuestVlanMapsByPhysicalNetwork(physicalNetworkId); _accountGuestVlanMapDao.remove(guestVlanMaps.get(i + 1).getId()); updatedVlanRange = vlanTokens1.get(0).intValue() + "-" + vlanTokens2.get(1).intValue(); break; accountGuestVlanMapVO = _accountGuestVlanMapDao.findById(guestVlanMapId); accountGuestVlanMapVO.setGuestVlanRange(updatedVlanRange); _accountGuestVlanMapDao.update(guestVlanMapId, accountGuestVlanMapVO); } else { accountGuestVlanMapVO = new AccountGuestVlanMapVO(vlanOwner.getAccountId(), physicalNetworkId); accountGuestVlanMapVO.setGuestVlanRange(startVlan + "-" + endVlan); _accountGuestVlanMapDao.persist(accountGuestVlanMapVO);
final AccountGuestVlanMapVO map = _accountGuestVlanMapDao.findById(accountGuestVlanMapId); if (map.getAccountId() != owner.getAccountId()) { throw new InvalidParameterValueException("Vlan " + vlanId + " is dedicated to a different account"); final List<AccountGuestVlanMapVO> maps = _accountGuestVlanMapDao.listAccountGuestVlanMapsByAccount(owner.getAccountId()); if (maps != null && !maps.isEmpty()) { final int vnetsAllocatedToAccount = _datacenterVnetDao.countVnetsAllocatedToAccount(zoneId, owner.getAccountId());
List<AccountGuestVlanMapVO> maps = _accountGuestVlanMapDao.listAccountGuestVlanMapsByAccount(accountId); for (AccountGuestVlanMapVO map : maps) { _dataCenterVnetDao.releaseDedicatedGuestVlans(map.getId()); int vlansReleased = _accountGuestVlanMapDao.removeByAccountId(accountId); s_logger.info("deleteAccount: Released " + vlansReleased + " dedicated guest vlan ranges from account " + accountId);
SearchBuilder<AccountGuestVlanMapVO> sb = _accountGuestVlanMapDao.createSearchBuilder(); sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ); sb.and("accountId", sb.entity().getAccountId(), SearchCriteria.Op.EQ); Pair<List<AccountGuestVlanMapVO>, Integer> result = _accountGuestVlanMapDao.searchAndCount(sc, searchFilter); return new Pair<List<? extends GuestVlan>, Integer>(result.first(), result.second());
@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; }
List<AccountGuestVlanMapVO> maps = _accountGuestVlanMapDao.listAccountGuestVlanMapsByPhysicalNetwork(network.getId()); for (AccountGuestVlanMapVO map : maps) { String[] vlans = map.getGuestVlanRange().split("-");