cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mc...@apache.org
Subject [47/57] [abbrv] git commit: updated refs/heads/object_store to a872d6d
Date Sat, 06 Apr 2013 00:35:20 GMT
Move previous AncientImageDataStore provider and DefaultImageDataStore
provider code into plugins.


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

Branch: refs/heads/object_store
Commit: a5416797ab2b3a93171e7d9ffa5832ed19988f9f
Parents: b0cbe26
Author: Min Chen <min.chen@citrix.com>
Authored: Fri Mar 29 16:35:13 2013 -0700
Committer: Min Chen <min.chen@citrix.com>
Committed: Fri Apr 5 11:18:32 2013 -0700

----------------------------------------------------------------------
 .../driver/AncientImageDataStoreDriverImpl.java    |  250 ---------------
 .../driver/DefaultImageDataStoreDriverImpl.java    |  126 --------
 .../image/store/AncientImageDataStoreProvider.java |  101 ------
 .../image/store/DefaultImageDataStoreProvider.java |   82 -----
 .../lifecycle/DefaultImageDataStoreLifeCycle.java  |  107 ------
 .../storage/allocator/StorageAllocatorTest.java    |    4 +-
 .../cloudstack/storage/test/volumeServiceTest.java |    8 +-
 .../provider/DataStoreProviderManagerImpl.java     |    2 +-
 .../driver/DefaultPrimaryDataStoreDriverImpl.java  |  249 --------------
 .../DefaultPrimaryDataStoreLifeCycleImpl.java      |  147 ---------
 .../DefaultPrimaryDatastoreProviderImpl.java       |   83 -----
 .../storage/volume/test/ConfiguratorTest.java      |    4 +-
 plugins/pom.xml                                    |    3 +
 plugins/storage/image/default/pom.xml              |   56 ++++
 .../driver/CloudStackImageDataStoreDriverImpl.java |  250 +++++++++++++++
 .../CloudStackImageDataStoreLifeCycle.java         |  108 +++++++
 .../provider/CloudStackImageDataStoreProvider.java |  101 ++++++
 plugins/storage/image/sample/pom.xml               |   56 ++++
 .../driver/SampleImageDataStoreDriverImpl.java     |  126 ++++++++
 .../lifecycle/SampleImageDataStoreLifeCycle.java   |  108 +++++++
 .../provider/SampleImageDataStoreProvider.java     |   82 +++++
 .../CloudStackPrimaryDataStoreProviderImpl.java    |    8 +-
 plugins/storage/volume/sample/pom.xml              |   56 ++++
 .../driver/SamplePrimaryDataStoreDriverImpl.java   |  249 ++++++++++++++
 .../SamplePrimaryDataStoreLifeCycleImpl.java       |  147 +++++++++
 .../SamplePrimaryDatastoreProviderImpl.java        |   83 +++++
 .../SolidfirePrimaryDataStoreProvider.java         |   52 +++-
 27 files changed, 1482 insertions(+), 1166 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a5416797/engine/storage/image/src/org/apache/cloudstack/storage/image/driver/AncientImageDataStoreDriverImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/driver/AncientImageDataStoreDriverImpl.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/driver/AncientImageDataStoreDriverImpl.java
