cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edi...@apache.org
Subject [02/17] clean up storage related coded
Date Thu, 30 May 2013 01:06:22 GMT
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0a522892/plugins/storage/image/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackImageStoreDriverImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/image/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackImageStoreDriverImpl.java b/plugins/storage/image/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackImageStoreDriverImpl.java
index bc64250..52595a1 100644
--- a/plugins/storage/image/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackImageStoreDriverImpl.java
+++ b/plugins/storage/image/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackImageStoreDriverImpl.java
@@ -24,8 +24,6 @@ import java.util.Set;
 
 import javax.inject.Inject;
 
-import org.apache.log4j.Logger;
-
 import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
 import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
@@ -45,10 +43,10 @@ import org.apache.cloudstack.storage.image.ImageStoreDriver;
 import org.apache.cloudstack.storage.image.store.ImageStoreImpl;
 import org.apache.cloudstack.storage.image.store.TemplateObject;
 import org.apache.cloudstack.storage.snapshot.SnapshotObject;
+import org.apache.log4j.Logger;
 
 import com.cloud.agent.AgentManager;
 import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.DeleteSnapshotBackupCommand;
 import com.cloud.agent.api.DeleteSnapshotBackupCommand2;
 import com.cloud.agent.api.storage.DeleteTemplateCommand;
 import com.cloud.agent.api.storage.DeleteVolumeCommand;
@@ -57,8 +55,6 @@ import com.cloud.agent.api.to.DataObjectType;
 import com.cloud.agent.api.to.DataStoreTO;
 import com.cloud.agent.api.to.DataTO;
 import com.cloud.agent.api.to.NfsTO;
-import com.cloud.api.query.dao.UserVmJoinDao;
-import com.cloud.api.query.vo.UserVmJoinVO;
 import com.cloud.event.EventTypes;
 import com.cloud.event.UsageEventUtils;
 import com.cloud.host.dao.HostDao;
@@ -74,43 +70,42 @@ import com.cloud.storage.dao.VMTemplateDao;
 import com.cloud.storage.dao.VMTemplateZoneDao;
 import com.cloud.storage.dao.VolumeDao;
 import com.cloud.storage.download.DownloadMonitor;
-import com.cloud.storage.s3.S3Manager;
 import com.cloud.storage.secondary.SecondaryStorageVmManager;
 import com.cloud.storage.snapshot.SnapshotManager;
-import com.cloud.storage.swift.SwiftManager;
 import com.cloud.user.Account;
 import com.cloud.user.dao.AccountDao;
 import com.cloud.utils.exception.CloudRuntimeException;
