You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by hu...@apache.org on 2014/01/31 09:47:41 UTC

[1/4] git commit: updated refs/heads/master to d578d7e

Updated Branches:
  refs/heads/master d409d709e -> d578d7ef8


Fix for a potential NPE


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/d56c5dfc
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/d56c5dfc
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/d56c5dfc

Branch: refs/heads/master
Commit: d56c5dfc1363c4acee4375108f5c4c868f547d14
Parents: d409d70
Author: Hugo Trippaers <ht...@schubergphilis.com>
Authored: Thu Jan 30 14:44:50 2014 +0100
Committer: Hugo Trippaers <ht...@schubergphilis.com>
Committed: Fri Jan 31 09:37:11 2014 +0100

----------------------------------------------------------------------
 .../storage/volume/VolumeServiceImpl.java       | 42 ++++++++++----------
 1 file changed, 21 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d56c5dfc/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
index 3e5a546..3e315da 100644
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
+++ b/engine/storage/volume/src/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java
@@ -420,12 +420,12 @@ public class VolumeServiceImpl implements VolumeService {
         } else {
             if (s_logger.isDebugEnabled()) {
                 s_logger.debug("Found template " + template.getUniqueName() + " in storage pool " + dataStore.getId() + " with VMTemplateStoragePool id: " +
-                    templatePoolRef.getId());
+                        templatePoolRef.getId());
             }
         }
         long templatePoolRefId = templatePoolRef.getId();
         CreateBaseImageContext<CreateCmdResult> context =
-            new CreateBaseImageContext<CreateCmdResult>(null, volume, dataStore, template, future, templateOnPrimaryStoreObj, templatePoolRefId);
+                new CreateBaseImageContext<CreateCmdResult>(null, volume, dataStore, template, future, templateOnPrimaryStoreObj, templatePoolRefId);
         AsyncCallbackDispatcher<VolumeServiceImpl, CopyCommandResult> caller = AsyncCallbackDispatcher.create(this);
         caller.setCallback(caller.getTarget().copyBaseImageCallback(null, null)).setContext(context);
 
@@ -440,9 +440,9 @@ public class VolumeServiceImpl implements VolumeService {
                 s_logger.info("Unable to acquire lock on VMTemplateStoragePool " + templatePoolRefId);
             }
             templatePoolRef = _tmpltPoolDao.findByPoolTemplate(dataStore.getId(), template.getId());
-            if (templatePoolRef.getState() == ObjectInDataStoreStateMachine.State.Ready) {
+            if (templatePoolRef != null && templatePoolRef.getState() == ObjectInDataStoreStateMachine.State.Ready) {
                 s_logger.info("Unable to acquire lock on VMTemplateStoragePool " + templatePoolRefId + ", But Template " + template.getUniqueName() +
-                    " is already copied to primary storage, skip copying");
+                        " is already copied to primary storage, skip copying");
                 createVolumeFromBaseImageAsync(volume, templateOnPrimaryStoreObj, dataStore, future);
                 return;
             }
