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 <tsp@apache.org>
This commit is contained in:
Prasanna Santhanam 2012-12-22 13:01:44 -08:00
parent 0b60dda1e6
commit d6083ce51d
50 changed files with 631 additions and 578 deletions

View File

@ -0,0 +1,45 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloudstack-plugins</artifactId>
<version>4.1.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloud-plugin-hypervisor-simulator</artifactId>
<version>4.1.0-SNAPSHOT</version>
<name>Apache CloudStack Plugin - Hypervisor Simulator</name>
<description>Simulator Hypervisor for Cloudstack</description>
<build>
<defaultGoal>install</defaultGoal>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test</testSourceDirectory>
</build>
<dependencies>
<dependency>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloud-utils</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>

View File

@ -30,43 +30,43 @@ import com.cloud.utils.concurrency.NamedThreadFactory;
public class MetricsCollector { public class MetricsCollector {
private static final Logger s_logger = Logger.getLogger(MetricsCollector.class); private static final Logger s_logger = Logger.getLogger(MetricsCollector.class);
private final Set<String> vmNames = new HashSet<String>(); private final Set<String> vmNames = new HashSet<String>();
private final Set<String> newVMnames = new HashSet<String>(); private final Set<String> newVMnames = new HashSet<String>();
private final Map<String, MockVmMetrics> metricsMap = new HashMap<String, MockVmMetrics>(); private final Map<String, MockVmMetrics> metricsMap = new HashMap<String, MockVmMetrics>();
private final transient ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(1, new NamedThreadFactory("Metrics")); private final transient ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(1, new NamedThreadFactory("Metrics"));
private Set<String> _currentVms; private Set<String> _currentVms;
public MetricsCollector(Set<String> currentVms) { public MetricsCollector(Set<String> currentVms) {
_currentVms = currentVms; _currentVms = currentVms;
getAllVMNames(); getAllVMNames();
} }
public MetricsCollector() { public MetricsCollector() {
} }
public synchronized void getAllVMNames() { public synchronized void getAllVMNames() {
Set<String> currentVMs = _currentVms; Set<String> currentVMs = _currentVms;
newVMnames.clear(); newVMnames.clear();
newVMnames.addAll(currentVMs); newVMnames.addAll(currentVMs);
newVMnames.removeAll(vmNames); //leave only new vms newVMnames.removeAll(vmNames); //leave only new vms
vmNames.removeAll(currentVMs); //old vms - current vms --> leave non-running vms; vmNames.removeAll(currentVMs); //old vms - current vms --> leave non-running vms;
for (String vm: vmNames) { for (String vm: vmNames) {
removeVM(vm); removeVM(vm);
} }
vmNames.clear(); vmNames.clear();
vmNames.addAll(currentVMs); vmNames.addAll(currentVMs);
} }
public synchronized void submitMetricsJobs() { public synchronized void submitMetricsJobs() {
s_logger.debug("Submit Metric Jobs called"); s_logger.debug("Submit Metric Jobs called");
for (String vm : newVMnames) { for (String vm : newVMnames) {
MockVmMetrics task = new MockVmMetrics(vm); MockVmMetrics task = new MockVmMetrics(vm);
if (!metricsMap.containsKey(vm)) { if (!metricsMap.containsKey(vm)) {
@ -77,30 +77,30 @@ public class MetricsCollector {
} }
newVMnames.clear(); newVMnames.clear();
} }
public synchronized void addVM(String vmName) { public synchronized void addVM(String vmName) {
newVMnames.add(vmName); newVMnames.add(vmName);
s_logger.debug("Added vm name= " + vmName); s_logger.debug("Added vm name= " + vmName);
} }
public synchronized void removeVM(String vmName) { public synchronized void removeVM(String vmName) {
newVMnames.remove(vmName); newVMnames.remove(vmName);
vmNames.remove(vmName); vmNames.remove(vmName);
MockVmMetrics task = metricsMap.get(vmName); MockVmMetrics task = metricsMap.get(vmName);
if (task != null) { if (task != null) {
task.stop(); task.stop();
boolean r1= task.getFuture().cancel(false); boolean r1= task.getFuture().cancel(false);
metricsMap.remove(vmName); metricsMap.remove(vmName);
s_logger.debug("removeVM: cancel returned " + r1 + " for VM " + vmName); s_logger.debug("removeVM: cancel returned " + r1 + " for VM " + vmName);
} else { } else {
s_logger.warn("removeVM called for nonexistent VM " + vmName); s_logger.warn("removeVM called for nonexistent VM " + vmName);
}
} }
}
public synchronized Set<String> getVMNames() { public synchronized Set<String> getVMNames() {
return vmNames; return vmNames;
} }
public synchronized Map<String, MockVmMetrics> getMetricsMap() { public synchronized Map<String, MockVmMetrics> getMetricsMap() {
return metricsMap; return metricsMap;
} }

View File

@ -25,52 +25,52 @@ import org.apache.log4j.Logger;
public class MockVmMetrics implements Runnable { public class MockVmMetrics implements Runnable {
private static final Logger s_logger = Logger.getLogger(MockVmMetrics.class); private static final Logger s_logger = Logger.getLogger(MockVmMetrics.class);
private String vmName; private String vmName;
public final int MAX_INTERFACES=1; public final int MAX_INTERFACES=1;
public final int MAX_DISKS=8; public final int MAX_DISKS=8;
//the last calculated traffic speed (transmit) per interface //the last calculated traffic speed (transmit) per interface
private Map<String, Double> netTxKBps = new HashMap<String, Double>(); private Map<String, Double> netTxKBps = new HashMap<String, Double>();
//the last calculated traffic speed (receive) per interface //the last calculated traffic speed (receive) per interface
private Map<String, Double> netRxKBps = new HashMap<String, Double>(); private Map<String, Double> netRxKBps = new HashMap<String, Double>();
//the last calculated disk write speed per disk (Bytes Per Second) //the last calculated disk write speed per disk (Bytes Per Second)
private Map<String, Double> diskWriteKBytesPerSec = new HashMap<String, Double>(); private Map<String, Double> diskWriteKBytesPerSec = new HashMap<String, Double>();
//the last calculated disk read speed per disk (Bytes Per Second) //the last calculated disk read speed per disk (Bytes Per Second)
private Map<String, Double> diskReadKBytesPerSec = new HashMap<String, Double>(); private Map<String, Double> diskReadKBytesPerSec = new HashMap<String, Double>();
//Total Bytes Transmitted on network interfaces //Total Bytes Transmitted on network interfaces
private Map<String, Long> netTxTotalBytes = new HashMap<String, Long>(); private Map<String, Long> netTxTotalBytes = new HashMap<String, Long>();
//Total Bytes Received on network interfaces //Total Bytes Received on network interfaces
private Map<String, Long> netRxTotalBytes = new HashMap<String, Long>(); private Map<String, Long> netRxTotalBytes = new HashMap<String, Long>();
//Total Bytes read per disk //Total Bytes read per disk
private Map<String, Long> diskReadTotalBytes = new HashMap<String, Long>(); private Map<String, Long> diskReadTotalBytes = new HashMap<String, Long>();
//Total Bytes written per disk //Total Bytes written per disk
private Map<String, Long> diskWriteTotalBytes = new HashMap<String, Long>(); private Map<String, Long> diskWriteTotalBytes = new HashMap<String, Long>();
//CPU time in seconds //CPU time in seconds
private Double cpuSeconds = new Double(0.0); private Double cpuSeconds = new Double(0.0);
//CPU percentage //CPU percentage
private Float cpuPercent = new Float(0.0); private Float cpuPercent = new Float(0.0);
private Map<String, String> diskMap = new HashMap<String, String>(); private Map<String, String> diskMap = new HashMap<String, String>();
private Map<String, String> vifMap = 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> diskStatTimestamp = new HashMap<String, Long>();
private Map<String, Long> netStatTimestamp = new HashMap<String, Long>(); private Map<String, Long> netStatTimestamp = new HashMap<String, Long>();
private long cpuStatTimestamp = 0L; private long cpuStatTimestamp = 0L;
private ScheduledFuture<?> future; private ScheduledFuture<?> future;
private boolean stopped = false; private boolean stopped = false;
private Random randSeed = new Random(); private Random randSeed = new Random();
@ -80,44 +80,44 @@ public class MockVmMetrics implements Runnable {
vifMap.put("eth0", "eth0"); vifMap.put("eth0", "eth0");
vifMap.put("eth1", "eth1"); vifMap.put("eth1", "eth1");
vifMap.put("eth2", "eth2"); vifMap.put("eth2", "eth2");
Long networkStart = 0L; Long networkStart = 0L;
netTxTotalBytes.put("eth0", networkStart); netTxTotalBytes.put("eth0", networkStart);
netRxTotalBytes.put("eth0", networkStart); netRxTotalBytes.put("eth0", networkStart);
netTxTotalBytes.put("eth1", networkStart); netTxTotalBytes.put("eth1", networkStart);
netRxTotalBytes.put("eth1", networkStart); netRxTotalBytes.put("eth1", networkStart);
netTxTotalBytes.put("eth2", networkStart); netTxTotalBytes.put("eth2", networkStart);
netRxTotalBytes.put("eth2", networkStart); netRxTotalBytes.put("eth2", networkStart);
} }
private int getIncrementor() { private int getIncrementor() {
return randSeed.nextInt(100); return randSeed.nextInt(100);
} }
@Override @Override
public void run() { public void run() {
if(s_logger.isDebugEnabled()) { if(s_logger.isDebugEnabled()) {
s_logger.debug("Generating MockVM metrics"); s_logger.debug("Generating MockVM metrics");
} }
for (Map.Entry<String, Long> entry : netRxTotalBytes.entrySet()) { for (Map.Entry<String, Long> entry : netRxTotalBytes.entrySet()) {
entry.setValue(entry.getValue() + getIncrementor()); entry.setValue(entry.getValue() + getIncrementor());
} }
for (Map.Entry<String, Long> entry : netTxTotalBytes.entrySet()) { for (Map.Entry<String, Long> entry : netTxTotalBytes.entrySet()) {
entry.setValue(entry.getValue() + getIncrementor()); entry.setValue(entry.getValue() + getIncrementor());
} }
} }
public String getVmName() { public String getVmName() {
return vmName; return vmName;
} }
public Map<String, Double> getNetTxKBps() { public Map<String, Double> getNetTxKBps() {
return netTxKBps; return netTxKBps;
} }
public Map<String, Double> getNetRxKBps() { public Map<String, Double> getNetRxKBps() {
return netRxKBps; return netRxKBps;
} }
@ -125,11 +125,11 @@ public class MockVmMetrics implements Runnable {
public Map<String, Double> getDiskWriteBytesPerSec() { public Map<String, Double> getDiskWriteBytesPerSec() {
return diskWriteKBytesPerSec; return diskWriteKBytesPerSec;
} }
public Map<String, Double> getDiskReadBytesPerSec() { public Map<String, Double> getDiskReadBytesPerSec() {
return diskReadKBytesPerSec; return diskReadKBytesPerSec;
} }
public Map<String, Long> getNetTxTotalBytes() { public Map<String, Long> getNetTxTotalBytes() {
return netTxTotalBytes; return netTxTotalBytes;
} }
@ -137,7 +137,7 @@ public class MockVmMetrics implements Runnable {
public Map<String, Long> getNetRxTotalBytes() { public Map<String, Long> getNetRxTotalBytes() {
return netRxTotalBytes; return netRxTotalBytes;
} }
public Map<String, Long> getDiskReadTotalBytes() { public Map<String, Long> getDiskReadTotalBytes() {
return diskReadTotalBytes; return diskReadTotalBytes;
} }
@ -145,7 +145,7 @@ public class MockVmMetrics implements Runnable {
public Map<String, Long> getDiskWriteTotalBytes() { public Map<String, Long> getDiskWriteTotalBytes() {
return diskWriteTotalBytes; return diskWriteTotalBytes;
} }
public Double getNetTxKBps(String intf) { public Double getNetTxKBps(String intf) {
return netTxKBps.get(intf); return netTxKBps.get(intf);
} }
@ -153,7 +153,7 @@ public class MockVmMetrics implements Runnable {
public Double getNetRxKBps(String intf) { public Double getNetRxKBps(String intf) {
return netRxKBps.get(intf); return netRxKBps.get(intf);
} }
public Double getDiskWriteKBytesPerSec(String disk) { public Double getDiskWriteKBytesPerSec(String disk) {
return diskWriteKBytesPerSec.get(disk); return diskWriteKBytesPerSec.get(disk);
} }
@ -161,7 +161,7 @@ public class MockVmMetrics implements Runnable {
public Double getDiskReadKBytesPerSec(String disk) { public Double getDiskReadKBytesPerSec(String disk) {
return diskReadKBytesPerSec.get(disk); return diskReadKBytesPerSec.get(disk);
} }
public Long getNetTxTotalBytes(String intf) { public Long getNetTxTotalBytes(String intf) {
return netTxTotalBytes.get(intf); return netTxTotalBytes.get(intf);
} }
@ -169,7 +169,7 @@ public class MockVmMetrics implements Runnable {
public Long getNetRxTotalBytes(String intf) { public Long getNetRxTotalBytes(String intf) {
return netRxTotalBytes.get(intf); return netRxTotalBytes.get(intf);
} }
public Long getDiskReadTotalBytes(String disk) { public Long getDiskReadTotalBytes(String disk) {
return diskReadTotalBytes.get(disk); return diskReadTotalBytes.get(disk);
} }
@ -177,7 +177,7 @@ public class MockVmMetrics implements Runnable {
public Long getDiskWriteTotalBytes(String disk) { public Long getDiskWriteTotalBytes(String disk) {
return diskWriteTotalBytes.get(disk); return diskWriteTotalBytes.get(disk);
} }
public Double getCpuSeconds() { public Double getCpuSeconds() {
return cpuSeconds; return cpuSeconds;
} }
@ -189,7 +189,7 @@ public class MockVmMetrics implements Runnable {
public Float getCpuPercent() { public Float getCpuPercent() {
return cpuPercent; return cpuPercent;
} }
public void setFuture(ScheduledFuture<?> sf) { public void setFuture(ScheduledFuture<?> sf) {
this.future = sf; this.future = sf;
} }
@ -197,9 +197,8 @@ public class MockVmMetrics implements Runnable {
public ScheduledFuture<?> getFuture() { public ScheduledFuture<?> getFuture() {
return future; return future;
} }
public void stop() { public void stop() {
this.stopped = true; this.stopped = true;
} }
} }

View File

@ -30,49 +30,49 @@ import org.apache.log4j.Logger;
public class MultiCaster implements Runnable { public class MultiCaster implements Runnable {
private static final Logger s_logger = Logger.getLogger(MultiCaster.class); private static final Logger s_logger = Logger.getLogger(MultiCaster.class);
public final int MAX_PACKET_SIZE = 8096; public final int MAX_PACKET_SIZE = 8096;
private List<MultiCasterListener> listeners; private List<MultiCasterListener> listeners;
private DatagramSocket socket; private DatagramSocket socket;
private byte[] recvBuffer; private byte[] recvBuffer;
private Thread driver; private Thread driver;
private volatile boolean stopRequested = false; private volatile boolean stopRequested = false;
public MultiCaster() { public MultiCaster() {
listeners = new ArrayList<MultiCasterListener>(); listeners = new ArrayList<MultiCasterListener>();
recvBuffer = new byte[MAX_PACKET_SIZE]; recvBuffer = new byte[MAX_PACKET_SIZE];
} }
public void addListener(MultiCasterListener listener) { public void addListener(MultiCasterListener listener) {
synchronized(listeners) { synchronized(listeners) {
listeners.add(listener); listeners.add(listener);
} }
} }
public void removeListener(MultiCasterListener listener) { public void removeListener(MultiCasterListener listener) {
synchronized(listeners) { synchronized(listeners) {
listeners.remove(listener); listeners.remove(listener);
} }
} }
public void cast(byte[] buf, int off, int len, public void cast(byte[] buf, int off, int len,
InetAddress toAddress, int nToPort) throws IOException { InetAddress toAddress, int nToPort) throws IOException {
if(socket == null) if(socket == null)
throw new IOException("multi caster is not started"); throw new IOException("multi caster is not started");
if(len >= MAX_PACKET_SIZE) if(len >= MAX_PACKET_SIZE)
throw new IOException("packet size exceeds limit of " + MAX_PACKET_SIZE); throw new IOException("packet size exceeds limit of " + MAX_PACKET_SIZE);
DatagramPacket packet = new DatagramPacket(buf, off, DatagramPacket packet = new DatagramPacket(buf, off,
len, toAddress, nToPort); len, toAddress, nToPort);
socket.send(packet); socket.send(packet);
} }
public void start(String strOutboundAddress, public void start(String strOutboundAddress,
String strClusterAddress, int nPort) throws SocketException { String strClusterAddress, int nPort) throws SocketException {
assert(socket == null); assert(socket == null);
@ -82,22 +82,22 @@ public class MultiCaster implements Runnable {
} catch(IOException e) { } catch(IOException e) {
s_logger.error("Unexpected exception " , e); s_logger.error("Unexpected exception " , e);
} }
if(addr != null && addr.isMulticastAddress()) { if(addr != null && addr.isMulticastAddress()) {
try { try {
socket = new MulticastSocket(nPort); socket = new MulticastSocket(nPort);
socket.setReuseAddress(true); socket.setReuseAddress(true);
if(s_logger.isInfoEnabled()) if(s_logger.isInfoEnabled())
s_logger.info("Join multicast group : " + addr); s_logger.info("Join multicast group : " + addr);
((MulticastSocket)socket).joinGroup(addr); ((MulticastSocket)socket).joinGroup(addr);
((MulticastSocket)socket).setTimeToLive(1); ((MulticastSocket)socket).setTimeToLive(1);
if(strOutboundAddress != null) { if(strOutboundAddress != null) {
if(s_logger.isInfoEnabled()) if(s_logger.isInfoEnabled())
s_logger.info("set outgoing interface to : " + strOutboundAddress); s_logger.info("set outgoing interface to : " + strOutboundAddress);
InetAddress ia = InetAddress.getByName(strOutboundAddress); InetAddress ia = InetAddress.getByName(strOutboundAddress);
NetworkInterface ni = NetworkInterface.getByInetAddress(ia); NetworkInterface ni = NetworkInterface.getByInetAddress(ia);
((MulticastSocket)socket).setNetworkInterface(ni); ((MulticastSocket)socket).setNetworkInterface(ni);
@ -109,16 +109,16 @@ public class MultiCaster implements Runnable {
socket = new DatagramSocket(nPort); socket = new DatagramSocket(nPort);
socket.setReuseAddress(true); socket.setReuseAddress(true);
} }
driver = new Thread(this, "Multi-caster"); driver = new Thread(this, "Multi-caster");
driver.setDaemon(true); driver.setDaemon(true);
driver.start(); driver.start();
} }
public void stop() { public void stop() {
if(socket != null) { if(socket != null) {
stopRequested = true; stopRequested = true;
socket.close(); socket.close();
if(driver != null) { if(driver != null) {
try { try {
@ -128,17 +128,17 @@ public class MultiCaster implements Runnable {
driver = null; driver = null;
} }
} }
socket = null; socket = null;
stopRequested = false; stopRequested = false;
} }
public void run() { public void run() {
while(!stopRequested) { while(!stopRequested) {
try { try {
DatagramPacket packet = new DatagramPacket(recvBuffer, recvBuffer.length); DatagramPacket packet = new DatagramPacket(recvBuffer, recvBuffer.length);
socket.receive(packet); socket.receive(packet);
for(Object listener : listeners.toArray()) { for(Object listener : listeners.toArray()) {
((MultiCasterListener)listener).onMultiCasting(packet.getData(), ((MultiCasterListener)listener).onMultiCasting(packet.getData(),
packet.getOffset(), packet.getLength(), packet.getAddress()); packet.getOffset(), packet.getLength(), packet.getAddress());

View File

@ -20,17 +20,17 @@ import java.io.Serializable;
public class SimulatorCmd implements Serializable { public class SimulatorCmd implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private String testCase = "DEFAULT"; private String testCase = "DEFAULT";
public SimulatorCmd(String testCase) { public SimulatorCmd(String testCase) {
this.testCase = testCase; this.testCase = testCase;
} }
public String getTestCase() { public String getTestCase() {
return testCase; return testCase;
} }
public void setTestCase(String testCase) { public void setTestCase(String testCase) {
this.testCase = testCase; this.testCase = testCase;
} }

View File

@ -21,12 +21,12 @@ public class SimulatorMigrateVmCmd extends SimulatorCmd {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private String destIp; private String destIp;
private String vmName; private String vmName;
private long ramSize; private long ramSize;
private int cpuCount; private int cpuCount;
private int utilization; private int utilization;
public SimulatorMigrateVmCmd(String testCase) { public SimulatorMigrateVmCmd(String testCase) {
super(testCase); super(testCase);
} }
@ -38,7 +38,7 @@ public class SimulatorMigrateVmCmd extends SimulatorCmd {
public void setDestIp(String destIp) { public void setDestIp(String destIp) {
this.destIp = destIp; this.destIp = destIp;
} }
public String getVmName() { public String getVmName() {
return vmName; return vmName;
} }
@ -70,14 +70,14 @@ public class SimulatorMigrateVmCmd extends SimulatorCmd {
public void setUtilization(int utilization) { public void setUtilization(int utilization) {
this.utilization = utilization; this.utilization = utilization;
} }
public String toString() { public String toString() {
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
sb.append("SimulatorMigrateVmCmd {").append("vm: ").append(getVmName()); sb.append("SimulatorMigrateVmCmd {").append("vm: ").append(getVmName());
sb.append(", destIp: ").append(getDestIp()).append(", ramSize: ").append(getRamSize()); sb.append(", destIp: ").append(getDestIp()).append(", ramSize: ").append(getRamSize());
sb.append(", cpuCount: ").append(getCpuCount()).append(", utilization: ").append(getUtilization()); sb.append(", cpuCount: ").append(getCpuCount()).append(", utilization: ").append(getUtilization());
sb.append("}"); sb.append("}");
return sb.toString(); return sb.toString();
} }
} }

View File

@ -51,17 +51,17 @@ import com.cloud.utils.component.Manager;
public interface MockStorageManager extends 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_HOST_STORAGE_SIZE = 1 * 1024 * 1024 * 1024 * 1024L; //1T
public static final long DEFAULT_TEMPLATE_SIZE = 1 * 1000 * 1000 * 1000L; //1G public static final long DEFAULT_TEMPLATE_SIZE = 1 * 1000 * 1000 * 1000L; //1G
public PrimaryStorageDownloadAnswer primaryStorageDownload(PrimaryStorageDownloadCommand cmd); public PrimaryStorageDownloadAnswer primaryStorageDownload(PrimaryStorageDownloadCommand cmd);
public CreateAnswer createVolume(CreateCommand cmd); public CreateAnswer createVolume(CreateCommand cmd);
public AttachVolumeAnswer AttachVolume(AttachVolumeCommand cmd); public AttachVolumeAnswer AttachVolume(AttachVolumeCommand cmd);
public Answer AttachIso(AttachIsoCommand cmd); public Answer AttachIso(AttachIsoCommand cmd);
public Answer DeleteStoragePool(DeleteStoragePoolCommand cmd); public Answer DeleteStoragePool(DeleteStoragePoolCommand cmd);
public Answer ModifyStoragePool(ModifyStoragePoolCommand cmd); public Answer ModifyStoragePool(ModifyStoragePoolCommand cmd);
public Answer CreateStoragePool(CreateStoragePoolCommand cmd); public Answer CreateStoragePool(CreateStoragePoolCommand cmd);
public Answer SecStorageSetup(SecStorageSetupCommand cmd); public Answer SecStorageSetup(SecStorageSetupCommand cmd);
public Answer ListTemplates(ListTemplateCommand cmd); public Answer ListTemplates(ListTemplateCommand cmd);
public Answer Destroy(DestroyCommand cmd); public Answer Destroy(DestroyCommand cmd);
@ -74,7 +74,7 @@ public interface MockStorageManager extends Manager {
public Answer CreateVolumeFromSnapshot(CreateVolumeFromSnapshotCommand cmd); public Answer CreateVolumeFromSnapshot(CreateVolumeFromSnapshotCommand cmd);
public Answer DeleteTemplate(DeleteTemplateCommand cmd); public Answer DeleteTemplate(DeleteTemplateCommand cmd);
public Answer SecStorageVMSetup(SecStorageVMSetupCommand cmd); public Answer SecStorageVMSetup(SecStorageVMSetupCommand cmd);
public void preinstallTemplates(String url, long zoneId); public void preinstallTemplates(String url, long zoneId);
StoragePoolInfo getLocalStorage(String hostGuid); StoragePoolInfo getLocalStorage(String hostGuid);

View File

@ -703,7 +703,7 @@ public class MockStorageManagerImpl implements MockStorageManager {
txn = Transaction.open(Transaction.CLOUD_DB); txn = Transaction.open(Transaction.CLOUD_DB);
txn.close(); txn.close();
} }
MockVolumeVO newsnapshot = new MockVolumeVO(); MockVolumeVO newsnapshot = new MockVolumeVO();
String name = UUID.randomUUID().toString(); String name = UUID.randomUUID().toString();
newsnapshot.setName(name); newsnapshot.setName(name);
@ -953,7 +953,7 @@ public class MockStorageManagerImpl implements MockStorageManager {
@Override @Override
public StoragePoolInfo getLocalStorage(String hostGuid) { public StoragePoolInfo getLocalStorage(String hostGuid) {
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB); Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
MockHost host = null; MockHost host = null;
MockStoragePoolVO storagePool = null; MockStoragePoolVO storagePool = null;
try { try {
txn.start(); txn.start();
@ -968,7 +968,7 @@ public class MockStorageManagerImpl implements MockStorageManager {
txn = Transaction.open(Transaction.CLOUD_DB); txn = Transaction.open(Transaction.CLOUD_DB);
txn.close(); txn.close();
} }
if (storagePool == null) { if (storagePool == null) {
String uuid = UUID.randomUUID().toString(); String uuid = UUID.randomUUID().toString();
storagePool = new MockStoragePoolVO(); storagePool = new MockStoragePoolVO();
@ -998,7 +998,7 @@ public class MockStorageManagerImpl implements MockStorageManager {
@Override @Override
public StoragePoolInfo getLocalStorage(String hostGuid, Long storageSize) { public StoragePoolInfo getLocalStorage(String hostGuid, Long storageSize) {
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB); Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
MockHost host = null; MockHost host = null;
try { try {
txn.start(); txn.start();
host = _mockHostDao.findByGuid(hostGuid); host = _mockHostDao.findByGuid(hostGuid);

View File

@ -40,7 +40,7 @@ import com.cloud.vm.VirtualMachine.State;
public interface MockVmManager extends Manager { public interface MockVmManager extends Manager {
public Answer stopVM(StopCommand cmd); public Answer stopVM(StopCommand cmd);
public Answer rebootVM(RebootCommand cmd); public Answer rebootVM(RebootCommand cmd);
public Answer checkVmState(CheckVirtualMachineCommand cmd); public Answer checkVmState(CheckVirtualMachineCommand cmd);
public Map<String, State> getVmStates(String hostGuid); public Map<String, State> getVmStates(String hostGuid);
public Answer getVncPort(GetVncPortCommand cmd); public Answer getVncPort(GetVncPortCommand cmd);
@ -49,27 +49,27 @@ public interface MockVmManager extends Manager {
Answer getVmStats(GetVmStatsCommand cmd); Answer getVmStats(GetVmStatsCommand cmd);
public CheckSshAnswer checkSshCommand(CheckSshCommand cmd); public CheckSshAnswer checkSshCommand(CheckSshCommand cmd);
Answer SetStaticNatRules(SetStaticNatRulesCommand cmd); Answer SetStaticNatRules(SetStaticNatRulesCommand cmd);
Answer SetPortForwardingRules(SetPortForwardingRulesCommand cmd); Answer SetPortForwardingRules(SetPortForwardingRulesCommand cmd);
Answer SetFirewallRules(SetFirewallRulesCommand cmd); Answer SetFirewallRules(SetFirewallRulesCommand cmd);
Answer getNetworkUsage(NetworkUsageCommand cmd); Answer getNetworkUsage(NetworkUsageCommand cmd);
Answer IpAssoc(IpAssocCommand cmd); Answer IpAssoc(IpAssocCommand cmd);
Answer LoadBalancerConfig(LoadBalancerConfigCommand cmd); Answer LoadBalancerConfig(LoadBalancerConfigCommand cmd);
Answer AddDhcpEntry(DhcpEntryCommand cmd); Answer AddDhcpEntry(DhcpEntryCommand cmd);
Answer setVmData(VmDataCommand cmd); Answer setVmData(VmDataCommand cmd);
Answer CleanupNetworkRules(CleanupNetworkRulesCmd cmd, SimulatorInfo info); Answer CleanupNetworkRules(CleanupNetworkRulesCmd cmd, SimulatorInfo info);
Answer CheckConsoleProxyLoad(CheckConsoleProxyLoadCommand cmd); Answer CheckConsoleProxyLoad(CheckConsoleProxyLoadCommand cmd);
Answer WatchConsoleProxyLoad(WatchConsoleProxyLoadCommand cmd); Answer WatchConsoleProxyLoad(WatchConsoleProxyLoadCommand cmd);
Answer SavePassword(SavePasswordCommand cmd); Answer SavePassword(SavePasswordCommand cmd);
HashMap<String, Pair<Long, Long>> syncNetworkGroups(SimulatorInfo info); HashMap<String, Pair<Long, Long>> syncNetworkGroups(SimulatorInfo info);
SecurityGroupRuleAnswer AddSecurityGroupRules(SecurityGroupRulesCmd cmd, SimulatorInfo info); SecurityGroupRuleAnswer AddSecurityGroupRules(SecurityGroupRulesCmd cmd, SimulatorInfo info);

View File

@ -60,20 +60,20 @@ public class MockVmManagerImpl implements MockVmManager {
@Inject MockHostDao _mockHostDao = null; @Inject MockHostDao _mockHostDao = null;
@Inject MockSecurityRulesDao _mockSecurityDao = null; @Inject MockSecurityRulesDao _mockSecurityDao = null;
private Map<String, Map<String, Ternary<String, Long, Long>>> _securityRules = new ConcurrentHashMap<String, Map<String, Ternary<String, Long, Long>>>(); private Map<String, Map<String, Ternary<String, Long, Long>>> _securityRules = new ConcurrentHashMap<String, Map<String, Ternary<String, Long, Long>>>();
public MockVmManagerImpl() { public MockVmManagerImpl() {
} }
@Override @Override
public boolean configure(String name, Map<String, Object> params) public boolean configure(String name, Map<String, Object> params)
throws ConfigurationException { throws ConfigurationException {
return true; return true;
} }
public String startVM(String vmName, NicTO[] nics, public String startVM(String vmName, NicTO[] nics,
int cpuHz, long ramSize, int cpuHz, long ramSize,
String bootArgs, String hostGuid) { String bootArgs, String hostGuid) {
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB); Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
MockHost host = null; MockHost host = null;
@ -95,7 +95,7 @@ public class MockVmManagerImpl implements MockVmManager {
txn = Transaction.open(Transaction.CLOUD_DB); txn = Transaction.open(Transaction.CLOUD_DB);
txn.close(); txn.close();
} }
if(vm == null) { if(vm == null) {
int vncPort = 0; int vncPort = 0;
if(vncPort < 0) if(vncPort < 0)
@ -108,13 +108,13 @@ public class MockVmManagerImpl implements MockVmManager {
vm.setVncPort(vncPort); vm.setVncPort(vncPort);
vm.setHostId(host.getId()); vm.setHostId(host.getId());
if(vmName.startsWith("s-")) { if(vmName.startsWith("s-")) {
vm.setType("SecondaryStorageVm"); vm.setType("SecondaryStorageVm");
} else if (vmName.startsWith("v-")) { } else if (vmName.startsWith("v-")) {
vm.setType("ConsoleProxy"); vm.setType("ConsoleProxy");
} else if (vmName.startsWith("r-")) { } else if (vmName.startsWith("r-")) {
vm.setType("DomainRouter"); vm.setType("DomainRouter");
} else if (vmName.startsWith("i-")) { } else if (vmName.startsWith("i-")) {
vm.setType("User"); vm.setType("User");
} }
txn = Transaction.open(Transaction.SIMULATOR_DB); txn = Transaction.open(Transaction.SIMULATOR_DB);
try { try {
@ -133,18 +133,18 @@ public class MockVmManagerImpl implements MockVmManager {
if(vm.getState() == State.Stopped) { if(vm.getState() == State.Stopped) {
vm.setState(State.Running); vm.setState(State.Running);
txn = Transaction.open(Transaction.SIMULATOR_DB); txn = Transaction.open(Transaction.SIMULATOR_DB);
try { try {
txn.start(); txn.start();
_mockVmDao.update(vm.getId(), (MockVMVO)vm); _mockVmDao.update(vm.getId(), (MockVMVO)vm);
txn.commit(); txn.commit();
} catch (Exception ex) { } catch (Exception ex) {
txn.rollback(); txn.rollback();
throw new CloudRuntimeException("unable to update vm " + vm.getName(), ex); throw new CloudRuntimeException("unable to update vm " + vm.getName(), ex);
} finally { } finally {
txn.close(); txn.close();
txn = Transaction.open(Transaction.CLOUD_DB); txn = Transaction.open(Transaction.CLOUD_DB);
txn.close(); txn.close();
} }
} }
} }
@ -212,7 +212,7 @@ public class MockVmManagerImpl implements MockVmManager {
} }
return true; return true;
} }
@Override @Override
public Map<String, MockVMVO> getVms(String hostGuid) { public Map<String, MockVMVO> getVms(String hostGuid) {
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB); Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
@ -303,8 +303,8 @@ public class MockVmManagerImpl implements MockVmManager {
@Override @Override
public String getName() { public String getName() {
return this.getClass().getSimpleName(); return this.getClass().getSimpleName();
} }
@Override @Override
public Answer getVmStats(GetVmStatsCommand cmd) { public Answer getVmStats(GetVmStatsCommand cmd) {
HashMap<String, VmStatsEntry> vmStatsNameMap = new HashMap<String, VmStatsEntry>(); HashMap<String, VmStatsEntry> vmStatsNameMap = new HashMap<String, VmStatsEntry>();
@ -370,9 +370,9 @@ public class MockVmManagerImpl implements MockVmManager {
@Override @Override
public Answer SetFirewallRules(SetFirewallRulesCommand cmd) { public Answer SetFirewallRules(SetFirewallRulesCommand cmd) {
return new Answer(cmd); return new Answer(cmd);
} }
@Override @Override
public NetworkUsageAnswer getNetworkUsage(NetworkUsageCommand cmd) { public NetworkUsageAnswer getNetworkUsage(NetworkUsageCommand cmd) {
@ -516,20 +516,20 @@ public class MockVmManagerImpl implements MockVmManager {
public Answer WatchConsoleProxyLoad(WatchConsoleProxyLoadCommand cmd) { public Answer WatchConsoleProxyLoad(WatchConsoleProxyLoadCommand cmd) {
return Answer.createUnsupportedCommandAnswer(cmd); return Answer.createUnsupportedCommandAnswer(cmd);
} }
@Override @Override
public GetDomRVersionAnswer getDomRVersion(GetDomRVersionCmd cmd) { public GetDomRVersionAnswer getDomRVersion(GetDomRVersionCmd cmd) {
return new GetDomRVersionAnswer(cmd, null, null, null); return new GetDomRVersionAnswer(cmd, null, null, null);
} }
@Override @Override
public SecurityGroupRuleAnswer AddSecurityGroupRules(SecurityGroupRulesCmd cmd, SimulatorInfo info) { public SecurityGroupRuleAnswer AddSecurityGroupRules(SecurityGroupRulesCmd cmd, SimulatorInfo info) {
if (!info.isEnabled()) { if (!info.isEnabled()) {
return new SecurityGroupRuleAnswer(cmd, false, "Disabled", SecurityGroupRuleAnswer.FailureReason.CANNOT_BRIDGE_FIREWALL); return new SecurityGroupRuleAnswer(cmd, false, "Disabled", SecurityGroupRuleAnswer.FailureReason.CANNOT_BRIDGE_FIREWALL);
} }
Map<String, Ternary<String,Long, Long>> rules = _securityRules.get(info.getHostUuid()); Map<String, Ternary<String,Long, Long>> rules = _securityRules.get(info.getHostUuid());
if (rules == null) { if (rules == null) {
logSecurityGroupAction(cmd, null); logSecurityGroupAction(cmd, null);
rules = new ConcurrentHashMap<String, Ternary<String, Long, Long>>(); rules = new ConcurrentHashMap<String, Ternary<String, Long, Long>>();
@ -539,10 +539,10 @@ public class MockVmManagerImpl implements MockVmManager {
logSecurityGroupAction(cmd, rules.get(cmd.getVmName())); logSecurityGroupAction(cmd, rules.get(cmd.getVmName()));
rules.put(cmd.getVmName(), new Ternary<String, Long,Long>(cmd.getSignature(), cmd.getVmId(), cmd.getSeqNum())); rules.put(cmd.getVmName(), new Ternary<String, Long,Long>(cmd.getSignature(), cmd.getVmId(), cmd.getSeqNum()));
} }
return new SecurityGroupRuleAnswer(cmd); return new SecurityGroupRuleAnswer(cmd);
} }
private boolean logSecurityGroupAction(SecurityGroupRulesCmd cmd, Ternary<String,Long, Long> rule) { private boolean logSecurityGroupAction(SecurityGroupRulesCmd cmd, Ternary<String,Long, Long> rule) {
String action = ", do nothing"; String action = ", do nothing";
String reason = ", reason="; String reason = ", reason=";
@ -554,13 +554,13 @@ public class MockVmManagerImpl implements MockVmManager {
s_logger.info("New seqno received: " + cmd.getSeqNum() + " curr=" + currSeqnum); s_logger.info("New seqno received: " + cmd.getSeqNum() + " curr=" + currSeqnum);
updateSeqnoAndSig = true; updateSeqnoAndSig = true;
if (!cmd.getSignature().equals(currSig)) { if (!cmd.getSignature().equals(currSig)) {
s_logger.info("New seqno received: " + cmd.getSeqNum() + " curr=" + currSeqnum s_logger.info("New seqno received: " + cmd.getSeqNum() + " curr=" + currSeqnum
+ " new signature received:" + cmd.getSignature() + " curr=" + currSig + ", updated iptables"); + " new signature received:" + cmd.getSignature() + " curr=" + currSig + ", updated iptables");
action = ", updated iptables"; action = ", updated iptables";
reason = reason + "seqno_increased_sig_changed"; reason = reason + "seqno_increased_sig_changed";
} else { } else {
s_logger.info("New seqno received: " + cmd.getSeqNum() + " curr=" + currSeqnum s_logger.info("New seqno received: " + cmd.getSeqNum() + " curr=" + currSeqnum
+ " no change in signature:" + cmd.getSignature() + ", do nothing"); + " no change in signature:" + cmd.getSignature() + ", do nothing");
reason = reason + "seqno_increased_sig_same"; reason = reason + "seqno_increased_sig_same";
} }
} else if (cmd.getSeqNum() < currSeqnum) { } else if (cmd.getSeqNum() < currSeqnum) {
@ -568,14 +568,14 @@ public class MockVmManagerImpl implements MockVmManager {
reason = reason + "seqno_decreased"; reason = reason + "seqno_decreased";
} else { } else {
if (!cmd.getSignature().equals(currSig)) { if (!cmd.getSignature().equals(currSig)) {
s_logger.info("Identical seqno received: " + cmd.getSeqNum() s_logger.info("Identical seqno received: " + cmd.getSeqNum()
+ " new signature received:" + cmd.getSignature() + " curr=" + currSig + ", updated iptables"); + " new signature received:" + cmd.getSignature() + " curr=" + currSig + ", updated iptables");
action = ", updated iptables"; action = ", updated iptables";
reason = reason + "seqno_same_sig_changed"; reason = reason + "seqno_same_sig_changed";
updateSeqnoAndSig = true; updateSeqnoAndSig = true;
} else { } else {
s_logger.info("Identical seqno received: " + cmd.getSeqNum() + " curr=" + currSeqnum s_logger.info("Identical seqno received: " + cmd.getSeqNum() + " curr=" + currSeqnum
+ " no change in signature:" + cmd.getSignature() + ", do nothing"); + " no change in signature:" + cmd.getSignature() + ", do nothing");
reason = reason + "seqno_same_sig_same"; reason = reason + "seqno_same_sig_same";
} }
} }
@ -585,8 +585,8 @@ public class MockVmManagerImpl implements MockVmManager {
action = ", updated iptables"; action = ", updated iptables";
reason = ", seqno_new"; reason = ", seqno_new";
} }
s_logger.info("Programmed network rules for vm " + cmd.getVmName() + " seqno=" + cmd.getSeqNum() s_logger.info("Programmed network rules for vm " + cmd.getVmName() + " seqno=" + cmd.getSeqNum()
+ " signature=" + cmd.getSignature() + " signature=" + cmd.getSignature()
+ " guestIp=" + cmd.getGuestIp() + ", numIngressRules=" + " guestIp=" + cmd.getGuestIp() + ", numIngressRules="
+ cmd.getIngressRuleSet().length + ", numEgressRules=" + cmd.getIngressRuleSet().length + ", numEgressRules="
+ cmd.getEgressRuleSet().length + " total cidrs=" + cmd.getTotalNumCidrs() + action + reason); + cmd.getEgressRuleSet().length + " total cidrs=" + cmd.getTotalNumCidrs() + action + reason);
@ -595,13 +595,13 @@ public class MockVmManagerImpl implements MockVmManager {
@Override @Override
public Answer SavePassword(SavePasswordCommand cmd) { public Answer SavePassword(SavePasswordCommand cmd) {
return new Answer(cmd); return new Answer(cmd);
} }
@Override @Override
public HashMap<String, Pair<Long, Long>> syncNetworkGroups(SimulatorInfo info) { public HashMap<String, Pair<Long, Long>> syncNetworkGroups(SimulatorInfo info) {
HashMap<String, Pair<Long, Long>> maps = new HashMap<String, Pair<Long, Long>>(); HashMap<String, Pair<Long, Long>> maps = new HashMap<String, Pair<Long, Long>>();
Map<String, Ternary<String, Long, Long>> rules = _securityRules.get(info.getHostUuid()); Map<String, Ternary<String, Long, Long>> rules = _securityRules.get(info.getHostUuid());
if (rules == null) { if (rules == null) {
return maps; return maps;

View File

@ -20,39 +20,39 @@ public class SimulatorInfo {
private boolean enabled; private boolean enabled;
private int timeout; private int timeout;
private String hostUuid; private String hostUuid;
public SimulatorInfo(boolean enabled, int timeout, String hostUuid) { public SimulatorInfo(boolean enabled, int timeout, String hostUuid) {
this.enabled = enabled; this.enabled = enabled;
this.timeout = timeout; this.timeout = timeout;
this.hostUuid = hostUuid; this.hostUuid = hostUuid;
} }
public SimulatorInfo() { public SimulatorInfo() {
this.enabled = true; this.enabled = true;
this.timeout = -1; this.timeout = -1;
this.hostUuid = null; this.hostUuid = null;
} }
public boolean isEnabled() { public boolean isEnabled() {
return this.enabled; return this.enabled;
} }
public int getTimeout() { public int getTimeout() {
return this.timeout; return this.timeout;
} }
public String getHostUuid() { public String getHostUuid() {
return this.hostUuid; return this.hostUuid;
} }
public void setEnabled(boolean enabled) { public void setEnabled(boolean enabled) {
this.enabled = enabled; this.enabled = enabled;
} }
public void setTimeout(int timeout) { public void setTimeout(int timeout) {
this.timeout = timeout; this.timeout = timeout;
} }
public void setHostUuid(String hostUuid) { public void setHostUuid(String hostUuid) {
this.hostUuid = hostUuid; this.hostUuid = hostUuid;
} }

View File

@ -23,7 +23,6 @@ import java.util.Map;
import com.cloud.agent.api.Answer; import com.cloud.agent.api.Answer;
import com.cloud.agent.api.Command; import com.cloud.agent.api.Command;
import com.cloud.agent.api.StoragePoolInfo; import com.cloud.agent.api.StoragePoolInfo;
import com.cloud.agent.mockvm.MockVm;
import com.cloud.simulator.MockVMVO; import com.cloud.simulator.MockVMVO;
import com.cloud.utils.Pair; import com.cloud.utils.Pair;
import com.cloud.utils.component.Manager; import com.cloud.utils.component.Manager;
@ -31,10 +30,10 @@ import com.cloud.vm.VirtualMachine.State;
public interface SimulatorManager extends Manager { public interface SimulatorManager extends Manager {
public static final String Name = "simulator manager"; public static final String Name = "simulator manager";
public enum AgentType { public enum AgentType {
Computing(0), // not used anymore Computing(0), // not used anymore
Routing(1), Routing(1),
Storage(2); Storage(2);
int value; int value;
@ -56,7 +55,7 @@ public interface SimulatorManager extends Manager {
Answer simulate(Command cmd, String hostGuid); Answer simulate(Command cmd, String hostGuid);
StoragePoolInfo getLocalStorage(String hostGuid); StoragePoolInfo getLocalStorage(String hostGuid);
boolean configureSimulator(Long zoneId, Long podId, Long clusterId, Long hostId, String command, String values); boolean configureSimulator(Long zoneId, Long podId, Long clusterId, Long hostId, String command, String values);
public HashMap<String, Pair<Long, Long>> syncNetworkGroups(String hostGuid); public HashMap<String, Pair<Long, Long>> syncNetworkGroups(String hostGuid);

View File

@ -121,43 +121,43 @@ public class SimulatorManagerImpl implements SimulatorManager {
public Answer simulate(Command cmd, String hostGuid) { public Answer simulate(Command cmd, String hostGuid) {
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB); Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
// txn.transitToUserManagedConnection(_concierge.conn()); // txn.transitToUserManagedConnection(_concierge.conn());
try { try {
MockHost host = _mockHost.findByGuid(hostGuid); MockHost host = _mockHost.findByGuid(hostGuid);
String cmdName = cmd.toString(); String cmdName = cmd.toString();
int index = cmdName.lastIndexOf("."); int index = cmdName.lastIndexOf(".");
if (index != -1) { if (index != -1) {
cmdName = cmdName.substring(index + 1); cmdName = cmdName.substring(index + 1);
} }
MockConfigurationVO config = _mockConfigDao.findByNameBottomUP(host.getDataCenterId(), host.getPodId(), host.getClusterId(), host.getId(), cmdName); MockConfigurationVO config = _mockConfigDao.findByNameBottomUP(host.getDataCenterId(), host.getPodId(), host.getClusterId(), host.getId(), cmdName);
SimulatorInfo info = new SimulatorInfo(); SimulatorInfo info = new SimulatorInfo();
info.setHostUuid(hostGuid); info.setHostUuid(hostGuid);
if (config != null) { if (config != null) {
Map<String, String> configParameters = config.getParameters(); Map<String, String> configParameters = config.getParameters();
for (Map.Entry<String, String> entry : configParameters.entrySet()) { for (Map.Entry<String, String> entry : configParameters.entrySet()) {
if (entry.getKey().equalsIgnoreCase("enabled")) { if (entry.getKey().equalsIgnoreCase("enabled")) {
info.setEnabled(Boolean.parseBoolean(entry.getValue())); info.setEnabled(Boolean.parseBoolean(entry.getValue()));
} else if (entry.getKey().equalsIgnoreCase("timeout")) { } else if (entry.getKey().equalsIgnoreCase("timeout")) {
try { try {
info.setTimeout(Integer.valueOf(entry.getValue())); info.setTimeout(Integer.valueOf(entry.getValue()));
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
s_logger.debug("invalid timeout parameter: " + e.toString()); s_logger.debug("invalid timeout parameter: " + e.toString());
} }
} else if (entry.getKey().equalsIgnoreCase("wait")) { } else if (entry.getKey().equalsIgnoreCase("wait")) {
try { try {
int wait = Integer.valueOf(entry.getValue()); int wait = Integer.valueOf(entry.getValue());
Thread.sleep(wait * 1000); Thread.sleep(wait * 1000);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
s_logger.debug("invalid timeout parameter: " + e.toString()); s_logger.debug("invalid timeout parameter: " + e.toString());
} catch (InterruptedException e) { } catch (InterruptedException e) {
s_logger.debug("thread is interrupted: " + e.toString()); s_logger.debug("thread is interrupted: " + e.toString());
} }
} }
} }
} }
if (cmd instanceof GetHostStatsCommand) { if (cmd instanceof GetHostStatsCommand) {
return _mockAgentMgr.getHostStatistic((GetHostStatsCommand)cmd); return _mockAgentMgr.getHostStatistic((GetHostStatsCommand)cmd);
} else if (cmd instanceof CheckHealthCommand) { } else if (cmd instanceof CheckHealthCommand) {
@ -165,7 +165,7 @@ public class SimulatorManagerImpl implements SimulatorManager {
} else if (cmd instanceof PingTestCommand) { } else if (cmd instanceof PingTestCommand) {
return _mockAgentMgr.pingTest((PingTestCommand)cmd); return _mockAgentMgr.pingTest((PingTestCommand)cmd);
} else if (cmd instanceof PrepareForMigrationCommand) { } else if (cmd instanceof PrepareForMigrationCommand) {
return _mockAgentMgr.prepareForMigrate((PrepareForMigrationCommand)cmd); return _mockAgentMgr.prepareForMigrate((PrepareForMigrationCommand)cmd);
} else if (cmd instanceof MigrateCommand) { } else if (cmd instanceof MigrateCommand) {
return _mockVmMgr.Migrate((MigrateCommand)cmd, info); return _mockVmMgr.Migrate((MigrateCommand)cmd, info);
} else if (cmd instanceof StartCommand) { } else if (cmd instanceof StartCommand) {
@ -173,11 +173,11 @@ public class SimulatorManagerImpl implements SimulatorManager {
} else if (cmd instanceof CheckSshCommand) { } else if (cmd instanceof CheckSshCommand) {
return _mockVmMgr.checkSshCommand((CheckSshCommand)cmd); return _mockVmMgr.checkSshCommand((CheckSshCommand)cmd);
} else if (cmd instanceof CheckVirtualMachineCommand) { } else if (cmd instanceof CheckVirtualMachineCommand) {
return _mockVmMgr.checkVmState((CheckVirtualMachineCommand)cmd); return _mockVmMgr.checkVmState((CheckVirtualMachineCommand)cmd);
} else if (cmd instanceof SetStaticNatRulesCommand) { } else if (cmd instanceof SetStaticNatRulesCommand) {
return _mockVmMgr.SetStaticNatRules((SetStaticNatRulesCommand)cmd); return _mockVmMgr.SetStaticNatRules((SetStaticNatRulesCommand)cmd);
} else if (cmd instanceof SetFirewallRulesCommand) { } else if (cmd instanceof SetFirewallRulesCommand) {
return _mockVmMgr.SetFirewallRules((SetFirewallRulesCommand)cmd); return _mockVmMgr.SetFirewallRules((SetFirewallRulesCommand)cmd);
} else if (cmd instanceof SetPortForwardingRulesCommand) { } else if (cmd instanceof SetPortForwardingRulesCommand) {
return _mockVmMgr.SetPortForwardingRules((SetPortForwardingRulesCommand)cmd); return _mockVmMgr.SetPortForwardingRules((SetPortForwardingRulesCommand)cmd);
} else if (cmd instanceof NetworkUsageCommand) { } else if (cmd instanceof NetworkUsageCommand) {
@ -193,7 +193,7 @@ public class SimulatorManagerImpl implements SimulatorManager {
} else if (cmd instanceof CleanupNetworkRulesCmd) { } else if (cmd instanceof CleanupNetworkRulesCmd) {
return _mockVmMgr.CleanupNetworkRules((CleanupNetworkRulesCmd)cmd, info); return _mockVmMgr.CleanupNetworkRules((CleanupNetworkRulesCmd)cmd, info);
} else if (cmd instanceof CheckNetworkCommand) { } else if (cmd instanceof CheckNetworkCommand) {
return _mockAgentMgr.checkNetworkCommand((CheckNetworkCommand) cmd); return _mockAgentMgr.checkNetworkCommand((CheckNetworkCommand) cmd);
}else if (cmd instanceof StopCommand) { }else if (cmd instanceof StopCommand) {
return _mockVmMgr.stopVM((StopCommand)cmd); return _mockVmMgr.stopVM((StopCommand)cmd);
} else if (cmd instanceof RebootCommand) { } else if (cmd instanceof RebootCommand) {
@ -261,12 +261,12 @@ public class SimulatorManagerImpl implements SimulatorManager {
} else if (cmd instanceof BumpUpPriorityCommand) { } else if (cmd instanceof BumpUpPriorityCommand) {
return _mockVmMgr.bumpPriority((BumpUpPriorityCommand) cmd); return _mockVmMgr.bumpPriority((BumpUpPriorityCommand) cmd);
} else if (cmd instanceof GetDomRVersionCmd) { } else if (cmd instanceof GetDomRVersionCmd) {
return _mockVmMgr.getDomRVersion((GetDomRVersionCmd) cmd); return _mockVmMgr.getDomRVersion((GetDomRVersionCmd) cmd);
} else if (cmd instanceof ClusterSyncCommand) { } else if (cmd instanceof ClusterSyncCommand) {
return new Answer(cmd); return new Answer(cmd);
//return new ClusterSyncAnswer(((ClusterSyncCommand) cmd).getClusterId(), this.getVmStates(hostGuid)); //return new ClusterSyncAnswer(((ClusterSyncCommand) cmd).getClusterId(), this.getVmStates(hostGuid));
} else if (cmd instanceof CopyVolumeCommand) { } else if (cmd instanceof CopyVolumeCommand) {
return _mockStorageMgr.CopyVolume((CopyVolumeCommand) cmd); return _mockStorageMgr.CopyVolume((CopyVolumeCommand) cmd);
} else { } else {
return Answer.createUnsupportedCommandAnswer(cmd); return Answer.createUnsupportedCommandAnswer(cmd);
} }
@ -288,19 +288,19 @@ public class SimulatorManagerImpl implements SimulatorManager {
@Override @Override
public Map<String, State> getVmStates(String hostGuid) { public Map<String, State> getVmStates(String hostGuid) {
return _mockVmMgr.getVmStates(hostGuid); return _mockVmMgr.getVmStates(hostGuid);
} }
@Override @Override
public Map<String, MockVMVO> getVms(String hostGuid) { public Map<String, MockVMVO> getVms(String hostGuid) {
return _mockVmMgr.getVms(hostGuid); return _mockVmMgr.getVms(hostGuid);
} }
@Override @Override
public HashMap<String, Pair<Long, Long>> syncNetworkGroups(String hostGuid) { public HashMap<String, Pair<Long, Long>> syncNetworkGroups(String hostGuid) {
SimulatorInfo info = new SimulatorInfo(); SimulatorInfo info = new SimulatorInfo();
info.setHostUuid(hostGuid); info.setHostUuid(hostGuid);
return _mockVmMgr.syncNetworkGroups(info); return _mockVmMgr.syncNetworkGroups(info);
} }
@Override @Override

View File

@ -37,25 +37,25 @@ import com.cloud.utils.component.ComponentLocator;
public class ConfigureSimulator extends BaseCmd { public class ConfigureSimulator extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(ConfigureSimulator.class.getName()); public static final Logger s_logger = Logger.getLogger(ConfigureSimulator.class.getName());
private static final String s_name = "configuresimulatorresponse"; private static final String s_name = "configuresimulatorresponse";
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, description="configure range: in a zone") @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, description="configure range: in a zone")
private Long zoneId; private Long zoneId;
@Parameter(name=ApiConstants.POD_ID, type=CommandType.LONG, description="configure range: in a pod") @Parameter(name=ApiConstants.POD_ID, type=CommandType.LONG, description="configure range: in a pod")
private Long podId; private Long podId;
@Parameter(name=ApiConstants.CLUSTER_ID, type=CommandType.LONG, description="configure range: in a cluster") @Parameter(name=ApiConstants.CLUSTER_ID, type=CommandType.LONG, description="configure range: in a cluster")
private Long clusterId; private Long clusterId;
@Parameter(name=ApiConstants.HOST_ID, type=CommandType.LONG, description="configure range: in a host") @Parameter(name=ApiConstants.HOST_ID, type=CommandType.LONG, description="configure range: in a host")
private Long hostId; private Long hostId;
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="which command needs to be configured") @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="which command needs to be configured")
private String command; private String command;
@Parameter(name=ApiConstants.VALUE, type=CommandType.STRING, required=true, description="configuration options for this command, which is seperated by ;") @Parameter(name=ApiConstants.VALUE, type=CommandType.STRING, required=true, description="configuration options for this command, which is seperated by ;")
private String values; private String values;
@Override @Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException { public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
ComponentLocator locator = ComponentLocator.getLocator(ManagementService.Name); ComponentLocator locator = ComponentLocator.getLocator(ManagementService.Name);
@ -64,7 +64,7 @@ public class ConfigureSimulator extends BaseCmd {
if (!result) { if (!result) {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to configure simulator"); throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to configure simulator");
} }
SuccessResponse response = new SuccessResponse(getCommandName()); SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response); this.setResponseObject(response);
} }

View File

@ -52,7 +52,7 @@ public class AgentResourceBase implements ServerResource {
protected String _name; protected String _name;
private List<String> _warnings = new LinkedList<String>(); private List<String> _warnings = new LinkedList<String>();
private List<String> _errors = new LinkedList<String>(); private List<String> _errors = new LinkedList<String>();
private transient IAgentControl _agentControl; private transient IAgentControl _agentControl;
protected long _instanceId; protected long _instanceId;
@ -64,36 +64,36 @@ public class AgentResourceBase implements ServerResource {
protected MockHost agentHost = null; protected MockHost agentHost = null;
protected boolean stopped = false; protected boolean stopped = false;
protected String hostGuid = null; protected String hostGuid = null;
public AgentResourceBase(long instanceId, AgentType agentType, SimulatorManager simMgr, String hostGuid) { public AgentResourceBase(long instanceId, AgentType agentType, SimulatorManager simMgr, String hostGuid) {
_instanceId = instanceId; _instanceId = instanceId;
if(s_logger.isDebugEnabled()) { if(s_logger.isDebugEnabled()) {
s_logger.info("New Routing host instantiated with guid:" + hostGuid); s_logger.info("New Routing host instantiated with guid:" + hostGuid);
} }
if (agentType == AgentType.Routing) { if (agentType == AgentType.Routing) {
_type = Host.Type.Routing; _type = Host.Type.Routing;
} else { } else {
_type = Host.Type.Storage; _type = Host.Type.Storage;
} }
this.hostGuid = hostGuid; this.hostGuid = hostGuid;
} }
protected MockVmManager getVmMgr() { protected MockVmManager getVmMgr() {
return _simMgr.getVmMgr(); return _simMgr.getVmMgr();
} }
protected MockStorageManager getStorageMgr() { protected MockStorageManager getStorageMgr() {
return _simMgr.getStorageMgr(); return _simMgr.getStorageMgr();
} }
protected MockAgentManager getAgentMgr() { protected MockAgentManager getAgentMgr() {
return _simMgr.getAgentMgr(); return _simMgr.getAgentMgr();
} }
protected long getInstanceId() { protected long getInstanceId() {
return _instanceId; return _instanceId;
} }
@ -102,7 +102,7 @@ public class AgentResourceBase implements ServerResource {
if(s_logger.isDebugEnabled()) { if(s_logger.isDebugEnabled()) {
s_logger.debug("Deserializing simulated agent on reconnect"); s_logger.debug("Deserializing simulated agent on reconnect");
} }
} }
@Override @Override
@ -113,18 +113,18 @@ public class AgentResourceBase implements ServerResource {
public void setName(String name) { public void setName(String name) {
_name = name; _name = name;
} }
@Override @Override
public boolean configure(String name, Map<String, Object> params) public boolean configure(String name, Map<String, Object> params)
throws ConfigurationException { throws ConfigurationException {
hostGuid = (String)params.get("guid"); hostGuid = (String)params.get("guid");
_locator = ComponentLocator.getLocator("management-server"); _locator = ComponentLocator.getLocator("management-server");
_simMgr = _locator.getManager(SimulatorManager.class); _simMgr = _locator.getManager(SimulatorManager.class);
agentHost = getAgentMgr().getHost(hostGuid); agentHost = getAgentMgr().getHost(hostGuid);
return true; return true;
} }
private void reconnect(MockHost host) { private void reconnect(MockHost host) {
if(s_logger.isDebugEnabled()) { if(s_logger.isDebugEnabled()) {
@ -244,7 +244,7 @@ public class AgentResourceBase implements ServerResource {
} }
return file.getAbsolutePath(); return file.getAbsolutePath();
} }
@Override @Override
public Answer executeRequest(Command cmd) { public Answer executeRequest(Command cmd) {
@ -264,20 +264,20 @@ public class AgentResourceBase implements ServerResource {
public void setType(Host.Type _type) { public void setType(Host.Type _type) {
this._type = _type; this._type = _type;
} }
@Override @Override
public StartupCommand[] initialize() { public StartupCommand[] initialize() {
return null; return null;
} }
public SimulatorManager getSimulatorManager() { public SimulatorManager getSimulatorManager() {
return _simMgr; return _simMgr;
}
public void setSimulatorManager(SimulatorManager simMgr) {
_simMgr = simMgr;
} }
public void setSimulatorManager(SimulatorManager simMgr) {
_simMgr = simMgr;
}
public boolean isStopped() { public boolean isStopped() {
return this.stopped; return this.stopped;
} }

View File

@ -91,7 +91,7 @@ public class AgentRoutingResource extends AgentStorageResource {
} else if (cmd instanceof ReadyCommand) { } else if (cmd instanceof ReadyCommand) {
return new ReadyAnswer((ReadyCommand)cmd); return new ReadyAnswer((ReadyCommand)cmd);
} else if (cmd instanceof ShutdownCommand) { } else if (cmd instanceof ShutdownCommand) {
return execute((ShutdownCommand)cmd); return execute((ShutdownCommand)cmd);
} else { } else {
return _simMgr.simulate(cmd, hostGuid); return _simMgr.simulate(cmd, hostGuid);
} }
@ -99,7 +99,7 @@ public class AgentRoutingResource extends AgentStorageResource {
return new Answer(cmd, false, e.getMessage()); return new Answer(cmd, false, e.getMessage());
} }
} }
@Override @Override
public Type getType() { public Type getType() {
return Host.Type.Routing; return Host.Type.Routing;
@ -111,10 +111,10 @@ public class AgentRoutingResource extends AgentStorageResource {
return null; return null;
} }
synchronized (_vms) { synchronized (_vms) {
if (_vms.size() == 0) { if (_vms.size() == 0) {
//load vms state from database //load vms state from database
_vms.putAll(_simMgr.getVmStates(hostGuid)); _vms.putAll(_simMgr.getVmStates(hostGuid));
} }
} }
final HashMap<String, State> newStates = sync(); final HashMap<String, State> newStates = sync();
HashMap<String, Pair<Long, Long>> nwGrpStates = _simMgr.syncNetworkGroups(hostGuid); HashMap<String, Pair<Long, Long>> nwGrpStates = _simMgr.syncNetworkGroups(hostGuid);
@ -131,18 +131,18 @@ public class AgentRoutingResource extends AgentStorageResource {
totalCpu = agentHost.getCpuCount() * agentHost.getCpuSpeed(); totalCpu = agentHost.getCpuCount() * agentHost.getCpuSpeed();
totalMem = agentHost.getMemorySize(); totalMem = agentHost.getMemorySize();
for (Map.Entry<String, MockVMVO> entry : vmsMaps.entrySet()) { for (Map.Entry<String, MockVMVO> entry : vmsMaps.entrySet()) {
MockVMVO vm = entry.getValue(); MockVMVO vm = entry.getValue();
usedCpu += vm.getCpu(); usedCpu += vm.getCpu();
usedMem += vm.getMemory(); usedMem += vm.getMemory();
_runningVms.put(entry.getKey(), new Pair<Long, Long>(Long.valueOf(vm.getCpu()), vm.getMemory())); _runningVms.put(entry.getKey(), new Pair<Long, Long>(Long.valueOf(vm.getCpu()), vm.getMemory()));
} }
List<Object> info = getHostInfo(); List<Object> info = getHostInfo();
StartupRoutingCommand cmd = new StartupRoutingCommand((Integer) info.get(0), (Long) info.get(1), (Long) info.get(2), (Long) info.get(4), (String) info.get(3), HypervisorType.Simulator, StartupRoutingCommand cmd = new StartupRoutingCommand((Integer) info.get(0), (Long) info.get(1), (Long) info.get(2), (Long) info.get(4), (String) info.get(3), HypervisorType.Simulator,
RouterPrivateIpStrategy.HostLocal); RouterPrivateIpStrategy.HostLocal);
cmd.setStateChanges(changes); cmd.setStateChanges(changes);
Map<String, String> hostDetails = new HashMap<String, String>(); Map<String, String> hostDetails = new HashMap<String, String>();
hostDetails.put(RouterPrivateIpStrategy.class.getCanonicalName(), RouterPrivateIpStrategy.DcGlobal.toString()); hostDetails.put(RouterPrivateIpStrategy.class.getCanonicalName(), RouterPrivateIpStrategy.DcGlobal.toString());
@ -167,13 +167,13 @@ public class AgentRoutingResource extends AgentStorageResource {
cmd.setCluster(String.valueOf(agentHost.getClusterId())); cmd.setCluster(String.valueOf(agentHost.getClusterId()));
StartupStorageCommand ssCmd = initializeLocalSR(); StartupStorageCommand ssCmd = initializeLocalSR();
return new StartupCommand[] { cmd, ssCmd }; return new StartupCommand[] { cmd, ssCmd };
} }
private StartupStorageCommand initializeLocalSR() { private StartupStorageCommand initializeLocalSR() {
Map<String, TemplateInfo> tInfo = new HashMap<String, TemplateInfo>(); Map<String, TemplateInfo> tInfo = new HashMap<String, TemplateInfo>();
StoragePoolInfo poolInfo = _simMgr.getLocalStorage(hostGuid); StoragePoolInfo poolInfo = _simMgr.getLocalStorage(hostGuid);
StartupStorageCommand cmd = new StartupStorageCommand(poolInfo.getHostPath(), poolInfo.getPoolType(), poolInfo.getCapacityBytes(), tInfo); StartupStorageCommand cmd = new StartupStorageCommand(poolInfo.getHostPath(), poolInfo.getPoolType(), poolInfo.getCapacityBytes(), tInfo);
@ -183,14 +183,14 @@ public class AgentRoutingResource extends AgentStorageResource {
cmd.setResourceType(StorageResourceType.STORAGE_POOL); cmd.setResourceType(StorageResourceType.STORAGE_POOL);
return cmd; return cmd;
} }
protected synchronized Answer execute(StartCommand cmd) protected synchronized Answer execute(StartCommand cmd)
throws IllegalArgumentException { throws IllegalArgumentException {
VirtualMachineTO vmSpec = cmd.getVirtualMachine(); VirtualMachineTO vmSpec = cmd.getVirtualMachine();
String vmName = vmSpec.getName(); String vmName = vmSpec.getName();
if (this.totalCpu < (vmSpec.getCpus() * vmSpec.getSpeed() + this.usedCpu) || if (this.totalCpu < (vmSpec.getCpus() * vmSpec.getSpeed() + this.usedCpu) ||
this.totalMem < (vmSpec.getMaxRam() + this.usedMem)) { this.totalMem < (vmSpec.getMaxRam() + this.usedMem)) {
return new StartAnswer(cmd, "Not enough resource to start the vm"); return new StartAnswer(cmd, "Not enough resource to start the vm");
} }
State state = State.Stopped; State state = State.Stopped;
synchronized (_vms) { synchronized (_vms) {
@ -202,7 +202,7 @@ public class AgentRoutingResource extends AgentStorageResource {
if (!result.getResult()) { if (!result.getResult()) {
return new StartAnswer(cmd, result.getDetails()); return new StartAnswer(cmd, result.getDetails());
} }
this.usedCpu += vmSpec.getCpus() * vmSpec.getSpeed(); this.usedCpu += vmSpec.getCpus() * vmSpec.getSpeed();
this.usedMem += vmSpec.getMaxRam(); this.usedMem += vmSpec.getMaxRam();
_runningVms.put(vmName, new Pair<Long, Long>(Long.valueOf(vmSpec.getCpus() * vmSpec.getSpeed()), vmSpec.getMaxRam())); _runningVms.put(vmName, new Pair<Long, Long>(Long.valueOf(vmSpec.getCpus() * vmSpec.getSpeed()), vmSpec.getMaxRam()));
@ -217,7 +217,7 @@ public class AgentRoutingResource extends AgentStorageResource {
return new StartAnswer(cmd); return new StartAnswer(cmd);
} }
protected synchronized StopAnswer execute(StopCommand cmd) { protected synchronized StopAnswer execute(StopCommand cmd) {
StopAnswer answer = null; StopAnswer answer = null;
@ -230,11 +230,11 @@ public class AgentRoutingResource extends AgentStorageResource {
} }
try { try {
Answer result = _simMgr.simulate(cmd, hostGuid); Answer result = _simMgr.simulate(cmd, hostGuid);
if (!result.getResult()) { if (!result.getResult()) {
return new StopAnswer(cmd, result.getDetails(), false); return new StopAnswer(cmd, result.getDetails(), false);
} }
answer = new StopAnswer(cmd, null, 0, true); answer = new StopAnswer(cmd, null, 0, true);
Pair<Long, Long> data = _runningVms.get(vmName); Pair<Long, Long> data = _runningVms.get(vmName);
if (data != null) { if (data != null) {
@ -242,16 +242,16 @@ public class AgentRoutingResource extends AgentStorageResource {
this.usedMem -= data.second(); this.usedMem -= data.second();
} }
state = State.Stopped; state = State.Stopped;
} finally { } finally {
synchronized (_vms) { synchronized (_vms) {
_vms.put(vmName, state); _vms.put(vmName, state);
} }
} }
return answer; return answer;
} }
protected CheckVirtualMachineAnswer execute(final CheckVirtualMachineCommand cmd) { protected CheckVirtualMachineAnswer execute(final CheckVirtualMachineCommand cmd) {
final String vmName = cmd.getVmName(); final String vmName = cmd.getVmName();
CheckVirtualMachineAnswer result = (CheckVirtualMachineAnswer)_simMgr.simulate(cmd, hostGuid); CheckVirtualMachineAnswer result = (CheckVirtualMachineAnswer)_simMgr.simulate(cmd, hostGuid);
@ -346,7 +346,7 @@ public class AgentRoutingResource extends AgentStorageResource {
return changes; return changes;
} }
private Answer execute(ShutdownCommand cmd) { private Answer execute(ShutdownCommand cmd) {
this.stopped = true; this.stopped = true;
return new Answer(cmd); return new Answer(cmd);

View File

@ -62,7 +62,7 @@ public class AgentStorageResource extends AgentResourceBase implements Secondary
return _simMgr.simulate(cmd, hostGuid); return _simMgr.simulate(cmd, hostGuid);
} }
} }
@Override @Override
public PingCommand getCurrentStatus(long id) { public PingCommand getCurrentStatus(long id) {
if (isStopped()) { if (isStopped()) {
@ -73,14 +73,14 @@ public class AgentStorageResource extends AgentResourceBase implements Secondary
@Override @Override
public Type getType() { public Type getType() {
if(SecondaryStorageVm.Role.templateProcessor.toString().equals(_role)) if(SecondaryStorageVm.Role.templateProcessor.toString().equals(_role))
return Host.Type.SecondaryStorage; return Host.Type.SecondaryStorage;
return Host.Type.SecondaryStorageCmdExecutor; return Host.Type.SecondaryStorageCmdExecutor;
} }
@Override @Override
public StartupCommand[] initialize() { public StartupCommand[] initialize() {
StartupSecondaryStorageCommand cmd = new StartupSecondaryStorageCommand(); StartupSecondaryStorageCommand cmd = new StartupSecondaryStorageCommand();
cmd.setPrivateIpAddress(agentHost.getPrivateIpAddress()); cmd.setPrivateIpAddress(agentHost.getPrivateIpAddress());
cmd.setPrivateNetmask(agentHost.getPrivateNetMask()); cmd.setPrivateNetmask(agentHost.getPrivateNetMask());
@ -97,15 +97,15 @@ public class AgentStorageResource extends AgentResourceBase implements Secondary
cmd.setPod(String.valueOf(agentHost.getPodId())); cmd.setPod(String.valueOf(agentHost.getPodId()));
cmd.setGuid(agentHost.getGuid()); cmd.setGuid(agentHost.getGuid());
return new StartupCommand[] { cmd }; return new StartupCommand[] { cmd };
} }
@Override @Override
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException { public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
if (!super.configure(name, params)) { if (!super.configure(name, params)) {
s_logger.warn("Base class was unable to configure"); s_logger.warn("Base class was unable to configure");
return false; return false;
} }
return true; return true;
} }

View File

@ -60,7 +60,7 @@ import com.cloud.utils.component.Inject;
public class SimulatorDiscoverer extends DiscovererBase implements Discoverer, Listener, ResourceStateAdapter { public class SimulatorDiscoverer extends DiscovererBase implements Discoverer, Listener, ResourceStateAdapter {
private static final Logger s_logger = Logger private static final Logger s_logger = Logger
.getLogger(SimulatorDiscoverer.class); .getLogger(SimulatorDiscoverer.class);
@Inject HostDao _hostDao; @Inject HostDao _hostDao;
@Inject VMTemplateDao _vmTemplateDao; @Inject VMTemplateDao _vmTemplateDao;
@Inject VMTemplateHostDao _vmTemplateHostDao; @Inject VMTemplateHostDao _vmTemplateHostDao;
@ -70,10 +70,10 @@ public class SimulatorDiscoverer extends DiscovererBase implements Discoverer, L
@Inject MockAgentManager _mockAgentMgr = null; @Inject MockAgentManager _mockAgentMgr = null;
@Inject MockStorageManager _mockStorageMgr = null; @Inject MockStorageManager _mockStorageMgr = null;
@Inject ResourceManager _resourceMgr; @Inject ResourceManager _resourceMgr;
/** /**
* Finds ServerResources of an in-process simulator * Finds ServerResources of an in-process simulator
* *
* @see com.cloud.resource.Discoverer#find(long, java.lang.Long, * @see com.cloud.resource.Discoverer#find(long, java.lang.Long,
* java.lang.Long, java.net.URI, java.lang.String, java.lang.String) * java.lang.Long, java.net.URI, java.lang.String, java.lang.String)
*/ */
@ -88,7 +88,7 @@ public class SimulatorDiscoverer extends DiscovererBase implements Discoverer, L
String scheme = uri.getScheme(); String scheme = uri.getScheme();
String host = uri.getAuthority(); String host = uri.getAuthority();
String commands = URLDecoder.decode(uri.getPath()); String commands = URLDecoder.decode(uri.getPath());
long cpuSpeed = _mockAgentMgr.DEFAULT_HOST_SPEED_MHZ; long cpuSpeed = _mockAgentMgr.DEFAULT_HOST_SPEED_MHZ;
long cpuCores = _mockAgentMgr.DEFAULT_HOST_CPU_CORES; long cpuCores = _mockAgentMgr.DEFAULT_HOST_CPU_CORES;
long memory = _mockAgentMgr.DEFAULT_HOST_MEM_SIZE; long memory = _mockAgentMgr.DEFAULT_HOST_MEM_SIZE;
@ -145,7 +145,7 @@ public class SimulatorDiscoverer extends DiscovererBase implements Discoverer, L
if (s_logger.isInfoEnabled()) if (s_logger.isInfoEnabled())
s_logger.info("invalid cluster id or cluster is not for Simulator hypervisors"); s_logger.info("invalid cluster id or cluster is not for Simulator hypervisors");
return null; return null;
} }
cluster = Long.toString(clusterId); cluster = Long.toString(clusterId);
if(clu.getGuid() == null) { if(clu.getGuid() == null) {
clu.setGuid(UUID.randomUUID().toString()); clu.setGuid(UUID.randomUUID().toString());
@ -205,23 +205,23 @@ public class SimulatorDiscoverer extends DiscovererBase implements Discoverer, L
for (HostVO h : hosts) { for (HostVO h : hosts) {
associateTemplatesToZone(h.getId(), h.getDataCenterId()); associateTemplatesToZone(h.getId(), h.getDataCenterId());
} }
} }
private void associateTemplatesToZone(long hostId, long dcId){ private void associateTemplatesToZone(long hostId, long dcId){
VMTemplateZoneVO tmpltZone; VMTemplateZoneVO tmpltZone;
List<VMTemplateVO> allTemplates = _vmTemplateDao.listAll(); List<VMTemplateVO> allTemplates = _vmTemplateDao.listAll();
for (VMTemplateVO vt: allTemplates){ for (VMTemplateVO vt: allTemplates){
if (vt.isCrossZones()) { if (vt.isCrossZones()) {
tmpltZone = _vmTemplateZoneDao.findByZoneTemplate(dcId, vt.getId()); tmpltZone = _vmTemplateZoneDao.findByZoneTemplate(dcId, vt.getId());
if (tmpltZone == null) { if (tmpltZone == null) {
VMTemplateZoneVO vmTemplateZone = new VMTemplateZoneVO(dcId, vt.getId(), new Date()); VMTemplateZoneVO vmTemplateZone = new VMTemplateZoneVO(dcId, vt.getId(), new Date());
_vmTemplateZoneDao.persist(vmTemplateZone); _vmTemplateZoneDao.persist(vmTemplateZone);
} }
} }
} }
} }
@Override @Override
public HypervisorType getHypervisorType() { public HypervisorType getHypervisorType() {
return HypervisorType.Simulator; return HypervisorType.Simulator;
@ -231,7 +231,7 @@ public class SimulatorDiscoverer extends DiscovererBase implements Discoverer, L
public boolean matchHypervisor(String hypervisor) { public boolean matchHypervisor(String hypervisor) {
return hypervisor.equalsIgnoreCase(HypervisorType.Simulator.toString()); return hypervisor.equalsIgnoreCase(HypervisorType.Simulator.toString());
} }
@Override @Override
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException { public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
super.configure(name, params); super.configure(name, params);
@ -257,9 +257,9 @@ public class SimulatorDiscoverer extends DiscovererBase implements Discoverer, L
@Override @Override
public void processConnect(HostVO host, StartupCommand cmd, boolean forRebalance) throws ConnectionException { public void processConnect(HostVO host, StartupCommand cmd, boolean forRebalance) throws ConnectionException {
/*if(forRebalance) /*if(forRebalance)
return; return;
if ( Host.Type.SecondaryStorage == host.getType() ) { if ( Host.Type.SecondaryStorage == host.getType() ) {
List<VMTemplateVO> tmplts = _vmTemplateDao.listAll(); List<VMTemplateVO> tmplts = _vmTemplateDao.listAll();
for( VMTemplateVO tmplt : tmplts ) { for( VMTemplateVO tmplt : tmplts ) {
@ -275,7 +275,7 @@ public class SimulatorDiscoverer extends DiscovererBase implements Discoverer, L
} }
} }
}*/ }*/
} }
@Override @Override
@ -312,12 +312,12 @@ public class SimulatorDiscoverer extends DiscovererBase implements Discoverer, L
if (!(firstCmd instanceof StartupRoutingCommand)) { if (!(firstCmd instanceof StartupRoutingCommand)) {
return null; return null;
} }
StartupRoutingCommand ssCmd = ((StartupRoutingCommand) firstCmd); StartupRoutingCommand ssCmd = ((StartupRoutingCommand) firstCmd);
if (ssCmd.getHypervisorType() != HypervisorType.Simulator) { if (ssCmd.getHypervisorType() != HypervisorType.Simulator) {
return null; return null;
} }
return _resourceMgr.fillRoutingHostVO(host, ssCmd, HypervisorType.Simulator, details, hostTags); return _resourceMgr.fillRoutingHostVO(host, ssCmd, HypervisorType.Simulator, details, hostTags);
} }
@ -326,11 +326,11 @@ public class SimulatorDiscoverer extends DiscovererBase implements Discoverer, L
boolean isForceDeleteStorage) throws UnableDeleteHostException { boolean isForceDeleteStorage) throws UnableDeleteHostException {
return null; return null;
} }
@Override @Override
public boolean stop() { public boolean stop() {
_resourceMgr.unregisterResourceStateAdapter(this.getClass().getSimpleName()); _resourceMgr.unregisterResourceStateAdapter(this.getClass().getSimpleName());
return super.stop(); return super.stop();
} }
} }

View File

@ -45,14 +45,14 @@ public class SimulatorSecondaryDiscoverer extends SecondaryStorageDiscoverer imp
@Inject AgentManager _agentMgr; @Inject AgentManager _agentMgr;
@Inject ResourceManager _resourceMgr; @Inject ResourceManager _resourceMgr;
@Inject SnapshotDao _snapshotDao; @Inject SnapshotDao _snapshotDao;
@Override @Override
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException { public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
_agentMgr.registerForHostEvents(this, true, false, false); _agentMgr.registerForHostEvents(this, true, false, false);
_resourceMgr.registerResourceStateAdapter(this.getClass().getSimpleName(), this); _resourceMgr.registerResourceStateAdapter(this.getClass().getSimpleName(), this);
return super.configure(name, params); return super.configure(name, params);
} }
@Override @Override
public void postDiscovery(List<HostVO> hosts, long msId) { public void postDiscovery(List<HostVO> hosts, long msId) {
super.postDiscovery(hosts, msId); super.postDiscovery(hosts, msId);
@ -74,9 +74,9 @@ public class SimulatorSecondaryDiscoverer extends SecondaryStorageDiscoverer imp
//for detecting SSVM dispatch //for detecting SSVM dispatch
StartupCommand firstCmd = startup[0]; StartupCommand firstCmd = startup[0];
if (!(firstCmd instanceof StartupSecondaryStorageCommand)) { if (!(firstCmd instanceof StartupSecondaryStorageCommand)) {
return null; return null;
} }
host.setType(com.cloud.host.Host.Type.SecondaryStorageVM); host.setType(com.cloud.host.Host.Type.SecondaryStorageVM);
return host; return host;
} }
@ -103,7 +103,7 @@ public class SimulatorSecondaryDiscoverer extends SecondaryStorageDiscoverer imp
@Override @Override
public boolean stop() { public boolean stop() {
_resourceMgr.unregisterResourceStateAdapter(this.getClass().getSimpleName()); _resourceMgr.unregisterResourceStateAdapter(this.getClass().getSimpleName());
return true; return true;
} }
@ -130,7 +130,7 @@ public class SimulatorSecondaryDiscoverer extends SecondaryStorageDiscoverer imp
@Override @Override
public void processConnect(HostVO host, StartupCommand cmd, public void processConnect(HostVO host, StartupCommand cmd,
boolean forRebalance) throws ConnectionException { boolean forRebalance) throws ConnectionException {
} }
@Override @Override

View File

@ -25,7 +25,7 @@ public class ManagementServerSimulatorImpl extends ManagementServerExtImpl {
for (int i = 0; i < apis.length; i++) { for (int i = 0; i < apis.length; i++) {
newapis[i] = apis[i]; newapis[i] = apis[i];
} }
newapis[apis.length] = "commands-simulator.properties"; newapis[apis.length] = "commands-simulator.properties";
return newapis; return newapis;
} }

View File

@ -33,79 +33,79 @@ public class MockConfigurationVO {
@GeneratedValue(strategy=GenerationType.IDENTITY) @GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="id") @Column(name="id")
private long id; private long id;
@Column(name="data_center_id", nullable=false) @Column(name="data_center_id", nullable=false)
private Long dataCenterId; private Long dataCenterId;
@Column(name="pod_id") @Column(name="pod_id")
private Long podId; private Long podId;
@Column(name="cluster_id") @Column(name="cluster_id")
private Long clusterId; private Long clusterId;
@Column(name="host_id") @Column(name="host_id")
private Long hostId; private Long hostId;
@Column(name="name") @Column(name="name")
private String name; private String name;
@Column(name="values") @Column(name="values")
private String values; private String values;
public long getId() { public long getId() {
return this.id; return this.id;
} }
public Long getDataCenterId() { public Long getDataCenterId() {
return this.dataCenterId; return this.dataCenterId;
} }
public void setDataCenterId(Long dcId) { public void setDataCenterId(Long dcId) {
this.dataCenterId = dcId; this.dataCenterId = dcId;
} }
public Long getPodId() { public Long getPodId() {
return this.podId; return this.podId;
} }
public void setPodId(Long podId) { public void setPodId(Long podId) {
this.podId = podId; this.podId = podId;
} }
public Long getClusterId() { public Long getClusterId() {
return this.clusterId; return this.clusterId;
} }
public void setClusterId(Long clusterId) { public void setClusterId(Long clusterId) {
this.clusterId = clusterId; this.clusterId = clusterId;
} }
public Long getHostId() { public Long getHostId() {
return this.hostId; return this.hostId;
} }
public void setHostId(Long hostId) { public void setHostId(Long hostId) {
this.hostId = hostId; this.hostId = hostId;
} }
public String getName() { public String getName() {
return this.name; return this.name;
} }
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
public String getValues() { public String getValues() {
return this.values; return this.values;
} }
public Map<String, String> getParameters() { public Map<String, String> getParameters() {
Map<String, String> maps = new HashMap<String, String>(); Map<String, String> maps = new HashMap<String, String>();
if (this.values == null) { if (this.values == null) {
return maps; return maps;
} }
String[] vals = this.values.split("\\|"); String[] vals = this.values.split("\\|");
for (String val : vals) { for (String val : vals) {
String[] paras = val.split(":"); String[] paras = val.split(":");
@ -113,9 +113,8 @@ public class MockConfigurationVO {
} }
return maps; return maps;
} }
public void setValues(String values) { public void setValues(String values) {
this.values = values; this.values = values;
} }
} }

View File

@ -19,44 +19,44 @@ package com.cloud.simulator;
public interface MockHost { public interface MockHost {
public long getCpuSpeed(); public long getCpuSpeed();
public long getCpuCount(); public long getCpuCount();
public long getMemorySize(); public long getMemorySize();
public String getCapabilities(); public String getCapabilities();
public long getId(); public long getId();
public String getName(); public String getName();
public String getGuid(); public String getGuid();
public String getVersion(); public String getVersion();
public Long getDataCenterId(); public Long getDataCenterId();
public Long getPodId(); public Long getPodId();
public Long getClusterId(); public Long getClusterId();
public String getPrivateIpAddress(); public String getPrivateIpAddress();
public String getPrivateNetMask(); public String getPrivateNetMask();
public String getPrivateMacAddress(); public String getPrivateMacAddress();
public String getPublicIpAddress(); public String getPublicIpAddress();
public String getPublicNetMask(); public String getPublicNetMask();
public String getPublicMacAddress(); public String getPublicMacAddress();
public String getStorageIpAddress(); public String getStorageIpAddress();
public String getStorageNetMask(); public String getStorageNetMask();
public String getStorageMacAddress(); public String getStorageMacAddress();
} }

View File

@ -31,245 +31,245 @@ public class MockHostVO implements MockHost {
@GeneratedValue(strategy=GenerationType.IDENTITY) @GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="id") @Column(name="id")
private long id; private long id;
@Column(name="name", nullable=false) @Column(name="name", nullable=false)
private String name = null; private String name = null;
@Column(name="private_ip_address", nullable=false) @Column(name="private_ip_address", nullable=false)
private String privateIpAddress; private String privateIpAddress;
@Column(name="private_mac_address", nullable=false) @Column(name="private_mac_address", nullable=false)
private String privateMacAddress; private String privateMacAddress;
@Column(name="private_netmask", nullable=false) @Column(name="private_netmask", nullable=false)
private String privateNetmask; private String privateNetmask;
@Column(name="public_netmask") @Column(name="public_netmask")
private String publicNetmask; private String publicNetmask;
@Column(name="public_ip_address") @Column(name="public_ip_address")
private String publicIpAddress; private String publicIpAddress;
@Column(name="public_mac_address") @Column(name="public_mac_address")
private String publicMacAddress; private String publicMacAddress;
@Column(name="storage_ip_address") @Column(name="storage_ip_address")
private String storageIpAddress; private String storageIpAddress;
@Column(name="storage_mac_address") @Column(name="storage_mac_address")
private String storageMacAddress; private String storageMacAddress;
@Column(name="storage_netmask") @Column(name="storage_netmask")
private String storageNetMask; private String storageNetMask;
@Column(name="guid") @Column(name="guid")
private String guid; private String guid;
@Column(name="version") @Column(name="version")
private String version; private String version;
@Column(name="data_center_id", nullable=false) @Column(name="data_center_id", nullable=false)
private long dataCenterId; private long dataCenterId;
@Column(name="pod_id") @Column(name="pod_id")
private Long podId; private Long podId;
@Column(name="cluster_id") @Column(name="cluster_id")
private Long clusterId; private Long clusterId;
@Column(name="speed") @Column(name="speed")
private long cpuSpeed; private long cpuSpeed;
@Column(name="cpus") @Column(name="cpus")
private long cpuCount; private long cpuCount;
@Column(name="ram") @Column(name="ram")
private long memorySize; private long memorySize;
@Column(name="capabilities") @Column(name="capabilities")
private String capabilities; private String capabilities;
@Column(name="vm_id") @Column(name="vm_id")
private long vmId; private long vmId;
@Column(name="resource") @Column(name="resource")
private String resource; private String resource;
public MockHostVO() { public MockHostVO() {
} }
public long getVmId() { public long getVmId() {
return vmId; return vmId;
} }
public void setVmId(long vmId) { public void setVmId(long vmId) {
this.vmId = vmId; this.vmId = vmId;
} }
public String getResource() { public String getResource() {
return this.resource; return this.resource;
} }
public void setResource(String resource) { public void setResource(String resource) {
this.resource = resource; this.resource = resource;
} }
public long getCpuSpeed() { public long getCpuSpeed() {
return this.cpuSpeed; return this.cpuSpeed;
} }
public void setCpuSpeed(long cpuSpeed) { public void setCpuSpeed(long cpuSpeed) {
this.cpuSpeed = cpuSpeed; this.cpuSpeed = cpuSpeed;
} }
public long getCpuCount() { public long getCpuCount() {
return this.cpuCount; return this.cpuCount;
} }
public void setCpuCount(long cpuCount) { public void setCpuCount(long cpuCount) {
this.cpuCount = cpuCount; this.cpuCount = cpuCount;
} }
public long getMemorySize() { public long getMemorySize() {
return this.memorySize; return this.memorySize;
} }
public void setMemorySize(long memorySize) { public void setMemorySize(long memorySize) {
this.memorySize = memorySize; this.memorySize = memorySize;
} }
public String getCapabilities() { public String getCapabilities() {
return this.capabilities; return this.capabilities;
} }
public void setCapabilities(String capabilities) { public void setCapabilities(String capabilities) {
this.capabilities = capabilities; this.capabilities = capabilities;
} }
public long getId() { public long getId() {
return id; return id;
} }
public String getName() { public String getName() {
return name; return name;
} }
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
public String getGuid() { public String getGuid() {
return this.guid; return this.guid;
} }
public void setGuid(String guid) { public void setGuid(String guid) {
this.guid = guid; this.guid = guid;
} }
public String getVersion() { public String getVersion() {
return this.version; return this.version;
} }
public void setVersion(String version) { public void setVersion(String version) {
this.version = version; this.version = version;
} }
public Long getDataCenterId() { public Long getDataCenterId() {
return this.dataCenterId; return this.dataCenterId;
} }
public void setDataCenterId(Long dataCenterId) { public void setDataCenterId(Long dataCenterId) {
this.dataCenterId = dataCenterId; this.dataCenterId = dataCenterId;
} }
public Long getPodId() { public Long getPodId() {
return this.podId; return this.podId;
} }
public void setPodId(long podId) { public void setPodId(long podId) {
this.podId = podId; this.podId = podId;
} }
public Long getClusterId() { public Long getClusterId() {
return this.clusterId; return this.clusterId;
} }
public void setClusterId(Long clusterId) { public void setClusterId(Long clusterId) {
this.clusterId = clusterId; this.clusterId = clusterId;
} }
public String getPrivateIpAddress() { public String getPrivateIpAddress() {
return privateIpAddress; return privateIpAddress;
} }
public void setPrivateIpAddress(String privateIpAddress) { public void setPrivateIpAddress(String privateIpAddress) {
this.privateIpAddress = privateIpAddress; this.privateIpAddress = privateIpAddress;
} }
public String getPrivateNetMask() { public String getPrivateNetMask() {
return this.privateNetmask; return this.privateNetmask;
} }
public void setPrivateNetMask(String privateNetmask) { public void setPrivateNetMask(String privateNetmask) {
this.privateNetmask = privateNetmask; this.privateNetmask = privateNetmask;
} }
public String getPrivateMacAddress() { public String getPrivateMacAddress() {
return this.privateMacAddress; return this.privateMacAddress;
} }
public void setPrivateMacAddress(String privateMacAddress) { public void setPrivateMacAddress(String privateMacAddress) {
this.privateMacAddress = privateMacAddress; this.privateMacAddress = privateMacAddress;
} }
public String getPublicIpAddress() { public String getPublicIpAddress() {
return this.publicIpAddress; return this.publicIpAddress;
} }
public void setPublicIpAddress(String publicIpAddress) { public void setPublicIpAddress(String publicIpAddress) {
this.publicIpAddress = publicIpAddress; this.publicIpAddress = publicIpAddress;
} }
public String getPublicNetMask() { public String getPublicNetMask() {
return this.publicNetmask; return this.publicNetmask;
} }
public void setPublicNetMask(String publicNetMask) { public void setPublicNetMask(String publicNetMask) {
this.publicNetmask = publicNetMask; this.publicNetmask = publicNetMask;
} }
public String getPublicMacAddress() { public String getPublicMacAddress() {
return this.publicMacAddress; return this.publicMacAddress;
} }
public void setPublicMacAddress(String publicMacAddress) { public void setPublicMacAddress(String publicMacAddress) {
this.publicMacAddress = publicMacAddress; this.publicMacAddress = publicMacAddress;
} }
public String getStorageIpAddress() { public String getStorageIpAddress() {
return this.storageIpAddress; return this.storageIpAddress;
} }
public void setStorageIpAddress(String storageIpAddress) { public void setStorageIpAddress(String storageIpAddress) {
this.storageIpAddress = storageIpAddress; this.storageIpAddress = storageIpAddress;
} }
public String getStorageNetMask() { public String getStorageNetMask() {
return this.storageNetMask; return this.storageNetMask;
} }
public void setStorageNetMask(String storageNetMask) { public void setStorageNetMask(String storageNetMask) {
this.storageNetMask = storageNetMask; this.storageNetMask = storageNetMask;
} }
public String getStorageMacAddress() { public String getStorageMacAddress() {
return this.storageMacAddress; return this.storageMacAddress;
} }
public void setStorageMacAddress(String storageMacAddress) { public void setStorageMacAddress(String storageMacAddress) {
this.storageMacAddress = storageMacAddress; this.storageMacAddress = storageMacAddress;
} }

View File

@ -31,45 +31,45 @@ public class MockSecStorageVO {
@GeneratedValue(strategy=GenerationType.IDENTITY) @GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="id") @Column(name="id")
private long id; private long id;
@Column(name="url") @Column(name="url")
private String url; private String url;
@Column(name="capacity") @Column(name="capacity")
private long capacity; private long capacity;
@Column(name="mount_point") @Column(name="mount_point")
private String mountPoint; private String mountPoint;
public MockSecStorageVO() { public MockSecStorageVO() {
} }
public long getId() { public long getId() {
return this.id; return this.id;
} }
public String getMountPoint() { public String getMountPoint() {
return this.mountPoint; return this.mountPoint;
} }
public void setMountPoint(String mountPoint) { public void setMountPoint(String mountPoint) {
this.mountPoint = mountPoint; this.mountPoint = mountPoint;
} }
public String getUrl() { public String getUrl() {
return url; return url;
} }
public void setUrl(String url) { public void setUrl(String url) {
this.url = url; this.url = url;
} }
public long getCapacity() { public long getCapacity() {
return this.capacity; return this.capacity;
} }
public void setCapacity(long capacity) { public void setCapacity(long capacity) {
this.capacity = capacity; this.capacity = capacity;
} }

View File

@ -31,73 +31,73 @@ public class MockSecurityRulesVO {
@GeneratedValue(strategy=GenerationType.IDENTITY) @GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="id") @Column(name="id")
private long id; private long id;
@Column(name="vmid") @Column(name="vmid")
private Long vmId; private Long vmId;
@Column(name="signature") @Column(name="signature")
private String signature; private String signature;
@Column(name="seqnum") @Column(name="seqnum")
private Long seqNum; private Long seqNum;
@Column(name="ruleset") @Column(name="ruleset")
private String ruleSet; private String ruleSet;
@Column(name="hostid") @Column(name="hostid")
private String hostId; private String hostId;
@Column(name="vmname") @Column(name="vmname")
public String vmName; public String vmName;
public String getVmName() { public String getVmName() {
return this.vmName; return this.vmName;
} }
public void setVmName(String vmName) { public void setVmName(String vmName) {
this.vmName = vmName; this.vmName = vmName;
} }
public String getHostId() { public String getHostId() {
return this.hostId; return this.hostId;
} }
public void setHostId(String hostId) { public void setHostId(String hostId) {
this.hostId = hostId; this.hostId = hostId;
} }
public long getId() { public long getId() {
return this.id; return this.id;
} }
public Long getVmId() { public Long getVmId() {
return this.vmId; return this.vmId;
} }
public void setVmId(Long vmId) { public void setVmId(Long vmId) {
this.vmId = vmId; this.vmId = vmId;
} }
public String getSignature() { public String getSignature() {
return this.signature; return this.signature;
} }
public void setSignature(String sig) { public void setSignature(String sig) {
this.signature = sig; this.signature = sig;
} }
public Long getSeqNum() { public Long getSeqNum() {
return this.seqNum; return this.seqNum;
} }
public void setSeqNum(Long seqNum) { public void setSeqNum(Long seqNum) {
this.seqNum = seqNum; this.seqNum = seqNum;
} }
public String getRuleSet() { public String getRuleSet() {
return this.ruleSet; return this.ruleSet;
} }
public void setRuleSet(String ruleset) { public void setRuleSet(String ruleset) {
this.ruleSet = ruleset; this.ruleSet = ruleset;
} }

View File

@ -35,67 +35,67 @@ public class MockStoragePoolVO {
@GeneratedValue(strategy=GenerationType.IDENTITY) @GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="id") @Column(name="id")
private long id; private long id;
@Column(name="guid") @Column(name="guid")
private String uuid; private String uuid;
@Column(name="mount_point") @Column(name="mount_point")
private String mountPoint; private String mountPoint;
@Column(name="capacity") @Column(name="capacity")
private long capacity; private long capacity;
@Column(name="hostguid") @Column(name="hostguid")
private String hostGuid; private String hostGuid;
@Column(name="pool_type") @Column(name="pool_type")
@Enumerated(value=EnumType.STRING) @Enumerated(value=EnumType.STRING)
private StoragePoolType poolType; private StoragePoolType poolType;
public MockStoragePoolVO() { public MockStoragePoolVO() {
} }
public String getHostGuid() { public String getHostGuid() {
return this.hostGuid; return this.hostGuid;
} }
public void setHostGuid(String hostGuid) { public void setHostGuid(String hostGuid) {
this.hostGuid = hostGuid; this.hostGuid = hostGuid;
} }
public long getId() { public long getId() {
return this.id; return this.id;
} }
public StoragePoolType getPoolType() { public StoragePoolType getPoolType() {
return this.poolType; return this.poolType;
} }
public void setStorageType(StoragePoolType poolType) { public void setStorageType(StoragePoolType poolType) {
this.poolType = poolType; this.poolType = poolType;
} }
public String getUuid() { public String getUuid() {
return this.uuid; return this.uuid;
} }
public void setUuid(String uuid) { public void setUuid(String uuid) {
this.uuid = uuid; this.uuid = uuid;
} }
public String getMountPoint() { public String getMountPoint() {
return this.mountPoint; return this.mountPoint;
} }
public void setMountPoint(String mountPoint) { public void setMountPoint(String mountPoint) {
this.mountPoint = mountPoint; this.mountPoint = mountPoint;
} }
public long getCapacity() { public long getCapacity() {
return this.capacity; return this.capacity;
} }
public void setCapacity(long capacity) { public void setCapacity(long capacity) {
this.capacity = capacity; this.capacity = capacity;
} }

View File

@ -33,98 +33,98 @@ public class MockVMVO implements MockVm{
@GeneratedValue(strategy=GenerationType.IDENTITY) @GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="id") @Column(name="id")
private long id; private long id;
@Column(name="name") @Column(name="name")
private String name; private String name;
@Column(name="host_id") @Column(name="host_id")
private long hostId; private long hostId;
@Column(name="type") @Column(name="type")
private String vmType; private String vmType;
@Column(name="state") @Column(name="state")
private State state; private State state;
@Column(name="vnc_port") @Column(name="vnc_port")
private int vncPort; private int vncPort;
@Column(name="memory") @Column(name="memory")
private long memory; private long memory;
@Column(name="cpu") @Column(name="cpu")
private int cpu; private int cpu;
public MockVMVO() { public MockVMVO() {
} }
public long getId() { public long getId() {
return this.id; return this.id;
} }
public String getName() { public String getName() {
return this.name; return this.name;
} }
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
public long getHostId() { public long getHostId() {
return this.hostId; return this.hostId;
} }
public void setHostId(long hostId) { public void setHostId(long hostId) {
this.hostId = hostId; this.hostId = hostId;
} }
public String getVmType() { public String getVmType() {
return this.vmType; return this.vmType;
} }
public void setVmType(String vmType) { public void setVmType(String vmType) {
this.vmType = vmType; this.vmType = vmType;
} }
public State getState() { public State getState() {
return this.state; return this.state;
} }
public String getType() { public String getType() {
return this.vmType; return this.vmType;
} }
public void setState(State state) { public void setState(State state) {
this.state = state; this.state = state;
} }
public int getVncPort() { public int getVncPort() {
return this.vncPort; return this.vncPort;
} }
public void setVncPort(int vncPort) { public void setVncPort(int vncPort) {
this.vncPort = vncPort; this.vncPort = vncPort;
} }
public long getMemory() { public long getMemory() {
return this.memory; return this.memory;
} }
public void setMemory(long memory) { public void setMemory(long memory) {
this.memory = memory; this.memory = memory;
} }
public int getCpu() { public int getCpu() {
return this.cpu; return this.cpu;
} }
public void setCpu(int cpu) { public void setCpu(int cpu) {
this.cpu = cpu; this.cpu = cpu;
} }
public void setType(String type) { public void setType(String type) {
this.vmType = type; this.vmType = type;
} }
} }

View File

@ -20,21 +20,21 @@ import com.cloud.vm.VirtualMachine.State;
// As storage is mapped from storage device, can virtually treat that VM here does // As storage is mapped from storage device, can virtually treat that VM here does
public interface MockVm { public interface MockVm {
public String getName(); public String getName();
public State getState(); public State getState();
public void setState(State state); public void setState(State state);
public void setHostId(long hostId); public void setHostId(long hostId);
public long getMemory(); public long getMemory();
public int getCpu(); public int getCpu();
public String getType(); public String getType();
public int getVncPort(); public int getVncPort();
public void setName(String name); public void setName(String name);
public void setMemory(long memory); public void setMemory(long memory);
public void setCpu(int cpu); public void setCpu(int cpu);
@ -42,4 +42,3 @@ public interface MockVm {
public void setVncPort(int vncPort); public void setVncPort(int vncPort);
public long getId(); public long getId();
} }

View File

@ -43,76 +43,76 @@ public class MockVolumeVO {
@GeneratedValue(strategy=GenerationType.IDENTITY) @GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="id") @Column(name="id")
private long id; private long id;
@Column(name="name") @Column(name="name")
private String name; private String name;
@Column(name="size") @Column(name="size")
private long size; private long size;
@Column(name="path") @Column(name="path")
private String path; private String path;
@Column(name="pool_id") @Column(name="pool_id")
private long poolId; private long poolId;
@Column(name="type") @Column(name="type")
@Enumerated(value=EnumType.STRING) @Enumerated(value=EnumType.STRING)
private MockVolumeType type; private MockVolumeType type;
@Column(name="status") @Column(name="status")
@Enumerated(value=EnumType.STRING) @Enumerated(value=EnumType.STRING)
private VMTemplateStorageResourceAssoc.Status status; private VMTemplateStorageResourceAssoc.Status status;
public long getId() { public long getId() {
return id; return id;
} }
public String getName() { public String getName() {
return this.name; return this.name;
} }
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
public long getSize() { public long getSize() {
return this.size; return this.size;
} }
public void setSize(long size) { public void setSize(long size) {
this.size = size; this.size = size;
} }
public String getPath() { public String getPath() {
return this.path; return this.path;
} }
public void setPath(String path) { public void setPath(String path) {
this.path = path; this.path = path;
} }
public long getPoolId() { public long getPoolId() {
return this.poolId; return this.poolId;
} }
public void setPoolId(long poolId) { public void setPoolId(long poolId) {
this.poolId = poolId; this.poolId = poolId;
} }
public MockVolumeType getType() { public MockVolumeType getType() {
return this.type; return this.type;
} }
public void setType(MockVolumeType type) { public void setType(MockVolumeType type) {
this.type = type; this.type = type;
} }
public Status getStatus() { public Status getStatus() {
return this.status; return this.status;
} }
public void setStatus(Status status) { public void setStatus(Status status) {
this.status = status; this.status = status;
} }
} }

View File

@ -35,7 +35,7 @@ public class SimulatorGuru extends HypervisorGuruBase implements HypervisorGuru
protected SimulatorGuru() { protected SimulatorGuru() {
super(); super();
} }
@Override @Override
public HypervisorType getHypervisorType() { public HypervisorType getHypervisorType() {
return HypervisorType.Simulator; return HypervisorType.Simulator;
@ -44,11 +44,11 @@ public class SimulatorGuru extends HypervisorGuruBase implements HypervisorGuru
@Override @Override
public <T extends VirtualMachine> VirtualMachineTO implement(VirtualMachineProfile<T> vm) { public <T extends VirtualMachine> VirtualMachineTO implement(VirtualMachineProfile<T> vm) {
VirtualMachineTO to = toVirtualMachineTO(vm); VirtualMachineTO to = toVirtualMachineTO(vm);
// Determine the VM's OS description // Determine the VM's OS description
GuestOSVO guestOS = _guestOsDao.findById(vm.getVirtualMachine().getGuestOSId()); GuestOSVO guestOS = _guestOsDao.findById(vm.getVirtualMachine().getGuestOSId());
to.setOs(guestOS.getDisplayName()); to.setOs(guestOS.getDisplayName());
return to; return to;
} }

View File

@ -26,15 +26,15 @@ import com.cloud.utils.exception.RuntimeCloudException;
public class SimulatorRuntimeException extends RuntimeCloudException { public class SimulatorRuntimeException extends RuntimeCloudException {
private static final long serialVersionUID = SerialVersionUID.CloudRuntimeException; private static final long serialVersionUID = SerialVersionUID.CloudRuntimeException;
public SimulatorRuntimeException(String message) { public SimulatorRuntimeException(String message) {
super(message); super(message);
} }
public SimulatorRuntimeException(String message, Throwable th) { public SimulatorRuntimeException(String message, Throwable th) {
super(message, th); super(message, th);
} }
protected SimulatorRuntimeException() { protected SimulatorRuntimeException() {
super(); super();
} }

View File

@ -35,8 +35,8 @@ public class MockConfigurationDaoImpl extends GenericDaoBase<MockConfigurationVO
private SearchBuilder<MockConfigurationVO> _searchByDcIDPodIdClusterIdName; private SearchBuilder<MockConfigurationVO> _searchByDcIDPodIdClusterIdName;
private SearchBuilder<MockConfigurationVO> _searchByDcIDPodIdClusterIdHostIdName; private SearchBuilder<MockConfigurationVO> _searchByDcIDPodIdClusterIdHostIdName;
private SearchBuilder<MockConfigurationVO> _searchByGlobalName; private SearchBuilder<MockConfigurationVO> _searchByGlobalName;
public MockConfigurationDaoImpl() { public MockConfigurationDaoImpl() {
_searchByGlobalName = createSearchBuilder(); _searchByGlobalName = createSearchBuilder();
_searchByGlobalName.and("dcId", _searchByGlobalName.entity().getDataCenterId(), SearchCriteria.Op.NULL); _searchByGlobalName.and("dcId", _searchByGlobalName.entity().getDataCenterId(), SearchCriteria.Op.NULL);
@ -45,7 +45,7 @@ public class MockConfigurationDaoImpl extends GenericDaoBase<MockConfigurationVO
_searchByGlobalName.and("hostId", _searchByGlobalName.entity().getHostId(), SearchCriteria.Op.NULL); _searchByGlobalName.and("hostId", _searchByGlobalName.entity().getHostId(), SearchCriteria.Op.NULL);
_searchByGlobalName.and("name", _searchByGlobalName.entity().getName(), SearchCriteria.Op.EQ); _searchByGlobalName.and("name", _searchByGlobalName.entity().getName(), SearchCriteria.Op.EQ);
_searchByGlobalName.done(); _searchByGlobalName.done();
_searchByDcIdName = createSearchBuilder(); _searchByDcIdName = createSearchBuilder();
_searchByDcIdName.and("dcId", _searchByDcIdName.entity().getDataCenterId(), SearchCriteria.Op.EQ); _searchByDcIdName.and("dcId", _searchByDcIdName.entity().getDataCenterId(), SearchCriteria.Op.EQ);
_searchByDcIdName.and("podId", _searchByDcIdName.entity().getPodId(), SearchCriteria.Op.NULL); _searchByDcIdName.and("podId", _searchByDcIdName.entity().getPodId(), SearchCriteria.Op.NULL);
@ -53,7 +53,7 @@ public class MockConfigurationDaoImpl extends GenericDaoBase<MockConfigurationVO
_searchByDcIdName.and("hostId", _searchByDcIdName.entity().getHostId(), SearchCriteria.Op.NULL); _searchByDcIdName.and("hostId", _searchByDcIdName.entity().getHostId(), SearchCriteria.Op.NULL);
_searchByDcIdName.and("name", _searchByDcIdName.entity().getName(), SearchCriteria.Op.EQ); _searchByDcIdName.and("name", _searchByDcIdName.entity().getName(), SearchCriteria.Op.EQ);
_searchByDcIdName.done(); _searchByDcIdName.done();
_searchByDcIDPodIdName = createSearchBuilder(); _searchByDcIDPodIdName = createSearchBuilder();
_searchByDcIDPodIdName.and("dcId", _searchByDcIDPodIdName.entity().getDataCenterId(), SearchCriteria.Op.EQ); _searchByDcIDPodIdName.and("dcId", _searchByDcIDPodIdName.entity().getDataCenterId(), SearchCriteria.Op.EQ);
_searchByDcIDPodIdName.and("podId", _searchByDcIDPodIdName.entity().getPodId(), SearchCriteria.Op.EQ); _searchByDcIDPodIdName.and("podId", _searchByDcIDPodIdName.entity().getPodId(), SearchCriteria.Op.EQ);
@ -61,7 +61,7 @@ public class MockConfigurationDaoImpl extends GenericDaoBase<MockConfigurationVO
_searchByDcIDPodIdName.and("hostId", _searchByDcIDPodIdName.entity().getHostId(), SearchCriteria.Op.NULL); _searchByDcIDPodIdName.and("hostId", _searchByDcIDPodIdName.entity().getHostId(), SearchCriteria.Op.NULL);
_searchByDcIDPodIdName.and("name", _searchByDcIDPodIdName.entity().getName(), SearchCriteria.Op.EQ); _searchByDcIDPodIdName.and("name", _searchByDcIDPodIdName.entity().getName(), SearchCriteria.Op.EQ);
_searchByDcIDPodIdName.done(); _searchByDcIDPodIdName.done();
_searchByDcIDPodIdClusterIdName = createSearchBuilder(); _searchByDcIDPodIdClusterIdName = createSearchBuilder();
_searchByDcIDPodIdClusterIdName.and("dcId", _searchByDcIDPodIdClusterIdName.entity().getDataCenterId(), SearchCriteria.Op.EQ); _searchByDcIDPodIdClusterIdName.and("dcId", _searchByDcIDPodIdClusterIdName.entity().getDataCenterId(), SearchCriteria.Op.EQ);
_searchByDcIDPodIdClusterIdName.and("podId", _searchByDcIDPodIdClusterIdName.entity().getPodId(), SearchCriteria.Op.EQ); _searchByDcIDPodIdClusterIdName.and("podId", _searchByDcIDPodIdClusterIdName.entity().getPodId(), SearchCriteria.Op.EQ);
@ -69,7 +69,7 @@ public class MockConfigurationDaoImpl extends GenericDaoBase<MockConfigurationVO
_searchByDcIDPodIdClusterIdName.and("hostId", _searchByDcIDPodIdClusterIdName.entity().getHostId(), SearchCriteria.Op.NULL); _searchByDcIDPodIdClusterIdName.and("hostId", _searchByDcIDPodIdClusterIdName.entity().getHostId(), SearchCriteria.Op.NULL);
_searchByDcIDPodIdClusterIdName.and("name", _searchByDcIDPodIdClusterIdName.entity().getName(), SearchCriteria.Op.EQ); _searchByDcIDPodIdClusterIdName.and("name", _searchByDcIDPodIdClusterIdName.entity().getName(), SearchCriteria.Op.EQ);
_searchByDcIDPodIdClusterIdName.done(); _searchByDcIDPodIdClusterIdName.done();
_searchByDcIDPodIdClusterIdHostIdName = createSearchBuilder(); _searchByDcIDPodIdClusterIdHostIdName = createSearchBuilder();
_searchByDcIDPodIdClusterIdHostIdName.and("dcId", _searchByDcIDPodIdClusterIdHostIdName.entity().getDataCenterId(), SearchCriteria.Op.EQ); _searchByDcIDPodIdClusterIdHostIdName.and("dcId", _searchByDcIDPodIdClusterIdHostIdName.entity().getDataCenterId(), SearchCriteria.Op.EQ);
_searchByDcIDPodIdClusterIdHostIdName.and("podId", _searchByDcIDPodIdClusterIdHostIdName.entity().getPodId(), SearchCriteria.Op.EQ); _searchByDcIDPodIdClusterIdHostIdName.and("podId", _searchByDcIDPodIdClusterIdHostIdName.entity().getPodId(), SearchCriteria.Op.EQ);
@ -80,7 +80,7 @@ public class MockConfigurationDaoImpl extends GenericDaoBase<MockConfigurationVO
} }
@Override @Override
public MockConfigurationVO findByCommand(Long dcId, Long podId, Long clusterId, Long hostId, String name) { public MockConfigurationVO findByCommand(Long dcId, Long podId, Long clusterId, Long hostId, String name) {
if (dcId == null) { if (dcId == null) {
SearchCriteria<MockConfigurationVO> sc = _searchByGlobalName.create(); SearchCriteria<MockConfigurationVO> sc = _searchByGlobalName.create();
sc.setParameters("name", name); sc.setParameters("name", name);
@ -113,19 +113,19 @@ public class MockConfigurationDaoImpl extends GenericDaoBase<MockConfigurationVO
return findOneBy(sc); return findOneBy(sc);
} }
} }
@Override @Override
public MockConfigurationVO findByNameBottomUP(Long dcId, Long podId, Long clusterId, Long hostId, String name) { public MockConfigurationVO findByNameBottomUP(Long dcId, Long podId, Long clusterId, Long hostId, String name) {
Transaction txn = Transaction.currentTxn(); Transaction txn = Transaction.currentTxn();
StringBuilder search = new StringBuilder(); StringBuilder search = new StringBuilder();
Formatter formatter = new Formatter(search); 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("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 = %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 = %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 = %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"); 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; PreparedStatement pstmt = null;
try { try {
String sql = search.toString(); String sql = search.toString();
pstmt = txn.prepareAutoCloseStatement(sql); pstmt = txn.prepareAutoCloseStatement(sql);
@ -134,9 +134,9 @@ public class MockConfigurationDaoImpl extends GenericDaoBase<MockConfigurationVO
return toEntityBean(rs, false); return toEntityBean(rs, false);
} }
} catch (Exception e) { } catch (Exception e) {
} }
return null; return null;
} }
} }

View File

@ -26,7 +26,7 @@ import com.cloud.utils.db.SearchCriteria;
@Local(value={MockHostDao.class}) @Local(value={MockHostDao.class})
public class MockHostDaoImpl extends GenericDaoBase<MockHostVO, Long> implements MockHostDao { public class MockHostDaoImpl extends GenericDaoBase<MockHostVO, Long> implements MockHostDao {
protected final SearchBuilder<MockHostVO> GuidSearch; protected final SearchBuilder<MockHostVO> GuidSearch;
public MockHostDaoImpl() { public MockHostDaoImpl() {
GuidSearch = createSearchBuilder(); GuidSearch = createSearchBuilder();
GuidSearch.and("guid", GuidSearch.entity().getGuid(), SearchCriteria.Op.EQ); GuidSearch.and("guid", GuidSearch.entity().getGuid(), SearchCriteria.Op.EQ);

View File

@ -25,14 +25,14 @@ import com.cloud.utils.db.SearchCriteria;
@Local(value={MockSecStorageDao.class}) @Local(value={MockSecStorageDao.class})
public class MockSecStorageDaoImpl extends GenericDaoBase<MockSecStorageVO, Long> implements MockSecStorageDao { public class MockSecStorageDaoImpl extends GenericDaoBase<MockSecStorageVO, Long> implements MockSecStorageDao {
protected final SearchBuilder<MockSecStorageVO> urlSearch; protected final SearchBuilder<MockSecStorageVO> urlSearch;
@Override @Override
public MockSecStorageVO findByUrl(String url) { public MockSecStorageVO findByUrl(String url) {
SearchCriteria<MockSecStorageVO> sc = urlSearch.create(); SearchCriteria<MockSecStorageVO> sc = urlSearch.create();
sc.setParameters("url", url); sc.setParameters("url", url);
return findOneBy(sc); return findOneBy(sc);
} }
public MockSecStorageDaoImpl() { public MockSecStorageDaoImpl() {
urlSearch = createSearchBuilder(); urlSearch = createSearchBuilder();
urlSearch.and("url", urlSearch.entity().getUrl(), SearchCriteria.Op.EQ); urlSearch.and("url", urlSearch.entity().getUrl(), SearchCriteria.Op.EQ);

View File

@ -29,7 +29,7 @@ import com.cloud.utils.db.SearchCriteria;
@Local(value={MockSecurityRulesDao.class}) @Local(value={MockSecurityRulesDao.class})
public class MockSecurityRulesDaoImpl extends GenericDaoBase<MockSecurityRulesVO, Long> implements MockSecurityRulesDao { public class MockSecurityRulesDaoImpl extends GenericDaoBase<MockSecurityRulesVO, Long> implements MockSecurityRulesDao {
protected SearchBuilder<MockSecurityRulesVO> vmIdSearch; protected SearchBuilder<MockSecurityRulesVO> vmIdSearch;
protected SearchBuilder<MockSecurityRulesVO> hostSearch; protected SearchBuilder<MockSecurityRulesVO> hostSearch;
@Override @Override
public MockSecurityRulesVO findByVmId(Long vmId) { public MockSecurityRulesVO findByVmId(Long vmId) {
SearchCriteria<MockSecurityRulesVO> sc = vmIdSearch.create(); SearchCriteria<MockSecurityRulesVO> sc = vmIdSearch.create();
@ -43,18 +43,18 @@ public class MockSecurityRulesDaoImpl extends GenericDaoBase<MockSecurityRulesVO
sc.setParameters("host", hostGuid); sc.setParameters("host", hostGuid);
return listBy(sc); return listBy(sc);
} }
@Override @Override
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException { public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
vmIdSearch = createSearchBuilder(); vmIdSearch = createSearchBuilder();
vmIdSearch.and("vmId", vmIdSearch.entity().getVmId(), SearchCriteria.Op.EQ); vmIdSearch.and("vmId", vmIdSearch.entity().getVmId(), SearchCriteria.Op.EQ);
vmIdSearch.done(); vmIdSearch.done();
hostSearch = createSearchBuilder(); hostSearch = createSearchBuilder();
hostSearch.and("host", hostSearch.entity().getHostId(), SearchCriteria.Op.EQ); hostSearch.and("host", hostSearch.entity().getHostId(), SearchCriteria.Op.EQ);
hostSearch.done(); hostSearch.done();
return true; return true;
} }
} }

View File

@ -34,12 +34,12 @@ public class MockStoragePoolDaoImpl extends GenericDaoBase<MockStoragePoolVO, Lo
sc.setParameters("uuid", uuid); sc.setParameters("uuid", uuid);
return findOneBy(sc); return findOneBy(sc);
} }
public MockStoragePoolDaoImpl() { public MockStoragePoolDaoImpl() {
uuidSearch = createSearchBuilder(); uuidSearch = createSearchBuilder();
uuidSearch.and("uuid", uuidSearch.entity().getUuid(), SearchCriteria.Op.EQ); uuidSearch.and("uuid", uuidSearch.entity().getUuid(), SearchCriteria.Op.EQ);
uuidSearch.done(); uuidSearch.done();
hostguidSearch = createSearchBuilder(); hostguidSearch = createSearchBuilder();
hostguidSearch.and("hostguid", hostguidSearch.entity().getHostGuid(), SearchCriteria.Op.EQ); hostguidSearch.and("hostguid", hostguidSearch.entity().getHostGuid(), SearchCriteria.Op.EQ);
hostguidSearch.and("type", hostguidSearch.entity().getPoolType(), SearchCriteria.Op.EQ); hostguidSearch.and("type", hostguidSearch.entity().getPoolType(), SearchCriteria.Op.EQ);

View File

@ -34,7 +34,7 @@ import com.cloud.vm.VirtualMachine;
@Local(value={MockVMDao.class}) @Local(value={MockVMDao.class})
public class MockVMDaoImpl extends GenericDaoBase<MockVMVO, Long> implements MockVMDao { public class MockVMDaoImpl extends GenericDaoBase<MockVMVO, Long> implements MockVMDao {
protected SearchBuilder<MockVMVO> GuidSearch; protected SearchBuilder<MockVMVO> GuidSearch;
protected SearchBuilder<MockVMVO> vmNameSearch; protected SearchBuilder<MockVMVO> vmNameSearch;
protected SearchBuilder<MockVMVO> vmhostSearch; protected SearchBuilder<MockVMVO> vmhostSearch;
@Inject MockHostDao _mockHostDao; @Inject MockHostDao _mockHostDao;
@ -57,7 +57,7 @@ public class MockVMDaoImpl extends GenericDaoBase<MockVMVO, Long> implements Moc
sc.setParameters("state", VirtualMachine.State.Running); sc.setParameters("state", VirtualMachine.State.Running);
return listBy(sc); return listBy(sc);
} }
@Override @Override
public MockVMVO findByVmNameAndHost(String vmName, String hostGuid) { public MockVMVO findByVmNameAndHost(String vmName, String hostGuid) {
SearchCriteria<MockVMVO> sc = vmhostSearch.create(); SearchCriteria<MockVMVO> sc = vmhostSearch.create();
@ -65,28 +65,28 @@ public class MockVMDaoImpl extends GenericDaoBase<MockVMVO, Long> implements Moc
sc.setParameters("name", vmName); sc.setParameters("name", vmName);
return findOneBy(sc); return findOneBy(sc);
} }
@Override @Override
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException { public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
SearchBuilder<MockHostVO> host = _mockHostDao.createSearchBuilder(); SearchBuilder<MockHostVO> host = _mockHostDao.createSearchBuilder();
host.and("guid", host.entity().getGuid(), SearchCriteria.Op.EQ); host.and("guid", host.entity().getGuid(), SearchCriteria.Op.EQ);
GuidSearch = createSearchBuilder(); GuidSearch = createSearchBuilder();
GuidSearch.join("host", host, host.entity().getId(), GuidSearch.entity().getHostId(), JoinBuilder.JoinType.INNER); GuidSearch.join("host", host, host.entity().getId(), GuidSearch.entity().getHostId(), JoinBuilder.JoinType.INNER);
GuidSearch.and("state", GuidSearch.entity().getState(), SearchCriteria.Op.EQ); GuidSearch.and("state", GuidSearch.entity().getState(), SearchCriteria.Op.EQ);
GuidSearch.done(); GuidSearch.done();
vmNameSearch = createSearchBuilder(); vmNameSearch = createSearchBuilder();
vmNameSearch.and("name", vmNameSearch.entity().getName(), SearchCriteria.Op.EQ); vmNameSearch.and("name", vmNameSearch.entity().getName(), SearchCriteria.Op.EQ);
vmNameSearch.done(); vmNameSearch.done();
SearchBuilder<MockHostVO> newhost = _mockHostDao.createSearchBuilder(); SearchBuilder<MockHostVO> newhost = _mockHostDao.createSearchBuilder();
newhost.and("guid", newhost.entity().getGuid(), SearchCriteria.Op.EQ); newhost.and("guid", newhost.entity().getGuid(), SearchCriteria.Op.EQ);
vmhostSearch = createSearchBuilder(); vmhostSearch = createSearchBuilder();
vmhostSearch.and("name", vmhostSearch.entity().getName(), SearchCriteria.Op.EQ); vmhostSearch.and("name", vmhostSearch.entity().getName(), SearchCriteria.Op.EQ);
vmhostSearch.join("host", newhost, newhost.entity().getId(), vmhostSearch.entity().getHostId(), JoinBuilder.JoinType.INNER); vmhostSearch.join("host", newhost, newhost.entity().getId(), vmhostSearch.entity().getHostId(), JoinBuilder.JoinType.INNER);
vmhostSearch.done(); vmhostSearch.done();
return true; return true;
} }
} }

View File

@ -42,11 +42,11 @@ public class MockVolumeDaoImpl extends GenericDaoBase<MockVolumeVO, Long> implem
sc.setParameters("type", type); sc.setParameters("type", type);
return listBy(sc); return listBy(sc);
} }
@Override @Override
public Long findTotalStorageId(long id) { public Long findTotalStorageId(long id) {
SearchCriteria<Long> sc = totalSearch.create(); SearchCriteria<Long> sc = totalSearch.create();
sc.setParameters("poolId", id); sc.setParameters("poolId", id);
return customSearch(sc, null).get(0); return customSearch(sc, null).get(0);
} }
@ -57,20 +57,20 @@ public class MockVolumeDaoImpl extends GenericDaoBase<MockVolumeVO, Long> implem
sc.setParameters("path", "%" + path + "%"); sc.setParameters("path", "%" + path + "%");
return findOneBy(sc); return findOneBy(sc);
} }
@Override @Override
public MockVolumeVO findByNameAndPool(String volumeName, String poolUUID) { public MockVolumeVO findByNameAndPool(String volumeName, String poolUUID) {
SearchCriteria<MockVolumeVO> sc = namePoolSearch.create(); SearchCriteria<MockVolumeVO> sc = namePoolSearch.create();
sc.setParameters("name", volumeName); sc.setParameters("name", volumeName);
sc.setParameters("poolUuid", poolUUID); sc.setParameters("poolUuid", poolUUID);
return findOneBy(sc); return findOneBy(sc);
} }
@Override @Override
public MockVolumeVO findByName(String volumeName) { public MockVolumeVO findByName(String volumeName) {
SearchCriteria<MockVolumeVO> sc = nameSearch.create(); SearchCriteria<MockVolumeVO> sc = nameSearch.create();
sc.setParameters("name", volumeName); sc.setParameters("name", volumeName);
return findOneBy(sc); return findOneBy(sc);
} }
public MockVolumeDaoImpl() { public MockVolumeDaoImpl() {
@ -78,24 +78,24 @@ public class MockVolumeDaoImpl extends GenericDaoBase<MockVolumeVO, Long> implem
idTypeSearch.and("storageId", idTypeSearch.entity().getPoolId(), SearchCriteria.Op.EQ); idTypeSearch.and("storageId", idTypeSearch.entity().getPoolId(), SearchCriteria.Op.EQ);
idTypeSearch.and("type", idTypeSearch.entity().getType(), SearchCriteria.Op.EQ); idTypeSearch.and("type", idTypeSearch.entity().getType(), SearchCriteria.Op.EQ);
idTypeSearch.done(); idTypeSearch.done();
pathTypeSearch = createSearchBuilder(); pathTypeSearch = createSearchBuilder();
pathTypeSearch.and("path", pathTypeSearch.entity().getPath(), SearchCriteria.Op.LIKE); pathTypeSearch.and("path", pathTypeSearch.entity().getPath(), SearchCriteria.Op.LIKE);
pathTypeSearch.done(); pathTypeSearch.done();
namePoolSearch = createSearchBuilder(); namePoolSearch = createSearchBuilder();
namePoolSearch.and("name", namePoolSearch.entity().getName(), SearchCriteria.Op.EQ); namePoolSearch.and("name", namePoolSearch.entity().getName(), SearchCriteria.Op.EQ);
namePoolSearch.and("poolUuid", namePoolSearch.entity().getPoolId(), SearchCriteria.Op.EQ); namePoolSearch.and("poolUuid", namePoolSearch.entity().getPoolId(), SearchCriteria.Op.EQ);
namePoolSearch.done(); namePoolSearch.done();
nameSearch = createSearchBuilder(); nameSearch = createSearchBuilder();
nameSearch.and("name", nameSearch.entity().getName(), SearchCriteria.Op.EQ); nameSearch.and("name", nameSearch.entity().getName(), SearchCriteria.Op.EQ);
nameSearch.done(); nameSearch.done();
totalSearch = createSearchBuilder(Long.class); totalSearch = createSearchBuilder(Long.class);
totalSearch.select(null, Func.SUM, totalSearch.entity().getSize()); totalSearch.select(null, Func.SUM, totalSearch.entity().getSize());
totalSearch.and("poolId", totalSearch.entity().getPoolId(), SearchCriteria.Op.EQ); totalSearch.and("poolId", totalSearch.entity().getPoolId(), SearchCriteria.Op.EQ);
totalSearch.done(); totalSearch.done();
} }
} }

View File

@ -38,6 +38,7 @@
<module>hypervisors/ovm</module> <module>hypervisors/ovm</module>
<module>hypervisors/xen</module> <module>hypervisors/xen</module>
<module>hypervisors/kvm</module> <module>hypervisors/kvm</module>
<module>hypervisors/simulator</module>
<module>network-elements/elastic-loadbalancer</module> <module>network-elements/elastic-loadbalancer</module>
<module>network-elements/ovs</module> <module>network-elements/ovs</module>
<module>network-elements/nicira-nvp</module> <module>network-elements/nicira-nvp</module>
@ -124,6 +125,17 @@
<module>hypervisors/vmware</module> <module>hypervisors/vmware</module>
</modules> </modules>
</profile> </profile>
<profile>
<id>kvm</id>
<activation>
<property>
<name>nonoss</name>
</property>
</activation>
<modules>
<module>hypervisors/simulator</module>
</modules>
</profile>
</profiles> </profiles>
</project> </project>