private boolean isOutOfBandManagementEnabledForCluster(Long clusterId) { if (clusterId == null) { return true; } final ClusterDetailsVO clusterDetails = clusterDetailsDao.findDetail(clusterId, OOBM_ENABLED_DETAIL); if (clusterDetails != null && !Strings.isNullOrEmpty(clusterDetails.getValue()) && !Boolean.valueOf(clusterDetails.getValue())) { return false; } return true; }
@Override public ClusterDetailsVO findDetail(long clusterId, String name) { SearchCriteria<ClusterDetailsVO> sc = DetailSearch.create(); // This is temporary fix to support list/update configuration api for cpu and memory overprovisioning ratios if (name.equalsIgnoreCase("cpu.overprovisioning.factor")) { name = "cpuOvercommitRatio"; } if (name.equalsIgnoreCase("mem.overprovisioning.factor")) { name = "memoryOvercommitRatio"; } sc.setParameters("clusterId", clusterId); sc.setParameters("name", name); ClusterDetailsVO detail = findOneIncludingRemovedBy(sc); if ("password".equals(name) && detail != null) { detail.setValue(DBEncryptionUtil.decrypt(detail.getValue())); } return detail; }
protected ClusterDetailsDaoImpl() { ClusterSearch = createSearchBuilder(); ClusterSearch.and("clusterId", ClusterSearch.entity().getClusterId(), SearchCriteria.Op.EQ); ClusterSearch.done(); DetailSearch = createSearchBuilder(); DetailSearch.and("clusterId", DetailSearch.entity().getClusterId(), SearchCriteria.Op.EQ); DetailSearch.and("name", DetailSearch.entity().getName(), SearchCriteria.Op.EQ); DetailSearch.done(); }
@Override public Map<String, String> findDetails(long clusterId) { SearchCriteria<ClusterDetailsVO> sc = ClusterSearch.create(); sc.setParameters("clusterId", clusterId); List<ClusterDetailsVO> results = search(sc, null); Map<String, String> details = new HashMap<String, String>(results.size()); for (ClusterDetailsVO result : results) { if ("password".equals(result.getName())) { details.put(result.getName(), DBEncryptionUtil.decrypt(result.getValue())); } else { details.put(result.getName(), result.getValue()); } } return details; }
clusterDetailsVO.setValue(Boolean.TRUE.toString()); _clusterDetailsDao.update(clusterDetailsVO.getId(), clusterDetailsVO); _clusterDetailsDao.remove(clusterDetailsVO.getId()); clusterDetailsVO = new ClusterDetailsVO(host.getClusterId(), name, Boolean.TRUE.toString());
@Override public void persist(long clusterId, Map<String, String> details) { TransactionLegacy txn = TransactionLegacy.currentTxn(); txn.start(); SearchCriteria<ClusterDetailsVO> sc = ClusterSearch.create(); sc.setParameters("clusterId", clusterId); expunge(sc); for (Map.Entry<String, String> detail : details.entrySet()) { String value = detail.getValue(); if ("password".equals(detail.getKey())) { value = DBEncryptionUtil.encrypt(value); } ClusterDetailsVO vo = new ClusterDetailsVO(clusterId, detail.getKey(), value); persist(vo); } txn.commit(); }
@Override public void deleteDetails(long clusterId) { SearchCriteria<ClusterDetailsVO> sc = ClusterSearch.create(); sc.setParameters("clusterId", clusterId); List<ClusterDetailsVO> results = search(sc, null); for (ClusterDetailsVO result : results) { remove(result.getId()); } }
clusterDetailsVO = new ClusterDetailsVO(resourceId, name, value); _clusterDetailsDao.persist(clusterDetailsVO); } else { clusterDetailsVO.setValue(value); _clusterDetailsDao.update(clusterDetailsVO.getId(), clusterDetailsVO);
@Override public void persist(long clusterId, String name, String value) { TransactionLegacy txn = TransactionLegacy.currentTxn(); txn.start(); SearchCriteria<ClusterDetailsVO> sc = DetailSearch.create(); sc.setParameters("clusterId", clusterId); sc.setParameters("name", name); expunge(sc); ClusterDetailsVO vo = new ClusterDetailsVO(clusterId, name, value); persist(vo); txn.commit(); }
public static String findClusterDetails(long clusterId, String name) { ClusterDetailsVO detailsVO = s_clusterDetailsDao.findDetail(clusterId, name); if (detailsVO != null) { return detailsVO.getValue(); } return null; }
final ClusterDetailsVO cluster_cpu_detail = new ClusterDetailsVO(clusterId, "cpuOvercommitRatio", "1"); final ClusterDetailsVO cluster_memory_detail = new ClusterDetailsVO(clusterId, "memoryOvercommitRatio", "1"); _clusterDetailsDao.persist(cluster_cpu_detail); _clusterDetailsDao.persist(cluster_memory_detail);
@Override public String getVmwareDcName(Long clusterId) { String dcName = null; String url = findDetail(clusterId, "url").getValue(); String[] tokens = url.split("/"); // Cluster URL format is 'http://vcenter/dc/cluster' if (tokens != null && tokens.length > 3) dcName = tokens[3]; return dcName; } }
private boolean isHAEnabledForCluster(final HAResource resource) { if (resource == null || resource.getClusterId() == null) { return true; } final ClusterDetailsVO clusterDetails = clusterDetailsDao.findDetail(resource.getClusterId(), HA_ENABLED_DETAIL); return clusterDetails == null || Strings.isNullOrEmpty(clusterDetails.getValue()) || Boolean.valueOf(clusterDetails.getValue()); }
@Override public float getClusterOverProvisioningFactor(Long clusterId, short capacityType) { String capacityOverProvisioningName = ""; if (capacityType == Capacity.CAPACITY_TYPE_CPU) { capacityOverProvisioningName = "cpuOvercommitRatio"; } else if (capacityType == Capacity.CAPACITY_TYPE_MEMORY) { capacityOverProvisioningName = "memoryOvercommitRatio"; } else { throw new CloudRuntimeException("Invalid capacityType - " + capacityType); } ClusterDetailsVO clusterDetailCpu = _clusterDetailsDao.findDetail(clusterId, capacityOverProvisioningName); Float clusterOverProvisioningRatio = Float.parseFloat(clusterDetailCpu.getValue()); return clusterOverProvisioningRatio; }
@Override public String getConfigValue(long id, ConfigKey<?> key) { ClusterDetailsVO vo = findDetail(id, key.key()); return vo == null ? null : vo.getValue(); }
@Override public boolean getSupportsResigning(long clusterId) { ClusterVO cluster = findById(clusterId); if (cluster == null || cluster.getAllocationState() != Grouping.AllocationState.Enabled) { return false; } ClusterDetailsVO clusterDetailsVO = clusterDetailsDao.findDetail(clusterId, "supportsResign"); if (clusterDetailsVO != null) { String value = clusterDetailsVO.getValue(); return Boolean.parseBoolean(value); } return false; } }
ClusterDetailsVO clusterDetailsCpuOvercommit = _clusterDetailsDao.findDetail(cluster.getId(), "cpuOvercommitRatio"); ClusterDetailsVO clusterDetailsRamOvercommmt = _clusterDetailsDao.findDetail(cluster.getId(), "memoryOvercommitRatio"); Float cpuOvercommitRatio = Float.parseFloat(clusterDetailsCpuOvercommit.getValue()); Float memoryOvercommitRatio = Float.parseFloat(clusterDetailsRamOvercommmt.getValue());
long reservedMem = capacityMemory.getReservedCapacity(); long actualTotalCpu = capacityCpu.getTotalCapacity(); float cpuOvercommitRatio = Float.parseFloat(_clusterDetailsDao.findDetail(clusterIdFinal, "cpuOvercommitRatio").getValue()); float memoryOvercommitRatio = Float.parseFloat(_clusterDetailsDao.findDetail(clusterIdFinal, "memoryOvercommitRatio").getValue()); int vmCPU = svo.getCpu() * svo.getSpeed(); long vmMem = svo.getRamSize() * 1024L * 1024L;
HostVO host = _hostDao.findById(hostId); final long clusterId = host.getClusterId(); final float cpuOvercommitRatio = Float.parseFloat(_clusterDetailsDao.findDetail(clusterId, "cpuOvercommitRatio").getValue()); final float memoryOvercommitRatio = Float.parseFloat(_clusterDetailsDao.findDetail(clusterId, "memoryOvercommitRatio").getValue());
ClusterDetailsVO cluster_detail_cpu = _clusterDetailsDao.findDetail(cluster_id, "cpuOvercommitRatio"); ClusterDetailsVO cluster_detail_ram = _clusterDetailsDao.findDetail(cluster_id, "memoryOvercommitRatio"); Float cpuOvercommitRatio = Float.parseFloat(cluster_detail_cpu.getValue()); Float memoryOvercommitRatio = Float.parseFloat(cluster_detail_ram.getValue());