@@ -523,7 +523,7 @@ public class VolumeServiceImpl implements VolumeService {
         volumeOnPrimaryStorage.processEvent(Event.CreateOnlyRequested);
 
         CreateVolumeFromBaseImageContext<VolumeApiResult> context =
-            new CreateVolumeFromBaseImageContext<VolumeApiResult>(null, volumeOnPrimaryStorage, pd, templateOnPrimaryStore, future, null);
+                new CreateVolumeFromBaseImageContext<VolumeApiResult>(null, volumeOnPrimaryStorage, pd, templateOnPrimaryStore, future, null);
         AsyncCallbackDispatcher<VolumeServiceImpl, CopyCommandResult> caller = AsyncCallbackDispatcher.create(this);
         caller.setCallback(caller.getTarget().createVolumeFromBaseImageCallBack(null, null));
         caller.setContext(context);
@@ -534,7 +534,7 @@ public class VolumeServiceImpl implements VolumeService {
 
     @DB
     protected Void createVolumeFromBaseImageCallBack(AsyncCallbackDispatcher<VolumeServiceImpl, CopyCommandResult> callback,
-        CreateVolumeFromBaseImageContext<VolumeApiResult> context) {
+            CreateVolumeFromBaseImageContext<VolumeApiResult> context) {
         DataObject vo = context.vo;
         DataObject tmplOnPrimary = context.templateOnStore;
         CopyCommandResult result = callback.getResult();
@@ -615,7 +615,7 @@ public class VolumeServiceImpl implements VolumeService {
             volumeOnStore.processEvent(Event.CreateOnlyRequested);
             snapshot.processEvent(Event.CopyingRequested);
             CreateVolumeFromBaseImageContext<VolumeApiResult> context =
-                new CreateVolumeFromBaseImageContext<VolumeApiResult>(null, volume, store, volumeOnStore, future, snapshot);
+                    new CreateVolumeFromBaseImageContext<VolumeApiResult>(null, volume, store, volumeOnStore, future, snapshot);
             AsyncCallbackDispatcher<VolumeServiceImpl, CopyCommandResult> caller = AsyncCallbackDispatcher.create(this);
             caller.setCallback(caller.getTarget().createVolumeFromSnapshotCallback(null, null)).setContext(context);
             motionSrv.copyAsync(snapshot, volumeOnStore, caller);
@@ -630,7 +630,7 @@ public class VolumeServiceImpl implements VolumeService {
     }
 
     protected Void createVolumeFromSnapshotCallback(AsyncCallbackDispatcher<VolumeServiceImpl, CopyCommandResult> callback,
-        CreateVolumeFromBaseImageContext<VolumeApiResult> context) {
+            CreateVolumeFromBaseImageContext<VolumeApiResult> context) {
         CopyCommandResult result = callback.getResult();
         VolumeInfo volume = (VolumeInfo)context.templateOnStore;
         SnapshotInfo snapshot = context.snapshot;
@@ -716,7 +716,7 @@ public class VolumeServiceImpl implements VolumeService {
     }
 
     protected Void
-        copyVolumeFromImageToPrimaryCallback(AsyncCallbackDispatcher<VolumeServiceImpl, CopyCommandResult> callback, CopyVolumeContext<VolumeApiResult> context) {
+    copyVolumeFromImageToPrimaryCallback(AsyncCallbackDispatcher<VolumeServiceImpl, CopyCommandResult> callback, CopyVolumeContext<VolumeApiResult> context) {
         VolumeInfo srcVolume = context.srcVolume;
         VolumeInfo destVolume = context.destVolume;
         CopyCommandResult result = callback.getResult();
@@ -770,7 +770,7 @@ public class VolumeServiceImpl implements VolumeService {
     }
 
     protected Void
-        copyVolumeFromPrimaryToImageCallback(AsyncCallbackDispatcher<VolumeServiceImpl, CopyCommandResult> callback, CopyVolumeContext<VolumeApiResult> context) {
+    copyVolumeFromPrimaryToImageCallback(AsyncCallbackDispatcher<VolumeServiceImpl, CopyCommandResult> callback, CopyVolumeContext<VolumeApiResult> context) {
         VolumeInfo srcVolume = context.srcVolume;
         VolumeInfo destVolume = context.destVolume;
         CopyCommandResult result = callback.getResult();
@@ -988,7 +988,7 @@ public class VolumeServiceImpl implements VolumeService {
     }
 
     protected Void
-        migrateVmWithVolumesCallBack(AsyncCallbackDispatcher<VolumeServiceImpl, CopyCommandResult> callback, MigrateVmWithVolumesContext<CommandResult> context) {
+    migrateVmWithVolumesCallBack(AsyncCallbackDispatcher<VolumeServiceImpl, CopyCommandResult> callback, MigrateVmWithVolumesContext<CommandResult> context) {
         Map<VolumeInfo, DataStore> volumeToPool = context.volumeToPool;
         CopyCommandResult result = callback.getResult();
         AsyncCallFuture<CommandResult> future = context.future;
@@ -1065,20 +1065,20 @@ public class VolumeServiceImpl implements VolumeService {
                         physicalSize = volStore.getPhysicalSize();
                     } else {
                         s_logger.warn("No entry found in volume_store_ref for volume id: " + vo.getId() + " and image store id: " + ds.getId() +
-                            " at the end of uploading volume!");
+                                " at the end of uploading volume!");
                     }
                     Scope dsScope = ds.getScope();
                     if (dsScope.getScopeType() == ScopeType.ZONE) {
                         if (dsScope.getScopeId() != null) {
                             UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_UPLOAD, vo.getAccountId(), dsScope.getScopeId(), vo.getId(), vo.getName(), null,
-                                null, physicalSize, vo.getSize(), Volume.class.getName(), vo.getUuid());
+                                    null, physicalSize, vo.getSize(), Volume.class.getName(), vo.getUuid());
                         } else {
                             s_logger.warn("Zone scope image store " + ds.getId() + " has a null scope id");
                         }
                     } else if (dsScope.getScopeType() == ScopeType.REGION) {
                         // publish usage event for region-wide image store using a -1 zoneId for 4.2, need to revisit post-4.2
                         UsageEventUtils.publishUsageEvent(EventTypes.EVENT_VOLUME_UPLOAD, vo.getAccountId(), -1, vo.getId(), vo.getName(), null, null, physicalSize,
-                            vo.getSize(), Volume.class.getName(), vo.getUuid());
+                                vo.getSize(), Volume.class.getName(), vo.getUuid());
 
                         _resourceLimitMgr.incrementResourceCount(vo.getAccountId(), ResourceType.secondary_storage, vo.getSize());
                     }
@@ -1173,7 +1173,7 @@ public class VolumeServiceImpl implements VolumeService {
                         VolumeVO volume = _volumeDao.findById(volumeStore.getVolumeId());
                         if (volume == null) {
                             s_logger.warn("Volume_store_ref shows that volume " + volumeStore.getVolumeId() + " is on image store " + storeId +
-                                ", but the volume is not found in volumes table, potentially some bugs in deleteVolume, so we just treat this volume to be deleted and mark it as destroyed");
+                                    ", but the volume is not found in volumes table, potentially some bugs in deleteVolume, so we just treat this volume to be deleted and mark it as destroyed");
                             volumeStore.setDestroyed(true);
                             _volumeStoreDao.update(volumeStore.getId(), volumeStore);
                             continue;
@@ -1193,7 +1193,7 @@ public class VolumeServiceImpl implements VolumeService {
                                 s_logger.info("msg");
                                 if (volumeStore.getDownloadUrl() == null) {
                                     msg =
-                                        "Volume (" + volume.getUuid() + ") with install path " + volInfo.getInstallPath() +
+                                            "Volume (" + volume.getUuid() + ") with install path " + volInfo.getInstallPath() +
                                             "is corrupted, please check in image store: " + volumeStore.getDataStoreId();
                                     s_logger.warn(msg);
                                 } else {
@@ -1221,15 +1221,15 @@ public class VolumeServiceImpl implements VolumeService {
                                 if (volInfo.getSize() > 0) {
                                     try {
                                         _resourceLimitMgr.checkResourceLimit(_accountMgr.getAccount(volume.getAccountId()),
-                                            com.cloud.configuration.Resource.ResourceType.secondary_storage, volInfo.getSize() - volInfo.getPhysicalSize());
+                                                com.cloud.configuration.Resource.ResourceType.secondary_storage, volInfo.getSize() - volInfo.getPhysicalSize());
                                     } catch (ResourceAllocationException e) {
                                         s_logger.warn(e.getMessage());
                                         _alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_RESOURCE_LIMIT_EXCEEDED, volume.getDataCenterId(), volume.getPodId(),
-                                            e.getMessage(),
-                                            e.getMessage());
+                                                e.getMessage(),
+                                                e.getMessage());
                                     } finally {
                                         _resourceLimitMgr.recalculateResourceCount(volume.getAccountId(), volume.getDomainId(),
-                                            com.cloud.configuration.Resource.ResourceType.secondary_storage.getOrdinal());
+                                                com.cloud.configuration.Resource.ResourceType.secondary_storage.getOrdinal());
                                     }
                                 }
                             }
@@ -1238,7 +1238,7 @@ public class VolumeServiceImpl implements VolumeService {
                         // Volume is not on secondary but we should download.
                         if (volumeStore.getDownloadState() != Status.DOWNLOADED) {
                             s_logger.info("Volume Sync did not find " + volume.getName() + " ready on image store " + storeId +
-                                ", will request download to start/resume shortly");
+                                    ", will request download to start/resume shortly");
                             toBeDownloaded.add(volumeStore);
                         }
                     }


[4/4] git commit: updated refs/heads/master to d578d7e

Posted by hu...@apache.org.
update packages list before getting jre 7

(cherry picked from commit 5121f8cd4e4adcdf23b6ec25cb1c28bec8f417a7)
Signed-off-by: Hugo Trippaers <ht...@schubergphilis.com>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/d578d7ef
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/d578d7ef
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/d578d7ef

Branch: refs/heads/master
Commit: d578d7ef85a7304aec18a207a35535f62eed0e0b
Parents: 0685371
Author: Abhinandan Prateek <ap...@apache.org>
Authored: Fri Jan 17 21:15:51 2014 +0530
Committer: Hugo Trippaers <ht...@schubergphilis.com>
Committed: Fri Jan 31 09:42:31 2014 +0100

----------------------------------------------------------------------
 tools/appliance/definitions/systemvm64template/postinstall.sh | 1 +
 tools/appliance/definitions/systemvmtemplate/postinstall.sh   | 1 +
 2 files changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d578d7ef/tools/appliance/definitions/systemvm64template/postinstall.sh
----------------------------------------------------------------------
diff --git a/tools/appliance/definitions/systemvm64template/postinstall.sh b/tools/appliance/definitions/systemvm64template/postinstall.sh
index 144187d..1eddbdb 100644
--- a/tools/appliance/definitions/systemvm64template/postinstall.sh
+++ b/tools/appliance/definitions/systemvm64template/postinstall.sh
@@ -68,6 +68,7 @@ install_packages() {
   apt-get --no-install-recommends -q -y --force-yes install keepalived conntrackd ipvsadm libnetfilter-conntrack3 libnl1
   # ipcalc
   apt-get --no-install-recommends -q -y --force-yes install ipcalc
+  apt-get update
   # java
   apt-get --no-install-recommends -q -y --force-yes install  openjdk-7-jre-headless
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d578d7ef/tools/appliance/definitions/systemvmtemplate/postinstall.sh
----------------------------------------------------------------------
diff --git a/tools/appliance/definitions/systemvmtemplate/postinstall.sh b/tools/appliance/definitions/systemvmtemplate/postinstall.sh
index a4ff11f..175fc1f 100644
--- a/tools/appliance/definitions/systemvmtemplate/postinstall.sh
+++ b/tools/appliance/definitions/systemvmtemplate/postinstall.sh
@@ -64,6 +64,7 @@ install_packages() {
   apt-get --no-install-recommends -q -y --force-yes install keepalived conntrackd ipvsadm libnetfilter-conntrack3 libnl1
   # ipcalc
   apt-get --no-install-recommends -q -y --force-yes install ipcalc
+  apt-get update
   # java
   apt-get --no-install-recommends -q -y --force-yes install  openjdk-7-jre-headless
 


[2/4] git commit: updated refs/heads/master to d578d7e

Posted by hu...@apache.org.
Fix findbugs findings and remove dead code

Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/8f10dedc
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/8f10dedc
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/8f10dedc

Branch: refs/heads/master
Commit: 8f10dedce90e7768aca491a93f5f32f282669ece
Parents: d56c5df
Author: Hugo Trippaers <ht...@schubergphilis.com>
Authored: Fri Jan 31 09:36:33 2014 +0100
Committer: Hugo Trippaers <ht...@schubergphilis.com>
Committed: Fri Jan 31 09:37:16 2014 +0100

----------------------------------------------------------------------
 .../resource/NfsSecondaryStorageResource.java   | 207 +++--------
 .../resource/SecondaryStorageDiscoverer.java    |   7 -
 .../storage/template/DownloadManagerImpl.java   | 355 ++++++++-----------
 .../storage/template/UploadManagerImpl.java     | 246 ++++---------
 4 files changed, 260 insertions(+), 555 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8f10dedc/services/secondary-storage/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
----------------------------------------------------------------------
diff --git a/services/secondary-storage/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java b/services/secondary-storage/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
index 7c4b8ca..9782c2e 100755
--- a/services/secondary-storage/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
+++ b/services/secondary-storage/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
@@ -19,7 +19,6 @@ package org.apache.cloudstack.storage.resource;
 import static com.cloud.utils.S3Utils.mputFile;
 import static com.cloud.utils.S3Utils.putFile;
 import static com.cloud.utils.StringUtils.join;
-import static com.cloud.utils.db.GlobalLock.executeWithNoWaitLock;
 import static java.lang.String.format;
 import static java.util.Arrays.asList;
 import static org.apache.commons.lang.StringUtils.substringAfterLast;
@@ -44,7 +43,6 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.UUID;
-import java.util.concurrent.Callable;
 
 import javax.naming.ConfigurationException;
 
@@ -142,7 +140,6 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
     private static final Logger s_logger = Logger.getLogger(NfsSecondaryStorageResource.class);
 
     private static final String TEMPLATE_ROOT_DIR = "template/tmpl";
-    private static final String SNAPSHOT_ROOT_DIR = "snapshots";
     private static final String VOLUME_ROOT_DIR = "volumes";
 
     int _timeout;
@@ -180,7 +177,6 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
     private String _storageGateway;
     private final List<String> nfsIps = new ArrayList<String>();
     protected String _parent = "/mnt/SecStorage";
-    final private String _tmpltDir = "/var/cloudstack/template";
     final private String _tmpltpp = "template.properties";
     protected String createTemplateFromSnapshotXenScript;
 
@@ -264,7 +260,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
         String script = srcData.getObjectType() == DataObjectType.TEMPLATE ? createTmpltScr : createVolScr;
 
         int installTimeoutPerGig = 180 * 60 * 1000;
-        int imgSizeGigs = (int)Math.ceil(destFile.length() * 1.0d / (1024 * 1024 * 1024));
+        long imgSizeGigs = (long)Math.ceil(destFile.length() * 1.0d / (1024 * 1024 * 1024));
         imgSizeGigs++; // add one just in case
         long timeout = imgSizeGigs * installTimeoutPerGig;
 
@@ -279,7 +275,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
         String templateName = UUID.randomUUID().toString();
         String templateFilename = templateName + "." + extension;
         Script scr = new Script(script, timeout, s_logger);
-        scr.add("-s", Integer.toString(imgSizeGigs)); // not used for now
+        scr.add("-s", Long.toString(imgSizeGigs)); // not used for now
         scr.add("-n", templateFilename);
 
         scr.add("-t", downloadPath);
@@ -324,7 +320,9 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
         try {
             String downloadPath = determineStorageTemplatePath(storagePath, destPath);
             final File downloadDirectory = _storage.getFile(downloadPath);
-            downloadDirectory.mkdirs();
+            if (!downloadDirectory.mkdirs()) {
+                return new CopyCmdAnswer("Failed to create download directory " + downloadPath);
+            }
             File destFile = SwiftUtil.getObject(swiftTO, downloadDirectory, srcData.getPath());
             return postProcessing(destFile, downloadPath, destPath, srcData, destData);
         } catch (Exception e) {
@@ -341,9 +339,8 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
 
             String downloadPath = determineStorageTemplatePath(storagePath, destPath);
             final File downloadDirectory = _storage.getFile(downloadPath);
-            downloadDirectory.mkdirs();
 
-            if (!downloadDirectory.exists()) {
+            if (!downloadDirectory.mkdirs()) {
                 final String errMsg = "Unable to create directory " + downloadPath + " to copy from S3 to cache.";
                 s_logger.error(errMsg);
                 return new CopyCmdAnswer(errMsg);
@@ -372,7 +369,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
     }
 
     protected Answer copySnapshotToTemplateFromNfsToNfsXenserver(CopyCommand cmd, SnapshotObjectTO srcData, NfsTO srcDataStore, TemplateObjectTO destData,
-        NfsTO destDataStore) {
+            NfsTO destDataStore) {
         String srcMountPoint = getRootDir(srcDataStore.getUrl());
         String snapshotPath = srcData.getPath();
         int index = snapshotPath.lastIndexOf("/");
@@ -488,6 +485,8 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
                     processor = new QCOW2Processor();
                 } else if (srcFormat == ImageFormat.RAW) {
                     processor = new RawImageProcessor();
+                } else {
+                    throw new ConfigurationException("Unknown image format " + srcFormat.toString());
                 }
 
                 Map<String, Object> params = new HashMap<String, Object>();
@@ -550,8 +549,8 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
             } else if (destDataStore instanceof SwiftTO) {
                 //create template on the same data store
                 CopyCmdAnswer answer =
-                    (CopyCmdAnswer)copySnapshotToTemplateFromNfsToNfs(cmd, (SnapshotObjectTO)srcData, (NfsTO)srcDataStore, (TemplateObjectTO)destData,
-                        (NfsTO)srcDataStore);
+                        (CopyCmdAnswer)copySnapshotToTemplateFromNfsToNfs(cmd, (SnapshotObjectTO)srcData, (NfsTO)srcDataStore, (TemplateObjectTO)destData,
+                                (NfsTO)srcDataStore);
                 if (!answer.getResult()) {
                     return answer;
                 }
@@ -585,8 +584,8 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
             } else if (destDataStore instanceof S3TO) {
                 //create template on the same data store
                 CopyCmdAnswer answer =
-                    (CopyCmdAnswer)copySnapshotToTemplateFromNfsToNfs(cmd, (SnapshotObjectTO)srcData, (NfsTO)srcDataStore, (TemplateObjectTO)destData,
-                        (NfsTO)srcDataStore);
+                        (CopyCmdAnswer)copySnapshotToTemplateFromNfsToNfs(cmd, (SnapshotObjectTO)srcData, (NfsTO)srcDataStore, (TemplateObjectTO)destData,
+                                (NfsTO)srcDataStore);
                 if (!answer.getResult()) {
                     return answer;
                 }
@@ -651,7 +650,6 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
         return join(asList(TEMPLATE_ROOT_DIR, accountId, templateId, templateUniqueName), S3Utils.SEPARATOR);
     }
 
-    @SuppressWarnings("unchecked")
     private String determineS3TemplateNameFromKey(String key) {
         return StringUtils.substringAfterLast(StringUtils.substringBeforeLast(key, S3Utils.SEPARATOR), S3Utils.SEPARATOR);
     }
@@ -661,12 +659,10 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
         return join(asList(VOLUME_ROOT_DIR, accountId, volId), S3Utils.SEPARATOR);
     }
 
-    @SuppressWarnings("unchecked")
     protected Long determineS3VolumeIdFromKey(String key) {
         return Long.parseLong(StringUtils.substringAfterLast(StringUtils.substringBeforeLast(key, S3Utils.SEPARATOR), S3Utils.SEPARATOR));
     }
 
-    @SuppressWarnings("unchecked")
     private String determineStorageTemplatePath(final String storagePath, String dataPath) {
         return join(asList(getRootDir(storagePath), dataPath), File.separator);
     }
@@ -690,8 +686,8 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
                 _storage.mkdirs(filePath);
             }
             File destFile = new File(filePath + File.separator + name);
-            if (!destFile.exists()) {
-                destFile.createNewFile();
+            if (!destFile.createNewFile()) {
+                s_logger.warn("Reusing existing file " + destFile.getPath());
             }
             FileOutputStream outputStream = new FileOutputStream(destFile);
             entity.writeTo(outputStream);
@@ -744,9 +740,9 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
             }
 
             DownloadAnswer answer =
-                new DownloadAnswer(null, 100, null, VMTemplateStorageResourceAssoc.Status.DOWNLOADED, swiftPath, swiftPath, file.length(), file.length(), md5sum);
+                    new DownloadAnswer(null, 100, null, VMTemplateStorageResourceAssoc.Status.DOWNLOADED, swiftPath, swiftPath, file.length(), file.length(), md5sum);
             return answer;
-        } catch (Exception e) {
+        } catch (IOException e) {
             s_logger.debug("Failed to register template into swift", e);
             return new DownloadAnswer(e.toString(), VMTemplateStorageResourceAssoc.Status.DOWNLOAD_ERROR);
         } finally {
@@ -904,7 +900,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
         Script command = new Script("/bin/bash", s_logger);
         command.add("-c");
         command.add("/usr/bin/python /usr/local/cloud/systemvm/scripts/storage/secondary/swift -A " + swift.getUrl() + " -U " + swift.getAccount() + ":" +
-            swift.getUserName() + " -K " + swift.getKey() + " download " + container + " " + rfilename + " -o " + lFullPath);
+                swift.getUserName() + " -K " + swift.getKey() + " download " + container + " " + rfilename + " -o " + lFullPath);
         OutputInterpreter.AllLinesParser parser = new OutputInterpreter.AllLinesParser();
         String result = command.execute(parser);
         if (result != null) {
@@ -916,7 +912,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
             String[] lines = parser.getLines().split("\\n");
             for (String line : lines) {
                 if (line.contains("Errno") || line.contains("failed")) {
-                    String errMsg = "swiftDownload failed , err=" + lines.toString();
+                    String errMsg = "swiftDownload failed , err=" + parser.getLines();
                     s_logger.warn(errMsg);
                     return errMsg;
                 }
@@ -930,7 +926,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
         Script command = new Script("/bin/bash", s_logger);
         command.add("-c");
         command.add("cd " + ldir + ";/usr/bin/python /usr/local/cloud/systemvm/scripts/storage/secondary/swift -A " + swift.getUrl() + " -U " + swift.getAccount() + ":" +
-            swift.getUserName() + " -K " + swift.getKey() + " download " + container);
+                swift.getUserName() + " -K " + swift.getKey() + " download " + container);
         OutputInterpreter.AllLinesParser parser = new OutputInterpreter.AllLinesParser();
         String result = command.execute(parser);
         if (result != null) {
@@ -942,7 +938,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
             String[] lines = parser.getLines().split("\\n");
             for (String line : lines) {
                 if (line.contains("Errno") || line.contains("failed")) {
-                    String errMsg = "swiftDownloadContainer failed , err=" + lines.toString();
+                    String errMsg = "swiftDownloadContainer failed , err=" + parser.getLines();
                     s_logger.warn(errMsg);
                     return errMsg;
                 }
@@ -974,10 +970,10 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
             command.add("-c");
             if (size <= SWIFT_MAX_SIZE) {
                 command.add("cd " + lDir + ";/usr/bin/python /usr/local/cloud/systemvm/scripts/storage/secondary/swift -A " + swift.getUrl() + " -U " +
-                    swift.getAccount() + ":" + swift.getUserName() + " -K " + swift.getKey() + " upload " + container + " " + file);
+                        swift.getAccount() + ":" + swift.getUserName() + " -K " + swift.getKey() + " upload " + container + " " + file);
             } else {
                 command.add("cd " + lDir + ";/usr/bin/python /usr/local/cloud/systemvm/scripts/storage/secondary/swift -A " + swift.getUrl() + " -U " +
-                    swift.getAccount() + ":" + swift.getUserName() + " -K " + swift.getKey() + " upload -S " + SWIFT_MAX_SIZE + " " + container + " " + file);
+                        swift.getAccount() + ":" + swift.getUserName() + " -K " + swift.getKey() + " upload -S " + SWIFT_MAX_SIZE + " " + container + " " + file);
             }
             OutputInterpreter.AllLinesParser parser = new OutputInterpreter.AllLinesParser();
             String result = command.execute(parser);
@@ -990,7 +986,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
                 String[] lines = parser.getLines().split("\\n");
                 for (String line : lines) {
                     if (line.contains("Errno") || line.contains("failed")) {
-                        String errMsg = "swiftUpload failed , err=" + lines.toString();
+                        String errMsg = "swiftUpload failed , err=" + parser.getLines();
                         s_logger.warn(errMsg);
                         return errMsg;
                     }
@@ -1005,7 +1001,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
         Script command = new Script("/bin/bash", s_logger);
         command.add("-c");
         command.add("/usr/bin/python /usr/local/cloud/systemvm/scripts/storage/secondary/swift -A " + swift.getUrl() + " -U " + swift.getAccount() + ":" +
-            swift.getUserName() + " -K " + swift.getKey() + " list " + container + " " + rFilename);
+                swift.getUserName() + " -K " + swift.getKey() + " list " + container + " " + rFilename);
         OutputInterpreter.AllLinesParser parser = new OutputInterpreter.AllLinesParser();
         String result = command.execute(parser);
         if (result == null && parser.getLines() != null) {
@@ -1027,7 +1023,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
         Script command = new Script("/bin/bash", s_logger);
         command.add("-c");
         command.add("/usr/bin/python /usr/local/cloud/systemvm/scripts/storage/secondary/swift -A " + swift.getUrl() + " -U " + swift.getAccount() + ":" +
-            swift.getUserName() + " -K " + swift.getKey() + " delete " + container + " " + object);
+                swift.getUserName() + " -K " + swift.getKey() + " delete " + container + " " + object);
         OutputInterpreter.AllLinesParser parser = new OutputInterpreter.AllLinesParser();
         String result = command.execute(parser);
         if (result != null) {
@@ -1039,7 +1035,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
             String[] lines = parser.getLines().split("\\n");
             for (String line : lines) {
                 if (line.contains("Errno") || line.contains("failed")) {
-                    String errMsg = "swiftDelete failed , err=" + lines.toString();
+                    String errMsg = "swiftDelete failed , err=" + parser.getLines();
                     s_logger.warn(errMsg);
                     return errMsg;
                 }
@@ -1094,7 +1090,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
                 return new Answer(cmd, true, String.format("Deleted snapshot %1%s from bucket %2$s.", path, bucket));
             } catch (Exception e) {
                 final String errorMessage =
-                    String.format("Failed to delete snapshot %1$s from bucket %2$s due to the following error: %3$s", path, bucket, e.getMessage());
+                        String.format("Failed to delete snapshot %1$s from bucket %2$s due to the following error: %3$s", path, bucket, e.getMessage());
                 s_logger.error(errorMessage, e);
                 return new Answer(cmd, false, errorMessage);
             }
@@ -1123,21 +1119,6 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
         }
     }
 
-    private String determineSnapshotS3Directory(final Long accountId, final Long volumeId) {
-        return join(S3Utils.SEPARATOR, SNAPSHOT_ROOT_DIR, accountId, volumeId);
-    }
-
-    private String determineSnapshotS3Key(final Long accountId, final Long volumeId, final String snapshotFileName) {
-
-        final String directoryName = determineSnapshotS3Directory(accountId, volumeId);
-        return join(S3Utils.SEPARATOR, directoryName, snapshotFileName);
-
-    }
-
-    private String determineSnapshotLocalDirectory(final String secondaryStorageUrl, final Long accountId, final Long volumeId) {
-        return join(File.pathSeparator, getRootDir(secondaryStorageUrl), SNAPSHOT_ROOT_DIR, accountId, volumeId);
-    }
-
     private Answer execute(ComputeChecksumCommand cmd) {
 
         String relativeTemplatePath = cmd.getTemplatePath();
@@ -1207,7 +1188,6 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
         } else {
             String prvKey = certs.getPrivKey();
             String pubCert = certs.getPrivCert();
-            String certChain = certs.getCertChain();
 
             try {
                 File prvKeyFile = File.createTempFile("prvkey", null);
@@ -1265,69 +1245,6 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
         }
     }
 
-    private String deleteSnapshotBackupFromLocalFileSystem(final String secondaryStorageUrl, final Long accountId, final Long volumeId, final String name,
-        final Boolean deleteAllFlag) {
-        String lPath = null;
-        int index = name.lastIndexOf(File.separator);
-        String snapshotPath = name.substring(0, index);
-        if (deleteAllFlag) {
-            lPath = getRootDir(secondaryStorageUrl) + File.separator + snapshotPath + File.separator + "*";
-        } else {
-            lPath = getRootDir(secondaryStorageUrl) + File.separator + name + "*";
-        }
-
-        final String result = deleteLocalFile(lPath);
-
-        if (result != null) {
-            return "failed to delete snapshot " + lPath + " , err=" + result;
-        }
-
-        return null;
-
-    }
-
-    private String deleteSnapshotBackupfromS3(final S3TO s3, final Long accountId, final Long volumeId, final String name, final Boolean deleteAllFlag) {
-
-        try {
-
-            final String bucket = s3.getBucketName();
-
-            final String result = executeWithNoWaitLock(determineSnapshotLockId(accountId, volumeId), new Callable<String>() {
-
-                @Override
-                public String call() throws Exception {
-
-                    if (deleteAllFlag) {
-                        S3Utils.deleteDirectory(s3, bucket, determineSnapshotS3Directory(accountId, volumeId));
-                    } else {
-                        S3Utils.deleteObject(s3, bucket, determineSnapshotS3Key(accountId, volumeId, determineSnapshotBackupFilename(name)));
-                    }
-
-                    return null;
-
-                }
-
-            });
-
-            return result;
-
-        } catch (Exception e) {
-
-            s_logger.error(String.format("Failed to delete snapshot backup for account id %1$s volume id %2$sfrom S3.", accountId, volumeId), e);
-            return e.getMessage();
-
-        }
-
-    }
-
-    private String determineSnapshotBackupFilename(final String snapshotUuid) {
-        return snapshotUuid + ".vhd";
-    }
-
-    private String determineSnapshotLockId(final Long accountId, final Long volumeId) {
-        return join("_", "SNAPSHOT", accountId, volumeId);
-    }
-
     protected Answer deleteSnapshot(final DeleteCommand cmd) {
         DataTO obj = cmd.getData();
         DataStoreTO dstore = obj.getDataStore();
@@ -1381,7 +1298,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
                 return new Answer(cmd, true, String.format("Deleted snapshot %1%s from bucket %2$s.", path, bucket));
             } catch (Exception e) {
                 final String errorMessage =
-                    String.format("Failed to delete snapshot %1$s from bucket %2$s due to the following error: %3$s", path, bucket, e.getMessage());
+                        String.format("Failed to delete snapshot %1$s from bucket %2$s due to the following error: %3$s", path, bucket, e.getMessage());
                 s_logger.error(errorMessage, e);
                 return new Answer(cmd, false, errorMessage);
             }
@@ -1523,7 +1440,6 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
         }
         DataStoreTO store = cmd.getDataStore();
         if (store instanceof NfsTO) {
-            NfsTO nfs = (NfsTO)store;
             String root = getRootDir(cmd.getSecUrl());
             Map<Long, TemplateProp> templateInfos = _dlMgr.gatherVolumeInfo(root);
             return new ListVolumeAnswer(cmd.getSecUrl(), templateInfos);
@@ -1571,45 +1487,6 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
 
     }
 
-    private String setVhdParent(String lFullPath, String pFullPath) {
-        Script command = new Script("/bin/bash", s_logger);
-        command.add("-c");
-        command.add("/bin/vhd-util modify -n " + lFullPath + " -p " + pFullPath);
-        String result = command.execute();
-        if (result != null) {
-            String errMsg = "failed to set vhd parent, child " + lFullPath + " parent " + pFullPath + ", err=" + result;
-            s_logger.warn(errMsg);
-            return errMsg;
-        }
-        return null;
-    }
-
-    private String createLocalDir(String folder) {
-        Script command = new Script("/bin/bash", s_logger);
-        command.add("-c");
-        command.add("mkdir -p " + folder);
-        String result = command.execute();
-        if (result != null) {
-            String errMsg = "Create local path " + folder + " failed , err=" + result;
-            s_logger.warn(errMsg);
-            return errMsg;
-        }
-        return null;
-    }
-
-    private String deleteLocalDir(String folder) {
-        Script command = new Script("/bin/bash", s_logger);
-        command.add("-c");
-        command.add("rmdir " + folder);
-        String result = command.execute();
-        if (result != null) {
-            String errMsg = "Delete local path " + folder + " failed , err=" + result;
-            s_logger.warn(errMsg);
-            return errMsg;
-        }
-        return null;
-    }
-
     private String deleteLocalFile(String fullPath) {
         Script command = new Script("/bin/bash", s_logger);
         command.add("-c");
@@ -1690,12 +1567,12 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
             return new Answer(cmd, true, "Object with null install path does not exist on image store , no need to delete");
         }
         switch (objType) {
-            case TEMPLATE:
-                return deleteTemplate(cmd);
-            case VOLUME:
-                return deleteVolume(cmd);
-            case SNAPSHOT:
-                return deleteSnapshot(cmd);
+        case TEMPLATE:
+            return deleteTemplate(cmd);
+        case VOLUME:
+            return deleteVolume(cmd);
+        case SNAPSHOT:
+            return deleteSnapshot(cmd);
         }
         return Answer.createUnsupportedCommandAnswer(cmd);
     }
@@ -1777,7 +1654,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
                 return new Answer(cmd, true, String.format("Deleted template %1$s from bucket %2$s.", path, bucket));
             } catch (Exception e) {
                 final String errorMessage =
-                    String.format("Failed to delete template %1$s from bucket %2$s due to the following error: %3$s", path, bucket, e.getMessage());
+                        String.format("Failed to delete template %1$s from bucket %2$s due to the following error: %3$s", path, bucket, e.getMessage());
                 s_logger.error(errorMessage, e);
                 return new Answer(cmd, false, errorMessage);
             }
@@ -2361,7 +2238,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
         List<NameValuePair> args = URLEncodedUtils.parse(uri, "UTF-8");
         boolean foundUser = false;
         boolean foundPswd = false;
-        String extraOpts = "";
+        StringBuilder extraOpts = new StringBuilder();
         for (NameValuePair nvp : args) {
             String name = nvp.getName();
             if (name.equals("user")) {
@@ -2369,10 +2246,10 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
                 s_logger.debug("foundUser is" + foundUser);
             } else if (name.equals("password")) {
                 foundPswd = true;
-                s_logger.debug("foundPswd is" + foundPswd);
+                s_logger.debug("password is present in uri");
             }
 
-            extraOpts = extraOpts + name + "=" + nvp.getValue() + ",";
+            extraOpts.append(name + "=" + nvp.getValue() + ",");
         }
 
         if (s_logger.isDebugEnabled()) {
@@ -2381,12 +2258,12 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
 
         if (!foundUser || !foundPswd) {
             String errMsg =
-                "Missing user and password from URI. Make sure they" + "are in the query string and separated by '&'.  E.g. "
-                    + "cifs://example.com/some_share?user=foo&password=bar";
+                    "Missing user and password from URI. Make sure they" + "are in the query string and separated by '&'.  E.g. "
+                            + "cifs://example.com/some_share?user=foo&password=bar";
             s_logger.error(errMsg);
             throw new CloudRuntimeException(errMsg);
         }
-        return extraOpts;
+        return extraOpts.toString();
     }
 
     protected boolean mountExists(String localRootPath, URI uri) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8f10dedc/services/secondary-storage/src/org/apache/cloudstack/storage/resource/SecondaryStorageDiscoverer.java
----------------------------------------------------------------------
diff --git a/services/secondary-storage/src/org/apache/cloudstack/storage/resource/SecondaryStorageDiscoverer.java b/services/secondary-storage/src/org/apache/cloudstack/storage/resource/SecondaryStorageDiscoverer.java
index fef034d..ee50647 100755
--- a/services/secondary-storage/src/org/apache/cloudstack/storage/resource/SecondaryStorageDiscoverer.java
+++ b/services/secondary-storage/src/org/apache/cloudstack/storage/resource/SecondaryStorageDiscoverer.java
@@ -32,12 +32,9 @@ import javax.naming.ConfigurationException;
 
 import org.apache.log4j.Logger;
 
-import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
-
 import com.cloud.agent.AgentManager;
 import com.cloud.host.HostVO;
 import com.cloud.host.Status.Event;
-import com.cloud.host.dao.HostDao;
 import com.cloud.hypervisor.Hypervisor;
 import com.cloud.resource.Discoverer;
 import com.cloud.resource.DiscovererBase;
@@ -66,16 +63,12 @@ public class SecondaryStorageDiscoverer extends DiscovererBase implements Discov
 
     Random _random = new Random(System.currentTimeMillis());
     @Inject
-    protected HostDao _hostDao = null;
-    @Inject
     protected VMTemplateDao _tmpltDao = null;
     @Inject
     protected VMTemplateZoneDao _vmTemplateZoneDao = null;
     @Inject
     protected VMTemplateDao _vmTemplateDao = null;
     @Inject
-    protected ConfigurationDao _configDao = null;
-    @Inject
     protected AgentManager _agentMgr = null;
 
     protected SecondaryStorageDiscoverer() {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8f10dedc/services/secondary-storage/src/org/apache/cloudstack/storage/template/DownloadManagerImpl.java
----------------------------------------------------------------------
diff --git a/services/secondary-storage/src/org/apache/cloudstack/storage/template/DownloadManagerImpl.java b/services/secondary-storage/src/org/apache/cloudstack/storage/template/DownloadManagerImpl.java
index 84daf27..d45a6bb 100755
--- a/services/secondary-storage/src/org/apache/cloudstack/storage/template/DownloadManagerImpl.java
+++ b/services/secondary-storage/src/org/apache/cloudstack/storage/template/DownloadManagerImpl.java
@@ -62,6 +62,7 @@ import com.cloud.storage.VMTemplateStorageResourceAssoc;
 import com.cloud.storage.template.HttpTemplateDownloader;
 import com.cloud.storage.template.IsoProcessor;
 import com.cloud.storage.template.LocalTemplateDownloader;
+import com.cloud.storage.template.OVAProcessor;
 import com.cloud.storage.template.Processor;
 import com.cloud.storage.template.Processor.FormatInfo;
 import com.cloud.storage.template.QCOW2Processor;
@@ -75,7 +76,6 @@ import com.cloud.storage.template.TemplateDownloader.Status;
 import com.cloud.storage.template.TemplateLocation;
 import com.cloud.storage.template.TemplateProp;
 import com.cloud.storage.template.VhdProcessor;
-import com.cloud.storage.template.OVAProcessor;
 import com.cloud.storage.template.VmdkProcessor;
 import com.cloud.utils.NumbersUtil;
 import com.cloud.utils.component.ManagerBase;
@@ -104,14 +104,12 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager
 
     private static class DownloadJob {
         private final TemplateDownloader td;
-        private final String jobId;
         private final String tmpltName;
         private final boolean hvm;
         private final ImageFormat format;
         private String tmpltPath;
         private final String description;
         private String checksum;
-        private final Long accountId;
         private final String installPathPrefix;
         private long templatesize;
         private long templatePhysicalSize;
@@ -122,11 +120,9 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager
                 String installPathPrefix, ResourceType resourceType) {
             super();
             this.td = td;
-            this.jobId = jobId;
             this.tmpltName = tmpltName;
             this.format = format;
             this.hvm = hvm;
-            this.accountId = accountId;
             description = descr;
             checksum = cksum;
             this.installPathPrefix = installPathPrefix;
@@ -135,10 +131,6 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager
             this.resourceType = resourceType;
         }
 
-        public TemplateDownloader getTd() {
-            return td;
-        }
-
         public String getDescription() {
             return description;
         }
@@ -151,10 +143,6 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager
             return td;
         }
 
-        public String getJobId() {
-            return jobId;
-        }
-
         public String getTmpltName() {
             return tmpltName;
         }
@@ -167,10 +155,6 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager
             return hvm;
         }
 
-        public Long getAccountId() {
-            return accountId;
-        }
-
         public long getId() {
             return id;
         }
@@ -232,7 +216,6 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager
     private String _volumeDir;
     private String createTmpltScr;
     private String createVolScr;
-    private List<Processor> processors;
 
     private ExecutorService threadPool;
 
@@ -240,7 +223,6 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager
     private String listTmpltScr;
     private String listVolScr;
     private int installTimeoutPerGig = 180 * 60 * 1000;
-    private boolean _sslCopy;
 
     public void setThreadPool(ExecutorService threadPool) {
         this.threadPool = threadPool;
@@ -268,55 +250,55 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager
         TemplateDownloader td = dj.getTemplateDownloader();
         s_logger.info("Download Completion for jobId: " + jobId + ", status=" + status);
         s_logger.info("local: " + td.getDownloadLocalPath() + ", bytes=" + td.getDownloadedBytes() + ", error=" + td.getDownloadError() + ", pct=" +
-            td.getDownloadPercent());
+                td.getDownloadPercent());
 
         switch (status) {
-            case ABORTED:
-            case NOT_STARTED:
-            case UNRECOVERABLE_ERROR:
-                // TODO
-                dj.cleanup();
-                break;
-            case UNKNOWN:
-                return;
-            case IN_PROGRESS:
-                s_logger.info("Resuming jobId: " + jobId + ", status=" + status);
-                td.setResume(true);
-                threadPool.execute(td);
-                break;
-            case RECOVERABLE_ERROR:
-                threadPool.execute(td);
-                break;
-            case DOWNLOAD_FINISHED:
-                if (!(td instanceof S3TemplateDownloader)) {
-                    // we currently only create template.properties for NFS by
-                    // running some post download script
-                    td.setDownloadError("Download success, starting install ");
-                    String result = postDownload(jobId);
-                    if (result != null) {
-                        s_logger.error("Failed post download script: " + result);
-                        td.setStatus(Status.UNRECOVERABLE_ERROR);
-                        td.setDownloadError("Failed post download script: " + result);
-                    } else {
-                        td.setStatus(Status.POST_DOWNLOAD_FINISHED);
-                        td.setDownloadError("Install completed successfully at " + new SimpleDateFormat().format(new Date()));
-                    }
+        case ABORTED:
+        case NOT_STARTED:
+        case UNRECOVERABLE_ERROR:
+            // TODO
+            dj.cleanup();
+            break;
+        case UNKNOWN:
+            return;
+        case IN_PROGRESS:
+            s_logger.info("Resuming jobId: " + jobId + ", status=" + status);
+            td.setResume(true);
+            threadPool.execute(td);
+            break;
+        case RECOVERABLE_ERROR:
+            threadPool.execute(td);
+            break;
+        case DOWNLOAD_FINISHED:
+            if (!(td instanceof S3TemplateDownloader)) {
+                // we currently only create template.properties for NFS by
+                // running some post download script
+                td.setDownloadError("Download success, starting install ");
+                String result = postDownload(jobId);
+                if (result != null) {
+                    s_logger.error("Failed post download script: " + result);
+                    td.setStatus(Status.UNRECOVERABLE_ERROR);
+                    td.setDownloadError("Failed post download script: " + result);
                 } else {
-                    // for s3 and swift, we skip post download step and just set
-                    // status to trigger callback.
                     td.setStatus(Status.POST_DOWNLOAD_FINISHED);
-                    // set template size for S3
-                    S3TemplateDownloader std = (S3TemplateDownloader)td;
-                    long size = std.totalBytes;
-                    DownloadJob dnld = jobs.get(jobId);
-                    dnld.setTemplatesize(size);
-                    dnld.setTemplatePhysicalSize(size);
-                    dnld.setTmpltPath(std.getDownloadLocalPath()); // update template path to include file name.
+                    td.setDownloadError("Install completed successfully at " + new SimpleDateFormat().format(new Date()));
                 }
-                dj.cleanup();
-                break;
-            default:
-                break;
+            } else {
+                // for s3 and swift, we skip post download step and just set
+                // status to trigger callback.
+                td.setStatus(Status.POST_DOWNLOAD_FINISHED);
+                // set template size for S3
+                S3TemplateDownloader std = (S3TemplateDownloader)td;
+                long size = std.totalBytes;
+                DownloadJob dnld = jobs.get(jobId);
+                dnld.setTemplatesize(size);
+                dnld.setTemplatePhysicalSize(size);
+                dnld.setTmpltPath(std.getDownloadLocalPath()); // update template path to include file name.
+            }
+            dj.cleanup();
+            break;
+        default:
+            break;
         }
     }
 
@@ -360,28 +342,12 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager
         DownloadJob dnld = jobs.get(jobId);
         TemplateDownloader td = dnld.getTemplateDownloader();
         String resourcePath = dnld.getInstallPathPrefix(); // path with mount
-                                                           // directory
+        // directory
         String finalResourcePath = dnld.getTmpltPath(); // template download
-                                                        // path on secondary
-                                                        // storage
+        // path on secondary
+        // storage
         ResourceType resourceType = dnld.getResourceType();
 
-        /*
-        // once template path is set, remove the parent dir so that the template
-        // is installed with a relative path
-        String finalResourcePath = "";
-        if (resourceType == ResourceType.TEMPLATE) {
-            finalResourcePath += _templateDir + File.separator + dnld.getAccountId() + File.separator + dnld.getId() + File.separator;
-            resourcePath = dnld.getInstallPathPrefix() + dnld.getAccountId() + File.separator + dnld.getId() + File.separator;// dnld.getTmpltName();
-        } else {
-            finalResourcePath += _volumeDir + File.separator + dnld.getId() + File.separator;
-            resourcePath = dnld.getInstallPathPrefix() + dnld.getId() + File.separator;// dnld.getTmpltName();
-        }
-
-        _storage.mkdirs(resourcePath);
-        dnld.setTmpltPath(finalResourcePath);
-        */
-
         File originalTemplate = new File(td.getDownloadLocalPath());
         String checkSum = computeCheckSum(originalTemplate);
         if (checkSum == null) {
@@ -421,7 +387,7 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager
 
         scr.add("-t", resourcePath);
         scr.add("-f", td.getDownloadLocalPath()); // this is the temporary
-                                                  // template file downloaded
+        // template file downloaded
         if (dnld.getChecksum() != null && dnld.getChecksum().length() > 1) {
             scr.add("-c", dnld.getChecksum());
         }
@@ -497,7 +463,7 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager
 
     @Override
     public String downloadS3Template(S3TO s3, long id, String url, String name, ImageFormat format, boolean hvm, Long accountId, String descr, String cksum,
-        String installPathPrefix, String user, String password, long maxTemplateSizeInBytes, Proxy proxy, ResourceType resourceType) {
+            String installPathPrefix, String user, String password, long maxTemplateSizeInBytes, Proxy proxy, ResourceType resourceType) {
         UUID uuid = UUID.randomUUID();
         String jobId = uuid.toString();
 
@@ -527,7 +493,7 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager
 
     @Override
     public String downloadPublicTemplate(long id, String url, String name, ImageFormat format, boolean hvm, Long accountId, String descr, String cksum,
-        String installPathPrefix, String templatePath, String user, String password, long maxTemplateSizeInBytes, Proxy proxy, ResourceType resourceType) {
+            String installPathPrefix, String templatePath, String user, String password, long maxTemplateSizeInBytes, Proxy proxy, ResourceType resourceType) {
         UUID uuid = UUID.randomUUID();
         String jobId = uuid.toString();
         String tmpDir = installPathPrefix;
@@ -540,52 +506,52 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager
             }
             // TO DO - define constant for volume properties.
             File file =
-                ResourceType.TEMPLATE == resourceType ? _storage.getFile(tmpDir + File.separator + TemplateLocation.Filename) : _storage.getFile(tmpDir + File.separator +
-                    "volume.properties");
-            if (file.exists()) {
-                file.delete();
-            }
-
-            if (!file.createNewFile()) {
-                s_logger.warn("Unable to create new file: " + file.getAbsolutePath());
-                return "Unable to create new file: " + file.getAbsolutePath();
-            }
+                    ResourceType.TEMPLATE == resourceType ? _storage.getFile(tmpDir + File.separator + TemplateLocation.Filename) : _storage.getFile(tmpDir + File.separator +
+                            "volume.properties");
+                    if (file.exists()) {
+                        file.delete();
+                    }
 
-            URI uri;
-            try {
-                uri = new URI(url);
-            } catch (URISyntaxException e) {
-                throw new CloudRuntimeException("URI is incorrect: " + url);
-            }
-            TemplateDownloader td;
-            if ((uri != null) && (uri.getScheme() != null)) {
-                if (uri.getScheme().equalsIgnoreCase("http") || uri.getScheme().equalsIgnoreCase("https")) {
-                    td = new HttpTemplateDownloader(_storage, url, tmpDir, new Completion(jobId), maxTemplateSizeInBytes, user, password, proxy, resourceType);
-                } else if (uri.getScheme().equalsIgnoreCase("file")) {
-                    td = new LocalTemplateDownloader(_storage, url, tmpDir, maxTemplateSizeInBytes, new Completion(jobId));
-                } else if (uri.getScheme().equalsIgnoreCase("scp")) {
-                    td = new ScpTemplateDownloader(_storage, url, tmpDir, maxTemplateSizeInBytes, new Completion(jobId));
-                } else if (uri.getScheme().equalsIgnoreCase("nfs") || uri.getScheme().equalsIgnoreCase("cifs")) {
-                    td = null;
-                    // TODO: implement this.
-                    throw new CloudRuntimeException("Scheme is not supported " + url);
-                } else {
-                    throw new CloudRuntimeException("Scheme is not supported " + url);
-                }
-            } else {
-                throw new CloudRuntimeException("Unable to download from URL: " + url);
-            }
-            // NOTE the difference between installPathPrefix and templatePath
-            // here. instalPathPrefix is the absolute path for template
-            // including mount directory
-            // on ssvm, while templatePath is the final relative path on
-            // secondary storage.
-            DownloadJob dj = new DownloadJob(td, jobId, id, name, format, hvm, accountId, descr, cksum, installPathPrefix, resourceType);
-            dj.setTmpltPath(templatePath);
-            jobs.put(jobId, dj);
-            threadPool.execute(td);
+                    if (!file.createNewFile()) {
+                        s_logger.warn("Unable to create new file: " + file.getAbsolutePath());
+                        return "Unable to create new file: " + file.getAbsolutePath();
+                    }
 
-            return jobId;
+                    URI uri;
+                    try {
+                        uri = new URI(url);
+                    } catch (URISyntaxException e) {
+                        throw new CloudRuntimeException("URI is incorrect: " + url);
+                    }
+                    TemplateDownloader td;
+                    if ((uri != null) && (uri.getScheme() != null)) {
+                        if (uri.getScheme().equalsIgnoreCase("http") || uri.getScheme().equalsIgnoreCase("https")) {
+                            td = new HttpTemplateDownloader(_storage, url, tmpDir, new Completion(jobId), maxTemplateSizeInBytes, user, password, proxy, resourceType);
+                        } else if (uri.getScheme().equalsIgnoreCase("file")) {
+                            td = new LocalTemplateDownloader(_storage, url, tmpDir, maxTemplateSizeInBytes, new Completion(jobId));
+                        } else if (uri.getScheme().equalsIgnoreCase("scp")) {
+                            td = new ScpTemplateDownloader(_storage, url, tmpDir, maxTemplateSizeInBytes, new Completion(jobId));
+                        } else if (uri.getScheme().equalsIgnoreCase("nfs") || uri.getScheme().equalsIgnoreCase("cifs")) {
+                            td = null;
+                            // TODO: implement this.
+                            throw new CloudRuntimeException("Scheme is not supported " + url);
+                        } else {
+                            throw new CloudRuntimeException("Scheme is not supported " + url);
+                        }
+                    } else {
+                        throw new CloudRuntimeException("Unable to download from URL: " + url);
+                    }
+                    // NOTE the difference between installPathPrefix and templatePath
+                    // here. instalPathPrefix is the absolute path for template
+                    // including mount directory
+                    // on ssvm, while templatePath is the final relative path on
+                    // secondary storage.
+                    DownloadJob dj = new DownloadJob(td, jobId, id, name, format, hvm, accountId, descr, cksum, installPathPrefix, resourceType);
+                    dj.setTmpltPath(templatePath);
+                    jobs.put(jobId, dj);
+                    threadPool.execute(td);
+
+                    return jobId;
         } catch (IOException e) {
             s_logger.warn("Unable to download to " + tmpDir, e);
             return null;
@@ -645,24 +611,24 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager
 
     public static VMTemplateHostVO.Status convertStatus(Status tds) {
         switch (tds) {
-            case ABORTED:
-                return VMTemplateHostVO.Status.NOT_DOWNLOADED;
-            case DOWNLOAD_FINISHED:
-                return VMTemplateHostVO.Status.DOWNLOAD_IN_PROGRESS;
-            case IN_PROGRESS:
-                return VMTemplateHostVO.Status.DOWNLOAD_IN_PROGRESS;
-            case NOT_STARTED:
-                return VMTemplateHostVO.Status.NOT_DOWNLOADED;
-            case RECOVERABLE_ERROR:
-                return VMTemplateHostVO.Status.NOT_DOWNLOADED;
-            case UNKNOWN:
-                return VMTemplateHostVO.Status.UNKNOWN;
-            case UNRECOVERABLE_ERROR:
-                return VMTemplateHostVO.Status.DOWNLOAD_ERROR;
-            case POST_DOWNLOAD_FINISHED:
-                return VMTemplateHostVO.Status.DOWNLOADED;
-            default:
-                return VMTemplateHostVO.Status.UNKNOWN;
+        case ABORTED:
+            return VMTemplateHostVO.Status.NOT_DOWNLOADED;
+        case DOWNLOAD_FINISHED:
+            return VMTemplateHostVO.Status.DOWNLOAD_IN_PROGRESS;
+        case IN_PROGRESS:
+            return VMTemplateHostVO.Status.DOWNLOAD_IN_PROGRESS;
+        case NOT_STARTED:
+            return VMTemplateHostVO.Status.NOT_DOWNLOADED;
+        case RECOVERABLE_ERROR:
+            return VMTemplateHostVO.Status.NOT_DOWNLOADED;
+        case UNKNOWN:
+            return VMTemplateHostVO.Status.UNKNOWN;
+        case UNRECOVERABLE_ERROR:
+            return VMTemplateHostVO.Status.DOWNLOAD_ERROR;
+        case POST_DOWNLOAD_FINISHED:
+            return VMTemplateHostVO.Status.DOWNLOADED;
+        default:
+            return VMTemplateHostVO.Status.UNKNOWN;
         }
     }
 
@@ -680,7 +646,7 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager
 
         if (cmd.getUrl() == null) {
             return new DownloadAnswer(resourceType.toString() + " is corrupted on storage due to an invalid url , cannot download",
-                VMTemplateStorageResourceAssoc.Status.DOWNLOAD_ERROR);
+                    VMTemplateStorageResourceAssoc.Status.DOWNLOAD_ERROR);
         }
 
         if (cmd.getName() == null) {
@@ -697,27 +663,27 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager
         String password = null;
         if (cmd.getAuth() != null) {
             user = cmd.getAuth().getUserName();
-            password = new String(cmd.getAuth().getPassword());
+            password = cmd.getAuth().getPassword();
         }
         // TO DO - Define Volume max size as well
         long maxDownloadSizeInBytes =
-            (cmd.getMaxDownloadSizeInBytes() == null) ? TemplateDownloader.DEFAULT_MAX_TEMPLATE_SIZE_IN_BYTES : (cmd.getMaxDownloadSizeInBytes());
+                (cmd.getMaxDownloadSizeInBytes() == null) ? TemplateDownloader.DEFAULT_MAX_TEMPLATE_SIZE_IN_BYTES : (cmd.getMaxDownloadSizeInBytes());
         String jobId = null;
         if (dstore instanceof S3TO) {
             jobId =
-                downloadS3Template((S3TO)dstore, cmd.getId(), cmd.getUrl(), cmd.getName(), cmd.getFormat(), cmd.isHvm(), cmd.getAccountId(), cmd.getDescription(),
-                    cmd.getChecksum(), installPathPrefix, user, password, maxDownloadSizeInBytes, cmd.getProxy(), resourceType);
+                    downloadS3Template((S3TO)dstore, cmd.getId(), cmd.getUrl(), cmd.getName(), cmd.getFormat(), cmd.isHvm(), cmd.getAccountId(), cmd.getDescription(),
+                            cmd.getChecksum(), installPathPrefix, user, password, maxDownloadSizeInBytes, cmd.getProxy(), resourceType);
         } else {
             jobId =
-                downloadPublicTemplate(cmd.getId(), cmd.getUrl(), cmd.getName(), cmd.getFormat(), cmd.isHvm(), cmd.getAccountId(), cmd.getDescription(),
-                    cmd.getChecksum(), installPathPrefix, cmd.getInstallPath(), user, password, maxDownloadSizeInBytes, cmd.getProxy(), resourceType);
+                    downloadPublicTemplate(cmd.getId(), cmd.getUrl(), cmd.getName(), cmd.getFormat(), cmd.isHvm(), cmd.getAccountId(), cmd.getDescription(),
+                            cmd.getChecksum(), installPathPrefix, cmd.getInstallPath(), user, password, maxDownloadSizeInBytes, cmd.getProxy(), resourceType);
         }
         sleep();
         if (jobId == null) {
             return new DownloadAnswer("Internal Error", VMTemplateStorageResourceAssoc.Status.DOWNLOAD_ERROR);
         }
         return new DownloadAnswer(jobId, getDownloadPct(jobId), getDownloadError(jobId), getDownloadStatus2(jobId), getDownloadLocalPath(jobId), getInstallPath(jobId),
-            getDownloadTemplateSize(jobId), getDownloadTemplateSize(jobId), getDownloadCheckSum(jobId));
+                getDownloadTemplateSize(jobId), getDownloadTemplateSize(jobId), getDownloadCheckSum(jobId));
     }
 
     private void sleep() {
@@ -745,29 +711,29 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager
         }
         TemplateDownloader td = dj.getTemplateDownloader();
         switch (cmd.getRequest()) {
-            case GET_STATUS:
-                break;
-            case ABORT:
-                td.stopDownload();
-                sleep();
-                break;
-            case RESTART:
-                td.stopDownload();
-                sleep();
-                threadPool.execute(td);
-                break;
-            case PURGE:
-                td.stopDownload();
-                answer =
+        case GET_STATUS:
+            break;
+        case ABORT:
+            td.stopDownload();
+            sleep();
+            break;
+        case RESTART:
+            td.stopDownload();
+            sleep();
+            threadPool.execute(td);
+            break;
+        case PURGE:
+            td.stopDownload();
+            answer =
                     new DownloadAnswer(jobId, getDownloadPct(jobId), getDownloadError(jobId), getDownloadStatus2(jobId), getDownloadLocalPath(jobId),
-                        getInstallPath(jobId), getDownloadTemplateSize(jobId), getDownloadTemplatePhysicalSize(jobId), getDownloadCheckSum(jobId));
-                jobs.remove(jobId);
-                return answer;
-            default:
-                break; // TODO
+                            getInstallPath(jobId), getDownloadTemplateSize(jobId), getDownloadTemplatePhysicalSize(jobId), getDownloadCheckSum(jobId));
+            jobs.remove(jobId);
+            return answer;
+        default:
+            break; // TODO
         }
         return new DownloadAnswer(jobId, getDownloadPct(jobId), getDownloadError(jobId), getDownloadStatus2(jobId), getDownloadLocalPath(jobId), getInstallPath(jobId),
-            getDownloadTemplateSize(jobId), getDownloadTemplatePhysicalSize(jobId), getDownloadCheckSum(jobId));
+                getDownloadTemplateSize(jobId), getDownloadTemplatePhysicalSize(jobId), getDownloadCheckSum(jobId));
     }
 
     private String getInstallPath(String jobId) {
@@ -778,16 +744,6 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager
         return null;
     }
 
