use of org.apache.cloudstack.storage.command.ResignatureAnswer in project cloudstack by apache.
the class StorageSystemDataMotionStrategy method performResignature.
private CopyCmdAnswer performResignature(DataObject dataObj, HostVO hostVO, boolean keepGrantedAccess) {
long storagePoolId = dataObj.getDataStore().getId();
DataStore dataStore = dataStoreMgr.getDataStore(storagePoolId, DataStoreRole.Primary);
Map<String, String> details = getDetails(dataObj);
ResignatureCommand command = new ResignatureCommand(details);
ResignatureAnswer answer = null;
try {
_volumeService.grantAccess(dataObj, hostVO, dataStore);
answer = (ResignatureAnswer) _agentMgr.send(hostVO.getId(), command);
} catch (CloudRuntimeException | AgentUnavailableException | OperationTimedoutException ex) {
keepGrantedAccess = false;
String msg = "Failed to resign the DataObject with the following ID: " + dataObj.getId();
LOGGER.warn(msg, ex);
throw new CloudRuntimeException(msg + ex.getMessage());
} finally {
if (keepGrantedAccess == false) {
_volumeService.revokeAccess(dataObj, hostVO, dataStore);
}
}
if (answer == null || !answer.getResult()) {
final String errMsg;
if (answer != null && answer.getDetails() != null && !answer.getDetails().isEmpty()) {
errMsg = answer.getDetails();
} else {
errMsg = "Unable to perform resignature operation in 'StorageSystemDataMotionStrategy.performResignature'";
}
throw new CloudRuntimeException(errMsg);
}
VolumeObjectTO newVolume = new VolumeObjectTO();
newVolume.setSize(answer.getSize());
newVolume.setPath(answer.getPath());
newVolume.setFormat(answer.getFormat());
return new CopyCmdAnswer(newVolume);
}
use of org.apache.cloudstack.storage.command.ResignatureAnswer in project cloudstack by apache.
the class XenServerStorageProcessor method resignature.
@Override
public ResignatureAnswer resignature(final ResignatureCommand cmd) {
SR newSr = null;
final Connection conn = hypervisorResource.getConnection();
try {
final Map<String, String> details = cmd.getDetails();
final String iScsiName = details.get(DiskTO.IQN);
final String storageHost = details.get(DiskTO.STORAGE_HOST);
final String chapInitiatorUsername = details.get(DiskTO.CHAP_INITIATOR_USERNAME);
final String chapInitiatorSecret = details.get(DiskTO.CHAP_INITIATOR_SECRET);
newSr = hypervisorResource.getIscsiSR(conn, iScsiName, storageHost, iScsiName, chapInitiatorUsername, chapInitiatorSecret, true, false);
Set<VDI> vdis = newSr.getVDIs(conn);
if (vdis.size() != 1) {
throw new RuntimeException("There were " + vdis.size() + " VDIs in the SR.");
}
VDI vdi = vdis.iterator().next();
final ResignatureAnswer resignatureAnswer = new ResignatureAnswer();
resignatureAnswer.setSize(vdi.getVirtualSize(conn));
resignatureAnswer.setPath(vdi.getUuid(conn));
resignatureAnswer.setFormat(ImageFormat.VHD);
return resignatureAnswer;
} catch (final Exception ex) {
s_logger.warn("Failed to resignature: " + ex.toString(), ex);
return new ResignatureAnswer(ex.getMessage());
} finally {
if (newSr != null) {
hypervisorResource.removeSR(conn, newSr);
}
}
}
Aggregations