deleted file mode 100644
index 97ea6c4..0000000
--- a/engine/storage/image/src/org/apache/cloudstack/storage/image/driver/AncientImageDataStoreDriverImpl.java
+++ /dev/null
@@ -1,250 +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.image.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.ImageDataStoreDriver;
-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 AncientImageDataStoreDriverImpl implements ImageDataStoreDriver {
-    private static final Logger s_logger = Logger
-            .getLogger(AncientImageDataStoreDriverImpl.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/a5416797/engine/storage/image/src/org/apache/cloudstack/storage/image/driver/DefaultImageDataStoreDriverImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/driver/DefaultImageDataStoreDriverImpl.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/driver/DefaultImageDataStoreDriverImpl.java
deleted file mode 100644
index 3d46c73..0000000
--- a/engine/storage/image/src/org/apache/cloudstack/storage/image/driver/DefaultImageDataStoreDriverImpl.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.image.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 DefaultImageDataStoreDriverImpl implements ImageDataStoreDriver {
-    @Inject
-    EndPointSelector selector;
-    @Inject
-    VMTemplateDao imageDataDao;
-    public DefaultImageDataStoreDriverImpl() {
-    }
-
-    @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/a5416797/engine/storage/image/src/org/apache/cloudstack/storage/image/store/AncientImageDataStoreProvider.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/store/AncientImageDataStoreProvider.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/store/AncientImageDataStoreProvider.java
deleted file mode 100644
index 2715dc7..0000000
--- a/engine/storage/image/src/org/apache/cloudstack/storage/image/store/AncientImageDataStoreProvider.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.image.store;
-
-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.engine.subsystem.api.storage.ScopeType;
-import org.apache.cloudstack.storage.image.ImageDataStoreDriver;
-import org.apache.cloudstack.storage.image.datastore.ImageDataStoreHelper;
-import org.apache.cloudstack.storage.image.datastore.ImageDataStoreManager;
-import org.apache.cloudstack.storage.image.driver.AncientImageDataStoreDriverImpl;
-import org.apache.cloudstack.storage.image.store.lifecycle.DefaultImageDataStoreLifeCycle;
-import org.apache.cloudstack.storage.image.store.lifecycle.ImageDataStoreLifeCycle;
-import org.springframework.stereotype.Component;
-
-import com.cloud.utils.component.ComponentContext;
-
-@Component
-public class AncientImageDataStoreProvider implements ImageDataStoreProvider {
-
-    private final String name = "ancient image data store";
-    protected ImageDataStoreLifeCycle lifeCycle;
-    protected ImageDataStoreDriver driver;
-    @Inject
-    ImageDataStoreManager 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(DefaultImageDataStoreLifeCycle.class);
-        driver = ComponentContext.inject(AncientImageDataStoreDriverImpl.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/a5416797/engine/storage/image/src/org/apache/cloudstack/storage/image/store/DefaultImageDataStoreProvider.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/store/DefaultImageDataStoreProvider.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/store/DefaultImageDataStoreProvider.java
deleted file mode 100644
index 0b5de85..0000000
--- a/engine/storage/image/src/org/apache/cloudstack/storage/image/store/DefaultImageDataStoreProvider.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.image.store;
-
-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.image.ImageDataStoreDriver;
-import org.apache.cloudstack.storage.image.datastore.ImageDataStoreManager;
-import org.apache.cloudstack.storage.image.driver.DefaultImageDataStoreDriverImpl;
-import org.apache.cloudstack.storage.image.store.lifecycle.DefaultImageDataStoreLifeCycle;
-import org.apache.cloudstack.storage.image.store.lifecycle.ImageDataStoreLifeCycle;
-
-import com.cloud.utils.component.ComponentContext;
-
-public class DefaultImageDataStoreProvider implements ImageDataStoreProvider {
-    private final String name = "default image data store";
-    protected ImageDataStoreLifeCycle lifeCycle;
-    protected ImageDataStoreDriver driver;
-    @Inject
-    ImageDataStoreManager 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(DefaultImageDataStoreLifeCycle.class);
-        driver = ComponentContext.inject(DefaultImageDataStoreDriverImpl.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/a5416797/engine/storage/image/src/org/apache/cloudstack/storage/image/store/lifecycle/DefaultImageDataStoreLifeCycle.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/store/lifecycle/DefaultImageDataStoreLifeCycle.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/store/lifecycle/DefaultImageDataStoreLifeCycle.java
deleted file mode 100644
index ba29c1a..0000000
--- a/engine/storage/image/src/org/apache/cloudstack/storage/image/store/lifecycle/DefaultImageDataStoreLifeCycle.java
+++ /dev/null
@@ -1,107 +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.image.store.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.ImageDataStoreManager;
-import org.apache.cloudstack.storage.image.db.ImageDataStoreDao;
-import org.apache.cloudstack.storage.image.db.ImageDataStoreVO;
-
-import com.cloud.agent.api.StoragePoolInfo;
-
-public class DefaultImageDataStoreLifeCycle implements ImageDataStoreLifeCycle {
-    @Inject
-	protected ImageDataStoreDao imageStoreDao;
-	@Inject
-	ImageDataStoreHelper imageStoreHelper;
-	@Inject
-	ImageDataStoreManager imageStoreMgr;
-	public DefaultImageDataStoreLifeCycle() {
-	}
-
-
-    @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/a5416797/engine/storage/integration-test/test/org/apache/cloudstack/storage/allocator/StorageAllocatorTest.java
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/allocator/StorageAllocatorTest.java b/engine/storage/integration-test/test/org/apache/cloudstack/storage/allocator/StorageAllocatorTest.java
index 9444fa5..c6ebf2e 100644
--- a/engine/storage/integration-test/test/org/apache/cloudstack/storage/allocator/StorageAllocatorTest.java
+++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/allocator/StorageAllocatorTest.java
@@ -121,7 +121,7 @@ public class StorageAllocatorTest {
 		cluster = clusterDao.persist(cluster);
 		clusterId = cluster.getId();
 
-		DataStoreProvider provider = providerMgr.getDataStoreProvider("ancient primary data store provider");
+		DataStoreProvider provider = providerMgr.getDataStoreProvider("cloudstack primary data store provider");
 		storage = new StoragePoolVO();
 		storage.setDataCenterId(dcId);
 		storage.setPodId(podId);
@@ -164,7 +164,7 @@ public class StorageAllocatorTest {
 		try {
 			createDb();
 			
-			DataStoreProvider provider = providerMgr.getDataStoreProvider("ancient primary data store provider");
+			DataStoreProvider provider = providerMgr.getDataStoreProvider("cloudstack primary data store provider");
 			storage = new StoragePoolVO();
 			storage.setDataCenterId(dcId);
 			storage.setPodId(podId);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a5416797/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/volumeServiceTest.java
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/volumeServiceTest.java b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/volumeServiceTest.java
index 35a1790..b542e85 100644
--- a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/volumeServiceTest.java
+++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/volumeServiceTest.java
@@ -262,7 +262,7 @@ public class volumeServiceTest extends CloudStackTestNGBase {
 	
 	@Test
 	public void testCreatePrimaryStorage() {
-	    DataStoreProvider provider = dataStoreProviderMgr.getDataStoreProvider("default primary data store provider");
+	    DataStoreProvider provider = dataStoreProviderMgr.getDataStoreProvider("sample primary data store provider");
         Map<String, Object> params = new HashMap<String, Object>();
         URI uri = null;
         try {
@@ -290,7 +290,7 @@ public class volumeServiceTest extends CloudStackTestNGBase {
 	}
 	
 	private DataStore createImageStore() {
-	    DataStoreProvider provider = dataStoreProviderMgr.getDataStoreProvider("default image data store");
+	    DataStoreProvider provider = dataStoreProviderMgr.getDataStoreProvider("sample image data store provider");
         Map<String, Object> params = new HashMap<String, Object>();
         String name = UUID.randomUUID().toString();
         params.put("name", name);
@@ -310,7 +310,7 @@ public class volumeServiceTest extends CloudStackTestNGBase {
 
 	public DataStore createPrimaryDataStore() {
 		try {
-		    DataStoreProvider provider = dataStoreProviderMgr.getDataStoreProvider("default primary data store provider");
+		    DataStoreProvider provider = dataStoreProviderMgr.getDataStoreProvider("sample primary data store provider");
 		    Map<String, Object> params = new HashMap<String, Object>();
 		    URI uri = new URI(this.getPrimaryStorageUrl());
 		    params.put("url", this.getPrimaryStorageUrl());
@@ -331,7 +331,7 @@ public class volumeServiceTest extends CloudStackTestNGBase {
 		    lifeCycle.attachCluster(store, scope);
 		    
 		    /*
-		    PrimaryDataStoreProvider provider = primaryDataStoreProviderMgr.getDataStoreProvider("default primary data store provider");
+		    PrimaryDataStoreProvider provider = primaryDataStoreProviderMgr.getDataStoreProvider("sample primary data store provider");
 		    primaryDataStoreProviderMgr.configure("primary data store mgr", new HashMap<String, Object>());
             
 		    List<PrimaryDataStoreVO> ds = primaryStoreDao.findPoolByName(this.primaryName);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a5416797/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/DataStoreProviderManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/DataStoreProviderManagerImpl.java b/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/DataStoreProviderManagerImpl.java
index 91b6c63..f7d7167 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/DataStoreProviderManagerImpl.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/datastore/provider/DataStoreProviderManagerImpl.java
@@ -129,7 +129,7 @@ public class DataStoreProviderManagerImpl extends ManagerBase implements DataSto
 
     @Override
     public DataStoreProvider getDefaultPrimaryDataStoreProvider() {
-        return this.getDataStoreProvider("ancient primary data store provider");
+        return this.getDataStoreProvider("cloudstack primary data store provider");
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a5416797/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/driver/DefaultPrimaryDataStoreDriverImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/driver/DefaultPrimaryDataStoreDriverImpl.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/driver/DefaultPrimaryDataStoreDriverImpl.java
deleted file mode 100644
index 6d0c2c6..0000000
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/driver/DefaultPrimaryDataStoreDriverImpl.java
+++ /dev/null
@@ -1,249 +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.net.URISyntaxException;
-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.DataStore;
-import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
-import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreDriver;
-import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
-import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher;
-import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
-import org.apache.cloudstack.framework.async.AsyncRpcConext;
-import org.apache.cloudstack.storage.command.CreateObjectAnswer;
-import org.apache.cloudstack.storage.command.CreateObjectCommand;
-import org.apache.cloudstack.storage.command.DeleteCommand;
-import org.apache.cloudstack.storage.datastore.DataObjectManager;
-import org.apache.cloudstack.storage.endpoint.EndPointSelector;
-import org.apache.log4j.Logger;
-
-import com.cloud.agent.api.Answer;
-import com.cloud.storage.dao.StoragePoolHostDao;
-import com.cloud.utils.exception.CloudRuntimeException;
-import com.cloud.utils.storage.encoding.DecodedDataObject;
-import com.cloud.utils.storage.encoding.Decoder;
-
-
-public class DefaultPrimaryDataStoreDriverImpl implements PrimaryDataStoreDriver {
-    private static final Logger s_logger = Logger.getLogger(DefaultPrimaryDataStoreDriverImpl.class);
-    @Inject
-    EndPointSelector selector;
-    @Inject
-    StoragePoolHostDao storeHostDao;
-    @Inject
-    DataObjectManager dataObjMgr;
-    public DefaultPrimaryDataStoreDriverImpl() {
-        
-    }
-    
-    private class CreateVolumeContext<T> extends AsyncRpcConext<T> {
-        private final DataObject volume;
-        /**
-         * @param callback
-         */
-        public CreateVolumeContext(AsyncCompletionCallback<T> callback, DataObject volume) {
-            super(callback);
-            this.volume = volume;
-        }
-        
-        public DataObject getVolume() {
-            return this.volume;
-        }
-        
-    }
-    
-    public Void createAsyncCallback(AsyncCallbackDispatcher<DefaultPrimaryDataStoreDriverImpl, Answer> callback, CreateVolumeContext<CreateCmdResult> context) {
-        CreateCmdResult result = null;
-        CreateObjectAnswer volAnswer = (CreateObjectAnswer) callback.getResult();
-        if (volAnswer.getResult()) {
-            result = new CreateCmdResult(volAnswer.getPath(), volAnswer.getSize());
-        } else {
-            result = new CreateCmdResult("", null);
-            result.setResult(volAnswer.getDetails());
-        }
-        
-        context.getParentCallback().complete(result);
-        return null;
-    }
-  
-    @Override
-    public void deleteAsync(DataObject vo, AsyncCompletionCallback<CommandResult> callback) {
-        DeleteCommand cmd = new DeleteCommand(vo.getUri());
-    
-        EndPoint ep = selector.select(vo);
-        AsyncRpcConext<CommandResult> context = new AsyncRpcConext<CommandResult>(callback);
-        AsyncCallbackDispatcher<DefaultPrimaryDataStoreDriverImpl, Answer> caller = AsyncCallbackDispatcher.create(this);
-        caller.setCallback(caller.getTarget().deleteCallback(null, null))
-            .setContext(context);
-        ep.sendMessageAsync(cmd, caller);
-    }
-    
-    public Void deleteCallback(AsyncCallbackDispatcher<DefaultPrimaryDataStoreDriverImpl, Answer> callback, AsyncRpcConext<CommandResult> context) {
-        CommandResult result = new CommandResult();
-        Answer answer = callback.getResult();
-        if (!answer.getResult()) {
-            result.setResult(answer.getDetails());
-        }
-        context.getParentCallback().complete(result);
-        return null;
-    }
-    /*
-    private class CreateVolumeFromBaseImageContext<T> extends AsyncRpcConext<T> {
-        private final VolumeObject volume;
-      
-        public CreateVolumeFromBaseImageContext(AsyncCompletionCallback<T> callback, VolumeObject volume) {
-            super(callback);
-            this.volume = volume;
-        }
-        
-        public VolumeObject getVolume() {
-            return this.volume;
-        }
-        
-    }
-
-    @Override
-    public void createVolumeFromBaseImageAsync(VolumeObject volume, TemplateInfo template, AsyncCompletionCallback<CommandResult> callback) {
-        VolumeTO vol = this.dataStore.getVolumeTO(volume);
-        List<EndPoint> endPoints = this.dataStore.getEndPoints();
-        EndPoint ep = endPoints.get(0);
-        String templateUri = template.getDataStore().grantAccess(template, ep);
-        CreateVolumeFromBaseImageCommand cmd = new CreateVolumeFromBaseImageCommand(vol, templateUri);
-        
-        CreateVolumeFromBaseImageContext<CommandResult> context = new CreateVolumeFromBaseImageContext<CommandResult>(callback, volume);
-        AsyncCallbackDispatcher<DefaultPrimaryDataStoreDriverImpl, Answer> caller = AsyncCallbackDispatcher.create(this);
-        caller.setContext(context)
-            .setCallback(caller.getTarget().createVolumeFromBaseImageAsyncCallback(null, null));
-
-        ep.sendMessageAsync(cmd, caller);
-    }*/
-    /*
-    public Object createVolumeFromBaseImageAsyncCallback(AsyncCallbackDispatcher<DefaultPrimaryDataStoreDriverImpl, Answer> callback, CreateVolumeFromBaseImageContext<CommandResult> context) {
-        CreateVolumeAnswer answer = (CreateVolumeAnswer)callback.getResult();
-        CommandResult result = new CommandResult();
-        if (answer == null || answer.getDetails() != null) {
-            result.setSucess(false);
-            if (answer != null) {
-                result.setResult(answer.getDetails());
-            }
-        } else {
-            result.setSucess(true);
-            VolumeObject volume = context.getVolume();
-            volume.setPath(answer.getVolumeUuid());
-        }
-        AsyncCompletionCallback<CommandResult> parentCall = context.getParentCallback();
-        parentCall.complete(result);
-        return null;
-    }*/
-
-    @Override
-    public void createAsync(DataObject vol,
-            AsyncCompletionCallback<CreateCmdResult> callback) {
-        EndPoint ep = selector.select(vol);
-        CreateObjectCommand createCmd = new CreateObjectCommand(vol.getUri());
-        
-        CreateVolumeContext<CreateCmdResult> context = new CreateVolumeContext<CreateCmdResult>(callback, vol);
-        AsyncCallbackDispatcher<DefaultPrimaryDataStoreDriverImpl, Answer> caller = AsyncCallbackDispatcher.create(this);
-        caller.setContext(context)
-            .setCallback(caller.getTarget().createAsyncCallback(null, null));
-
-        ep.sendMessageAsync(createCmd, caller);
-    }
-
-    @Override
-    public String grantAccess(DataObject object, EndPoint ep) {
-        //StoragePoolHostVO poolHost = storeHostDao.findByPoolHost(object.getDataStore().getId(), ep.getId());
-        
-        String uri = object.getUri();
-        try {
-            DecodedDataObject obj = Decoder.decode(uri);
-            if (obj.getPath() == null) {
-                //create an obj
-                EndPoint newEp = selector.select(object);
-                CreateObjectCommand createCmd = new CreateObjectCommand(uri);
-                CreateObjectAnswer answer = (CreateObjectAnswer)ep.sendMessage(createCmd);
-                if (answer.getResult()) {
-                    dataObjMgr.update(object, answer.getPath(), answer.getSize());
-                } else {
-                    s_logger.debug("failed to create object" + answer.getDetails());
-                    throw new CloudRuntimeException("failed to create object" + answer.getDetails());
-                }
-            }
-            
-            return object.getUri();
-        } catch (URISyntaxException e) {
-           throw new CloudRuntimeException("uri parsed error", e);
-        }
-    }
-
-    @Override
-    public boolean revokeAccess(DataObject vol, EndPoint ep) {
-        // TODO Auto-generated method stub
-        return false;
-    }
-
-    @Override
-    public Set<DataObject> listObjects(DataStore store) {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    @Override
-    public void revertSnapshot(SnapshotInfo snapshot,
-            AsyncCompletionCallback<CommandResult> callback) {
-        // TODO Auto-generated method stub
-        
-    }
-
-    
-
-    @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
-		
-	}
-
-	@Override
-	public void takeSnapshot(SnapshotInfo snapshot,
-			AsyncCompletionCallback<CreateCmdResult> callback) {
-		// TODO Auto-generated method stub
-		
-	}
-   
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a5416797/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/lifecycle/DefaultPrimaryDataStoreLifeCycleImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/lifecycle/DefaultPrimaryDataStoreLifeCycleImpl.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/lifecycle/DefaultPrimaryDataStoreLifeCycleImpl.java
deleted file mode 100644
index fea02e8..0000000
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/lifecycle/DefaultPrimaryDataStoreLifeCycleImpl.java
+++ /dev/null
@@ -1,147 +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.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.EndPoint;
-import org.apache.cloudstack.engine.subsystem.api.storage.HostScope;
-import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreLifeCycle;
-import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
-import org.apache.cloudstack.storage.command.AttachPrimaryDataStoreCmd;
-import org.apache.cloudstack.storage.command.CreatePrimaryDataStoreCmd;
-import org.apache.cloudstack.storage.datastore.PrimaryDataStoreProviderManager;
-import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
-import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
-import org.apache.cloudstack.storage.endpoint.EndPointSelector;
-import org.apache.cloudstack.storage.volume.datastore.PrimaryDataStoreHelper;
-
-import com.cloud.agent.api.StoragePoolInfo;
-import com.cloud.host.HostVO;
-import com.cloud.host.dao.HostDao;
-import com.cloud.hypervisor.Hypervisor.HypervisorType;
-import com.cloud.storage.StoragePoolStatus;
-
-public class DefaultPrimaryDataStoreLifeCycleImpl implements PrimaryDataStoreLifeCycle {
-    @Inject
-    EndPointSelector selector;
-    @Inject
-    PrimaryDataStoreDao dataStoreDao;
-    @Inject
-    HostDao hostDao;
-    @Inject
-    PrimaryDataStoreHelper primaryStoreHelper;
-    @Inject
-    PrimaryDataStoreProviderManager providerMgr;
-    public DefaultPrimaryDataStoreLifeCycleImpl() {
-    }
-    
-    @Override
-    public DataStore initialize(Map<String, Object> dsInfos) {
-        
-        DataStore store = primaryStoreHelper.createPrimaryDataStore(null); 
-        return providerMgr.getPrimaryDataStore(store.getId());
-    }
-
-    protected void attachCluster(DataStore store) {
-        //send down AttachPrimaryDataStoreCmd command to all the hosts in the cluster
-        List<EndPoint> endPoints = selector.selectAll(store);
-        CreatePrimaryDataStoreCmd createCmd = new CreatePrimaryDataStoreCmd(store.getUri());
-        EndPoint ep = endPoints.get(0);
-        HostVO host = hostDao.findById(ep.getId());
-        if (host.getHypervisorType() == HypervisorType.XenServer) {
-            ep.sendMessage(createCmd);
-        }
-        
-        endPoints.get(0).sendMessage(createCmd);
-        AttachPrimaryDataStoreCmd cmd = new AttachPrimaryDataStoreCmd(store.getUri());
-        for (EndPoint endp : endPoints) {
-            endp.sendMessage(cmd);
-        }
-    }
-    
-    @Override
-    public boolean attachCluster(DataStore dataStore, ClusterScope scope) {
-        StoragePoolVO dataStoreVO = dataStoreDao.findById(dataStore.getId());
-        dataStoreVO.setDataCenterId(scope.getZoneId());
-        dataStoreVO.setPodId(scope.getPodId());
-        dataStoreVO.setClusterId(scope.getScopeId());
-        dataStoreVO.setStatus(StoragePoolStatus.Attaching);
-        dataStoreVO.setScope(scope.getScopeType());
-        dataStoreDao.update(dataStoreVO.getId(), dataStoreVO);
-        
-        
-        attachCluster(dataStore);
-        
-        dataStoreVO = dataStoreDao.findById(dataStore.getId());
-        dataStoreVO.setStatus(StoragePoolStatus.Up);
-        dataStoreDao.update(dataStoreVO.getId(), dataStoreVO);
-        
-        return true;
-    }
-
-    @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 attachZone(DataStore dataStore, ZoneScope 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 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/a5416797/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/provider/DefaultPrimaryDatastoreProviderImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/provider/DefaultPrimaryDatastoreProviderImpl.java b/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/provider/DefaultPrimaryDatastoreProviderImpl.java
deleted file mode 100644
index 46fa738..0000000
--- a/engine/storage/volume/src/org/apache/cloudstack/storage/datastore/provider/DefaultPrimaryDatastoreProviderImpl.java
+++ /dev/null
@@ -1,83 +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.DataStoreLifeCycle;
-import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider;
-import org.apache.cloudstack.engine.subsystem.api.storage.HypervisorHostListener;
-import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreDriver;
-import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreProvider;
-import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider.DataStoreProviderType;
-import org.apache.cloudstack.storage.datastore.PrimaryDataStoreProviderManager;
-import org.apache.cloudstack.storage.datastore.driver.DefaultPrimaryDataStoreDriverImpl;
-import org.apache.cloudstack.storage.datastore.lifecycle.DefaultPrimaryDataStoreLifeCycleImpl;
-
-import com.cloud.utils.component.ComponentContext;
-
-
-public class DefaultPrimaryDatastoreProviderImpl implements PrimaryDataStoreProvider {
-    private final String providerName = "default primary data store provider";
-    protected PrimaryDataStoreDriver driver;
-    protected HypervisorHostListener listener;
-    @Inject
-    PrimaryDataStoreProviderManager storeMgr;
-
-    protected DataStoreLifeCycle lifecyle;
-    protected String uuid;
-    protected long id;
-    @Override
-    public String getName() {
-        return providerName;
-    }
-
-    @Override
-    public DataStoreLifeCycle getDataStoreLifeCycle() {
-        return this.lifecyle;
-    }
-
-    @Override
-    public boolean configure(Map<String, Object> params) {
-        lifecyle = ComponentContext.inject(DefaultPrimaryDataStoreLifeCycleImpl.class);
-        driver = ComponentContext.inject(DefaultPrimaryDataStoreDriverImpl.class);
-        listener = ComponentContext.inject(DefaultHostListener.class);
-        return true;
-    }
-
-    @Override
-    public PrimaryDataStoreDriver getDataStoreDriver() {
-        return this.driver;
-    }
-
-    @Override
-    public HypervisorHostListener getHostListener() {
-        return this.listener;
-    }
-    
-    @Override
-    public Set<DataStoreProviderType> getTypes() {
-        Set<DataStoreProviderType> types =  new HashSet<DataStoreProviderType>();
-        types.add(DataStoreProviderType.PRIMARY);
-        return types;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a5416797/engine/storage/volume/test/org/apache/cloudstack/storage/volume/test/ConfiguratorTest.java
----------------------------------------------------------------------
diff --git a/engine/storage/volume/test/org/apache/cloudstack/storage/volume/test/ConfiguratorTest.java b/engine/storage/volume/test/org/apache/cloudstack/storage/volume/test/ConfiguratorTest.java
index 122c353..6ad951a 100644
--- a/engine/storage/volume/test/org/apache/cloudstack/storage/volume/test/ConfiguratorTest.java
+++ b/engine/storage/volume/test/org/apache/cloudstack/storage/volume/test/ConfiguratorTest.java
@@ -79,12 +79,12 @@ public class ConfiguratorTest {
     
     @Test
     public void getProvider() {
-       // assertNotNull(providerMgr.getDataStoreProvider("default primary data store provider"));
+       // assertNotNull(providerMgr.getDataStoreProvider("sample primary data store provider"));
     }
     
     @Test
     public void createDataStore() {
-        /*PrimaryDataStoreProvider provider = providerMgr.getDataStoreProvider("default primary data store provider");
+        /*PrimaryDataStoreProvider provider = providerMgr.getDataStoreProvider("sample primary data store provider");
         Map<String, String> params = new HashMap<String, String>();
         params.put("url", "nfs://localhost/mnt");
         params.put("clusterId", "1");

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a5416797/plugins/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/pom.xml b/plugins/pom.xml
index 607c50c..a4f37bb 100755
--- a/plugins/pom.xml
+++ b/plugins/pom.xml
@@ -58,8 +58,11 @@
     <module>user-authenticators/sha256salted</module>
     <module>network-elements/dns-notifier</module>
     <module>storage/image/s3</module>
+    <module>storage/image/default</module>
+    <module>storage/image/sample</module>    
     <module>storage/volume/solidfire</module>
     <module>storage/volume/default</module>
+    <module>storage/volume/sample</module>
     <module>alert-handlers/snmp-alerts</module>
     <module>alert-handlers/syslog-alerts</module>
   </modules>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a5416797/plugins/storage/image/default/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/storage/image/default/pom.xml b/plugins/storage/image/default/pom.xml
new file mode 100644
index 0000000..e84eab4
--- /dev/null
+++ b/plugins/storage/image/default/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-default</artifactId>
+  <name>Apache CloudStack Plugin - Storage Image default 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/a5416797/plugins/storage/image/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackImageDataStoreDriverImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/image/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackImageDataStoreDriverImpl.java b/plugins/storage/image/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackImageDataStoreDriverImpl.java
new file mode 100644
index 0000000..1ff395c
--- /dev/null
+++ b/plugins/storage/image/default/src/org/apache/cloudstack/storage/datastore/driver/CloudStackImageDataStoreDriverImpl.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.ImageDataStoreDriver;
+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 CloudStackImageDataStoreDriverImpl implements ImageDataStoreDriver {
+    private static final Logger s_logger = Logger
+            .getLogger(CloudStackImageDataStoreDriverImpl.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/a5416797/plugins/storage/image/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackImageDataStoreLifeCycle.java
----------------------------------------------------------------------
diff --git a/plugins/storage/image/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackImageDataStoreLifeCycle.java b/plugins/storage/image/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackImageDataStoreLifeCycle.java
new file mode 100644
index 0000000..d896517
--- /dev/null
+++ b/plugins/storage/image/default/src/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackImageDataStoreLifeCycle.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.ImageDataStoreHelper;
+import org.apache.cloudstack.storage.image.datastore.ImageDataStoreManager;
+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 CloudStackImageDataStoreLifeCycle implements ImageDataStoreLifeCycle {
+    @Inject
+	protected ImageDataStoreDao imageStoreDao;
+	@Inject
+	ImageDataStoreHelper imageStoreHelper;
+	@Inject
+	ImageDataStoreManager imageStoreMgr;
+	public CloudStackImageDataStoreLifeCycle() {
+	}
+
+
+    @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/a5416797/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
new file mode 100644
index 0000000..1358c9f
--- /dev/null
+++ b/plugins/storage/image/default/src/org/apache/cloudstack/storage/datastore/provider/CloudStackImageDataStoreProvider.java
@@ -0,0 +1,101 @@
+/*
+ * 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.engine.subsystem.api.storage.ScopeType;
+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.ImageDataStoreManager;
+import org.apache.cloudstack.storage.image.store.lifecycle.ImageDataStoreLifeCycle;
+import org.springframework.stereotype.Component;
+
+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
+    ImageDataStoreManager 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/a5416797/plugins/storage/image/sample/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/storage/image/sample/pom.xml b/plugins/storage/image/sample/pom.xml
new file mode 100644
index 0000000..e4d5ac2
--- /dev/null
+++ b/plugins/storage/image/sample/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-sample</artifactId>
+  <name>Apache CloudStack Plugin - Storage Image sample 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>


Mime
View raw message