-    private String createTempDir(File rootDir, String name) throws IOException {
-
-        File f = File.createTempFile(name, "", rootDir);
-        f.delete();
-        f.mkdir();
-        _storage.setWorldReadableAndWriteable(f);
-        return f.getAbsolutePath();
-
-    }
-
     private List<String> listVolumes(String rootdir) {
         List<String> result = new ArrayList<String>();
 
@@ -915,27 +871,6 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager
         return result;
     }
 
-    private int deleteDownloadDirectories(File downloadPath, int deleted) {
-        try {
-            if (downloadPath.exists()) {
-                File[] files = downloadPath.listFiles();
-                for (int i = 0; i < files.length; i++) {
-                    if (files[i].isDirectory()) {
-                        deleteDownloadDirectories(files[i], deleted);
-                        files[i].delete();
-                        deleted++;
-                    } else {
-                        files[i].delete();
-                        deleted++;
-                    }
-                }
-            }
-        } catch (Exception ex) {
-            s_logger.info("Failed to clean up template downloads directory " + ex.toString());
-        }
-        return deleted;
-    }
-
     public static class ZfsPathParser extends OutputInterpreter {
         String _parent;
         List<String> paths = new ArrayList<String>();
@@ -992,11 +927,7 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager
                 throw new ConfigurationException("Unable to instantiate " + value);
             }
         }
