@Override public List<VlanVO> listVlansForAccountByType(Long zoneId, long accountId, VlanType vlanType) { //FIXME: use a join statement to improve the performance (should be minor since we expect only one or two) List<AccountVlanMapVO> vlanMaps = _accountVlanMapDao.listAccountVlanMapsByAccount(accountId); List<VlanVO> result = new ArrayList<VlanVO>(); for (AccountVlanMapVO acvmvo : vlanMaps) { VlanVO vlan = findById(acvmvo.getVlanDbId()); if (vlan.getVlanType() == vlanType && (zoneId == null || vlan.getDataCenterId() == zoneId)) { result.add(vlan); } } return result; }
private void updateVlanWithNetworkId(VlanVO vlan) { long zoneId = vlan.getDataCenterId(); long networkId = 0L; DataCenterVO zone = _zoneDao.findById(zoneId); if (zone.getNetworkType() == NetworkType.Advanced) { networkId = getSystemNetworkIdByZoneAndTrafficType(zoneId, TrafficType.Public); } else { networkId = getSystemNetworkIdByZoneAndTrafficType(zoneId, TrafficType.Guest); } vlan.setNetworkId(networkId); _vlanDao.update(vlan.getId(), vlan); }
@Override public void doInTransactionWithoutResult(TransactionStatus status) { IPRangeConfig config = new IPRangeConfig(); long startIPLong = NetUtils.ip2Long(startIp); long endIPLong = NetUtils.ip2Long(endIp); config.savePublicIPRange(TransactionLegacy.currentTxn(), startIPLong, endIPLong, vlan.getDataCenterId(), vlan.getId(), vlan.getNetworkId(), vlan.getPhysicalNetworkId(), false); } });
final long allocIpCount = _publicIpAddressDao.countIPs(vlan.getDataCenterId(), vlanDbId, true); final List<IPAddressVO> ips = _publicIpAddressDao.listByVlanId(vlanDbId); boolean success = true;
private void checkVlanUnderlayCompatibility(VlanVO newVlan) throws ResourceUnavailableException { List<VlanVO> vlans = _vlanDao.listByZone(newVlan.getDataCenterId()); if (CollectionUtils.isNotEmpty(vlans)) { boolean newVlanUnderlay = NuageVspUtil.isUnderlayEnabledForVlan(_vlanDetailsDao, newVlan); final String newCidr = NetUtils.getCidrFromGatewayAndNetmask(newVlan.getVlanGateway(), newVlan.getVlanNetmask()); for (VlanVO vlan : vlans) { if (vlan.getId() == newVlan.getId()) continue; final String existingCidr = NetUtils.getCidrFromGatewayAndNetmask(vlan.getVlanGateway(), vlan.getVlanNetmask()); NetUtils.SupersetOrSubset supersetOrSubset = NetUtils.isNetowrkASubsetOrSupersetOfNetworkB(newCidr, existingCidr); if (supersetOrSubset == NetUtils.SupersetOrSubset.sameSubnet) { boolean vlanUnderlay = NuageVspUtil.isUnderlayEnabledForVlan(_vlanDetailsDao, vlan); if (newVlanUnderlay != vlanUnderlay) { throw new ResourceUnavailableException("Mixed values for the underlay flag for IP ranges in the same subnet is not supported", Vlan.class, newVlan.getId()); } break; } } } }
public VlanDaoImpl() { ZoneVlanIdSearch = createSearchBuilder(); ZoneVlanIdSearch.and("zoneId", ZoneVlanIdSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ); ZoneVlanIdSearch.and("vlanId", ZoneVlanIdSearch.entity().getVlanTag(), SearchCriteria.Op.EQ); ZoneVlanIdSearch.done(); ZoneSearch = createSearchBuilder(); ZoneSearch.and("zoneId", ZoneSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ); ZoneSearch.done(); ZoneTypeSearch = createSearchBuilder(); ZoneTypeSearch.and("zoneId", ZoneTypeSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ); ZoneTypeSearch.and("vlanType", ZoneTypeSearch.entity().getVlanType(), SearchCriteria.Op.EQ); ZoneTypeSearch.done(); NetworkVlanSearch = createSearchBuilder(); NetworkVlanSearch.and("networkId", NetworkVlanSearch.entity().getNetworkId(), SearchCriteria.Op.EQ); NetworkVlanSearch.done(); PhysicalNetworkVlanSearch = createSearchBuilder(); PhysicalNetworkVlanSearch.and("physicalNetworkId", PhysicalNetworkVlanSearch.entity().getPhysicalNetworkId(), SearchCriteria.Op.EQ); PhysicalNetworkVlanSearch.done(); VlanGatewaysearch = createSearchBuilder(); VlanGatewaysearch.and("gateway", VlanGatewaysearch.entity().getVlanGateway(), SearchCriteria.Op.EQ); VlanGatewaysearch.and("networkid", VlanGatewaysearch.entity().getNetworkId(), SearchCriteria.Op.EQ); VlanGatewaysearch.done(); }
+ "is being used for providing dhcp service in this subnet. Delete all VMs in this subnet and try again"); final long allocIpCount = _publicIpAddressDao.countIPs(vlanRange.getDataCenterId(), vlanDbId, true); if (allocIpCount > 0) { throw new InvalidParameterValueException(allocIpCount + " Ips are in use. Cannot delete this vlan");
final Long zoneId = vlan.getDataCenterId(); final DataCenterVO zone = _zoneDao.findById(zoneId); if (zone == null) {
boolean result = super.configure(name, params); ZoneTypeAllPodsSearch = createSearchBuilder(); ZoneTypeAllPodsSearch.and("zoneId", ZoneTypeAllPodsSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ); ZoneTypeAllPodsSearch.and("vlanType", ZoneTypeAllPodsSearch.entity().getVlanType(), SearchCriteria.Op.EQ); ZoneTypePodSearch.and("zoneId", ZoneTypePodSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ); ZoneTypePodSearch.and("vlanType", ZoneTypePodSearch.entity().getVlanType(), SearchCriteria.Op.EQ); ZoneWideNonDedicatedVlanSearch.and("zoneId", ZoneWideNonDedicatedVlanSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ); AccountVlanMapSearch = _accountVlanMapDao.createSearchBuilder(); AccountVlanMapSearch.and("accountId", AccountVlanMapSearch.entity().getAccountId(), SearchCriteria.Op.NULL);
sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ); sb.and("vlan", sb.entity().getVlanTag(), SearchCriteria.Op.EQ); sb.and("dataCenterId", sb.entity().getDataCenterId(), SearchCriteria.Op.EQ); sb.and("vlan", sb.entity().getVlanTag(), SearchCriteria.Op.EQ); sb.and("networkId", sb.entity().getNetworkId(), SearchCriteria.Op.EQ);