Simulator: moving hypervisor simulator into plugin

Simulator just like any hypervisor should be a plugin.
resurrecting it to aid api refactoring tests. WIP

Signed-off-by: Prasanna Santhanam <[email protected]>


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

Branch: refs/heads/api_refactoring
Commit: d6083ce51dd53592073efd700186e9ac6a14fb7e
Parents: 0b60dda
Author: Prasanna Santhanam <[email protected]>
Authored: Sat Dec 22 13:01:44 2012 -0800
Committer: Prasanna Santhanam <[email protected]>
Committed: Sat Dec 22 13:02:57 2012 -0800

----------------------------------------------------------------------
 .../src/com/cloud/agent/MetricsCollector.java      |  107 --
 .../src/com/cloud/agent/MockVmMetrics.java         |  205 ---
 .../src/com/cloud/agent/MultiCaster.java           |  152 --
 .../src/com/cloud/agent/MultiCasterListener.java   |   22 -
 .../src/com/cloud/agent/SimulatorCmd.java          |   37 -
 .../src/com/cloud/agent/SimulatorMigrateVmCmd.java |   83 -
 .../com/cloud/agent/manager/MockAgentManager.java  |   66 -
 .../cloud/agent/manager/MockAgentManagerImpl.java  |  468 ------
 .../cloud/agent/manager/MockStorageManager.java    |   91 -
 .../agent/manager/MockStorageManagerImpl.java      | 1298 ---------------
 .../src/com/cloud/agent/manager/MockVmManager.java |   83 -
 .../com/cloud/agent/manager/MockVmManagerImpl.java |  615 -------
 .../src/com/cloud/agent/manager/SimulatorInfo.java |   59 -
 .../com/cloud/agent/manager/SimulatorManager.java  |   66 -
 .../cloud/agent/manager/SimulatorManagerImpl.java  |  336 ----
 .../com/cloud/api/commands/ConfigureSimulator.java |   82 -
 .../configuration/SimulatorComponentLibrary.java   |   50 -
 .../src/com/cloud/resource/AgentResourceBase.java  |  284 ----
 .../com/cloud/resource/AgentRoutingResource.java   |  363 ----
 .../com/cloud/resource/AgentStorageResource.java   |  117 --
 .../com/cloud/resource/SimulatorDiscoverer.java    |  336 ----
 .../resource/SimulatorSecondaryDiscoverer.java     |  151 --
 .../server/ManagementServerSimulatorImpl.java      |   32 -
 .../com/cloud/simulator/MockConfigurationVO.java   |  121 --
 .../src/com/cloud/simulator/MockHost.java          |   62 -
 .../src/com/cloud/simulator/MockHostVO.java        |  276 ---
 .../src/com/cloud/simulator/MockSecStorageVO.java  |   76 -
 .../com/cloud/simulator/MockSecurityRulesVO.java   |  104 --
 .../src/com/cloud/simulator/MockStoragePoolVO.java |  102 --
 .../src/com/cloud/simulator/MockVMVO.java          |  130 --
 .../src/com/cloud/simulator/MockVm.java            |   45 -
 .../src/com/cloud/simulator/MockVolumeVO.java      |  118 --
 .../src/com/cloud/simulator/SimulatorGuru.java     |   59 -
 .../cloud/simulator/SimulatorRuntimeException.java |   41 -
 .../cloud/simulator/dao/MockConfigurationDao.java  |   27 -
 .../simulator/dao/MockConfigurationDaoImpl.java    |  142 --
 .../src/com/cloud/simulator/dao/MockHostDao.java   |   27 -
 .../com/cloud/simulator/dao/MockHostDaoImpl.java   |   55 -
 .../com/cloud/simulator/dao/MockSecStorageDao.java |   24 -
 .../cloud/simulator/dao/MockSecStorageDaoImpl.java |   42 -
 .../cloud/simulator/dao/MockSecurityRulesDao.java  |   27 -
 .../simulator/dao/MockSecurityRulesDaoImpl.java    |   60 -
 .../cloud/simulator/dao/MockStoragePoolDao.java    |   25 -
 .../simulator/dao/MockStoragePoolDaoImpl.java      |   57 -
 .../src/com/cloud/simulator/dao/MockVMDao.java     |   29 -
 .../src/com/cloud/simulator/dao/MockVMDaoImpl.java |   92 -
 .../src/com/cloud/simulator/dao/MockVolumeDao.java |   30 -
 .../com/cloud/simulator/dao/MockVolumeDaoImpl.java |  101 --
 plugins/hypervisors/simulator/pom.xml              |   45 +
 .../src/com/cloud/agent/MetricsCollector.java      |  107 ++
 .../src/com/cloud/agent/MockVmMetrics.java         |  204 +++
 .../simulator/src/com/cloud/agent/MultiCaster.java |  152 ++
 .../src/com/cloud/agent/MultiCasterListener.java   |   22 +
 .../src/com/cloud/agent/SimulatorCmd.java          |   37 +
 .../src/com/cloud/agent/SimulatorMigrateVmCmd.java |   83 +
 .../com/cloud/agent/manager/MockAgentManager.java  |   66 +
 .../cloud/agent/manager/MockAgentManagerImpl.java  |  468 ++++++
 .../cloud/agent/manager/MockStorageManager.java    |   91 +
 .../agent/manager/MockStorageManagerImpl.java      | 1298 +++++++++++++++
 .../src/com/cloud/agent/manager/MockVmManager.java |   83 +
 .../com/cloud/agent/manager/MockVmManagerImpl.java |  615 +++++++
 .../src/com/cloud/agent/manager/SimulatorInfo.java |   59 +
 .../com/cloud/agent/manager/SimulatorManager.java  |   65 +
 .../cloud/agent/manager/SimulatorManagerImpl.java  |  336 ++++
 .../com/cloud/api/commands/ConfigureSimulator.java |   82 +
 .../configuration/SimulatorComponentLibrary.java   |   50 +
 .../src/com/cloud/resource/AgentResourceBase.java  |  284 ++++
 .../com/cloud/resource/AgentRoutingResource.java   |  363 ++++
 .../com/cloud/resource/AgentStorageResource.java   |  117 ++
 .../com/cloud/resource/SimulatorDiscoverer.java    |  336 ++++
 .../resource/SimulatorSecondaryDiscoverer.java     |  151 ++
 .../server/ManagementServerSimulatorImpl.java      |   32 +
 .../com/cloud/simulator/MockConfigurationVO.java   |  120 ++
 .../src/com/cloud/simulator/MockHost.java          |   62 +
 .../src/com/cloud/simulator/MockHostVO.java        |  276 +++
 .../src/com/cloud/simulator/MockSecStorageVO.java  |   76 +
 .../com/cloud/simulator/MockSecurityRulesVO.java   |  104 ++
 .../src/com/cloud/simulator/MockStoragePoolVO.java |  102 ++
 .../src/com/cloud/simulator/MockVMVO.java          |  130 ++
 .../simulator/src/com/cloud/simulator/MockVm.java  |   44 +
 .../src/com/cloud/simulator/MockVolumeVO.java      |  118 ++
 .../src/com/cloud/simulator/SimulatorGuru.java     |   59 +
 .../cloud/simulator/SimulatorRuntimeException.java |   41 +
 .../cloud/simulator/dao/MockConfigurationDao.java  |   27 +
 .../simulator/dao/MockConfigurationDaoImpl.java    |  142 ++
 .../src/com/cloud/simulator/dao/MockHostDao.java   |   27 +
 .../com/cloud/simulator/dao/MockHostDaoImpl.java   |   55 +
 .../com/cloud/simulator/dao/MockSecStorageDao.java |   24 +
 .../cloud/simulator/dao/MockSecStorageDaoImpl.java |   42 +
 .../cloud/simulator/dao/MockSecurityRulesDao.java  |   27 +
 .../simulator/dao/MockSecurityRulesDaoImpl.java    |   60 +
 .../cloud/simulator/dao/MockStoragePoolDao.java    |   25 +
 .../simulator/dao/MockStoragePoolDaoImpl.java      |   57 +
 .../src/com/cloud/simulator/dao/MockVMDao.java     |   29 +
 .../src/com/cloud/simulator/dao/MockVMDaoImpl.java |   92 +
 .../src/com/cloud/simulator/dao/MockVolumeDao.java |   30 +
 .../com/cloud/simulator/dao/MockVolumeDaoImpl.java |  101 ++
 plugins/pom.xml                                    |   12 +
 98 files changed, 7028 insertions(+), 6975 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6083ce5/agent-simulator/src/com/cloud/agent/MetricsCollector.java