-        String useSsl = (String)params.get("sslcopy");
-        if (useSsl != null) {
-            _sslCopy = Boolean.parseBoolean(useSsl);
 
-        }
         String inSystemVM = (String)params.get("secondary.storage.vm");
         if (inSystemVM != null && "true".equalsIgnoreCase(inSystemVM)) {
             s_logger.info("DownloadManager: starting additional services since we are inside system vm");
@@ -1081,7 +1012,7 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager
         String intf = "eth1";
         command.add("-c");
         command.add("iptables -A OUTPUT -o " + intf + " -p tcp -m state --state NEW -m tcp --dport " + "80" + " -j REJECT;" + "iptables -A OUTPUT -o " + intf +
-            " -p tcp -m state --state NEW -m tcp --dport " + "443" + " -j REJECT;");
+                " -p tcp -m state --state NEW -m tcp --dport " + "443" + " -j REJECT;");
 
         String result = command.execute();
         if (result != null) {
@@ -1120,7 +1051,7 @@ public class DownloadManagerImpl extends ManagerBase implements DownloadManager
         command = new Script("/bin/bash", s_logger);
         command.add("-c");
         command.add("iptables -I INPUT -i " + intf + " -p tcp -m state --state NEW -m tcp --dport " + port + " -j ACCEPT;" + "iptables -I INPUT -i " + intf +
-            " -p tcp -m state --state NEW -m tcp --dport " + "443" + " -j ACCEPT;");
+                " -p tcp -m state --state NEW -m tcp --dport " + "443" + " -j ACCEPT;");
 
         result = command.execute();
         if (result != null) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8f10dedc/services/secondary-storage/src/org/apache/cloudstack/storage/template/UploadManagerImpl.java
