Skip to content

Commit 79151f5

Browse files
committed
Remove sendToSSVM reference from SnapshotManagerImpl and
TemplateManagerImpl.
1 parent 4c174a6 commit 79151f5

3 files changed

Lines changed: 11 additions & 87 deletions

File tree

‎plugins/storage/image/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackImageStoreDriverImpl.java‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -310,12 +310,13 @@ private void deleteTemplate(DataObject data, AsyncCompletionCallback<CommandResu
310310
callback.complete(result);
311311
}
312312

313-
VMTemplateZoneVO templateZone = templateZoneDao.findByZoneTemplate(sZoneId, templateId);
314-
315-
if (templateZone != null) {
316-
templateZoneDao.remove(templateZone.getId());
313+
List<VMTemplateZoneVO> templateZones = templateZoneDao.listByZoneTemplate(sZoneId, templateId);
314+
if (templateZones != null) {
315+
for (VMTemplateZoneVO templateZone : templateZones) {
316+
templateZoneDao.remove(templateZone.getId());
317+
}
317318
}
318-
}
319+
}
319320
}
320321

321322
}

‎server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java‎

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -319,20 +319,14 @@ public Snapshot createSnapshot(Long volumeId, Long policyId, Long snapshotId, Ac
319319
return snapshot;
320320
}
321321

322-
private void checkObjectStorageConfiguration(SwiftTO swift, S3TO s3) {
323-
324-
if (swift != null && s3 != null) {
325-
throw new CloudRuntimeException(
326-
"Swift and S3 are not simultaneously supported for snapshot backup.");
327-
}
328-
329-
}
330322

331323
@Override
332324
public void deleteSnapshotsDirForVolume(String secondaryStoragePoolUrl, Long dcId, Long accountId, Long volumeId) {
333325
DeleteSnapshotsDirCommand cmd = new DeleteSnapshotsDirCommand(secondaryStoragePoolUrl, dcId, accountId, volumeId);
334326
try {
335-
Answer ans = _agentMgr.sendToSSVM(dcId, cmd);
327+
DataStore store = this.dataStoreMgr.getImageStore(dcId);
328+
EndPoint ep = _epSelector.select(store);
329+
Answer ans = ep.sendMessage(cmd);
336330
if (ans == null || !ans.getResult()) {
337331
s_logger.warn("DeleteSnapshotsDirCommand failed due to " + ans.getDetails() + " volume id: " + volumeId);
338332
}

‎server/src/com/cloud/template/TemplateManagerImpl.java‎

Lines changed: 2 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -530,61 +530,6 @@ private void reallyRun() {
530530
}
531531

532532

533-
534-
String uploadTemplateToSwiftFromSecondaryStorage(VMTemplateHostVO templateHostRef) {
535-
Long templateId = templateHostRef.getTemplateId();
536-
VMTemplateVO template = _tmpltDao.findById(templateId);
537-
if (template == null) {
538-
String errMsg = " Can not find template " + templateId;
539-
s_logger.warn(errMsg);
540-
return errMsg;
541-
}
542-
543-
if (template.getTemplateType() == TemplateType.PERHOST) {
544-
return null;
545-
}
546-
547-
SwiftTO swift = _swiftMgr.getSwiftTO();
548-
if (swift == null) {
549-
String errMsg = " There is no Swift in this setup ";
550-
s_logger.warn(errMsg);
551-
return errMsg;
552-
}
553-
554-
HostVO secHost = _hostDao.findById(templateHostRef.getHostId());
555-
if (secHost == null) {
556-
String errMsg = "Can not find secondary storage " + templateHostRef.getHostId();
557-
s_logger.warn(errMsg);
558-
return errMsg;
559-
}
560-
561-
uploadTemplateToSwiftFromSecondaryStorageCommand cmd = new uploadTemplateToSwiftFromSecondaryStorageCommand(swift, secHost.getName(), secHost.getDataCenterId(), template.getAccountId(),
562-
templateId, _primaryStorageDownloadWait);
563-
Answer answer = null;
564-
try {
565-
answer = _agentMgr.sendToSSVM(secHost.getDataCenterId(), cmd);
566-
if (answer == null || !answer.getResult()) {
567-
if (template.getTemplateType() != TemplateType.SYSTEM) {
568-
String errMsg = "Failed to upload template " + templateId + " to Swift from secondary storage due to " + ((answer == null) ? "null" : answer.getDetails());
569-
s_logger.warn(errMsg);
570-
throw new CloudRuntimeException(errMsg);
571-
}
572-
return null;
573-
}
574-
String path = templateHostRef.getInstallPath();
575-
int index = path.lastIndexOf('/');
576-
path = path.substring(index + 1);
577-
VMTemplateSwiftVO tmpltSwift = new VMTemplateSwiftVO(swift.getId(), templateHostRef.getTemplateId(), new Date(), path, templateHostRef.getSize(), templateHostRef.getPhysicalSize());
578-
_tmpltSwiftDao.persist(tmpltSwift);
579-
_swiftMgr.propagateTemplateOnAllZones(templateHostRef.getTemplateId());
580-
} catch (Exception e) {
581-
String errMsg = "Failed to upload template " + templateId + " to Swift from secondary storage due to " + e.toString();
582-
s_logger.warn(errMsg);
583-
throw new CloudRuntimeException(errMsg);
584-
}
585-
return null;
586-
}
587-
588533
@Override @DB
589534
public VMTemplateStoragePoolVO prepareTemplateForCreate(VMTemplateVO templ, StoragePool pool) {
590535
VMTemplateVO template = _tmpltDao.findById(templ.getId(), true);
@@ -1182,30 +1127,14 @@ public boolean deleteIso(DeleteIsoCmd cmd) {
11821127
if (template.getFormat() != ImageFormat.ISO) {
11831128
throw new InvalidParameterValueException("Please specify a valid iso.");
11841129
}
1185-
if (cmd.getZoneId() == null && _swiftMgr.isSwiftEnabled()) {
1186-
_swiftMgr.deleteIso(cmd);
1187-
}
1188-
if (cmd.getZoneId() == null && _s3Mgr.isS3Enabled()) {
1189-
_s3Mgr.deleteTemplate(caller.getAccountId(), templateId);
1190-
}
11911130

1192-
if (zoneId != null && (_ssvmMgr.findSecondaryStorageHost(zoneId) == null)) {
1193-
throw new InvalidParameterValueException("Failed to find a secondary storage host in the specified zone.");
1131+
if (zoneId != null && (this._dataStoreMgr.getImageStore(zoneId) == null)) {
1132+
throw new InvalidParameterValueException("Failed to find a secondary storage store in the specified zone.");
11941133
}
11951134
TemplateAdapter adapter = getAdapter(template.getHypervisorType());
11961135
TemplateProfile profile = adapter.prepareDelete(cmd);
11971136
boolean result = adapter.delete(profile);
11981137
if (result) {
1199-
if (cmd.getZoneId() == null
1200-
&& (_swiftMgr.isSwiftEnabled() || _s3Mgr.isS3Enabled())) {
1201-
List<VMTemplateZoneVO> templateZones = _tmpltZoneDao
1202-
.listByZoneTemplate(null, templateId);
1203-
if (templateZones != null) {
1204-
for (VMTemplateZoneVO templateZone : templateZones) {
1205-
_tmpltZoneDao.remove(templateZone.getId());
1206-
}
1207-
}
1208-
}
12091138
return true;
12101139
} else {
12111140
throw new CloudRuntimeException("Failed to delete ISO");

0 commit comments

Comments
 (0)