cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bfede...@apache.org
Subject [35/51] [abbrv] squash changes into one giant patch
Date Thu, 21 Feb 2013 21:45:19 GMT
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a22403ed/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
new file mode 100644
index 0000000..2c19c7f
--- /dev/null
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/driver/AncientImageDataStoreDriverImpl.java
@@ -0,0 +1,187 @@
+/*
+ * 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.storage.DeleteVolumeCommand;
+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.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.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.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 AgentManager agentMgr;
+    @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) {
+        
+    }
+    
+    @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);
+        }
+       
+
+       
+    }
+
+    @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;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a22403ed/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
index dce5a93..1a506fa 100644
--- 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
@@ -34,15 +34,15 @@ 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 org.apache.cloudstack.storage.image.db.ImageDataDao;
-import org.apache.cloudstack.storage.image.db.ImageDataVO;
+
+import com.cloud.storage.dao.VMTemplateDao;
 
 //http-read-only based image store
 public class DefaultImageDataStoreDriverImpl implements ImageDataStoreDriver {
     @Inject
     EndPointSelector selector;
     @Inject
-    ImageDataDao imageDataDao;
+    VMTemplateDao imageDataDao;
     public DefaultImageDataStoreDriverImpl() {
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a22403ed/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataManager.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataManager.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataManager.java
index e5a6863..e1fd46b 100644
--- a/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataManager.java
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataManager.java
@@ -18,13 +18,13 @@
  */
 package org.apache.cloudstack.storage.image.manager;
 
-import org.apache.cloudstack.storage.image.TemplateEvent;
-import org.apache.cloudstack.storage.image.TemplateState;
-import org.apache.cloudstack.storage.image.db.ImageDataVO;
+import org.apache.cloudstack.engine.subsystem.api.storage.TemplateEvent;
+import org.apache.cloudstack.engine.subsystem.api.storage.TemplateState;
 
