use of org.apache.cloudstack.engine.subsystem.api.storage.EndPoint in project cloudstack by apache.
the class AncientDataMotionStrategy method copySnapshot.
protected Answer copySnapshot(DataObject srcData, DataObject destData) {
String value = configDao.getValue(Config.BackupSnapshotWait.toString());
int _backupsnapshotwait = NumbersUtil.parseInt(value, Integer.parseInt(Config.BackupSnapshotWait.getDefaultValue()));
DataObject cacheData = null;
SnapshotInfo snapshotInfo = (SnapshotInfo) srcData;
Object payload = snapshotInfo.getPayload();
Boolean fullSnapshot = true;
if (payload != null) {
fullSnapshot = (Boolean) payload;
}
Map<String, String> options = new HashMap<String, String>();
options.put("fullSnapshot", fullSnapshot.toString());
Answer answer = null;
try {
if (needCacheStorage(srcData, destData)) {
Scope selectedScope = pickCacheScopeForCopy(srcData, destData);
cacheData = cacheMgr.getCacheObject(srcData, selectedScope);
CopyCommand cmd = new CopyCommand(srcData.getTO(), addFullCloneFlagOnVMwareDest(destData.getTO()), _backupsnapshotwait, VirtualMachineManager.ExecuteInSequence.value());
cmd.setCacheTO(cacheData.getTO());
cmd.setOptions(options);
EndPoint ep = selector.select(srcData, destData);
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);
}
} else {
addFullCloneFlagOnVMwareDest(destData.getTO());
CopyCommand cmd = new CopyCommand(srcData.getTO(), destData.getTO(), _backupsnapshotwait, VirtualMachineManager.ExecuteInSequence.value());
cmd.setOptions(options);
EndPoint ep = selector.select(srcData, destData, StorageAction.BACKUPSNAPSHOT);
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);
}
}
// clean up cache entry
if (cacheData != null) {
cacheMgr.deleteCacheObject(cacheData);
}
return answer;
} catch (Exception e) {
s_logger.debug("copy snasphot failed: " + e.toString());
if (cacheData != null) {
cacheMgr.deleteCacheObject(cacheData);
}
throw new CloudRuntimeException(e.toString());
}
}
use of org.apache.cloudstack.engine.subsystem.api.storage.EndPoint in project cloudstack by apache.
the class AncientDataMotionStrategy method createTemplateFromSnapshot.
@DB
protected Answer createTemplateFromSnapshot(DataObject srcData, DataObject destData) {
String value = configDao.getValue(Config.CreatePrivateTemplateFromSnapshotWait.toString());
int _createprivatetemplatefromsnapshotwait = NumbersUtil.parseInt(value, Integer.parseInt(Config.CreatePrivateTemplateFromSnapshotWait.getDefaultValue()));
boolean needCache = false;
if (needCacheStorage(srcData, destData)) {
needCache = true;
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);
}
CopyCommand cmd = new CopyCommand(srcData.getTO(), addFullCloneFlagOnVMwareDest(destData.getTO()), _createprivatetemplatefromsnapshotwait, VirtualMachineManager.ExecuteInSequence.value());
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);
}
// 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 org.apache.cloudstack.engine.subsystem.api.storage.EndPoint in project cloudstack by apache.
the class VolumeServiceImpl method registerVolumeForPostUpload.
@Override
public Pair<EndPoint, DataObject> registerVolumeForPostUpload(VolumeInfo volume, DataStore store) {
EndPoint ep = _epSelector.select(store);
if (ep == null) {
String errorMessage = "There is no secondary storage VM for image store " + store.getName();
s_logger.warn(errorMessage);
throw new CloudRuntimeException(errorMessage);
}
DataObject volumeOnStore = store.create(volume);
return new Pair<>(ep, volumeOnStore);
}
use of org.apache.cloudstack.engine.subsystem.api.storage.EndPoint in project cloudstack by apache.
the class VolumeServiceImpl method resizeVolumeOnHypervisor.
@Override
public void resizeVolumeOnHypervisor(long volumeId, long newSize, long destHostId, String instanceName) {
final String errMsg = "Resize command failed";
try {
Answer answer = null;
Host destHost = _hostDao.findById(destHostId);
EndPoint ep = RemoteHostEndPoint.getHypervisorHostEndPoint(destHost);
if (ep != null) {
VolumeVO volume = volDao.findById(volumeId);
PrimaryDataStore primaryDataStore = this.dataStoreMgr.getPrimaryDataStore(volume.getPoolId());
ResizeVolumeCommand resizeCmd = new ResizeVolumeCommand(volume.getPath(), new StorageFilerTO(primaryDataStore), volume.getSize(), newSize, true, instanceName, primaryDataStore.isManaged(), volume.get_iScsiName());
answer = ep.sendMessage(resizeCmd);
} else {
throw new CloudRuntimeException("Could not find a remote endpoint to send command to. Check if host or SSVM is down.");
}
if (answer == null || !answer.getResult()) {
throw new CloudRuntimeException(answer != null ? answer.getDetails() : errMsg);
}
} catch (Exception e) {
throw new CloudRuntimeException(errMsg, e);
}
}
use of org.apache.cloudstack.engine.subsystem.api.storage.EndPoint in project cloudstack by apache.
the class DefaultEndPointSelector method select.
@Override
public EndPoint select(DataObject object) {
DataStore store = object.getDataStore();
EndPoint ep = select(store);
if (ep != null) {
return ep;
}
if (object instanceof TemplateInfo) {
TemplateInfo tmplInfo = (TemplateInfo) object;
if (store.getScope().getScopeType() == ScopeType.ZONE && store.getScope().getScopeId() == null && tmplInfo.getTemplateType() == TemplateType.SYSTEM) {
// for bootstrap system vm template downloading to region image store
return LocalHostEndpoint.getEndpoint();
}
}
return null;
}
Aggregations