use of com.cloud.agent.api.storage.ListVolumeAnswer in project cloudstack by apache.
the class VolumeServiceImpl method listVolume.
private Map<Long, TemplateProp> listVolume(DataStore store) {
ListVolumeCommand cmd = new ListVolumeCommand(store.getTO(), store.getUri());
EndPoint ep = _epSelector.select(store);
Answer answer = null;
if (ep == null) {
String errMsg = "No remote endpoint to send command, check if host or ssvm is down?";
s_logger.error(errMsg);
answer = new Answer(cmd, false, errMsg);
} else {
answer = ep.sendMessage(cmd);
}
if (answer != null && answer.getResult()) {
ListVolumeAnswer tanswer = (ListVolumeAnswer) answer;
return tanswer.getTemplateInfo();
} else {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Can not list volumes for image store " + store.getId());
}
}
return null;
}
use of com.cloud.agent.api.storage.ListVolumeAnswer in project cloudstack by apache.
the class MockStorageManagerImpl method ListVolumes.
@Override
public Answer ListVolumes(ListVolumeCommand cmd) {
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
MockSecStorageVO storage = null;
try {
txn.start();
storage = _mockSecStorageDao.findByUrl(cmd.getSecUrl());
if (storage == null) {
return new Answer(cmd, false, "Failed to get secondary storage");
}
txn.commit();
} catch (Exception ex) {
txn.rollback();
throw new CloudRuntimeException("Error when finding sec storage " + cmd.getSecUrl(), ex);
} finally {
txn.close();
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
try {
txn.start();
List<MockVolumeVO> volumes = _mockVolumeDao.findByStorageIdAndType(storage.getId(), MockVolumeType.VOLUME);
Map<Long, TemplateProp> templateInfos = new HashMap<Long, TemplateProp>();
for (MockVolumeVO volume : volumes) {
templateInfos.put(volume.getId(), new TemplateProp(volume.getName(), volume.getPath().replaceAll(storage.getMountPoint(), ""), volume.getSize(), volume.getSize(), true, false));
}
txn.commit();
return new ListVolumeAnswer(cmd.getSecUrl(), templateInfos);
} catch (Exception ex) {
txn.rollback();
throw new CloudRuntimeException("Error when finding template on sec storage " + storage.getId(), ex);
} finally {
txn.close();
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
}
use of com.cloud.agent.api.storage.ListVolumeAnswer in project cloudstack by apache.
the class NfsSecondaryStorageResource method execute.
private Answer execute(ListVolumeCommand cmd) {
if (!_inSystemVM) {
return new ListVolumeAnswer(cmd.getSecUrl(), null);
}
DataStoreTO store = cmd.getDataStore();
if (store instanceof NfsTO) {
String root = getRootDir(cmd.getSecUrl(), _nfsVersion);
Map<Long, TemplateProp> templateInfos = _dlMgr.gatherVolumeInfo(root);
return new ListVolumeAnswer(cmd.getSecUrl(), templateInfos);
} else if (store instanceof S3TO) {
S3TO s3 = (S3TO) store;
Map<Long, TemplateProp> templateInfos = s3ListVolume(s3);
return new ListVolumeAnswer(s3.getBucketName(), templateInfos);
} else {
return new Answer(cmd, false, "Unsupported image data store: " + store);
}
}
use of com.cloud.agent.api.storage.ListVolumeAnswer in project cosmic by MissionCriticalCloud.
the class VolumeServiceImpl method listVolume.
private Map<Long, TemplateProp> listVolume(final DataStore store) {
final ListVolumeCommand cmd = new ListVolumeCommand(store.getTO(), store.getUri());
final EndPoint ep = _epSelector.select(store);
Answer answer = null;
if (ep == null) {
final String errMsg = "No remote endpoint to send command, check if host or ssvm is down?";
s_logger.error(errMsg);
answer = new Answer(cmd, false, errMsg);
} else {
answer = ep.sendMessage(cmd);
}
if (answer != null && answer.getResult()) {
final ListVolumeAnswer tanswer = (ListVolumeAnswer) answer;
return tanswer.getTemplateInfo();
} else {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Can not list volumes for image store " + store.getId());
}
}
return null;
}
use of com.cloud.agent.api.storage.ListVolumeAnswer in project cosmic by MissionCriticalCloud.
the class NfsSecondaryStorageResource method execute.
private Answer execute(final ListVolumeCommand cmd) {
if (!_inSystemVM) {
return new ListVolumeAnswer(cmd.getSecUrl(), null);
}
final DataStoreTO store = cmd.getDataStore();
if (store instanceof NfsTO) {
final String root = getRootDir(cmd.getSecUrl());
final Map<Long, TemplateProp> templateInfos = _dlMgr.gatherVolumeInfo(root);
return new ListVolumeAnswer(cmd.getSecUrl(), templateInfos);
} else {
return new Answer(cmd, false, "Unsupported image data store: " + store);
}
}
Aggregations