+import com.cloud.storage.VMTemplateVO;
 import com.cloud.utils.fsm.StateMachine2;
 
 public interface ImageDataManager {
-    StateMachine2<TemplateState, TemplateEvent, ImageDataVO> getStateMachine();
+    StateMachine2<TemplateState, TemplateEvent, VMTemplateVO> getStateMachine();
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a22403ed/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataManagerImpl.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataManagerImpl.java
index d90f2b6..83e9887 100644
--- a/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataManagerImpl.java
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataManagerImpl.java
@@ -18,17 +18,17 @@
  */
 package org.apache.cloudstack.storage.image.manager;
 
-import org.apache.cloudstack.storage.image.TemplateEvent;
-import org.apache.cloudstack.storage.image.TemplateState;
-import org.apache.cloudstack.storage.image.db.ImageDataVO;
+import org.apache.cloudstack.engine.subsystem.api.storage.TemplateEvent;
+import org.apache.cloudstack.engine.subsystem.api.storage.TemplateState;
 import org.springframework.stereotype.Component;
 
+import com.cloud.storage.VMTemplateVO;
 import com.cloud.utils.fsm.StateMachine2;
 
 @Component
 public class ImageDataManagerImpl implements ImageDataManager {
-    private final StateMachine2<TemplateState, TemplateEvent, ImageDataVO> 
-        stateMachine = new StateMachine2<TemplateState, TemplateEvent, ImageDataVO>();
+    private final StateMachine2<TemplateState, TemplateEvent, VMTemplateVO> 
+        stateMachine = new StateMachine2<TemplateState, TemplateEvent, VMTemplateVO>();
     
     public ImageDataManagerImpl() {
         stateMachine.addTransition(TemplateState.Allocated, TemplateEvent.CreateRequested, TemplateState.Creating);
@@ -44,7 +44,7 @@ public class ImageDataManagerImpl implements ImageDataManager {
     }
     
     @Override
-    public StateMachine2<TemplateState, TemplateEvent, ImageDataVO> getStateMachine() {
+    public StateMachine2<TemplateState, TemplateEvent, VMTemplateVO> getStateMachine() {
         return stateMachine;
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a22403ed/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataStoreManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataStoreManagerImpl.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataStoreManagerImpl.java
index 68a2770..2771f78 100644
--- a/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataStoreManagerImpl.java
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataStoreManagerImpl.java
@@ -18,38 +18,48 @@
  */
 package org.apache.cloudstack.storage.image.manager;
 
+import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
+import javax.annotation.PostConstruct;
 import javax.inject.Inject;
 
-import org.apache.cloudstack.storage.datastore.provider.DataStoreProviderManager;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProviderManager;
 import org.apache.cloudstack.storage.datastore.provider.ImageDataStoreProvider;
 import org.apache.cloudstack.storage.image.ImageDataStoreDriver;
 import org.apache.cloudstack.storage.image.datastore.ImageDataStore;
 import org.apache.cloudstack.storage.image.datastore.ImageDataStoreManager;
-import org.apache.cloudstack.storage.image.db.ImageDataDao;
 import org.apache.cloudstack.storage.image.db.ImageDataStoreDao;
 import org.apache.cloudstack.storage.image.db.ImageDataStoreVO;
-import org.apache.cloudstack.storage.image.store.HttpDataStoreImpl;
+import org.apache.cloudstack.storage.image.store.DefaultImageDataStoreImpl;
 import org.springframework.stereotype.Component;
 
+import com.cloud.storage.dao.VMTemplateDao;
+
 @Component
 public class ImageDataStoreManagerImpl implements ImageDataStoreManager {
     @Inject
     ImageDataStoreDao dataStoreDao;
     @Inject
-    ImageDataDao imageDataDao;
+    VMTemplateDao imageDataDao;
     @Inject
     DataStoreProviderManager providerManager;
-    Map<String, ImageDataStoreDriver> driverMaps = new HashMap<String, ImageDataStoreDriver>();
+    Map<String, ImageDataStoreDriver> driverMaps;
 
+    @PostConstruct
+    public void config() {
+        driverMaps = new HashMap<String, ImageDataStoreDriver>();
+    }
+    
     @Override
     public ImageDataStore getImageDataStore(long dataStoreId) {
         ImageDataStoreVO dataStore = dataStoreDao.findById(dataStoreId);
         long providerId = dataStore.getProvider();
         ImageDataStoreProvider provider = (ImageDataStoreProvider)providerManager.getDataStoreProviderById(providerId);
-        ImageDataStore imgStore = HttpDataStoreImpl.getDataStore(dataStore, 
+        ImageDataStore imgStore = DefaultImageDataStoreImpl.getDataStore(dataStore, 
                 driverMaps.get(provider.getUuid()), provider
                 );
         // TODO Auto-generated method stub
@@ -65,4 +75,20 @@ public class ImageDataStoreManagerImpl implements ImageDataStoreManager {
         return true;
     }
 
+    @Override
+    public ImageDataStore getImageDataStore(String uuid) {
+        ImageDataStoreVO dataStore = dataStoreDao.findByUuid(uuid);
+        return getImageDataStore(dataStore.getId());
+    }
+
+    @Override
+    public List<DataStore> getList() {
+        List<ImageDataStoreVO> stores = dataStoreDao.listAll();
+        List<DataStore> imageStores = new ArrayList<DataStore>();
+        for (ImageDataStoreVO store : stores) {
+            imageStores.add(getImageDataStore(store.getId()));
+        }
+        return imageStores;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a22403ed/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
new file mode 100644
index 0000000..b2ee9ab
--- /dev/null
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/store/AncientImageDataStoreProvider.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.image.store;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+
+import javax.inject.Inject;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreLifeCycle;
+import org.apache.cloudstack.engine.subsystem.api.storage.ScopeType;
+import org.apache.cloudstack.storage.datastore.provider.ImageDataStoreProvider;
+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;
+    long id;
+    String uuid;
+    @Override
+    public DataStoreLifeCycle getLifeCycle() {
+        return lifeCycle;
+    }
+
+    @Override
+    public String getName() {
+        return this.name;
+    }
+
+    @Override
+    public String getUuid() {
+        return this.uuid;
+    }
+
+    @Override
+    public long getId() {
+        return this.id;
+    }
+
+    @Override
+    public boolean configure(Map<String, Object> params) {
+        lifeCycle = ComponentContext.inject(DefaultImageDataStoreLifeCycle.class);
+        driver = ComponentContext.inject(AncientImageDataStoreDriverImpl.class);
+        uuid = (String)params.get("uuid");
+        id = (Long)params.get("id");
+        storeMgr.registerDriver(uuid, 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("provider", this.getId());
+        DataStoreLifeCycle lifeCycle = this.getLifeCycle();
+        lifeCycle.initialize(infos);
+        return true;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a22403ed/engine/storage/image/src/org/apache/cloudstack/storage/image/store/DefaultImageDataStoreImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/store/DefaultImageDataStoreImpl.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/store/DefaultImageDataStoreImpl.java
new file mode 100644
index 0000000..d159f74
--- /dev/null
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/store/DefaultImageDataStoreImpl.java
@@ -0,0 +1,145 @@
+/*
+ * 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.Set;
+
+import javax.inject.Inject;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreRole;
+import org.apache.cloudstack.engine.subsystem.api.storage.Scope;
+import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
+import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo;
+import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
+import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
+import org.apache.cloudstack.storage.datastore.ObjectInDataStoreManager;
+import org.apache.cloudstack.storage.datastore.provider.ImageDataStoreProvider;
+import org.apache.cloudstack.storage.image.ImageDataStoreDriver;
+import org.apache.cloudstack.storage.image.datastore.ImageDataStore;
+import org.apache.cloudstack.storage.image.db.ImageDataStoreVO;
+
+import com.cloud.storage.dao.VMTemplateDao;
+import com.cloud.utils.component.ComponentContext;
+import com.cloud.utils.storage.encoding.EncodingType;
+
+
+public class DefaultImageDataStoreImpl implements ImageDataStore {
+    @Inject
+    VMTemplateDao imageDao;
+    @Inject
+    private ObjectInDataStoreManager objectInStoreMgr;
+    protected ImageDataStoreDriver driver;
+    protected ImageDataStoreVO imageDataStoreVO;
+    protected ImageDataStoreProvider provider;
+    boolean needDownloadToCacheStorage = false;
+
+    protected DefaultImageDataStoreImpl() {
+     
+    }
+    
+    protected void configure(ImageDataStoreVO dataStoreVO, ImageDataStoreDriver imageDataStoreDriver,
+            ImageDataStoreProvider provider) {
+        this.driver = imageDataStoreDriver;
+        this.imageDataStoreVO = dataStoreVO;
+        this.provider = provider;
+    }
+
+    public static ImageDataStore getDataStore(ImageDataStoreVO dataStoreVO, ImageDataStoreDriver imageDataStoreDriver,
+            ImageDataStoreProvider provider) {
+        DefaultImageDataStoreImpl instance = (DefaultImageDataStoreImpl)ComponentContext.inject(DefaultImageDataStoreImpl.class);
+        instance.configure(dataStoreVO, imageDataStoreDriver, provider);
+        return instance;
+    }
+
+    @Override
+    public Set<TemplateInfo> listTemplates() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public DataStoreDriver getDriver() {
+        // TODO Auto-generated method stub
+        return this.driver;
+    }
+
+    @Override
+    public DataStoreRole getRole() {
+        // TODO Auto-generated method stub
+        return DataStoreRole.Image;
+    }
+    @Override
+    public long getId() {
+        // TODO Auto-generated method stub
+        return this.imageDataStoreVO.getId();
+    }
+
+    @Override
+    public String getUri() {
+        return this.imageDataStoreVO.getProtocol() + "://" + "?" + EncodingType.ROLE + "=" + this.getRole();
+    }
+
+    @Override
+    public Scope getScope() {
+        return new ZoneScope(imageDataStoreVO.getDcId());
+    }
+
+    @Override
+    public TemplateInfo getTemplate(long templateId) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public VolumeInfo getVolume(long volumeId) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public SnapshotInfo getSnapshot(long snapshotId) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public boolean exists(DataObject object) {
+        return (objectInStoreMgr.findObject(object,
+                this) != null) ? true : false;
+    }
+
+    @Override
+    public String getUuid() {
+        return this.imageDataStoreVO.getUuid();
+    }
+
+    @Override
+    public DataObject create(DataObject obj) {
+        DataObject object = objectInStoreMgr.create(obj, this);
+        return object;
+    }
+
+    @Override
+    public boolean delete(DataObject obj) {
+        // TODO Auto-generated method stub
+        return false;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a22403ed/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
index 3569fe8..efbb999 100644
--- 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
@@ -29,11 +29,9 @@ 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 org.springframework.stereotype.Component;
 
 import com.cloud.utils.component.ComponentContext;
 
-@Component
 public class DefaultImageDataStoreProvider implements ImageDataStoreProvider {
     private final String name = "default image data store";
     protected ImageDataStoreLifeCycle lifeCycle;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a22403ed/engine/storage/image/src/org/apache/cloudstack/storage/image/store/HttpDataStoreImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/store/HttpDataStoreImpl.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/store/HttpDataStoreImpl.java
deleted file mode 100644
index 34b4ff2..0000000
--- a/engine/storage/image/src/org/apache/cloudstack/storage/image/store/HttpDataStoreImpl.java
+++ /dev/null
@@ -1,144 +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.Set;
-
-import javax.inject.Inject;
-
-import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
-import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver;
-import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreRole;
-import org.apache.cloudstack.engine.subsystem.api.storage.Scope;
-import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
-import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
-import org.apache.cloudstack.storage.datastore.ObjectInDataStoreManager;
-import org.apache.cloudstack.storage.datastore.provider.ImageDataStoreProvider;
-import org.apache.cloudstack.storage.image.ImageDataStoreDriver;
-import org.apache.cloudstack.storage.image.TemplateInfo;
-import org.apache.cloudstack.storage.image.datastore.ImageDataStore;
-import org.apache.cloudstack.storage.image.db.ImageDataDao;
-import org.apache.cloudstack.storage.image.db.ImageDataStoreVO;
-import org.apache.cloudstack.storage.snapshot.SnapshotInfo;
-
-import com.cloud.utils.component.ComponentContext;
-import com.cloud.utils.storage.encoding.EncodingType;
-
-
-public class HttpDataStoreImpl implements ImageDataStore {
-    @Inject
-    ImageDataDao imageDao;
-    @Inject
-    private ObjectInDataStoreManager objectInStoreMgr;
-    protected ImageDataStoreDriver driver;
-    protected ImageDataStoreVO imageDataStoreVO;
-    protected ImageDataStoreProvider provider;
-    boolean needDownloadToCacheStorage = false;
-
-    protected HttpDataStoreImpl() {
-     
-    }
-    
-    protected void configure(ImageDataStoreVO dataStoreVO, ImageDataStoreDriver imageDataStoreDriver,
-            ImageDataStoreProvider provider) {
-        this.driver = imageDataStoreDriver;
-        this.imageDataStoreVO = dataStoreVO;
-        this.provider = provider;
-    }
-
-    public static HttpDataStoreImpl getDataStore(ImageDataStoreVO dataStoreVO, ImageDataStoreDriver imageDataStoreDriver,
-            ImageDataStoreProvider provider) {
-        HttpDataStoreImpl instance = (HttpDataStoreImpl)ComponentContext.inject(HttpDataStoreImpl.class);
-        instance.configure(dataStoreVO, imageDataStoreDriver, provider);
-        return instance;
-    }
-
-    @Override
-    public Set<TemplateInfo> listTemplates() {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    @Override
-    public DataStoreDriver getDriver() {
-        // TODO Auto-generated method stub
-        return this.driver;
-    }
-
-
-
-    @Override
-    public DataStoreRole getRole() {
-        // TODO Auto-generated method stub
-        return DataStoreRole.Image;
-    }
-
-
-
-    @Override
-    public long getId() {
-        // TODO Auto-generated method stub
-        return this.imageDataStoreVO.getId();
-    }
-
-
-
-    @Override
-    public String getUri() {
-        return this.imageDataStoreVO.getProtocol() + "://" + "?" + EncodingType.ROLE + "=" + this.getRole();
-    }
-
-    @Override
-    public Scope getScope() {
-        // TODO Auto-generated method stub
-        return new ZoneScope(imageDataStoreVO.getDcId());
-    }
-
-
-
-    @Override
-    public TemplateInfo getTemplate(long templateId) {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-
-
-    @Override
-    public VolumeInfo getVolume(long volumeId) {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-
-
-    @Override
-    public SnapshotInfo getSnapshot(long snapshotId) {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-
-
-    @Override
-    public boolean exists(DataObject object) {
-        return (objectInStoreMgr.findObject(object.getId(), object.getType(),
-                this.getId(), this.getRole()) != null) ? true : false;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a22403ed/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java b/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java
index 1b0661c..85bc0c1 100644
--- a/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java
@@ -20,44 +20,48 @@ package org.apache.cloudstack.storage.image.store;
 
 import javax.inject.Inject;
 
+import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
 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.ObjectInDataStoreStateMachine;
+import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine.Event;
+import org.apache.cloudstack.engine.subsystem.api.storage.TemplateEvent;
+import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo;
 import org.apache.cloudstack.engine.subsystem.api.storage.disktype.DiskFormat;
 import org.apache.cloudstack.storage.datastore.ObjectInDataStoreManager;
-import org.apache.cloudstack.storage.db.ObjectInDataStoreVO;
-import org.apache.cloudstack.storage.image.TemplateEvent;
-import org.apache.cloudstack.storage.image.TemplateInfo;
-import org.apache.cloudstack.storage.image.db.ImageDataDao;
-import org.apache.cloudstack.storage.image.db.ImageDataVO;
 import org.apache.cloudstack.storage.image.manager.ImageDataManager;
-import org.apache.cloudstack.storage.volume.ObjectInDataStoreStateMachine;
 import org.apache.log4j.Logger;
 
+import com.cloud.storage.VMTemplateVO;
+import com.cloud.storage.dao.VMTemplateDao;
+import com.cloud.storage.dao.VMTemplatePoolDao;
 import com.cloud.utils.component.ComponentContext;
+import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.utils.fsm.NoTransitionException;
 import com.cloud.utils.storage.encoding.EncodingType;
 
 public class TemplateObject implements TemplateInfo {
     private static final Logger s_logger = Logger
             .getLogger(TemplateObject.class);
-    private ImageDataVO imageVO;
+    private VMTemplateVO imageVO;
     private DataStore dataStore;
     @Inject
     ImageDataManager imageMgr;
     @Inject
-    ImageDataDao imageDao;
+    VMTemplateDao imageDao;
     @Inject
     ObjectInDataStoreManager ojbectInStoreMgr;
+    @Inject VMTemplatePoolDao templatePoolDao;
 
     protected TemplateObject() {
     }
 
-    protected void configure(ImageDataVO template, DataStore dataStore) {
+    protected void configure(VMTemplateVO template, DataStore dataStore) {
         this.imageVO = template;
         this.dataStore = dataStore;
     }
 
-    public static TemplateObject getTemplate(ImageDataVO vo, DataStore store) {
+    public static TemplateObject getTemplate(VMTemplateVO vo, DataStore store) {
         TemplateObject to = ComponentContext.inject(TemplateObject.class);
         to.configure(vo, store);
         return to;
@@ -66,12 +70,12 @@ public class TemplateObject implements TemplateInfo {
     public void setImageStoreId(long id) {
         this.imageVO.setImageDataStoreId(id);
     }
-    
+
     public void setSize(Long size) {
         this.imageVO.setSize(size);
     }
 
-    public ImageDataVO getImage() {
+    public VMTemplateVO getImage() {
         return this.imageVO;
     }
 
@@ -87,23 +91,20 @@ public class TemplateObject implements TemplateInfo {
 
     @Override
     public String getUuid() {
-        // TODO Auto-generated method stub
-        return null;
+        return this.imageVO.getUuid();
     }
 
     @Override
     public String getUri() {
-        ImageDataVO image = imageDao.findById(this.imageVO.getId());
+        VMTemplateVO image = imageDao.findById(this.imageVO.getId());
         if (this.dataStore == null) {
             return image.getUrl();
         } else {
-            ObjectInDataStoreVO obj = ojbectInStoreMgr.findObject(
-                    this.imageVO.getId(), DataObjectType.TEMPLATE,
-                    this.dataStore.getId(), this.dataStore.getRole());
+            DataObjectInStore obj = ojbectInStoreMgr.findObject(this, this.dataStore);
             StringBuilder builder = new StringBuilder();
             if (obj.getState() == ObjectInDataStoreStateMachine.State.Ready
                     || obj.getState() == ObjectInDataStoreStateMachine.State.Copying) {
-                
+
                 builder.append(this.dataStore.getUri());
                 builder.append("&" + EncodingType.OBJTYPE + "=" + DataObjectType.TEMPLATE);
                 builder.append("&" + EncodingType.PATH + "=" + obj.getInstallPath());
@@ -124,10 +125,33 @@ public class TemplateObject implements TemplateInfo {
         if (this.dataStore == null) {
             return this.imageVO.getSize();
         }
-        ObjectInDataStoreVO obj = ojbectInStoreMgr.findObject(
-                this.imageVO.getId(), DataObjectType.TEMPLATE,
-                this.dataStore.getId(), this.dataStore.getRole());
-        return obj.getSize();
+
+        /*
+
+// If the template that was passed into this allocator is not installed in the storage pool,
+            // add 3 * (template size on secondary storage) to the running total
+            VMTemplateHostVO templateHostVO = _storageMgr.findVmTemplateHost(templateForVmCreation.getId(), null);
+
+            if (templateHostVO == null) {
+                VMTemplateSwiftVO templateSwiftVO = _swiftMgr.findByTmpltId(templateForVmCreation.getId());
+                if (templateSwiftVO != null) {                                    
+                    long templateSize = templateSwiftVO.getPhysicalSize();
+                    if (templateSize == 0) {
+                        templateSize = templateSwiftVO.getSize();
+                    }
+                    totalAllocatedSize += (templateSize + _extraBytesPerVolume);
+                }
+            } else {
+                long templateSize = templateHostVO.getPhysicalSize();
+                if ( templateSize == 0 ){
+                    templateSize = templateHostVO.getSize();
+                }
+                totalAllocatedSize +=  (templateSize + _extraBytesPerVolume);
+            }
+
+         */
+        VMTemplateVO image = imageDao.findById(this.imageVO.getId());
+        return image.getSize();
     }
 
     @Override
@@ -137,7 +161,7 @@ public class TemplateObject implements TemplateInfo {
 
     @Override
     public DiskFormat getFormat() {
-        return DiskFormat.getFormat(this.imageVO.getFormat());
+        return DiskFormat.valueOf(this.imageVO.getFormat().toString());
     }
 
     public boolean stateTransit(TemplateEvent e) throws NoTransitionException {
@@ -146,4 +170,14 @@ public class TemplateObject implements TemplateInfo {
         this.imageVO = imageDao.findById(this.imageVO.getId());
         return result;
     }
+
+    @Override
+    public void processEvent(Event event) {
+        try {
+            ojbectInStoreMgr.update(this, event);
+        } catch (NoTransitionException e) {
+            s_logger.debug("failed to update state", e);
+            throw new CloudRuntimeException("Failed to update state" + e.toString());
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a22403ed/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
index 07d52b4..17aabca 100644
--- 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
@@ -22,12 +22,15 @@ 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;
@@ -40,7 +43,7 @@ public class DefaultImageDataStoreLifeCycle implements ImageDataStoreLifeCycle {
 
 
     @Override
-    public DataStore initialize(Map<String, String> dsInfos) {
+    public DataStore initialize(Map<String, Object> dsInfos) {
         ImageDataStoreVO ids = imageStoreHelper.createImageDataStore(dsInfos);
         return imageStoreMgr.getImageDataStore(ids.getId());
     }
@@ -54,6 +57,14 @@ public class DefaultImageDataStoreLifeCycle implements ImageDataStoreLifeCycle {
 
 
     @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;
@@ -75,23 +86,27 @@ public class DefaultImageDataStoreLifeCycle implements ImageDataStoreLifeCycle {
 
 
     @Override
-    public boolean maintain() {
+    public boolean maintain(long storeId) {
         // TODO Auto-generated method stub
         return false;
     }
 
 
     @Override
-    public boolean cancelMaintain() {
+    public boolean cancelMaintain(long storeId) {
         // TODO Auto-generated method stub
         return false;
     }
 
 
     @Override
-    public boolean deleteDataStore() {
+    public boolean deleteDataStore(long storeId) {
         // TODO Auto-generated method stub
         return false;
     }
 
+
+  
+
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a22403ed/engine/storage/imagemotion/src/org/apache/cloudstack/storage/image/motion/DefaultImageMotionStrategy.java
----------------------------------------------------------------------
diff --git a/engine/storage/imagemotion/src/org/apache/cloudstack/storage/image/motion/DefaultImageMotionStrategy.java b/engine/storage/imagemotion/src/org/apache/cloudstack/storage/image/motion/DefaultImageMotionStrategy.java
index 390b0fd..561c1cb 100644
--- a/engine/storage/imagemotion/src/org/apache/cloudstack/storage/image/motion/DefaultImageMotionStrategy.java
+++ b/engine/storage/imagemotion/src/org/apache/cloudstack/storage/image/motion/DefaultImageMotionStrategy.java
@@ -23,7 +23,6 @@ import javax.inject.Inject;
 import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
 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.DataStoreRole;
 import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
 import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher;
 import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
@@ -32,12 +31,11 @@ import org.apache.cloudstack.storage.command.CopyCmd;
 import org.apache.cloudstack.storage.command.CopyCmdAnswer;
 import org.apache.cloudstack.storage.endpoint.EndPointSelector;
 import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreInfo;
-import org.springframework.stereotype.Component;
 
 import com.cloud.agent.api.Answer;
 
 //At least one of datastore is coming from image store or image cache store
-@Component
+
 public class DefaultImageMotionStrategy implements ImageMotionStrategy {
     @Inject
     EndPointSelector selector;
@@ -86,14 +84,15 @@ public class DefaultImageMotionStrategy implements ImageMotionStrategy {
 
     @Override
     public boolean canHandle(DataObject srcData, DataObject destData) {
+        /*
         DataStore destStore = destData.getDataStore();
         DataStore srcStore = srcData.getDataStore();
         if (destStore.getRole() == DataStoreRole.Image || destStore.getRole() == DataStoreRole.ImageCache 
                 || srcStore.getRole() == DataStoreRole.Image 
                 || srcStore.getRole() == DataStoreRole.ImageCache) {
             return true;
-        }
-        return true;
+        }*/
+        return false;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a22403ed/engine/storage/imagemotion/src/org/apache/cloudstack/storage/image/motion/ImageMotionServiceImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/imagemotion/src/org/apache/cloudstack/storage/image/motion/ImageMotionServiceImpl.java b/engine/storage/imagemotion/src/org/apache/cloudstack/storage/image/motion/ImageMotionServiceImpl.java
index 0e3636e..93ba4a5 100644
--- a/engine/storage/imagemotion/src/org/apache/cloudstack/storage/image/motion/ImageMotionServiceImpl.java
+++ b/engine/storage/imagemotion/src/org/apache/cloudstack/storage/image/motion/ImageMotionServiceImpl.java
@@ -23,18 +23,12 @@ import java.util.List;
 import javax.inject.Inject;
 
 import org.apache.cloudstack.engine.subsystem.api.storage.CommandResult;
-import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
+import org.apache.cloudstack.engine.subsystem.api.storage.ImageService;
+import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo;
+import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService;
 import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
-import org.apache.cloudstack.storage.db.ObjectInDataStoreVO;
-import org.apache.cloudstack.storage.image.ImageService;
-import org.apache.cloudstack.storage.image.TemplateInfo;
-import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreInfo;
-import org.apache.cloudstack.storage.volume.VolumeService;
-import org.springframework.stereotype.Component;
 
-import com.cloud.utils.exception.CloudRuntimeException;
 
-@Component
 public class ImageMotionServiceImpl implements ImageMotionService {
     @Inject
     List<ImageMotionStrategy> motionStrategies;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a22403ed/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/ChildTestConfiguration.java
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/ChildTestConfiguration.java b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/ChildTestConfiguration.java
index 9c30a2e..2ad5215 100644
--- a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/ChildTestConfiguration.java
+++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/ChildTestConfiguration.java
@@ -16,14 +16,25 @@
 // under the License.
 package org.apache.cloudstack.storage.test;
 
+import java.io.IOException;
+
 import org.apache.cloudstack.acl.APIChecker;
 import org.apache.cloudstack.engine.service.api.OrchestrationService;
 import org.apache.cloudstack.storage.HostEndpointRpcServer;
 import org.apache.cloudstack.storage.endpoint.EndPointSelector;
+import org.apache.cloudstack.storage.test.ChildTestConfiguration.Library;
 import org.mockito.Mockito;
 import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.ComponentScan.Filter;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.FilterType;
+import org.springframework.core.type.classreading.MetadataReader;
+import org.springframework.core.type.classreading.MetadataReaderFactory;
+import org.springframework.core.type.filter.TypeFilter;
 
 import com.cloud.agent.AgentManager;
+import com.cloud.alert.AlertManager;
 import com.cloud.cluster.ClusteredAgentRebalanceService;
 import com.cloud.cluster.agentlb.dao.HostTransferMapDao;
 import com.cloud.cluster.agentlb.dao.HostTransferMapDaoImpl;
@@ -50,11 +61,35 @@ import com.cloud.host.dao.HostTagsDaoImpl;
 import com.cloud.server.auth.UserAuthenticator;
 import com.cloud.storage.dao.StoragePoolHostDao;
 import com.cloud.storage.dao.StoragePoolHostDaoImpl;
+import com.cloud.storage.dao.VMTemplateDaoImpl;
 import com.cloud.storage.dao.VMTemplateDetailsDao;
 import com.cloud.storage.dao.VMTemplateDetailsDaoImpl;
+import com.cloud.storage.dao.VMTemplateHostDaoImpl;
+import com.cloud.storage.dao.VMTemplatePoolDaoImpl;
 import com.cloud.storage.dao.VMTemplateZoneDao;
 import com.cloud.storage.dao.VMTemplateZoneDaoImpl;
-
+import com.cloud.storage.dao.VolumeDaoImpl;
+import com.cloud.storage.dao.VolumeHostDaoImpl;
+import com.cloud.storage.snapshot.SnapshotManager;
+import com.cloud.tags.dao.ResourceTagsDaoImpl;
+import com.cloud.utils.component.SpringComponentScanUtils;
+import com.cloud.vm.dao.NicDaoImpl;
+import com.cloud.vm.dao.VMInstanceDaoImpl;
+@Configuration
+@ComponentScan(basePackageClasses={
+        NicDaoImpl.class,
+        VMInstanceDaoImpl.class,
+        VMTemplateHostDaoImpl.class,
+        VolumeHostDaoImpl.class,
+        VolumeDaoImpl.class,
+        VMTemplatePoolDaoImpl.class,
+        ResourceTagsDaoImpl.class,
+        VMTemplateDaoImpl.class,
+        MockStorageMotionStrategy.class
+},
+includeFilters={@Filter(value=Library.class, type=FilterType.CUSTOM)},
+useDefaultFilters=false
+)
 public class ChildTestConfiguration extends TestConfiguration {
 	
 	@Override
@@ -148,6 +183,27 @@ public class ChildTestConfiguration extends TestConfiguration {
     public APIChecker apiChecker() {
         return Mockito.mock(APIChecker.class);
     }
+    
+    @Bean
+    public SnapshotManager snapshotMgr() {
+        return Mockito.mock(SnapshotManager.class);
+    }
+    
+    @Bean
+    public AlertManager alertMgr() {
+        return Mockito.mock(AlertManager.class);
+    }
+
+    public static class Library implements TypeFilter {
+
+        @Override
+        public boolean match(MetadataReader mdr, MetadataReaderFactory arg1) throws IOException {
+            mdr.getClassMetadata().getClassName();
+            ComponentScan cs = ChildTestConfiguration.class.getAnnotation(ComponentScan.class);
+            return SpringComponentScanUtils.includedInBasePackageClasses(mdr.getClassMetadata().getClassName(), cs);
+        }
+
+    }
 /*	@Override
 	@Bean
 	public PrimaryDataStoreDao primaryDataStoreDao() {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a22403ed/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/MockStorageMotionStrategy.java
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/MockStorageMotionStrategy.java b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/MockStorageMotionStrategy.java
new file mode 100644
index 0000000..e2e8f94
--- /dev/null
+++ b/engine/storage/integration-test/test/org/apache/cloudstack/storage/test/MockStorageMotionStrategy.java
@@ -0,0 +1,42 @@
+/*
+ * 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.test;
+
+import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
+import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
+import org.apache.cloudstack.storage.motion.DataMotionStrategy;
+
+public class MockStorageMotionStrategy implements DataMotionStrategy {
+
+    @Override
+    public boolean canHandle(DataObject srcData, DataObject destData) {
+        // TODO Auto-generated method stub
+        return true;
+    }
+
+    @Override
+    public Void copyAsync(DataObject srcData, DataObject destData,
+            AsyncCompletionCallback<CopyCommandResult> callback) {
+        CopyCommandResult result = new CopyCommandResult("something");
+        callback.complete(result);
+        return null;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a22403ed/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 0e88f73..85421a5 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
@@ -28,33 +28,30 @@ import java.util.UUID;
 import java.util.concurrent.ExecutionException;
 
 import javax.inject.Inject;
-import javax.naming.ConfigurationException;
 
 import org.apache.cloudstack.engine.subsystem.api.storage.ClusterScope;
 import org.apache.cloudstack.engine.subsystem.api.storage.CommandResult;
 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.DataStoreLifeCycle;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProviderManager;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreRole;
 import org.apache.cloudstack.engine.subsystem.api.storage.EndPoint;
+import org.apache.cloudstack.engine.subsystem.api.storage.ImageDataFactory;
+import org.apache.cloudstack.engine.subsystem.api.storage.ImageService;
 import org.apache.cloudstack.engine.subsystem.api.storage.ScopeType;
+import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo;
+import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory;
 import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
+import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService;
+import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService.VolumeApiResult;
 import org.apache.cloudstack.engine.subsystem.api.storage.type.RootDisk;
 import org.apache.cloudstack.framework.async.AsyncCallFuture;
 import org.apache.cloudstack.storage.HypervisorHostEndPoint;
-import org.apache.cloudstack.storage.datastore.VolumeDataFactory;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
-import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreVO;
-import org.apache.cloudstack.storage.datastore.provider.DataStoreProvider;
-import org.apache.cloudstack.storage.datastore.provider.DataStoreProviderManager;
+import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
 import org.apache.cloudstack.storage.endpoint.EndPointSelector;
-import org.apache.cloudstack.storage.image.ImageDataFactory;
-import org.apache.cloudstack.storage.image.ImageService;
-import org.apache.cloudstack.storage.image.TemplateInfo;
-import org.apache.cloudstack.storage.image.db.ImageDataDao;
-import org.apache.cloudstack.storage.image.db.ImageDataVO;
-import org.apache.cloudstack.storage.volume.VolumeService;
-import org.apache.cloudstack.storage.volume.VolumeService.VolumeApiResult;
 import org.apache.cloudstack.storage.volume.db.VolumeDao2;
 import org.apache.cloudstack.storage.volume.db.VolumeVO;
 import org.mockito.Mockito;
@@ -78,7 +75,11 @@ import com.cloud.org.Cluster.ClusterType;
 import com.cloud.org.Managed.ManagedState;
 import com.cloud.resource.ResourceState;
 import com.cloud.storage.Storage;
+import com.cloud.storage.Storage.StoragePoolType;
 import com.cloud.storage.Storage.TemplateType;
+import com.cloud.storage.VMTemplateVO;
+import com.cloud.storage.dao.VMTemplateDao;
+import com.cloud.utils.component.ComponentContext;
 
 @ContextConfiguration(locations={"classpath:/storageContext.xml"})
 public class volumeServiceTest extends CloudStackTestNGBase {
@@ -89,7 +90,7 @@ public class volumeServiceTest extends CloudStackTestNGBase {
 	@Inject
 	VolumeService volumeService;
 	@Inject
-	ImageDataDao imageDataDao;
+	VMTemplateDao imageDataDao;
 	@Inject
 	VolumeDao2 volumeDao;
 	@Inject 
@@ -121,12 +122,13 @@ public class volumeServiceTest extends CloudStackTestNGBase {
 	
     @Test(priority = -1)
 	public void setUp() {
-        try {
+        ComponentContext.initComponentsLifeCycle();
+       /* try {
             dataStoreProviderMgr.configure(null, new HashMap<String, Object>());
         } catch (ConfigurationException e) {
             // TODO Auto-generated catch block
             e.printStackTrace();
-        }
+        }*/
         host = hostDao.findByGuid(this.getHostGuid());
         if (host != null) {
             dcId = host.getDataCenterId();
@@ -205,18 +207,17 @@ public class volumeServiceTest extends CloudStackTestNGBase {
         Mockito.when(selector.select(Mockito.any(DataObject.class), Mockito.any(DataObject.class))).thenReturn(eps.get(0));
     }
 
-	private ImageDataVO createImageData() {
-		ImageDataVO image = new ImageDataVO();
+	private VMTemplateVO createImageData() {
+		VMTemplateVO image = new VMTemplateVO();
 		image.setTemplateType(TemplateType.USER);
 		image.setUrl(this.getTemplateUrl());
 		image.setUniqueName(UUID.randomUUID().toString());
 		image.setName(UUID.randomUUID().toString());
 		image.setPublicTemplate(true);
 		image.setFeatured(true);
-		image.setRequireHvm(true);
+		image.setRequiresHvm(true);
 		image.setBits(64);
-		image.setFormat(Storage.ImageFormat.VHD.toString());
-		image.setAccountId(1);
+		image.setFormat(Storage.ImageFormat.VHD);
 		image.setEnablePassword(true);
 		image.setEnableSshKey(true);
 		image.setGuestOSId(1);
@@ -234,13 +235,13 @@ public class volumeServiceTest extends CloudStackTestNGBase {
 	private TemplateInfo createTemplate() {
 		try {
 		    DataStore store = createImageStore();
-		    ImageDataVO image = createImageData();
+		    VMTemplateVO image = createImageData();
 		    TemplateInfo template = imageDataFactory.getTemplate(image.getId(), store);
 		    AsyncCallFuture<CommandResult> future = imageService.createTemplateAsync(template, store);
 		    future.get();
 		    template = imageDataFactory.getTemplate(image.getId(), store);
 			/*imageProviderMgr.configure("image Provider", new HashMap<String, Object>());
-			ImageDataVO image = createImageData();
+			VMTemplateVO image = createImageData();
 			ImageDataStoreProvider defaultProvider = imageProviderMgr.getProvider("DefaultProvider");
 			ImageDataStoreLifeCycle lifeCycle = defaultProvider.getLifeCycle();
 			ImageDataStore store = lifeCycle.registerDataStore("defaultHttpStore", new HashMap<String, String>());
@@ -262,7 +263,7 @@ public class volumeServiceTest extends CloudStackTestNGBase {
 	@Test
 	public void testCreatePrimaryStorage() {
 	    DataStoreProvider provider = dataStoreProviderMgr.getDataStoreProvider("default primary data store provider");
-        Map<String, String> params = new HashMap<String, String>();
+        Map<String, Object> params = new HashMap<String, Object>();
         URI uri = null;
         try {
             uri = new URI(this.getPrimaryStorageUrl());
@@ -273,7 +274,7 @@ public class volumeServiceTest extends CloudStackTestNGBase {
         params.put("url", this.getPrimaryStorageUrl());
         params.put("server", uri.getHost());
         params.put("path", uri.getPath());
-        params.put("protocol", uri.getScheme());
+        params.put("protocol", StoragePoolType.NetworkFilesystem);
         params.put("dcId", dcId.toString());
         params.put("clusterId", clusterId.toString());
         params.put("name", this.primaryName);
@@ -290,7 +291,7 @@ public class volumeServiceTest extends CloudStackTestNGBase {
 	
 	private DataStore createImageStore() {
 	    DataStoreProvider provider = dataStoreProviderMgr.getDataStoreProvider("default image data store");
-        Map<String, String> params = new HashMap<String, String>();
+        Map<String, Object> params = new HashMap<String, Object>();
         String name = UUID.randomUUID().toString();
         params.put("name", name);
         params.put("uuid", name);
@@ -310,12 +311,12 @@ public class volumeServiceTest extends CloudStackTestNGBase {
 	public DataStore createPrimaryDataStore() {
 		try {
 		    DataStoreProvider provider = dataStoreProviderMgr.getDataStoreProvider("default primary data store provider");
-		    Map<String, String> params = new HashMap<String, String>();
+		    Map<String, Object> params = new HashMap<String, Object>();
 		    URI uri = new URI(this.getPrimaryStorageUrl());
 		    params.put("url", this.getPrimaryStorageUrl());
             params.put("server", uri.getHost());
             params.put("path", uri.getPath());
-            params.put("protocol", uri.getScheme());
+            params.put("protocol", Storage.StoragePoolType.NetworkFilesystem);
             params.put("dcId", dcId.toString());
             params.put("clusterId", clusterId.toString());
             params.put("name", this.primaryName);
@@ -390,7 +391,7 @@ public class volumeServiceTest extends CloudStackTestNGBase {
 	    DataStore primaryStore = this.primaryStore;
 	    VolumeVO volume = createVolume(null, primaryStore.getId());
 	    VolumeInfo vol = volumeFactory.getVolume(volume.getId(), primaryStore);
-	    AsyncCallFuture<VolumeApiResult> future = volumeService.createVolumeAsync(vol, primaryStore.getId());
+	    AsyncCallFuture<VolumeApiResult> future = volumeService.createVolumeAsync(vol, primaryStore);
 	    try {
             future.get();
         } catch (InterruptedException e) {
@@ -407,7 +408,7 @@ public class volumeServiceTest extends CloudStackTestNGBase {
 	    DataStore primaryStore = this.primaryStore;
 	    VolumeVO volume = createVolume(null, primaryStore.getId());
 	    VolumeInfo vol = volumeFactory.getVolume(volume.getId(), primaryStore);
-	    AsyncCallFuture<VolumeApiResult> future = volumeService.createVolumeAsync(vol, primaryStore.getId());
+	    AsyncCallFuture<VolumeApiResult> future = volumeService.createVolumeAsync(vol, primaryStore);
 	    try {
 	        future.get();
 	    } catch (InterruptedException e) {
@@ -420,7 +421,7 @@ public class volumeServiceTest extends CloudStackTestNGBase {
 	    
 	    //delete the volume
 	    vol = volumeFactory.getVolume(volume.getId(), primaryStore);
-	    future = volumeService.deleteVolumeAsync(vol);
+	    future = volumeService.expungeVolumeAsync(vol);
 	    try {
             future.get();
         } catch (InterruptedException e) {
@@ -434,9 +435,9 @@ public class volumeServiceTest extends CloudStackTestNGBase {
 
 	//@Test(priority=3)
 	public void tearDown() {
-	    List<PrimaryDataStoreVO> ds = primaryStoreDao.findPoolByName(this.primaryName);
+	    List<StoragePoolVO> ds = primaryStoreDao.findPoolByName(this.primaryName);
 	    for (int i = 0; i < ds.size(); i++) {
-	        PrimaryDataStoreVO store = ds.get(i);
+	        StoragePoolVO store = ds.get(i);
 	        store.setUuid(null);
 	        primaryStoreDao.remove(ds.get(i).getId());
 	        primaryStoreDao.expunge(ds.get(i).getId());

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a22403ed/engine/storage/integration-test/test/resource/component.xml
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/resource/component.xml b/engine/storage/integration-test/test/resource/component.xml
new file mode 100644
index 0000000..0368ad4
--- /dev/null
+++ b/engine/storage/integration-test/test/resource/component.xml
@@ -0,0 +1,201 @@
+<!--
+  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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
+  xmlns:context="http://www.springframework.org/schema/context"
+  xmlns:tx="http://www.springframework.org/schema/tx" 
+  xmlns:aop="http://www.springframework.org/schema/aop"
+  xsi:schemaLocation="http://www.springframework.org/schema/beans
+                      http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+                      http://www.springframework.org/schema/tx 
+                      http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
+                      http://www.springframework.org/schema/aop
+                      http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
+                      http://www.springframework.org/schema/context
+                      http://www.springframework.org/schema/context/spring-context-3.0.xsd">                     
+
+
+  <!--
+      Compose a CloudStack deployment with selected components here
+  -->
+  <bean id="databaseUpgradeChecker" class="com.cloud.upgrade.DatabaseUpgradeChecker" />
+  
+  <bean id="management-server" class ="com.cloud.server.ManagementServerExtImpl" />
+  <bean id="configuration-server" class="com.cloud.server.ConfigurationServerImpl" />
+   
+  <bean id="clusterManagerImpl" class="com.cloud.cluster.ClusterManagerImpl" />
+  <bean id="clusteredVirtualMachineManagerImpl" class="com.cloud.vm.ClusteredVirtualMachineManagerImpl" />
+  <bean id="highAvailabilityManagerExtImpl" class="com.cloud.ha.HighAvailabilityManagerExtImpl" />
+  <bean id="bareMetalVmManagerImpl" class="com.cloud.baremetal.BareMetalVmManagerImpl" />
+  <bean id="consoleProxyManagerImpl" class="com.cloud.consoleproxy.ConsoleProxyManagerImpl" />
+  <bean id="securityGroupManagerImpl2" class="com.cloud.network.security.SecurityGroupManagerImpl2" />
+  <bean id="premiumSecondaryStorageManagerImpl" class="com.cloud.secstorage.PremiumSecondaryStorageManagerImpl" />
+  <bean id="randomlyIncreasingVMInstanceDaoImpl" class="com.cloud.vm.dao.RandomlyIncreasingVMInstanceDaoImpl" />
+    
+            
+  <!--
+     Adapters
+  -->
+  <bean id="FirstFitRouting" class="com.cloud.agent.manager.allocator.impl.FirstFitRoutingAllocator">
+    <property name="name" value="FirstFitRouting"/>
+  </bean>
+  
+  <!--
+    Storage pool allocators
+  -->
+  <bean id="LocalStoragePoolAllocator" class="com.cloud.storage.allocator.LocalStoragePoolAllocator">
+    <property name="name" value="LocalStorage"/>
+  </bean>
+  <bean id="FirstFitStoragePoolAllocator" class="com.cloud.storage.allocator.FirstFitStoragePoolAllocator">
+    <property name="name" value="Storage"/>
+  </bean>
+
+  <bean id="UserConcentratedAllocator" class="com.cloud.agent.manager.allocator.impl.UserConcentratedAllocator">
+    <property name="name" value="User First"/>
+  </bean>
+
+  <bean id="ConsoleProxyAllocator" class="com.cloud.consoleproxy.ConsoleProxyBalanceAllocator">
+    <property name="name" value="Balance"/>
+  </bean>
+
+ 
+  <bean id="ExteralIpAddressAllocator" class="com.cloud.network.ExteralIpAddressAllocator">
+    <property name="name" value="Basic"/>
+  </bean>
+
+  <!--
+    Investigators
+  -->
+  <bean id="CheckOnAgentInvestigator" class="com.cloud.ha.CheckOnAgentInvestigator">
+    <property name="name" value="SimpleInvestigator"/>
+  </bean>
+
+  <bean id="XenServerInvestigator" class="com.cloud.ha.XenServerInvestigator">
+    <property name="name" value="XenServerInvestigator"/>
+  </bean>
+  
+  <bean id="UserVmDomRInvestigator" class="com.cloud.ha.UserVmDomRInvestigator">
+    <property name="name" value="PingInvestigator"/>
+  </bean>
+
+  <bean id="ManagementIPSystemVMInvestigator" class="com.cloud.ha.ManagementIPSystemVMInvestigator">
+    <property name="name" value="ManagementIPSysVMInvestigator"/>
+  </bean>
+
+  <!--
+    Fencers
+  -->
+  <bean id="XenServerFencer" class="com.cloud.ha.XenServerFencer">
+    <property name="name" value="XenServerFenceBuilder"/>
+  </bean>
+  <bean id="KVMFencer" class="com.cloud.ha.KVMFencer">
+    <property name="name" value="KVMFenceBuilder"/>
+  </bean>
+
+
+  <bean id="XcpServerDiscoverer" class="com.cloud.hypervisor.xen.discoverer.XcpServerDiscoverer">
+    <property name="name" value="XCP Agent"/>
+  </bean>
+
+  <bean id="SecondaryStorageDiscoverer" class="com.cloud.storage.secondary.SecondaryStorageDiscoverer">
+    <property name="name" value="SecondaryStorage"/>
+  </bean>
+
+  <bean id="KvmServerDiscoverer" class="com.cloud.hypervisor.kvm.discoverer.KvmServerDiscoverer">
+    <property name="name" value="KVM Agent"/>
+  </bean>
+
+  <bean id="BareMetalDiscoverer" class="com.cloud.baremetal.BareMetalDiscoverer">
+    <property name="name" value="Bare Metal Agent"/>
+  </bean>
+
+  <bean id="HypervServerDiscoverer" class="com.cloud.hypervisor.hyperv.HypervServerDiscoverer">
+    <property name="name" value="SCVMMServer"/>
+  </bean>
+
+
+  <bean id="FirstFitPlanner" class="com.cloud.deploy.FirstFitPlanner">
+    <property name="name" value="First Fit"/>
+  </bean>
+
+
+  <bean id="BareMetalPlanner" class="com.cloud.deploy.BareMetalPlanner">
+    <property name="name" value="BareMetal Fit"/>
+  </bean>
+    
+   
+  <!--
+    Network Gurus
+  -->
+  <bean id="StorageNetworkGuru" class="com.cloud.network.guru.StorageNetworkGuru">
+    <property name="name" value="StorageNetworkGuru"/>
+  </bean>
+  <bean id="ExternalGuestNetworkGuru" class="com.cloud.network.guru.ExternalGuestNetworkGuru">
+    <property name="name" value="ExternalGuestNetworkGuru"/>
+  </bean>
+  <bean id="PublicNetworkGuru" class="com.cloud.network.guru.PublicNetworkGuru">
+    <property name="name" value="PublicNetworkGuru"/>
+  </bean>
+  <bean id="PodBasedNetworkGuru" class="com.cloud.network.guru.PodBasedNetworkGuru">
+    <property name="name" value="PodBasedNetworkGuru"/>
+  </bean>
+  <bean id="ControlNetworkGuru" class="com.cloud.network.guru.ControlNetworkGuru">
+    <property name="name" value="ControlNetworkGuru"/>
+  </bean>
+  <bean id="DirectNetworkGuru" class="com.cloud.network.guru.DirectNetworkGuru">
+    <property name="name" value="DirectNetworkGuru"/>
+  </bean>
+  <bean id="DirectPodBasedNetworkGuru" class="com.cloud.network.guru.DirectPodBasedNetworkGuru">
+    <property name="name" value="DirectPodBasedNetworkGuru"/>
+  </bean>
+  <bean id="OvsGuestNetworkGuru" class="com.cloud.network.guru.OvsGuestNetworkGuru">
+    <property name="name" value="OvsGuestNetworkGuru"/>
+  </bean>
+  <bean id="PrivateNetworkGuru" class="com.cloud.network.guru.PrivateNetworkGuru">
+    <property name="name" value="PrivateNetworkGuru"/>
+  </bean>
+   <bean id="VpcVirtualRouter" class="com.cloud.network.element.VpcVirtualRouterElement">
+    <property name="name" value="VpcVirtualRouter"/>
+  </bean>
+  <!--
+   Hypervisor Gurus
+  -->
+  <bean id="XenServerGuru" class="com.cloud.hypervisor.XenServerGuru">
+    <property name="name" value="XenServerGuru"/>
+  </bean>
+  
+  <bean id="KVMGuru" class="com.cloud.hypervisor.KVMGuru">
+    <property name="name" value="KVMGuru"/>
+  </bean>
+  
+  <bean id="BareMetalGuru" class="com.cloud.baremetal.BareMetalGuru">
+    <property name="name" value="BareMetalGuru"/>
+  </bean>
+
+  <bean id="HypervGuru" class="com.cloud.hypervisor.guru.HypervGuru">
+    <property name="name" value="HypervGuru"/>
+  </bean>
+  
+  <!--
+    DAO with customized configuration
+  -->
+  <bean id="configurationDaoImpl" class="com.cloud.configuration.dao.ConfigurationDaoImpl">
+  </bean>
+  
+</beans>

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a22403ed/engine/storage/integration-test/test/resource/storageContext.xml
----------------------------------------------------------------------
diff --git a/engine/storage/integration-test/test/resource/storageContext.xml b/engine/storage/integration-test/test/resource/storageContext.xml
index 0127c96..4f55e24 100644
--- a/engine/storage/integration-test/test/resource/storageContext.xml
+++ b/engine/storage/integration-test/test/resource/storageContext.xml
@@ -45,6 +45,7 @@
   <bean id="transactionContextBuilder" class="com.cloud.utils.db.TransactionContextBuilder" />
   <bean id="actionEventInterceptor" class="com.cloud.event.ActionEventInterceptor" />
 
+  <bean id="componentContext" class="com.cloud.utils.component.ComponentContext"/>
 
   <bean class="org.apache.cloudstack.storage.test.ChildTestConfiguration" />
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a22403ed/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotDataFactoryImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotDataFactoryImpl.java b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotDataFactoryImpl.java
index 487e2d5..0953209 100644
--- a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotDataFactoryImpl.java
+++ b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotDataFactoryImpl.java
@@ -20,11 +20,14 @@ package org.apache.cloudstack.storage.snapshot;
 
 import javax.inject.Inject;
 
+import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectType;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
-import org.apache.cloudstack.storage.datastore.DataStoreManager;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
+import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotDataFactory;
+import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
 import org.apache.cloudstack.storage.datastore.ObjectInDataStoreManager;
-import org.apache.cloudstack.storage.db.ObjectInDataStoreVO;
 import org.apache.cloudstack.storage.snapshot.db.SnapshotDao2;
 import org.apache.cloudstack.storage.snapshot.db.SnapshotVO;
 import org.springframework.stereotype.Component;
@@ -40,8 +43,21 @@ public class SnapshotDataFactoryImpl implements SnapshotDataFactory {
     @Override
     public SnapshotInfo getSnapshot(long snapshotId, DataStore store) {
         SnapshotVO snapshot = snapshotDao.findById(snapshotId);
-        ObjectInDataStoreVO obj = objMap.findObject(snapshotId, DataObjectType.SNAPSHOT, store.getId(), store.getRole());
+        DataObjectInStore obj = objMap.findObject(snapshot.getUuid(), DataObjectType.SNAPSHOT, store.getUuid(), store.getRole());
+        if (obj == null) {
+            return null;
+        }
         SnapshotObject so = new SnapshotObject(snapshot, store);
         return so;
     }
+    @Override
+    public SnapshotInfo getSnapshot(long snapshotId) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+    @Override
+    public SnapshotInfo getSnapshot(DataObject obj, DataStore store) {
+        // TODO Auto-generated method stub
+        return null;
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a22403ed/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotObject.java
----------------------------------------------------------------------
diff --git a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotObject.java b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotObject.java
index 6ce1797..d9fc8aa 100644
--- a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotObject.java
+++ b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotObject.java
@@ -20,6 +20,8 @@ package org.apache.cloudstack.storage.snapshot;
 
 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.ObjectInDataStoreStateMachine.Event;
+import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
 import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
 import org.apache.cloudstack.engine.subsystem.api.storage.disktype.DiskFormat;
 import org.apache.cloudstack.storage.snapshot.db.SnapshotVO;
@@ -97,4 +99,10 @@ public class SnapshotObject implements SnapshotInfo {
         return null;
     }
 
+    @Override
+    public void processEvent(Event event) {
+        // TODO Auto-generated method stub
+        
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a22403ed/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotServiceImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotServiceImpl.java b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotServiceImpl.java
index 80b1918..bd3caf4 100644
--- a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotServiceImpl.java
+++ b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/SnapshotServiceImpl.java
@@ -17,6 +17,7 @@
 package org.apache.cloudstack.storage.snapshot;
 
 import org.apache.cloudstack.engine.cloud.entity.api.SnapshotEntity;
+import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
 import org.springframework.stereotype.Component;
 
 @Component

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a22403ed/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/strategy/HypervisorBasedSnapshot.java
----------------------------------------------------------------------
diff --git a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/strategy/HypervisorBasedSnapshot.java b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/strategy/HypervisorBasedSnapshot.java
index 7f18200..8ef0927 100644
--- a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/strategy/HypervisorBasedSnapshot.java
+++ b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/strategy/HypervisorBasedSnapshot.java
@@ -16,7 +16,7 @@
 // under the License.
 package org.apache.cloudstack.storage.snapshot.strategy;
 
-import org.apache.cloudstack.storage.snapshot.SnapshotInfo;
+import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
 import org.apache.cloudstack.storage.snapshot.SnapshotStrategy;
 import org.springframework.stereotype.Component;
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a22403ed/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/strategy/StorageBasedSnapshot.java
----------------------------------------------------------------------
diff --git a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/strategy/StorageBasedSnapshot.java b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/strategy/StorageBasedSnapshot.java
index fa9c5ae..7af395a 100644
--- a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/strategy/StorageBasedSnapshot.java
+++ b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/strategy/StorageBasedSnapshot.java
@@ -16,7 +16,7 @@
 // under the License.
 package org.apache.cloudstack.storage.snapshot.strategy;
 
-import org.apache.cloudstack.storage.snapshot.SnapshotInfo;
+import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
 import org.apache.cloudstack.storage.snapshot.SnapshotStrategy;
 
 public class StorageBasedSnapshot implements SnapshotStrategy {


Mime
View raw message