----------------------------------------------------------------------
diff --git a/agent-simulator/src/com/cloud/agent/MetricsCollector.java 
b/agent-simulator/src/com/cloud/agent/MetricsCollector.java
deleted file mode 100644
index 7d86a0c..0000000
--- a/agent-simulator/src/com/cloud/agent/MetricsCollector.java
+++ /dev/null
@@ -1,107 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.agent;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ScheduledFuture;
-import java.util.concurrent.ScheduledThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.utils.concurrency.NamedThreadFactory;
-
-public class MetricsCollector {
-    private static final Logger s_logger = 
Logger.getLogger(MetricsCollector.class);
-       
-       private final Set<String> vmNames = new HashSet<String>();
-       private final Set<String> newVMnames = new HashSet<String>();
-       private final Map<String, MockVmMetrics> metricsMap = new 
HashMap<String, MockVmMetrics>();
-       
-       private final transient ScheduledThreadPoolExecutor executor = new 
ScheduledThreadPoolExecutor(1, new NamedThreadFactory("Metrics"));
-
-       private Set<String> _currentVms;
-       
-       public MetricsCollector(Set<String> currentVms) {
-               _currentVms = currentVms;
-               getAllVMNames();
-       }
-       
-       public MetricsCollector() {
-               
-       }
-       
-       public synchronized void getAllVMNames() {
-               Set<String> currentVMs = _currentVms;
-               
-        newVMnames.clear();
-        newVMnames.addAll(currentVMs);
-        newVMnames.removeAll(vmNames); //leave only new vms
-        
-        vmNames.removeAll(currentVMs); //old vms - current vms --> leave 
non-running vms;
-        for (String vm: vmNames) {
-               removeVM(vm);
-        }
-        
-        vmNames.clear();
-        vmNames.addAll(currentVMs);
-       }
-       
-       public synchronized void submitMetricsJobs() {
-               s_logger.debug("Submit Metric Jobs called");
-               
-               for (String vm : newVMnames) {
-                       MockVmMetrics task = new MockVmMetrics(vm);
-                       if (!metricsMap.containsKey(vm)) {
-                           metricsMap.put(vm, task);
-                           ScheduledFuture<?> sf = 
executor.scheduleWithFixedDelay(task, 2, 600, TimeUnit.SECONDS);
-                           task.setFuture(sf);
-                       }
-               }
-               newVMnames.clear();
-       }
-       
-       public synchronized void addVM(String vmName) {
-               newVMnames.add(vmName);
-               s_logger.debug("Added vm name= " + vmName);
-       }
-       
-       public synchronized void removeVM(String vmName) {
-               newVMnames.remove(vmName);
-               vmNames.remove(vmName);
-               MockVmMetrics task = metricsMap.get(vmName);
-       if (task != null) {
-               task.stop();
-               boolean r1= task.getFuture().cancel(false);
-               metricsMap.remove(vmName);
-               s_logger.debug("removeVM: cancel returned " + r1 + " for VM " + 
vmName);
-       } else {
-               s_logger.warn("removeVM called for nonexistent VM " + vmName);
-       }
-       }
-       
-       public synchronized Set<String> getVMNames() {
-         return vmNames;
-       }
-               
-       public synchronized Map<String, MockVmMetrics> getMetricsMap() {
-               return metricsMap;
-       }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6083ce5/agent-simulator/src/com/cloud/agent/MockVmMetrics.java
----------------------------------------------------------------------
diff --git a/agent-simulator/src/com/cloud/agent/MockVmMetrics.java 
b/agent-simulator/src/com/cloud/agent/MockVmMetrics.java
deleted file mode 100644
index f106f36..0000000
--- a/agent-simulator/src/com/cloud/agent/MockVmMetrics.java
+++ /dev/null
@@ -1,205 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.agent;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Random;
-import java.util.concurrent.ScheduledFuture;
-
-import org.apache.log4j.Logger;
-
-public class MockVmMetrics implements Runnable {
-       private static final Logger s_logger = 
Logger.getLogger(MockVmMetrics.class);
-       
-       private String vmName;
-       
-       public final int MAX_INTERFACES=1;
-       
-       public final int MAX_DISKS=8;
-       
-       //the last calculated traffic speed (transmit) per interface
-       private Map<String, Double> netTxKBps = new HashMap<String, Double>();
-       
-       //the last calculated traffic speed (receive) per interface
-       private Map<String, Double> netRxKBps = new HashMap<String, Double>();
-       
-       //the last calculated disk write speed per disk (Bytes Per Second)
-       private Map<String, Double> diskWriteKBytesPerSec = new HashMap<String, 
Double>();
-       
-       //the last calculated disk read speed per disk (Bytes Per Second)
-       private Map<String, Double> diskReadKBytesPerSec = new HashMap<String, 
Double>();
-       
-       //Total Bytes Transmitted on network interfaces
-       private Map<String, Long> netTxTotalBytes = new HashMap<String, Long>();
-       
-       //Total Bytes Received on network interfaces
-       private Map<String, Long> netRxTotalBytes = new HashMap<String, Long>();
-       
-       //Total Bytes read per disk
-       private Map<String, Long> diskReadTotalBytes = new HashMap<String, 
Long>();
-
-       //Total Bytes written per disk
-       private Map<String, Long> diskWriteTotalBytes = new HashMap<String, 
Long>();
-       
-       //CPU time in seconds
-       private Double cpuSeconds = new Double(0.0);
-       
-       //CPU percentage
-       private Float cpuPercent = new Float(0.0);
-       
-       private Map<String, String> diskMap = new HashMap<String, String>();
-
-       private Map<String, String> vifMap = new HashMap<String, String>();
-       
-       private Map<String, Long> diskStatTimestamp = new HashMap<String, 
Long>();
-       private Map<String, Long> netStatTimestamp = new HashMap<String, 
Long>();
-       
-       private long cpuStatTimestamp = 0L;
-       
-       private ScheduledFuture<?> future;
-       private boolean stopped = false;
-       private Random randSeed = new Random();
-
-       public MockVmMetrics(String vmName) {
-               this.vmName = vmName;
-               vifMap.put("eth0", "eth0");
-               vifMap.put("eth1", "eth1");
-               vifMap.put("eth2", "eth2");
-               
-               Long networkStart = 0L;
-               netTxTotalBytes.put("eth0", networkStart);
-               netRxTotalBytes.put("eth0", networkStart);
-               
-               netTxTotalBytes.put("eth1", networkStart);
-               netRxTotalBytes.put("eth1", networkStart);
-               
-               netTxTotalBytes.put("eth2", networkStart);
-               netRxTotalBytes.put("eth2", networkStart);              
-       }
-       
-       private int getIncrementor() {
-               return randSeed.nextInt(100);
-       }
-       
-       @Override
-       public void run() {
-               if(s_logger.isDebugEnabled()) {
-                       s_logger.debug("Generating MockVM metrics");
-               }
-               for (Map.Entry<String, Long> entry : 
netRxTotalBytes.entrySet()) {
-                       entry.setValue(entry.getValue() + getIncrementor());    
        
-               }
-               
-               for (Map.Entry<String, Long> entry : 
netTxTotalBytes.entrySet()) {
-                       entry.setValue(entry.getValue() + getIncrementor());
-               }
-       }
-       
-       public String getVmName() {
-               return vmName;
-       }
-       
-       public Map<String, Double> getNetTxKBps() {
-               return netTxKBps;
-       }
-       
-       public Map<String, Double> getNetRxKBps() {
-               return netRxKBps;
-       }
-
-       public Map<String, Double> getDiskWriteBytesPerSec() {
-               return diskWriteKBytesPerSec;
-       }
-       
-       public Map<String, Double> getDiskReadBytesPerSec() {
-               return diskReadKBytesPerSec;
-       }
-       
-       public  Map<String, Long> getNetTxTotalBytes() {
-               return netTxTotalBytes;
-       }
-
-       public Map<String, Long> getNetRxTotalBytes() {
-               return netRxTotalBytes;
-       }
-       
-       public Map<String, Long> getDiskReadTotalBytes() {
-               return diskReadTotalBytes;
-       }
-
-       public Map<String, Long> getDiskWriteTotalBytes() {
-               return diskWriteTotalBytes;
-       }
-       
-       public Double getNetTxKBps(String intf) {
-               return netTxKBps.get(intf);
-       }
-
-       public Double getNetRxKBps(String intf) {
-               return netRxKBps.get(intf);
-       }
-       
-       public Double getDiskWriteKBytesPerSec(String disk) {
-               return diskWriteKBytesPerSec.get(disk);
-       }
-
-       public Double getDiskReadKBytesPerSec(String disk) {
-               return diskReadKBytesPerSec.get(disk);
-       }
-       
-       public Long getNetTxTotalBytes(String intf) {
-               return netTxTotalBytes.get(intf);
-       }
-
-       public Long getNetRxTotalBytes(String intf) {
-               return netRxTotalBytes.get(intf);
-       }
-       
-       public Long getDiskReadTotalBytes(String disk) {
-               return diskReadTotalBytes.get(disk);
-       }
-
-       public Long getDiskWriteTotalBytes(String disk) {
-               return diskWriteTotalBytes.get(disk);
-       }
-       
-       public Double getCpuSeconds() {
-               return cpuSeconds;
-       }
-
-       public Map<String, String> getDiskMap() {
-               return diskMap;
-       }
-
-       public Float getCpuPercent() {
-               return cpuPercent;
-       }
-       
-       public void setFuture(ScheduledFuture<?> sf) {
-               this.future = sf;
-       }
-
-       public ScheduledFuture<?> getFuture() {
-               return future;
-       }
-       
-       public void stop() {
-               this.stopped = true;
-       }
-}
-

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6083ce5/agent-simulator/src/com/cloud/agent/MultiCaster.java
----------------------------------------------------------------------
diff --git a/agent-simulator/src/com/cloud/agent/MultiCaster.java 
b/agent-simulator/src/com/cloud/agent/MultiCaster.java
deleted file mode 100644
index 9c98ef6..0000000
--- a/agent-simulator/src/com/cloud/agent/MultiCaster.java
+++ /dev/null
@@ -1,152 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.agent;
-
-import java.io.IOException;
-import java.net.DatagramPacket;
-import java.net.DatagramSocket;
-import java.net.InetAddress;
-import java.net.MulticastSocket;
-import java.net.NetworkInterface;
-import java.net.SocketException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-
-public class MultiCaster implements Runnable {
-    private static final Logger s_logger = Logger.getLogger(MultiCaster.class);
-       
-       public final int MAX_PACKET_SIZE = 8096;
-       
-       private List<MultiCasterListener> listeners;
-       private DatagramSocket socket;
-       private byte[] recvBuffer;
-       
-       private Thread driver;
-       private volatile boolean stopRequested = false;
-       
-       public MultiCaster() {
-               listeners = new ArrayList<MultiCasterListener>();
-               recvBuffer = new byte[MAX_PACKET_SIZE];
-       }
-       
-       public void addListener(MultiCasterListener listener) {
-               synchronized(listeners) {
-                       listeners.add(listener);
-               }
-       }
-       
-       public void removeListener(MultiCasterListener listener) {
-               synchronized(listeners) {
-                       listeners.remove(listener);
-               }
-       }
-       
-       public void cast(byte[] buf, int off, int len, 
-               InetAddress toAddress, int nToPort) throws IOException {
-               
-               if(socket == null)
-                       throw new IOException("multi caster is not started");
-               
-               if(len >= MAX_PACKET_SIZE)
-                       throw new IOException("packet size exceeds limit of " + 
MAX_PACKET_SIZE);
-                       
-               DatagramPacket packet = new DatagramPacket(buf, off, 
-                       len, toAddress, nToPort);
-
-               socket.send(packet);
-       }
-       
-       public void start(String strOutboundAddress, 
-               String strClusterAddress, int nPort) throws SocketException {
-               assert(socket == null);
-
-               InetAddress addr = null;
-               try {
-                       addr = InetAddress.getByName(strClusterAddress);
-               } catch(IOException e) {
-                       s_logger.error("Unexpected exception " , e);
-               }
-               
-               if(addr != null && addr.isMulticastAddress()) {
-                       try {
-                               socket = new MulticastSocket(nPort);
-                               socket.setReuseAddress(true);
-                               
-                               if(s_logger.isInfoEnabled())
-                                       s_logger.info("Join multicast group : " 
+ addr);
-                               
-                               ((MulticastSocket)socket).joinGroup(addr);
-                               ((MulticastSocket)socket).setTimeToLive(1);
-                               
-                               if(strOutboundAddress != null) {
-                                       if(s_logger.isInfoEnabled())
-                                               s_logger.info("set outgoing 
interface to : " + strOutboundAddress);
-                                       
-                                       InetAddress ia = 
InetAddress.getByName(strOutboundAddress);
-                                       NetworkInterface ni = 
NetworkInterface.getByInetAddress(ia);
-                                       
((MulticastSocket)socket).setNetworkInterface(ni);
-                               }
-                       } catch(IOException e) {
-                               s_logger.error("Unexpected exception " , e);
-                       }
-               } else {
-                       socket = new DatagramSocket(nPort);
-                       socket.setReuseAddress(true);
-               }
-               
-               driver = new Thread(this, "Multi-caster");
-               driver.setDaemon(true);
-               driver.start();
-       }
-       
-       public void stop() {
-               if(socket != null) {
-                       stopRequested = true;
-                       
-                       socket.close();
-                       if(driver != null) {
-                               try {
-                                       driver.join();
-                               } catch(InterruptedException e) {
-                               }
-                               driver = null;
-                       }
-               }
-               
-               socket = null;
-               stopRequested = false;
-       }
-       
-       public void run() {
-               while(!stopRequested) {
-                       try {
-                               DatagramPacket packet = new 
DatagramPacket(recvBuffer, recvBuffer.length);
-                               socket.receive(packet);
-                               
-                               for(Object listener : listeners.toArray()) {
-                                       
((MultiCasterListener)listener).onMultiCasting(packet.getData(),
-                                               packet.getOffset(), 
packet.getLength(), packet.getAddress());
-                               }
-                       } catch(IOException e) {
-                       } catch(Throwable e) {
-                               s_logger.error("Unhandled exception : ", e);
-                       }
-               }
-       }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6083ce5/agent-simulator/src/com/cloud/agent/MultiCasterListener.java
----------------------------------------------------------------------
diff --git a/agent-simulator/src/com/cloud/agent/MultiCasterListener.java 
b/agent-simulator/src/com/cloud/agent/MultiCasterListener.java
deleted file mode 100644
index fe4761b..0000000
--- a/agent-simulator/src/com/cloud/agent/MultiCasterListener.java
+++ /dev/null
@@ -1,22 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.agent;
-import java.net.InetAddress;
-
-public interface MultiCasterListener {
-       public void onMultiCasting(byte[] data, int off, int len, InetAddress 
addrFrom);
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6083ce5/agent-simulator/src/com/cloud/agent/SimulatorCmd.java
----------------------------------------------------------------------
diff --git a/agent-simulator/src/com/cloud/agent/SimulatorCmd.java 
b/agent-simulator/src/com/cloud/agent/SimulatorCmd.java
deleted file mode 100644
index 342bfd2..0000000
--- a/agent-simulator/src/com/cloud/agent/SimulatorCmd.java
+++ /dev/null
@@ -1,37 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.agent;
-
-import java.io.Serializable;
-
-public class SimulatorCmd implements Serializable {
-       private static final long serialVersionUID = 1L;
-       
-       private String testCase = "DEFAULT";
-       
-       public SimulatorCmd(String testCase) {
-               this.testCase = testCase; 
-       }
-       
-       public String getTestCase() {
-               return testCase;
-       }
-       
-       public void setTestCase(String testCase) {
-               this.testCase = testCase;
-       }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6083ce5/agent-simulator/src/com/cloud/agent/SimulatorMigrateVmCmd.java
----------------------------------------------------------------------
diff --git a/agent-simulator/src/com/cloud/agent/SimulatorMigrateVmCmd.java 
b/agent-simulator/src/com/cloud/agent/SimulatorMigrateVmCmd.java
deleted file mode 100644
index f86b16e..0000000
--- a/agent-simulator/src/com/cloud/agent/SimulatorMigrateVmCmd.java
+++ /dev/null
@@ -1,83 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.agent;
-
-public class SimulatorMigrateVmCmd extends SimulatorCmd {
-
-       private static final long serialVersionUID = 1L;
-
-    private String destIp;
-       
-       private String vmName;
-       private long ramSize;
-       private int cpuCount;
-       private int utilization;
-       
-       public SimulatorMigrateVmCmd(String testCase) {
-               super(testCase);
-       }
-
-       public String getDestIp() {
-               return destIp;
-       }
-
-       public void setDestIp(String destIp) {
-               this.destIp = destIp;
-       }
-       
-       public String getVmName() {
-               return vmName;
-       }
-
-       public void setVmName(String vmName) {
-               this.vmName = vmName;
-       }
-
-       public long getRamSize() {
-               return ramSize;
-       }
-
-       public void setRamSize(long ramSize) {
-               this.ramSize = ramSize;
-       }
-
-       public int getCpuCount() {
-               return cpuCount;
-       }
-
-       public void setCpuCount(int cpuCount) {
-               this.cpuCount = cpuCount;
-       }
-
-       public int getUtilization() {
-               return utilization;
-       }
-
-       public void setUtilization(int utilization) {
-               this.utilization = utilization;
-       }
-       
-       public String toString() {
-               StringBuffer sb = new StringBuffer();
-               sb.append("SimulatorMigrateVmCmd {").append("vm: 
").append(getVmName());
-               sb.append(", destIp: ").append(getDestIp()).append(", ramSize: 
").append(getRamSize());
-               sb.append(", cpuCount: ").append(getCpuCount()).append(", 
utilization: ").append(getUtilization());
-               sb.append("}");
-               
-               return sb.toString();
-       }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6083ce5/agent-simulator/src/com/cloud/agent/manager/MockAgentManager.java
----------------------------------------------------------------------
diff --git a/agent-simulator/src/com/cloud/agent/manager/MockAgentManager.java 
b/agent-simulator/src/com/cloud/agent/manager/MockAgentManager.java
deleted file mode 100644
index 7db5b20..0000000
--- a/agent-simulator/src/com/cloud/agent/manager/MockAgentManager.java
+++ /dev/null
@@ -1,66 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.agent.manager;
-
-import java.util.Map;
-
-import javax.naming.ConfigurationException;
-
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.CheckHealthCommand;
-import com.cloud.agent.api.CheckNetworkCommand;
-import com.cloud.agent.api.GetHostStatsAnswer;
-import com.cloud.agent.api.GetHostStatsCommand;
-import com.cloud.agent.api.MaintainCommand;
-import com.cloud.agent.api.PingTestCommand;
-import com.cloud.agent.api.PrepareForMigrationCommand;
-import com.cloud.resource.AgentResourceBase;
-import com.cloud.simulator.MockHost;
-import com.cloud.utils.component.Manager;
-
-public interface MockAgentManager extends Manager {
-       public static final long DEFAULT_HOST_MEM_SIZE = 8 * 1024 * 1024 * 
1024L; // 8G,
-                                                                               
                                                                                
// unit
-                                                                               
                                                                                
// of
-       // Mbytes
-       public static final int DEFAULT_HOST_CPU_CORES = 4; // 2 dual core CPUs 
(2 x
-       // 2)
-       public static final int DEFAULT_HOST_SPEED_MHZ = 8000; // 1 GHz CPUs
-
-       boolean configure(String name, Map<String, Object> params) throws 
ConfigurationException;
-
-       Map<AgentResourceBase, Map<String, String>> 
createServerResources(Map<String, Object> params);
-
-       boolean handleSystemVMStart(long vmId, String privateIpAddress, String 
privateMacAddress, String privateNetMask,
-                       long dcId, long podId, String name, String vmType, 
String url);
-
-       boolean handleSystemVMStop(long vmId);
-
-       GetHostStatsAnswer getHostStatistic(GetHostStatsCommand cmd);
-
-       Answer checkHealth(CheckHealthCommand cmd);
-
-       Answer pingTest(PingTestCommand cmd);
-
-       Answer prepareForMigrate(PrepareForMigrationCommand cmd);
-
-       MockHost getHost(String guid);
-
-       Answer maintain(MaintainCommand cmd);
-
-       Answer checkNetworkCommand(CheckNetworkCommand cmd);
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6083ce5/agent-simulator/src/com/cloud/agent/manager/MockAgentManagerImpl.java
----------------------------------------------------------------------
diff --git 
a/agent-simulator/src/com/cloud/agent/manager/MockAgentManagerImpl.java 
b/agent-simulator/src/com/cloud/agent/manager/MockAgentManagerImpl.java
deleted file mode 100755
index cb99297..0000000
--- a/agent-simulator/src/com/cloud/agent/manager/MockAgentManagerImpl.java
+++ /dev/null
@@ -1,468 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.agent.manager;
-
-import java.security.NoSuchAlgorithmException;
-import java.security.SecureRandom;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-import java.util.regex.PatternSyntaxException;
-
-import javax.ejb.Local;
-import javax.naming.ConfigurationException;
-
-import org.apache.log4j.Logger;
-
-import com.cloud.agent.AgentManager;
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.CheckHealthCommand;
-import com.cloud.agent.api.CheckNetworkAnswer;
-import com.cloud.agent.api.CheckNetworkCommand;
-import com.cloud.agent.api.GetHostStatsAnswer;
-import com.cloud.agent.api.GetHostStatsCommand;
-import com.cloud.agent.api.HostStatsEntry;
-import com.cloud.agent.api.MaintainAnswer;
-import com.cloud.agent.api.PingTestCommand;
-import com.cloud.agent.api.PrepareForMigrationAnswer;
-import com.cloud.agent.api.PrepareForMigrationCommand;
-import com.cloud.agent.api.to.VirtualMachineTO;
-import com.cloud.dc.dao.HostPodDao;
-import com.cloud.host.Host;
-import com.cloud.resource.AgentResourceBase;
-import com.cloud.resource.AgentRoutingResource;
-import com.cloud.resource.AgentStorageResource;
-import com.cloud.resource.ResourceManager;
-import com.cloud.simulator.MockHost;
-import com.cloud.simulator.MockHostVO;
-import com.cloud.simulator.MockVMVO;
-import com.cloud.simulator.dao.MockHostDao;
-import com.cloud.simulator.dao.MockVMDao;
-import com.cloud.utils.Pair;
-import com.cloud.utils.component.Inject;
-import com.cloud.utils.concurrency.NamedThreadFactory;
-import com.cloud.utils.db.DB;
-import com.cloud.utils.db.Transaction;
-import com.cloud.utils.exception.CloudRuntimeException;
-import com.cloud.utils.net.NetUtils;
-
-@Local(value = { MockAgentManager.class })
-public class MockAgentManagerImpl implements MockAgentManager {
-       private static final Logger s_logger = 
Logger.getLogger(MockAgentManagerImpl.class);
-       @Inject
-       HostPodDao _podDao = null;
-       @Inject
-       MockHostDao _mockHostDao = null;
-       @Inject
-       MockVMDao _mockVmDao = null;
-       @Inject
-       SimulatorManager _simulatorMgr = null;
-       @Inject
-       AgentManager _agentMgr = null;
-       @Inject
-       MockStorageManager _storageMgr = null;
-       @Inject
-       ResourceManager _resourceMgr;
-       private SecureRandom random;
-       private Map<String, AgentResourceBase> _resources = new 
ConcurrentHashMap<String, AgentResourceBase>();
-       private ThreadPoolExecutor _executor;
-
-       private Pair<String, Long> getPodCidr(long podId, long dcId) {
-               try {
-
-                       HashMap<Long, List<Object>> podMap = 
_podDao.getCurrentPodCidrSubnets(dcId, 0);
-                       List<Object> cidrPair = podMap.get(podId);
-                       String cidrAddress = (String) cidrPair.get(0);
-                       Long cidrSize = (Long) cidrPair.get(1);
-                       return new Pair<String, Long>(cidrAddress, cidrSize);
-               } catch (PatternSyntaxException e) {
-                       s_logger.error("Exception while splitting pod cidr");
-                       return null;
-               } catch (IndexOutOfBoundsException e) {
-                       s_logger.error("Invalid pod cidr. Please check");
-                       return null;
-               }
-       }
-
-       private String getIpAddress(long instanceId, long dcId, long podId) {
-               Pair<String, Long> cidr = this.getPodCidr(podId, dcId);
-               return NetUtils.long2Ip(NetUtils.ip2Long(cidr.first()) + 
instanceId);
-       }
-
-       private String getMacAddress(long dcId, long podId, long clusterId, int 
instanceId) {
-               return NetUtils.long2Mac((dcId << 40 + podId << 32 + clusterId 
<< 24 + instanceId));
-       }
-
-       public synchronized int getNextAgentId(long cidrSize) {
-               return random.nextInt((int) cidrSize);
-       }
-
-       @Override
-       @DB
-       public Map<AgentResourceBase, Map<String, String>> 
createServerResources(Map<String, Object> params) {
-
-               Map<String, String> args = new HashMap<String, String>();
-               Map<AgentResourceBase, Map<String, String>> newResources = new 
HashMap<AgentResourceBase, Map<String, String>>();
-               AgentResourceBase agentResource;
-               long cpuCore = Long.parseLong((String) params.get("cpucore"));
-               long cpuSpeed = Long.parseLong((String) params.get("cpuspeed"));
-               long memory = Long.parseLong((String) params.get("memory"));
-               long localStorageSize = Long.parseLong((String) 
params.get("localstorage"));
-               synchronized (this) {
-                       long dataCenterId = Long.parseLong((String) 
params.get("zone"));
-                       long podId = Long.parseLong((String) params.get("pod"));
-                       long clusterId = Long.parseLong((String) 
params.get("cluster"));
-                       long cidrSize = getPodCidr(podId, 
dataCenterId).second();
-
-                       int agentId = getNextAgentId(cidrSize);
-                       String ipAddress = getIpAddress(agentId, dataCenterId, 
podId);
-                       String macAddress = getMacAddress(dataCenterId, podId, 
clusterId, agentId);
-                       MockHostVO mockHost = new MockHostVO();
-                       mockHost.setDataCenterId(dataCenterId);
-                       mockHost.setPodId(podId);
-                       mockHost.setClusterId(clusterId);
-                       mockHost.setCapabilities("hvm");
-                       mockHost.setCpuCount(cpuCore);
-                       mockHost.setCpuSpeed(cpuSpeed);
-                       mockHost.setMemorySize(memory);
-                       String guid = UUID.randomUUID().toString();
-                       mockHost.setGuid(guid);
-                       mockHost.setName("SimulatedAgent." + guid);
-                       mockHost.setPrivateIpAddress(ipAddress);
-                       mockHost.setPublicIpAddress(ipAddress);
-                       mockHost.setStorageIpAddress(ipAddress);
-                       mockHost.setPrivateMacAddress(macAddress);
-                       mockHost.setPublicMacAddress(macAddress);
-                       mockHost.setStorageMacAddress(macAddress);
-                       
mockHost.setVersion(this.getClass().getPackage().getImplementationVersion());
-                       
mockHost.setResource("com.cloud.agent.AgentRoutingResource");
-
-                       Transaction txn = 
Transaction.open(Transaction.SIMULATOR_DB);
-                       try {
-                               txn.start();
-                               mockHost = _mockHostDao.persist(mockHost);
-                               txn.commit();
-                       } catch (Exception ex) {
-                               txn.rollback();
-                               s_logger.error("Error while configuring mock 
agent " + ex.getMessage());
-                               throw new CloudRuntimeException("Error 
configuring agent", ex);
-                       } finally {
-                               txn.close();
-                txn = Transaction.open(Transaction.CLOUD_DB);
-                txn.close();
-                       }
-
-                       _storageMgr.getLocalStorage(guid, localStorageSize);
-
-                       agentResource = new AgentRoutingResource();
-                       if (agentResource != null) {
-                               try {
-                                       params.put("guid", mockHost.getGuid());
-                                       agentResource.start();
-                                       
agentResource.configure(mockHost.getName(), params);
-
-                                       newResources.put(agentResource, args);
-                               } catch (ConfigurationException e) {
-                                       s_logger.error("error while configuring 
server resource" + e.getMessage());
-                               }
-                       }
-               }
-               return newResources;
-       }
-
-       @Override
-       public boolean configure(String name, Map<String, Object> params) 
throws ConfigurationException {
-               try {
-                       random = SecureRandom.getInstance("SHA1PRNG");
-                       _executor = new ThreadPoolExecutor(1, 5, 1, 
TimeUnit.DAYS, new LinkedBlockingQueue<Runnable>(),
-                                       new 
NamedThreadFactory("Simulator-Agent-Mgr"));
-                       // ComponentLocator locator = 
ComponentLocator.getCurrentLocator();
-                       // _simulatorMgr = (SimulatorManager)
-                       // locator.getComponent(SimulatorManager.Name);
-               } catch (NoSuchAlgorithmException e) {
-                       s_logger.debug("Failed to initialize random:" + 
e.toString());
-                       return false;
-               }
-               return true;
-       }
-
-       @Override
-       public boolean handleSystemVMStart(long vmId, String privateIpAddress, 
String privateMacAddress,
-                       String privateNetMask, long dcId, long podId, String 
name, String vmType, String url) {
-               _executor.execute(new SystemVMHandler(vmId, privateIpAddress, 
privateMacAddress, privateNetMask, dcId, podId,
-                               name, vmType, _simulatorMgr, url));
-               return true;
-       }
-
-       @Override
-       public boolean handleSystemVMStop(long vmId) {
-               _executor.execute(new SystemVMHandler(vmId));
-               return true;
-       }
-
-       private class SystemVMHandler implements Runnable {
-               private long vmId;
-               private String privateIpAddress;
-               private String privateMacAddress;
-               private String privateNetMask;
-               private long dcId;
-               private long podId;
-               private String guid;
-               private String name;
-               private String vmType;
-               private SimulatorManager mgr;
-               private String mode;
-               private String url;
-
-               public SystemVMHandler(long vmId, String privateIpAddress, 
String privateMacAddress, String privateNetMask,
-                               long dcId, long podId, String name, String 
vmType, SimulatorManager mgr, String url) {
-                       this.vmId = vmId;
-                       this.privateIpAddress = privateIpAddress;
-                       this.privateMacAddress = privateMacAddress;
-                       this.privateNetMask = privateNetMask;
-                       this.dcId = dcId;
-                       this.guid = "SystemVM-" + UUID.randomUUID().toString();
-                       this.name = name;
-                       this.vmType = vmType;
-                       this.mgr = mgr;
-                       this.mode = "Start";
-                       this.url = url;
-                       this.podId = podId;
-               }
-
-               public SystemVMHandler(long vmId) {
-                       this.vmId = vmId;
-                       this.mode = "Stop";
-               }
-
-               @Override
-               @DB
-               public void run() {
-
-                       Transaction txn = 
Transaction.open(Transaction.SIMULATOR_DB);
-                       try {
-                               if (this.mode.equalsIgnoreCase("Stop")) {
-                                       txn.start();
-                                       MockHost host = 
_mockHostDao.findByVmId(this.vmId);
-                                       if (host != null) {
-                                               String guid = host.getGuid();
-                                               if (guid != null) {
-                                                       AgentResourceBase res = 
_resources.get(guid);
-                                                       if (res != null) {
-                                                               res.stop();
-                                                               
_resources.remove(guid);
-                                                       }
-                                               }
-                                       }
-                                       txn.commit();
-                                       return;
-                               }
-                       } catch (Exception ex) {
-                               txn.rollback();
-                               throw new CloudRuntimeException("Unable to get 
host " + guid + " due to " + ex.getMessage(), ex);
-                       } finally {
-                               txn.close();
-                txn = Transaction.open(Transaction.CLOUD_DB);
-                txn.close();
-                       }
-
-                       String resource = null;
-                       if (vmType.equalsIgnoreCase("secstorage")) {
-                               resource = 
"com.cloud.agent.AgentStorageResource";
-                       }
-                       MockHostVO mockHost = new MockHostVO();
-                       mockHost.setDataCenterId(this.dcId);
-                       mockHost.setPodId(this.podId);
-                       mockHost.setCpuCount(DEFAULT_HOST_CPU_CORES);
-                       mockHost.setCpuSpeed(DEFAULT_HOST_SPEED_MHZ);
-                       mockHost.setMemorySize(DEFAULT_HOST_MEM_SIZE);
-                       mockHost.setGuid(this.guid);
-                       mockHost.setName(name);
-                       mockHost.setPrivateIpAddress(this.privateIpAddress);
-                       mockHost.setPublicIpAddress(this.privateIpAddress);
-                       mockHost.setStorageIpAddress(this.privateIpAddress);
-                       mockHost.setPrivateMacAddress(this.privateMacAddress);
-                       mockHost.setPublicMacAddress(this.privateMacAddress);
-                       mockHost.setStorageMacAddress(this.privateMacAddress);
-                       
mockHost.setVersion(this.getClass().getPackage().getImplementationVersion());
-                       mockHost.setResource(resource);
-                       mockHost.setVmId(vmId);
-                       Transaction simtxn = 
Transaction.open(Transaction.SIMULATOR_DB);
-                       try {
-                               simtxn.start();
-                               mockHost = _mockHostDao.persist(mockHost);
-                               simtxn.commit();
-                       } catch (Exception ex) {
-                               simtxn.rollback();
-                               throw new CloudRuntimeException("Unable to 
persist host " + mockHost.getGuid() + " due to "
-                                               + ex.getMessage(), ex);
-                       } finally {
-                               simtxn.close();
-                simtxn = Transaction.open(Transaction.CLOUD_DB);
-                simtxn.close();
-                       }
-
-                       if (vmType.equalsIgnoreCase("secstorage")) {
-                               AgentStorageResource storageResource = new 
AgentStorageResource();
-                               try {
-                                       Map<String, Object> params = new 
HashMap<String, Object>();
-                                       Map<String, String> details = new 
HashMap<String, String>();
-                                       params.put("guid", this.guid);
-                                       details.put("guid", this.guid);
-                                       
storageResource.configure("secondaryStorage", params);
-                                       storageResource.start();
-                                       // on the simulator the ssvm is as good 
as a direct
-                                       // agent
-                                       
_resourceMgr.addHost(mockHost.getDataCenterId(), storageResource, 
Host.Type.SecondaryStorageVM,
-                                                       details);
-                                       _resources.put(this.guid, 
storageResource);
-                               } catch (ConfigurationException e) {
-                                       s_logger.debug("Failed to load 
secondary storage resource: " + e.toString());
-                                       return;
-                               }
-                       }
-               }
-       }
-
-       @Override
-       public MockHost getHost(String guid) {
-               Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
-               try {
-                       txn.start();
-                       MockHost _host = _mockHostDao.findByGuid(guid);
-                       txn.commit();
-                       if (_host != null) {
-                               return _host;
-                       } else {
-                               s_logger.error("Host with guid " + guid + " was 
not found");
-                               return null;
-                       }
-               } catch (Exception ex) {
-                       txn.rollback();
-                       throw new CloudRuntimeException("Unable to get host " + 
guid + " due to " + ex.getMessage(), ex);
-               } finally {
-                       txn.close();
-            txn = Transaction.open(Transaction.CLOUD_DB);
-            txn.close();
-               }
-       }
-
-       @Override
-       public GetHostStatsAnswer getHostStatistic(GetHostStatsCommand cmd) {
-               String hostGuid = cmd.getHostGuid();
-               MockHost host = null;
-               Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
-               try {
-                       txn.start();
-                       host = _mockHostDao.findByGuid(hostGuid);
-                       txn.commit();
-                       if (host == null) {
-                               return null;
-                       }
-               } catch (Exception ex) {
-                       txn.rollback();
-                       throw new CloudRuntimeException("Unable to get host " + 
hostGuid + " due to " + ex.getMessage(), ex);
-               } finally {
-                       txn.close();
-            txn = Transaction.open(Transaction.CLOUD_DB);
-            txn.close();
-               }
-
-               Transaction vmtxn = Transaction.open(Transaction.SIMULATOR_DB);
-               try {
-                       vmtxn.start();
-                       List<MockVMVO> vms = 
_mockVmDao.findByHostId(host.getId());
-                       vmtxn.commit();
-                       double usedMem = 0.0;
-                       double usedCpu = 0.0;
-                       for (MockVMVO vm : vms) {
-                               usedMem += vm.getMemory();
-                               usedCpu += vm.getCpu();
-                       }
-
-                       HostStatsEntry hostStats = new HostStatsEntry();
-                       hostStats.setTotalMemoryKBs(host.getMemorySize());
-                       hostStats.setFreeMemoryKBs(host.getMemorySize() - 
usedMem);
-                       hostStats.setNetworkReadKBs(32768);
-                       hostStats.setNetworkWriteKBs(16384);
-                       hostStats.setCpuUtilization(usedCpu / 
(host.getCpuCount() * host.getCpuSpeed()));
-                       hostStats.setEntityType("simulator-host");
-                       hostStats.setHostId(cmd.getHostId());
-                       return new GetHostStatsAnswer(cmd, hostStats);
-               } catch (Exception ex) {
-                       vmtxn.rollback();
-                       throw new CloudRuntimeException("Unable to get Vms on 
host " + host.getGuid() + " due to "
-                                       + ex.getMessage(), ex);
-               } finally {
-                       vmtxn.close();
-            vmtxn = Transaction.open(Transaction.CLOUD_DB);
-            vmtxn.close();
-               }
-       }
-
-       @Override
-       public Answer checkHealth(CheckHealthCommand cmd) {
-               return new Answer(cmd);
-       }
-
-       @Override
-       public Answer pingTest(PingTestCommand cmd) {
-               return new Answer(cmd);
-       }
-
-       @Override
-       public PrepareForMigrationAnswer 
prepareForMigrate(PrepareForMigrationCommand cmd) {
-               VirtualMachineTO vm = cmd.getVirtualMachine();
-               if (s_logger.isDebugEnabled()) {
-                       s_logger.debug("Preparing host for migrating " + vm);
-               }
-               return new PrepareForMigrationAnswer(cmd);
-       }
-
-       @Override
-       public boolean start() {
-               return true;
-       }
-
-       @Override
-       public boolean stop() {
-               return true;
-       }
-
-       @Override
-       public String getName() {
-               return this.getClass().getSimpleName();
-       }
-
-       @Override
-       public MaintainAnswer maintain(com.cloud.agent.api.MaintainCommand cmd) 
{
-               return new MaintainAnswer(cmd);
-       }
-
-       @Override
-       public Answer checkNetworkCommand(CheckNetworkCommand cmd) {
-               if (s_logger.isDebugEnabled()) {
-                       s_logger.debug("Checking if network name setup is done 
on the resource");
-               }
-               return new CheckNetworkAnswer(cmd, true, "Network Setup check 
by names is done");
-       }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/d6083ce5/agent-simulator/src/com/cloud/agent/manager/MockStorageManager.java
----------------------------------------------------------------------
diff --git 
a/agent-simulator/src/com/cloud/agent/manager/MockStorageManager.java 
b/agent-simulator/src/com/cloud/agent/manager/MockStorageManager.java
deleted file mode 100644
index 3b7a286..0000000
--- a/agent-simulator/src/com/cloud/agent/manager/MockStorageManager.java
+++ /dev/null
@@ -1,91 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.agent.manager;
-
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.AttachIsoCommand;
-import com.cloud.agent.api.AttachVolumeAnswer;
-import com.cloud.agent.api.AttachVolumeCommand;
-import com.cloud.agent.api.BackupSnapshotCommand;
-import com.cloud.agent.api.ComputeChecksumCommand;
-import com.cloud.agent.api.CreatePrivateTemplateFromSnapshotCommand;
-import com.cloud.agent.api.CreatePrivateTemplateFromVolumeCommand;
-import com.cloud.agent.api.CreateStoragePoolCommand;
-import com.cloud.agent.api.CreateVolumeFromSnapshotCommand;
-import com.cloud.agent.api.DeleteSnapshotBackupCommand;
-import com.cloud.agent.api.DeleteStoragePoolCommand;
-import com.cloud.agent.api.GetStorageStatsAnswer;
-import com.cloud.agent.api.GetStorageStatsCommand;
-import com.cloud.agent.api.ManageSnapshotCommand;
-import com.cloud.agent.api.ModifyStoragePoolCommand;
-import com.cloud.agent.api.SecStorageSetupCommand;
-import com.cloud.agent.api.SecStorageVMSetupCommand;
-import com.cloud.agent.api.StoragePoolInfo;
-import com.cloud.agent.api.storage.CopyVolumeAnswer;
-import com.cloud.agent.api.storage.CopyVolumeCommand;
-import com.cloud.agent.api.storage.CreateAnswer;
-import com.cloud.agent.api.storage.CreateCommand;
-import com.cloud.agent.api.storage.DeleteTemplateCommand;
-import com.cloud.agent.api.storage.DestroyCommand;
-import com.cloud.agent.api.storage.DownloadCommand;
-import com.cloud.agent.api.storage.DownloadProgressCommand;
-import com.cloud.agent.api.storage.ListTemplateCommand;
-import com.cloud.agent.api.storage.PrimaryStorageDownloadAnswer;
-import com.cloud.agent.api.storage.PrimaryStorageDownloadCommand;
-import com.cloud.utils.component.Manager;
-
-public interface MockStorageManager extends Manager {
-    public static final long DEFAULT_HOST_STORAGE_SIZE = 1 * 1024 * 1024 * 
1024 * 1024L; //1T
-    public static final long DEFAULT_TEMPLATE_SIZE = 1 * 1000 * 1000 * 1000L; 
//1G
-    
-       public PrimaryStorageDownloadAnswer 
primaryStorageDownload(PrimaryStorageDownloadCommand cmd);
-       
-       public CreateAnswer createVolume(CreateCommand cmd);
-       public AttachVolumeAnswer AttachVolume(AttachVolumeCommand cmd);
-       public Answer AttachIso(AttachIsoCommand cmd);
-       
-       public Answer DeleteStoragePool(DeleteStoragePoolCommand cmd);
-       public Answer ModifyStoragePool(ModifyStoragePoolCommand cmd);
-       public Answer CreateStoragePool(CreateStoragePoolCommand cmd);
-       
-       public Answer SecStorageSetup(SecStorageSetupCommand cmd);
-       public Answer ListTemplates(ListTemplateCommand cmd);
-       public Answer Destroy(DestroyCommand cmd);
-       public Answer Download(DownloadCommand cmd);
-       public Answer DownloadProcess(DownloadProgressCommand cmd);
-       public GetStorageStatsAnswer GetStorageStats(GetStorageStatsCommand 
cmd);
-       public Answer ManageSnapshot(ManageSnapshotCommand cmd);
-       public Answer BackupSnapshot(BackupSnapshotCommand cmd, SimulatorInfo 
info);
-       public Answer DeleteSnapshotBackup(DeleteSnapshotBackupCommand cmd);
-       public Answer CreateVolumeFromSnapshot(CreateVolumeFromSnapshotCommand 
cmd);
-       public Answer DeleteTemplate(DeleteTemplateCommand cmd);
-       public Answer SecStorageVMSetup(SecStorageVMSetupCommand cmd);
-       
-       public void preinstallTemplates(String url, long zoneId);
-
-    StoragePoolInfo getLocalStorage(String hostGuid);
-
-    public Answer 
CreatePrivateTemplateFromSnapshot(CreatePrivateTemplateFromSnapshotCommand cmd);
-
-    public Answer ComputeChecksum(ComputeChecksumCommand cmd);
-
-    public Answer 
CreatePrivateTemplateFromVolume(CreatePrivateTemplateFromVolumeCommand cmd);
-
-    StoragePoolInfo getLocalStorage(String hostGuid, Long storageSize);
-
-       CopyVolumeAnswer CopyVolume(CopyVolumeCommand cmd);
-}

Reply via email to