You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ah...@apache.org on 2013/07/01 23:25:02 UTC

[18/50] [abbrv] git commit: updated refs/heads/vmsync to f737019

DataStore - provider, lifecycle, driver implementations for simulator

mock implementation to manage secondary storage related operations for
the simulator.

Signed-off-by: Prasanna Santhanam <ts...@apache.org>


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

Branch: refs/heads/vmsync
Commit: fd867d5afa819d89c22238fcc0a45dacb84a9c70
Parents: 085e883
Author: Prasanna Santhanam <ts...@apache.org>
Authored: Tue Jun 25 19:37:04 2013 +0530
Committer: Prasanna Santhanam <ts...@apache.org>
Committed: Sat Jun 29 13:52:16 2013 +0530

----------------------------------------------------------------------
 client/tomcatconf/applicationContext.xml.in     |   3 +-
 .../tomcatconf/simulatorComponentContext.xml.in |  11 +-
 .../agent/manager/MockStorageManagerImpl.java   |  11 +-
 plugins/pom.xml                                 |   7 +-
 plugins/storage/image/simulator/pom.xml         |  68 +++++++++
 .../driver/SimulatorImageStoreDriverImpl.java   | 149 +++++++++++++++++++
 .../SimulatorImageStoreLifeCycleImpl.java       | 132 ++++++++++++++++
 .../SimulatorImageStoreProviderImpl.java        |  98 ++++++++++++
 8 files changed, 463 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fd867d5a/client/tomcatconf/applicationContext.xml.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/applicationContext.xml.in b/client/tomcatconf/applicationContext.xml.in
index 7052fd7..5c61b4e2 100644
--- a/client/tomcatconf/applicationContext.xml.in
+++ b/client/tomcatconf/applicationContext.xml.in
@@ -805,8 +805,9 @@
   <bean id="ClassicalPrimaryDataStoreProvider" class="org.apache.cloudstack.storage.datastore.provider.CloudStackPrimaryDataStoreProviderImpl" />
   <bean id="cloudStackImageStoreProviderImpl" class="org.apache.cloudstack.storage.datastore.provider.CloudStackImageStoreProviderImpl" />
   <bean id="s3ImageStoreProviderImpl" class="org.apache.cloudstack.storage.datastore.provider.S3ImageStoreProviderImpl" />
-  <bean id="swiftImageStoreProviderImpl" class="org.apache.cloudstack.storage.datastore.provider.SwiftImageStoreProviderImpl" />  
+  <bean id="swiftImageStoreProviderImpl" class="org.apache.cloudstack.storage.datastore.provider.SwiftImageStoreProviderImpl" />
   <bean id="solidFireDataStoreProvider" class="org.apache.cloudstack.storage.datastore.provider.SolidfirePrimaryDataStoreProvider" />
+  <bean id="simulatorImageStoreProvider" class="org.apache.cloudstack.storage.datastore.provider.SimulatorImageStoreProviderImpl" />
   <bean id="ApplicationLoadBalancerService" class="org.apache.cloudstack.network.lb.ApplicationLoadBalancerManagerImpl" />
   <bean id="InternalLoadBalancerVMManager" class="org.apache.cloudstack.network.lb.InternalLoadBalancerVMManagerImpl" />
   <bean id="StorageCacheReplacementAlgorithm" class="org.apache.cloudstack.storage.cache.manager.StorageCacheReplacementAlgorithmLRU" />

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fd867d5a/client/tomcatconf/simulatorComponentContext.xml.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/simulatorComponentContext.xml.in b/client/tomcatconf/simulatorComponentContext.xml.in
index d71cf16..cfe0a9a 100644
--- a/client/tomcatconf/simulatorComponentContext.xml.in
+++ b/client/tomcatconf/simulatorComponentContext.xml.in
@@ -37,9 +37,9 @@
   <bean id="configurationDaoImpl" class="com.cloud.configuration.dao.ConfigurationDaoImpl"/>
 
   <!-- simulator components -->
-  <bean id="SimulatorSecondaryDiscoverer" class="com.cloud.resource.SimulatorSecondaryDiscoverer">
-    <property name="name" value="SecondaryStorage"/>
-  </bean>
+  <!--<bean id="SimulatorSecondaryDiscoverer" class="com.cloud.resource.SimulatorSecondaryDiscoverer">-->
+    <!--<property name="name" value="SecondaryStorage"/>-->
+  <!--</bean>-->
   <bean id="SimulatorDiscoverer" class="com.cloud.resource.SimulatorDiscoverer">
     <property name="name" value="Simulator Agent"/>
   </bean>
