cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mc...@apache.org
Subject [55/57] [abbrv] Renamed internal classes to use "imageStorexxx" instead of previous "imageDataStorexxx". Add new addImageStoreCmd to use 3 image store provider plugins.
Date Sat, 06 Apr 2013 00:35:28 GMT
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a872d6d3/plugins/storage/image/default/src/org/apache/cloudstack/storage/datastore/provider/CloudStackImageDataStoreProvider.java
----------------------------------------------------------------------
diff --git a/plugins/storage/image/default/src/org/apache/cloudstack/storage/datastore/provider/CloudStackImageDataStoreProvider.java b/plugins/storage/image/default/src/org/apache/cloudstack/storage/datastore/provider/CloudStackImageDataStoreProvider.java
deleted file mode 100644
index 1e88da3..0000000
--- a/plugins/storage/image/default/src/org/apache/cloudstack/storage/datastore/provider/CloudStackImageDataStoreProvider.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-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;
-import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreLifeCycle;
-import org.apache.cloudstack.engine.subsystem.api.storage.HypervisorHostListener;
-import org.apache.cloudstack.engine.subsystem.api.storage.ImageDataStoreProvider;
-import org.apache.cloudstack.storage.datastore.driver.CloudStackImageDataStoreDriverImpl;
-import org.apache.cloudstack.storage.datastore.lifecycle.CloudStackImageDataStoreLifeCycle;
-import org.apache.cloudstack.storage.image.ImageDataStoreDriver;
-import org.apache.cloudstack.storage.image.datastore.ImageDataStoreHelper;
-import org.apache.cloudstack.storage.image.datastore.ImageDataStoreProviderManager;
-import org.apache.cloudstack.storage.image.store.lifecycle.ImageDataStoreLifeCycle;
-import org.springframework.stereotype.Component;
-
-import com.cloud.storage.ScopeType;
-import com.cloud.utils.component.ComponentContext;
-
-@Component
-public class CloudStackImageDataStoreProvider implements ImageDataStoreProvider {
-
-    private final String name = "cloudstack image data store provider";
-    protected ImageDataStoreLifeCycle lifeCycle;
-    protected ImageDataStoreDriver driver;
-    @Inject
-    ImageDataStoreProviderManager storeMgr;
-    @Inject
-    ImageDataStoreHelper helper;
-
-    @Override
-    public DataStoreLifeCycle getDataStoreLifeCycle() {
-        return lifeCycle;
-    }
-
-    @Override
-    public String getName() {
-        return this.name;
-    }
-
-    @Override
-    public boolean configure(Map<String, Object> params) {
-        lifeCycle = ComponentContext.inject(CloudStackImageDataStoreLifeCycle.class);
-        driver = ComponentContext.inject(CloudStackImageDataStoreDriverImpl.class);
-
-        storeMgr.registerDriver(this.getName(), driver);
-
-        Map<String, Object> infos = new HashMap<String, Object>();
-        String dataStoreName = UUID.nameUUIDFromBytes(this.name.getBytes()).toString();
-        infos.put("name", dataStoreName);
-        infos.put("uuid", dataStoreName);
-        infos.put("protocol", "http");
-        infos.put("scope", ScopeType.GLOBAL);
-        infos.put("providerName", this.getName());
-        DataStoreLifeCycle lifeCycle = this.getDataStoreLifeCycle();
-        lifeCycle.initialize(infos);
-        return true;
-    }
-
-    @Override
-    public DataStoreDriver getDataStoreDriver() {
-        return this.driver;
-    }
-
-    @Override
-    public HypervisorHostListener getHostListener() {
-        return null;
-    }
-
-    @Override
-    public Set<DataStoreProviderType> getTypes() {
-        Set<DataStoreProviderType> types =  new HashSet<DataStoreProviderType>();
-        types.add(DataStoreProviderType.IMAGE);
-        return types;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a872d6d3/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
new file mode 100644
index 0000000..058dd27
--- /dev/null
+++ b/plugins/storage/image/default/src/org/apache/cloudstack/storage/datastore/provider/CloudStackImageStoreProviderImpl.java
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cloudstack.storage.datastore.provider;
+
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import javax.inject.Inject;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreLifeCycle;
+import org.apache.cloudstack.engine.subsystem.api.storage.HypervisorHostListener;
+import org.apache.cloudstack.engine.subsystem.api.storage.ImageStoreProvider;
+import org.apache.cloudstack.storage.datastore.driver.CloudStackImageStoreDriverImpl;
+import org.apache.cloudstack.storage.datastore.lifecycle.CloudStackImageStoreLifeCycleImpl;
+import org.apache.cloudstack.storage.image.ImageStoreDriver;
+import org.apache.cloudstack.storage.image.datastore.ImageStoreHelper;
+import org.apache.cloudstack.storage.image.datastore.ImageStoreProviderManager;
+import org.apache.cloudstack.storage.image.store.lifecycle.ImageStoreLifeCycle;
+import org.springframework.stereotype.Component;
+
+import com.cloud.utils.component.ComponentContext;
+
+@Component
+public class CloudStackImageStoreProviderImpl implements ImageStoreProvider {
+
+    private final String providerName = "cloudstack image store provider";
+    protected ImageStoreLifeCycle lifeCycle;
+    protected ImageStoreDriver driver;
+    @Inject
+    ImageStoreProviderManager storeMgr;
+    @Inject
+    ImageStoreHelper helper;
+
+    @Override
+    public DataStoreLifeCycle getDataStoreLifeCycle() {
+        return lifeCycle;
+    }
+
+    @Override
+    public String getName() {
+        return this.providerName;
+    }
+
+    @Override
+    public boolean configure(Map<String, Object> params) {
+        lifeCycle = ComponentContext.inject(CloudStackImageStoreLifeCycleImpl.class);
+        driver = ComponentContext.inject(CloudStackImageStoreDriverImpl.class);
+
+        storeMgr.registerDriver(this.getName(), driver);
+
+        return true;
+    }
+
+    @Override
+    public DataStoreDriver getDataStoreDriver() {
+        return this.driver;
+    }
+
+    @Override
+    public HypervisorHostListener getHostListener() {
+        return null;
+    }
+
+    @Override
+    public Set<DataStoreProviderType> getTypes() {
+        Set<DataStoreProviderType> types =  new HashSet<DataStoreProviderType>();
+        types.add(DataStoreProviderType.IMAGE);
+        return types;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a872d6d3/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
new file mode 100644
index 0000000..c9e8521
--- /dev/null
+++ b/plugins/storage/image/s3/src/org/apache/cloudstack/storage/datastore/driver/S3ImageStoreDriverImpl.java
@@ -0,0 +1,250 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cloudstack.storage.datastore.driver;
+
+import java.util.List;
+import java.util.Set;
+
+import javax.inject.Inject;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.CommandResult;
+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;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectType;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
+import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
+import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
+import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
+import org.apache.cloudstack.framework.async.AsyncRpcConext;
+import org.apache.cloudstack.storage.image.ImageStoreDriver;
+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.storage.DeleteVolumeCommand;
+import com.cloud.agent.api.to.S3TO;
+import com.cloud.agent.api.to.SwiftTO;
+import com.cloud.host.HostVO;
+import com.cloud.host.dao.HostDao;
+import com.cloud.storage.RegisterVolumePayload;
+import com.cloud.storage.Storage.ImageFormat;
+import com.cloud.storage.SnapshotVO;
+import com.cloud.storage.VMTemplateStorageResourceAssoc;
+import com.cloud.storage.VMTemplateVO;
+import com.cloud.storage.VMTemplateZoneVO;
+import com.cloud.storage.VolumeHostVO;
+import com.cloud.storage.VolumeVO;
+import com.cloud.storage.dao.SnapshotDao;
+import com.cloud.storage.dao.VMTemplateDao;
+import com.cloud.storage.dao.VMTemplateHostDao;
+import com.cloud.storage.dao.VMTemplateZoneDao;
+import com.cloud.storage.dao.VolumeDao;
+import com.cloud.storage.dao.VolumeHostDao;
+import com.cloud.storage.download.DownloadMonitor;
+import com.cloud.storage.s3.S3Manager;
+import com.cloud.storage.snapshot.SnapshotManager;
+import com.cloud.storage.swift.SwiftManager;
+import com.cloud.utils.exception.CloudRuntimeException;
+
+public class S3ImageStoreDriverImpl implements ImageStoreDriver {
+    private static final Logger s_logger = Logger
+            .getLogger(S3ImageStoreDriverImpl.class);
+    @Inject
+    VMTemplateZoneDao templateZoneDao;
+    @Inject
+    VMTemplateDao templateDao;
+    @Inject DownloadMonitor _downloadMonitor;
+    @Inject 
+    VMTemplateHostDao _vmTemplateHostDao;
+    @Inject VolumeDao volumeDao;
+    @Inject VolumeHostDao volumeHostDao;
+    @Inject HostDao hostDao;
+    @Inject SnapshotDao snapshotDao;
+    @Inject AgentManager agentMgr;
+    @Inject SnapshotManager snapshotMgr;
+	@Inject
+    private SwiftManager _swiftMgr;
+    @Inject 
+    private S3Manager _s3Mgr; 
+    @Override
+    public String grantAccess(DataObject data, EndPoint ep) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public boolean revokeAccess(DataObject data, EndPoint ep) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    @Override
+    public Set<DataObject> listObjects(DataStore store) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    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) {
+        if (data.getType() == DataObjectType.TEMPLATE) {
+            List<VMTemplateZoneVO> templateZones = this.templateZoneDao.listByTemplateId(data.getId());
+            for (VMTemplateZoneVO templateZone : templateZones) {
+                VMTemplateVO template = this.templateDao.findById(data.getId());
+                _downloadMonitor.downloadTemplateToStorage(template, templateZone.getZoneId());
+            }
+        } else if (data.getType() == DataObjectType.VOLUME) {
+            VolumeVO vol = this.volumeDao.findById(data.getId());
+            VolumeInfo volInfo = (VolumeInfo)data;
+            RegisterVolumePayload payload = (RegisterVolumePayload)volInfo.getpayload();
+            _downloadMonitor.downloadVolumeToStorage(vol, vol.getDataCenterId(), payload.getUrl(),
+                    payload.getChecksum(), ImageFormat.valueOf(payload.getFormat().toUpperCase()));
+        }
+
+        CreateCmdResult result = new CreateCmdResult(null, null);
+        callback.complete(result);
+    }
+    
+    private void deleteVolume(DataObject data, AsyncCompletionCallback<CommandResult> callback) {
+        // TODO Auto-generated method stub
+        VolumeVO vol = volumeDao.findById(data.getId());
+        if (s_logger.isDebugEnabled()) {
+            s_logger.debug("Expunging " + vol);
+        }
+
+        // Find out if the volume is present on secondary storage
+        VolumeHostVO volumeHost = volumeHostDao.findByVolumeId(vol.getId());
+        if (volumeHost != null) {
+            if (volumeHost.getDownloadState() == VMTemplateStorageResourceAssoc.Status.DOWNLOADED) {
+                HostVO ssHost = hostDao.findById(volumeHost.getHostId());
+                DeleteVolumeCommand dtCommand = new DeleteVolumeCommand(
+                        ssHost.getStorageUrl(), volumeHost.getInstallPath());
+                Answer answer = agentMgr.sendToSecStorage(ssHost, dtCommand);
+                if (answer == null || !answer.getResult()) {
+                    s_logger.debug("Failed to delete "
+                            + volumeHost
+                            + " due to "
+                            + ((answer == null) ? "answer is null" : answer
+                                    .getDetails()));
+                    return;
+                }
+            } else if (volumeHost.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.");
+            }
+            volumeHostDao.remove(volumeHost.getId());
+            volumeDao.remove(vol.getId());
+            CommandResult result = new CommandResult();
+            callback.complete(result);
+            return;
+        }
+    }
+    
+    private void deleteTemplate(DataObject data, AsyncCompletionCallback<CommandResult> callback) {
+        
+    }
+    
+    private void deleteSnapshot(DataObject data, AsyncCompletionCallback<CommandResult> callback) {
+    	Long snapshotId = data.getId();
+    	SnapshotVO snapshot = this.snapshotDao.findByIdIncludingRemoved(snapshotId);
+    	CommandResult result = new CommandResult();
+    	if (snapshot == null) {
+    		s_logger.debug("Destroying snapshot " + snapshotId + " backup failed due to unable to find snapshot ");
+    		result.setResult("Unable to find snapshot: " + snapshotId);
+    		callback.complete(result);
+    		return;
+    	}
+
+    	try {
+    		String secondaryStoragePoolUrl = this.snapshotMgr.getSecondaryStorageURL(snapshot);
+    		Long dcId = snapshot.getDataCenterId();
+    		Long accountId = snapshot.getAccountId();
+    		Long volumeId = snapshot.getVolumeId();
+
+    		String backupOfSnapshot = snapshot.getBackupSnapshotId();
+    		if (backupOfSnapshot == null) {
+    			callback.complete(result);
+    			return;
+    		}
+    		SwiftTO swift = _swiftMgr.getSwiftTO(snapshot.getSwiftId());
+    		S3TO s3 = _s3Mgr.getS3TO();
+
+    		DeleteSnapshotBackupCommand cmd = new DeleteSnapshotBackupCommand(
+    				swift, s3, secondaryStoragePoolUrl, dcId, accountId, volumeId,
+    				backupOfSnapshot, false);
+    		Answer answer = agentMgr.sendToSSVM(dcId, cmd);
+
+    		if ((answer != null) && answer.getResult()) {
+    			snapshot.setBackupSnapshotId(null);
+    			snapshotDao.update(snapshotId, snapshot);
+    		} else if (answer != null) {
+    			result.setResult(answer.getDetails());
+    		}
+    	} catch (Exception e) {
+    		s_logger.debug("failed to delete snapshot: " + snapshotId + ": " + e.toString());
+    		result.setResult(e.toString());
+    	}
+    	callback.complete(result);
+    }
+    
+    @Override
+    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);
+        }
+    }
+
+    @Override
+    public void copyAsync(DataObject srcdata, DataObject destData,
+            AsyncCompletionCallback<CopyCommandResult> callback) {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public boolean canCopy(DataObject srcData, DataObject destData) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+	@Override
+	public void resize(DataObject data,
+			AsyncCompletionCallback<CreateCmdResult> callback) {
+		// TODO Auto-generated method stub
+		
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a872d6d3/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
new file mode 100644
index 0000000..7d22df5
--- /dev/null
+++ b/plugins/storage/image/s3/src/org/apache/cloudstack/storage/datastore/lifecycle/S3ImageStoreLifeCycleImpl.java
@@ -0,0 +1,177 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// 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;
+
+import javax.inject.Inject;
+
+import org.apache.cloudstack.api.ApiConstants;
+import org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
+import org.apache.cloudstack.engine.subsystem.api.storage.HostScope;
+import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
+import org.apache.cloudstack.storage.image.datastore.ImageStoreHelper;
+import org.apache.cloudstack.storage.image.datastore.ImageStoreProviderManager;
+import org.apache.cloudstack.storage.image.db.ImageStoreDao;
+import org.apache.cloudstack.storage.image.db.ImageStoreVO;
+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.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);
+    @Inject
+    protected ResourceManager _resourceMgr;
+    @Inject
+	protected ImageStoreDao imageStoreDao;
+	@Inject
+	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() {
+	}
+
+
+    @Override
+    public DataStore initialize(Map<String, Object> dsInfos) {
+
+        Long dcId = (Long) dsInfos.get("zoneId");
+        String url = (String) dsInfos.get("url");
+        String providerName = (String)dsInfos.get("providerName");
+        ScopeType scope = (ScopeType)dsInfos.get("scope");
+        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!");
+        }
+
+        Map<String, Object> imageStoreParameters = new HashMap<String, Object>();
+        imageStoreParameters.put("name", url);
+        imageStoreParameters.put("zoneId", dcId);
+        imageStoreParameters.put("url", url);
+        String protocol = "http";
+        String useHttps = details.get(ApiConstants.S3_HTTPS_FLAG);
+        if (useHttps != null && Boolean.parseBoolean(useHttps)){
+            protocol = "https";
+        }
+        imageStoreParameters.put("protocol", protocol);
+        if (scope != null) {
+            imageStoreParameters.put("scope", scope);
+        } else {
+            imageStoreParameters.put("scope", ScopeType.REGION);
+        }
+        imageStoreParameters.put("providerName", providerName);
+
+        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) {
+        // 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
+        return false;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a872d6d3/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
new file mode 100644
index 0000000..820882d
--- /dev/null
+++ b/plugins/storage/image/s3/src/org/apache/cloudstack/storage/datastore/provider/S3ImageStoreProviderImpl.java
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+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;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreLifeCycle;
+import org.apache.cloudstack.engine.subsystem.api.storage.HypervisorHostListener;
+import org.apache.cloudstack.engine.subsystem.api.storage.ImageStoreProvider;
+import org.apache.cloudstack.storage.datastore.driver.S3ImageStoreDriverImpl;
+import org.apache.cloudstack.storage.datastore.lifecycle.S3ImageStoreLifeCycleImpl;
+import org.apache.cloudstack.storage.image.ImageStoreDriver;
+import org.apache.cloudstack.storage.image.datastore.ImageStoreHelper;
+import org.apache.cloudstack.storage.image.datastore.ImageStoreProviderManager;
+import org.apache.cloudstack.storage.image.store.lifecycle.ImageStoreLifeCycle;
+import org.springframework.stereotype.Component;
+
+import com.cloud.storage.ScopeType;
+import com.cloud.utils.component.ComponentContext;
+
+@Component
+public class S3ImageStoreProviderImpl implements ImageStoreProvider {
+
+    private final String providerName = "S3 image store provider";
+    protected ImageStoreLifeCycle lifeCycle;
+    protected ImageStoreDriver driver;
+    @Inject
+    ImageStoreProviderManager storeMgr;
+    @Inject
+    ImageStoreHelper helper;
+
+    @Override
+    public DataStoreLifeCycle getDataStoreLifeCycle() {
+        return lifeCycle;
+    }
+
+    @Override
+    public String getName() {
+        return this.providerName;
+    }
+
+    @Override
+    public boolean configure(Map<String, Object> params) {
+        lifeCycle = ComponentContext.inject(S3ImageStoreLifeCycleImpl.class);
+        driver = ComponentContext.inject(S3ImageStoreDriverImpl.class);
+        storeMgr.registerDriver(this.getName(), driver);
+        return true;
+    }
+
+    @Override
+    public DataStoreDriver getDataStoreDriver() {
+        return this.driver;
+    }
+
+    @Override
+    public HypervisorHostListener getHostListener() {
+        return null;
+    }
+
+    @Override
+    public Set<DataStoreProviderType> getTypes() {
+        Set<DataStoreProviderType> types =  new HashSet<DataStoreProviderType>();
+        types.add(DataStoreProviderType.IMAGE);
+        return types;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a872d6d3/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/driver/SampleImageDataStoreDriverImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/driver/SampleImageDataStoreDriverImpl.java b/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/driver/SampleImageDataStoreDriverImpl.java
deleted file mode 100644
index cf42ac3..0000000
--- a/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/driver/SampleImageDataStoreDriverImpl.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cloudstack.storage.datastore.driver;
-
-import java.util.Set;
-
-import javax.inject.Inject;
-
-import org.apache.cloudstack.engine.subsystem.api.storage.CommandResult;
-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;
-import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectType;
-import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
-import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
-import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
-import org.apache.cloudstack.storage.command.CreateObjectAnswer;
-import org.apache.cloudstack.storage.command.CreateObjectCommand;
-import org.apache.cloudstack.storage.endpoint.EndPointSelector;
-import org.apache.cloudstack.storage.image.ImageDataStoreDriver;
-
-import com.cloud.storage.dao.VMTemplateDao;
-
-//http-read-only based image store
-public class SampleImageDataStoreDriverImpl implements ImageDataStoreDriver {
-    @Inject
-    EndPointSelector selector;
-    @Inject
-    VMTemplateDao imageDataDao;
-    public SampleImageDataStoreDriverImpl() {
-    }
-
-    @Override
-    public String grantAccess(DataObject data, EndPoint ep) {
-        return data.getUri();
-    }
-
-    @Override
-    public boolean revokeAccess(DataObject data, EndPoint ep) {
-        // TODO Auto-generated method stub
-        return true;
-    }
-
-    @Override
-    public Set<DataObject> listObjects(DataStore store) {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    @Override
-    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");
-            callback.complete(result);
-            return;
-        }
-        
-        if (data.getSize() == null && data.getType() == DataObjectType.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());
-                callback.complete(result);
-                return;
-            }
-            CreateObjectCommand createCmd = new CreateObjectCommand(data.getUri());
-            CreateObjectAnswer answer = (CreateObjectAnswer)ep.sendMessage(createCmd);
-            if (answer.getResult()) {
-                //update imagestorevo
-               
-                result = new CreateCmdResult(answer.getPath(), answer.getSize());
-            } else {
-                result.setResult(answer.getDetails());
-            }
-            
-        }
-        
-        callback.complete(result);
-    }
-
-    @Override
-    public void deleteAsync(DataObject data,
-            AsyncCompletionCallback<CommandResult> callback) {
-        CommandResult result = new CommandResult();
-        callback.complete(result);
-    }
-
-    @Override
-    public boolean canCopy(DataObject srcData, DataObject destData) {
-        // TODO Auto-generated method stub
-        return false;
-    }
-
-    @Override
-    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
-		
-	}
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a872d6d3/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
new file mode 100644
index 0000000..dc2e58c
--- /dev/null
+++ b/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/driver/SampleImageStoreDriverImpl.java
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cloudstack.storage.datastore.driver;
+
+import java.util.Set;
+
+import javax.inject.Inject;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.CommandResult;
+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;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectType;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
+import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
+import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
+import org.apache.cloudstack.storage.command.CreateObjectAnswer;
+import org.apache.cloudstack.storage.command.CreateObjectCommand;
+import org.apache.cloudstack.storage.endpoint.EndPointSelector;
+import org.apache.cloudstack.storage.image.ImageStoreDriver;
+
+import com.cloud.storage.dao.VMTemplateDao;
+
+//http-read-only based image store
+public class SampleImageStoreDriverImpl implements ImageStoreDriver {
+    @Inject
+    EndPointSelector selector;
+    @Inject
+    VMTemplateDao imageDataDao;
+    public SampleImageStoreDriverImpl() {
+    }
+
+    @Override
+    public String grantAccess(DataObject data, EndPoint ep) {
+        return data.getUri();
+    }
+
+    @Override
+    public boolean revokeAccess(DataObject data, EndPoint ep) {
+        // TODO Auto-generated method stub
+        return true;
+    }
+
+    @Override
+    public Set<DataObject> listObjects(DataStore store) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    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");
+            callback.complete(result);
+            return;
+        }
+        
+        if (data.getSize() == null && data.getType() == DataObjectType.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());
+                callback.complete(result);
+                return;
+            }
+            CreateObjectCommand createCmd = new CreateObjectCommand(data.getUri());
+            CreateObjectAnswer answer = (CreateObjectAnswer)ep.sendMessage(createCmd);
+            if (answer.getResult()) {
+                //update imagestorevo
+               
+                result = new CreateCmdResult(answer.getPath(), answer.getSize());
+            } else {
+                result.setResult(answer.getDetails());
+            }
+            
+        }
+        
+        callback.complete(result);
+    }
+
+    @Override
+    public void deleteAsync(DataObject data,
+            AsyncCompletionCallback<CommandResult> callback) {
+        CommandResult result = new CommandResult();
+        callback.complete(result);
+    }
+
+    @Override
+    public boolean canCopy(DataObject srcData, DataObject destData) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    @Override
+    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
+		
+	}
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a872d6d3/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/lifecycle/SampleImageDataStoreLifeCycle.java
----------------------------------------------------------------------
diff --git a/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/lifecycle/SampleImageDataStoreLifeCycle.java b/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/lifecycle/SampleImageDataStoreLifeCycle.java
deleted file mode 100644
index c1e0891..0000000
--- a/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/lifecycle/SampleImageDataStoreLifeCycle.java
+++ /dev/null
@@ -1,108 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package org.apache.cloudstack.storage.datastore.lifecycle;
-
-import java.util.Map;
-
-import javax.inject.Inject;
-
-import org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope;
-import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
-import org.apache.cloudstack.engine.subsystem.api.storage.HostScope;
-import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
-import org.apache.cloudstack.storage.image.datastore.ImageDataStoreHelper;
-import org.apache.cloudstack.storage.image.datastore.ImageDataStoreProviderManager;
-import org.apache.cloudstack.storage.image.db.ImageDataStoreDao;
-import org.apache.cloudstack.storage.image.db.ImageDataStoreVO;
-import org.apache.cloudstack.storage.image.store.lifecycle.ImageDataStoreLifeCycle;
-
-import com.cloud.agent.api.StoragePoolInfo;
-
-public class SampleImageDataStoreLifeCycle implements ImageDataStoreLifeCycle {
-    @Inject
-	protected ImageDataStoreDao imageStoreDao;
-	@Inject
-	ImageDataStoreHelper imageStoreHelper;
-	@Inject
-	ImageDataStoreProviderManager imageStoreMgr;
-	public SampleImageDataStoreLifeCycle() {
-	}
-
-
-    @Override
-    public DataStore initialize(Map<String, Object> dsInfos) {
-        ImageDataStoreVO ids = imageStoreHelper.createImageDataStore(dsInfos);
-        return imageStoreMgr.getImageDataStore(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) {
-        // 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
-        return false;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a872d6d3/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
new file mode 100644
index 0000000..8c61f03
--- /dev/null
+++ b/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/lifecycle/SampleImageStoreLifeCycleImpl.java
@@ -0,0 +1,108 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.storage.datastore.lifecycle;
+
+import java.util.Map;
+
+import javax.inject.Inject;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
+import org.apache.cloudstack.engine.subsystem.api.storage.HostScope;
+import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
+import org.apache.cloudstack.storage.image.datastore.ImageStoreHelper;
+import org.apache.cloudstack.storage.image.datastore.ImageStoreProviderManager;
+import org.apache.cloudstack.storage.image.db.ImageStoreDao;
+import org.apache.cloudstack.storage.image.db.ImageStoreVO;
+import org.apache.cloudstack.storage.image.store.lifecycle.ImageStoreLifeCycle;
+
+import com.cloud.agent.api.StoragePoolInfo;
+
+public class SampleImageStoreLifeCycleImpl implements ImageStoreLifeCycle {
+    @Inject
+	protected ImageStoreDao imageStoreDao;
+	@Inject
+	ImageStoreHelper imageStoreHelper;
+	@Inject
+	ImageStoreProviderManager imageStoreMgr;
+	public SampleImageStoreLifeCycleImpl() {
+	}
+
+
+    @Override
+    public DataStore initialize(Map<String, Object> dsInfos) {
+        ImageStoreVO ids = imageStoreHelper.createImageStore(dsInfos);
+        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) {
+        // 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
+        return false;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a872d6d3/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/provider/SampleImageDataStoreProvider.java
----------------------------------------------------------------------
diff --git a/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/provider/SampleImageDataStoreProvider.java b/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/provider/SampleImageDataStoreProvider.java
deleted file mode 100644
index 2ad9602..0000000
--- a/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/provider/SampleImageDataStoreProvider.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cloudstack.storage.datastore.provider;
-
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import javax.inject.Inject;
-
-import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver;
-import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreLifeCycle;
-import org.apache.cloudstack.engine.subsystem.api.storage.HypervisorHostListener;
-import org.apache.cloudstack.engine.subsystem.api.storage.ImageDataStoreProvider;
-import org.apache.cloudstack.storage.datastore.driver.SampleImageDataStoreDriverImpl;
-import org.apache.cloudstack.storage.datastore.lifecycle.SampleImageDataStoreLifeCycle;
-import org.apache.cloudstack.storage.image.ImageDataStoreDriver;
-import org.apache.cloudstack.storage.image.datastore.ImageDataStoreProviderManager;
-import org.apache.cloudstack.storage.image.store.lifecycle.ImageDataStoreLifeCycle;
-
-import com.cloud.utils.component.ComponentContext;
-
-public class SampleImageDataStoreProvider implements ImageDataStoreProvider {
-    private final String name = "sample image data store provider";
-    protected ImageDataStoreLifeCycle lifeCycle;
-    protected ImageDataStoreDriver driver;
-    @Inject
-    ImageDataStoreProviderManager storeMgr;
-    long id;
-    String uuid;
-    @Override
-    public DataStoreLifeCycle getDataStoreLifeCycle() {
-        return lifeCycle;
-    }
-
-    @Override
-    public String getName() {
-        return this.name;
-    }
-
-    @Override
-    public boolean configure(Map<String, Object> params) {
-        lifeCycle = ComponentContext.inject(SampleImageDataStoreLifeCycle.class);
-        driver = ComponentContext.inject(SampleImageDataStoreDriverImpl.class);
-
-        storeMgr.registerDriver(this.getName(), driver);
-        return true;
-    }
-
-    @Override
-    public Set<DataStoreProviderType> getTypes() {
-        Set<DataStoreProviderType> types =  new HashSet<DataStoreProviderType>();
-        types.add(DataStoreProviderType.IMAGE);
-        return types;
-    }
-
-    @Override
-    public DataStoreDriver getDataStoreDriver() {
-        return this.driver;
-    }
-
-    @Override
-    public HypervisorHostListener getHostListener() {
-        return null;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a872d6d3/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
new file mode 100644
index 0000000..073a157
--- /dev/null
+++ b/plugins/storage/image/sample/src/org/apache/cloudstack/storage/datastore/provider/SampleImageStoreProviderImpl.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cloudstack.storage.datastore.provider;
+
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.inject.Inject;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreLifeCycle;
+import org.apache.cloudstack.engine.subsystem.api.storage.HypervisorHostListener;
+import org.apache.cloudstack.engine.subsystem.api.storage.ImageStoreProvider;
+import org.apache.cloudstack.storage.datastore.driver.SampleImageStoreDriverImpl;
+import org.apache.cloudstack.storage.datastore.lifecycle.SampleImageStoreLifeCycleImpl;
+import org.apache.cloudstack.storage.image.ImageStoreDriver;
+import org.apache.cloudstack.storage.image.datastore.ImageStoreProviderManager;
+import org.apache.cloudstack.storage.image.store.lifecycle.ImageStoreLifeCycle;
+
+import com.cloud.utils.component.ComponentContext;
+
+public class SampleImageStoreProviderImpl implements ImageStoreProvider {
+    private final String name = "sample image data store provider";
+    protected ImageStoreLifeCycle lifeCycle;
+    protected ImageStoreDriver driver;
+    @Inject
+    ImageStoreProviderManager storeMgr;
+    long id;
+    String uuid;
+    @Override
+    public DataStoreLifeCycle getDataStoreLifeCycle() {
+        return lifeCycle;
+    }
+
+    @Override
+    public String getName() {
+        return this.name;
+    }
+
+    @Override
+    public boolean configure(Map<String, Object> params) {
+        lifeCycle = ComponentContext.inject(SampleImageStoreLifeCycleImpl.class);
+        driver = ComponentContext.inject(SampleImageStoreDriverImpl.class);
+
+        storeMgr.registerDriver(this.getName(), driver);
+        return true;
+    }
+
+    @Override
+    public Set<DataStoreProviderType> getTypes() {
+        Set<DataStoreProviderType> types =  new HashSet<DataStoreProviderType>();
+        types.add(DataStoreProviderType.IMAGE);
+        return types;
+    }
+
+    @Override
+    public DataStoreDriver getDataStoreDriver() {
+        return this.driver;
+    }
+
+    @Override
+    public HypervisorHostListener getHostListener() {
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a872d6d3/plugins/storage/image/swift/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/storage/image/swift/pom.xml b/plugins/storage/image/swift/pom.xml
new file mode 100644
index 0000000..27ebbe5
--- /dev/null
+++ b/plugins/storage/image/swift/pom.xml
@@ -0,0 +1,56 @@
+<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor 
+  license agreements. See the NOTICE file distributed with this work for additional 
+  information regarding copyright ownership. The ASF licenses this file to 
+  you under the Apache License, Version 2.0 (the "License"); you may not use 
+  this file except in compliance with the License. You may obtain a copy of 
+  the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required 
+  by applicable law or agreed to in writing, software distributed under the 
+  License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS 
+  OF ANY KIND, either express or implied. See the License for the specific 
+  language governing permissions and limitations under the License. -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>cloud-plugin-storage-image-swift</artifactId>
+  <name>Apache CloudStack Plugin - Storage Image Swift provider</name>
+  <parent>
+    <groupId>org.apache.cloudstack</groupId>
+    <artifactId>cloudstack-plugins</artifactId>
+    <version>4.2.0-SNAPSHOT</version>
+    <relativePath>../../../pom.xml</relativePath>
+  </parent>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.cloudstack</groupId>
+      <artifactId>cloud-engine-storage-image</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>mysql</groupId>
+      <artifactId>mysql-connector-java</artifactId>
+      <version>${cs.mysql.version}</version>
+      <scope>provided</scope>
+    </dependency>
+  </dependencies>
+  <build>
+    <defaultGoal>install</defaultGoal>
+    <sourceDirectory>src</sourceDirectory>
+    <testSourceDirectory>test</testSourceDirectory>
+    <plugins>
+      <plugin>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <skipTests>true</skipTests>
+        </configuration>
+        <executions>
+          <execution>
+            <phase>integration-test</phase>
+            <goals>
+              <goal>test</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a872d6d3/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
new file mode 100644
index 0000000..168e23a
--- /dev/null
+++ b/plugins/storage/image/swift/src/org/apache/cloudstack/storage/datastore/driver/SwiftImageStoreDriverImpl.java
@@ -0,0 +1,250 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cloudstack.storage.datastore.driver;
+
+import java.util.List;
+import java.util.Set;
+
+import javax.inject.Inject;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.CommandResult;
+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;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectType;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
+import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
+import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
+import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
+import org.apache.cloudstack.framework.async.AsyncRpcConext;
+import org.apache.cloudstack.storage.image.ImageStoreDriver;
+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.storage.DeleteVolumeCommand;
+import com.cloud.agent.api.to.S3TO;
+import com.cloud.agent.api.to.SwiftTO;
+import com.cloud.host.HostVO;
+import com.cloud.host.dao.HostDao;
+import com.cloud.storage.RegisterVolumePayload;
+import com.cloud.storage.Storage.ImageFormat;
+import com.cloud.storage.SnapshotVO;
+import com.cloud.storage.VMTemplateStorageResourceAssoc;
+import com.cloud.storage.VMTemplateVO;
+import com.cloud.storage.VMTemplateZoneVO;
+import com.cloud.storage.VolumeHostVO;
+import com.cloud.storage.VolumeVO;
+import com.cloud.storage.dao.SnapshotDao;
+import com.cloud.storage.dao.VMTemplateDao;
+import com.cloud.storage.dao.VMTemplateHostDao;
+import com.cloud.storage.dao.VMTemplateZoneDao;
+import com.cloud.storage.dao.VolumeDao;
+import com.cloud.storage.dao.VolumeHostDao;
+import com.cloud.storage.download.DownloadMonitor;
+import com.cloud.storage.s3.S3Manager;
+import com.cloud.storage.snapshot.SnapshotManager;
+import com.cloud.storage.swift.SwiftManager;
+import com.cloud.utils.exception.CloudRuntimeException;
+
+public class SwiftImageStoreDriverImpl implements ImageStoreDriver {
+    private static final Logger s_logger = Logger
+            .getLogger(SwiftImageStoreDriverImpl.class);
+    @Inject
+    VMTemplateZoneDao templateZoneDao;
+    @Inject
+    VMTemplateDao templateDao;
+    @Inject DownloadMonitor _downloadMonitor;
+    @Inject 
+    VMTemplateHostDao _vmTemplateHostDao;
+    @Inject VolumeDao volumeDao;
+    @Inject VolumeHostDao volumeHostDao;
+    @Inject HostDao hostDao;
+    @Inject SnapshotDao snapshotDao;
+    @Inject AgentManager agentMgr;
+    @Inject SnapshotManager snapshotMgr;
+	@Inject
+    private SwiftManager _swiftMgr;
+    @Inject 
+    private S3Manager _s3Mgr; 
+    @Override
+    public String grantAccess(DataObject data, EndPoint ep) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public boolean revokeAccess(DataObject data, EndPoint ep) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    @Override
+    public Set<DataObject> listObjects(DataStore store) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    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) {
+        if (data.getType() == DataObjectType.TEMPLATE) {
+            List<VMTemplateZoneVO> templateZones = this.templateZoneDao.listByTemplateId(data.getId());
+            for (VMTemplateZoneVO templateZone : templateZones) {
+                VMTemplateVO template = this.templateDao.findById(data.getId());
+                _downloadMonitor.downloadTemplateToStorage(template, templateZone.getZoneId());
+            }
+        } else if (data.getType() == DataObjectType.VOLUME) {
+            VolumeVO vol = this.volumeDao.findById(data.getId());
+            VolumeInfo volInfo = (VolumeInfo)data;
+            RegisterVolumePayload payload = (RegisterVolumePayload)volInfo.getpayload();
+            _downloadMonitor.downloadVolumeToStorage(vol, vol.getDataCenterId(), payload.getUrl(),
+                    payload.getChecksum(), ImageFormat.valueOf(payload.getFormat().toUpperCase()));
+        }
+
+        CreateCmdResult result = new CreateCmdResult(null, null);
+        callback.complete(result);
+    }
+    
+    private void deleteVolume(DataObject data, AsyncCompletionCallback<CommandResult> callback) {
+        // TODO Auto-generated method stub
+        VolumeVO vol = volumeDao.findById(data.getId());
+        if (s_logger.isDebugEnabled()) {
+            s_logger.debug("Expunging " + vol);
+        }
+
+        // Find out if the volume is present on secondary storage
+        VolumeHostVO volumeHost = volumeHostDao.findByVolumeId(vol.getId());
+        if (volumeHost != null) {
+            if (volumeHost.getDownloadState() == VMTemplateStorageResourceAssoc.Status.DOWNLOADED) {
+                HostVO ssHost = hostDao.findById(volumeHost.getHostId());
+                DeleteVolumeCommand dtCommand = new DeleteVolumeCommand(
+                        ssHost.getStorageUrl(), volumeHost.getInstallPath());
+                Answer answer = agentMgr.sendToSecStorage(ssHost, dtCommand);
+                if (answer == null || !answer.getResult()) {
+                    s_logger.debug("Failed to delete "
+                            + volumeHost
+                            + " due to "
+                            + ((answer == null) ? "answer is null" : answer
+                                    .getDetails()));
+                    return;
+                }
+            } else if (volumeHost.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.");
+            }
+            volumeHostDao.remove(volumeHost.getId());
+            volumeDao.remove(vol.getId());
+            CommandResult result = new CommandResult();
+            callback.complete(result);
+            return;
+        }
+    }
+    
+    private void deleteTemplate(DataObject data, AsyncCompletionCallback<CommandResult> callback) {
+        
+    }
+    
+    private void deleteSnapshot(DataObject data, AsyncCompletionCallback<CommandResult> callback) {
+    	Long snapshotId = data.getId();
+    	SnapshotVO snapshot = this.snapshotDao.findByIdIncludingRemoved(snapshotId);
+    	CommandResult result = new CommandResult();
+    	if (snapshot == null) {
+    		s_logger.debug("Destroying snapshot " + snapshotId + " backup failed due to unable to find snapshot ");
+    		result.setResult("Unable to find snapshot: " + snapshotId);
+    		callback.complete(result);
+    		return;
+    	}
+
+    	try {
+    		String secondaryStoragePoolUrl = this.snapshotMgr.getSecondaryStorageURL(snapshot);
+    		Long dcId = snapshot.getDataCenterId();
+    		Long accountId = snapshot.getAccountId();
+    		Long volumeId = snapshot.getVolumeId();
+
+    		String backupOfSnapshot = snapshot.getBackupSnapshotId();
+    		if (backupOfSnapshot == null) {
+    			callback.complete(result);
+    			return;
+    		}
+    		SwiftTO swift = _swiftMgr.getSwiftTO(snapshot.getSwiftId());
+    		S3TO s3 = _s3Mgr.getS3TO();
+
+    		DeleteSnapshotBackupCommand cmd = new DeleteSnapshotBackupCommand(
+    				swift, s3, secondaryStoragePoolUrl, dcId, accountId, volumeId,
+    				backupOfSnapshot, false);
+    		Answer answer = agentMgr.sendToSSVM(dcId, cmd);
+
+    		if ((answer != null) && answer.getResult()) {
+    			snapshot.setBackupSnapshotId(null);
+    			snapshotDao.update(snapshotId, snapshot);
+    		} else if (answer != null) {
+    			result.setResult(answer.getDetails());
+    		}
+    	} catch (Exception e) {
+    		s_logger.debug("failed to delete snapshot: " + snapshotId + ": " + e.toString());
+    		result.setResult(e.toString());
+    	}
+    	callback.complete(result);
+    }
+    
+    @Override
+    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);
+        }
+    }
+
+    @Override
+    public void copyAsync(DataObject srcdata, DataObject destData,
+            AsyncCompletionCallback<CopyCommandResult> callback) {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public boolean canCopy(DataObject srcData, DataObject destData) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+	@Override
+	public void resize(DataObject data,
+			AsyncCompletionCallback<CreateCmdResult> callback) {
+		// TODO Auto-generated method stub
+		
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a872d6d3/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
new file mode 100644
index 0000000..62dbfae
--- /dev/null
+++ b/plugins/storage/image/swift/src/org/apache/cloudstack/storage/datastore/lifecycle/SwiftImageStoreLifeCycleImpl.java
@@ -0,0 +1,161 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// 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;
+
+import javax.inject.Inject;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
+import org.apache.cloudstack.engine.subsystem.api.storage.HostScope;
+import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
+import org.apache.cloudstack.storage.image.datastore.ImageStoreHelper;
+import org.apache.cloudstack.storage.image.datastore.ImageStoreProviderManager;
+import org.apache.cloudstack.storage.image.db.ImageStoreDao;
+import org.apache.cloudstack.storage.image.db.ImageStoreVO;
+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.ScopeType;
+import com.cloud.utils.UriUtils;
+
+public class SwiftImageStoreLifeCycleImpl implements ImageStoreLifeCycle {
+
+    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 List<? extends Discoverer> _discoverers;
+    public List<? extends Discoverer> getDiscoverers() {
+        return _discoverers;
+    }
+    public void setDiscoverers(List<? extends Discoverer> _discoverers) {
+        this._discoverers = _discoverers;
+    }
+
+	public SwiftImageStoreLifeCycleImpl() {
+	}
+
+
+    @Override
+    public DataStore initialize(Map<String, Object> dsInfos) {
+
+        Long dcId = (Long) dsInfos.get("zoneId");
+        String url = (String) dsInfos.get("url");
+        ScopeType scope = (ScopeType)dsInfos.get("scope");
+        String providerName = (String)dsInfos.get("providerName");
+        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);
+
+        // just need to insert an entry in DB
+        Map<String, Object> imageStoreParameters = new HashMap<String, Object>();
+        imageStoreParameters.put("name", url);
+        imageStoreParameters.put("zoneId", dcId);
+        imageStoreParameters.put("url", url);
+        imageStoreParameters.put("protocol", "http");
+        if (scope != null) {
+            imageStoreParameters.put("scope", scope);
+        } else {
+            imageStoreParameters.put("scope", ScopeType.REGION);
+        }
+        imageStoreParameters.put("providerName", providerName);
+
+        ImageStoreVO ids = imageStoreHelper.createImageStore(imageStoreParameters);
+        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) {
+        // 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
+        return false;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a872d6d3/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
new file mode 100644
index 0000000..625fcff
--- /dev/null
+++ b/plugins/storage/image/swift/src/org/apache/cloudstack/storage/datastore/provider/SwiftImageStoreProviderImpl.java
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+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;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreLifeCycle;
+import org.apache.cloudstack.engine.subsystem.api.storage.HypervisorHostListener;
+import org.apache.cloudstack.engine.subsystem.api.storage.ImageStoreProvider;
+import org.apache.cloudstack.storage.datastore.driver.SwiftImageStoreDriverImpl;
+import org.apache.cloudstack.storage.datastore.lifecycle.SwiftImageStoreLifeCycleImpl;
+import org.apache.cloudstack.storage.image.ImageStoreDriver;
+import org.apache.cloudstack.storage.image.datastore.ImageStoreHelper;
+import org.apache.cloudstack.storage.image.datastore.ImageStoreProviderManager;
+import org.apache.cloudstack.storage.image.store.lifecycle.ImageStoreLifeCycle;
+import org.springframework.stereotype.Component;
+
+import com.cloud.storage.ScopeType;
+import com.cloud.utils.component.ComponentContext;
+
+@Component
+public class SwiftImageStoreProviderImpl implements ImageStoreProvider {
+
+    private final String providerName = "Swift image store provider";
+    protected ImageStoreLifeCycle lifeCycle;
+    protected ImageStoreDriver driver;
+    @Inject
+    ImageStoreProviderManager storeMgr;
+    @Inject
+    ImageStoreHelper helper;
+
+    @Override
+    public DataStoreLifeCycle getDataStoreLifeCycle() {
+        return lifeCycle;
+    }
+
+    @Override
+    public String getName() {
+        return this.providerName;
+    }
+
+    @Override
+    public boolean configure(Map<String, Object> params) {
+        lifeCycle = ComponentContext.inject(SwiftImageStoreLifeCycleImpl.class);
+        driver = ComponentContext.inject(SwiftImageStoreDriverImpl.class);
+
+        storeMgr.registerDriver(this.getName(), driver);
+
+        return true;
+    }
+
+    @Override
+    public DataStoreDriver getDataStoreDriver() {
+        return this.driver;
+    }
+
+    @Override
+    public HypervisorHostListener getHostListener() {
+        return null;
+    }
+
+    @Override
+    public Set<DataStoreProviderType> getTypes() {
+        Set<DataStoreProviderType> types =  new HashSet<DataStoreProviderType>();
+        types.add(DataStoreProviderType.IMAGE);
+        return types;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a872d6d3/server/src/com/cloud/api/ApiDBUtils.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiDBUtils.java b/server/src/com/cloud/api/ApiDBUtils.java
index 41f0759..6b8607f 100755
--- a/server/src/com/cloud/api/ApiDBUtils.java
+++ b/server/src/com/cloud/api/ApiDBUtils.java
@@ -34,7 +34,7 @@ import org.apache.cloudstack.api.response.DomainRouterResponse;
 import org.apache.cloudstack.api.response.EventResponse;
 import org.apache.cloudstack.api.response.HostResponse;
 import org.apache.cloudstack.api.response.InstanceGroupResponse;
-import org.apache.cloudstack.api.response.ObjectStoreResponse;
+import org.apache.cloudstack.api.response.ImageStoreResponse;
 import org.apache.cloudstack.api.response.ProjectAccountResponse;
 import org.apache.cloudstack.api.response.ProjectInvitationResponse;
 import org.apache.cloudstack.api.response.ProjectResponse;
@@ -56,7 +56,7 @@ import com.cloud.api.query.dao.DataCenterJoinDao;
 import com.cloud.api.query.dao.DiskOfferingJoinDao;
 import com.cloud.api.query.dao.DomainRouterJoinDao;
 import com.cloud.api.query.dao.HostJoinDao;
-import com.cloud.api.query.dao.ImageDataStoreJoinDao;
+import com.cloud.api.query.dao.ImageStoreJoinDao;
 import com.cloud.api.query.dao.InstanceGroupJoinDao;
 import com.cloud.api.query.dao.ProjectAccountJoinDao;
 import com.cloud.api.query.dao.ProjectInvitationJoinDao;
@@ -75,7 +75,7 @@ import com.cloud.api.query.vo.DiskOfferingJoinVO;
 import com.cloud.api.query.vo.DomainRouterJoinVO;
 import com.cloud.api.query.vo.EventJoinVO;
 import com.cloud.api.query.vo.HostJoinVO;
-import com.cloud.api.query.vo.ImageDataStoreJoinVO;
+import com.cloud.api.query.vo.ImageStoreJoinVO;
 import com.cloud.api.query.vo.InstanceGroupJoinVO;
 import com.cloud.api.query.vo.ProjectAccountJoinVO;
 import com.cloud.api.query.vo.ProjectInvitationJoinVO;
@@ -208,6 +208,7 @@ import com.cloud.service.dao.ServiceOfferingDao;
 import com.cloud.storage.DiskOfferingVO;
 import com.cloud.storage.GuestOS;
 import com.cloud.storage.GuestOSCategoryVO;
+import com.cloud.storage.ImageStore;
 import com.cloud.storage.Snapshot;
 import com.cloud.storage.SnapshotVO;
 import com.cloud.storage.Storage.ImageFormat;
@@ -365,7 +366,7 @@ public class ApiDBUtils {
     static HostJoinDao _hostJoinDao;
     static VolumeJoinDao _volJoinDao;
     static StoragePoolJoinDao _poolJoinDao;
-    static ImageDataStoreJoinDao _imageStoreJoinDao;
+    static ImageStoreJoinDao _imageStoreJoinDao;
     static AccountJoinDao _accountJoinDao;
     static AsyncJobJoinDao _jobJoinDao;
 
@@ -470,7 +471,7 @@ public class ApiDBUtils {
     @Inject private HostJoinDao hostJoinDao;
     @Inject private VolumeJoinDao volJoinDao;
     @Inject private StoragePoolJoinDao poolJoinDao;
-    @Inject private ImageDataStoreJoinDao imageStoreJoinDao;
+    @Inject private ImageStoreJoinDao imageStoreJoinDao;
     @Inject private AccountJoinDao accountJoinDao;
     @Inject private AsyncJobJoinDao jobJoinDao;
 
@@ -1541,16 +1542,16 @@ public class ApiDBUtils {
         return _poolJoinDao.newStoragePoolView(vr);
     }
 
-    public static ObjectStoreResponse newImageStoreResponse(ImageDataStoreJoinVO vr) {
-        return _imageStoreJoinDao.newObjectStoreResponse(vr);
+    public static ImageStoreResponse newImageStoreResponse(ImageStoreJoinVO vr) {
+        return _imageStoreJoinDao.newImageStoreResponse(vr);
     }
 
-    public static ObjectStoreResponse fillImageStoreDetails(ObjectStoreResponse vrData, ImageDataStoreJoinVO vr){
-        return _imageStoreJoinDao.setObjectStoreResponse(vrData, vr);
+    public static ImageStoreResponse fillImageStoreDetails(ImageStoreResponse vrData, ImageStoreJoinVO vr){
+        return _imageStoreJoinDao.setImageStoreResponse(vrData, vr);
     }
 
-    public static List<ImageDataStoreJoinVO> newImageStoreView(ObjectStore vr){
-        return _imageStoreJoinDao.newObjectStoreView(vr);
+    public static List<ImageStoreJoinVO> newImageStoreView(ImageStore vr){
+        return _imageStoreJoinDao.newImageStoreView(vr);
     }
 
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a872d6d3/server/src/com/cloud/api/ApiResponseHelper.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java
index 03ed97d..5272045 100755
--- a/server/src/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/com/cloud/api/ApiResponseHelper.java
@@ -80,7 +80,7 @@ import org.apache.cloudstack.api.response.NetworkOfferingResponse;
 import org.apache.cloudstack.api.response.NetworkResponse;
 import org.apache.cloudstack.api.response.NicResponse;
 import org.apache.cloudstack.api.response.NicSecondaryIpResponse;
-import org.apache.cloudstack.api.response.ObjectStoreResponse;
+import org.apache.cloudstack.api.response.ImageStoreResponse;
 import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
 import org.apache.cloudstack.api.response.PodResponse;
 import org.apache.cloudstack.api.response.PrivateGatewayResponse;
@@ -142,7 +142,7 @@ import com.cloud.api.query.vo.DiskOfferingJoinVO;
 import com.cloud.api.query.vo.DomainRouterJoinVO;
 import com.cloud.api.query.vo.EventJoinVO;
 import com.cloud.api.query.vo.HostJoinVO;
-import com.cloud.api.query.vo.ImageDataStoreJoinVO;
+import com.cloud.api.query.vo.ImageStoreJoinVO;
 import com.cloud.api.query.vo.InstanceGroupJoinVO;
 import com.cloud.api.query.vo.ProjectAccountJoinVO;
 import com.cloud.api.query.vo.ProjectInvitationJoinVO;
@@ -237,7 +237,7 @@ import com.cloud.service.ServiceOfferingVO;
 import com.cloud.storage.DiskOfferingVO;
 import com.cloud.storage.GuestOS;
 import com.cloud.storage.GuestOSCategoryVO;
-import com.cloud.storage.ObjectStore;
+import com.cloud.storage.ImageStore;
 import com.cloud.storage.S3;
 import com.cloud.storage.Snapshot;
 import com.cloud.storage.SnapshotVO;
@@ -892,9 +892,9 @@ public class ApiResponseHelper implements ResponseGenerator {
 
 
     @Override
-    public ObjectStoreResponse createObjectStoreResponse(ObjectStore os) {
-        List<ImageDataStoreJoinVO> viewStores = ApiDBUtils.newImageStoreView(os);
-        List<ObjectStoreResponse> listStores = ViewResponseHelper.createObjectStoreResponse(viewStores.toArray(new ImageDataStoreJoinVO[viewStores.size()]));
+    public ImageStoreResponse createImageStoreResponse(ImageStore os) {
+        List<ImageStoreJoinVO> viewStores = ApiDBUtils.newImageStoreView(os);
+        List<ImageStoreResponse> listStores = ViewResponseHelper.createObjectStoreResponse(viewStores.toArray(new ImageStoreJoinVO[viewStores.size()]));
         assert listStores != null && listStores.size() == 1 : "There should be one image data store returned";
         return listStores.get(0);
 


Mime
View raw message