@Override public HostPodVO doInTransaction(final TransactionStatus status) { final HostPodVO pod = _podDao.persist(podFinal); if (!Strings.isNullOrEmpty(startIp)) { _zoneDao.addPrivateIpAddress(zoneId, pod.getId(), startIp, endIpFinal, false, null); } final String[] linkLocalIpRanges = getLinkLocalIPRange(); if (linkLocalIpRanges != null) { _zoneDao.addLinkLocalIpAddress(zoneId, pod.getId(), linkLocalIpRanges[0], linkLocalIpRanges[1]); } return pod; } });
@Override public List<PodCluster> listByDataCenter(final long dcId) { final List<HostPodVO> pods = _podDao.listByDataCenterId(dcId); final ArrayList<PodCluster> pcs = new ArrayList<PodCluster>(); for (final HostPodVO pod : pods) { final List<ClusterVO> clusters = _clusterDao.listByPodId(pod.getId()); if (clusters.size() == 0) { pcs.add(new PodCluster(pod, null)); } else { for (final ClusterVO cluster : clusters) { pcs.add(new PodCluster(pod, cluster)); } } } return pcs; }
Map<Long, Long> podHostCandidates = new HashMap<Long, Long>(); for (HostPodVO pod : podsInZone) { long podId = pod.getId(); if (!avoids.contains(podId)) { if (template != null && !templateAvailableInPod(template.getId(), pod.getDataCenterId(), podId)) { List<UserVmVO> vmsInPod = _vmDao.listByAccountAndPod(accountId, pod.getId()); if (!vmsInPod.isEmpty()) { return new Pair<Pod, Long>(pod, podHostCandidates.get(podId)); List<VolumeVO> volumesInPod = _volumeDao.findByAccountAndPod(accountId, pod.getId()); if (!volumesInPod.isEmpty()) { return new Pair<Pod, Long>(pod, podHostCandidates.get(podId)); HostPodVO selectedPod = availablePods.get(next); s_logger.debug("Found pod " + selectedPod.getName() + " in zone " + zone.getName()); return new Pair<Pod, Long>(selectedPod, podHostCandidates.get(selectedPod.getId()));
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(TransactionStatus status) throws InternalErrorException { if (_podDao.persist(pod) == null) { throw new InternalErrorException("Failed to create new pod. Please contact Cloud Support."); } if (startIp != null) { _zoneDao.addPrivateIpAddress(zoneId, pod.getId(), startIp, endIpFinal, false, null); } String ipNums = _configDao.getValue("linkLocalIp.nums"); int nums = Integer.parseInt(ipNums); if (nums > 16 || nums <= 0) { throw new InvalidParameterValueException("The linkLocalIp.nums: " + nums + "is wrong, should be 1~16"); } /* local link ip address starts from 169.254.0.2 - 169.254.(nums) */ String[] linkLocalIpRanges = NetUtils.getLinkLocalIPRange(nums); if (linkLocalIpRanges == null) { throw new InvalidParameterValueException("The linkLocalIp.nums: " + nums + "may be wrong, should be 1~16"); } else { _zoneDao.addLinkLocalIpAddress(zoneId, pod.getId(), linkLocalIpRanges[0], linkLocalIpRanges[1]); } } });
final long podId = pod.getId(); final List<DomainRouterVO> virtualRouters = routerDao.listByPodIdAndStates(podId, VirtualMachine.State.Starting, VirtualMachine.State.Running);
long podId = pod.getId(); long dcId = pod.getDataCenterId();
@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); } });
String guid = getPxeServerGuid(Long.toString(zoneId) + "-" + pod.getId(), BaremetalPxeType.PING.toString(), ipAddress); params.put(BaremetalPxeService.PXE_PARAM_POD, String.valueOf(pod.getId())); params.put(BaremetalPxeService.PXE_PARAM_IP, ipAddress); params.put(BaremetalPxeService.PXE_PARAM_USERNAME, cmd.getUsername()); vo.setHostId(pxeServer.getId()); vo.setNetworkServiceProviderId(ntwkSvcProvider.getId()); vo.setPodId(pod.getId()); vo.setPhysicalNetworkId(pcmd.getPhysicalNetworkId()); vo.setDeviceType(BaremetalPxeType.PING.toString());
while (it.hasNext()) { PodCluster pc = it.next(); if (pc.getPod().getId() != podId) { it.remove(); if (p.getPod().getAllocationState() != Grouping.AllocationState.Enabled) { if (s_logger.isDebugEnabled()) { s_logger.debug("Pod name: " + p.getPod().getName() + ", podId: " + p.getPod().getId() + " is in " + p.getPod().getAllocationState().name() + " state, skipping this and trying other pods"); DataCenterDeployment newPlan = new DataCenterDeployment(plan.getDataCenterId(), p.getPod().getId(), clusterId, null, null, null); hosts = super.allocateTo(vm, newPlan, type, avoid, returnUpTo); if (hosts != null && !hosts.isEmpty()) {
List<SummedCapacity> capacity = _capacityDao.findCapacityBy(capacityType.intValue(), pod.getDataCenterId(), pod.getId(), null); if (capacity == null || capacity.size() == 0) { continue;
@Override public List<Long> listClustersWithDisabledPods(long zoneId) { GenericSearchBuilder<HostPodVO, Long> disabledPodIdSearch = hostPodDao.createSearchBuilder(Long.class); disabledPodIdSearch.selectFields(disabledPodIdSearch.entity().getId()); disabledPodIdSearch.and("dataCenterId", disabledPodIdSearch.entity().getDataCenterId(), Op.EQ); disabledPodIdSearch.and("allocationState", disabledPodIdSearch.entity().getAllocationState(), Op.EQ); GenericSearchBuilder<ClusterVO, Long> clusterIdSearch = createSearchBuilder(Long.class); clusterIdSearch.selectFields(clusterIdSearch.entity().getId()); clusterIdSearch.join("disabledPodIdSearch", disabledPodIdSearch, clusterIdSearch.entity().getPodId(), disabledPodIdSearch.entity().getId(), JoinBuilder.JoinType.INNER); clusterIdSearch.done(); SearchCriteria<Long> sc = clusterIdSearch.create(); sc.setJoinParameters("disabledPodIdSearch", "dataCenterId", zoneId); sc.setJoinParameters("disabledPodIdSearch", "allocationState", Grouping.AllocationState.Disabled); return customSearch(sc, null); }
List<ClusterVO> clusters = _clusterDao.listByPodId(pod.getId()); List<DedicatedResourceVO> clustersToRelease = new ArrayList<DedicatedResourceVO>(); List<DedicatedResourceVO> hostsToRelease = new ArrayList<DedicatedResourceVO>(); hosts = _hostDao.findByPodId(pod.getId()); for (HostVO host : hosts) { DedicatedResourceVO dHost = _dedicatedDao.findByHostId(host.getId());
/** * Lists all pods given a Data Center Id, a {@link VirtualMachine.Type} and * a list of {@link VirtualMachine.State} * @param id * @param type * @param states * @return */ protected List<HostPodVO> listByDataCenterIdVMTypeAndStates(final long id, final VirtualMachine.Type type, final VirtualMachine.State... states) { final SearchBuilder<VMInstanceVO> vmInstanceSearch = vmDao.createSearchBuilder(); vmInstanceSearch.and("type", vmInstanceSearch.entity().getType(), SearchCriteria.Op.EQ); vmInstanceSearch.and("states", vmInstanceSearch.entity().getState(), SearchCriteria.Op.IN); final SearchBuilder<HostPodVO> podIdSearch = podDao.createSearchBuilder(); podIdSearch.and("dc", podIdSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ); podIdSearch.select(null, SearchCriteria.Func.DISTINCT, podIdSearch.entity().getId()); podIdSearch.join("vmInstanceSearch", vmInstanceSearch, podIdSearch.entity().getId(), vmInstanceSearch.entity().getPodIdToDeployIn(), JoinBuilder.JoinType.INNER); podIdSearch.done(); final SearchCriteria<HostPodVO> sc = podIdSearch.create(); sc.setParameters("dc", id); sc.setJoinParameters("vmInstanceSearch", "type", type); sc.setJoinParameters("vmInstanceSearch", "states", (Object[]) states); return podDao.search(sc, null); }
if (pod != null) { s_logger.debug("Found pod " + pod.getName() + " for the secondary storage host " + startup.getName()); podId = pod.getId();
public HostPodDaoImpl() { DataCenterAndNameSearch = createSearchBuilder(); DataCenterAndNameSearch.and("dc", DataCenterAndNameSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ); DataCenterAndNameSearch.and("name", DataCenterAndNameSearch.entity().getName(), SearchCriteria.Op.EQ); DataCenterAndNameSearch.done(); DataCenterIdSearch = createSearchBuilder(); DataCenterIdSearch.and("dcId", DataCenterIdSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ); DataCenterIdSearch.done(); PodIdSearch = createSearchBuilder(Long.class); PodIdSearch.selectFields(PodIdSearch.entity().getId()); PodIdSearch.and("dataCenterId", PodIdSearch.entity().getDataCenterId(), Op.EQ); PodIdSearch.and("allocationState", PodIdSearch.entity().getAllocationState(), Op.EQ); PodIdSearch.done(); }
capacityResponses.addAll(getStatsCapacityresponse(null, cluster.getId(), pod.getId(), pod.getDataCenterId())); clusterResponse.setCapacitites(new ArrayList<CapacityResponse>(capacityResponses));
throw new ResourceAllocationException("No sush pod exists", ResourceType.network); vo = _privateIPAddressDao.takeIpAddress(zone.getId(), podvo.getId(), 0, caller.getId() + "", false); if(vo == null) throw new ResourceAllocationException("Unable to allocate IP from this Pod", ResourceType.network);
sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ); sb.and("name", sb.entity().getName(), SearchCriteria.Op.LIKE); sb.and("dataCenterId", sb.entity().getDataCenterId(), SearchCriteria.Op.EQ);