@@ -215,6 +215,11 @@
     </property>
   </bean>
 
+  <!--
+    Image Store
+  -->
+  <!--<bean id="simulatorImageStoreProvider" class="org.apache.cloudstack.storage.datastore.provider.SimulatorImageStoreProviderImpl" />-->
+
   <bean id="GlobalLoadBalancingRulesServiceImpl"
         class="org.apache.cloudstack.region.gslb.GlobalLoadBalancingRulesServiceImpl"/>
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fd867d5a/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockStorageManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockStorageManagerImpl.java b/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockStorageManagerImpl.java
index a59949f..bc5aa58 100644
--- a/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockStorageManagerImpl.java
+++ b/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockStorageManagerImpl.java
@@ -476,7 +476,7 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
         }
         Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
         MockSecStorageVO storage = null;
-        String nfsUrl = ((NfsTO)cmd.getDataStore()).getUrl();
+        String nfsUrl = ((NfsTO) store).getUrl();
         try {
             txn.start();
             storage = _mockSecStorageDao.findByUrl(nfsUrl);
@@ -868,19 +868,16 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
 
     @Override
     public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
-        // TODO Auto-generated method stub
         return true;
     }
 
     @Override
     public boolean start() {
-        // TODO Auto-generated method stub
         return true;
     }
 
     @Override
     public boolean stop() {
-        // TODO Auto-generated method stub
         return true;
     }
 
