DedicatedResourceVO resource = null; if (zoneId != null) { resource = _dedicatedDao.findByZoneId(zoneId); resource = _dedicatedDao.findByPodId(podId); resource = _dedicatedDao.findByClusterId(clusterId); resource = _dedicatedDao.findByHostId(hostId); List<DedicatedResourceVO> resourcesInGroup = _dedicatedDao.listByAffinityGroupId(resource.getAffinityGroupId()); if (resourcesInGroup.isEmpty()) {
@Override public Boolean doInTransaction(final TransactionStatus status) { // delete vlans for this zone final List<VlanVO> vlans = _vlanDao.listByZone(zoneId); for (final VlanVO vlan : vlans) { _vlanDao.remove(vlan.getId()); } final boolean success = _zoneDao.remove(zoneId); if (success) { // delete all capacity records for the zone _capacityDao.removeBy(null, zoneId, null, null, null); // remove from dedicated resources final DedicatedResourceVO dr = _dedicatedDao.findByZoneId(zoneId); if (dr != null) { _dedicatedDao.remove(dr.getId()); // find the group associated and check if there are any more // resources under that group final List<DedicatedResourceVO> resourcesInGroup = _dedicatedDao.listByAffinityGroupId(dr.getAffinityGroupId()); if (resourcesInGroup.isEmpty()) { // delete the group _affinityGroupService.deleteAffinityGroup(dr.getAffinityGroupId(), null, null, null, null); } } } return success; } });
private List<DedicatedResourceVO> searchInDomainResources(long domainId) { List<DedicatedResourceVO> dr = _dedicatedDao.listByDomainId(domainId); return dr; }
private boolean checkIfHostIsDedicated(HostVO host) { long hostId = host.getId(); DedicatedResourceVO dedicatedHost = _dedicatedDao.findByHostId(hostId); DedicatedResourceVO dedicatedClusterOfHost = _dedicatedDao.findByClusterId(host.getClusterId()); DedicatedResourceVO dedicatedPodOfHost = _dedicatedDao.findByPodId(host.getPodId()); if (dedicatedHost != null || dedicatedClusterOfHost != null || dedicatedPodOfHost != null) { return true; } else { return false; } }
@Override public void doInTransactionWithoutResult(TransactionStatus status) { SearchBuilder<DedicatedResourceVO> listByAffinityGroup = _dedicatedDao.createSearchBuilder(); listByAffinityGroup.and("affinityGroupId", listByAffinityGroup.entity().getAffinityGroupId(), SearchCriteria.Op.EQ); listByAffinityGroup.done(); SearchCriteria<DedicatedResourceVO> sc = listByAffinityGroup.create(); sc.setParameters("affinityGroupId", group.getId()); _dedicatedDao.lockRows(sc, null, true); _dedicatedDao.remove(sc); } });
DedicatedResourceVO dedicatedZone = _dedicatedDao.findByZoneId(dc.getId()); if (dedicatedZone != null && !_accountMgr.isRootAdmin(vmProfile.getOwner().getId())) { long accountDomainId = vmProfile.getOwner().getDomainId(); List<Long> allDedicatedPods = _dedicatedDao.listAllPods(); allPodsInDc.retainAll(allDedicatedPods); List<Long> allDedicatedClusters = _dedicatedDao.listAllClusters(); allClustersInDc.retainAll(allDedicatedClusters); List<Long> allDedicatedHosts = _dedicatedDao.listAllHosts(); allHostsInDc.retainAll(allDedicatedHosts); tempStorage = _dedicatedDao.searchDedicatedPods(null, vmDomainId, vmAccountId, null, new Filter(DedicatedResourceVO.class, "id", true, 0L, 1L)).first(); tempStorage = _dedicatedDao.searchDedicatedClusters(null, vmDomainId, vmAccountId, null, new Filter(DedicatedResourceVO.class, "id", true, 0L, 1L)).first(); tempStorage = _dedicatedDao.searchDedicatedHosts(null, vmDomainId, vmAccountId, null, new Filter(DedicatedResourceVO.class, "id", true, 0L, 1L)).first(); tempStorage = _dedicatedDao.searchDedicatedPods(null, vmDomainId, null, null, new Filter(DedicatedResourceVO.class, "id", true, 0L, 1L)).first(); tempStorage = _dedicatedDao.searchDedicatedClusters(null, vmDomainId, null, null, new Filter(DedicatedResourceVO.class, "id", true, 0L, 1L)).first(); tempStorage = _dedicatedDao.searchDedicatedHosts(null, vmDomainId, null, null, new Filter(DedicatedResourceVO.class, "id", true, 0L, 1L)).first();
if (accountsForCleanupInDomain.isEmpty()) { List<DedicatedResourceVO> dedicatedResources = _dedicatedDao.listByDomainId(domainId); if (dedicatedResources != null && !dedicatedResources.isEmpty()) { s_logger.debug("Releasing dedicated resources for domain" + domainId); for (DedicatedResourceVO dr : dedicatedResources) { if (!_dedicatedDao.remove(dr.getId())) { s_logger.warn("Fail to release dedicated resources for domain " + domainId);
final DedicatedResourceVO dr = _dedicatedDao.findByClusterId(cluster.getId()); if (dr != null) { _dedicatedDao.remove(dr.getId());
final DedicatedResourceVO dr = _dedicatedDao.findByPodId(podId); if (dr != null) { _dedicatedDao.remove(dr.getId());
_capacityDao.remove(hostCapacitySC); final DedicatedResourceVO dr = _dedicatedDao.findByHostId(hostId); if (dr != null) { _dedicatedDao.remove(dr.getId());
@Override public List<DedicatedResourceVO> doInTransaction(TransactionStatus status) { // find or create the affinity group by name under this account/domain AffinityGroup group = findOrCreateDedicatedAffinityGroup(domainId, accountIdFinal); if (group == null) { s_logger.error("Unable to dedicate zone due to, failed to create dedication affinity group"); throw new CloudRuntimeException("Failed to dedicate zone. Please contact Cloud Support."); } DedicatedResourceVO dedicatedResource = new DedicatedResourceVO(null, null, null, hostId, null, null, group.getId()); try { dedicatedResource.setDomainId(domainId); if (accountIdFinal != null) { dedicatedResource.setAccountId(accountIdFinal); } dedicatedResource = _dedicatedDao.persist(dedicatedResource); } catch (Exception e) { s_logger.error("Unable to dedicate host due to " + e.getMessage(), e); throw new CloudRuntimeException("Failed to dedicate host. Please contact Cloud Support.", e); } List<DedicatedResourceVO> result = new ArrayList<DedicatedResourceVO>(); result.add(dedicatedResource); return result; } });
List<DedicatedResourceVO> dedicatedResources = _dedicatedDao.listByAccountId(accountId); if (dedicatedResources != null && !dedicatedResources.isEmpty()) { s_logger.debug("Releasing dedicated resources for account " + accountId); for (DedicatedResourceVO dr : dedicatedResources) { if (!_dedicatedDao.remove(dr.getId())) { s_logger.warn("Fail to release dedicated resources for account " + accountId);
List<DedicatedResourceVO> dedicatedResources = _dedicatedDao.listByAffinityGroupId(group.getId()); if (!dedicatedResources.isEmpty()) { if (s_logger.isDebugEnabled()) {
@Override public void doInTransactionWithoutResult(TransactionStatus status) { Long resourceId = resourceFinal.getId(); if (!_dedicatedDao.remove(resourceId)) { throw new CloudRuntimeException("Failed to delete Resource " + resourceId); } if (zoneId != null) { // remove the domainId set in zone DataCenterVO dc = _zoneDao.findById(zoneId); if (dc != null) { dc.setDomainId(null); dc.setDomain(null); if (!_zoneDao.update(zoneId, dc)) { throw new CloudRuntimeException("Failed to release dedicated zone, could not clear domainId. Please contact Cloud Support."); } } } } });
DedicatedResourceVO dedicatedZone = _dedicatedDao.findByZoneId(zone.getId()); if (dedicatedZone != null) { DomainVO domain = _domainDao.findById(dedicatedZone.getDomainId());
@Override public Pair<List<? extends DedicatedResourceVO>, Integer> listDedicatedClusters(ListDedicatedClustersCmd cmd) { Long clusterId = cmd.getClusterId(); Long domainId = cmd.getDomainId(); String accountName = cmd.getAccountName(); Long accountId = null; Long affinityGroupId = cmd.getAffinityGroupId(); Long startIndex = cmd.getStartIndex(); Long pageSize = cmd.getPageSizeVal(); if (accountName != null) { if (domainId != null) { Account account = _accountDao.findActiveAccount(accountName, domainId); if (account != null) { accountId = account.getId(); } } else { throw new InvalidParameterValueException("Please specify the domain id of the account: " + accountName); } } Filter searchFilter = new Filter(DedicatedResourceVO.class, "id", true, startIndex, pageSize); Pair<List<DedicatedResourceVO>, Integer> result = _dedicatedDao.searchDedicatedClusters(clusterId, domainId, accountId, affinityGroupId, searchFilter); return new Pair<List<? extends DedicatedResourceVO>, Integer>(result.first(), result.second()); }
@Override public Pair<List<? extends DedicatedResourceVO>, Integer> listDedicatedHosts(ListDedicatedHostsCmd cmd) { Long hostId = cmd.getHostId(); Long domainId = cmd.getDomainId(); String accountName = cmd.getAccountName(); Long affinityGroupId = cmd.getAffinityGroupId(); Long startIndex = cmd.getStartIndex(); Long pageSize = cmd.getPageSizeVal(); Long accountId = null; if (accountName != null) { if (domainId != null) { Account account = _accountDao.findActiveAccount(accountName, domainId); if (account != null) { accountId = account.getId(); } } else { throw new InvalidParameterValueException("Please specify the domain id of the account: " + accountName); } } Filter searchFilter = new Filter(DedicatedResourceVO.class, "id", true, startIndex, pageSize); Pair<List<DedicatedResourceVO>, Integer> result = _dedicatedDao.searchDedicatedHosts(hostId, domainId, accountId, affinityGroupId, searchFilter); return new Pair<List<? extends DedicatedResourceVO>, Integer>(result.first(), result.second()); }
private Long accountOfDedicatedHost(HostVO host) { long hostId = host.getId(); DedicatedResourceVO dedicatedHost = _dedicatedDao.findByHostId(hostId); DedicatedResourceVO dedicatedClusterOfHost = _dedicatedDao.findByClusterId(host.getClusterId()); DedicatedResourceVO dedicatedPodOfHost = _dedicatedDao.findByPodId(host.getPodId()); if (dedicatedHost != null) { return dedicatedHost.getAccountId(); } if (dedicatedClusterOfHost != null) { return dedicatedClusterOfHost.getAccountId(); } if (dedicatedPodOfHost != null) { return dedicatedPodOfHost.getAccountId(); } return null; }
if (accountsForCleanup.isEmpty()) { List<DedicatedResourceVO> dedicatedResources = _dedicatedDao.listByDomainId(domainId); if (dedicatedResources != null && !dedicatedResources.isEmpty()) { s_logger.debug("Releasing dedicated resources for domain" + domainId); for (DedicatedResourceVO dr : dedicatedResources) { if (!_dedicatedDao.remove(dr.getId())) { s_logger.warn("Fail to release dedicated resources for domain " + domainId); return false;
@Override public List<DedicatedResourceVO> doInTransaction(TransactionStatus status) { // find or create the affinity group by name under this account/domain AffinityGroup group = findOrCreateDedicatedAffinityGroup(domainId, accountIdFinal); if (group == null) { s_logger.error("Unable to dedicate zone due to, failed to create dedication affinity group"); throw new CloudRuntimeException("Failed to dedicate zone. Please contact Cloud Support."); } DedicatedResourceVO dedicatedResource = new DedicatedResourceVO(null, null, clusterId, null, null, null, group.getId()); try { dedicatedResource.setDomainId(domainId); if (accountIdFinal != null) { dedicatedResource.setAccountId(accountIdFinal); } dedicatedResource = _dedicatedDao.persist(dedicatedResource); } catch (Exception e) { s_logger.error("Unable to dedicate cluster due to " + e.getMessage(), e); throw new CloudRuntimeException("Failed to dedicate cluster. Please contact Cloud Support.", e); } List<DedicatedResourceVO> result = new ArrayList<DedicatedResourceVO>(); result.add(dedicatedResource); return result; } });