-import com.cloud.vm.UserVmVO;
-import com.cloud.vm.dao.UserVmDao;
 
 public class CloudStackImageStoreDriverImpl implements ImageStoreDriver {
-    private static final Logger s_logger = Logger
-            .getLogger(CloudStackImageStoreDriverImpl.class);
+    private static final Logger s_logger = Logger.getLogger(CloudStackImageStoreDriverImpl.class);
     @Inject
     VMTemplateZoneDao templateZoneDao;
     @Inject
     VMTemplateDao templateDao;
-    @Inject DownloadMonitor _downloadMonitor;
-    @Inject VolumeDao volumeDao;
-    @Inject VolumeDataStoreDao _volumeStoreDao;
-    @Inject HostDao hostDao;
-    @Inject SnapshotDao snapshotDao;
-    @Inject AgentManager agentMgr;
-    @Inject SnapshotManager snapshotMgr;
-	@Inject
-    private SwiftManager _swiftMgr;
     @Inject
-    private S3Manager _s3Mgr;
-    @Inject AccountDao _accountDao;
+    DownloadMonitor _downloadMonitor;
+    @Inject
+    VolumeDao volumeDao;
+    @Inject
+    VolumeDataStoreDao _volumeStoreDao;
+    @Inject
+    HostDao hostDao;
+    @Inject
+    SnapshotDao snapshotDao;
+    @Inject
+    AgentManager agentMgr;
+    @Inject
+    SnapshotManager snapshotMgr;
+    @Inject
+    AccountDao _accountDao;
     @Inject
     SecondaryStorageVmManager _ssvmMgr;
     @Inject
-    private AgentManager _agentMgr;
-    @Inject TemplateDataStoreDao _templateStoreDao;
-    @Inject EndPointSelector _epSelector;
-    @Inject DataStoreManager _dataStoreMgr;
-
+    TemplateDataStoreDao _templateStoreDao;
+    @Inject
+    EndPointSelector _epSelector;
+    @Inject
+    DataStoreManager _dataStoreMgr;
 
     @Override
     public String grantAccess(DataObject data, EndPoint ep) {
@@ -123,10 +118,9 @@ public class CloudStackImageStoreDriverImpl implements ImageStoreDriver {
         return null;
     }
 
-
     @Override
     public DataStoreTO getStoreTO(DataStore store) {
-        ImageStoreImpl nfsStore = (ImageStoreImpl)store;
+        ImageStoreImpl nfsStore = (ImageStoreImpl) store;
         NfsTO nfsTO = new NfsTO();
         nfsTO.setRole(store.getRole());
         nfsTO.setUrl(nfsStore.getUri());
@@ -147,23 +141,21 @@ public class CloudStackImageStoreDriverImpl implements ImageStoreDriver {
 
     class CreateContext<T> extends AsyncRpcConext<T> {
         final DataObject data;
+
         public CreateContext(AsyncCompletionCallback<T> callback, DataObject data) {
             super(callback);
             this.data = data;
         }
     }
 
-
     @Override
-    public void createAsync(DataObject data,
-            AsyncCompletionCallback<CreateCmdResult> callback) {
-    	CreateContext<CreateCmdResult> context = new CreateContext<CreateCmdResult>(callback, data);
-        AsyncCallbackDispatcher<CloudStackImageStoreDriverImpl, DownloadAnswer> caller =
-        		AsyncCallbackDispatcher.create(this);
+    public void createAsync(DataObject data, AsyncCompletionCallback<CreateCmdResult> callback) {
+        CreateContext<CreateCmdResult> context = new CreateContext<CreateCmdResult>(callback, data);
+        AsyncCallbackDispatcher<CloudStackImageStoreDriverImpl, DownloadAnswer> caller = AsyncCallbackDispatcher
+                .create(this);
         caller.setContext(context);
         caller.setCallback(caller.getTarget().createAsyncCallback(null, null));
 
-
         if (data.getType() == DataObjectType.TEMPLATE) {
             _downloadMonitor.downloadTemplateToStorage(data, caller);
         } else if (data.getType() == DataObjectType.VOLUME) {
@@ -171,13 +163,14 @@ public class CloudStackImageStoreDriverImpl implements ImageStoreDriver {
         }
     }
 
-    protected Void createAsyncCallback(AsyncCallbackDispatcher<CloudStackImageStoreDriverImpl, DownloadAnswer> callback,
-    		CreateContext<CreateCmdResult> context) {
-    	DownloadAnswer answer = callback.getResult();
-    	DataObject obj = context.data;
-    	DataStore store = obj.getDataStore();
+    protected Void createAsyncCallback(
+            AsyncCallbackDispatcher<CloudStackImageStoreDriverImpl, DownloadAnswer> callback,
+            CreateContext<CreateCmdResult> context) {
+        DownloadAnswer answer = callback.getResult();
+        DataObject obj = context.data;
+        DataStore store = obj.getDataStore();
 
-    	TemplateDataStoreVO tmpltStoreVO = _templateStoreDao.findByStoreTemplate(store.getId(),obj.getId());
+        TemplateDataStoreVO tmpltStoreVO = _templateStoreDao.findByStoreTemplate(store.getId(), obj.getId());
         if (tmpltStoreVO != null) {
             TemplateDataStoreVO updateBuilder = _templateStoreDao.createForUpdate();
             updateBuilder.setDownloadPercent(answer.getDownloadPct());
@@ -196,27 +189,26 @@ public class CloudStackImageStoreDriverImpl implements ImageStoreDriver {
             templateDao.update(obj.getId(), tmlptUpdater);
         }
 
-    	AsyncCompletionCallback<CreateCmdResult> caller = context.getParentCallback();
+        AsyncCompletionCallback<CreateCmdResult> caller = context.getParentCallback();
 
-    	if (answer.getDownloadStatus() == VMTemplateStorageResourceAssoc.Status.DOWNLOAD_ERROR ||
-    			answer.getDownloadStatus() == VMTemplateStorageResourceAssoc.Status.ABANDONED ||
-    			answer.getDownloadStatus() == VMTemplateStorageResourceAssoc.Status.UNKNOWN) {
-    		CreateCmdResult result = new CreateCmdResult(null, null);
+        if (answer.getDownloadStatus() == VMTemplateStorageResourceAssoc.Status.DOWNLOAD_ERROR
+                || answer.getDownloadStatus() == VMTemplateStorageResourceAssoc.Status.ABANDONED
+                || answer.getDownloadStatus() == VMTemplateStorageResourceAssoc.Status.UNKNOWN) {
+            CreateCmdResult result = new CreateCmdResult(null, null);
             result.setSuccess(false);
-    		result.setResult(answer.getErrorString());
-    		caller.complete(result);
-    	} else if (answer.getDownloadStatus() == VMTemplateStorageResourceAssoc.Status.DOWNLOADED) {
-    		if (answer.getCheckSum() != null) {
-    			VMTemplateVO templateDaoBuilder = templateDao.createForUpdate();
-    			templateDaoBuilder.setChecksum(answer.getCheckSum());
-    			templateDao.update(obj.getId(), templateDaoBuilder);
-    		}
-
-
-    		CreateCmdResult result = new CreateCmdResult(null, answer);
-    		caller.complete(result);
-    	}
-    	return null;
+            result.setResult(answer.getErrorString());
+            caller.complete(result);
+        } else if (answer.getDownloadStatus() == VMTemplateStorageResourceAssoc.Status.DOWNLOADED) {
+            if (answer.getCheckSum() != null) {
+                VMTemplateVO templateDaoBuilder = templateDao.createForUpdate();
+                templateDaoBuilder.setChecksum(answer.getCheckSum());
+                templateDao.update(obj.getId(), templateDaoBuilder);
+            }
+
+            CreateCmdResult result = new CreateCmdResult(null, answer);
+            caller.complete(result);
+        }
+        return null;
     }
 
     private void deleteVolume(DataObject data, AsyncCompletionCallback<CommandResult> callback) {
@@ -231,22 +223,17 @@ public class CloudStackImageStoreDriverImpl implements ImageStoreDriver {
             if (volumeStore.getDownloadState() == VMTemplateStorageResourceAssoc.Status.DOWNLOADED) {
                 DataStore store = _dataStoreMgr.getDataStore(volumeStore.getDataStoreId(), DataStoreRole.Image);
                 EndPoint ep = _epSelector.select(store);
-                DeleteVolumeCommand dtCommand = new DeleteVolumeCommand(
-                        store.getTO(), volumeStore.getVolumeId(), volumeStore.getInstallPath());
+                DeleteVolumeCommand dtCommand = new DeleteVolumeCommand(store.getTO(), volumeStore.getVolumeId(),
+                        volumeStore.getInstallPath());
                 Answer answer = ep.sendMessage(dtCommand);
                 if (answer == null || !answer.getResult()) {
-                    s_logger.debug("Failed to delete "
-                            + volumeStore
-                            + " due to "
-                            + ((answer == null) ? "answer is null" : answer
-                                    .getDetails()));
+                    s_logger.debug("Failed to delete " + volumeStore + " due to "
+                            + ((answer == null) ? "answer is null" : answer.getDetails()));
                     return;
                 }
             } else if (volumeStore.getDownloadState() == VMTemplateStorageResourceAssoc.Status.DOWNLOAD_IN_PROGRESS) {
-                s_logger.debug("Volume: " + vol.getName()
-                        + " is currently being uploaded; cant' delete it.");
-                throw new CloudRuntimeException(
-                        "Please specify a volume that is not currently being uploaded.");
+                s_logger.debug("Volume: " + vol.getName() + " is currently being uploaded; cant' delete it.");
+                throw new CloudRuntimeException("Please specify a volume that is not currently being uploaded.");
             }
 
             CommandResult result = new CommandResult();
@@ -275,8 +262,9 @@ public class CloudStackImageStoreDriverImpl implements ImageStoreDriver {
 
         // TODO: need to understand why we need to mark destroyed in
         // template_store_ref table here instead of in callback.
-        // Currently I did that in callback, so I removed previous code to mark template_host_ref
-        if ( sZoneId != null ){
+        // Currently I did that in callback, so I removed previous code to mark
+        // template_host_ref
+        if (sZoneId != null) {
             UsageEventUtils.publishUsageEvent(eventType, account.getId(), sZoneId, templateId, null, null, null);
         }
 
@@ -284,85 +272,83 @@ public class CloudStackImageStoreDriverImpl implements ImageStoreDriver {
         TemplateDataStoreVO tmplStore = _templateStoreDao.findByStoreTemplate(storeId, templateId);
         String installPath = tmplStore.getInstallPath();
         if (installPath != null) {
-        	DeleteTemplateCommand cmd = new DeleteTemplateCommand(store.getTO(), installPath, template.getId(), template.getAccountId());
-        	EndPoint ep = _epSelector.select(templateObj);
-        	Answer answer = ep.sendMessage(cmd);
-
-        	if (answer == null || !answer.getResult()) {
-        		s_logger.debug("Failed to deleted template at store: " + store.getName());
-        		CommandResult result = new CommandResult();
-        		result.setSuccess(false);
-        		result.setResult("Delete template failed");
-        		callback.complete(result);
-
-        	} else {
-        		s_logger.debug("Deleted template at: " + installPath);
-        		CommandResult result = new CommandResult();
-        		result.setSuccess(true);
-        		callback.complete(result);
-        	}
-
-        	List<VMTemplateZoneVO> templateZones = templateZoneDao.listByZoneTemplate(sZoneId, templateId);
-        	if (templateZones != null) {
-        		for (VMTemplateZoneVO templateZone : templateZones) {
-        			templateZoneDao.remove(templateZone.getId());
-        		}
-        	}
-        }
+            DeleteTemplateCommand cmd = new DeleteTemplateCommand(store.getTO(), installPath, template.getId(),
+                    template.getAccountId());
+            EndPoint ep = _epSelector.select(templateObj);
+            Answer answer = ep.sendMessage(cmd);
+
+            if (answer == null || !answer.getResult()) {
+                s_logger.debug("Failed to deleted template at store: " + store.getName());
+                CommandResult result = new CommandResult();
+                result.setSuccess(false);
+                result.setResult("Delete template failed");
+                callback.complete(result);
+
+            } else {
+                s_logger.debug("Deleted template at: " + installPath);
+                CommandResult result = new CommandResult();
+                result.setSuccess(true);
+                callback.complete(result);
+            }
 
+            List<VMTemplateZoneVO> templateZones = templateZoneDao.listByZoneTemplate(sZoneId, templateId);
+            if (templateZones != null) {
+                for (VMTemplateZoneVO templateZone : templateZones) {
+                    templateZoneDao.remove(templateZone.getId());
+                }
+            }
+        }
 
     }
 
     private void deleteSnapshot(DataObject data, AsyncCompletionCallback<CommandResult> callback) {
-        SnapshotObject snapshotObj = (SnapshotObject)data;
+        SnapshotObject snapshotObj = (SnapshotObject) data;
         DataStore secStore = snapshotObj.getDataStore();
         CommandResult result = new CommandResult();
-     	SnapshotVO snapshot = snapshotObj.getSnapshotVO();
+        SnapshotVO snapshot = snapshotObj.getSnapshotVO();
 
-    	if (snapshot == null) {
-    		s_logger.debug("Destroying snapshot " + snapshotObj.getId() + " backup failed due to unable to find snapshot ");
-    		result.setResult("Unable to find snapshot: " + snapshotObj.getId());
-    		callback.complete(result);
-    		return;
-    	}
+        if (snapshot == null) {
+            s_logger.debug("Destroying snapshot " + snapshotObj.getId()
+                    + " backup failed due to unable to find snapshot ");
+            result.setResult("Unable to find snapshot: " + snapshotObj.getId());
+            callback.complete(result);
+            return;
+        }
 
-    	try {
+        try {
             String backupOfSnapshot = snapshotObj.getPath();
             if (backupOfSnapshot == null) {
                 callback.complete(result);
                 return;
             }
 
-    		DeleteSnapshotBackupCommand2 cmd = new DeleteSnapshotBackupCommand2(
-    				secStore.getTO(), backupOfSnapshot);
-    		EndPoint ep = _epSelector.select(secStore);
-    		Answer answer = ep.sendMessage(cmd);
-
-    		if (answer != null && !answer.getResult()) {
-    			result.setResult(answer.getDetails());
-    		}
-    	} catch (Exception e) {
-    		s_logger.debug("failed to delete snapshot: " + snapshotObj.getId() + ": " + e.toString());
-    		result.setResult(e.toString());
-    	}
-    	callback.complete(result);
+            DeleteSnapshotBackupCommand2 cmd = new DeleteSnapshotBackupCommand2(secStore.getTO(), backupOfSnapshot);
+            EndPoint ep = _epSelector.select(secStore);
+            Answer answer = ep.sendMessage(cmd);
+
+            if (answer != null && !answer.getResult()) {
+                result.setResult(answer.getDetails());
+            }
+        } catch (Exception e) {
+            s_logger.debug("failed to delete snapshot: " + snapshotObj.getId() + ": " + e.toString());
+            result.setResult(e.toString());
+        }
+        callback.complete(result);
     }
 
     @Override
-    public void deleteAsync(DataObject data,
-            AsyncCompletionCallback<CommandResult> callback) {
+    public void deleteAsync(DataObject data, AsyncCompletionCallback<CommandResult> callback) {
         if (data.getType() == DataObjectType.VOLUME) {
             deleteVolume(data, callback);
         } else if (data.getType() == DataObjectType.TEMPLATE) {
             deleteTemplate(data, callback);
         } else if (data.getType() == DataObjectType.SNAPSHOT) {
-        	deleteSnapshot(data, callback);
+            deleteSnapshot(data, callback);
         }
     }
 
     @Override
-    public void copyAsync(DataObject srcdata, DataObject destData,
-            AsyncCompletionCallback<CopyCommandResult> callback) {
+    public void copyAsync(DataObject srcdata, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback) {
         // TODO Auto-generated method stub
 
     }
@@ -373,11 +359,10 @@ public class CloudStackImageStoreDriverImpl implements ImageStoreDriver {
         return false;
     }
 
-	@Override
-	public void resize(DataObject data,
-			AsyncCompletionCallback<CreateCmdResult> callback) {
-		// TODO Auto-generated method stub
+    @Override
+    public void resize(DataObject data, AsyncCompletionCallback<CreateCmdResult> callback) {
+        // TODO Auto-generated method stub
 
-	}
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0a522892/plugins/storage/image/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackImageStoreLifeCycleImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/image/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackImageStoreLifeCycleImpl.java b/plugins/storage/image/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackImageStoreLifeCycleImpl.java
index d550f0b..a0b64bf 100644
--- a/plugins/storage/image/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackImageStoreLifeCycleImpl.java
+++ b/plugins/storage/image/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackImageStoreLifeCycleImpl.java
@@ -18,7 +18,6 @@ package org.apache.cloudstack.storage.datastore.lifecycle;
 
 import java.net.URI;
 import java.net.URISyntaxException;
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -37,56 +36,51 @@ import org.apache.cloudstack.storage.image.store.lifecycle.ImageStoreLifeCycle;
 import org.apache.log4j.Logger;
 
 import com.cloud.agent.api.StoragePoolInfo;
-import com.cloud.exception.DiscoveryException;
 import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.host.Host;
-import com.cloud.host.HostVO;
-import com.cloud.hypervisor.kvm.discoverer.KvmDummyResourceBase;
 import com.cloud.resource.Discoverer;
-import com.cloud.resource.ResourceListener;
 import com.cloud.resource.ResourceManager;
-import com.cloud.resource.ServerResource;
 import com.cloud.storage.DataStoreRole;
 import com.cloud.storage.ScopeType;
 import com.cloud.utils.UriUtils;
 
 public class CloudStackImageStoreLifeCycleImpl implements ImageStoreLifeCycle {
 
-    private static final Logger s_logger = Logger
-            .getLogger(CloudStackImageStoreLifeCycleImpl.class);
+    private static final Logger s_logger = Logger.getLogger(CloudStackImageStoreLifeCycleImpl.class);
     @Inject
     protected ResourceManager _resourceMgr;
     @Inject
-	protected ImageStoreDao imageStoreDao;
-	@Inject
-	ImageStoreHelper imageStoreHelper;
-	@Inject
-	ImageStoreProviderManager imageStoreMgr;
+    protected ImageStoreDao imageStoreDao;
+    @Inject
+    ImageStoreHelper imageStoreHelper;
+    @Inject
+    ImageStoreProviderManager imageStoreMgr;
 
     protected List<? extends Discoverer> _discoverers;
+
     public List<? extends Discoverer> getDiscoverers() {
         return _discoverers;
     }
+
     public void setDiscoverers(List<? extends Discoverer> _discoverers) {
         this._discoverers = _discoverers;
     }
 
-	public CloudStackImageStoreLifeCycleImpl() {
-	}
-
+    public CloudStackImageStoreLifeCycleImpl() {
+    }
 
+    @SuppressWarnings("unchecked")
     @Override
     public DataStore initialize(Map<String, Object> dsInfos) {
 
         Long dcId = (Long) dsInfos.get("zoneId");
         String url = (String) dsInfos.get("url");
-        String name = (String)dsInfos.get("name");
-        if ( name == null ){
+        String name = (String) dsInfos.get("name");
+        if (name == null) {
             name = url;
         }
-        String providerName = (String)dsInfos.get("providerName");
-        DataStoreRole role =(DataStoreRole) dsInfos.get("role");
-        Map<String, String> details = (Map<String, String>)dsInfos.get("details");
+        String providerName = (String) dsInfos.get("providerName");
+        DataStoreRole role = (DataStoreRole) dsInfos.get("role");
+        Map<String, String> details = (Map<String, String>) dsInfos.get("details");
 
         s_logger.info("Trying to add a new host at " + url + " in data center " + dcId);
 
@@ -94,91 +88,81 @@ public class CloudStackImageStoreLifeCycleImpl implements ImageStoreLifeCycle {
         try {
             uri = new URI(UriUtils.encodeURIComponent(url));
             if (uri.getScheme() == null) {
-                throw new InvalidParameterValueException("uri.scheme is null "
-                        + url + ", add nfs:// as a prefix");
+                throw new InvalidParameterValueException("uri.scheme is null " + url + ", add nfs:// as a prefix");
             } else if (uri.getScheme().equalsIgnoreCase("nfs")) {
-                if (uri.getHost() == null || uri.getHost().equalsIgnoreCase("")
-                        || uri.getPath() == null
+                if (uri.getHost() == null || uri.getHost().equalsIgnoreCase("") || uri.getPath() == null
                         || uri.getPath().equalsIgnoreCase("")) {
                     throw new InvalidParameterValueException(
                             "Your host and/or path is wrong.  Make sure it's of the format nfs://hostname/path");
                 }
             }
         } catch (URISyntaxException e) {
-            throw new InvalidParameterValueException(url
-                    + " is not a valid uri");
+            throw new InvalidParameterValueException(url + " is not a valid uri");
         }
 
-        if ( dcId == null ){
-            throw new InvalidParameterValueException("DataCenter id is null, and cloudstack default image storehas to be associated with a data center");
+        if (dcId == null) {
+            throw new InvalidParameterValueException(
+                    "DataCenter id is null, and cloudstack default image storehas to be associated with a data center");
         }
 
-
         Map<String, Object> imageStoreParameters = new HashMap<String, Object>();
         imageStoreParameters.put("name", name);
         imageStoreParameters.put("zoneId", dcId);
         imageStoreParameters.put("url", url);
         imageStoreParameters.put("protocol", uri.getScheme().toLowerCase());
-        imageStoreParameters.put("scope", ScopeType.ZONE);  // default cloudstack provider only supports zone-wide image store
+        imageStoreParameters.put("scope", ScopeType.ZONE); // default cloudstack
+                                                           // provider only
+                                                           // supports zone-wide
+                                                           // image store
         imageStoreParameters.put("providerName", providerName);
         imageStoreParameters.put("role", role);
 
-
         ImageStoreVO ids = imageStoreHelper.createImageStore(imageStoreParameters, details);
         return imageStoreMgr.getImageStore(ids.getId());
     }
 
-
     @Override
     public boolean attachCluster(DataStore store, ClusterScope scope) {
         // TODO Auto-generated method stub
         return false;
     }
 
-
     @Override
-    public boolean attachHost(DataStore store, HostScope scope,
-            StoragePoolInfo existingInfo) {
+    public boolean attachHost(DataStore store, HostScope scope, StoragePoolInfo existingInfo) {
         // TODO Auto-generated method stub
         return false;
     }
 
-
     @Override
     public boolean attachZone(DataStore dataStore, ZoneScope scope) {
         // TODO Auto-generated method stub
         return false;
     }
 
-
     @Override
     public boolean dettach() {
         // TODO Auto-generated method stub
         return false;
     }
 
-
     @Override
     public boolean unmanaged() {
         // TODO Auto-generated method stub
         return false;
     }
 
-
     @Override
     public boolean maintain(DataStore store) {
         // TODO Auto-generated method stub
         return false;
     }
 
-
     @Override
     public boolean cancelMaintain(DataStore store) {
         // TODO Auto-generated method stub
         return false;
     }
 
-
     @Override
     public boolean deleteDataStore(DataStore store) {
         // TODO Auto-generated method stub

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0a522892/plugins/storage/image/default/src/org/apache/cloudstack/storage/datastore/provider/CloudStackImageStoreProviderImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/image/default/src/org/apache/cloudstack/storage/datastore/provider/CloudStackImageStoreProviderImpl.java b/plugins/storage/image/default/src/org/apache/cloudstack/storage/datastore/provider/CloudStackImageStoreProviderImpl.java
index c9952e2..23de36f 100644
--- a/plugins/storage/image/default/src/org/apache/cloudstack/storage/datastore/provider/CloudStackImageStoreProviderImpl.java
+++ b/plugins/storage/image/default/src/org/apache/cloudstack/storage/datastore/provider/CloudStackImageStoreProviderImpl.java
@@ -82,7 +82,7 @@ public class CloudStackImageStoreProviderImpl implements ImageStoreProvider {
 
     @Override
     public Set<DataStoreProviderType> getTypes() {
-        Set<DataStoreProviderType> types =  new HashSet<DataStoreProviderType>();
+        Set<DataStoreProviderType> types = new HashSet<DataStoreProviderType>();
         types.add(DataStoreProviderType.IMAGE);
         types.add(DataStoreProviderType.ImageCache);
         return types;
@@ -90,15 +90,14 @@ public class CloudStackImageStoreProviderImpl implements ImageStoreProvider {
 
     @Override
     public boolean isScopeSupported(ScopeType scope) {
-        if ( scope == ScopeType.ZONE)
+        if (scope == ScopeType.ZONE)
             return true;
         return false;
     }
 
     @Override
     public boolean needDownloadSysTemplate() {
-         return false;
+        return false;
     }
 
-
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0a522892/plugins/storage/image/s3/src/org/apache/cloudstack/storage/datastore/driver/S3ImageStoreDriverImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/image/s3/src/org/apache/cloudstack/storage/datastore/driver/S3ImageStoreDriverImpl.java b/plugins/storage/image/s3/src/org/apache/cloudstack/storage/datastore/driver/S3ImageStoreDriverImpl.java
index 1798ded..0a2a840 100644
--- a/plugins/storage/image/s3/src/org/apache/cloudstack/storage/datastore/driver/S3ImageStoreDriverImpl.java
+++ b/plugins/storage/image/s3/src/org/apache/cloudstack/storage/datastore/driver/S3ImageStoreDriverImpl.java
@@ -25,8 +25,6 @@ import java.util.Set;
 
 import javax.inject.Inject;
 
-import org.apache.log4j.Logger;
-
 import org.apache.cloudstack.api.ApiConstants;
 import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
 import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult;
@@ -48,10 +46,10 @@ import org.apache.cloudstack.storage.image.ImageStoreDriver;
 import org.apache.cloudstack.storage.image.store.ImageStoreImpl;
 import org.apache.cloudstack.storage.image.store.TemplateObject;
 import org.apache.cloudstack.storage.snapshot.SnapshotObject;
+import org.apache.log4j.Logger;
 
 import com.cloud.agent.AgentManager;
 import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.DeleteSnapshotBackupCommand;
 import com.cloud.agent.api.DeleteSnapshotBackupCommand2;
 import com.cloud.agent.api.storage.DeleteTemplateCommand;
 import com.cloud.agent.api.storage.DeleteVolumeCommand;
@@ -61,7 +59,6 @@ import com.cloud.agent.api.to.DataStoreTO;
 import com.cloud.agent.api.to.DataTO;
 import com.cloud.agent.api.to.S3TO;
 import com.cloud.api.query.dao.UserVmJoinDao;
-import com.cloud.api.query.vo.UserVmJoinVO;
 import com.cloud.event.EventTypes;
 import com.cloud.event.UsageEventUtils;
 import com.cloud.host.dao.HostDao;
@@ -77,46 +74,49 @@ import com.cloud.storage.dao.VMTemplateDao;
 import com.cloud.storage.dao.VMTemplateZoneDao;
 import com.cloud.storage.dao.VolumeDao;
 import com.cloud.storage.download.DownloadMonitor;
-import com.cloud.storage.s3.S3Manager;
 import com.cloud.storage.secondary.SecondaryStorageVmManager;
 import com.cloud.storage.snapshot.SnapshotManager;
-import com.cloud.storage.swift.SwiftManager;
 import com.cloud.user.Account;
 import com.cloud.user.dao.AccountDao;
 import com.cloud.utils.exception.CloudRuntimeException;
-import com.cloud.vm.UserVmVO;
 import com.cloud.vm.dao.UserVmDao;
 
 public class S3ImageStoreDriverImpl implements ImageStoreDriver {
-    private static final Logger s_logger = Logger
-            .getLogger(S3ImageStoreDriverImpl.class);
+    private static final Logger s_logger = Logger.getLogger(S3ImageStoreDriverImpl.class);
     @Inject
     VMTemplateZoneDao templateZoneDao;
     @Inject
     VMTemplateDao templateDao;
-    @Inject DownloadMonitor _downloadMonitor;
+    @Inject
+    DownloadMonitor _downloadMonitor;
     @Inject
     ImageStoreDetailsDao _imageStoreDetailsDao;
-    @Inject VolumeDao volumeDao;
-    @Inject VolumeDataStoreDao _volumeStoreDao;
-    @Inject HostDao hostDao;
-    @Inject SnapshotDao snapshotDao;
-    @Inject AgentManager agentMgr;
-    @Inject SnapshotManager snapshotMgr;
-	@Inject
-    private SwiftManager _swiftMgr;
     @Inject
-    private S3Manager _s3Mgr;
-    @Inject AccountDao _accountDao;
-    @Inject UserVmDao _userVmDao;
-    @Inject UserVmJoinDao _userVmJoinDao;
+    VolumeDao volumeDao;
+    @Inject
+    VolumeDataStoreDao _volumeStoreDao;
+    @Inject
+    HostDao hostDao;
+    @Inject
+    SnapshotDao snapshotDao;
+    @Inject
+    AgentManager agentMgr;
+    @Inject
+    SnapshotManager snapshotMgr;
+    @Inject
+    AccountDao _accountDao;
+    @Inject
+    UserVmDao _userVmDao;
+    @Inject
+    UserVmJoinDao _userVmJoinDao;
     @Inject
     SecondaryStorageVmManager _ssvmMgr;
     @Inject
-    private AgentManager _agentMgr;
-    @Inject TemplateDataStoreDao _templateStoreDao;
-    @Inject EndPointSelector _epSelector;
-    @Inject DataStoreManager _dataStoreMgr;
+    TemplateDataStoreDao _templateStoreDao;
+    @Inject
+    EndPointSelector _epSelector;
+    @Inject
+    DataStoreManager _dataStoreMgr;
 
     @Override
     public String grantAccess(DataObject data, EndPoint ep) {
@@ -129,20 +129,20 @@ public class S3ImageStoreDriverImpl implements ImageStoreDriver {
         return null;
     }
 
-
     @Override
     public DataStoreTO getStoreTO(DataStore store) {
-        ImageStoreImpl imgStore = (ImageStoreImpl)store;
+        ImageStoreImpl imgStore = (ImageStoreImpl) store;
         Map<String, String> details = _imageStoreDetailsDao.getDetails(imgStore.getId());
         return new S3TO(imgStore.getId(), imgStore.getUuid(), details.get(ApiConstants.S3_ACCESS_KEY),
-                details.get(ApiConstants.S3_SECRET_KEY),
-                details.get(ApiConstants.S3_END_POINT),
-                details.get(ApiConstants.S3_BUCKET_NAME),
-                details.get(ApiConstants.S3_HTTPS_FLAG) == null ? false : Boolean.parseBoolean(details.get(ApiConstants.S3_HTTPS_FLAG)),
-                details.get(ApiConstants.S3_CONNECTION_TIMEOUT) == null ? null : Integer.valueOf(details.get(ApiConstants.S3_CONNECTION_TIMEOUT)),
-                details.get(ApiConstants.S3_MAX_ERROR_RETRY) == null ? null : Integer.valueOf(details.get(ApiConstants.S3_MAX_ERROR_RETRY)),
-                details.get(ApiConstants.S3_SOCKET_TIMEOUT) == null ? null : Integer.valueOf(details.get(ApiConstants.S3_SOCKET_TIMEOUT)),
-                imgStore.getCreated());
+                details.get(ApiConstants.S3_SECRET_KEY), details.get(ApiConstants.S3_END_POINT),
+                details.get(ApiConstants.S3_BUCKET_NAME), details.get(ApiConstants.S3_HTTPS_FLAG) == null ? false
+                        : Boolean.parseBoolean(details.get(ApiConstants.S3_HTTPS_FLAG)),
+                details.get(ApiConstants.S3_CONNECTION_TIMEOUT) == null ? null : Integer.valueOf(details
+                        .get(ApiConstants.S3_CONNECTION_TIMEOUT)),
+                details.get(ApiConstants.S3_MAX_ERROR_RETRY) == null ? null : Integer.valueOf(details
+                        .get(ApiConstants.S3_MAX_ERROR_RETRY)),
+                details.get(ApiConstants.S3_SOCKET_TIMEOUT) == null ? null : Integer.valueOf(details
+                        .get(ApiConstants.S3_SOCKET_TIMEOUT)), imgStore.getCreated());
 
     }
 
@@ -160,6 +160,7 @@ public class S3ImageStoreDriverImpl implements ImageStoreDriver {
 
     class CreateContext<T> extends AsyncRpcConext<T> {
         final DataObject data;
+
         public CreateContext(AsyncCompletionCallback<T> callback, DataObject data) {
             super(callback);
             this.data = data;
@@ -167,16 +168,13 @@ public class S3ImageStoreDriverImpl implements ImageStoreDriver {
     }
 
     @Override
-    public void createAsync(DataObject data,
-            AsyncCompletionCallback<CreateCmdResult> callback) {
+    public void createAsync(DataObject data, AsyncCompletionCallback<CreateCmdResult> callback) {
 
         CreateContext<CreateCmdResult> context = new CreateContext<CreateCmdResult>(callback, data);
-        AsyncCallbackDispatcher<S3ImageStoreDriverImpl, DownloadAnswer> caller =
-                AsyncCallbackDispatcher.create(this);
+        AsyncCallbackDispatcher<S3ImageStoreDriverImpl, DownloadAnswer> caller = AsyncCallbackDispatcher.create(this);
         caller.setContext(context);
         caller.setCallback(caller.getTarget().createAsyncCallback(null, null));
 
-
         if (data.getType() == DataObjectType.TEMPLATE) {
             _downloadMonitor.downloadTemplateToStorage(data, caller);
         } else if (data.getType() == DataObjectType.VOLUME) {
@@ -196,22 +194,17 @@ public class S3ImageStoreDriverImpl implements ImageStoreDriver {
             if (volumeStore.getDownloadState() == VMTemplateStorageResourceAssoc.Status.DOWNLOADED) {
                 DataStore store = _dataStoreMgr.getDataStore(volumeStore.getDataStoreId(), DataStoreRole.Image);
                 EndPoint ep = _epSelector.select(store);
-                DeleteVolumeCommand dtCommand = new DeleteVolumeCommand(
-                        store.getTO(), volumeStore.getVolumeId(), volumeStore.getInstallPath());
+                DeleteVolumeCommand dtCommand = new DeleteVolumeCommand(store.getTO(), volumeStore.getVolumeId(),
+                        volumeStore.getInstallPath());
                 Answer answer = ep.sendMessage(dtCommand);
                 if (answer == null || !answer.getResult()) {
-                    s_logger.debug("Failed to delete "
-                            + volumeStore
-                            + " due to "
-                            + ((answer == null) ? "answer is null" : answer
-                                    .getDetails()));
+                    s_logger.debug("Failed to delete " + volumeStore + " due to "
+                            + ((answer == null) ? "answer is null" : answer.getDetails()));
                     return;
                 }
             } else if (volumeStore.getDownloadState() == VMTemplateStorageResourceAssoc.Status.DOWNLOAD_IN_PROGRESS) {
-                s_logger.debug("Volume: " + vol.getName()
-                        + " is currently being uploaded; cant' delete it.");
-                throw new CloudRuntimeException(
-                        "Please specify a volume that is not currently being uploaded.");
+                s_logger.debug("Volume: " + vol.getName() + " is currently being uploaded; cant' delete it.");
+                throw new CloudRuntimeException("Please specify a volume that is not currently being uploaded.");
             }
             _volumeStoreDao.remove(volumeStore.getId());
             volumeDao.remove(vol.getId());
@@ -221,14 +214,13 @@ public class S3ImageStoreDriverImpl implements ImageStoreDriver {
         }
     }
 
-
     protected Void createAsyncCallback(AsyncCallbackDispatcher<S3ImageStoreDriverImpl, DownloadAnswer> callback,
             CreateContext<CreateCmdResult> context) {
         DownloadAnswer answer = callback.getResult();
         DataObject obj = context.data;
         DataStore store = obj.getDataStore();
 
-        TemplateDataStoreVO tmpltStoreVO = _templateStoreDao.findByStoreTemplate(store.getId(),obj.getId());
+        TemplateDataStoreVO tmpltStoreVO = _templateStoreDao.findByStoreTemplate(store.getId(), obj.getId());
         if (tmpltStoreVO != null) {
             TemplateDataStoreVO updateBuilder = _templateStoreDao.createForUpdate();
             updateBuilder.setDownloadPercent(answer.getDownloadPct());
@@ -249,9 +241,9 @@ public class S3ImageStoreDriverImpl implements ImageStoreDriver {
 
         AsyncCompletionCallback<CreateCmdResult> caller = context.getParentCallback();
 
-        if (answer.getDownloadStatus() == VMTemplateStorageResourceAssoc.Status.DOWNLOAD_ERROR ||
-                answer.getDownloadStatus() == VMTemplateStorageResourceAssoc.Status.ABANDONED ||
-                answer.getDownloadStatus() == VMTemplateStorageResourceAssoc.Status.UNKNOWN) {
+        if (answer.getDownloadStatus() == VMTemplateStorageResourceAssoc.Status.DOWNLOAD_ERROR
+                || answer.getDownloadStatus() == VMTemplateStorageResourceAssoc.Status.ABANDONED
+                || answer.getDownloadStatus() == VMTemplateStorageResourceAssoc.Status.UNKNOWN) {
             CreateCmdResult result = new CreateCmdResult(null, null);
             result.setSuccess(false);
             result.setResult(answer.getErrorString());
@@ -263,7 +255,6 @@ public class S3ImageStoreDriverImpl implements ImageStoreDriver {
                 templateDao.update(obj.getId(), templateDaoBuilder);
             }
 
-
             CreateCmdResult result = new CreateCmdResult(null, null);
             caller.complete(result);
         }
@@ -287,8 +278,8 @@ public class S3ImageStoreDriverImpl implements ImageStoreDriver {
             eventType = EventTypes.EVENT_TEMPLATE_DELETE;
         }
 
-        if ( sZoneId != null ){
-            //TODO: how to handle region wide usage data where sZoneId == null
+        if (sZoneId != null) {
+            // TODO: how to handle region wide usage data where sZoneId == null
             UsageEventUtils.publishUsageEvent(eventType, account.getId(), sZoneId, templateId, null, null, null);
         }
 
@@ -296,7 +287,8 @@ public class S3ImageStoreDriverImpl implements ImageStoreDriver {
         TemplateDataStoreVO tmplStore = _templateStoreDao.findByStoreTemplate(storeId, templateId);
         String installPath = tmplStore.getInstallPath();
         if (installPath != null) {
-            DeleteTemplateCommand cmd = new DeleteTemplateCommand(store.getTO(), installPath, template.getId(), template.getAccountId());
+            DeleteTemplateCommand cmd = new DeleteTemplateCommand(store.getTO(), installPath, template.getId(),
+                    template.getAccountId());
             EndPoint ep = _epSelector.select(templateObj);
             Answer answer = ep.sendMessage(cmd);
 
@@ -325,13 +317,14 @@ public class S3ImageStoreDriverImpl implements ImageStoreDriver {
     }
 
     private void deleteSnapshot(DataObject data, AsyncCompletionCallback<CommandResult> callback) {
-        SnapshotObject snapshotObj = (SnapshotObject)data;
+        SnapshotObject snapshotObj = (SnapshotObject) data;
         DataStore secStore = snapshotObj.getDataStore();
         CommandResult result = new CommandResult();
         SnapshotVO snapshot = snapshotObj.getSnapshotVO();
 
         if (snapshot == null) {
-            s_logger.debug("Destroying snapshot " + snapshotObj.getId() + " backup failed due to unable to find snapshot ");
+            s_logger.debug("Destroying snapshot " + snapshotObj.getId()
+                    + " backup failed due to unable to find snapshot ");
             result.setResult("Unable to find snapshot: " + snapshotObj.getId());
             callback.complete(result);
             return;
@@ -345,8 +338,7 @@ public class S3ImageStoreDriverImpl implements ImageStoreDriver {
                 return;
             }
 
-            DeleteSnapshotBackupCommand2 cmd = new DeleteSnapshotBackupCommand2(
-                    secStore.getTO(), backupOfSnapshot);
+            DeleteSnapshotBackupCommand2 cmd = new DeleteSnapshotBackupCommand2(secStore.getTO(), backupOfSnapshot);
             EndPoint ep = _epSelector.select(secStore);
             Answer answer = ep.sendMessage(cmd);
 
@@ -360,22 +352,19 @@ public class S3ImageStoreDriverImpl implements ImageStoreDriver {
         callback.complete(result);
     }
 
-
     @Override
-    public void deleteAsync(DataObject data,
-            AsyncCompletionCallback<CommandResult> callback) {
+    public void deleteAsync(DataObject data, AsyncCompletionCallback<CommandResult> callback) {
         if (data.getType() == DataObjectType.VOLUME) {
             deleteVolume(data, callback);
         } else if (data.getType() == DataObjectType.TEMPLATE) {
             deleteTemplate(data, callback);
         } else if (data.getType() == DataObjectType.SNAPSHOT) {
-        	deleteSnapshot(data, callback);
+            deleteSnapshot(data, callback);
         }
     }
 
     @Override
-    public void copyAsync(DataObject srcdata, DataObject destData,
-            AsyncCompletionCallback<CopyCommandResult> callback) {
+    public void copyAsync(DataObject srcdata, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback) {
         // TODO Auto-generated method stub
 
     }
@@ -386,11 +375,10 @@ public class S3ImageStoreDriverImpl implements ImageStoreDriver {
         return false;
     }
 
-	@Override
-	public void resize(DataObject data,
-			AsyncCompletionCallback<CreateCmdResult> callback) {
-		// TODO Auto-generated method stub
+    @Override
+    public void resize(DataObject data, AsyncCompletionCallback<CreateCmdResult> callback) {
+        // TODO Auto-generated method stub
 
-	}
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0a522892/plugins/storage/image/s3/src/org/apache/cloudstack/storage/datastore/lifecycle/S3ImageStoreLifeCycleImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/image/s3/src/org/apache/cloudstack/storage/datastore/lifecycle/S3ImageStoreLifeCycleImpl.java b/plugins/storage/image/s3/src/org/apache/cloudstack/storage/datastore/lifecycle/S3ImageStoreLifeCycleImpl.java
index 4ea97e5..674a13d 100644
--- a/plugins/storage/image/s3/src/org/apache/cloudstack/storage/datastore/lifecycle/S3ImageStoreLifeCycleImpl.java
+++ b/plugins/storage/image/s3/src/org/apache/cloudstack/storage/datastore/lifecycle/S3ImageStoreLifeCycleImpl.java
@@ -16,9 +16,6 @@
 // under the License.
 package org.apache.cloudstack.storage.datastore.lifecycle;
 
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -38,69 +35,58 @@ import org.apache.cloudstack.storage.image.store.lifecycle.ImageStoreLifeCycle;
 import org.apache.log4j.Logger;
 
 import com.cloud.agent.api.StoragePoolInfo;
-import com.cloud.exception.DiscoveryException;
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.host.Host;
-import com.cloud.host.HostVO;
-import com.cloud.hypervisor.kvm.discoverer.KvmDummyResourceBase;
 import com.cloud.resource.Discoverer;
-import com.cloud.resource.ResourceListener;
 import com.cloud.resource.ResourceManager;
-import com.cloud.resource.ServerResource;
 import com.cloud.storage.DataStoreRole;
 import com.cloud.storage.ScopeType;
 import com.cloud.storage.s3.S3Manager;
-import com.cloud.utils.UriUtils;
 
 public class S3ImageStoreLifeCycleImpl implements ImageStoreLifeCycle {
 
-    private static final Logger s_logger = Logger
-            .getLogger(S3ImageStoreLifeCycleImpl.class);
+    private static final Logger s_logger = Logger.getLogger(S3ImageStoreLifeCycleImpl.class);
     @Inject
     protected ResourceManager _resourceMgr;
     @Inject
-	protected ImageStoreDao imageStoreDao;
-	@Inject
-	ImageStoreHelper imageStoreHelper;
-	@Inject
-	ImageStoreProviderManager imageStoreMgr;
+    protected ImageStoreDao imageStoreDao;
     @Inject
-    S3Manager                      _s3Mgr;
+    ImageStoreHelper imageStoreHelper;
+    @Inject
+    ImageStoreProviderManager imageStoreMgr;
+    @Inject
+    S3Manager _s3Mgr;
 
     protected List<? extends Discoverer> _discoverers;
+
     public List<? extends Discoverer> getDiscoverers() {
         return _discoverers;
     }
+
     public void setDiscoverers(List<? extends Discoverer> _discoverers) {
         this._discoverers = _discoverers;
     }
 
-	public S3ImageStoreLifeCycleImpl() {
-	}
-
+    public S3ImageStoreLifeCycleImpl() {
+    }
 
+    @SuppressWarnings("unchecked")
     @Override
     public DataStore initialize(Map<String, Object> dsInfos) {
 
         Long dcId = (Long) dsInfos.get("zoneId");
         String url = (String) dsInfos.get("url");
-        String name = (String)dsInfos.get("name");
-        String providerName = (String)dsInfos.get("providerName");
-        ScopeType scope = (ScopeType)dsInfos.get("scope");
-        DataStoreRole role =(DataStoreRole) dsInfos.get("role");
-        Map<String, String> details = (Map<String, String>)dsInfos.get("details");
+        String name = (String) dsInfos.get("name");
+        String providerName = (String) dsInfos.get("providerName");
+        ScopeType scope = (ScopeType) dsInfos.get("scope");
+        DataStoreRole role = (DataStoreRole) dsInfos.get("role");
+        Map<String, String> details = (Map<String, String>) dsInfos.get("details");
 
         s_logger.info("Trying to add a S3 store in data center " + dcId);
 
         /*
-        try{
-        // verify S3 parameters
-        _s3Mgr.verifyS3Fields(details);
-        }
-        catch (DiscoveryException ex){
-            throw new InvalidParameterValueException("failed to verify S3 parameters!");
-        }
-        */
+         * try{ // verify S3 parameters _s3Mgr.verifyS3Fields(details); } catch
+         * (DiscoveryException ex){ throw new
+         * InvalidParameterValueException("failed to verify S3 parameters!"); }
+         */
 
         Map<String, Object> imageStoreParameters = new HashMap<String, Object>();
         imageStoreParameters.put("name", name);
@@ -108,7 +94,7 @@ public class S3ImageStoreLifeCycleImpl implements ImageStoreLifeCycle {
         imageStoreParameters.put("url", url);
         String protocol = "http";
         String useHttps = details.get(ApiConstants.S3_HTTPS_FLAG);
-        if (useHttps != null && Boolean.parseBoolean(useHttps)){
+        if (useHttps != null && Boolean.parseBoolean(useHttps)) {
             protocol = "https";
         }
         imageStoreParameters.put("protocol", protocol);
@@ -124,57 +110,48 @@ public class S3ImageStoreLifeCycleImpl implements ImageStoreLifeCycle {
         return imageStoreMgr.getImageStore(ids.getId());
     }
 
-
     @Override
     public boolean attachCluster(DataStore store, ClusterScope scope) {
         // TODO Auto-generated method stub
         return false;
     }
 
-
     @Override
-    public boolean attachHost(DataStore store, HostScope scope,
-            StoragePoolInfo existingInfo) {
+    public boolean attachHost(DataStore store, HostScope scope, StoragePoolInfo existingInfo) {
         // TODO Auto-generated method stub
         return false;
     }
 
-
     @Override
     public boolean attachZone(DataStore dataStore, ZoneScope scope) {
         // TODO Auto-generated method stub
         return false;
     }
 
-
     @Override
     public boolean dettach() {
         // TODO Auto-generated method stub
         return false;
     }
 
-
     @Override
     public boolean unmanaged() {
         // TODO Auto-generated method stub
         return false;
     }
 
-
     @Override
     public boolean maintain(DataStore store) {
         // TODO Auto-generated method stub
         return false;
     }
 
-
     @Override
     public boolean cancelMaintain(DataStore store) {
         // TODO Auto-generated method stub
         return false;
     }
 
-
     @Override
     public boolean deleteDataStore(DataStore store) {
         // TODO Auto-generated method stub

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0a522892/plugins/storage/image/s3/src/org/apache/cloudstack/storage/datastore/provider/S3ImageStoreProviderImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/image/s3/src/org/apache/cloudstack/storage/datastore/provider/S3ImageStoreProviderImpl.java b/plugins/storage/image/s3/src/org/apache/cloudstack/storage/datastore/provider/S3ImageStoreProviderImpl.java
index 7efb59a..8bcdb44 100644
--- a/plugins/storage/image/s3/src/org/apache/cloudstack/storage/datastore/provider/S3ImageStoreProviderImpl.java
+++ b/plugins/storage/image/s3/src/org/apache/cloudstack/storage/datastore/provider/S3ImageStoreProviderImpl.java
@@ -18,12 +18,9 @@
  */
 package org.apache.cloudstack.storage.datastore.provider;
 
-import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
-import java.util.UUID;
-
 import javax.inject.Inject;
 
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver;
@@ -83,22 +80,21 @@ public class S3ImageStoreProviderImpl implements ImageStoreProvider {
 
     @Override
     public Set<DataStoreProviderType> getTypes() {
-        Set<DataStoreProviderType> types =  new HashSet<DataStoreProviderType>();
+        Set<DataStoreProviderType> types = new HashSet<DataStoreProviderType>();
         types.add(DataStoreProviderType.IMAGE);
         return types;
     }
 
     @Override
     public boolean isScopeSupported(ScopeType scope) {
-        if ( scope == ScopeType.REGION )
+        if (scope == ScopeType.REGION)
             return true;
         return false;
     }
 
     @Override
     public boolean needDownloadSysTemplate() {
-         return true;
+        return true;
     }
 
-
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0a522892/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/driver/SampleImageStoreDriverImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/driver/SampleImageStoreDriverImpl.java b/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/driver/SampleImageStoreDriverImpl.java
index 2c7ba11..27e6081 100644
--- a/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/driver/SampleImageStoreDriverImpl.java
+++ b/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/driver/SampleImageStoreDriverImpl.java
@@ -45,6 +45,7 @@ public class SampleImageStoreDriverImpl implements ImageStoreDriver {
     EndPointSelector selector;
     @Inject
     VMTemplateDao imageDataDao;
+
     public SampleImageStoreDriverImpl() {
     }
 
@@ -53,7 +54,6 @@ public class SampleImageStoreDriverImpl implements ImageStoreDriver {
         return null;
     }
 
-
     @Override
     public DataStoreTO getStoreTO(DataStore store) {
         // TODO Auto-generated method stub
@@ -78,9 +78,8 @@ public class SampleImageStoreDriverImpl implements ImageStoreDriver {
     }
 
     @Override
-    public void createAsync(DataObject data,
-            AsyncCompletionCallback<CreateCmdResult> callback) {
-        //for default http data store, can create http based template/iso
+    public void createAsync(DataObject data, AsyncCompletionCallback<CreateCmdResult> callback) {
+        // for default http data store, can create http based template/iso
         CreateCmdResult result = new CreateCmdResult("", null);
         if (!data.getUri().startsWith("http")) {
             result.setResult("can't register an image which is not a http link");
@@ -89,7 +88,8 @@ public class SampleImageStoreDriverImpl implements ImageStoreDriver {
         }
 
         if (data.getSize() == null && data.getType() == DataObjectType.TEMPLATE) {
-            //the template size is unknown during registration, need to find out the size of template
+            // the template size is unknown during registration, need to find
+            // out the size of template
             EndPoint ep = selector.select(data);
             if (ep == null) {
                 result.setResult("can't find storage client for:" + data.getId() + "," + data.getType());
@@ -97,9 +97,9 @@ public class SampleImageStoreDriverImpl implements ImageStoreDriver {
                 return;
             }
             CreateObjectCommand createCmd = new CreateObjectCommand(data.getTO());
-            CreateObjectAnswer answer = (CreateObjectAnswer)ep.sendMessage(createCmd);
+            CreateObjectAnswer answer = (CreateObjectAnswer) ep.sendMessage(createCmd);
             if (answer.getResult()) {
-                //update imagestorevo
+                // update imagestorevo
 
                 result = new CreateCmdResult(null, null);
             } else {
@@ -112,8 +112,7 @@ public class SampleImageStoreDriverImpl implements ImageStoreDriver {
     }
 
     @Override
-    public void deleteAsync(DataObject data,
-            AsyncCompletionCallback<CommandResult> callback) {
+    public void deleteAsync(DataObject data, AsyncCompletionCallback<CommandResult> callback) {
         CommandResult result = new CommandResult();
         callback.complete(result);
     }
@@ -125,16 +124,14 @@ public class SampleImageStoreDriverImpl implements ImageStoreDriver {
     }
 
     @Override
-    public void copyAsync(DataObject srcdata, DataObject destData,
-            AsyncCompletionCallback<CopyCommandResult> callback) {
+    public void copyAsync(DataObject srcdata, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback) {
         // TODO Auto-generated method stub
 
     }
 
-	@Override
-	public void resize(DataObject data,
-			AsyncCompletionCallback<CreateCmdResult> callback) {
-		// TODO Auto-generated method stub
+    @Override
+    public void resize(DataObject data, AsyncCompletionCallback<CreateCmdResult> callback) {
+        // TODO Auto-generated method stub
 
-	}
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0a522892/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/lifecycle/SampleImageStoreLifeCycleImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/lifecycle/SampleImageStoreLifeCycleImpl.java b/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/lifecycle/SampleImageStoreLifeCycleImpl.java
index fbe9f19..e001c0b 100644
--- a/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/lifecycle/SampleImageStoreLifeCycleImpl.java
+++ b/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/lifecycle/SampleImageStoreLifeCycleImpl.java
@@ -34,14 +34,14 @@ import com.cloud.agent.api.StoragePoolInfo;
 
 public class SampleImageStoreLifeCycleImpl implements ImageStoreLifeCycle {
     @Inject
-	protected ImageStoreDao imageStoreDao;
-	@Inject
-	ImageStoreHelper imageStoreHelper;
-	@Inject
-	ImageStoreProviderManager imageStoreMgr;
-	public SampleImageStoreLifeCycleImpl() {
-	}
+    protected ImageStoreDao imageStoreDao;
+    @Inject
+    ImageStoreHelper imageStoreHelper;
+    @Inject
+    ImageStoreProviderManager imageStoreMgr;
 
+    public SampleImageStoreLifeCycleImpl() {
+    }
 
     @Override
     public DataStore initialize(Map<String, Object> dsInfos) {
@@ -49,57 +49,48 @@ public class SampleImageStoreLifeCycleImpl implements ImageStoreLifeCycle {
         return imageStoreMgr.getImageStore(ids.getId());
     }
 
-
     @Override
     public boolean attachCluster(DataStore store, ClusterScope scope) {
         // TODO Auto-generated method stub
         return false;
     }
 
-
     @Override
-    public boolean attachHost(DataStore store, HostScope scope,
-            StoragePoolInfo existingInfo) {
+    public boolean attachHost(DataStore store, HostScope scope, StoragePoolInfo existingInfo) {
         // TODO Auto-generated method stub
         return false;
     }
 
-
     @Override
     public boolean attachZone(DataStore dataStore, ZoneScope scope) {
         // TODO Auto-generated method stub
         return false;
     }
 
-
     @Override
     public boolean dettach() {
         // TODO Auto-generated method stub
         return false;
     }
 
-
     @Override
     public boolean unmanaged() {
         // TODO Auto-generated method stub
         return false;
     }
 
-
     @Override
     public boolean maintain(DataStore store) {
         // TODO Auto-generated method stub
         return false;
     }
 
-
     @Override
     public boolean cancelMaintain(DataStore store) {
         // TODO Auto-generated method stub
         return false;
     }
 
-
     @Override
     public boolean deleteDataStore(DataStore store) {
         // TODO Auto-generated method stub

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0a522892/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/provider/SampleImageStoreProviderImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/provider/SampleImageStoreProviderImpl.java b/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/provider/SampleImageStoreProviderImpl.java
index 1a0614b..c0c55d6 100644
--- a/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/provider/SampleImageStoreProviderImpl.java
+++ b/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/provider/SampleImageStoreProviderImpl.java
@@ -46,6 +46,7 @@ public class SampleImageStoreProviderImpl implements ImageStoreProvider {
     ImageStoreProviderManager storeMgr;
     long id;
     String uuid;
+
     @Override
     public DataStoreLifeCycle getDataStoreLifeCycle() {
         return lifeCycle;
@@ -67,7 +68,7 @@ public class SampleImageStoreProviderImpl implements ImageStoreProvider {
 
     @Override
     public Set<DataStoreProviderType> getTypes() {
-        Set<DataStoreProviderType> types =  new HashSet<DataStoreProviderType>();
+        Set<DataStoreProviderType> types = new HashSet<DataStoreProviderType>();
         types.add(DataStoreProviderType.IMAGE);
         return types;
     }
@@ -84,7 +85,7 @@ public class SampleImageStoreProviderImpl implements ImageStoreProvider {
 
     @Override
     public boolean isScopeSupported(ScopeType scope) {
-        if ( scope == ScopeType.ZONE)
+        if (scope == ScopeType.ZONE)
             return true;
         return false;
     }
@@ -94,5 +95,4 @@ public class SampleImageStoreProviderImpl implements ImageStoreProvider {
         return false;
     }
 
-
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0a522892/plugins/storage/image/swift/src/org/apache/cloudstack/storage/datastore/driver/SwiftImageStoreDriverImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/image/swift/src/org/apache/cloudstack/storage/datastore/driver/SwiftImageStoreDriverImpl.java b/plugins/storage/image/swift/src/org/apache/cloudstack/storage/datastore/driver/SwiftImageStoreDriverImpl.java
index cdfe63e..71b18d5 100644
--- a/plugins/storage/image/swift/src/org/apache/cloudstack/storage/datastore/driver/SwiftImageStoreDriverImpl.java
+++ b/plugins/storage/image/swift/src/org/apache/cloudstack/storage/datastore/driver/SwiftImageStoreDriverImpl.java
@@ -50,7 +50,6 @@ import org.apache.log4j.Logger;
 
 import com.cloud.agent.AgentManager;
 import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.DeleteSnapshotBackupCommand;
 import com.cloud.agent.api.DeleteSnapshotBackupCommand2;
 import com.cloud.agent.api.storage.DeleteTemplateCommand;
 import com.cloud.agent.api.storage.DeleteVolumeCommand;
@@ -60,7 +59,6 @@ import com.cloud.agent.api.to.DataStoreTO;
 import com.cloud.agent.api.to.DataTO;
 import com.cloud.agent.api.to.SwiftTO;
 import com.cloud.api.query.dao.UserVmJoinDao;
-import com.cloud.api.query.vo.UserVmJoinVO;
 import com.cloud.event.EventTypes;
 import com.cloud.event.UsageEventUtils;
 import com.cloud.host.dao.HostDao;
@@ -83,40 +81,50 @@ import com.cloud.storage.swift.SwiftManager;
 import com.cloud.user.Account;
 import com.cloud.user.dao.AccountDao;
 import com.cloud.utils.exception.CloudRuntimeException;
-import com.cloud.vm.UserVmVO;
 import com.cloud.vm.dao.UserVmDao;
 
 public class SwiftImageStoreDriverImpl implements ImageStoreDriver {
-    private static final Logger s_logger = Logger
-            .getLogger(SwiftImageStoreDriverImpl.class);
+    private static final Logger s_logger = Logger.getLogger(SwiftImageStoreDriverImpl.class);
     @Inject
     VMTemplateZoneDao templateZoneDao;
     @Inject
     VMTemplateDao templateDao;
-    @Inject DownloadMonitor _downloadMonitor;
+    @Inject
+    DownloadMonitor _downloadMonitor;
     @Inject
     ImageStoreDetailsDao _imageStoreDetailsDao;
-    @Inject VolumeDao volumeDao;
-    @Inject VolumeDataStoreDao _volumeStoreDao;
-    @Inject HostDao hostDao;
-    @Inject SnapshotDao snapshotDao;
-    @Inject AgentManager agentMgr;
-    @Inject SnapshotManager snapshotMgr;
-	@Inject
+    @Inject
+    VolumeDao volumeDao;
+    @Inject
+    VolumeDataStoreDao _volumeStoreDao;
+    @Inject
+    HostDao hostDao;
+    @Inject
+    SnapshotDao snapshotDao;
+    @Inject
+    AgentManager agentMgr;
+    @Inject
+    SnapshotManager snapshotMgr;
+    @Inject
     private SwiftManager _swiftMgr;
     @Inject
     private S3Manager _s3Mgr;
-    @Inject AccountDao _accountDao;
-    @Inject UserVmDao _userVmDao;
-    @Inject UserVmJoinDao _userVmJoinDao;
+    @Inject
+    AccountDao _accountDao;
+    @Inject
+    UserVmDao _userVmDao;
+    @Inject
+    UserVmJoinDao _userVmJoinDao;
     @Inject
     SecondaryStorageVmManager _ssvmMgr;
     @Inject
     private AgentManager _agentMgr;
-    @Inject TemplateDataStoreDao _templateStoreDao;
-    @Inject EndPointSelector _epSelector;
-    @Inject DataStoreManager _dataStoreMgr;
-
+    @Inject
+    TemplateDataStoreDao _templateStoreDao;
+    @Inject
+    EndPointSelector _epSelector;
+    @Inject
+    DataStoreManager _dataStoreMgr;
 
     @Override
     public String grantAccess(DataObject data, EndPoint ep) {
@@ -129,14 +137,12 @@ public class SwiftImageStoreDriverImpl implements ImageStoreDriver {
         return null;
     }
 
-
     @Override
     public DataStoreTO getStoreTO(DataStore store) {
-        ImageStoreImpl imgStore = (ImageStoreImpl)store;
+        ImageStoreImpl imgStore = (ImageStoreImpl) store;
         Map<String, String> details = _imageStoreDetailsDao.getDetails(imgStore.getId());
         return new SwiftTO(imgStore.getId(), imgStore.getUri(), details.get(ApiConstants.ACCOUNT),
-                details.get(ApiConstants.USERNAME),
-                details.get(ApiConstants.KEY));
+                details.get(ApiConstants.USERNAME), details.get(ApiConstants.KEY));
     }
 
     @Override
@@ -153,6 +159,7 @@ public class SwiftImageStoreDriverImpl implements ImageStoreDriver {
 
     class CreateContext<T> extends AsyncRpcConext<T> {
         final DataObject data;
+
         public CreateContext(AsyncCompletionCallback<T> callback, DataObject data) {
             super(callback);
             this.data = data;
@@ -160,15 +167,13 @@ public class SwiftImageStoreDriverImpl implements ImageStoreDriver {
     }
 
     @Override
-    public void createAsync(DataObject data,
-            AsyncCompletionCallback<CreateCmdResult> callback) {
+    public void createAsync(DataObject data, AsyncCompletionCallback<CreateCmdResult> callback) {
         CreateContext<CreateCmdResult> context = new CreateContext<CreateCmdResult>(callback, data);
-        AsyncCallbackDispatcher<SwiftImageStoreDriverImpl, DownloadAnswer> caller =
-                AsyncCallbackDispatcher.create(this);
+        AsyncCallbackDispatcher<SwiftImageStoreDriverImpl, DownloadAnswer> caller = AsyncCallbackDispatcher
+                .create(this);
         caller.setContext(context);
         caller.setCallback(caller.getTarget().createAsyncCallback(null, null));
 
-
         if (data.getType() == DataObjectType.TEMPLATE) {
             _downloadMonitor.downloadTemplateToStorage(data, caller);
         } else if (data.getType() == DataObjectType.VOLUME) {
@@ -182,7 +187,7 @@ public class SwiftImageStoreDriverImpl implements ImageStoreDriver {
         DataObject obj = context.data;
         DataStore store = obj.getDataStore();
 
-        TemplateDataStoreVO tmpltStoreVO = _templateStoreDao.findByStoreTemplate(store.getId(),obj.getId());
+        TemplateDataStoreVO tmpltStoreVO = _templateStoreDao.findByStoreTemplate(store.getId(), obj.getId());
         if (tmpltStoreVO != null) {
             TemplateDataStoreVO updateBuilder = _templateStoreDao.createForUpdate();
             updateBuilder.setDownloadPercent(answer.getDownloadPct());
@@ -203,11 +208,11 @@ public class SwiftImageStoreDriverImpl implements ImageStoreDriver {
 
         AsyncCompletionCallback<CreateCmdResult> caller = context.getParentCallback();
 
-        if (answer.getDownloadStatus() == VMTemplateStorageResourceAssoc.Status.DOWNLOAD_ERROR ||
-                answer.getDownloadStatus() == VMTemplateStorageResourceAssoc.Status.ABANDONED ||
-                answer.getDownloadStatus() == VMTemplateStorageResourceAssoc.Status.UNKNOWN) {
+        if (answer.getDownloadStatus() == VMTemplateStorageResourceAssoc.Status.DOWNLOAD_ERROR
+                || answer.getDownloadStatus() == VMTemplateStorageResourceAssoc.Status.ABANDONED
+                || answer.getDownloadStatus() == VMTemplateStorageResourceAssoc.Status.UNKNOWN) {
             CreateCmdResult result = new CreateCmdResult(null, null);
-            //result.setSucess(false);
+            // result.setSucess(false);
             result.setResult(answer.getErrorString());
             caller.complete(result);
         } else if (answer.getDownloadStatus() == VMTemplateStorageResourceAssoc.Status.DOWNLOADED) {
@@ -217,7 +222,6 @@ public class SwiftImageStoreDriverImpl implements ImageStoreDriver {
                 templateDao.update(obj.getId(), templateDaoBuilder);
             }
 
-
             CreateCmdResult result = new CreateCmdResult(null, null);
             caller.complete(result);
         }
@@ -237,22 +241,17 @@ public class SwiftImageStoreDriverImpl implements ImageStoreDriver {
             if (volumeStore.getDownloadState() == VMTemplateStorageResourceAssoc.Status.DOWNLOADED) {
                 DataStore store = this._dataStoreMgr.getDataStore(volumeStore.getDataStoreId(), DataStoreRole.Image);
                 EndPoint ep = _epSelector.select(store);
-                DeleteVolumeCommand dtCommand = new DeleteVolumeCommand(
-                        store.getTO(), volumeStore.getVolumeId(), volumeStore.getInstallPath());
+                DeleteVolumeCommand dtCommand = new DeleteVolumeCommand(store.getTO(), volumeStore.getVolumeId(),
+                        volumeStore.getInstallPath());
                 Answer answer = ep.sendMessage(dtCommand);
                 if (answer == null || !answer.getResult()) {
-                    s_logger.debug("Failed to delete "
-                            + volumeStore
-                            + " due to "
-                            + ((answer == null) ? "answer is null" : answer
-                                    .getDetails()));
+                    s_logger.debug("Failed to delete " + volumeStore + " due to "
+                            + ((answer == null) ? "answer is null" : answer.getDetails()));
                     return;
                 }
             } else if (volumeStore.getDownloadState() == VMTemplateStorageResourceAssoc.Status.DOWNLOAD_IN_PROGRESS) {
-                s_logger.debug("Volume: " + vol.getName()
-                        + " is currently being uploaded; cant' delete it.");
-                throw new CloudRuntimeException(
-                        "Please specify a volume that is not currently being uploaded.");
+                s_logger.debug("Volume: " + vol.getName() + " is currently being uploaded; cant' delete it.");
+                throw new CloudRuntimeException("Please specify a volume that is not currently being uploaded.");
             }
             _volumeStoreDao.remove(volumeStore.getId());
             volumeDao.remove(vol.getId());
@@ -281,8 +280,9 @@ public class SwiftImageStoreDriverImpl implements ImageStoreDriver {
 
         // TODO: need to understand why we need to mark destroyed in
         // template_store_ref table here instead of in callback.
-        // Currently I did that in callback, so I removed previous code to mark template_host_ref
-        if (sZoneId != null){
+        // Currently I did that in callback, so I removed previous code to mark
+        // template_host_ref
+        if (sZoneId != null) {
             UsageEventUtils.publishUsageEvent(eventType, account.getId(), sZoneId, templateId, null, null, null);
         }
 
@@ -290,7 +290,8 @@ public class SwiftImageStoreDriverImpl implements ImageStoreDriver {
         TemplateDataStoreVO tmplStore = _templateStoreDao.findByStoreTemplate(storeId, templateId);
         String installPath = tmplStore.getInstallPath();
         if (installPath != null) {
-            DeleteTemplateCommand cmd = new DeleteTemplateCommand(store.getTO(), installPath, template.getId(), template.getAccountId());
+            DeleteTemplateCommand cmd = new DeleteTemplateCommand(store.getTO(), installPath, template.getId(),
+                    template.getAccountId());
             EndPoint ep = _epSelector.select(templateObj);
             Answer answer = ep.sendMessage(cmd);
 
@@ -316,16 +317,17 @@ public class SwiftImageStoreDriverImpl implements ImageStoreDriver {
                 }
             }
         }
-     }
+    }
 
     private void deleteSnapshot(DataObject data, AsyncCompletionCallback<CommandResult> callback) {
-        SnapshotObject snapshotObj = (SnapshotObject)data;
+        SnapshotObject snapshotObj = (SnapshotObject) data;
         DataStore secStore = snapshotObj.getDataStore();
         CommandResult result = new CommandResult();
         SnapshotVO snapshot = snapshotObj.getSnapshotVO();
 
         if (snapshot == null) {
-            s_logger.debug("Destroying snapshot " + snapshotObj.getId() + " backup failed due to unable to find snapshot ");
+            s_logger.debug("Destroying snapshot " + snapshotObj.getId()
+                    + " backup failed due to unable to find snapshot ");
             result.setResult("Unable to find snapshot: " + snapshotObj.getId());
             callback.complete(result);
             return;
@@ -338,8 +340,7 @@ public class SwiftImageStoreDriverImpl implements ImageStoreDriver {
                 return;
             }
 
-            DeleteSnapshotBackupCommand2 cmd = new DeleteSnapshotBackupCommand2(
-                    secStore.getTO(), backupOfSnapshot);
+            DeleteSnapshotBackupCommand2 cmd = new DeleteSnapshotBackupCommand2(secStore.getTO(), backupOfSnapshot);
             EndPoint ep = _epSelector.select(secStore);
             Answer answer = ep.sendMessage(cmd);
 
@@ -354,20 +355,18 @@ public class SwiftImageStoreDriverImpl implements ImageStoreDriver {
     }
 
     @Override
-    public void deleteAsync(DataObject data,
-            AsyncCompletionCallback<CommandResult> callback) {
+    public void deleteAsync(DataObject data, AsyncCompletionCallback<CommandResult> callback) {
         if (data.getType() == DataObjectType.VOLUME) {
             deleteVolume(data, callback);
         } else if (data.getType() == DataObjectType.TEMPLATE) {
             deleteTemplate(data, callback);
         } else if (data.getType() == DataObjectType.SNAPSHOT) {
-        	deleteSnapshot(data, callback);
+            deleteSnapshot(data, callback);
         }
     }
 
     @Override
-    public void copyAsync(DataObject srcdata, DataObject destData,
-            AsyncCompletionCallback<CopyCommandResult> callback) {
+    public void copyAsync(DataObject srcdata, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback) {
         // TODO Auto-generated method stub
 
     }
@@ -378,11 +377,10 @@ public class SwiftImageStoreDriverImpl implements ImageStoreDriver {
         return false;
     }
 
-	@Override
-	public void resize(DataObject data,
-			AsyncCompletionCallback<CreateCmdResult> callback) {
-		// TODO Auto-generated method stub
+    @Override
+    public void resize(DataObject data, AsyncCompletionCallback<CreateCmdResult> callback) {
+        // TODO Auto-generated method stub
 
-	}
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0a522892/plugins/storage/image/swift/src/org/apache/cloudstack/storage/datastore/lifecycle/SwiftImageStoreLifeCycleImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/image/swift/src/org/apache/cloudstack/storage/datastore/lifecycle/SwiftImageStoreLifeCycleImpl.java b/plugins/storage/image/swift/src/org/apache/cloudstack/storage/datastore/lifecycle/SwiftImageStoreLifeCycleImpl.java
index 3fc68a1..3ba3b31 100644
--- a/plugins/storage/image/swift/src/org/apache/cloudstack/storage/datastore/lifecycle/SwiftImageStoreLifeCycleImpl.java
+++ b/plugins/storage/image/swift/src/org/apache/cloudstack/storage/datastore/lifecycle/SwiftImageStoreLifeCycleImpl.java
@@ -16,9 +16,6 @@
 // under the License.
 package org.apache.cloudstack.storage.datastore.lifecycle;
 
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -37,55 +34,47 @@ import org.apache.cloudstack.storage.image.store.lifecycle.ImageStoreLifeCycle;
 import org.apache.log4j.Logger;
 
 import com.cloud.agent.api.StoragePoolInfo;
-import com.cloud.exception.DiscoveryException;
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.host.Host;
-import com.cloud.host.HostVO;
-import com.cloud.hypervisor.kvm.discoverer.KvmDummyResourceBase;
 import com.cloud.resource.Discoverer;
-import com.cloud.resource.ResourceListener;
 import com.cloud.resource.ResourceManager;
-import com.cloud.resource.ServerResource;
 import com.cloud.storage.DataStoreRole;
 import com.cloud.storage.ScopeType;
-import com.cloud.utils.UriUtils;
 
 public class SwiftImageStoreLifeCycleImpl implements ImageStoreLifeCycle {
 
-    private static final Logger s_logger = Logger
-            .getLogger(SwiftImageStoreLifeCycleImpl.class);
+    private static final Logger s_logger = Logger.getLogger(SwiftImageStoreLifeCycleImpl.class);
     @Inject
     protected ResourceManager _resourceMgr;
     @Inject
-	protected ImageStoreDao imageStoreDao;
-	@Inject
-	ImageStoreHelper imageStoreHelper;
-	@Inject
-	ImageStoreProviderManager imageStoreMgr;
+    protected ImageStoreDao imageStoreDao;
+    @Inject
+    ImageStoreHelper imageStoreHelper;
+    @Inject
+    ImageStoreProviderManager imageStoreMgr;
 
     protected List<? extends Discoverer> _discoverers;
+
     public List<? extends Discoverer> getDiscoverers() {
         return _discoverers;
     }
+
     public void setDiscoverers(List<? extends Discoverer> _discoverers) {
         this._discoverers = _discoverers;
     }
 
-	public SwiftImageStoreLifeCycleImpl() {
-	}
-
+    public SwiftImageStoreLifeCycleImpl() {
+    }
 
     @Override
     public DataStore initialize(Map<String, Object> dsInfos) {
 
         Long dcId = (Long) dsInfos.get("zoneId");
         String url = (String) dsInfos.get("url");
-        String name = (String)dsInfos.get("name");
-        ScopeType scope = (ScopeType)dsInfos.get("scope");
-        String providerName = (String)dsInfos.get("providerName");
-        DataStoreRole role =(DataStoreRole) dsInfos.get("role");
+        String name = (String) dsInfos.get("name");
+        ScopeType scope = (ScopeType) dsInfos.get("scope");
+        String providerName = (String) dsInfos.get("providerName");
+        DataStoreRole role = (DataStoreRole) dsInfos.get("role");
 
-        Map<String, String> details = (Map<String, String>)dsInfos.get("details");
+        Map<String, String> details = (Map<String, String>) dsInfos.get("details");
 
         s_logger.info("Trying to add a swift store at " + url + " in data center " + dcId);
 
@@ -107,57 +96,48 @@ public class SwiftImageStoreLifeCycleImpl implements ImageStoreLifeCycle {
         return imageStoreMgr.getImageStore(ids.getId());
     }
 
-
     @Override
     public boolean attachCluster(DataStore store, ClusterScope scope) {
         // TODO Auto-generated method stub
         return false;
     }
 
-
     @Override
-    public boolean attachHost(DataStore store, HostScope scope,
-            StoragePoolInfo existingInfo) {
+    public boolean attachHost(DataStore store, HostScope scope, StoragePoolInfo existingInfo) {
         // TODO Auto-generated method stub
         return false;
     }
 
-
     @Override
     public boolean attachZone(DataStore dataStore, ZoneScope scope) {
         // TODO Auto-generated method stub
         return false;
     }
 
-
     @Override
     public boolean dettach() {
         // TODO Auto-generated method stub
         return false;
     }
 
-
     @Override
     public boolean unmanaged() {
         // TODO Auto-generated method stub
         return false;
     }
 
-
     @Override
     public boolean maintain(DataStore store) {
         // TODO Auto-generated method stub
         return false;
     }
 
-
     @Override
     public boolean cancelMaintain(DataStore store) {
         // TODO Auto-generated method stub
         return false;
     }
 
-
     @Override
     public boolean deleteDataStore(DataStore store) {
         // TODO Auto-generated method stub

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0a522892/plugins/storage/image/swift/src/org/apache/cloudstack/storage/datastore/provider/SwiftImageStoreProviderImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/image/swift/src/org/apache/cloudstack/storage/datastore/provider/SwiftImageStoreProviderImpl.java b/plugins/storage/image/swift/src/org/apache/cloudstack/storage/datastore/provider/SwiftImageStoreProviderImpl.java
index bd6f9f0..788eebc 100644
--- a/plugins/storage/image/swift/src/org/apache/cloudstack/storage/datastore/provider/SwiftImageStoreProviderImpl.java
+++ b/plugins/storage/image/swift/src/org/apache/cloudstack/storage/datastore/provider/SwiftImageStoreProviderImpl.java
@@ -82,22 +82,21 @@ public class SwiftImageStoreProviderImpl implements ImageStoreProvider {
 
     @Override
     public Set<DataStoreProviderType> getTypes() {
-        Set<DataStoreProviderType> types =  new HashSet<DataStoreProviderType>();
+        Set<DataStoreProviderType> types = new HashSet<DataStoreProviderType>();
         types.add(DataStoreProviderType.IMAGE);
         return types;
     }
 
     @Override
     public boolean isScopeSupported(ScopeType scope) {
-        if ( scope == ScopeType.REGION )
+        if (scope == ScopeType.REGION)
             return true;
         return false;
     }
 
     @Override
     public boolean needDownloadSysTemplate() {
-         return true;
+        return true;
     }
 
-
 }


Mime
View raw message