CLOUDSTACK-3513: [Automation] Failed to copy iso and template between

zones.
This commit is contained in:
Min Chen 2013-07-17 17:24:03 -07:00
parent 1e3e131e14
commit cb2a84241b
2 changed files with 24 additions and 5 deletions

View File

@ -580,8 +580,8 @@ public class TemplateServiceImpl implements TemplateService {
TemplateOpContext<TemplateApiResult> context = new TemplateOpContext<TemplateApiResult>(null,
(TemplateObject) templateOnStore, future);
AsyncCallbackDispatcher<TemplateServiceImpl, CopyCommandResult> caller = AsyncCallbackDispatcher.create(this);
caller.setCallback(caller.getTarget().copyTemplateCallBack(null, null)).setContext(context);
AsyncCallbackDispatcher<TemplateServiceImpl, CreateCmdResult> caller = AsyncCallbackDispatcher.create(this);
caller.setCallback(caller.getTarget().copyTemplateCrossZoneCallBack(null, null)).setContext(context);
destStore.getDriver().createAsync(destStore, templateOnStore, caller);
return future;
}
@ -652,6 +652,28 @@ public class TemplateServiceImpl implements TemplateService {
return null;
}
protected Void copyTemplateCrossZoneCallBack(AsyncCallbackDispatcher<TemplateServiceImpl, CreateCmdResult> callback, TemplateOpContext<TemplateApiResult> context) {
TemplateInfo destTemplate = context.getTemplate();
CreateCmdResult result = callback.getResult();
AsyncCallFuture<TemplateApiResult> future = context.getFuture();
TemplateApiResult res = new TemplateApiResult(destTemplate);
try {
if (result.isFailed()) {
res.setResult(result.getResult());
destTemplate.processEvent(Event.OperationFailed);
} else {
destTemplate.processEvent(Event.OperationSuccessed, result.getAnswer());
}
future.complete(res);
} catch (Exception e) {
s_logger.debug("Failed to process copy template cross zones callback", e);
res.setResult(e.toString());
future.complete(res);
}
return null;
}
@Override
public void addSystemVMTemplatesToSecondary(DataStore store) {
long storeId = store.getId();

View File

@ -634,9 +634,6 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
createEventType = EventTypes.EVENT_TEMPLATE_CREATE;
}
Transaction txn = Transaction.currentTxn();
txn.start();
TemplateInfo srcTemplate = this._tmplFactory.getTemplate(template.getId(), srcSecStore);
// Copy will just find one eligible image store for the destination zone
// and copy template there, not propagate to all image stores