You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by mc...@apache.org on 2013/07/24 01:55:51 UTC
git commit: updated refs/heads/4.2 to ae248af
Updated Branches:
refs/heads/4.2 040292d60 -> ae248afc5
CLOUDSTACK-3639:Unable to create template from snapshot when there are
multiple secondary storages in the zone.
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/ae248afc
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/ae248afc
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/ae248afc
Branch: refs/heads/4.2
Commit: ae248afc5791f0af8b915f15ef5d368ac69a0256
Parents: 040292d
Author: Min Chen <mi...@citrix.com>
Authored: Tue Jul 23 16:55:26 2013 -0700
Committer: Min Chen <mi...@citrix.com>
Committed: Tue Jul 23 16:55:26 2013 -0700
----------------------------------------------------------------------
.../com/cloud/template/TemplateManagerImpl.java | 39 ++++++++++----------
1 file changed, 19 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ae248afc/server/src/com/cloud/template/TemplateManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/template/TemplateManagerImpl.java b/server/src/com/cloud/template/TemplateManagerImpl.java
index 5005ee0..c87f8eb 100755
--- a/server/src/com/cloud/template/TemplateManagerImpl.java
+++ b/server/src/com/cloud/template/TemplateManagerImpl.java
@@ -611,7 +611,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
@Override
@DB
public boolean copy(long userId, VMTemplateVO template, DataStore srcSecStore, DataCenterVO dstZone) throws StorageUnavailableException,
- ResourceAllocationException {
+ ResourceAllocationException {
long tmpltId = template.getId();
long dstZoneId = dstZone.getId();
// find all eligible image stores for the destination zone
@@ -913,7 +913,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
}
boolean result = attachISOToVM(vmId, userId, isoId, false); // attach=false
- // => detach
+ // => detach
if (result) {
return result;
} else {
@@ -1256,14 +1256,14 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
}
if (isExtractable != null && caller.getType() == Account.ACCOUNT_TYPE_ADMIN) {// Only
- // ROOT
- // admins
- // allowed
- // to
- // change
- // this
- // powerful
- // attribute
+ // ROOT
+ // admins
+ // allowed
+ // to
+ // change
+ // this
+ // powerful
+ // attribute
updatedTemplate.setExtractable(isExtractable.booleanValue());
} else if (isExtractable != null && caller.getType() != Account.ACCOUNT_TYPE_ADMIN) {
throw new InvalidParameterValueException("Only ROOT admins are allowed to modify this attribute.");
@@ -1279,7 +1279,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
if (permittedAccount != null) {
if (permittedAccount.getId() == caller.getId()) {
continue; // don't grant permission to the template
- // owner, they implicitly have permission
+ // owner, they implicitly have permission
}
LaunchPermissionVO existingPermission = _launchPermissionDao.findByTemplateAndAccount(id, permittedAccount.getId());
if (existingPermission == null) {
@@ -1336,7 +1336,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
try {
TemplateInfo tmplInfo = this._tmplFactory.getTemplate(templateId, DataStoreRole.Image);
- Long zoneId = null;
+ long zoneId = 0;
if (snapshotId != null) {
snapshot = _snapshotDao.findById(snapshotId);
zoneId = snapshot.getDataCenterId();
@@ -1344,18 +1344,17 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
volume = _volumeDao.findById(volumeId);
zoneId = volume.getDataCenterId();
}
- ZoneScope scope = new ZoneScope(zoneId);
- List<DataStore> store = this._dataStoreMgr.getImageStoresByScope(scope);
- if (store.size() > 1) {
- throw new CloudRuntimeException("muliple image data store, don't know which one to use");
+ DataStore store = this._dataStoreMgr.getImageStore(zoneId);
+ if (store == null) {
+ throw new CloudRuntimeException("cannot find an image store for zone " + zoneId);
}
AsyncCallFuture<TemplateApiResult> future = null;
if (snapshotId != null) {
SnapshotInfo snapInfo = this._snapshotFactory.getSnapshot(snapshotId, DataStoreRole.Image);
- future = this._tmpltSvr.createTemplateFromSnapshotAsync(snapInfo, tmplInfo, store.get(0));
+ future = this._tmpltSvr.createTemplateFromSnapshotAsync(snapInfo, tmplInfo, store);
} else if (volumeId != null) {
VolumeInfo volInfo = this._volFactory.getVolume(volumeId);
- future = this._tmpltSvr.createTemplateFromVolumeAsync(volInfo, tmplInfo, store.get(0));
+ future = this._tmpltSvr.createTemplateFromVolumeAsync(volInfo, tmplInfo, store);
} else {
throw new CloudRuntimeException("Creating private Template need to specify snapshotId or volumeId");
}
@@ -1556,8 +1555,8 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
if (template != null) {
sourceTemplateId = template.getId();
} else if (volume.getVolumeType() == Volume.Type.ROOT) { // vm
- // created
- // out
+ // created
+ // out
// of blank
// template
UserVm userVm = ApiDBUtils.findUserVmById(volume.getInstanceId());