use of com.cloud.utils.storage.encoding.DecodedDataStore in project cloudstack by apache.
the class XenServerStorageProcessor method execute.
protected Answer execute(final AttachPrimaryDataStoreCmd cmd) {
final String dataStoreUri = cmd.getDataStore();
final Connection conn = hypervisorResource.getConnection();
try {
final DecodedDataObject obj = Decoder.decode(dataStoreUri);
final DecodedDataStore store = obj.getStore();
final SR sr = hypervisorResource.getStorageRepository(conn, store.getUuid());
hypervisorResource.setupHeartbeatSr(conn, sr, false);
final long capacity = sr.getPhysicalSize(conn);
final long available = capacity - sr.getPhysicalUtilisation(conn);
if (capacity == -1) {
final String msg = "Pool capacity is -1! pool: ";
s_logger.warn(msg);
return new Answer(cmd, false, msg);
}
final AttachPrimaryDataStoreAnswer answer = new AttachPrimaryDataStoreAnswer(cmd);
answer.setCapacity(capacity);
answer.setUuid(sr.getUuid(conn));
answer.setAvailable(available);
return answer;
} catch (final XenAPIException e) {
final String msg = "AttachPrimaryDataStoreCmd add XenAPIException:" + e.toString();
s_logger.warn(msg, e);
return new Answer(cmd, false, msg);
} catch (final Exception e) {
final String msg = "AttachPrimaryDataStoreCmd failed:" + e.getMessage();
s_logger.warn(msg, e);
return new Answer(cmd, false, msg);
}
}
Aggregations