----------------------------------------------------------------------
diff --git a/services/secondary-storage/src/org/apache/cloudstack/storage/template/UploadManagerImpl.java b/services/secondary-storage/src/org/apache/cloudstack/storage/template/UploadManagerImpl.java
index dc0ef06..cdbc52d 100755
--- a/services/secondary-storage/src/org/apache/cloudstack/storage/template/UploadManagerImpl.java
+++ b/services/secondary-storage/src/org/apache/cloudstack/storage/template/UploadManagerImpl.java
@@ -21,7 +21,6 @@ import java.net.URI;
 import java.net.URISyntaxException;
 import java.text.SimpleDateFormat;
 import java.util.Date;
-import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 import java.util.concurrent.ConcurrentHashMap;
@@ -46,7 +45,6 @@ import com.cloud.storage.StorageLayer;
 import com.cloud.storage.Upload;
 import com.cloud.storage.UploadVO;
 import com.cloud.storage.template.FtpTemplateUploader;
-import com.cloud.storage.template.Processor;
 import com.cloud.storage.template.TemplateUploader;
 import com.cloud.storage.template.TemplateUploader.Status;
 import com.cloud.storage.template.TemplateUploader.UploadCompleteCallback;
@@ -72,87 +70,17 @@ public class UploadManagerImpl extends ManagerBase implements UploadManager {
 
     private static class UploadJob {
         private final TemplateUploader tu;
-        private final String jobId;
-        private final String name;
-        private final ImageFormat format;
-        private String tmpltPath;
-        private String description;
-        private String checksum;
-        private Long accountId;
-        private String installPathPrefix;
-        private long templatesize;
-        private long id;
 
         public UploadJob(TemplateUploader tu, String jobId, long id, String name, ImageFormat format, boolean hvm, Long accountId, String descr, String cksum,
                 String installPathPrefix) {
             super();
             this.tu = tu;
-            this.jobId = jobId;
-            this.name = name;
-            this.format = format;
-            this.accountId = accountId;
-            this.description = descr;
-            this.checksum = cksum;
-            this.installPathPrefix = installPathPrefix;
-            this.templatesize = 0;
-            this.id = id;
-        }
-
-        public TemplateUploader getTd() {
-            return tu;
-        }
-
-        public String getDescription() {
-            return description;
-        }
-
-        public String getChecksum() {
-            return checksum;
-        }
-
-        public UploadJob(TemplateUploader td, String jobId, UploadCommand cmd) {
-            this.tu = td;
-            this.jobId = jobId;
-            this.name = cmd.getName();
-            this.format = cmd.getFormat();
         }
 
         public TemplateUploader getTemplateUploader() {
             return tu;
         }
 
-        public String getJobId() {
-            return jobId;
-        }
-
-        public String getTmpltName() {
-            return name;
-        }
-
-        public ImageFormat getFormat() {
-            return format;
-        }
-
-        public Long getAccountId() {
-            return accountId;
-        }
-
-        public long getId() {
-            return id;
-        }
-
-        public void setTmpltPath(String tmpltPath) {
-            this.tmpltPath = tmpltPath;
-        }
-
-        public String getTmpltPath() {
-            return tmpltPath;
-        }
-
-        public String getInstallPathPrefix() {
-            return installPathPrefix;
-        }
-
         public void cleanup() {
             if (tu != null) {
                 String upldPath = tu.getUploadLocalPath();
@@ -163,30 +91,19 @@ public class UploadManagerImpl extends ManagerBase implements UploadManager {
             }
         }
 
-        public void setTemplatesize(long templatesize) {
-            this.templatesize = templatesize;
-        }
-
-        public long getTemplatesize() {
-            return templatesize;
-        }
     }
 
     public static final Logger s_logger = Logger.getLogger(UploadManagerImpl.class);
     private ExecutorService threadPool;
     private final Map<String, UploadJob> jobs = new ConcurrentHashMap<String, UploadJob>();
     private String parentDir;
-    private List<Processor> _processors;
-    private String publicTemplateRepo;
     private final String extractMountPoint = "/mnt/SecStorage/extractmnt";
     private StorageLayer _storage;
-    private int installTimeoutPerGig;
-    private boolean _sslCopy;
     private boolean hvm;
 
     @Override
     public String uploadPublicTemplate(long id, String url, String name, ImageFormat format, Long accountId, String descr, String cksum, String installPathPrefix,
-        String userName, String passwd, long templateSizeInBytes) {
+            String userName, String passwd, long templateSizeInBytes) {
 
         UUID uuid = UUID.randomUUID();
         String jobId = uuid.toString();
@@ -253,24 +170,24 @@ public class UploadManagerImpl extends ManagerBase implements UploadManager {
 
     public static UploadVO.Status convertStatus(Status tds) {
         switch (tds) {
-            case ABORTED:
-                return UploadVO.Status.NOT_UPLOADED;
-            case UPLOAD_FINISHED:
-                return UploadVO.Status.UPLOAD_IN_PROGRESS;
-            case IN_PROGRESS:
-                return UploadVO.Status.UPLOAD_IN_PROGRESS;
-            case NOT_STARTED:
-                return UploadVO.Status.NOT_UPLOADED;
-            case RECOVERABLE_ERROR:
-                return UploadVO.Status.NOT_UPLOADED;
-            case UNKNOWN:
-                return UploadVO.Status.UNKNOWN;
-            case UNRECOVERABLE_ERROR:
-                return UploadVO.Status.UPLOAD_ERROR;
-            case POST_UPLOAD_FINISHED:
-                return UploadVO.Status.UPLOADED;
-            default:
-                return UploadVO.Status.UNKNOWN;
+        case ABORTED:
+            return UploadVO.Status.NOT_UPLOADED;
+        case UPLOAD_FINISHED:
+            return UploadVO.Status.UPLOAD_IN_PROGRESS;
+        case IN_PROGRESS:
+            return UploadVO.Status.UPLOAD_IN_PROGRESS;
+        case NOT_STARTED:
+            return UploadVO.Status.NOT_UPLOADED;
+        case RECOVERABLE_ERROR:
+            return UploadVO.Status.NOT_UPLOADED;
+        case UNKNOWN:
+            return UploadVO.Status.UNKNOWN;
+        case UNRECOVERABLE_ERROR:
+            return UploadVO.Status.UPLOAD_ERROR;
+        case POST_UPLOAD_FINISHED:
+            return UploadVO.Status.UPLOADED;
+        default:
+            return UploadVO.Status.UNKNOWN;
         }
     }
 
@@ -296,29 +213,29 @@ public class UploadManagerImpl extends ManagerBase implements UploadManager {
         }
         TemplateUploader td = uj.getTemplateUploader();
         switch (cmd.getRequest()) {
-            case GET_STATUS:
-                break;
-            case ABORT:
-                td.stopUpload();
-                sleep();
-                break;
+        case GET_STATUS:
+            break;
+        case ABORT:
+            td.stopUpload();
+            sleep();
+            break;
             /*case RESTART:
             td.stopUpload();
             sleep();
             threadPool.execute(td);
             break;*/
-            case PURGE:
-                td.stopUpload();
-                answer =
+        case PURGE:
+            td.stopUpload();
+            answer =
                     new UploadAnswer(jobId, getUploadPct(jobId), getUploadError(jobId), getUploadStatus2(jobId), getUploadLocalPath(jobId), getInstallPath(jobId),
-                        getUploadTemplateSize(jobId));
-                jobs.remove(jobId);
-                return answer;
-            default:
-                break; // TODO
+                            getUploadTemplateSize(jobId));
+            jobs.remove(jobId);
+            return answer;
+        default:
+            break; // TODO
         }
         return new UploadAnswer(jobId, getUploadPct(jobId), getUploadError(jobId), getUploadStatus2(jobId), getUploadLocalPath(jobId), getInstallPath(jobId),
-            getUploadTemplateSize(jobId));
+                getUploadTemplateSize(jobId));
     }
 
     @Override
@@ -331,14 +248,11 @@ public class UploadManagerImpl extends ManagerBase implements UploadManager {
         String user = null;
         String password = null;
         String jobId =
-            uploadPublicTemplate(cmd.getId(), cmd.getUrl(), cmd.getName(), cmd.getFormat(), cmd.getAccountId(), cmd.getDescription(), cmd.getChecksum(),
-                cmd.getInstallPath(), user, password, cmd.getTemplateSizeInBytes());
+                uploadPublicTemplate(cmd.getId(), cmd.getUrl(), cmd.getName(), cmd.getFormat(), cmd.getAccountId(), cmd.getDescription(), cmd.getChecksum(),
+                        cmd.getInstallPath(), user, password, cmd.getTemplateSizeInBytes());
         sleep();
-        if (jobId == null) {
-            return new UploadAnswer(null, 0, "Internal Error", com.cloud.storage.UploadVO.Status.UPLOAD_ERROR, "", "", 0);
-        }
         return new UploadAnswer(jobId, getUploadPct(jobId), getUploadError(jobId), getUploadStatus2(jobId), getUploadLocalPath(jobId), getInstallPath(jobId),
-            getUploadTemplateSize(jobId));
+                getUploadTemplateSize(jobId));
     }
 
     @Override