@@ -891,17 +888,13 @@ public class MockStorageManagerImpl extends ManagerBase implements MockStorageMa
 
     @Override
     public void preinstallTemplates(String url, long zoneId) {
-        Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
         MockSecStorageVO storage = null;
+        Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
         try {
-            txn.start();
             storage = _mockSecStorageDao.findByUrl(url);
-            txn.commit();
         } catch (Exception ex) {
-            txn.rollback();
             throw new CloudRuntimeException("Unable to find sec storage at " + url, ex);
         } finally {
-            txn.close();
             txn = Transaction.open(Transaction.CLOUD_DB);
             txn.close();
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fd867d5a/plugins/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/pom.xml b/plugins/pom.xml
index 9ad56c6..04eb55c 100755
--- a/plugins/pom.xml
+++ b/plugins/pom.xml
@@ -35,7 +35,7 @@
     <module>api/rate-limit</module>
     <module>api/discovery</module>
     <module>acl/static-role-based</module>
-	<module>affinity-group-processors/host-anti-affinity</module>
+	  <module>affinity-group-processors/host-anti-affinity</module>
     <module>affinity-group-processors/explicit-dedication</module>
     <module>deployment-planners/user-concentrated-pod</module>
     <module>deployment-planners/user-dispersing</module>
@@ -64,7 +64,8 @@
     <module>storage/image/s3</module>
     <module>storage/image/swift</module>
     <module>storage/image/default</module>
-    <module>storage/image/sample</module>    
+    <module>storage/image/sample</module>
+    <module>storage/image/simulator</module>
     <module>storage/volume/solidfire</module>
     <module>storage/volume/default</module>
     <module>storage/volume/sample</module>
@@ -158,8 +159,8 @@
       </activation>
       <modules>
         <module>hypervisors/simulator</module>
+        <module>storage/image/simulator</module>
       </modules>
      </profile>
   </profiles>
-
 </project>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fd867d5a/plugins/storage/image/simulator/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/storage/image/simulator/pom.xml b/plugins/storage/image/simulator/pom.xml
new file mode 100644
index 0000000..d4b6838
--- /dev/null
+++ b/plugins/storage/image/simulator/pom.xml
@@ -0,0 +1,68 @@
+<!-- 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-simulator</artifactId>
+  <name>Apache CloudStack Plugin - Storage Image Simulator 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</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.cloudstack</groupId>
+      <artifactId>cloud-engine-storage-image</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.cloudstack</groupId>
+      <artifactId>cloud-engine-storage-volume</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.cloudstack</groupId>
+      <artifactId>cloud-engine-storage-snapshot</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>
+        <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/fd867d5a/plugins/storage/image/simulator/src/org/apache/cloudstack/storage/datastore/driver/SimulatorImageStoreDriverImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/image/simulator/src/org/apache/cloudstack/storage/datastore/driver/SimulatorImageStoreDriverImpl.java b/plugins/storage/image/simulator/src/org/apache/cloudstack/storage/datastore/driver/SimulatorImageStoreDriverImpl.java
new file mode 100644
index 0000000..74177ed
--- /dev/null
+++ b/plugins/storage/image/simulator/src/org/apache/cloudstack/storage/datastore/driver/SimulatorImageStoreDriverImpl.java
@@ -0,0 +1,149 @@
+/*
+ * 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 com.cloud.agent.api.storage.DownloadAnswer;
+import com.cloud.agent.api.to.DataObjectType;
+import com.cloud.agent.api.to.DataStoreTO;
+import com.cloud.agent.api.to.NfsTO;
+import com.cloud.storage.Storage;
+import com.cloud.storage.VMTemplateVO;
+import com.cloud.storage.VolumeVO;
+import com.cloud.storage.dao.VMTemplateDao;
+import com.cloud.storage.dao.VolumeDao;
+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.framework.async.AsyncCallbackDispatcher;
+import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
+import org.apache.cloudstack.framework.async.AsyncRpcContext;
+import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
+import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
+import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreDao;
+import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreVO;
+import org.apache.cloudstack.storage.image.BaseImageStoreDriverImpl;
+import org.apache.cloudstack.storage.image.store.ImageStoreImpl;
+
+import javax.inject.Inject;
+import java.util.Date;
+
+public class SimulatorImageStoreDriverImpl extends BaseImageStoreDriverImpl {
+
+    @Inject
+    TemplateDataStoreDao _templateStoreDao;
+    @Inject
+    VMTemplateDao _templateDao;
+    @Inject
+    VolumeDao _volumeDao;
+    @Inject
+    VolumeDataStoreDao _volumeStoreDao;
+
+    @Override
+    public DataStoreTO getStoreTO(DataStore store) {
+        ImageStoreImpl nfsStore = (ImageStoreImpl) store;
+        NfsTO nfsTO = new NfsTO();
+        nfsTO.setRole(store.getRole());
+        nfsTO.setUrl(nfsStore.getUri());
+        return nfsTO;
+    }
+
+    class CreateContext<T> extends AsyncRpcContext<T> {
+        final DataObject data;
+
+        public CreateContext(AsyncCompletionCallback<T> callback, DataObject data) {
+            super(callback);
+            this.data = data;
+        }
+    }
+
+    public String createEntityExtractUrl(DataStore store, String installPath, Storage.ImageFormat format) {
+        return null;
+    }
+
+    @Override
+    public void createAsync(DataObject data, AsyncCompletionCallback<CreateCmdResult> callback) {
+        CreateContext<CreateCmdResult> context = new CreateContext<CreateCmdResult>(callback, data);
+        AsyncCallbackDispatcher<SimulatorImageStoreDriverImpl, DownloadAnswer> caller = AsyncCallbackDispatcher
+                .create(this);
+        caller.setContext(context);
+        if (data.getType() == DataObjectType.TEMPLATE) {
+            this.createTemplateAsyncCallback(caller, context);
+        } else if (data.getType() == DataObjectType.VOLUME) {
+            this.createVolumeAsyncCallback(caller, context);
+        }
+    }
+
+    protected Void createTemplateAsyncCallback(AsyncCallbackDispatcher<SimulatorImageStoreDriverImpl, DownloadAnswer> callback,
+                                               CreateContext<CreateCmdResult> context) {
+        DownloadAnswer answer = callback.getResult();
+        DataObject obj = context.data;
+        DataStore store = obj.getDataStore();
+
+        TemplateDataStoreVO tmpltStoreVO = _templateStoreDao.findByStoreTemplate(store.getId(), obj.getId());
+        if (tmpltStoreVO != null) {
+            TemplateDataStoreVO updateBuilder = _templateStoreDao.createForUpdate();
+            updateBuilder.setDownloadPercent(answer.getDownloadPct());
+            updateBuilder.setDownloadState(answer.getDownloadStatus());
+            updateBuilder.setLastUpdated(new Date());
+            updateBuilder.setErrorString(answer.getErrorString());
+            updateBuilder.setJobId(answer.getJobId());
+            updateBuilder.setLocalDownloadPath(answer.getDownloadPath());
+            updateBuilder.setInstallPath(answer.getInstallPath());
+            updateBuilder.setSize(answer.getTemplateSize());
+            updateBuilder.setPhysicalSize(answer.getTemplatePhySicalSize());
+            _templateStoreDao.update(tmpltStoreVO.getId(), updateBuilder);
+            // update size in vm_template table
+            VMTemplateVO tmlptUpdater = _templateDao.createForUpdate();
+            tmlptUpdater.setSize(answer.getTemplateSize());
+            _templateDao.update(obj.getId(), tmlptUpdater);
+        }
+
+        return null;
+    }
+
+    protected Void createVolumeAsyncCallback(AsyncCallbackDispatcher<SimulatorImageStoreDriverImpl, DownloadAnswer> callback,
+                                             CreateContext<CreateCmdResult> context) {
+        DownloadAnswer answer = callback.getResult();
+        DataObject obj = context.data;
+        DataStore store = obj.getDataStore();
+
+        VolumeDataStoreVO volStoreVO = _volumeStoreDao.findByStoreVolume(store.getId(), obj.getId());
+        if (volStoreVO != null) {
+            VolumeDataStoreVO updateBuilder = _volumeStoreDao.createForUpdate();
+            updateBuilder.setDownloadPercent(answer.getDownloadPct());
+            updateBuilder.setDownloadState(answer.getDownloadStatus());
+            updateBuilder.setLastUpdated(new Date());
+            updateBuilder.setErrorString(answer.getErrorString());
+            updateBuilder.setJobId(answer.getJobId());
+            updateBuilder.setLocalDownloadPath(answer.getDownloadPath());
+            updateBuilder.setInstallPath(answer.getInstallPath());
+            updateBuilder.setSize(answer.getTemplateSize());
+            updateBuilder.setPhysicalSize(answer.getTemplatePhySicalSize());
+            _volumeStoreDao.update(volStoreVO.getId(), updateBuilder);
+            // update size in volume table
+            VolumeVO volUpdater = _volumeDao.createForUpdate();
+            volUpdater.setSize(answer.getTemplateSize());
+            _volumeDao.update(obj.getId(), volUpdater);
+        }
+
+        return null;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fd867d5a/plugins/storage/image/simulator/src/org/apache/cloudstack/storage/datastore/lifecycle/SimulatorImageStoreLifeCycleImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/image/simulator/src/org/apache/cloudstack/storage/datastore/lifecycle/SimulatorImageStoreLifeCycleImpl.java b/plugins/storage/image/simulator/src/org/apache/cloudstack/storage/datastore/lifecycle/SimulatorImageStoreLifeCycleImpl.java
new file mode 100644
index 0000000..beaa7a5
--- /dev/null
+++ b/plugins/storage/image/simulator/src/org/apache/cloudstack/storage/datastore/lifecycle/SimulatorImageStoreLifeCycleImpl.java
@@ -0,0 +1,132 @@
+/*
+ * 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 com.cloud.agent.api.StoragePoolInfo;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.hypervisor.Hypervisor;
+import com.cloud.storage.DataStoreRole;
+import com.cloud.storage.ScopeType;
+import com.cloud.utils.UriUtils;
+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.datastore.db.ImageStoreVO;
+import org.apache.cloudstack.storage.image.datastore.ImageStoreHelper;
+import org.apache.cloudstack.storage.image.datastore.ImageStoreProviderManager;
+import org.apache.cloudstack.storage.image.store.lifecycle.ImageStoreLifeCycle;
+import org.apache.log4j.Logger;
+
+import javax.inject.Inject;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.HashMap;
+import java.util.Map;
+
+public class SimulatorImageStoreLifeCycleImpl implements ImageStoreLifeCycle {
+    private static final Logger s_logger = Logger.getLogger(SimulatorImageStoreLifeCycleImpl.class);
+
+    @Inject
+    ImageStoreHelper imageStoreHelper;
+
+    @Inject
+    ImageStoreProviderManager imageStoreMgr;
+
+
+    @Override
+    public DataStore initialize(Map<String, Object> dsInfos) {
+        Long dcId = (Long) dsInfos.get("zoneId");
+        String url = (String) dsInfos.get("url");
+        String name = (String) dsInfos.get("name");
+        if (name == null) {
+            name = url;
+        }
+        String providerName = (String) dsInfos.get("providerName");
+        DataStoreRole role = (DataStoreRole) dsInfos.get("role");
+        Map<String, String> details = (Map<String, String>) dsInfos.get("details");
+
+        s_logger.info("Trying to add a new data store at " + url + " to data center " + dcId);
+
+        URI uri;
+        try {
+            uri = new URI(UriUtils.encodeURIComponent(url));
+            if (uri.getScheme() == null) {
+                throw new InvalidParameterValueException("uri.scheme is null " + url + ", add nfs:// as a prefix");
+            } else if (uri.getScheme().equalsIgnoreCase("nfs")) {
+                if (uri.getHost() == null || uri.getHost().equalsIgnoreCase("") || uri.getPath() == null
+                        || uri.getPath().equalsIgnoreCase("")) {
+                    throw new InvalidParameterValueException(
+                            "Your host and/or path is wrong.  Make sure it is of the format nfs://hostname/path");
+                }
+            }
+        } catch (URISyntaxException e) {
+            throw new InvalidParameterValueException(url + " is not a valid uri");
+        }
+
+        if (dcId == null) {
+            throw new InvalidParameterValueException(
+                    "DataCenter id is null, and simulator image store has to be associated with a data center");
+        }
+
+        Map<String, Object> imageStoreParameters = new HashMap<String, Object>();
+        imageStoreParameters.put("name", name);
+        imageStoreParameters.put("zoneId", dcId);
+        imageStoreParameters.put("url", url);
+        imageStoreParameters.put("protocol", uri.getScheme().toLowerCase());
+        imageStoreParameters.put("scope", ScopeType.ZONE);
+        imageStoreParameters.put("providerName", providerName);
+        imageStoreParameters.put("role", role);
+
+        ImageStoreVO ids = imageStoreHelper.createImageStore(imageStoreParameters, details);
+        return imageStoreMgr.getImageStore(ids.getId());
+    }
+
+    @Override
+    public boolean attachCluster(DataStore store, ClusterScope scope) {
+        return false;
+    }
+
+    @Override
+    public boolean attachHost(DataStore store, HostScope scope, StoragePoolInfo existingInfo) {
+        return false;
+    }
+
+    @Override
+    public boolean attachZone(DataStore dataStore, ZoneScope scope, Hypervisor.HypervisorType hypervisorType) {
+        return false;
+    }
+
+    @Override
+    public boolean maintain(DataStore store) {
+        return false;
+    }
+
+    @Override
+    public boolean cancelMaintain(DataStore store) {
+        return false;
+    }
+
+    @Override
+    public boolean deleteDataStore(DataStore store) {
+        return false;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/fd867d5a/plugins/storage/image/simulator/src/org/apache/cloudstack/storage/datastore/provider/SimulatorImageStoreProviderImpl.java
----------------------------------------------------------------------
diff --git a/plugins/storage/image/simulator/src/org/apache/cloudstack/storage/datastore/provider/SimulatorImageStoreProviderImpl.java b/plugins/storage/image/simulator/src/org/apache/cloudstack/storage/datastore/provider/SimulatorImageStoreProviderImpl.java
new file mode 100644
index 0000000..775d743
--- /dev/null
+++ b/plugins/storage/image/simulator/src/org/apache/cloudstack/storage/datastore/provider/SimulatorImageStoreProviderImpl.java
@@ -0,0 +1,98 @@
+/*
+ * 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 com.cloud.storage.ScopeType;
+import com.cloud.utils.component.ComponentContext;
+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.DataStoreProvider;
+import org.apache.cloudstack.engine.subsystem.api.storage.HypervisorHostListener;
+import org.apache.cloudstack.engine.subsystem.api.storage.ImageStoreProvider;
+import org.apache.cloudstack.storage.datastore.driver.SimulatorImageStoreDriverImpl;
+import org.apache.cloudstack.storage.datastore.lifecycle.SimulatorImageStoreLifeCycleImpl;
+import org.apache.cloudstack.storage.image.ImageStoreDriver;
+import org.apache.cloudstack.storage.image.datastore.ImageStoreHelper;
+import org.apache.cloudstack.storage.image.datastore.ImageStoreProviderManager;
+import org.apache.cloudstack.storage.image.store.lifecycle.ImageStoreLifeCycle;
+import org.springframework.stereotype.Component;
+
+import javax.inject.Inject;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+@Component
+public class SimulatorImageStoreProviderImpl implements ImageStoreProvider {
+
+    private final String _providerName = DataStoreProvider.NFS_IMAGE;
+    protected ImageStoreLifeCycle lifeCycle;
+    protected ImageStoreDriver driver;
+
+    @Inject
+    ImageStoreProviderManager storeMgr;
+    @Inject
+    ImageStoreHelper helper;
+
+    @Override
+    public boolean isScopeSupported(ScopeType scope) {
+        return true;
+    }
+
+    @Override
+    public boolean needDownloadSysTemplate() {
+        return false;
+    }
+
+    @Override
+    public DataStoreLifeCycle getDataStoreLifeCycle() {
+        return this.lifeCycle;
+    }
+
+    @Override
+    public DataStoreDriver getDataStoreDriver() {
+        return this.driver;
+    }
+
+    @Override
+    public HypervisorHostListener getHostListener() {
+        return null;
+    }
+
+    @Override
+    public String getName() {
+        return this._providerName;
+    }
+
+    @Override
+    public boolean configure(Map<String, Object> params) {
+        lifeCycle = ComponentContext.inject(SimulatorImageStoreLifeCycleImpl.class);
+        driver = ComponentContext.inject(SimulatorImageStoreDriverImpl.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;
+    }
+}