incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t..@apache.org
Subject [7/8] Simulator: moving hypervisor simulator into plugin
Date Sat, 22 Dec 2012 21:03:04 GMT
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6083ce5/plugins/hypervisors/simulator/src/com/cloud/resource/SimulatorDiscoverer.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/resource/SimulatorDiscoverer.java b/plugins/hypervisors/simulator/src/com/cloud/resource/SimulatorDiscoverer.java
new file mode 100755
index 0000000..b6d40d4
--- /dev/null
+++ b/plugins/hypervisors/simulator/src/com/cloud/resource/SimulatorDiscoverer.java
@@ -0,0 +1,336 @@
+// 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 com.cloud.resource;
+
+import java.net.URI;
+import java.net.URLDecoder;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import javax.ejb.Local;
+import javax.naming.ConfigurationException;
+
+import org.apache.log4j.Logger;
+
+import com.cloud.agent.AgentManager;
+import com.cloud.agent.Listener;
+import com.cloud.agent.api.AgentControlAnswer;
+import com.cloud.agent.api.AgentControlCommand;
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.Command;
+import com.cloud.agent.api.StartupCommand;
+import com.cloud.agent.api.StartupRoutingCommand;
+import com.cloud.agent.manager.MockAgentManager;
+import com.cloud.agent.manager.MockStorageManager;
+import com.cloud.dc.ClusterVO;
+import com.cloud.dc.dao.ClusterDao;
+import com.cloud.exception.ConnectionException;
+import com.cloud.exception.DiscoveryException;
+import com.cloud.host.Host;
+import com.cloud.host.HostVO;
+import com.cloud.host.Status;
+import com.cloud.host.dao.HostDao;
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
+import com.cloud.storage.VMTemplateHostVO;
+import com.cloud.storage.VMTemplateVO;
+import com.cloud.storage.VMTemplateZoneVO;
+import com.cloud.storage.dao.VMTemplateDao;
+import com.cloud.storage.dao.VMTemplateHostDao;
+import com.cloud.storage.dao.VMTemplateZoneDao;
+import com.cloud.utils.component.Inject;
+
+@Local(value = Discoverer.class)
+public class SimulatorDiscoverer extends DiscovererBase implements Discoverer, Listener, ResourceStateAdapter {
+	private static final Logger s_logger = Logger
+			.getLogger(SimulatorDiscoverer.class);
+
+	@Inject HostDao _hostDao;
+	@Inject VMTemplateDao _vmTemplateDao;
+    @Inject VMTemplateHostDao _vmTemplateHostDao;
+    @Inject VMTemplateZoneDao _vmTemplateZoneDao;
+    @Inject ClusterDao _clusterDao;
+    @Inject AgentManager _agentMgr = null;
+    @Inject MockAgentManager _mockAgentMgr = null;
+    @Inject MockStorageManager _mockStorageMgr = null;
+    @Inject ResourceManager _resourceMgr;
+
+	/**
+	 * Finds ServerResources of an in-process simulator
+	 *
+	 * @see com.cloud.resource.Discoverer#find(long, java.lang.Long,
+	 *      java.lang.Long, java.net.URI, java.lang.String, java.lang.String)
+	 */
+	@Override
+	public Map<? extends ServerResource, Map<String, String>> find(long dcId,
+			Long podId, Long clusterId, URI uri, String username,
+			String password, List<String> hostTags) throws DiscoveryException {
+		Map<AgentResourceBase, Map<String, String>> resources;
+
+		try {
+		    //http://sim/count=$count, it will add $count number of hosts into the cluster
+		    String scheme = uri.getScheme();
+		    String host = uri.getAuthority();
+		    String commands = URLDecoder.decode(uri.getPath());
+
+		    long cpuSpeed = _mockAgentMgr.DEFAULT_HOST_SPEED_MHZ;
+		    long cpuCores = _mockAgentMgr.DEFAULT_HOST_CPU_CORES;
+		    long memory = _mockAgentMgr.DEFAULT_HOST_MEM_SIZE;
+		    long localstorageSize = _mockStorageMgr.DEFAULT_HOST_STORAGE_SIZE;
+			if (scheme.equals("http")) {
+				if (host == null || !host.startsWith("sim")) {
+					String msg = "uri is not of simulator type so we're not taking care of the discovery for this: "
+							+ uri;
+					if(s_logger.isDebugEnabled()) {
+						s_logger.debug(msg);
+					}
+					return null;
+				}
+				if (commands != null) {
+				    int index = commands.lastIndexOf("/");
+				    if (index != -1) {
+				        commands = commands.substring(index+1);
+
+				        String[] cmds = commands.split("&");
+				        for (String cmd : cmds) {
+				            String[] parameter = cmd.split("=");
+				            if (parameter[0].equalsIgnoreCase("cpuspeed") && parameter[1] != null) {
+				                cpuSpeed = Long.parseLong(parameter[1]);
+				            } else if (parameter[0].equalsIgnoreCase("cpucore") && parameter[1] != null) {
+				                cpuCores = Long.parseLong(parameter[1]);
+				            } else if (parameter[0].equalsIgnoreCase("memory") && parameter[1] != null) {
+				                memory = Long.parseLong(parameter[1]);
+				            } else if (parameter[0].equalsIgnoreCase("localstorage") && parameter[1] != null) {
+				                localstorageSize = Long.parseLong(parameter[1]);
+				            }
+				        }
+				    }
+				}
+			} else {
+				String msg = "uriString is not http so we're not taking care of the discovery for this: "
+						+ uri;
+				if(s_logger.isDebugEnabled()) {
+					s_logger.debug(msg);
+				}
+				return null;
+			}
+
+			String cluster = null;
+			if (clusterId == null) {
+				String msg = "must specify cluster Id when adding host";
+				if(s_logger.isDebugEnabled()) {
+					s_logger.debug(msg);
+				}
+				throw new RuntimeException(msg);
+			} else {
+				ClusterVO clu = _clusterDao.findById(clusterId);
+				if (clu == null
+						|| (clu.getHypervisorType() != HypervisorType.Simulator)) {
+					if (s_logger.isInfoEnabled())
+						s_logger.info("invalid cluster id or cluster is not for Simulator hypervisors");
+					return null;
+				}
+				cluster = Long.toString(clusterId);
+				if(clu.getGuid() == null) {
+					clu.setGuid(UUID.randomUUID().toString());
+				}
+				_clusterDao.update(clusterId, clu);
+			}
+
+			String pod;
+			if (podId == null) {
+				String msg = "must specify pod Id when adding host";
+				if(s_logger.isDebugEnabled()) {
+					s_logger.debug(msg);
+				}
+				throw new RuntimeException(msg);
+			} else {
+				pod = Long.toString(podId);
+			}
+
+			Map<String, String> details = new HashMap<String, String>();
+			Map<String, Object> params = new HashMap<String, Object>();
+			details.put("username", username);
+			params.put("username", username);
+			details.put("password", password);
+			params.put("password", password);
+			params.put("zone", Long.toString(dcId));
+			params.put("pod", pod);
+			params.put("cluster", cluster);
+			params.put("cpuspeed", Long.toString(cpuSpeed));
+			params.put("cpucore", Long.toString(cpuCores));
+			params.put("memory", Long.toString(memory));
+			params.put("localstorage", Long.toString(localstorageSize));
+
+			resources = createAgentResources(params);
+			return resources;
+		} catch (Exception ex) {
+			s_logger.error("Exception when discovering simulator hosts: "
+					+ ex.getMessage());
+		}
+		return null;
+	}
+
+	private Map<AgentResourceBase, Map<String, String>> createAgentResources(
+			Map<String, Object> params) {
+		try {
+			s_logger.info("Creating Simulator Resources");
+			return _mockAgentMgr.createServerResources(params);
+		} catch (Exception ex) {
+			s_logger.warn("Caught exception at agent resource creation: "
+					+ ex.getMessage(), ex);
+		}
+		return null;
+	}
+
+	@Override
+	public void postDiscovery(List<HostVO> hosts, long msId) {
+
+		for (HostVO h : hosts) {
+			associateTemplatesToZone(h.getId(), h.getDataCenterId());
+		}
+	}
+
+    private void associateTemplatesToZone(long hostId, long dcId){
+	VMTemplateZoneVO tmpltZone;
+
+	List<VMTemplateVO> allTemplates = _vmTemplateDao.listAll();
+	for (VMTemplateVO vt: allTemplates){
+		if (vt.isCrossZones()) {
+			tmpltZone = _vmTemplateZoneDao.findByZoneTemplate(dcId, vt.getId());
+			if (tmpltZone == null) {
+				VMTemplateZoneVO vmTemplateZone = new VMTemplateZoneVO(dcId, vt.getId(), new Date());
+				_vmTemplateZoneDao.persist(vmTemplateZone);
+			}
+		}
+	}
+    }
+
+	@Override
+	public HypervisorType getHypervisorType() {
+		return HypervisorType.Simulator;
+	}
+
+	@Override
+	public boolean matchHypervisor(String hypervisor) {
+		return hypervisor.equalsIgnoreCase(HypervisorType.Simulator.toString());
+	}
+
+    @Override
+    public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
+        super.configure(name, params);
+        _agentMgr.registerForHostEvents(this, true, false, false);
+        _resourceMgr.registerResourceStateAdapter(this.getClass().getSimpleName(), this);
+        return true;
+    }
+
+    @Override
+    public boolean processAnswers(long agentId, long seq, Answer[] answers) {
+        return false;
+    }
+
+    @Override
+    public boolean processCommands(long agentId, long seq, Command[] commands) {
+        return false;
+    }
+
+    @Override
+    public AgentControlAnswer processControlCommand(long agentId, AgentControlCommand cmd) {
+        return null;
+    }
+
+    @Override
+    public void processConnect(HostVO host, StartupCommand cmd, boolean forRebalance) throws ConnectionException {
+
+        /*if(forRebalance)
+		return;
+        if ( Host.Type.SecondaryStorage == host.getType() ) {
+            List<VMTemplateVO> tmplts = _vmTemplateDao.listAll();
+            for( VMTemplateVO tmplt : tmplts ) {
+                VMTemplateHostVO vmTemplateHost = _vmTemplateHostDao.findByHostTemplate(host.getId(), tmplt.getId());
+                if (vmTemplateHost == null) {
+                    vmTemplateHost = new VMTemplateHostVO(host.getId(), tmplt.getId(), new Date(), 100,
+                            com.cloud.storage.VMTemplateStorageResourceAssoc.Status.DOWNLOADED, null, null, null, null, tmplt.getUrl());
+                    _vmTemplateHostDao.persist(vmTemplateHost);
+                } else {
+                    vmTemplateHost.setDownloadState(com.cloud.storage.VMTemplateStorageResourceAssoc.Status.DOWNLOADED);
+                    vmTemplateHost.setDownloadPercent(100);
+                    _vmTemplateHostDao.update(vmTemplateHost.getId(), vmTemplateHost);
+                }
+            }
+        }*/
+
+    }
+
+    @Override
+    public boolean processDisconnect(long agentId, Status state) {
+        return false;
+    }
+
+    @Override
+    public boolean isRecurring() {
+        return false;
+    }
+
+    @Override
+    public int getTimeout() {
+        return 0;
+    }
+
+    @Override
+    public boolean processTimeout(long agentId, long seq) {
+        return false;
+    }
+
+	@Override
+	public HostVO createHostVOForConnectedAgent(HostVO host,
+			StartupCommand[] cmd) {
+		return null;
+	}
+
+	@Override
+	public HostVO createHostVOForDirectConnectAgent(HostVO host,
+			StartupCommand[] startup, ServerResource resource,
+			Map<String, String> details, List<String> hostTags) {
+		StartupCommand firstCmd = startup[0];
+		if (!(firstCmd instanceof StartupRoutingCommand)) {
+			return null;
+		}
+
+		StartupRoutingCommand ssCmd = ((StartupRoutingCommand) firstCmd);
+		if (ssCmd.getHypervisorType() != HypervisorType.Simulator) {
+			return null;
+		}
+
+		return _resourceMgr.fillRoutingHostVO(host, ssCmd, HypervisorType.Simulator, details, hostTags);
+	}
+
+	@Override
+	public DeleteHostAnswer deleteHost(HostVO host, boolean isForced,
+			boolean isForceDeleteStorage) throws UnableDeleteHostException {
+		return null;
+	}
+
+    @Override
+    public boolean stop() {
+	_resourceMgr.unregisterResourceStateAdapter(this.getClass().getSimpleName());
+        return super.stop();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6083ce5/plugins/hypervisors/simulator/src/com/cloud/resource/SimulatorSecondaryDiscoverer.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/resource/SimulatorSecondaryDiscoverer.java b/plugins/hypervisors/simulator/src/com/cloud/resource/SimulatorSecondaryDiscoverer.java
new file mode 100644
index 0000000..5d4d5b9
--- /dev/null
+++ b/plugins/hypervisors/simulator/src/com/cloud/resource/SimulatorSecondaryDiscoverer.java
@@ -0,0 +1,151 @@
+// 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 com.cloud.resource;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.ejb.Local;
+import javax.naming.ConfigurationException;
+
+import com.cloud.agent.AgentManager;
+import com.cloud.agent.Listener;
+import com.cloud.agent.api.AgentControlAnswer;
+import com.cloud.agent.api.AgentControlCommand;
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.Command;
+import com.cloud.agent.api.StartupCommand;
+import com.cloud.agent.api.StartupSecondaryStorageCommand;
+import com.cloud.agent.manager.MockStorageManager;
+import com.cloud.exception.ConnectionException;
+import com.cloud.host.HostVO;
+import com.cloud.host.Status;
+import com.cloud.storage.SnapshotVO;
+import com.cloud.storage.dao.SnapshotDao;
+import com.cloud.storage.secondary.SecondaryStorageDiscoverer;
+import com.cloud.utils.component.Inject;
+import com.cloud.utils.exception.CloudRuntimeException;
+@Local(value=Discoverer.class)
+public class SimulatorSecondaryDiscoverer extends SecondaryStorageDiscoverer implements ResourceStateAdapter, Listener {
+    @Inject MockStorageManager _mockStorageMgr = null;
+    @Inject AgentManager _agentMgr;
+    @Inject ResourceManager _resourceMgr;
+    @Inject SnapshotDao _snapshotDao;
+
+    @Override
+    public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
+	_agentMgr.registerForHostEvents(this, true, false, false);
+        _resourceMgr.registerResourceStateAdapter(this.getClass().getSimpleName(), this);
+        return super.configure(name, params);
+    }
+
+    @Override
+    public void postDiscovery(List<HostVO> hosts, long msId) {
+        super.postDiscovery(hosts, msId);
+        for (HostVO host: hosts) {
+            _mockStorageMgr.preinstallTemplates(host.getStorageUrl(), host.getDataCenterId());
+        }
+    }
+
+	@Override
+	public HostVO createHostVOForConnectedAgent(HostVO host,
+			StartupCommand[] cmd) {
+		return null;
+	}
+
+	@Override
+	public HostVO createHostVOForDirectConnectAgent(HostVO host,
+			StartupCommand[] startup, ServerResource resource,
+			Map<String, String> details, List<String> hostTags) {
+		//for detecting SSVM dispatch
+		StartupCommand firstCmd = startup[0];
+	    if (!(firstCmd instanceof StartupSecondaryStorageCommand)) {
+		return null;
+	    }
+
+		host.setType(com.cloud.host.Host.Type.SecondaryStorageVM);
+		return host;
+	}
+
+	@Override
+	public DeleteHostAnswer deleteHost(HostVO host, boolean isForced,
+			boolean isForceDeleteStorage) throws UnableDeleteHostException {
+		long hostId = host.getId();
+		List<SnapshotVO> snapshots = _snapshotDao.listByHostId(hostId);
+		if (snapshots != null && !snapshots.isEmpty()) {
+			throw new CloudRuntimeException("Cannot delete this secondary storage because there are still snapshots on it ");
+		}
+		_vmTemplateHostDao.deleteByHost(hostId);
+		host.setGuid(null);
+		_hostDao.update(hostId, host);
+		_hostDao.remove(hostId);
+		return new DeleteHostAnswer(true);
+	}
+
+    @Override
+    public boolean start() {
+        return true;
+    }
+
+    @Override
+    public boolean stop() {
+	_resourceMgr.unregisterResourceStateAdapter(this.getClass().getSimpleName());
+        return true;
+    }
+
+	@Override
+	public int getTimeout() {
+		return 0;
+	}
+
+	@Override
+	public boolean isRecurring() {
+		return false;
+	}
+
+	@Override
+	public boolean processAnswers(long agentId, long seq, Answer[] answers) {
+		return false;
+	}
+
+	@Override
+	public boolean processCommands(long agentId, long seq, Command[] commands) {
+		return false;
+	}
+
+	@Override
+	public void processConnect(HostVO host, StartupCommand cmd,
+			boolean forRebalance) throws ConnectionException {
+
+	}
+
+	@Override
+	public AgentControlAnswer processControlCommand(long agentId,
+			AgentControlCommand cmd) {
+		return null;
+	}
+
+	@Override
+	public boolean processDisconnect(long agentId, Status state) {
+		return false;
+	}
+
+	@Override
+	public boolean processTimeout(long agentId, long seq) {
+		return false;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6083ce5/plugins/hypervisors/simulator/src/com/cloud/server/ManagementServerSimulatorImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/server/ManagementServerSimulatorImpl.java b/plugins/hypervisors/simulator/src/com/cloud/server/ManagementServerSimulatorImpl.java
new file mode 100644
index 0000000..35aa301
--- /dev/null
+++ b/plugins/hypervisors/simulator/src/com/cloud/server/ManagementServerSimulatorImpl.java
@@ -0,0 +1,32 @@
+// 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 com.cloud.server;
+
+
+public class ManagementServerSimulatorImpl extends ManagementServerExtImpl {
+    @Override
+    public String[] getApiConfig() {
+        String[] apis = super.getApiConfig();
+        String[] newapis = new String[apis.length + 1];
+        for (int i = 0; i < apis.length; i++) {
+            newapis[i] = apis[i];
+        }
+
+        newapis[apis.length] = "commands-simulator.properties";
+        return newapis;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6083ce5/plugins/hypervisors/simulator/src/com/cloud/simulator/MockConfigurationVO.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/simulator/MockConfigurationVO.java b/plugins/hypervisors/simulator/src/com/cloud/simulator/MockConfigurationVO.java
new file mode 100644
index 0000000..3ed862b
--- /dev/null
+++ b/plugins/hypervisors/simulator/src/com/cloud/simulator/MockConfigurationVO.java
@@ -0,0 +1,120 @@
+// 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 com.cloud.simulator;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Entity
+@Table(name="mockconfiguration")
+public class MockConfigurationVO {
+    @Id
+    @GeneratedValue(strategy=GenerationType.IDENTITY)
+    @Column(name="id")
+    private long id;
+
+    @Column(name="data_center_id", nullable=false)
+    private Long dataCenterId;
+
+    @Column(name="pod_id")
+    private Long podId;
+
+    @Column(name="cluster_id")
+    private Long clusterId;
+
+    @Column(name="host_id")
+    private Long hostId;
+
+    @Column(name="name")
+    private String name;
+
+    @Column(name="values")
+    private String values;
+
+    public long getId() {
+        return this.id;
+    }
+
+    public Long getDataCenterId() {
+        return this.dataCenterId;
+    }
+
+    public void setDataCenterId(Long dcId) {
+        this.dataCenterId = dcId;
+    }
+
+    public Long getPodId() {
+        return this.podId;
+    }
+
+    public void setPodId(Long podId) {
+        this.podId = podId;
+    }
+
+    public Long getClusterId() {
+        return this.clusterId;
+    }
+
+    public void setClusterId(Long clusterId) {
+        this.clusterId = clusterId;
+    }
+
+    public Long getHostId() {
+        return this.hostId;
+    }
+
+    public void setHostId(Long hostId) {
+        this.hostId = hostId;
+    }
+
+    public String getName() {
+        return this.name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getValues() {
+        return this.values;
+    }
+
+    public Map<String, String> getParameters() {
+        Map<String, String> maps = new HashMap<String, String>();
+        if (this.values == null) {
+            return maps;
+        }
+
+        String[] vals = this.values.split("\\|");
+        for (String val : vals) {
+            String[] paras = val.split(":");
+            maps.put(paras[0], paras[1]);
+        }
+        return maps;
+    }
+
+    public void setValues(String values) {
+        this.values = values;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6083ce5/plugins/hypervisors/simulator/src/com/cloud/simulator/MockHost.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/simulator/MockHost.java b/plugins/hypervisors/simulator/src/com/cloud/simulator/MockHost.java
new file mode 100644
index 0000000..5ca9017
--- /dev/null
+++ b/plugins/hypervisors/simulator/src/com/cloud/simulator/MockHost.java
@@ -0,0 +1,62 @@
+// 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 com.cloud.simulator;
+
+public interface MockHost {
+    public long getCpuSpeed();
+    public long getCpuCount();
+
+
+    public long getMemorySize();
+
+    public String getCapabilities();
+
+    public long getId();
+
+    public String getName();
+
+    public String getGuid();
+
+
+    public String getVersion();
+
+    public Long getDataCenterId();
+
+    public Long getPodId();
+
+    public Long getClusterId();
+
+    public String getPrivateIpAddress();
+
+    public String getPrivateNetMask();
+
+    public String getPrivateMacAddress();
+
+
+    public String getPublicIpAddress();
+
+    public String getPublicNetMask();
+
+    public String getPublicMacAddress();
+
+    public String getStorageIpAddress();
+
+    public String getStorageNetMask();
+
+    public String getStorageMacAddress();
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6083ce5/plugins/hypervisors/simulator/src/com/cloud/simulator/MockHostVO.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/simulator/MockHostVO.java b/plugins/hypervisors/simulator/src/com/cloud/simulator/MockHostVO.java
new file mode 100644
index 0000000..c86dfa6
--- /dev/null
+++ b/plugins/hypervisors/simulator/src/com/cloud/simulator/MockHostVO.java
@@ -0,0 +1,276 @@
+// 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 com.cloud.simulator;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Entity
+@Table(name="mockhost")
+
+public class MockHostVO implements MockHost {
+    @Id
+    @GeneratedValue(strategy=GenerationType.IDENTITY)
+    @Column(name="id")
+    private long id;
+
+    @Column(name="name", nullable=false)
+    private String name = null;
+
+    @Column(name="private_ip_address", nullable=false)
+    private String privateIpAddress;
+
+    @Column(name="private_mac_address", nullable=false)
+    private String privateMacAddress;
+
+    @Column(name="private_netmask", nullable=false)
+    private String privateNetmask;
+
+    @Column(name="public_netmask")
+    private String publicNetmask;
+
+    @Column(name="public_ip_address")
+    private String publicIpAddress;
+
+    @Column(name="public_mac_address")
+    private String publicMacAddress;
+
+    @Column(name="storage_ip_address")
+    private String storageIpAddress;
+
+    @Column(name="storage_mac_address")
+    private String storageMacAddress;
+
+    @Column(name="storage_netmask")
+    private String storageNetMask;
+
+    @Column(name="guid")
+    private String guid;
+
+    @Column(name="version")
+    private String version;
+
+    @Column(name="data_center_id", nullable=false)
+    private long dataCenterId;
+
+    @Column(name="pod_id")
+    private Long podId;
+
+    @Column(name="cluster_id")
+    private Long clusterId;
+
+    @Column(name="speed")
+    private long cpuSpeed;
+
+    @Column(name="cpus")
+    private long cpuCount;
+
+    @Column(name="ram")
+    private long memorySize;
+
+    @Column(name="capabilities")
+    private String capabilities;
+
+    @Column(name="vm_id")
+    private long vmId;
+
+    @Column(name="resource")
+    private String resource;
+
+
+
+    public MockHostVO() {
+
+    }
+
+
+    public long getVmId() {
+        return vmId;
+    }
+
+    public void setVmId(long vmId) {
+        this.vmId = vmId;
+    }
+
+    public String getResource() {
+        return this.resource;
+    }
+
+    public void setResource(String resource) {
+        this.resource = resource;
+    }
+
+    public long getCpuSpeed() {
+        return this.cpuSpeed;
+    }
+
+    public void setCpuSpeed(long cpuSpeed) {
+        this.cpuSpeed = cpuSpeed;
+    }
+
+    public long getCpuCount() {
+        return this.cpuCount;
+    }
+
+    public void setCpuCount(long cpuCount) {
+        this.cpuCount = cpuCount;
+    }
+
+    public long getMemorySize() {
+        return this.memorySize;
+    }
+
+    public void setMemorySize(long memorySize) {
+        this.memorySize = memorySize;
+    }
+
+    public String getCapabilities() {
+        return this.capabilities;
+    }
+
+    public void setCapabilities(String capabilities) {
+        this.capabilities = capabilities;
+    }
+
+    public long getId() {
+        return id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getGuid() {
+        return this.guid;
+    }
+
+    public void setGuid(String guid) {
+        this.guid = guid;
+    }
+
+    public String getVersion() {
+        return this.version;
+    }
+
+    public void setVersion(String version) {
+        this.version = version;
+    }
+
+    public Long getDataCenterId() {
+        return this.dataCenterId;
+    }
+
+    public void setDataCenterId(Long dataCenterId) {
+        this.dataCenterId = dataCenterId;
+    }
+
+    public Long getPodId() {
+        return this.podId;
+    }
+
+    public void setPodId(long podId) {
+        this.podId = podId;
+    }
+
+    public Long getClusterId() {
+        return this.clusterId;
+    }
+
+    public void setClusterId(Long clusterId) {
+        this.clusterId = clusterId;
+    }
+
+    public String getPrivateIpAddress() {
+        return privateIpAddress;
+    }
+
+    public void setPrivateIpAddress(String privateIpAddress) {
+        this.privateIpAddress = privateIpAddress;
+    }
+
+    public String getPrivateNetMask() {
+        return this.privateNetmask;
+    }
+
+    public void setPrivateNetMask(String privateNetmask) {
+        this.privateNetmask = privateNetmask;
+    }
+
+    public String getPrivateMacAddress() {
+        return this.privateMacAddress;
+    }
+
+    public void setPrivateMacAddress(String privateMacAddress) {
+        this.privateMacAddress = privateMacAddress;
+    }
+
+    public String getPublicIpAddress() {
+        return this.publicIpAddress;
+    }
+
+    public void setPublicIpAddress(String publicIpAddress) {
+        this.publicIpAddress = publicIpAddress;
+    }
+
+    public String getPublicNetMask() {
+        return this.publicNetmask;
+    }
+
+    public void setPublicNetMask(String publicNetMask) {
+        this.publicNetmask = publicNetMask;
+    }
+
+    public String getPublicMacAddress() {
+        return this.publicMacAddress;
+    }
+
+    public void setPublicMacAddress(String publicMacAddress) {
+        this.publicMacAddress = publicMacAddress;
+    }
+
+    public String getStorageIpAddress() {
+        return this.storageIpAddress;
+    }
+
+    public void setStorageIpAddress(String storageIpAddress) {
+        this.storageIpAddress = storageIpAddress;
+    }
+
+    public String getStorageNetMask() {
+        return this.storageNetMask;
+    }
+
+    public void setStorageNetMask(String storageNetMask) {
+        this.storageNetMask = storageNetMask;
+    }
+
+    public String getStorageMacAddress() {
+        return this.storageMacAddress;
+    }
+
+    public void setStorageMacAddress(String storageMacAddress) {
+        this.storageMacAddress = storageMacAddress;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6083ce5/plugins/hypervisors/simulator/src/com/cloud/simulator/MockSecStorageVO.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/simulator/MockSecStorageVO.java b/plugins/hypervisors/simulator/src/com/cloud/simulator/MockSecStorageVO.java
new file mode 100644
index 0000000..59a81c7
--- /dev/null
+++ b/plugins/hypervisors/simulator/src/com/cloud/simulator/MockSecStorageVO.java
@@ -0,0 +1,76 @@
+// 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 com.cloud.simulator;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Entity
+@Table(name="mocksecstorage")
+
+public class MockSecStorageVO {
+    @Id
+    @GeneratedValue(strategy=GenerationType.IDENTITY)
+    @Column(name="id")
+    private long id;
+
+    @Column(name="url")
+    private String url;
+
+    @Column(name="capacity")
+    private long capacity;
+
+    @Column(name="mount_point")
+    private String mountPoint;
+
+
+    public MockSecStorageVO() {
+
+    }
+
+    public long getId() {
+        return this.id;
+    }
+
+    public String getMountPoint() {
+        return this.mountPoint;
+    }
+
+    public void setMountPoint(String mountPoint) {
+        this.mountPoint = mountPoint;
+    }
+
+    public String getUrl() {
+        return url;
+    }
+
+    public void setUrl(String url) {
+        this.url = url;
+    }
+
+    public long getCapacity() {
+        return this.capacity;
+    }
+
+    public void setCapacity(long capacity) {
+        this.capacity = capacity;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6083ce5/plugins/hypervisors/simulator/src/com/cloud/simulator/MockSecurityRulesVO.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/simulator/MockSecurityRulesVO.java b/plugins/hypervisors/simulator/src/com/cloud/simulator/MockSecurityRulesVO.java
new file mode 100644
index 0000000..df31fbf
--- /dev/null
+++ b/plugins/hypervisors/simulator/src/com/cloud/simulator/MockSecurityRulesVO.java
@@ -0,0 +1,104 @@
+// 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 com.cloud.simulator;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+
+@Entity
+@Table(name="mocksecurityrules")
+public class MockSecurityRulesVO {
+    @Id
+    @GeneratedValue(strategy=GenerationType.IDENTITY)
+    @Column(name="id")
+    private long id;
+
+    @Column(name="vmid")
+    private Long vmId;
+
+    @Column(name="signature")
+    private String signature;
+
+    @Column(name="seqnum")
+    private Long seqNum;
+
+    @Column(name="ruleset")
+    private String ruleSet;
+
+    @Column(name="hostid")
+    private String hostId;
+
+    @Column(name="vmname")
+    public String vmName;
+
+    public String getVmName() {
+        return this.vmName;
+    }
+
+    public void setVmName(String vmName) {
+        this.vmName = vmName;
+    }
+
+    public String getHostId() {
+        return this.hostId;
+    }
+
+    public void setHostId(String hostId) {
+        this.hostId = hostId;
+    }
+
+    public long getId() {
+        return this.id;
+    }
+
+    public Long getVmId() {
+        return this.vmId;
+    }
+
+    public void setVmId(Long vmId) {
+        this.vmId = vmId;
+    }
+
+    public String getSignature() {
+        return this.signature;
+    }
+
+    public void setSignature(String sig) {
+        this.signature = sig;
+    }
+
+    public Long getSeqNum() {
+        return this.seqNum;
+    }
+
+    public void setSeqNum(Long seqNum) {
+        this.seqNum = seqNum;
+    }
+
+    public String getRuleSet() {
+        return this.ruleSet;
+    }
+
+    public void setRuleSet(String ruleset) {
+        this.ruleSet = ruleset;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6083ce5/plugins/hypervisors/simulator/src/com/cloud/simulator/MockStoragePoolVO.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/simulator/MockStoragePoolVO.java b/plugins/hypervisors/simulator/src/com/cloud/simulator/MockStoragePoolVO.java
new file mode 100644
index 0000000..9c6e84d
--- /dev/null
+++ b/plugins/hypervisors/simulator/src/com/cloud/simulator/MockStoragePoolVO.java
@@ -0,0 +1,102 @@
+// 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 com.cloud.simulator;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import com.cloud.storage.Storage.StoragePoolType;
+
+@Entity
+@Table(name="mockstoragepool")
+
+public class MockStoragePoolVO {
+    @Id
+    @GeneratedValue(strategy=GenerationType.IDENTITY)
+    @Column(name="id")
+    private long id;
+
+    @Column(name="guid")
+    private String uuid;
+
+    @Column(name="mount_point")
+    private String mountPoint;
+
+    @Column(name="capacity")
+    private long capacity;
+
+    @Column(name="hostguid")
+    private String hostGuid;
+
+    @Column(name="pool_type")
+    @Enumerated(value=EnumType.STRING)
+    private StoragePoolType poolType;
+
+    public MockStoragePoolVO() {
+
+    }
+
+    public String getHostGuid() {
+        return this.hostGuid;
+    }
+
+    public void setHostGuid(String hostGuid) {
+        this.hostGuid = hostGuid;
+    }
+
+    public long getId() {
+        return this.id;
+    }
+
+    public StoragePoolType getPoolType() {
+        return this.poolType;
+    }
+
+    public void setStorageType(StoragePoolType poolType) {
+        this.poolType = poolType;
+    }
+
+    public String getUuid() {
+        return this.uuid;
+    }
+
+    public void setUuid(String uuid) {
+        this.uuid = uuid;
+    }
+
+    public String getMountPoint() {
+        return this.mountPoint;
+    }
+
+    public void setMountPoint(String mountPoint) {
+        this.mountPoint = mountPoint;
+    }
+
+    public long getCapacity() {
+        return this.capacity;
+    }
+
+    public void setCapacity(long capacity) {
+        this.capacity = capacity;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6083ce5/plugins/hypervisors/simulator/src/com/cloud/simulator/MockVMVO.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/simulator/MockVMVO.java b/plugins/hypervisors/simulator/src/com/cloud/simulator/MockVMVO.java
new file mode 100644
index 0000000..4fb3085
--- /dev/null
+++ b/plugins/hypervisors/simulator/src/com/cloud/simulator/MockVMVO.java
@@ -0,0 +1,130 @@
+// 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 com.cloud.simulator;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import com.cloud.vm.VirtualMachine.State;
+
+@Entity
+@Table(name="mockvm")
+
+public class MockVMVO implements MockVm{
+    @Id
+    @GeneratedValue(strategy=GenerationType.IDENTITY)
+    @Column(name="id")
+    private long id;
+
+    @Column(name="name")
+    private String name;
+
+    @Column(name="host_id")
+    private long hostId;
+
+    @Column(name="type")
+    private String vmType;
+
+    @Column(name="state")
+    private State state;
+
+    @Column(name="vnc_port")
+    private int vncPort;
+
+    @Column(name="memory")
+    private long memory;
+
+    @Column(name="cpu")
+    private int cpu;
+
+    public MockVMVO() {
+
+    }
+
+    public long getId() {
+        return this.id;
+    }
+
+    public String getName() {
+        return this.name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public long getHostId() {
+        return this.hostId;
+    }
+
+    public void setHostId(long hostId) {
+        this.hostId = hostId;
+    }
+
+    public String getVmType() {
+        return this.vmType;
+    }
+
+    public void setVmType(String vmType) {
+        this.vmType = vmType;
+    }
+
+    public State getState() {
+        return this.state;
+    }
+
+    public String getType() {
+	return this.vmType;
+    }
+
+    public void setState(State state) {
+        this.state = state;
+    }
+
+    public int getVncPort() {
+        return this.vncPort;
+    }
+
+    public void setVncPort(int vncPort) {
+        this.vncPort = vncPort;
+    }
+
+    public long getMemory() {
+        return this.memory;
+    }
+
+    public void setMemory(long memory) {
+        this.memory = memory;
+    }
+
+    public int getCpu() {
+        return this.cpu;
+    }
+
+    public void setCpu(int cpu) {
+        this.cpu = cpu;
+    }
+
+    public void setType(String type) {
+	this.vmType = type;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6083ce5/plugins/hypervisors/simulator/src/com/cloud/simulator/MockVm.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/simulator/MockVm.java b/plugins/hypervisors/simulator/src/com/cloud/simulator/MockVm.java
new file mode 100644
index 0000000..2e1ba27
--- /dev/null
+++ b/plugins/hypervisors/simulator/src/com/cloud/simulator/MockVm.java
@@ -0,0 +1,44 @@
+// 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 com.cloud.simulator;
+
+import com.cloud.vm.VirtualMachine.State;
+
+// As storage is mapped from storage device, can virtually treat that VM here does
+public interface MockVm {
+
+
+	public String getName();
+
+	public State getState();
+
+	public void setState(State state);
+
+	public void setHostId(long hostId);
+	public long getMemory();
+
+	public int getCpu();
+	public String getType();
+	public int getVncPort();
+
+	public void setName(String name);
+	public void setMemory(long memory);
+	public void setCpu(int cpu);
+	public void setType(String type);
+	public void setVncPort(int vncPort);
+	public long getId();
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6083ce5/plugins/hypervisors/simulator/src/com/cloud/simulator/MockVolumeVO.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/simulator/MockVolumeVO.java b/plugins/hypervisors/simulator/src/com/cloud/simulator/MockVolumeVO.java
new file mode 100644
index 0000000..48a12f8
--- /dev/null
+++ b/plugins/hypervisors/simulator/src/com/cloud/simulator/MockVolumeVO.java
@@ -0,0 +1,118 @@
+// 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 com.cloud.simulator;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.EnumType;
+import javax.persistence.Enumerated;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+import com.cloud.storage.VMTemplateStorageResourceAssoc;
+import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
+
+
+@Entity
+@Table(name="mockvolume")
+
+public class MockVolumeVO {
+    public enum MockVolumeType {
+        VOLUME,
+        TEMPLATE,
+        ISO,
+        SNAPSHOT;
+    }
+    @Id
+    @GeneratedValue(strategy=GenerationType.IDENTITY)
+    @Column(name="id")
+    private long id;
+
+    @Column(name="name")
+    private String name;
+
+    @Column(name="size")
+    private long size;
+
+    @Column(name="path")
+    private String path;
+
+    @Column(name="pool_id")
+    private long poolId;
+
+    @Column(name="type")
+    @Enumerated(value=EnumType.STRING)
+    private MockVolumeType type;
+
+    @Column(name="status")
+    @Enumerated(value=EnumType.STRING)
+    private VMTemplateStorageResourceAssoc.Status status;
+
+    public long getId() {
+        return id;
+    }
+    public String getName() {
+        return this.name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public long getSize() {
+        return this.size;
+    }
+
+    public void setSize(long size) {
+        this.size = size;
+    }
+
+    public String getPath() {
+        return this.path;
+    }
+
+    public void setPath(String path) {
+        this.path = path;
+    }
+
+    public long getPoolId() {
+        return this.poolId;
+    }
+
+    public void setPoolId(long poolId) {
+        this.poolId = poolId;
+    }
+
+    public MockVolumeType getType() {
+        return this.type;
+    }
+
+    public void setType(MockVolumeType type) {
+        this.type = type;
+    }
+
+    public Status getStatus() {
+        return this.status;
+    }
+
+    public void setStatus(Status status) {
+        this.status = status;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6083ce5/plugins/hypervisors/simulator/src/com/cloud/simulator/SimulatorGuru.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/simulator/SimulatorGuru.java b/plugins/hypervisors/simulator/src/com/cloud/simulator/SimulatorGuru.java
new file mode 100644
index 0000000..b9c404b
--- /dev/null
+++ b/plugins/hypervisors/simulator/src/com/cloud/simulator/SimulatorGuru.java
@@ -0,0 +1,59 @@
+// 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 com.cloud.simulator;
+
+import javax.ejb.Local;
+
+import com.cloud.agent.api.to.VirtualMachineTO;
+import com.cloud.hypervisor.HypervisorGuru;
+import com.cloud.hypervisor.HypervisorGuruBase;
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
+import com.cloud.storage.GuestOSVO;
+import com.cloud.storage.dao.GuestOSDao;
+import com.cloud.utils.component.Inject;
+import com.cloud.vm.VirtualMachine;
+import com.cloud.vm.VirtualMachineProfile;
+
+@Local(value=HypervisorGuru.class)
+public class SimulatorGuru extends HypervisorGuruBase implements HypervisorGuru {
+    @Inject GuestOSDao _guestOsDao;
+
+    protected SimulatorGuru() {
+        super();
+    }
+
+    @Override
+    public HypervisorType getHypervisorType() {
+        return HypervisorType.Simulator;
+    }
+
+    @Override
+    public <T extends VirtualMachine> VirtualMachineTO implement(VirtualMachineProfile<T> vm) {
+        VirtualMachineTO to = toVirtualMachineTO(vm);
+
+        // Determine the VM's OS description
+        GuestOSVO guestOS = _guestOsDao.findById(vm.getVirtualMachine().getGuestOSId());
+        to.setOs(guestOS.getDisplayName());
+
+        return to;
+    }
+
+	@Override
+	public boolean trackVmHostChange() {
+		return false;
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6083ce5/plugins/hypervisors/simulator/src/com/cloud/simulator/SimulatorRuntimeException.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/simulator/SimulatorRuntimeException.java b/plugins/hypervisors/simulator/src/com/cloud/simulator/SimulatorRuntimeException.java
new file mode 100644
index 0000000..9891bc8
--- /dev/null
+++ b/plugins/hypervisors/simulator/src/com/cloud/simulator/SimulatorRuntimeException.java
@@ -0,0 +1,41 @@
+// 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 com.cloud.simulator;
+
+import com.cloud.utils.SerialVersionUID;
+import com.cloud.utils.exception.RuntimeCloudException;
+
+/**
+ * wrap exceptions that you know there's no point in dealing with.
+ */
+public class SimulatorRuntimeException extends RuntimeCloudException {
+
+    private static final long serialVersionUID = SerialVersionUID.CloudRuntimeException;
+
+    public SimulatorRuntimeException(String message) {
+        super(message);
+    }
+
+    public SimulatorRuntimeException(String message, Throwable th) {
+        super(message, th);
+    }
+
+    protected SimulatorRuntimeException() {
+        super();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6083ce5/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockConfigurationDao.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockConfigurationDao.java b/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockConfigurationDao.java
new file mode 100644
index 0000000..c0b3c6a
--- /dev/null
+++ b/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockConfigurationDao.java
@@ -0,0 +1,27 @@
+// 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 com.cloud.simulator.dao;
+
+import com.cloud.simulator.MockConfigurationVO;
+import com.cloud.utils.db.GenericDao;
+
+public interface MockConfigurationDao extends GenericDao<MockConfigurationVO, Long> {
+    MockConfigurationVO findByCommand(Long dcId, Long podId, Long clusterId, Long hostId, String name);
+
+	MockConfigurationVO findByNameBottomUP(Long dcId, Long podId,
+			Long clusterId, Long hostId, String name);
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6083ce5/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockConfigurationDaoImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockConfigurationDaoImpl.java b/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockConfigurationDaoImpl.java
new file mode 100644
index 0000000..bd1b48d
--- /dev/null
+++ b/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockConfigurationDaoImpl.java
@@ -0,0 +1,142 @@
+// 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 com.cloud.simulator.dao;
+
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.util.Formatter;
+
+import javax.ejb.Local;
+
+import com.cloud.simulator.MockConfigurationVO;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+import com.cloud.utils.db.Transaction;
+
+@Local(value={MockConfigurationDao.class})
+public class MockConfigurationDaoImpl extends GenericDaoBase<MockConfigurationVO, Long> implements MockConfigurationDao {
+    private SearchBuilder<MockConfigurationVO> _searchByDcIdName;
+    private SearchBuilder<MockConfigurationVO> _searchByDcIDPodIdName;
+    private SearchBuilder<MockConfigurationVO> _searchByDcIDPodIdClusterIdName;
+    private SearchBuilder<MockConfigurationVO> _searchByDcIDPodIdClusterIdHostIdName;
+    private SearchBuilder<MockConfigurationVO> _searchByGlobalName;
+
+
+    public MockConfigurationDaoImpl() {
+        _searchByGlobalName = createSearchBuilder();
+        _searchByGlobalName.and("dcId", _searchByGlobalName.entity().getDataCenterId(), SearchCriteria.Op.NULL);
+        _searchByGlobalName.and("podId", _searchByGlobalName.entity().getPodId(), SearchCriteria.Op.NULL);
+        _searchByGlobalName.and("clusterId", _searchByGlobalName.entity().getClusterId(), SearchCriteria.Op.NULL);
+        _searchByGlobalName.and("hostId", _searchByGlobalName.entity().getHostId(), SearchCriteria.Op.NULL);
+        _searchByGlobalName.and("name", _searchByGlobalName.entity().getName(), SearchCriteria.Op.EQ);
+        _searchByGlobalName.done();
+
+        _searchByDcIdName = createSearchBuilder();
+        _searchByDcIdName.and("dcId", _searchByDcIdName.entity().getDataCenterId(), SearchCriteria.Op.EQ);
+        _searchByDcIdName.and("podId", _searchByDcIdName.entity().getPodId(), SearchCriteria.Op.NULL);
+        _searchByDcIdName.and("clusterId", _searchByDcIdName.entity().getClusterId(), SearchCriteria.Op.NULL);
+        _searchByDcIdName.and("hostId", _searchByDcIdName.entity().getHostId(), SearchCriteria.Op.NULL);
+        _searchByDcIdName.and("name", _searchByDcIdName.entity().getName(), SearchCriteria.Op.EQ);
+        _searchByDcIdName.done();
+
+        _searchByDcIDPodIdName = createSearchBuilder();
+        _searchByDcIDPodIdName.and("dcId", _searchByDcIDPodIdName.entity().getDataCenterId(), SearchCriteria.Op.EQ);
+        _searchByDcIDPodIdName.and("podId", _searchByDcIDPodIdName.entity().getPodId(), SearchCriteria.Op.EQ);
+        _searchByDcIDPodIdName.and("clusterId", _searchByDcIDPodIdName.entity().getClusterId(), SearchCriteria.Op.NULL);
+        _searchByDcIDPodIdName.and("hostId", _searchByDcIDPodIdName.entity().getHostId(), SearchCriteria.Op.NULL);
+        _searchByDcIDPodIdName.and("name", _searchByDcIDPodIdName.entity().getName(), SearchCriteria.Op.EQ);
+        _searchByDcIDPodIdName.done();
+
+        _searchByDcIDPodIdClusterIdName = createSearchBuilder();
+        _searchByDcIDPodIdClusterIdName.and("dcId", _searchByDcIDPodIdClusterIdName.entity().getDataCenterId(), SearchCriteria.Op.EQ);
+        _searchByDcIDPodIdClusterIdName.and("podId", _searchByDcIDPodIdClusterIdName.entity().getPodId(), SearchCriteria.Op.EQ);
+        _searchByDcIDPodIdClusterIdName.and("clusterId", _searchByDcIDPodIdClusterIdName.entity().getClusterId(), SearchCriteria.Op.EQ);
+        _searchByDcIDPodIdClusterIdName.and("hostId", _searchByDcIDPodIdClusterIdName.entity().getHostId(), SearchCriteria.Op.NULL);
+        _searchByDcIDPodIdClusterIdName.and("name", _searchByDcIDPodIdClusterIdName.entity().getName(), SearchCriteria.Op.EQ);
+        _searchByDcIDPodIdClusterIdName.done();
+
+        _searchByDcIDPodIdClusterIdHostIdName = createSearchBuilder();
+        _searchByDcIDPodIdClusterIdHostIdName.and("dcId", _searchByDcIDPodIdClusterIdHostIdName.entity().getDataCenterId(), SearchCriteria.Op.EQ);
+        _searchByDcIDPodIdClusterIdHostIdName.and("podId", _searchByDcIDPodIdClusterIdHostIdName.entity().getPodId(), SearchCriteria.Op.EQ);
+        _searchByDcIDPodIdClusterIdHostIdName.and("clusterId", _searchByDcIDPodIdClusterIdHostIdName.entity().getClusterId(), SearchCriteria.Op.EQ);
+        _searchByDcIDPodIdClusterIdHostIdName.and("hostId", _searchByDcIDPodIdClusterIdHostIdName.entity().getHostId(), SearchCriteria.Op.EQ);
+        _searchByDcIDPodIdClusterIdHostIdName.and("name", _searchByDcIDPodIdClusterIdHostIdName.entity().getName(), SearchCriteria.Op.EQ);
+        _searchByDcIDPodIdClusterIdHostIdName.done();
+    }
+    @Override
+    public MockConfigurationVO findByCommand(Long dcId, Long podId, Long clusterId, Long hostId, String name) {
+
+        if (dcId == null) {
+            SearchCriteria<MockConfigurationVO> sc = _searchByGlobalName.create();
+            sc.setParameters("name", name);
+            return findOneBy(sc);
+        } else if (podId == null) {
+            SearchCriteria<MockConfigurationVO> sc = _searchByDcIdName.create();
+            sc.setParameters("name", name);
+            sc.setParameters("dcId", dcId);
+            return findOneBy(sc);
+        } else if (clusterId == null) {
+            SearchCriteria<MockConfigurationVO> sc = _searchByDcIDPodIdName.create();
+            sc.setParameters("name", name);
+            sc.setParameters("dcId", dcId);
+            sc.setParameters("podId", podId);
+            return findOneBy(sc);
+        } else if (hostId == null) {
+            SearchCriteria<MockConfigurationVO> sc = _searchByDcIDPodIdClusterIdName.create();
+            sc.setParameters("name", name);
+            sc.setParameters("dcId", dcId);
+            sc.setParameters("podId", podId);
+            sc.setParameters("clusterId", clusterId);
+            return findOneBy(sc);
+        } else {
+            SearchCriteria<MockConfigurationVO> sc = _searchByDcIDPodIdClusterIdHostIdName.create();
+            sc.setParameters("name", name);
+            sc.setParameters("dcId", dcId);
+            sc.setParameters("podId", podId);
+            sc.setParameters("clusterId", clusterId);
+            sc.setParameters("hostId", hostId);
+            return findOneBy(sc);
+        }
+    }
+
+    @Override
+    public MockConfigurationVO findByNameBottomUP(Long dcId, Long podId, Long clusterId, Long hostId, String name) {
+	 Transaction txn = Transaction.currentTxn();
+	StringBuilder search = new StringBuilder();
+	Formatter formatter = new Formatter(search);
+	formatter.format("select * from mockconfiguration where (name='%s') and ((data_center_id = %d and pod_id = %d and cluster_id = %d and host_id = %d)", name, dcId, podId, clusterId, hostId);
+	formatter.format(" or (data_center_id = %d and pod_id = %d and cluster_id = %d and host_id is null)", dcId, podId, clusterId);
+	formatter.format(" or (data_center_id = %d and pod_id = %d and cluster_id is null and host_id is null)", dcId, podId);
+	formatter.format(" or (data_center_id = %d and pod_id is null and cluster_id is null and host_id is null)", dcId);
+	formatter.format(" or (data_center_id is null and pod_id is null and cluster_id is null and host_id is null)) LIMIT 1");
+
+	PreparedStatement pstmt = null;
+		try {
+			String sql = search.toString();
+			pstmt = txn.prepareAutoCloseStatement(sql);
+			ResultSet rs = pstmt.executeQuery();
+			if (rs.next()) {
+                return toEntityBean(rs, false);
+            }
+		} catch (Exception e) {
+
+		}
+		return null;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6083ce5/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockHostDao.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockHostDao.java b/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockHostDao.java
new file mode 100644
index 0000000..4732783
--- /dev/null
+++ b/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockHostDao.java
@@ -0,0 +1,27 @@
+// 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 com.cloud.simulator.dao;
+
+import com.cloud.simulator.MockHost;
+import com.cloud.simulator.MockHostVO;
+import com.cloud.utils.db.GenericDao;
+
+public interface MockHostDao extends GenericDao<MockHostVO, Long> {
+    public MockHost findByGuid(String guid);
+    public MockHost findByVmId(long vmId);
+    public boolean removeByGuid(String guid);
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6083ce5/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockHostDaoImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockHostDaoImpl.java b/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockHostDaoImpl.java
new file mode 100644
index 0000000..8a566d7
--- /dev/null
+++ b/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockHostDaoImpl.java
@@ -0,0 +1,55 @@
+// 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 com.cloud.simulator.dao;
+
+import javax.ejb.Local;
+
+import com.cloud.simulator.MockHost;
+import com.cloud.simulator.MockHostVO;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+
+@Local(value={MockHostDao.class})
+public class MockHostDaoImpl extends GenericDaoBase<MockHostVO, Long> implements MockHostDao {
+    protected final SearchBuilder<MockHostVO> GuidSearch;
+    public MockHostDaoImpl() {
+        GuidSearch = createSearchBuilder();
+        GuidSearch.and("guid", GuidSearch.entity().getGuid(), SearchCriteria.Op.EQ);
+        GuidSearch.done();
+    }
+    @Override
+    public MockHost findByGuid(String guid) {
+        SearchCriteria<MockHostVO> sc = GuidSearch.create();
+        sc.setParameters("guid", guid);
+        return findOneBy(sc);
+    }
+    @Override
+    public MockHost findByVmId(long vmId) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+    @Override
+    public boolean removeByGuid(String guid) {
+       MockHost host = this.findByGuid(guid);
+       if (host == null) {
+           return false;
+       }
+       return this.remove(host.getId());
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6083ce5/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockSecStorageDao.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockSecStorageDao.java b/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockSecStorageDao.java
new file mode 100644
index 0000000..fc19f63
--- /dev/null
+++ b/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockSecStorageDao.java
@@ -0,0 +1,24 @@
+// 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 com.cloud.simulator.dao;
+
+import com.cloud.simulator.MockSecStorageVO;
+import com.cloud.utils.db.GenericDao;
+
+public interface MockSecStorageDao extends GenericDao<MockSecStorageVO, Long> {
+    public MockSecStorageVO findByUrl(String url);
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6083ce5/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockSecStorageDaoImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockSecStorageDaoImpl.java b/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockSecStorageDaoImpl.java
new file mode 100644
index 0000000..65a375f
--- /dev/null
+++ b/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockSecStorageDaoImpl.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 com.cloud.simulator.dao;
+
+import javax.ejb.Local;
+
+import com.cloud.simulator.MockSecStorageVO;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+
+@Local(value={MockSecStorageDao.class})
+public class MockSecStorageDaoImpl extends GenericDaoBase<MockSecStorageVO, Long> implements MockSecStorageDao {
+    protected final SearchBuilder<MockSecStorageVO> urlSearch;
+    @Override
+    public MockSecStorageVO findByUrl(String url) {
+        SearchCriteria<MockSecStorageVO> sc = urlSearch.create();
+        sc.setParameters("url", url);
+        return findOneBy(sc);
+    }
+
+    public MockSecStorageDaoImpl() {
+        urlSearch = createSearchBuilder();
+        urlSearch.and("url", urlSearch.entity().getUrl(), SearchCriteria.Op.EQ);
+        urlSearch.done();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6083ce5/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockSecurityRulesDao.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockSecurityRulesDao.java b/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockSecurityRulesDao.java
new file mode 100644
index 0000000..ecc69f1
--- /dev/null
+++ b/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockSecurityRulesDao.java
@@ -0,0 +1,27 @@
+// 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 com.cloud.simulator.dao;
+
+import java.util.List;
+
+import com.cloud.simulator.MockSecurityRulesVO;
+import com.cloud.utils.db.GenericDao;
+
+public interface MockSecurityRulesDao extends GenericDao<MockSecurityRulesVO, Long> {
+    public MockSecurityRulesVO findByVmId(Long vmId);
+    public List<MockSecurityRulesVO> findByHost(String hostGuid);
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6083ce5/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockSecurityRulesDaoImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockSecurityRulesDaoImpl.java b/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockSecurityRulesDaoImpl.java
new file mode 100644
index 0000000..8831efe
--- /dev/null
+++ b/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockSecurityRulesDaoImpl.java
@@ -0,0 +1,60 @@
+// 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 com.cloud.simulator.dao;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.ejb.Local;
+import javax.naming.ConfigurationException;
+
+import com.cloud.simulator.MockSecurityRulesVO;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+@Local(value={MockSecurityRulesDao.class})
+public class MockSecurityRulesDaoImpl extends GenericDaoBase<MockSecurityRulesVO, Long> implements MockSecurityRulesDao {
+    protected  SearchBuilder<MockSecurityRulesVO> vmIdSearch;
+    protected  SearchBuilder<MockSecurityRulesVO> hostSearch;
+    @Override
+    public MockSecurityRulesVO findByVmId(Long vmId) {
+        SearchCriteria<MockSecurityRulesVO> sc = vmIdSearch.create();
+        sc.setParameters("vmId", vmId);
+        return findOneBy(sc);
+    }
+
+    @Override
+    public List<MockSecurityRulesVO> findByHost(String hostGuid) {
+        SearchCriteria<MockSecurityRulesVO> sc = hostSearch.create();
+        sc.setParameters("host", hostGuid);
+        return listBy(sc);
+    }
+
+    @Override
+    public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
+        vmIdSearch = createSearchBuilder();
+        vmIdSearch.and("vmId", vmIdSearch.entity().getVmId(), SearchCriteria.Op.EQ);
+        vmIdSearch.done();
+
+        hostSearch = createSearchBuilder();
+        hostSearch.and("host", hostSearch.entity().getHostId(), SearchCriteria.Op.EQ);
+        hostSearch.done();
+
+        return true;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6083ce5/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockStoragePoolDao.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockStoragePoolDao.java b/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockStoragePoolDao.java
new file mode 100644
index 0000000..e1b4f42
--- /dev/null
+++ b/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockStoragePoolDao.java
@@ -0,0 +1,25 @@
+// 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 com.cloud.simulator.dao;
+
+import com.cloud.simulator.MockStoragePoolVO;
+import com.cloud.utils.db.GenericDao;
+
+public interface MockStoragePoolDao extends GenericDao<MockStoragePoolVO, Long> {
+    public MockStoragePoolVO findByUuid(String uuid);
+    public MockStoragePoolVO findByHost(String hostUuid);
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6083ce5/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockStoragePoolDaoImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockStoragePoolDaoImpl.java b/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockStoragePoolDaoImpl.java
new file mode 100644
index 0000000..3a64d27
--- /dev/null
+++ b/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockStoragePoolDaoImpl.java
@@ -0,0 +1,57 @@
+// 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 com.cloud.simulator.dao;
+
+import javax.ejb.Local;
+
+import com.cloud.simulator.MockStoragePoolVO;
+import com.cloud.storage.Storage.StoragePoolType;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+
+@Local(value={MockStoragePoolDao.class})
+public class MockStoragePoolDaoImpl extends GenericDaoBase<MockStoragePoolVO, Long> implements MockStoragePoolDao {
+    protected final SearchBuilder<MockStoragePoolVO> uuidSearch;
+    protected final SearchBuilder<MockStoragePoolVO> hostguidSearch;
+    @Override
+    public MockStoragePoolVO findByUuid(String uuid) {
+        SearchCriteria<MockStoragePoolVO> sc = uuidSearch.create();
+        sc.setParameters("uuid", uuid);
+        return findOneBy(sc);
+    }
+
+    public MockStoragePoolDaoImpl() {
+        uuidSearch = createSearchBuilder();
+        uuidSearch.and("uuid", uuidSearch.entity().getUuid(), SearchCriteria.Op.EQ);
+        uuidSearch.done();
+
+        hostguidSearch = createSearchBuilder();
+        hostguidSearch.and("hostguid", hostguidSearch.entity().getHostGuid(), SearchCriteria.Op.EQ);
+        hostguidSearch.and("type", hostguidSearch.entity().getPoolType(), SearchCriteria.Op.EQ);
+        hostguidSearch.done();
+    }
+
+    @Override
+    public MockStoragePoolVO findByHost(String hostUuid) {
+        SearchCriteria<MockStoragePoolVO> sc = hostguidSearch.create();
+        sc.setParameters("hostguid", hostUuid);
+        sc.setParameters("type", StoragePoolType.Filesystem.toString());
+        return findOneBy(sc);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6083ce5/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockVMDao.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockVMDao.java b/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockVMDao.java
new file mode 100644
index 0000000..fd4d708
--- /dev/null
+++ b/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockVMDao.java
@@ -0,0 +1,29 @@
+// 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 com.cloud.simulator.dao;
+
+import java.util.List;
+
+import com.cloud.simulator.MockVMVO;
+import com.cloud.utils.db.GenericDao;
+
+public interface MockVMDao extends GenericDao<MockVMVO, Long> {
+    public List<MockVMVO> findByHostId(long hostId);
+    public List<MockVMVO> findByHostGuid(String guid);
+    public MockVMVO findByVmName(String vmName);
+    public MockVMVO findByVmNameAndHost(String vmName, String hostGuid);
+}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6083ce5/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockVMDaoImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockVMDaoImpl.java b/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockVMDaoImpl.java
new file mode 100644
index 0000000..86264f2
--- /dev/null
+++ b/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockVMDaoImpl.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 com.cloud.simulator.dao;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import javax.ejb.Local;
+import javax.naming.ConfigurationException;
+
+import com.cloud.simulator.MockHostVO;
+import com.cloud.simulator.MockVMVO;
+import com.cloud.utils.component.Inject;
+import com.cloud.utils.db.GenericDaoBase;
+import com.cloud.utils.db.JoinBuilder;
+import com.cloud.utils.db.SearchBuilder;
+import com.cloud.utils.db.SearchCriteria;
+import com.cloud.vm.VirtualMachine;
+
+@Local(value={MockVMDao.class})
+public class MockVMDaoImpl extends GenericDaoBase<MockVMVO, Long> implements MockVMDao {
+    protected SearchBuilder<MockVMVO> GuidSearch;
+    protected SearchBuilder<MockVMVO> vmNameSearch;
+    protected SearchBuilder<MockVMVO> vmhostSearch;
+    @Inject MockHostDao _mockHostDao;
+    @Override
+    public List<MockVMVO> findByHostId(long hostId) {
+        return new ArrayList<MockVMVO>();
+    }
+
+    @Override
+    public MockVMVO findByVmName(String vmName) {
+        SearchCriteria<MockVMVO> sc = vmNameSearch.create();
+        sc.setParameters("name", vmName);
+        return findOneBy(sc);
+    }
+
+    @Override
+    public List<MockVMVO> findByHostGuid(String guid) {
+        SearchCriteria<MockVMVO> sc = GuidSearch.create();
+        sc.setJoinParameters("host", "guid", guid);
+        sc.setParameters("state", VirtualMachine.State.Running);
+        return listBy(sc);
+    }
+
+    @Override
+    public MockVMVO findByVmNameAndHost(String vmName, String hostGuid) {
+        SearchCriteria<MockVMVO> sc = vmhostSearch.create();
+        sc.setJoinParameters("host", "guid", hostGuid);
+        sc.setParameters("name", vmName);
+        return findOneBy(sc);
+    }
+
+    @Override
+    public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
+        SearchBuilder<MockHostVO> host = _mockHostDao.createSearchBuilder();
+        host.and("guid", host.entity().getGuid(), SearchCriteria.Op.EQ);
+
+        GuidSearch = createSearchBuilder();
+        GuidSearch.join("host", host, host.entity().getId(), GuidSearch.entity().getHostId(), JoinBuilder.JoinType.INNER);
+        GuidSearch.and("state", GuidSearch.entity().getState(), SearchCriteria.Op.EQ);
+        GuidSearch.done();
+
+        vmNameSearch = createSearchBuilder();
+        vmNameSearch.and("name", vmNameSearch.entity().getName(), SearchCriteria.Op.EQ);
+        vmNameSearch.done();
+
+        SearchBuilder<MockHostVO> newhost = _mockHostDao.createSearchBuilder();
+        newhost.and("guid", newhost.entity().getGuid(), SearchCriteria.Op.EQ);
+        vmhostSearch = createSearchBuilder();
+        vmhostSearch.and("name", vmhostSearch.entity().getName(), SearchCriteria.Op.EQ);
+        vmhostSearch.join("host", newhost, newhost.entity().getId(), vmhostSearch.entity().getHostId(), JoinBuilder.JoinType.INNER);
+        vmhostSearch.done();
+
+        return true;
+    }
+}


Mime
View raw message