@@ -435,13 +349,10 @@ public class UploadManagerImpl extends ManagerBase implements UploadManager {
     }
 
     private long getUploadTemplateSize(String jobId) {
-        UploadJob uj = jobs.get(jobId);
-        if (uj != null) {
-            return uj.getTemplatesize();
-        }
         return 0;
     }
 
+    @SuppressWarnings("unchecked")
     @Override
     public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
 
@@ -466,11 +377,7 @@ public class UploadManagerImpl extends ManagerBase implements UploadManager {
                 throw new ConfigurationException("Unable to instantiate " + value);
             }
         }
-        String useSsl = (String)params.get("sslcopy");
-        if (useSsl != null) {
-            _sslCopy = Boolean.parseBoolean(useSsl);
 
-        }
         String inSystemVM = (String)params.get("secondary.storage.vm");
         if (inSystemVM != null && "true".equalsIgnoreCase(inSystemVM)) {
             s_logger.info("UploadManager: starting additional services since we are inside system vm");
@@ -478,9 +385,6 @@ public class UploadManagerImpl extends ManagerBase implements UploadManager {
             //blockOutgoingOnPrivate();
         }
 
-        value = (String)params.get("install.timeout.pergig");
-        this.installTimeoutPerGig = NumbersUtil.parseInt(value, 15 * 60) * 1000;
-
         value = (String)params.get("install.numthreads");
         final int numInstallThreads = NumbersUtil.parseInt(value, 10);
 
@@ -544,43 +448,43 @@ public class UploadManagerImpl extends ManagerBase implements UploadManager {
         s_logger.warn("UploadedBytes=" + tu.getUploadedBytes() + ", error=" + tu.getUploadError() + ", pct=" + tu.getUploadPercent());
 
         switch (status) {
-            case ABORTED:
-            case NOT_STARTED:
-            case UNRECOVERABLE_ERROR:
-                // Delete the entity only if its a volume. TO DO - find a better way of finding it a volume.
-                if (uj.getTemplateUploader().getUploadLocalPath().indexOf("volume") > -1) {
-                    uj.cleanup();
-                }
-                break;
-            case UNKNOWN:
-                return;
-            case IN_PROGRESS:
-                s_logger.info("Resuming jobId: " + jobId + ", status=" + status);
-                tu.setResume(true);
-                threadPool.execute(tu);
-                break;
-            case RECOVERABLE_ERROR:
-                threadPool.execute(tu);
-                break;
-            case UPLOAD_FINISHED:
-                tu.setUploadError("Upload success, starting install ");
-                String result = postUpload(jobId);
-                if (result != null) {
-                    s_logger.error("Failed post upload script: " + result);
-                    tu.setStatus(Status.UNRECOVERABLE_ERROR);
-                    tu.setUploadError("Failed post upload script: " + result);
-                } else {
-                    s_logger.warn("Upload completed successfully at " + new SimpleDateFormat().format(new Date()));
-                    tu.setStatus(Status.POST_UPLOAD_FINISHED);
-                    tu.setUploadError("Upload completed successfully at " + new SimpleDateFormat().format(new Date()));
-                }
-                // Delete the entity only if its a volume. TO DO - find a better way of finding it a volume.
-                if (uj.getTemplateUploader().getUploadLocalPath().indexOf("volume") > -1) {
-                    uj.cleanup();
-                }
-                break;
-            default:
-                break;
+        case ABORTED:
+        case NOT_STARTED:
+        case UNRECOVERABLE_ERROR:
+            // Delete the entity only if its a volume. TO DO - find a better way of finding it a volume.
+            if (uj.getTemplateUploader().getUploadLocalPath().indexOf("volume") > -1) {
+                uj.cleanup();
+            }
+            break;
+        case UNKNOWN:
+            return;
+        case IN_PROGRESS:
+            s_logger.info("Resuming jobId: " + jobId + ", status=" + status);
+            tu.setResume(true);
+            threadPool.execute(tu);
+            break;
+        case RECOVERABLE_ERROR:
+            threadPool.execute(tu);
+            break;
+        case UPLOAD_FINISHED:
+            tu.setUploadError("Upload success, starting install ");
+            String result = postUpload(jobId);
+            if (result != null) {
+                s_logger.error("Failed post upload script: " + result);
+                tu.setStatus(Status.UNRECOVERABLE_ERROR);
+                tu.setUploadError("Failed post upload script: " + result);
+            } else {
+                s_logger.warn("Upload completed successfully at " + new SimpleDateFormat().format(new Date()));
+                tu.setStatus(Status.POST_UPLOAD_FINISHED);
+                tu.setUploadError("Upload completed successfully at " + new SimpleDateFormat().format(new Date()));
+            }
+            // Delete the entity only if its a volume. TO DO - find a better way of finding it a volume.
+            if (uj.getTemplateUploader().getUploadLocalPath().indexOf("volume") > -1) {
+                uj.cleanup();
+            }
+            break;
+        default:
+            break;
         }
     }
 


[3/4] git commit: updated refs/heads/master to d578d7e

Posted by hu...@apache.org.
updating the jre to version 7 on system vms

(cherry picked from commit fc2e7ec70a1cc48a10a168ec3df607b49a7bcdf6)
Signed-off-by: Hugo Trippaers <ht...@schubergphilis.com>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/06853711
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/06853711
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/06853711

Branch: refs/heads/master
Commit: 0685371179a22035351be1fa6151a39f16865ae6
Parents: 8f10ded
Author: Abhinandan Prateek <ap...@apache.org>
Authored: Fri Jan 17 16:11:28 2014 +0530
Committer: Hugo Trippaers <ht...@schubergphilis.com>
Committed: Fri Jan 31 09:41:41 2014 +0100

----------------------------------------------------------------------
 tools/appliance/definitions/systemvm64template/postinstall.sh | 2 +-
 tools/appliance/definitions/systemvmtemplate/postinstall.sh   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/06853711/tools/appliance/definitions/systemvm64template/postinstall.sh
----------------------------------------------------------------------
diff --git a/tools/appliance/definitions/systemvm64template/postinstall.sh b/tools/appliance/definitions/systemvm64template/postinstall.sh
index a9a057d..144187d 100644
--- a/tools/appliance/definitions/systemvm64template/postinstall.sh
+++ b/tools/appliance/definitions/systemvm64template/postinstall.sh
@@ -69,7 +69,7 @@ install_packages() {
   # ipcalc
   apt-get --no-install-recommends -q -y --force-yes install ipcalc
   # java
-  apt-get --no-install-recommends -q -y --force-yes install  default-jre-headless
+  apt-get --no-install-recommends -q -y --force-yes install  openjdk-7-jre-headless
 
   echo "iptables-persistent iptables-persistent/autosave_v4 boolean true" | debconf-set-selections
   echo "iptables-persistent iptables-persistent/autosave_v6 boolean true" | debconf-set-selections

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/06853711/tools/appliance/definitions/systemvmtemplate/postinstall.sh
----------------------------------------------------------------------
diff --git a/tools/appliance/definitions/systemvmtemplate/postinstall.sh b/tools/appliance/definitions/systemvmtemplate/postinstall.sh
index 48ba04b..a4ff11f 100644
--- a/tools/appliance/definitions/systemvmtemplate/postinstall.sh
+++ b/tools/appliance/definitions/systemvmtemplate/postinstall.sh
@@ -65,7 +65,7 @@ install_packages() {
   # ipcalc
   apt-get --no-install-recommends -q -y --force-yes install ipcalc
   # java
-  apt-get --no-install-recommends -q -y --force-yes install  default-jre-headless
+  apt-get --no-install-recommends -q -y --force-yes install  openjdk-7-jre-headless
 
   echo "iptables-persistent iptables-persistent/autosave_v4 boolean true" | debconf-set-selections
   echo "iptables-persistent iptables-persistent/autosave_v6 boolean true" | debconf-set-selections