use of com.cloud.legacymodel.exceptions.CloudRuntimeException in project cosmic by MissionCriticalCloud.
the class VolumeDaoImpl method listZoneWidePoolIdsByVolumeCount.
@Override
public List<Long> listZoneWidePoolIdsByVolumeCount(final long dcId, final long accountId) {
final TransactionLegacy txn = TransactionLegacy.currentTxn();
PreparedStatement pstmt = null;
final List<Long> result = new ArrayList<>();
try {
final String sql = ORDER_ZONE_WIDE_POOLS_NUMBER_OF_VOLUMES_FOR_ACCOUNT;
pstmt = txn.prepareAutoCloseStatement(sql);
pstmt.setLong(1, accountId);
pstmt.setLong(2, dcId);
final ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
result.add(rs.getLong(1));
}
return result;
} catch (final SQLException e) {
throw new CloudRuntimeException("DB Exception on: " + ORDER_ZONE_WIDE_POOLS_NUMBER_OF_VOLUMES_FOR_ACCOUNT, e);
}
}
use of com.cloud.legacymodel.exceptions.CloudRuntimeException in project cosmic by MissionCriticalCloud.
the class VolumeDaoImpl method listPoolIdsByVolumeCount.
@Override
public List<Long> listPoolIdsByVolumeCount(final long dcId, final Long podId, final Long clusterId, final long accountId) {
final TransactionLegacy txn = TransactionLegacy.currentTxn();
PreparedStatement pstmt = null;
final List<Long> result = new ArrayList<>();
try {
final String sql = ORDER_POOLS_NUMBER_OF_VOLUMES_FOR_ACCOUNT;
pstmt = txn.prepareAutoCloseStatement(sql);
pstmt.setLong(1, accountId);
pstmt.setLong(2, dcId);
pstmt.setLong(3, podId);
pstmt.setLong(4, clusterId);
final ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
result.add(rs.getLong(1));
}
return result;
} catch (final SQLException e) {
throw new CloudRuntimeException("DB Exception on: " + ORDER_POOLS_NUMBER_OF_VOLUMES_FOR_ACCOUNT, e);
}
}
use of com.cloud.legacymodel.exceptions.CloudRuntimeException in project cosmic by MissionCriticalCloud.
the class VolumeDaoImpl method getVolumeStoragePoolScope.
@Override
public ScopeType getVolumeStoragePoolScope(final long volumeId) {
// finding the storage scope where the volume is present
final TransactionLegacy txn = TransactionLegacy.currentTxn();
PreparedStatement pstmt = null;
try {
final String sql = SELECT_POOLSCOPE;
pstmt = txn.prepareAutoCloseStatement(sql);
pstmt.setLong(1, volumeId);
final ResultSet rs = pstmt.executeQuery();
if (rs.next()) {
final String scope = rs.getString(1);
if (scope != null) {
try {
return Enum.valueOf(ScopeType.class, scope.toUpperCase());
} catch (final Exception e) {
throw new InvalidParameterValueException("invalid scope for pool " + scope);
}
}
}
} catch (final SQLException e) {
throw new CloudRuntimeException("DB Exception on: " + SELECT_POOLSCOPE, e);
}
return null;
}
use of com.cloud.legacymodel.exceptions.CloudRuntimeException in project cosmic by MissionCriticalCloud.
the class VolumeDaoImpl method getHypervisorType.
@Override
@DB
public HypervisorType getHypervisorType(final long volumeId) {
/* lookup from cluster of pool */
final TransactionLegacy txn = TransactionLegacy.currentTxn();
PreparedStatement pstmt = null;
String sql = null;
try {
final ScopeType scope = getVolumeStoragePoolScope(volumeId);
if (scope != null) {
if (scope == ScopeType.CLUSTER || scope == ScopeType.HOST) {
sql = SELECT_HYPERTYPE_FROM_CLUSTER_VOLUME;
} else if (scope == ScopeType.ZONE) {
sql = SELECT_HYPERTYPE_FROM_ZONE_VOLUME;
} else {
s_logger.error("Unhandled scope type '" + scope + "' when running getHypervisorType on volume id " + volumeId);
}
pstmt = txn.prepareAutoCloseStatement(sql);
pstmt.setLong(1, volumeId);
final ResultSet rs = pstmt.executeQuery();
if (rs.next()) {
if (rs.getString(1) != null) {
return HypervisorType.getType(rs.getString(1));
}
}
}
return HypervisorType.None;
} catch (final SQLException e) {
throw new CloudRuntimeException("DB Exception on: " + sql, e);
}
}
use of com.cloud.legacymodel.exceptions.CloudRuntimeException in project cosmic by MissionCriticalCloud.
the class ServiceOfferingDaoImpl method findDefaultSystemOffering.
@Override
public ServiceOfferingVO findDefaultSystemOffering(final String offeringName, final Boolean useLocalStorage) {
String name = offeringName;
if (useLocalStorage != null && useLocalStorage.booleanValue()) {
name += "-Local";
}
final ServiceOfferingVO serviceOffering = findByName(name);
if (serviceOffering == null) {
final String message = "System service offering " + name + " not found";
s_logger.error(message);
throw new CloudRuntimeException(message);
}
return serviceOffering;
}
Aggregations