use of com.cloud.engine.subsystem.api.storage.EndPoint in project cosmic by MissionCriticalCloud.
the class CloudStackPrimaryDataStoreDriverImpl method revertSnapshot.
@Override
public void revertSnapshot(final SnapshotInfo snapshot, final SnapshotInfo snapshotOnPrimaryStore, final AsyncCompletionCallback<CommandResult> callback) {
final SnapshotObjectTO snapshotTO = (SnapshotObjectTO) snapshot.getTO();
final RevertSnapshotCommand cmd = new RevertSnapshotCommand(snapshotTO);
final CommandResult result = new CommandResult();
try {
final EndPoint ep = epSelector.select(snapshotOnPrimaryStore);
if (ep == null) {
final String errMsg = "No remote endpoint to send RevertSnapshotCommand, check if host or ssvm is down?";
s_logger.error(errMsg);
result.setResult(errMsg);
} else {
final Answer answer = ep.sendMessage(cmd);
if (answer != null && !answer.getResult()) {
result.setResult(answer.getDetails());
}
}
} catch (final Exception ex) {
s_logger.debug("Unable to revert snapshot " + snapshot.getId(), ex);
result.setResult(ex.toString());
}
callback.complete(result);
}
use of com.cloud.engine.subsystem.api.storage.EndPoint in project cosmic by MissionCriticalCloud.
the class BaseImageStoreDriverImpl method deleteAsync.
@Override
public void deleteAsync(final DataStore dataStore, final DataObject data, final AsyncCompletionCallback<CommandResult> callback) {
final CommandResult result = new CommandResult();
try {
final DeleteCommand cmd = new DeleteCommand(data.getTO());
final EndPoint ep = _epSelector.select(data);
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()) {
result.setResult(answer.getDetails());
}
} catch (final Exception ex) {
s_logger.debug("Unable to destoy " + data.getType().toString() + ": " + data.getId(), ex);
result.setResult(ex.toString());
}
callback.complete(result);
}
use of com.cloud.engine.subsystem.api.storage.EndPoint in project cosmic by MissionCriticalCloud.
the class AncientDataMotionStrategy method createTemplateFromSnapshot.
@DB
protected Answer createTemplateFromSnapshot(DataObject srcData, final DataObject destData) {
final String value = configDao.getValue(Config.CreatePrivateTemplateFromSnapshotWait.toString());
final int _createprivatetemplatefromsnapshotwait = NumbersUtil.parseInt(value, Integer.parseInt(Config.CreatePrivateTemplateFromSnapshotWait.getDefaultValue()));
boolean needCache = false;
if (needCacheStorage(srcData, destData)) {
needCache = true;
final SnapshotInfo snapshot = (SnapshotInfo) srcData;
srcData = cacheSnapshotChain(snapshot, snapshot.getDataStore().getScope());
}
EndPoint ep = null;
if (srcData.getDataStore().getRole() == DataStoreRole.Primary) {
ep = selector.select(destData);
} else {
ep = selector.select(srcData, destData);
}
final CopyCommand cmd = new CopyCommand(srcData.getTO(), destData.getTO(), _createprivatetemplatefromsnapshotwait, VirtualMachineManager.ExecuteInSequence.value());
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);
}
// clean up snapshot copied to staging
if (needCache && srcData != null) {
// reduce ref count, but keep it there on cache which is converted from previous secondary storage
cacheMgr.releaseCacheObject(srcData);
}
return answer;
}
use of com.cloud.engine.subsystem.api.storage.EndPoint in project cosmic by MissionCriticalCloud.
the class AncientDataMotionStrategy method migrateVolumeToPool.
protected Answer migrateVolumeToPool(final DataObject srcData, final DataObject destData) {
final String value = configDao.getValue(Config.MigrateWait.key());
final int waitInterval = NumbersUtil.parseInt(value, Integer.parseInt(Config.MigrateWait.getDefaultValue()));
final VolumeInfo volume = (VolumeInfo) srcData;
final StoragePool destPool = (StoragePool) dataStoreMgr.getDataStore(destData.getDataStore().getId(), DataStoreRole.Primary);
final MigrateVolumeCommand command = new MigrateVolumeCommand(volume.getId(), volume.getPath(), destPool, volume.getAttachedVmName(), volume.getVolumeType(), waitInterval);
final EndPoint ep = selector.select(srcData, StorageAction.MIGRATEVOLUME);
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(command, false, errMsg);
} else {
answer = ep.sendMessage(command);
}
if (answer == null || !answer.getResult()) {
throw new CloudRuntimeException("Failed to migrate volume " + volume + " to storage pool " + destPool);
} else {
// Update the volume details after migration.
final VolumeVO volumeVo = volDao.findById(volume.getId());
final Long oldPoolId = volume.getPoolId();
volumeVo.setPath(((MigrateVolumeAnswer) answer).getVolumePath());
final String chainInfo = ((MigrateVolumeAnswer) answer).getVolumeChainInfo();
if (chainInfo != null) {
volumeVo.setChainInfo(chainInfo);
}
volumeVo.setPodId(destPool.getPodId());
volumeVo.setPoolId(destPool.getId());
volumeVo.setLastPoolId(oldPoolId);
// For SMB, pool credentials are also stored in the uri query string. We trim the query string
// part here to make sure the credentials do not get stored in the db unencrypted.
String folder = destPool.getPath();
if (destPool.getPoolType() == StoragePoolType.SMB && folder != null && folder.contains("?")) {
folder = folder.substring(0, folder.indexOf("?"));
}
volumeVo.setFolder(folder);
volDao.update(volume.getId(), volumeVo);
}
return answer;
}
use of com.cloud.engine.subsystem.api.storage.EndPoint in project cosmic by MissionCriticalCloud.
the class AncientDataMotionStrategy method copyVolumeBetweenPools.
protected Answer copyVolumeBetweenPools(final DataObject srcData, final DataObject destData) {
final String value = configDao.getValue(Config.CopyVolumeWait.key());
final int _copyvolumewait = NumbersUtil.parseInt(value, Integer.parseInt(Config.CopyVolumeWait.getDefaultValue()));
final Scope destScope = getZoneScope(destData.getDataStore().getScope());
final DataStore cacheStore = cacheMgr.getCacheStorage(destScope);
if (cacheStore == null) {
// need to find a nfs or cifs image store, assuming that can't copy volume
final ImageStoreEntity imageStore = (ImageStoreEntity) dataStoreMgr.getImageStore(destScope.getScopeId());
if (!imageStore.getProtocol().equalsIgnoreCase("nfs") && !imageStore.getProtocol().equalsIgnoreCase("cifs")) {
s_logger.debug("can't find a nfs (or cifs) image store to satisfy the need for a staging store");
return null;
}
final DataObject objOnImageStore = imageStore.create(srcData);
objOnImageStore.processEvent(Event.CreateOnlyRequested);
Answer answer = copyObject(srcData, objOnImageStore);
if (answer == null || !answer.getResult()) {
if (answer != null) {
s_logger.debug("copy to image store failed: " + answer.getDetails());
}
objOnImageStore.processEvent(Event.OperationFailed);
imageStore.delete(objOnImageStore);
return answer;
}
objOnImageStore.processEvent(Event.OperationSuccessed, answer);
objOnImageStore.processEvent(Event.CopyingRequested);
final CopyCommand cmd = new CopyCommand(objOnImageStore.getTO(), destData.getTO(), _copyvolumewait, VirtualMachineManager.ExecuteInSequence.value());
final EndPoint ep = selector.select(objOnImageStore, destData);
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()) {
if (answer != null) {
s_logger.debug("copy to primary store failed: " + answer.getDetails());
}
objOnImageStore.processEvent(Event.OperationFailed);
imageStore.delete(objOnImageStore);
return answer;
}
objOnImageStore.processEvent(Event.OperationSuccessed);
imageStore.delete(objOnImageStore);
return answer;
} else {
final DataObject cacheData = cacheMgr.createCacheObject(srcData, destScope);
final CopyCommand cmd = new CopyCommand(cacheData.getTO(), destData.getTO(), _copyvolumewait, VirtualMachineManager.ExecuteInSequence.value());
final EndPoint ep = selector.select(cacheData, destData);
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);
}
// delete volume on cache store
if (cacheData != null) {
cacheMgr.deleteCacheObject(cacheData);
}
return answer;
}
}
Aggregations