private void updatePodNetmaskIfNeeded(HostPodVO pod, String agentNetmask) { // If the server's private netmask is less inclusive than the pod's CIDR // netmask, update cidrSize of the default POD //(reason: we are maintaining pods only for internal accounting.) long cidrSize = pod.getCidrSize(); String cidrNetmask = NetUtils.getCidrSubNet("255.255.255.255", cidrSize); long cidrNetmaskNumeric = NetUtils.ip2Long(cidrNetmask); long serverNetmaskNumeric = NetUtils.ip2Long(agentNetmask);// if (serverNetmaskNumeric > cidrNetmaskNumeric) { //update pod's cidrsize int newCidrSize = new Long(NetUtils.getCidrSize(agentNetmask)).intValue(); pod.setCidrSize(newCidrSize); _podDao.update(pod.getId(), pod); } }
@Override public void doInTransactionWithoutResult(final TransactionStatus status) { final long zoneId = pod.getDataCenterId(); pod.setName(nameFinal); pod.setDataCenterId(zoneId); pod.setGateway(gatewayFinal); pod.setCidrAddress(getCidrAddress(cidr)); pod.setCidrSize(getCidrSize(cidr)); Grouping.AllocationState allocationState = null; if (allocationStateStrFinal != null && !allocationStateStrFinal.isEmpty()) { allocationState = Grouping.AllocationState.valueOf(allocationStateStrFinal); pod.setAllocationState(allocationState); } _podDao.update(id, pod); } });
@Override public void doInTransactionWithoutResult(final TransactionStatus status) { String ipRange = pod.getDescription(); /* * POD Description is refactored to: * <START_IP>-<END_IP>-<FOR_SYSTEM_VMS>-<VLAN>,<START_IP>-<END_IP>-<FOR_SYSTEM_VMS>-<VLAN>,... */ String range = startIp + "-" + endIpFinal + "-" + (forSystemVms ? "1" : "0") + "-" + (vlanId == null ? DefaultVlanForPodIpRange : vlanId); if(ipRange != null && !ipRange.isEmpty()) ipRange += ("," + range); else ipRange = (range); pod.setDescription(ipRange); HostPodVO lock = null; try { lock = _podDao.acquireInLockTable(podId); if (lock == null) { String msg = "Unable to acquire lock on table to update the ip range of POD: " + pod.getName() + ", Creation failed."; s_logger.warn(msg); throw new CloudRuntimeException(msg); } _podDao.update(podId, pod); } finally { if (lock != null) { _podDao.releaseFromLockTable(podId); } } _zoneDao.addPrivateIpAddress(zoneId, pod.getId(), startIp, endIpFinal, forSystemVms, vlanId); } });
@Override public void doInTransactionWithoutResult(final TransactionStatus status) { pod.setDescription(newPodIpRange.toString()); HostPodVO lock = null; try { lock = _podDao.acquireInLockTable(podId); if (lock == null) { String msg = "Unable to acquire lock on table to update the ip range of POD: " + pod.getName() + ", Deletion failed."; s_logger.warn(msg); throw new CloudRuntimeException(msg); } _podDao.update(podId, pod); } finally { if (lock != null) { _podDao.releaseFromLockTable(podId); } } for(long ipAddr = NetUtils.ip2Long(startIp); ipAddr <= NetUtils.ip2Long(endIp); ipAddr++) { if (!_privateIpAddressDao.deleteIpAddressByPodDc(NetUtils.long2Ip(ipAddr), podId, pod.getDataCenterId())) { throw new CloudRuntimeException("Failed to cleanup private ip address: " + NetUtils.long2Ip(ipAddr) + " of Pod: " + podId + " DC: " + pod.getDataCenterId()); } } } });