mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
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:
parent
0b60dda1e6
commit
d6083ce51d
45
plugins/hypervisors/simulator/pom.xml
Normal file
45
plugins/hypervisors/simulator/pom.xml
Normal 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>
|
||||
@ -30,43 +30,43 @@ import com.cloud.utils.concurrency.NamedThreadFactory;
|
||||
|
||||
public class MetricsCollector {
|
||||
private static final Logger s_logger = Logger.getLogger(MetricsCollector.class);
|
||||
|
||||
|
||||
private final Set<String> vmNames = new HashSet<String>();
|
||||
private final Set<String> newVMnames = new HashSet<String>();
|
||||
private final Map<String, MockVmMetrics> metricsMap = new HashMap<String, MockVmMetrics>();
|
||||
|
||||
|
||||
private final transient ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(1, new NamedThreadFactory("Metrics"));
|
||||
|
||||
private Set<String> _currentVms;
|
||||
|
||||
|
||||
public MetricsCollector(Set<String> currentVms) {
|
||||
_currentVms = currentVms;
|
||||
getAllVMNames();
|
||||
}
|
||||
|
||||
|
||||
public MetricsCollector() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public synchronized void getAllVMNames() {
|
||||
Set<String> currentVMs = _currentVms;
|
||||
|
||||
|
||||
newVMnames.clear();
|
||||
newVMnames.addAll(currentVMs);
|
||||
newVMnames.removeAll(vmNames); //leave only new vms
|
||||
|
||||
|
||||
vmNames.removeAll(currentVMs); //old vms - current vms --> leave non-running vms;
|
||||
for (String vm: vmNames) {
|
||||
removeVM(vm);
|
||||
removeVM(vm);
|
||||
}
|
||||
|
||||
|
||||
vmNames.clear();
|
||||
vmNames.addAll(currentVMs);
|
||||
}
|
||||
|
||||
|
||||
public synchronized void submitMetricsJobs() {
|
||||
s_logger.debug("Submit Metric Jobs called");
|
||||
|
||||
|
||||
for (String vm : newVMnames) {
|
||||
MockVmMetrics task = new MockVmMetrics(vm);
|
||||
if (!metricsMap.containsKey(vm)) {
|
||||
@ -77,30 +77,30 @@ public class MetricsCollector {
|
||||
}
|
||||
newVMnames.clear();
|
||||
}
|
||||
|
||||
|
||||
public synchronized void addVM(String vmName) {
|
||||
newVMnames.add(vmName);
|
||||
s_logger.debug("Added vm name= " + vmName);
|
||||
}
|
||||
|
||||
|
||||
public synchronized void removeVM(String vmName) {
|
||||
newVMnames.remove(vmName);
|
||||
vmNames.remove(vmName);
|
||||
MockVmMetrics task = metricsMap.get(vmName);
|
||||
if (task != null) {
|
||||
task.stop();
|
||||
boolean r1= task.getFuture().cancel(false);
|
||||
metricsMap.remove(vmName);
|
||||
s_logger.debug("removeVM: cancel returned " + r1 + " for VM " + vmName);
|
||||
} else {
|
||||
s_logger.warn("removeVM called for nonexistent VM " + vmName);
|
||||
}
|
||||
if (task != null) {
|
||||
task.stop();
|
||||
boolean r1= task.getFuture().cancel(false);
|
||||
metricsMap.remove(vmName);
|
||||
s_logger.debug("removeVM: cancel returned " + r1 + " for VM " + vmName);
|
||||
} else {
|
||||
s_logger.warn("removeVM called for nonexistent VM " + vmName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public synchronized Set<String> getVMNames() {
|
||||
return vmNames;
|
||||
}
|
||||
|
||||
|
||||
public synchronized Map<String, MockVmMetrics> getMetricsMap() {
|
||||
return metricsMap;
|
||||
}
|
||||
@ -25,52 +25,52 @@ import org.apache.log4j.Logger;
|
||||
|
||||
public class MockVmMetrics implements Runnable {
|
||||
private static final Logger s_logger = Logger.getLogger(MockVmMetrics.class);
|
||||
|
||||
|
||||
private String vmName;
|
||||
|
||||
|
||||
public final int MAX_INTERFACES=1;
|
||||
|
||||
|
||||
public final int MAX_DISKS=8;
|
||||
|
||||
|
||||
//the last calculated traffic speed (transmit) per interface
|
||||
private Map<String, Double> netTxKBps = new HashMap<String, Double>();
|
||||
|
||||
|
||||
//the last calculated traffic speed (receive) per interface
|
||||
private Map<String, Double> netRxKBps = new HashMap<String, Double>();
|
||||
|
||||
|
||||
//the last calculated disk write speed per disk (Bytes Per Second)
|
||||
private Map<String, Double> diskWriteKBytesPerSec = new HashMap<String, Double>();
|
||||
|
||||
|
||||
//the last calculated disk read speed per disk (Bytes Per Second)
|
||||
private Map<String, Double> diskReadKBytesPerSec = new HashMap<String, Double>();
|
||||
|
||||
|
||||
//Total Bytes Transmitted on network interfaces
|
||||
private Map<String, Long> netTxTotalBytes = new HashMap<String, Long>();
|
||||
|
||||
|
||||
//Total Bytes Received on network interfaces
|
||||
private Map<String, Long> netRxTotalBytes = new HashMap<String, Long>();
|
||||
|
||||
|
||||
//Total Bytes read per disk
|
||||
private Map<String, Long> diskReadTotalBytes = new HashMap<String, Long>();
|
||||
|
||||
//Total Bytes written per disk
|
||||
private Map<String, Long> diskWriteTotalBytes = new HashMap<String, Long>();
|
||||
|
||||
|
||||
//CPU time in seconds
|
||||
private Double cpuSeconds = new Double(0.0);
|
||||
|
||||
|
||||
//CPU percentage
|
||||
private Float cpuPercent = new Float(0.0);
|
||||
|
||||
|
||||
private Map<String, String> diskMap = new HashMap<String, String>();
|
||||
|
||||
private Map<String, String> vifMap = new HashMap<String, String>();
|
||||
|
||||
|
||||
private Map<String, Long> diskStatTimestamp = new HashMap<String, Long>();
|
||||
private Map<String, Long> netStatTimestamp = new HashMap<String, Long>();
|
||||
|
||||
|
||||
private long cpuStatTimestamp = 0L;
|
||||
|
||||
|
||||
private ScheduledFuture<?> future;
|
||||
private boolean stopped = false;
|
||||
private Random randSeed = new Random();
|
||||
@ -80,44 +80,44 @@ public class MockVmMetrics implements Runnable {
|
||||
vifMap.put("eth0", "eth0");
|
||||
vifMap.put("eth1", "eth1");
|
||||
vifMap.put("eth2", "eth2");
|
||||
|
||||
|
||||
Long networkStart = 0L;
|
||||
netTxTotalBytes.put("eth0", networkStart);
|
||||
netRxTotalBytes.put("eth0", networkStart);
|
||||
|
||||
|
||||
netTxTotalBytes.put("eth1", networkStart);
|
||||
netRxTotalBytes.put("eth1", networkStart);
|
||||
|
||||
|
||||
netTxTotalBytes.put("eth2", networkStart);
|
||||
netRxTotalBytes.put("eth2", networkStart);
|
||||
netRxTotalBytes.put("eth2", networkStart);
|
||||
}
|
||||
|
||||
|
||||
private int getIncrementor() {
|
||||
return randSeed.nextInt(100);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if(s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Generating MockVM metrics");
|
||||
}
|
||||
for (Map.Entry<String, Long> entry : netRxTotalBytes.entrySet()) {
|
||||
entry.setValue(entry.getValue() + getIncrementor());
|
||||
entry.setValue(entry.getValue() + getIncrementor());
|
||||
}
|
||||
|
||||
|
||||
for (Map.Entry<String, Long> entry : netTxTotalBytes.entrySet()) {
|
||||
entry.setValue(entry.getValue() + getIncrementor());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String getVmName() {
|
||||
return vmName;
|
||||
}
|
||||
|
||||
|
||||
public Map<String, Double> getNetTxKBps() {
|
||||
return netTxKBps;
|
||||
}
|
||||
|
||||
|
||||
public Map<String, Double> getNetRxKBps() {
|
||||
return netRxKBps;
|
||||
}
|
||||
@ -125,11 +125,11 @@ public class MockVmMetrics implements Runnable {
|
||||
public Map<String, Double> getDiskWriteBytesPerSec() {
|
||||
return diskWriteKBytesPerSec;
|
||||
}
|
||||
|
||||
|
||||
public Map<String, Double> getDiskReadBytesPerSec() {
|
||||
return diskReadKBytesPerSec;
|
||||
}
|
||||
|
||||
|
||||
public Map<String, Long> getNetTxTotalBytes() {
|
||||
return netTxTotalBytes;
|
||||
}
|
||||
@ -137,7 +137,7 @@ public class MockVmMetrics implements Runnable {
|
||||
public Map<String, Long> getNetRxTotalBytes() {
|
||||
return netRxTotalBytes;
|
||||
}
|
||||
|
||||
|
||||
public Map<String, Long> getDiskReadTotalBytes() {
|
||||
return diskReadTotalBytes;
|
||||
}
|
||||
@ -145,7 +145,7 @@ public class MockVmMetrics implements Runnable {
|
||||
public Map<String, Long> getDiskWriteTotalBytes() {
|
||||
return diskWriteTotalBytes;
|
||||
}
|
||||
|
||||
|
||||
public Double getNetTxKBps(String intf) {
|
||||
return netTxKBps.get(intf);
|
||||
}
|
||||
@ -153,7 +153,7 @@ public class MockVmMetrics implements Runnable {
|
||||
public Double getNetRxKBps(String intf) {
|
||||
return netRxKBps.get(intf);
|
||||
}
|
||||
|
||||
|
||||
public Double getDiskWriteKBytesPerSec(String disk) {
|
||||
return diskWriteKBytesPerSec.get(disk);
|
||||
}
|
||||
@ -161,7 +161,7 @@ public class MockVmMetrics implements Runnable {
|
||||
public Double getDiskReadKBytesPerSec(String disk) {
|
||||
return diskReadKBytesPerSec.get(disk);
|
||||
}
|
||||
|
||||
|
||||
public Long getNetTxTotalBytes(String intf) {
|
||||
return netTxTotalBytes.get(intf);
|
||||
}
|
||||
@ -169,7 +169,7 @@ public class MockVmMetrics implements Runnable {
|
||||
public Long getNetRxTotalBytes(String intf) {
|
||||
return netRxTotalBytes.get(intf);
|
||||
}
|
||||
|
||||
|
||||
public Long getDiskReadTotalBytes(String disk) {
|
||||
return diskReadTotalBytes.get(disk);
|
||||
}
|
||||
@ -177,7 +177,7 @@ public class MockVmMetrics implements Runnable {
|
||||
public Long getDiskWriteTotalBytes(String disk) {
|
||||
return diskWriteTotalBytes.get(disk);
|
||||
}
|
||||
|
||||
|
||||
public Double getCpuSeconds() {
|
||||
return cpuSeconds;
|
||||
}
|
||||
@ -189,7 +189,7 @@ public class MockVmMetrics implements Runnable {
|
||||
public Float getCpuPercent() {
|
||||
return cpuPercent;
|
||||
}
|
||||
|
||||
|
||||
public void setFuture(ScheduledFuture<?> sf) {
|
||||
this.future = sf;
|
||||
}
|
||||
@ -197,9 +197,8 @@ public class MockVmMetrics implements Runnable {
|
||||
public ScheduledFuture<?> getFuture() {
|
||||
return future;
|
||||
}
|
||||
|
||||
|
||||
public void stop() {
|
||||
this.stopped = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,49 +30,49 @@ import org.apache.log4j.Logger;
|
||||
|
||||
public class MultiCaster implements Runnable {
|
||||
private static final Logger s_logger = Logger.getLogger(MultiCaster.class);
|
||||
|
||||
|
||||
public final int MAX_PACKET_SIZE = 8096;
|
||||
|
||||
|
||||
private List<MultiCasterListener> listeners;
|
||||
private DatagramSocket socket;
|
||||
private byte[] recvBuffer;
|
||||
|
||||
|
||||
private Thread driver;
|
||||
private volatile boolean stopRequested = false;
|
||||
|
||||
|
||||
public MultiCaster() {
|
||||
listeners = new ArrayList<MultiCasterListener>();
|
||||
recvBuffer = new byte[MAX_PACKET_SIZE];
|
||||
}
|
||||
|
||||
|
||||
public void addListener(MultiCasterListener listener) {
|
||||
synchronized(listeners) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void removeListener(MultiCasterListener listener) {
|
||||
synchronized(listeners) {
|
||||
listeners.remove(listener);
|
||||
}
|
||||
}
|
||||
|
||||
public void cast(byte[] buf, int off, int len,
|
||||
|
||||
public void cast(byte[] buf, int off, int len,
|
||||
InetAddress toAddress, int nToPort) throws IOException {
|
||||
|
||||
|
||||
if(socket == null)
|
||||
throw new IOException("multi caster is not started");
|
||||
|
||||
|
||||
if(len >= MAX_PACKET_SIZE)
|
||||
throw new IOException("packet size exceeds limit of " + MAX_PACKET_SIZE);
|
||||
|
||||
DatagramPacket packet = new DatagramPacket(buf, off,
|
||||
|
||||
DatagramPacket packet = new DatagramPacket(buf, off,
|
||||
len, toAddress, nToPort);
|
||||
|
||||
socket.send(packet);
|
||||
}
|
||||
|
||||
public void start(String strOutboundAddress,
|
||||
|
||||
public void start(String strOutboundAddress,
|
||||
String strClusterAddress, int nPort) throws SocketException {
|
||||
assert(socket == null);
|
||||
|
||||
@ -82,22 +82,22 @@ public class MultiCaster implements Runnable {
|
||||
} catch(IOException e) {
|
||||
s_logger.error("Unexpected exception " , e);
|
||||
}
|
||||
|
||||
|
||||
if(addr != null && addr.isMulticastAddress()) {
|
||||
try {
|
||||
socket = new MulticastSocket(nPort);
|
||||
socket.setReuseAddress(true);
|
||||
|
||||
|
||||
if(s_logger.isInfoEnabled())
|
||||
s_logger.info("Join multicast group : " + addr);
|
||||
|
||||
|
||||
((MulticastSocket)socket).joinGroup(addr);
|
||||
((MulticastSocket)socket).setTimeToLive(1);
|
||||
|
||||
|
||||
if(strOutboundAddress != null) {
|
||||
if(s_logger.isInfoEnabled())
|
||||
s_logger.info("set outgoing interface to : " + strOutboundAddress);
|
||||
|
||||
|
||||
InetAddress ia = InetAddress.getByName(strOutboundAddress);
|
||||
NetworkInterface ni = NetworkInterface.getByInetAddress(ia);
|
||||
((MulticastSocket)socket).setNetworkInterface(ni);
|
||||
@ -109,16 +109,16 @@ public class MultiCaster implements Runnable {
|
||||
socket = new DatagramSocket(nPort);
|
||||
socket.setReuseAddress(true);
|
||||
}
|
||||
|
||||
|
||||
driver = new Thread(this, "Multi-caster");
|
||||
driver.setDaemon(true);
|
||||
driver.start();
|
||||
}
|
||||
|
||||
|
||||
public void stop() {
|
||||
if(socket != null) {
|
||||
stopRequested = true;
|
||||
|
||||
|
||||
socket.close();
|
||||
if(driver != null) {
|
||||
try {
|
||||
@ -128,17 +128,17 @@ public class MultiCaster implements Runnable {
|
||||
driver = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
socket = null;
|
||||
stopRequested = false;
|
||||
}
|
||||
|
||||
|
||||
public void run() {
|
||||
while(!stopRequested) {
|
||||
try {
|
||||
DatagramPacket packet = new DatagramPacket(recvBuffer, recvBuffer.length);
|
||||
socket.receive(packet);
|
||||
|
||||
|
||||
for(Object listener : listeners.toArray()) {
|
||||
((MultiCasterListener)listener).onMultiCasting(packet.getData(),
|
||||
packet.getOffset(), packet.getLength(), packet.getAddress());
|
||||
@ -20,17 +20,17 @@ import java.io.Serializable;
|
||||
|
||||
public class SimulatorCmd implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
private String testCase = "DEFAULT";
|
||||
|
||||
|
||||
public SimulatorCmd(String testCase) {
|
||||
this.testCase = testCase;
|
||||
this.testCase = testCase;
|
||||
}
|
||||
|
||||
|
||||
public String getTestCase() {
|
||||
return testCase;
|
||||
}
|
||||
|
||||
|
||||
public void setTestCase(String testCase) {
|
||||
this.testCase = testCase;
|
||||
}
|
||||
@ -21,12 +21,12 @@ public class SimulatorMigrateVmCmd extends SimulatorCmd {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String destIp;
|
||||
|
||||
|
||||
private String vmName;
|
||||
private long ramSize;
|
||||
private int cpuCount;
|
||||
private int utilization;
|
||||
|
||||
|
||||
public SimulatorMigrateVmCmd(String testCase) {
|
||||
super(testCase);
|
||||
}
|
||||
@ -38,7 +38,7 @@ public class SimulatorMigrateVmCmd extends SimulatorCmd {
|
||||
public void setDestIp(String destIp) {
|
||||
this.destIp = destIp;
|
||||
}
|
||||
|
||||
|
||||
public String getVmName() {
|
||||
return vmName;
|
||||
}
|
||||
@ -70,14 +70,14 @@ public class SimulatorMigrateVmCmd extends SimulatorCmd {
|
||||
public void setUtilization(int utilization) {
|
||||
this.utilization = utilization;
|
||||
}
|
||||
|
||||
|
||||
public String toString() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("SimulatorMigrateVmCmd {").append("vm: ").append(getVmName());
|
||||
sb.append(", destIp: ").append(getDestIp()).append(", ramSize: ").append(getRamSize());
|
||||
sb.append(", cpuCount: ").append(getCpuCount()).append(", utilization: ").append(getUtilization());
|
||||
sb.append("}");
|
||||
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
@ -51,17 +51,17 @@ import com.cloud.utils.component.Manager;
|
||||
public interface MockStorageManager extends Manager {
|
||||
public static final long DEFAULT_HOST_STORAGE_SIZE = 1 * 1024 * 1024 * 1024 * 1024L; //1T
|
||||
public static final long DEFAULT_TEMPLATE_SIZE = 1 * 1000 * 1000 * 1000L; //1G
|
||||
|
||||
|
||||
public PrimaryStorageDownloadAnswer primaryStorageDownload(PrimaryStorageDownloadCommand cmd);
|
||||
|
||||
|
||||
public CreateAnswer createVolume(CreateCommand cmd);
|
||||
public AttachVolumeAnswer AttachVolume(AttachVolumeCommand cmd);
|
||||
public Answer AttachIso(AttachIsoCommand cmd);
|
||||
|
||||
|
||||
public Answer DeleteStoragePool(DeleteStoragePoolCommand cmd);
|
||||
public Answer ModifyStoragePool(ModifyStoragePoolCommand cmd);
|
||||
public Answer CreateStoragePool(CreateStoragePoolCommand cmd);
|
||||
|
||||
|
||||
public Answer SecStorageSetup(SecStorageSetupCommand cmd);
|
||||
public Answer ListTemplates(ListTemplateCommand cmd);
|
||||
public Answer Destroy(DestroyCommand cmd);
|
||||
@ -74,7 +74,7 @@ public interface MockStorageManager extends Manager {
|
||||
public Answer CreateVolumeFromSnapshot(CreateVolumeFromSnapshotCommand cmd);
|
||||
public Answer DeleteTemplate(DeleteTemplateCommand cmd);
|
||||
public Answer SecStorageVMSetup(SecStorageVMSetupCommand cmd);
|
||||
|
||||
|
||||
public void preinstallTemplates(String url, long zoneId);
|
||||
|
||||
StoragePoolInfo getLocalStorage(String hostGuid);
|
||||
@ -703,7 +703,7 @@ public class MockStorageManagerImpl implements MockStorageManager {
|
||||
txn = Transaction.open(Transaction.CLOUD_DB);
|
||||
txn.close();
|
||||
}
|
||||
|
||||
|
||||
MockVolumeVO newsnapshot = new MockVolumeVO();
|
||||
String name = UUID.randomUUID().toString();
|
||||
newsnapshot.setName(name);
|
||||
@ -953,7 +953,7 @@ public class MockStorageManagerImpl implements MockStorageManager {
|
||||
@Override
|
||||
public StoragePoolInfo getLocalStorage(String hostGuid) {
|
||||
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
|
||||
MockHost host = null;
|
||||
MockHost host = null;
|
||||
MockStoragePoolVO storagePool = null;
|
||||
try {
|
||||
txn.start();
|
||||
@ -968,7 +968,7 @@ public class MockStorageManagerImpl implements MockStorageManager {
|
||||
txn = Transaction.open(Transaction.CLOUD_DB);
|
||||
txn.close();
|
||||
}
|
||||
|
||||
|
||||
if (storagePool == null) {
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
storagePool = new MockStoragePoolVO();
|
||||
@ -998,7 +998,7 @@ public class MockStorageManagerImpl implements MockStorageManager {
|
||||
@Override
|
||||
public StoragePoolInfo getLocalStorage(String hostGuid, Long storageSize) {
|
||||
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
|
||||
MockHost host = null;
|
||||
MockHost host = null;
|
||||
try {
|
||||
txn.start();
|
||||
host = _mockHostDao.findByGuid(hostGuid);
|
||||
@ -40,7 +40,7 @@ import com.cloud.vm.VirtualMachine.State;
|
||||
public interface MockVmManager extends Manager {
|
||||
public Answer stopVM(StopCommand cmd);
|
||||
public Answer rebootVM(RebootCommand cmd);
|
||||
|
||||
|
||||
public Answer checkVmState(CheckVirtualMachineCommand cmd);
|
||||
public Map<String, State> getVmStates(String hostGuid);
|
||||
public Answer getVncPort(GetVncPortCommand cmd);
|
||||
@ -49,27 +49,27 @@ public interface MockVmManager extends Manager {
|
||||
|
||||
Answer getVmStats(GetVmStatsCommand cmd);
|
||||
public CheckSshAnswer checkSshCommand(CheckSshCommand cmd);
|
||||
|
||||
|
||||
Answer SetStaticNatRules(SetStaticNatRulesCommand cmd);
|
||||
|
||||
|
||||
Answer SetPortForwardingRules(SetPortForwardingRulesCommand cmd);
|
||||
|
||||
Answer SetFirewallRules(SetFirewallRulesCommand cmd);
|
||||
|
||||
|
||||
Answer getNetworkUsage(NetworkUsageCommand cmd);
|
||||
|
||||
|
||||
Answer IpAssoc(IpAssocCommand cmd);
|
||||
|
||||
Answer LoadBalancerConfig(LoadBalancerConfigCommand cmd);
|
||||
|
||||
|
||||
Answer AddDhcpEntry(DhcpEntryCommand cmd);
|
||||
|
||||
|
||||
Answer setVmData(VmDataCommand cmd);
|
||||
Answer CleanupNetworkRules(CleanupNetworkRulesCmd cmd, SimulatorInfo info);
|
||||
|
||||
|
||||
Answer CheckConsoleProxyLoad(CheckConsoleProxyLoadCommand cmd);
|
||||
Answer WatchConsoleProxyLoad(WatchConsoleProxyLoadCommand cmd);
|
||||
|
||||
|
||||
Answer SavePassword(SavePasswordCommand cmd);
|
||||
HashMap<String, Pair<Long, Long>> syncNetworkGroups(SimulatorInfo info);
|
||||
SecurityGroupRuleAnswer AddSecurityGroupRules(SecurityGroupRulesCmd cmd, SimulatorInfo info);
|
||||
@ -60,20 +60,20 @@ public class MockVmManagerImpl implements MockVmManager {
|
||||
@Inject MockHostDao _mockHostDao = null;
|
||||
@Inject MockSecurityRulesDao _mockSecurityDao = null;
|
||||
private Map<String, Map<String, Ternary<String, Long, Long>>> _securityRules = new ConcurrentHashMap<String, Map<String, Ternary<String, Long, Long>>>();
|
||||
|
||||
|
||||
public MockVmManagerImpl() {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params)
|
||||
throws ConfigurationException {
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public String startVM(String vmName, NicTO[] nics,
|
||||
int cpuHz, long ramSize,
|
||||
String bootArgs, String hostGuid) {
|
||||
int cpuHz, long ramSize,
|
||||
String bootArgs, String hostGuid) {
|
||||
|
||||
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
|
||||
MockHost host = null;
|
||||
@ -95,7 +95,7 @@ public class MockVmManagerImpl implements MockVmManager {
|
||||
txn = Transaction.open(Transaction.CLOUD_DB);
|
||||
txn.close();
|
||||
}
|
||||
|
||||
|
||||
if(vm == null) {
|
||||
int vncPort = 0;
|
||||
if(vncPort < 0)
|
||||
@ -108,13 +108,13 @@ public class MockVmManagerImpl implements MockVmManager {
|
||||
vm.setVncPort(vncPort);
|
||||
vm.setHostId(host.getId());
|
||||
if(vmName.startsWith("s-")) {
|
||||
vm.setType("SecondaryStorageVm");
|
||||
vm.setType("SecondaryStorageVm");
|
||||
} else if (vmName.startsWith("v-")) {
|
||||
vm.setType("ConsoleProxy");
|
||||
vm.setType("ConsoleProxy");
|
||||
} else if (vmName.startsWith("r-")) {
|
||||
vm.setType("DomainRouter");
|
||||
vm.setType("DomainRouter");
|
||||
} else if (vmName.startsWith("i-")) {
|
||||
vm.setType("User");
|
||||
vm.setType("User");
|
||||
}
|
||||
txn = Transaction.open(Transaction.SIMULATOR_DB);
|
||||
try {
|
||||
@ -133,18 +133,18 @@ public class MockVmManagerImpl implements MockVmManager {
|
||||
if(vm.getState() == State.Stopped) {
|
||||
vm.setState(State.Running);
|
||||
txn = Transaction.open(Transaction.SIMULATOR_DB);
|
||||
try {
|
||||
txn.start();
|
||||
_mockVmDao.update(vm.getId(), (MockVMVO)vm);
|
||||
txn.commit();
|
||||
} catch (Exception ex) {
|
||||
txn.rollback();
|
||||
throw new CloudRuntimeException("unable to update vm " + vm.getName(), ex);
|
||||
} finally {
|
||||
txn.close();
|
||||
try {
|
||||
txn.start();
|
||||
_mockVmDao.update(vm.getId(), (MockVMVO)vm);
|
||||
txn.commit();
|
||||
} catch (Exception ex) {
|
||||
txn.rollback();
|
||||
throw new CloudRuntimeException("unable to update vm " + vm.getName(), ex);
|
||||
} finally {
|
||||
txn.close();
|
||||
txn = Transaction.open(Transaction.CLOUD_DB);
|
||||
txn.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -212,7 +212,7 @@ public class MockVmManagerImpl implements MockVmManager {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, MockVMVO> getVms(String hostGuid) {
|
||||
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
|
||||
@ -303,8 +303,8 @@ public class MockVmManagerImpl implements MockVmManager {
|
||||
@Override
|
||||
public String getName() {
|
||||
return this.getClass().getSimpleName();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Answer getVmStats(GetVmStatsCommand cmd) {
|
||||
HashMap<String, VmStatsEntry> vmStatsNameMap = new HashMap<String, VmStatsEntry>();
|
||||
@ -370,9 +370,9 @@ public class MockVmManagerImpl implements MockVmManager {
|
||||
|
||||
@Override
|
||||
public Answer SetFirewallRules(SetFirewallRulesCommand cmd) {
|
||||
return new Answer(cmd);
|
||||
return new Answer(cmd);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public NetworkUsageAnswer getNetworkUsage(NetworkUsageCommand cmd) {
|
||||
@ -516,20 +516,20 @@ public class MockVmManagerImpl implements MockVmManager {
|
||||
public Answer WatchConsoleProxyLoad(WatchConsoleProxyLoadCommand cmd) {
|
||||
return Answer.createUnsupportedCommandAnswer(cmd);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public GetDomRVersionAnswer getDomRVersion(GetDomRVersionCmd cmd) {
|
||||
return new GetDomRVersionAnswer(cmd, null, null, null);
|
||||
return new GetDomRVersionAnswer(cmd, null, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SecurityGroupRuleAnswer AddSecurityGroupRules(SecurityGroupRulesCmd cmd, SimulatorInfo info) {
|
||||
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());
|
||||
|
||||
|
||||
if (rules == null) {
|
||||
logSecurityGroupAction(cmd, null);
|
||||
rules = new ConcurrentHashMap<String, Ternary<String, Long, Long>>();
|
||||
@ -539,10 +539,10 @@ public class MockVmManagerImpl implements MockVmManager {
|
||||
logSecurityGroupAction(cmd, rules.get(cmd.getVmName()));
|
||||
rules.put(cmd.getVmName(), new Ternary<String, Long,Long>(cmd.getSignature(), cmd.getVmId(), cmd.getSeqNum()));
|
||||
}
|
||||
|
||||
|
||||
return new SecurityGroupRuleAnswer(cmd);
|
||||
}
|
||||
|
||||
|
||||
private boolean logSecurityGroupAction(SecurityGroupRulesCmd cmd, Ternary<String,Long, Long> rule) {
|
||||
String action = ", do nothing";
|
||||
String reason = ", reason=";
|
||||
@ -554,13 +554,13 @@ public class MockVmManagerImpl implements MockVmManager {
|
||||
s_logger.info("New seqno received: " + cmd.getSeqNum() + " curr=" + currSeqnum);
|
||||
updateSeqnoAndSig = true;
|
||||
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");
|
||||
action = ", updated iptables";
|
||||
reason = reason + "seqno_increased_sig_changed";
|
||||
} else {
|
||||
s_logger.info("New seqno received: " + cmd.getSeqNum() + " curr=" + currSeqnum
|
||||
+ " no change in signature:" + cmd.getSignature() + ", do nothing");
|
||||
s_logger.info("New seqno received: " + cmd.getSeqNum() + " curr=" + currSeqnum
|
||||
+ " no change in signature:" + cmd.getSignature() + ", do nothing");
|
||||
reason = reason + "seqno_increased_sig_same";
|
||||
}
|
||||
} else if (cmd.getSeqNum() < currSeqnum) {
|
||||
@ -568,14 +568,14 @@ public class MockVmManagerImpl implements MockVmManager {
|
||||
reason = reason + "seqno_decreased";
|
||||
} else {
|
||||
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");
|
||||
action = ", updated iptables";
|
||||
reason = reason + "seqno_same_sig_changed";
|
||||
updateSeqnoAndSig = true;
|
||||
} else {
|
||||
s_logger.info("Identical seqno received: " + cmd.getSeqNum() + " curr=" + currSeqnum
|
||||
+ " no change in signature:" + cmd.getSignature() + ", do nothing");
|
||||
s_logger.info("Identical seqno received: " + cmd.getSeqNum() + " curr=" + currSeqnum
|
||||
+ " no change in signature:" + cmd.getSignature() + ", do nothing");
|
||||
reason = reason + "seqno_same_sig_same";
|
||||
}
|
||||
}
|
||||
@ -585,8 +585,8 @@ public class MockVmManagerImpl implements MockVmManager {
|
||||
action = ", updated iptables";
|
||||
reason = ", seqno_new";
|
||||
}
|
||||
s_logger.info("Programmed network rules for vm " + cmd.getVmName() + " seqno=" + cmd.getSeqNum()
|
||||
+ " signature=" + cmd.getSignature()
|
||||
s_logger.info("Programmed network rules for vm " + cmd.getVmName() + " seqno=" + cmd.getSeqNum()
|
||||
+ " signature=" + cmd.getSignature()
|
||||
+ " guestIp=" + cmd.getGuestIp() + ", numIngressRules="
|
||||
+ cmd.getIngressRuleSet().length + ", numEgressRules="
|
||||
+ cmd.getEgressRuleSet().length + " total cidrs=" + cmd.getTotalNumCidrs() + action + reason);
|
||||
@ -595,13 +595,13 @@ public class MockVmManagerImpl implements MockVmManager {
|
||||
|
||||
@Override
|
||||
public Answer SavePassword(SavePasswordCommand cmd) {
|
||||
return new Answer(cmd);
|
||||
return new Answer(cmd);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public HashMap<String, Pair<Long, Long>> syncNetworkGroups(SimulatorInfo info) {
|
||||
HashMap<String, Pair<Long, Long>> maps = new HashMap<String, Pair<Long, Long>>();
|
||||
|
||||
|
||||
Map<String, Ternary<String, Long, Long>> rules = _securityRules.get(info.getHostUuid());
|
||||
if (rules == null) {
|
||||
return maps;
|
||||
@ -20,39 +20,39 @@ public class SimulatorInfo {
|
||||
private boolean enabled;
|
||||
private int timeout;
|
||||
private String hostUuid;
|
||||
|
||||
|
||||
public SimulatorInfo(boolean enabled, int timeout, String hostUuid) {
|
||||
this.enabled = enabled;
|
||||
this.timeout = timeout;
|
||||
this.hostUuid = hostUuid;
|
||||
}
|
||||
|
||||
|
||||
public SimulatorInfo() {
|
||||
this.enabled = true;
|
||||
this.timeout = -1;
|
||||
this.hostUuid = null;
|
||||
}
|
||||
|
||||
|
||||
public boolean isEnabled() {
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
|
||||
public int getTimeout() {
|
||||
return this.timeout;
|
||||
}
|
||||
|
||||
|
||||
public String getHostUuid() {
|
||||
return this.hostUuid;
|
||||
}
|
||||
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
|
||||
public void setTimeout(int timeout) {
|
||||
this.timeout = timeout;
|
||||
}
|
||||
|
||||
|
||||
public void setHostUuid(String hostUuid) {
|
||||
this.hostUuid = hostUuid;
|
||||
}
|
||||
@ -23,7 +23,6 @@ import java.util.Map;
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.Command;
|
||||
import com.cloud.agent.api.StoragePoolInfo;
|
||||
import com.cloud.agent.mockvm.MockVm;
|
||||
import com.cloud.simulator.MockVMVO;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.component.Manager;
|
||||
@ -31,10 +30,10 @@ import com.cloud.vm.VirtualMachine.State;
|
||||
|
||||
public interface SimulatorManager extends Manager {
|
||||
public static final String Name = "simulator manager";
|
||||
|
||||
|
||||
public enum AgentType {
|
||||
Computing(0), // not used anymore
|
||||
Routing(1),
|
||||
Routing(1),
|
||||
Storage(2);
|
||||
|
||||
int value;
|
||||
@ -56,7 +55,7 @@ public interface SimulatorManager extends Manager {
|
||||
|
||||
Answer simulate(Command cmd, String hostGuid);
|
||||
StoragePoolInfo getLocalStorage(String hostGuid);
|
||||
|
||||
|
||||
boolean configureSimulator(Long zoneId, Long podId, Long clusterId, Long hostId, String command, String values);
|
||||
public HashMap<String, Pair<Long, Long>> syncNetworkGroups(String hostGuid);
|
||||
|
||||
@ -121,43 +121,43 @@ public class SimulatorManagerImpl implements SimulatorManager {
|
||||
public Answer simulate(Command cmd, String hostGuid) {
|
||||
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
|
||||
// txn.transitToUserManagedConnection(_concierge.conn());
|
||||
|
||||
|
||||
try {
|
||||
MockHost host = _mockHost.findByGuid(hostGuid);
|
||||
String cmdName = cmd.toString();
|
||||
int index = cmdName.lastIndexOf(".");
|
||||
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);
|
||||
|
||||
|
||||
SimulatorInfo info = new SimulatorInfo();
|
||||
info.setHostUuid(hostGuid);
|
||||
|
||||
|
||||
if (config != null) {
|
||||
Map<String, String> configParameters = config.getParameters();
|
||||
for (Map.Entry<String, String> entry : configParameters.entrySet()) {
|
||||
if (entry.getKey().equalsIgnoreCase("enabled")) {
|
||||
info.setEnabled(Boolean.parseBoolean(entry.getValue()));
|
||||
} else if (entry.getKey().equalsIgnoreCase("timeout")) {
|
||||
try {
|
||||
info.setTimeout(Integer.valueOf(entry.getValue()));
|
||||
} catch (NumberFormatException e) {
|
||||
s_logger.debug("invalid timeout parameter: " + e.toString());
|
||||
}
|
||||
} else if (entry.getKey().equalsIgnoreCase("wait")) {
|
||||
try {
|
||||
int wait = Integer.valueOf(entry.getValue());
|
||||
Thread.sleep(wait * 1000);
|
||||
} catch (NumberFormatException e) {
|
||||
s_logger.debug("invalid timeout parameter: " + e.toString());
|
||||
} catch (InterruptedException e) {
|
||||
s_logger.debug("thread is interrupted: " + e.toString());
|
||||
}
|
||||
}
|
||||
if (entry.getKey().equalsIgnoreCase("enabled")) {
|
||||
info.setEnabled(Boolean.parseBoolean(entry.getValue()));
|
||||
} else if (entry.getKey().equalsIgnoreCase("timeout")) {
|
||||
try {
|
||||
info.setTimeout(Integer.valueOf(entry.getValue()));
|
||||
} catch (NumberFormatException e) {
|
||||
s_logger.debug("invalid timeout parameter: " + e.toString());
|
||||
}
|
||||
} else if (entry.getKey().equalsIgnoreCase("wait")) {
|
||||
try {
|
||||
int wait = Integer.valueOf(entry.getValue());
|
||||
Thread.sleep(wait * 1000);
|
||||
} catch (NumberFormatException e) {
|
||||
s_logger.debug("invalid timeout parameter: " + e.toString());
|
||||
} catch (InterruptedException e) {
|
||||
s_logger.debug("thread is interrupted: " + e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (cmd instanceof GetHostStatsCommand) {
|
||||
return _mockAgentMgr.getHostStatistic((GetHostStatsCommand)cmd);
|
||||
} else if (cmd instanceof CheckHealthCommand) {
|
||||
@ -165,7 +165,7 @@ public class SimulatorManagerImpl implements SimulatorManager {
|
||||
} else if (cmd instanceof PingTestCommand) {
|
||||
return _mockAgentMgr.pingTest((PingTestCommand)cmd);
|
||||
} else if (cmd instanceof PrepareForMigrationCommand) {
|
||||
return _mockAgentMgr.prepareForMigrate((PrepareForMigrationCommand)cmd);
|
||||
return _mockAgentMgr.prepareForMigrate((PrepareForMigrationCommand)cmd);
|
||||
} else if (cmd instanceof MigrateCommand) {
|
||||
return _mockVmMgr.Migrate((MigrateCommand)cmd, info);
|
||||
} else if (cmd instanceof StartCommand) {
|
||||
@ -173,11 +173,11 @@ public class SimulatorManagerImpl implements SimulatorManager {
|
||||
} else if (cmd instanceof CheckSshCommand) {
|
||||
return _mockVmMgr.checkSshCommand((CheckSshCommand)cmd);
|
||||
} else if (cmd instanceof CheckVirtualMachineCommand) {
|
||||
return _mockVmMgr.checkVmState((CheckVirtualMachineCommand)cmd);
|
||||
return _mockVmMgr.checkVmState((CheckVirtualMachineCommand)cmd);
|
||||
} else if (cmd instanceof SetStaticNatRulesCommand) {
|
||||
return _mockVmMgr.SetStaticNatRules((SetStaticNatRulesCommand)cmd);
|
||||
} else if (cmd instanceof SetFirewallRulesCommand) {
|
||||
return _mockVmMgr.SetFirewallRules((SetFirewallRulesCommand)cmd);
|
||||
return _mockVmMgr.SetFirewallRules((SetFirewallRulesCommand)cmd);
|
||||
} else if (cmd instanceof SetPortForwardingRulesCommand) {
|
||||
return _mockVmMgr.SetPortForwardingRules((SetPortForwardingRulesCommand)cmd);
|
||||
} else if (cmd instanceof NetworkUsageCommand) {
|
||||
@ -193,7 +193,7 @@ public class SimulatorManagerImpl implements SimulatorManager {
|
||||
} else if (cmd instanceof CleanupNetworkRulesCmd) {
|
||||
return _mockVmMgr.CleanupNetworkRules((CleanupNetworkRulesCmd)cmd, info);
|
||||
} else if (cmd instanceof CheckNetworkCommand) {
|
||||
return _mockAgentMgr.checkNetworkCommand((CheckNetworkCommand) cmd);
|
||||
return _mockAgentMgr.checkNetworkCommand((CheckNetworkCommand) cmd);
|
||||
}else if (cmd instanceof StopCommand) {
|
||||
return _mockVmMgr.stopVM((StopCommand)cmd);
|
||||
} else if (cmd instanceof RebootCommand) {
|
||||
@ -261,12 +261,12 @@ public class SimulatorManagerImpl implements SimulatorManager {
|
||||
} else if (cmd instanceof BumpUpPriorityCommand) {
|
||||
return _mockVmMgr.bumpPriority((BumpUpPriorityCommand) cmd);
|
||||
} else if (cmd instanceof GetDomRVersionCmd) {
|
||||
return _mockVmMgr.getDomRVersion((GetDomRVersionCmd) cmd);
|
||||
return _mockVmMgr.getDomRVersion((GetDomRVersionCmd) cmd);
|
||||
} else if (cmd instanceof ClusterSyncCommand) {
|
||||
return new Answer(cmd);
|
||||
//return new ClusterSyncAnswer(((ClusterSyncCommand) cmd).getClusterId(), this.getVmStates(hostGuid));
|
||||
return new Answer(cmd);
|
||||
//return new ClusterSyncAnswer(((ClusterSyncCommand) cmd).getClusterId(), this.getVmStates(hostGuid));
|
||||
} else if (cmd instanceof CopyVolumeCommand) {
|
||||
return _mockStorageMgr.CopyVolume((CopyVolumeCommand) cmd);
|
||||
return _mockStorageMgr.CopyVolume((CopyVolumeCommand) cmd);
|
||||
} else {
|
||||
return Answer.createUnsupportedCommandAnswer(cmd);
|
||||
}
|
||||
@ -288,19 +288,19 @@ public class SimulatorManagerImpl implements SimulatorManager {
|
||||
|
||||
@Override
|
||||
public Map<String, State> getVmStates(String hostGuid) {
|
||||
return _mockVmMgr.getVmStates(hostGuid);
|
||||
return _mockVmMgr.getVmStates(hostGuid);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, MockVMVO> getVms(String hostGuid) {
|
||||
return _mockVmMgr.getVms(hostGuid);
|
||||
return _mockVmMgr.getVms(hostGuid);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public HashMap<String, Pair<Long, Long>> syncNetworkGroups(String hostGuid) {
|
||||
SimulatorInfo info = new SimulatorInfo();
|
||||
info.setHostUuid(hostGuid);
|
||||
return _mockVmMgr.syncNetworkGroups(info);
|
||||
SimulatorInfo info = new SimulatorInfo();
|
||||
info.setHostUuid(hostGuid);
|
||||
return _mockVmMgr.syncNetworkGroups(info);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -37,25 +37,25 @@ import com.cloud.utils.component.ComponentLocator;
|
||||
public class ConfigureSimulator extends BaseCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(ConfigureSimulator.class.getName());
|
||||
private static final String s_name = "configuresimulatorresponse";
|
||||
|
||||
|
||||
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, description="configure range: in a zone")
|
||||
private Long zoneId;
|
||||
|
||||
|
||||
@Parameter(name=ApiConstants.POD_ID, type=CommandType.LONG, description="configure range: in a pod")
|
||||
private Long podId;
|
||||
|
||||
|
||||
@Parameter(name=ApiConstants.CLUSTER_ID, type=CommandType.LONG, description="configure range: in a cluster")
|
||||
private Long clusterId;
|
||||
|
||||
|
||||
@Parameter(name=ApiConstants.HOST_ID, type=CommandType.LONG, description="configure range: in a host")
|
||||
private Long hostId;
|
||||
|
||||
|
||||
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="which command needs to be configured")
|
||||
private String command;
|
||||
|
||||
|
||||
@Parameter(name=ApiConstants.VALUE, type=CommandType.STRING, required=true, description="configuration options for this command, which is seperated by ;")
|
||||
private String values;
|
||||
|
||||
|
||||
@Override
|
||||
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
|
||||
ComponentLocator locator = ComponentLocator.getLocator(ManagementService.Name);
|
||||
@ -64,7 +64,7 @@ public class ConfigureSimulator extends BaseCmd {
|
||||
if (!result) {
|
||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to configure simulator");
|
||||
}
|
||||
|
||||
|
||||
SuccessResponse response = new SuccessResponse(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
}
|
||||
@ -52,7 +52,7 @@ public class AgentResourceBase implements ServerResource {
|
||||
protected String _name;
|
||||
private List<String> _warnings = new LinkedList<String>();
|
||||
private List<String> _errors = new LinkedList<String>();
|
||||
|
||||
|
||||
private transient IAgentControl _agentControl;
|
||||
|
||||
protected long _instanceId;
|
||||
@ -64,36 +64,36 @@ public class AgentResourceBase implements ServerResource {
|
||||
protected MockHost agentHost = null;
|
||||
protected boolean stopped = false;
|
||||
protected String hostGuid = null;
|
||||
|
||||
|
||||
|
||||
public AgentResourceBase(long instanceId, AgentType agentType, SimulatorManager simMgr, String hostGuid) {
|
||||
_instanceId = instanceId;
|
||||
|
||||
_instanceId = instanceId;
|
||||
|
||||
if(s_logger.isDebugEnabled()) {
|
||||
s_logger.info("New Routing host instantiated with guid:" + hostGuid);
|
||||
}
|
||||
|
||||
|
||||
if (agentType == AgentType.Routing) {
|
||||
_type = Host.Type.Routing;
|
||||
} else {
|
||||
_type = Host.Type.Storage;
|
||||
}
|
||||
|
||||
|
||||
this.hostGuid = hostGuid;
|
||||
}
|
||||
|
||||
|
||||
protected MockVmManager getVmMgr() {
|
||||
return _simMgr.getVmMgr();
|
||||
}
|
||||
|
||||
|
||||
protected MockStorageManager getStorageMgr() {
|
||||
return _simMgr.getStorageMgr();
|
||||
}
|
||||
|
||||
|
||||
protected MockAgentManager getAgentMgr() {
|
||||
return _simMgr.getAgentMgr();
|
||||
}
|
||||
|
||||
|
||||
protected long getInstanceId() {
|
||||
return _instanceId;
|
||||
}
|
||||
@ -102,7 +102,7 @@ public class AgentResourceBase implements ServerResource {
|
||||
if(s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Deserializing simulated agent on reconnect");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -113,18 +113,18 @@ public class AgentResourceBase implements ServerResource {
|
||||
public void setName(String name) {
|
||||
_name = name;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params)
|
||||
throws ConfigurationException {
|
||||
hostGuid = (String)params.get("guid");
|
||||
_locator = ComponentLocator.getLocator("management-server");
|
||||
_simMgr = _locator.getManager(SimulatorManager.class);
|
||||
|
||||
|
||||
agentHost = getAgentMgr().getHost(hostGuid);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void reconnect(MockHost host) {
|
||||
if(s_logger.isDebugEnabled()) {
|
||||
@ -244,7 +244,7 @@ public class AgentResourceBase implements ServerResource {
|
||||
}
|
||||
return file.getAbsolutePath();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Answer executeRequest(Command cmd) {
|
||||
@ -264,20 +264,20 @@ public class AgentResourceBase implements ServerResource {
|
||||
public void setType(Host.Type _type) {
|
||||
this._type = _type;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public StartupCommand[] initialize() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public SimulatorManager getSimulatorManager() {
|
||||
return _simMgr;
|
||||
}
|
||||
|
||||
public void setSimulatorManager(SimulatorManager simMgr) {
|
||||
_simMgr = simMgr;
|
||||
}
|
||||
|
||||
|
||||
public void setSimulatorManager(SimulatorManager simMgr) {
|
||||
_simMgr = simMgr;
|
||||
}
|
||||
|
||||
public boolean isStopped() {
|
||||
return this.stopped;
|
||||
}
|
||||
@ -91,7 +91,7 @@ public class AgentRoutingResource extends AgentStorageResource {
|
||||
} else if (cmd instanceof ReadyCommand) {
|
||||
return new ReadyAnswer((ReadyCommand)cmd);
|
||||
} else if (cmd instanceof ShutdownCommand) {
|
||||
return execute((ShutdownCommand)cmd);
|
||||
return execute((ShutdownCommand)cmd);
|
||||
} else {
|
||||
return _simMgr.simulate(cmd, hostGuid);
|
||||
}
|
||||
@ -99,7 +99,7 @@ public class AgentRoutingResource extends AgentStorageResource {
|
||||
return new Answer(cmd, false, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Type getType() {
|
||||
return Host.Type.Routing;
|
||||
@ -111,10 +111,10 @@ public class AgentRoutingResource extends AgentStorageResource {
|
||||
return null;
|
||||
}
|
||||
synchronized (_vms) {
|
||||
if (_vms.size() == 0) {
|
||||
//load vms state from database
|
||||
_vms.putAll(_simMgr.getVmStates(hostGuid));
|
||||
}
|
||||
if (_vms.size() == 0) {
|
||||
//load vms state from database
|
||||
_vms.putAll(_simMgr.getVmStates(hostGuid));
|
||||
}
|
||||
}
|
||||
final HashMap<String, State> newStates = sync();
|
||||
HashMap<String, Pair<Long, Long>> nwGrpStates = _simMgr.syncNetworkGroups(hostGuid);
|
||||
@ -131,18 +131,18 @@ public class AgentRoutingResource extends AgentStorageResource {
|
||||
totalCpu = agentHost.getCpuCount() * agentHost.getCpuSpeed();
|
||||
totalMem = agentHost.getMemorySize();
|
||||
for (Map.Entry<String, MockVMVO> entry : vmsMaps.entrySet()) {
|
||||
MockVMVO vm = entry.getValue();
|
||||
usedCpu += vm.getCpu();
|
||||
usedMem += vm.getMemory();
|
||||
_runningVms.put(entry.getKey(), new Pair<Long, Long>(Long.valueOf(vm.getCpu()), vm.getMemory()));
|
||||
MockVMVO vm = entry.getValue();
|
||||
usedCpu += vm.getCpu();
|
||||
usedMem += vm.getMemory();
|
||||
_runningVms.put(entry.getKey(), new Pair<Long, Long>(Long.valueOf(vm.getCpu()), vm.getMemory()));
|
||||
}
|
||||
|
||||
|
||||
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,
|
||||
RouterPrivateIpStrategy.HostLocal);
|
||||
cmd.setStateChanges(changes);
|
||||
|
||||
|
||||
Map<String, String> hostDetails = new HashMap<String, String>();
|
||||
hostDetails.put(RouterPrivateIpStrategy.class.getCanonicalName(), RouterPrivateIpStrategy.DcGlobal.toString());
|
||||
|
||||
@ -167,13 +167,13 @@ public class AgentRoutingResource extends AgentStorageResource {
|
||||
cmd.setCluster(String.valueOf(agentHost.getClusterId()));
|
||||
|
||||
StartupStorageCommand ssCmd = initializeLocalSR();
|
||||
|
||||
|
||||
return new StartupCommand[] { cmd, ssCmd };
|
||||
}
|
||||
|
||||
private StartupStorageCommand initializeLocalSR() {
|
||||
Map<String, TemplateInfo> tInfo = new HashMap<String, TemplateInfo>();
|
||||
|
||||
|
||||
StoragePoolInfo poolInfo = _simMgr.getLocalStorage(hostGuid);
|
||||
|
||||
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);
|
||||
return cmd;
|
||||
}
|
||||
|
||||
|
||||
protected synchronized Answer execute(StartCommand cmd)
|
||||
throws IllegalArgumentException {
|
||||
VirtualMachineTO vmSpec = cmd.getVirtualMachine();
|
||||
String vmName = vmSpec.getName();
|
||||
if (this.totalCpu < (vmSpec.getCpus() * vmSpec.getSpeed() + this.usedCpu) ||
|
||||
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;
|
||||
synchronized (_vms) {
|
||||
@ -202,7 +202,7 @@ public class AgentRoutingResource extends AgentStorageResource {
|
||||
if (!result.getResult()) {
|
||||
return new StartAnswer(cmd, result.getDetails());
|
||||
}
|
||||
|
||||
|
||||
this.usedCpu += vmSpec.getCpus() * vmSpec.getSpeed();
|
||||
this.usedMem += 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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected synchronized StopAnswer execute(StopCommand cmd) {
|
||||
|
||||
StopAnswer answer = null;
|
||||
@ -230,11 +230,11 @@ public class AgentRoutingResource extends AgentStorageResource {
|
||||
}
|
||||
try {
|
||||
Answer result = _simMgr.simulate(cmd, hostGuid);
|
||||
|
||||
|
||||
if (!result.getResult()) {
|
||||
return new StopAnswer(cmd, result.getDetails(), false);
|
||||
}
|
||||
|
||||
|
||||
answer = new StopAnswer(cmd, null, 0, true);
|
||||
Pair<Long, Long> data = _runningVms.get(vmName);
|
||||
if (data != null) {
|
||||
@ -242,16 +242,16 @@ public class AgentRoutingResource extends AgentStorageResource {
|
||||
this.usedMem -= data.second();
|
||||
}
|
||||
state = State.Stopped;
|
||||
|
||||
|
||||
} finally {
|
||||
synchronized (_vms) {
|
||||
_vms.put(vmName, state);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return answer;
|
||||
}
|
||||
|
||||
|
||||
protected CheckVirtualMachineAnswer execute(final CheckVirtualMachineCommand cmd) {
|
||||
final String vmName = cmd.getVmName();
|
||||
CheckVirtualMachineAnswer result = (CheckVirtualMachineAnswer)_simMgr.simulate(cmd, hostGuid);
|
||||
@ -346,7 +346,7 @@ public class AgentRoutingResource extends AgentStorageResource {
|
||||
|
||||
return changes;
|
||||
}
|
||||
|
||||
|
||||
private Answer execute(ShutdownCommand cmd) {
|
||||
this.stopped = true;
|
||||
return new Answer(cmd);
|
||||
@ -62,7 +62,7 @@ public class AgentStorageResource extends AgentResourceBase implements Secondary
|
||||
return _simMgr.simulate(cmd, hostGuid);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PingCommand getCurrentStatus(long id) {
|
||||
if (isStopped()) {
|
||||
@ -73,14 +73,14 @@ public class AgentStorageResource extends AgentResourceBase implements Secondary
|
||||
|
||||
@Override
|
||||
public Type getType() {
|
||||
if(SecondaryStorageVm.Role.templateProcessor.toString().equals(_role))
|
||||
return Host.Type.SecondaryStorage;
|
||||
return Host.Type.SecondaryStorageCmdExecutor;
|
||||
if(SecondaryStorageVm.Role.templateProcessor.toString().equals(_role))
|
||||
return Host.Type.SecondaryStorage;
|
||||
return Host.Type.SecondaryStorageCmdExecutor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StartupCommand[] initialize() {
|
||||
StartupSecondaryStorageCommand cmd = new StartupSecondaryStorageCommand();
|
||||
StartupSecondaryStorageCommand cmd = new StartupSecondaryStorageCommand();
|
||||
|
||||
cmd.setPrivateIpAddress(agentHost.getPrivateIpAddress());
|
||||
cmd.setPrivateNetmask(agentHost.getPrivateNetMask());
|
||||
@ -97,15 +97,15 @@ public class AgentStorageResource extends AgentResourceBase implements Secondary
|
||||
cmd.setPod(String.valueOf(agentHost.getPodId()));
|
||||
cmd.setGuid(agentHost.getGuid());
|
||||
return new StartupCommand[] { cmd };
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||
if (!super.configure(name, params)) {
|
||||
s_logger.warn("Base class was unable to configure");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ import com.cloud.utils.component.Inject;
|
||||
public class SimulatorDiscoverer extends DiscovererBase implements Discoverer, Listener, ResourceStateAdapter {
|
||||
private static final Logger s_logger = Logger
|
||||
.getLogger(SimulatorDiscoverer.class);
|
||||
|
||||
|
||||
@Inject HostDao _hostDao;
|
||||
@Inject VMTemplateDao _vmTemplateDao;
|
||||
@Inject VMTemplateHostDao _vmTemplateHostDao;
|
||||
@ -70,10 +70,10 @@ public class SimulatorDiscoverer extends DiscovererBase implements Discoverer, L
|
||||
@Inject MockAgentManager _mockAgentMgr = null;
|
||||
@Inject MockStorageManager _mockStorageMgr = null;
|
||||
@Inject ResourceManager _resourceMgr;
|
||||
|
||||
|
||||
/**
|
||||
* Finds ServerResources of an in-process simulator
|
||||
*
|
||||
*
|
||||
* @see com.cloud.resource.Discoverer#find(long, java.lang.Long,
|
||||
* java.lang.Long, java.net.URI, java.lang.String, java.lang.String)
|
||||
*/
|
||||
@ -88,7 +88,7 @@ public class SimulatorDiscoverer extends DiscovererBase implements Discoverer, L
|
||||
String scheme = uri.getScheme();
|
||||
String host = uri.getAuthority();
|
||||
String commands = URLDecoder.decode(uri.getPath());
|
||||
|
||||
|
||||
long cpuSpeed = _mockAgentMgr.DEFAULT_HOST_SPEED_MHZ;
|
||||
long cpuCores = _mockAgentMgr.DEFAULT_HOST_CPU_CORES;
|
||||
long memory = _mockAgentMgr.DEFAULT_HOST_MEM_SIZE;
|
||||
@ -145,7 +145,7 @@ public class SimulatorDiscoverer extends DiscovererBase implements Discoverer, L
|
||||
if (s_logger.isInfoEnabled())
|
||||
s_logger.info("invalid cluster id or cluster is not for Simulator hypervisors");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
cluster = Long.toString(clusterId);
|
||||
if(clu.getGuid() == null) {
|
||||
clu.setGuid(UUID.randomUUID().toString());
|
||||
@ -205,23 +205,23 @@ public class SimulatorDiscoverer extends DiscovererBase implements Discoverer, L
|
||||
for (HostVO h : hosts) {
|
||||
associateTemplatesToZone(h.getId(), h.getDataCenterId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void associateTemplatesToZone(long hostId, long dcId){
|
||||
VMTemplateZoneVO tmpltZone;
|
||||
VMTemplateZoneVO tmpltZone;
|
||||
|
||||
List<VMTemplateVO> allTemplates = _vmTemplateDao.listAll();
|
||||
for (VMTemplateVO vt: allTemplates){
|
||||
if (vt.isCrossZones()) {
|
||||
tmpltZone = _vmTemplateZoneDao.findByZoneTemplate(dcId, vt.getId());
|
||||
if (tmpltZone == null) {
|
||||
VMTemplateZoneVO vmTemplateZone = new VMTemplateZoneVO(dcId, vt.getId(), new Date());
|
||||
_vmTemplateZoneDao.persist(vmTemplateZone);
|
||||
}
|
||||
}
|
||||
}
|
||||
List<VMTemplateVO> allTemplates = _vmTemplateDao.listAll();
|
||||
for (VMTemplateVO vt: allTemplates){
|
||||
if (vt.isCrossZones()) {
|
||||
tmpltZone = _vmTemplateZoneDao.findByZoneTemplate(dcId, vt.getId());
|
||||
if (tmpltZone == null) {
|
||||
VMTemplateZoneVO vmTemplateZone = new VMTemplateZoneVO(dcId, vt.getId(), new Date());
|
||||
_vmTemplateZoneDao.persist(vmTemplateZone);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public HypervisorType getHypervisorType() {
|
||||
return HypervisorType.Simulator;
|
||||
@ -231,7 +231,7 @@ public class SimulatorDiscoverer extends DiscovererBase implements Discoverer, L
|
||||
public boolean matchHypervisor(String hypervisor) {
|
||||
return hypervisor.equalsIgnoreCase(HypervisorType.Simulator.toString());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||
super.configure(name, params);
|
||||
@ -257,9 +257,9 @@ public class SimulatorDiscoverer extends DiscovererBase implements Discoverer, L
|
||||
|
||||
@Override
|
||||
public void processConnect(HostVO host, StartupCommand cmd, boolean forRebalance) throws ConnectionException {
|
||||
|
||||
|
||||
/*if(forRebalance)
|
||||
return;
|
||||
return;
|
||||
if ( Host.Type.SecondaryStorage == host.getType() ) {
|
||||
List<VMTemplateVO> tmplts = _vmTemplateDao.listAll();
|
||||
for( VMTemplateVO tmplt : tmplts ) {
|
||||
@ -275,7 +275,7 @@ public class SimulatorDiscoverer extends DiscovererBase implements Discoverer, L
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -312,12 +312,12 @@ public class SimulatorDiscoverer extends DiscovererBase implements Discoverer, L
|
||||
if (!(firstCmd instanceof StartupRoutingCommand)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
StartupRoutingCommand ssCmd = ((StartupRoutingCommand) firstCmd);
|
||||
if (ssCmd.getHypervisorType() != HypervisorType.Simulator) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
return _resourceMgr.fillRoutingHostVO(host, ssCmd, HypervisorType.Simulator, details, hostTags);
|
||||
}
|
||||
|
||||
@ -326,11 +326,11 @@ public class SimulatorDiscoverer extends DiscovererBase implements Discoverer, L
|
||||
boolean isForceDeleteStorage) throws UnableDeleteHostException {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean stop() {
|
||||
_resourceMgr.unregisterResourceStateAdapter(this.getClass().getSimpleName());
|
||||
_resourceMgr.unregisterResourceStateAdapter(this.getClass().getSimpleName());
|
||||
return super.stop();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -45,14 +45,14 @@ public class SimulatorSecondaryDiscoverer extends SecondaryStorageDiscoverer imp
|
||||
@Inject AgentManager _agentMgr;
|
||||
@Inject ResourceManager _resourceMgr;
|
||||
@Inject SnapshotDao _snapshotDao;
|
||||
|
||||
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||
_agentMgr.registerForHostEvents(this, true, false, false);
|
||||
_agentMgr.registerForHostEvents(this, true, false, false);
|
||||
_resourceMgr.registerResourceStateAdapter(this.getClass().getSimpleName(), this);
|
||||
return super.configure(name, params);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void postDiscovery(List<HostVO> hosts, long msId) {
|
||||
super.postDiscovery(hosts, msId);
|
||||
@ -74,9 +74,9 @@ public class SimulatorSecondaryDiscoverer extends SecondaryStorageDiscoverer imp
|
||||
//for detecting SSVM dispatch
|
||||
StartupCommand firstCmd = startup[0];
|
||||
if (!(firstCmd instanceof StartupSecondaryStorageCommand)) {
|
||||
return null;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
host.setType(com.cloud.host.Host.Type.SecondaryStorageVM);
|
||||
return host;
|
||||
}
|
||||
@ -103,7 +103,7 @@ public class SimulatorSecondaryDiscoverer extends SecondaryStorageDiscoverer imp
|
||||
|
||||
@Override
|
||||
public boolean stop() {
|
||||
_resourceMgr.unregisterResourceStateAdapter(this.getClass().getSimpleName());
|
||||
_resourceMgr.unregisterResourceStateAdapter(this.getClass().getSimpleName());
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -130,7 +130,7 @@ public class SimulatorSecondaryDiscoverer extends SecondaryStorageDiscoverer imp
|
||||
@Override
|
||||
public void processConnect(HostVO host, StartupCommand cmd,
|
||||
boolean forRebalance) throws ConnectionException {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -25,7 +25,7 @@ public class ManagementServerSimulatorImpl extends ManagementServerExtImpl {
|
||||
for (int i = 0; i < apis.length; i++) {
|
||||
newapis[i] = apis[i];
|
||||
}
|
||||
|
||||
|
||||
newapis[apis.length] = "commands-simulator.properties";
|
||||
return newapis;
|
||||
}
|
||||
@ -33,79 +33,79 @@ public class MockConfigurationVO {
|
||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||
@Column(name="id")
|
||||
private long id;
|
||||
|
||||
|
||||
@Column(name="data_center_id", nullable=false)
|
||||
private Long dataCenterId;
|
||||
|
||||
|
||||
@Column(name="pod_id")
|
||||
private Long podId;
|
||||
|
||||
|
||||
@Column(name="cluster_id")
|
||||
private Long clusterId;
|
||||
|
||||
|
||||
@Column(name="host_id")
|
||||
private Long hostId;
|
||||
|
||||
|
||||
@Column(name="name")
|
||||
private String name;
|
||||
|
||||
|
||||
@Column(name="values")
|
||||
private String values;
|
||||
|
||||
|
||||
public long getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
|
||||
public Long getDataCenterId() {
|
||||
return this.dataCenterId;
|
||||
}
|
||||
|
||||
|
||||
public void setDataCenterId(Long dcId) {
|
||||
this.dataCenterId = dcId;
|
||||
}
|
||||
|
||||
|
||||
public Long getPodId() {
|
||||
return this.podId;
|
||||
}
|
||||
|
||||
|
||||
public void setPodId(Long podId) {
|
||||
this.podId = podId;
|
||||
}
|
||||
|
||||
|
||||
public Long getClusterId() {
|
||||
return this.clusterId;
|
||||
}
|
||||
|
||||
|
||||
public void setClusterId(Long clusterId) {
|
||||
this.clusterId = clusterId;
|
||||
}
|
||||
|
||||
|
||||
public Long getHostId() {
|
||||
return this.hostId;
|
||||
}
|
||||
|
||||
|
||||
public void setHostId(Long hostId) {
|
||||
this.hostId = hostId;
|
||||
}
|
||||
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
public String getValues() {
|
||||
return this.values;
|
||||
}
|
||||
|
||||
|
||||
public Map<String, String> getParameters() {
|
||||
Map<String, String> maps = new HashMap<String, String>();
|
||||
if (this.values == null) {
|
||||
return maps;
|
||||
}
|
||||
|
||||
|
||||
String[] vals = this.values.split("\\|");
|
||||
for (String val : vals) {
|
||||
String[] paras = val.split(":");
|
||||
@ -113,9 +113,8 @@ public class MockConfigurationVO {
|
||||
}
|
||||
return maps;
|
||||
}
|
||||
|
||||
|
||||
public void setValues(String values) {
|
||||
this.values = values;
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,44 +19,44 @@ package com.cloud.simulator;
|
||||
public interface MockHost {
|
||||
public long getCpuSpeed();
|
||||
public long getCpuCount();
|
||||
|
||||
|
||||
|
||||
|
||||
public long getMemorySize();
|
||||
|
||||
|
||||
public String getCapabilities();
|
||||
|
||||
|
||||
public long getId();
|
||||
|
||||
|
||||
public String getName();
|
||||
|
||||
|
||||
public String getGuid();
|
||||
|
||||
|
||||
|
||||
|
||||
public String getVersion();
|
||||
|
||||
|
||||
public Long getDataCenterId();
|
||||
|
||||
|
||||
public Long getPodId();
|
||||
|
||||
|
||||
public Long getClusterId();
|
||||
|
||||
|
||||
public String getPrivateIpAddress();
|
||||
|
||||
|
||||
public String getPrivateNetMask();
|
||||
|
||||
|
||||
public String getPrivateMacAddress();
|
||||
|
||||
|
||||
|
||||
|
||||
public String getPublicIpAddress();
|
||||
|
||||
|
||||
public String getPublicNetMask();
|
||||
|
||||
|
||||
public String getPublicMacAddress();
|
||||
|
||||
|
||||
public String getStorageIpAddress();
|
||||
|
||||
|
||||
public String getStorageNetMask();
|
||||
|
||||
|
||||
public String getStorageMacAddress();
|
||||
|
||||
|
||||
}
|
||||
@ -31,245 +31,245 @@ public class MockHostVO implements MockHost {
|
||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||
@Column(name="id")
|
||||
private long id;
|
||||
|
||||
|
||||
@Column(name="name", nullable=false)
|
||||
private String name = null;
|
||||
|
||||
|
||||
@Column(name="private_ip_address", nullable=false)
|
||||
private String privateIpAddress;
|
||||
|
||||
|
||||
@Column(name="private_mac_address", nullable=false)
|
||||
private String privateMacAddress;
|
||||
|
||||
|
||||
@Column(name="private_netmask", nullable=false)
|
||||
private String privateNetmask;
|
||||
|
||||
|
||||
@Column(name="public_netmask")
|
||||
private String publicNetmask;
|
||||
|
||||
|
||||
@Column(name="public_ip_address")
|
||||
private String publicIpAddress;
|
||||
|
||||
|
||||
@Column(name="public_mac_address")
|
||||
private String publicMacAddress;
|
||||
|
||||
|
||||
@Column(name="storage_ip_address")
|
||||
private String storageIpAddress;
|
||||
|
||||
|
||||
@Column(name="storage_mac_address")
|
||||
private String storageMacAddress;
|
||||
|
||||
|
||||
@Column(name="storage_netmask")
|
||||
private String storageNetMask;
|
||||
|
||||
|
||||
@Column(name="guid")
|
||||
private String guid;
|
||||
|
||||
|
||||
@Column(name="version")
|
||||
private String version;
|
||||
|
||||
|
||||
@Column(name="data_center_id", nullable=false)
|
||||
private long dataCenterId;
|
||||
|
||||
|
||||
@Column(name="pod_id")
|
||||
private Long podId;
|
||||
|
||||
|
||||
@Column(name="cluster_id")
|
||||
private Long clusterId;
|
||||
|
||||
|
||||
@Column(name="speed")
|
||||
private long cpuSpeed;
|
||||
|
||||
|
||||
@Column(name="cpus")
|
||||
private long cpuCount;
|
||||
|
||||
|
||||
@Column(name="ram")
|
||||
private long memorySize;
|
||||
|
||||
|
||||
@Column(name="capabilities")
|
||||
private String capabilities;
|
||||
|
||||
|
||||
@Column(name="vm_id")
|
||||
private long vmId;
|
||||
|
||||
|
||||
@Column(name="resource")
|
||||
private String resource;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public MockHostVO() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public long getVmId() {
|
||||
return vmId;
|
||||
}
|
||||
|
||||
|
||||
public void setVmId(long vmId) {
|
||||
this.vmId = vmId;
|
||||
}
|
||||
|
||||
|
||||
public String getResource() {
|
||||
return this.resource;
|
||||
}
|
||||
|
||||
|
||||
public void setResource(String resource) {
|
||||
this.resource = resource;
|
||||
}
|
||||
|
||||
|
||||
public long getCpuSpeed() {
|
||||
return this.cpuSpeed;
|
||||
}
|
||||
|
||||
|
||||
public void setCpuSpeed(long cpuSpeed) {
|
||||
this.cpuSpeed = cpuSpeed;
|
||||
}
|
||||
|
||||
|
||||
public long getCpuCount() {
|
||||
return this.cpuCount;
|
||||
}
|
||||
|
||||
|
||||
public void setCpuCount(long cpuCount) {
|
||||
this.cpuCount = cpuCount;
|
||||
}
|
||||
|
||||
|
||||
public long getMemorySize() {
|
||||
return this.memorySize;
|
||||
}
|
||||
|
||||
|
||||
public void setMemorySize(long memorySize) {
|
||||
this.memorySize = memorySize;
|
||||
}
|
||||
|
||||
|
||||
public String getCapabilities() {
|
||||
return this.capabilities;
|
||||
}
|
||||
|
||||
|
||||
public void setCapabilities(String capabilities) {
|
||||
this.capabilities = capabilities;
|
||||
}
|
||||
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
public String getGuid() {
|
||||
return this.guid;
|
||||
}
|
||||
|
||||
|
||||
public void setGuid(String guid) {
|
||||
this.guid = guid;
|
||||
}
|
||||
|
||||
|
||||
public String getVersion() {
|
||||
return this.version;
|
||||
}
|
||||
|
||||
|
||||
public void setVersion(String version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
|
||||
public Long getDataCenterId() {
|
||||
return this.dataCenterId;
|
||||
}
|
||||
|
||||
|
||||
public void setDataCenterId(Long dataCenterId) {
|
||||
this.dataCenterId = dataCenterId;
|
||||
}
|
||||
|
||||
|
||||
public Long getPodId() {
|
||||
return this.podId;
|
||||
}
|
||||
|
||||
|
||||
public void setPodId(long podId) {
|
||||
this.podId = podId;
|
||||
}
|
||||
|
||||
|
||||
public Long getClusterId() {
|
||||
return this.clusterId;
|
||||
}
|
||||
|
||||
|
||||
public void setClusterId(Long clusterId) {
|
||||
this.clusterId = clusterId;
|
||||
}
|
||||
|
||||
|
||||
public String getPrivateIpAddress() {
|
||||
return privateIpAddress;
|
||||
}
|
||||
|
||||
|
||||
public void setPrivateIpAddress(String privateIpAddress) {
|
||||
this.privateIpAddress = privateIpAddress;
|
||||
}
|
||||
|
||||
|
||||
public String getPrivateNetMask() {
|
||||
return this.privateNetmask;
|
||||
}
|
||||
|
||||
|
||||
public void setPrivateNetMask(String privateNetmask) {
|
||||
this.privateNetmask = privateNetmask;
|
||||
}
|
||||
|
||||
|
||||
public String getPrivateMacAddress() {
|
||||
return this.privateMacAddress;
|
||||
}
|
||||
|
||||
|
||||
public void setPrivateMacAddress(String privateMacAddress) {
|
||||
this.privateMacAddress = privateMacAddress;
|
||||
}
|
||||
|
||||
|
||||
public String getPublicIpAddress() {
|
||||
return this.publicIpAddress;
|
||||
}
|
||||
|
||||
|
||||
public void setPublicIpAddress(String publicIpAddress) {
|
||||
this.publicIpAddress = publicIpAddress;
|
||||
}
|
||||
|
||||
|
||||
public String getPublicNetMask() {
|
||||
return this.publicNetmask;
|
||||
}
|
||||
|
||||
|
||||
public void setPublicNetMask(String publicNetMask) {
|
||||
this.publicNetmask = publicNetMask;
|
||||
}
|
||||
|
||||
|
||||
public String getPublicMacAddress() {
|
||||
return this.publicMacAddress;
|
||||
}
|
||||
|
||||
|
||||
public void setPublicMacAddress(String publicMacAddress) {
|
||||
this.publicMacAddress = publicMacAddress;
|
||||
}
|
||||
|
||||
|
||||
public String getStorageIpAddress() {
|
||||
return this.storageIpAddress;
|
||||
}
|
||||
|
||||
|
||||
public void setStorageIpAddress(String storageIpAddress) {
|
||||
this.storageIpAddress = storageIpAddress;
|
||||
}
|
||||
|
||||
|
||||
public String getStorageNetMask() {
|
||||
return this.storageNetMask;
|
||||
}
|
||||
|
||||
|
||||
public void setStorageNetMask(String storageNetMask) {
|
||||
this.storageNetMask = storageNetMask;
|
||||
}
|
||||
|
||||
|
||||
public String getStorageMacAddress() {
|
||||
return this.storageMacAddress;
|
||||
}
|
||||
|
||||
|
||||
public void setStorageMacAddress(String storageMacAddress) {
|
||||
this.storageMacAddress = storageMacAddress;
|
||||
}
|
||||
@ -31,45 +31,45 @@ public class MockSecStorageVO {
|
||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||
@Column(name="id")
|
||||
private long id;
|
||||
|
||||
|
||||
@Column(name="url")
|
||||
private String url;
|
||||
|
||||
|
||||
@Column(name="capacity")
|
||||
private long capacity;
|
||||
|
||||
|
||||
@Column(name="mount_point")
|
||||
private String mountPoint;
|
||||
|
||||
|
||||
|
||||
|
||||
public MockSecStorageVO() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public long getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
|
||||
public String getMountPoint() {
|
||||
return this.mountPoint;
|
||||
}
|
||||
|
||||
|
||||
public void setMountPoint(String mountPoint) {
|
||||
this.mountPoint = mountPoint;
|
||||
}
|
||||
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
|
||||
public long getCapacity() {
|
||||
return this.capacity;
|
||||
}
|
||||
|
||||
|
||||
public void setCapacity(long capacity) {
|
||||
this.capacity = capacity;
|
||||
}
|
||||
@ -31,73 +31,73 @@ public class MockSecurityRulesVO {
|
||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||
@Column(name="id")
|
||||
private long id;
|
||||
|
||||
|
||||
@Column(name="vmid")
|
||||
private Long vmId;
|
||||
|
||||
|
||||
@Column(name="signature")
|
||||
private String signature;
|
||||
|
||||
|
||||
@Column(name="seqnum")
|
||||
private Long seqNum;
|
||||
|
||||
|
||||
@Column(name="ruleset")
|
||||
private String ruleSet;
|
||||
|
||||
|
||||
@Column(name="hostid")
|
||||
private String hostId;
|
||||
|
||||
|
||||
@Column(name="vmname")
|
||||
public String vmName;
|
||||
|
||||
|
||||
public String getVmName() {
|
||||
return this.vmName;
|
||||
}
|
||||
|
||||
|
||||
public void setVmName(String vmName) {
|
||||
this.vmName = vmName;
|
||||
}
|
||||
|
||||
|
||||
public String getHostId() {
|
||||
return this.hostId;
|
||||
}
|
||||
|
||||
|
||||
public void setHostId(String hostId) {
|
||||
this.hostId = hostId;
|
||||
}
|
||||
|
||||
|
||||
public long getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
|
||||
public Long getVmId() {
|
||||
return this.vmId;
|
||||
}
|
||||
|
||||
|
||||
public void setVmId(Long vmId) {
|
||||
this.vmId = vmId;
|
||||
}
|
||||
|
||||
|
||||
public String getSignature() {
|
||||
return this.signature;
|
||||
}
|
||||
|
||||
|
||||
public void setSignature(String sig) {
|
||||
this.signature = sig;
|
||||
}
|
||||
|
||||
|
||||
public Long getSeqNum() {
|
||||
return this.seqNum;
|
||||
}
|
||||
|
||||
|
||||
public void setSeqNum(Long seqNum) {
|
||||
this.seqNum = seqNum;
|
||||
}
|
||||
|
||||
|
||||
public String getRuleSet() {
|
||||
return this.ruleSet;
|
||||
}
|
||||
|
||||
|
||||
public void setRuleSet(String ruleset) {
|
||||
this.ruleSet = ruleset;
|
||||
}
|
||||
@ -35,67 +35,67 @@ public class MockStoragePoolVO {
|
||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||
@Column(name="id")
|
||||
private long id;
|
||||
|
||||
|
||||
@Column(name="guid")
|
||||
private String uuid;
|
||||
|
||||
|
||||
@Column(name="mount_point")
|
||||
private String mountPoint;
|
||||
|
||||
|
||||
@Column(name="capacity")
|
||||
private long capacity;
|
||||
|
||||
|
||||
@Column(name="hostguid")
|
||||
private String hostGuid;
|
||||
|
||||
|
||||
@Column(name="pool_type")
|
||||
@Enumerated(value=EnumType.STRING)
|
||||
private StoragePoolType poolType;
|
||||
|
||||
|
||||
public MockStoragePoolVO() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public String getHostGuid() {
|
||||
return this.hostGuid;
|
||||
}
|
||||
|
||||
|
||||
public void setHostGuid(String hostGuid) {
|
||||
this.hostGuid = hostGuid;
|
||||
}
|
||||
|
||||
|
||||
public long getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
|
||||
public StoragePoolType getPoolType() {
|
||||
return this.poolType;
|
||||
}
|
||||
|
||||
|
||||
public void setStorageType(StoragePoolType poolType) {
|
||||
this.poolType = poolType;
|
||||
}
|
||||
|
||||
|
||||
public String getUuid() {
|
||||
return this.uuid;
|
||||
}
|
||||
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
|
||||
public String getMountPoint() {
|
||||
return this.mountPoint;
|
||||
}
|
||||
|
||||
|
||||
public void setMountPoint(String mountPoint) {
|
||||
this.mountPoint = mountPoint;
|
||||
}
|
||||
|
||||
|
||||
public long getCapacity() {
|
||||
return this.capacity;
|
||||
}
|
||||
|
||||
|
||||
public void setCapacity(long capacity) {
|
||||
this.capacity = capacity;
|
||||
}
|
||||
@ -33,98 +33,98 @@ public class MockVMVO implements MockVm{
|
||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||
@Column(name="id")
|
||||
private long id;
|
||||
|
||||
|
||||
@Column(name="name")
|
||||
private String name;
|
||||
|
||||
|
||||
@Column(name="host_id")
|
||||
private long hostId;
|
||||
|
||||
|
||||
@Column(name="type")
|
||||
private String vmType;
|
||||
|
||||
|
||||
@Column(name="state")
|
||||
private State state;
|
||||
|
||||
|
||||
@Column(name="vnc_port")
|
||||
private int vncPort;
|
||||
|
||||
|
||||
@Column(name="memory")
|
||||
private long memory;
|
||||
|
||||
|
||||
@Column(name="cpu")
|
||||
private int cpu;
|
||||
|
||||
|
||||
public MockVMVO() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public long getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
public long getHostId() {
|
||||
return this.hostId;
|
||||
}
|
||||
|
||||
|
||||
public void setHostId(long hostId) {
|
||||
this.hostId = hostId;
|
||||
}
|
||||
|
||||
|
||||
public String getVmType() {
|
||||
return this.vmType;
|
||||
}
|
||||
|
||||
|
||||
public void setVmType(String vmType) {
|
||||
this.vmType = vmType;
|
||||
}
|
||||
|
||||
|
||||
public State getState() {
|
||||
return this.state;
|
||||
}
|
||||
|
||||
|
||||
public String getType() {
|
||||
return this.vmType;
|
||||
return this.vmType;
|
||||
}
|
||||
|
||||
|
||||
public void setState(State state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
|
||||
public int getVncPort() {
|
||||
return this.vncPort;
|
||||
}
|
||||
|
||||
|
||||
public void setVncPort(int vncPort) {
|
||||
this.vncPort = vncPort;
|
||||
}
|
||||
|
||||
|
||||
public long getMemory() {
|
||||
return this.memory;
|
||||
}
|
||||
|
||||
|
||||
public void setMemory(long memory) {
|
||||
this.memory = memory;
|
||||
}
|
||||
|
||||
|
||||
public int getCpu() {
|
||||
return this.cpu;
|
||||
}
|
||||
|
||||
|
||||
public void setCpu(int cpu) {
|
||||
this.cpu = cpu;
|
||||
}
|
||||
|
||||
|
||||
public void setType(String type) {
|
||||
this.vmType = type;
|
||||
this.vmType = type;
|
||||
}
|
||||
|
||||
}
|
||||
@ -20,21 +20,21 @@ import com.cloud.vm.VirtualMachine.State;
|
||||
|
||||
// As storage is mapped from storage device, can virtually treat that VM here does
|
||||
public interface MockVm {
|
||||
|
||||
|
||||
|
||||
|
||||
public String getName();
|
||||
|
||||
|
||||
public State getState();
|
||||
|
||||
|
||||
public void setState(State state);
|
||||
|
||||
|
||||
public void setHostId(long hostId);
|
||||
public long getMemory();
|
||||
|
||||
|
||||
public int getCpu();
|
||||
public String getType();
|
||||
public int getVncPort();
|
||||
|
||||
|
||||
public void setName(String name);
|
||||
public void setMemory(long memory);
|
||||
public void setCpu(int cpu);
|
||||
@ -42,4 +42,3 @@ public interface MockVm {
|
||||
public void setVncPort(int vncPort);
|
||||
public long getId();
|
||||
}
|
||||
|
||||
@ -43,76 +43,76 @@ public class MockVolumeVO {
|
||||
@GeneratedValue(strategy=GenerationType.IDENTITY)
|
||||
@Column(name="id")
|
||||
private long id;
|
||||
|
||||
|
||||
@Column(name="name")
|
||||
private String name;
|
||||
|
||||
|
||||
@Column(name="size")
|
||||
private long size;
|
||||
|
||||
|
||||
@Column(name="path")
|
||||
private String path;
|
||||
|
||||
|
||||
@Column(name="pool_id")
|
||||
private long poolId;
|
||||
|
||||
|
||||
@Column(name="type")
|
||||
@Enumerated(value=EnumType.STRING)
|
||||
private MockVolumeType type;
|
||||
|
||||
|
||||
@Column(name="status")
|
||||
@Enumerated(value=EnumType.STRING)
|
||||
private VMTemplateStorageResourceAssoc.Status status;
|
||||
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
public long getSize() {
|
||||
return this.size;
|
||||
}
|
||||
|
||||
|
||||
public void setSize(long size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
|
||||
public String getPath() {
|
||||
return this.path;
|
||||
}
|
||||
|
||||
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
|
||||
public long getPoolId() {
|
||||
return this.poolId;
|
||||
}
|
||||
|
||||
|
||||
public void setPoolId(long poolId) {
|
||||
this.poolId = poolId;
|
||||
}
|
||||
|
||||
|
||||
public MockVolumeType getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
|
||||
public void setType(MockVolumeType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
||||
public Status getStatus() {
|
||||
return this.status;
|
||||
}
|
||||
|
||||
|
||||
public void setStatus(Status status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -35,7 +35,7 @@ public class SimulatorGuru extends HypervisorGuruBase implements HypervisorGuru
|
||||
protected SimulatorGuru() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public HypervisorType getHypervisorType() {
|
||||
return HypervisorType.Simulator;
|
||||
@ -44,11 +44,11 @@ public class SimulatorGuru extends HypervisorGuruBase implements HypervisorGuru
|
||||
@Override
|
||||
public <T extends VirtualMachine> VirtualMachineTO implement(VirtualMachineProfile<T> vm) {
|
||||
VirtualMachineTO to = toVirtualMachineTO(vm);
|
||||
|
||||
|
||||
// Determine the VM's OS description
|
||||
GuestOSVO guestOS = _guestOsDao.findById(vm.getVirtualMachine().getGuestOSId());
|
||||
to.setOs(guestOS.getDisplayName());
|
||||
|
||||
|
||||
return to;
|
||||
}
|
||||
|
||||
@ -26,15 +26,15 @@ import com.cloud.utils.exception.RuntimeCloudException;
|
||||
public class SimulatorRuntimeException extends RuntimeCloudException {
|
||||
|
||||
private static final long serialVersionUID = SerialVersionUID.CloudRuntimeException;
|
||||
|
||||
|
||||
public SimulatorRuntimeException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
|
||||
public SimulatorRuntimeException(String message, Throwable th) {
|
||||
super(message, th);
|
||||
}
|
||||
|
||||
|
||||
protected SimulatorRuntimeException() {
|
||||
super();
|
||||
}
|
||||
@ -35,8 +35,8 @@ public class MockConfigurationDaoImpl extends GenericDaoBase<MockConfigurationVO
|
||||
private SearchBuilder<MockConfigurationVO> _searchByDcIDPodIdClusterIdName;
|
||||
private SearchBuilder<MockConfigurationVO> _searchByDcIDPodIdClusterIdHostIdName;
|
||||
private SearchBuilder<MockConfigurationVO> _searchByGlobalName;
|
||||
|
||||
|
||||
|
||||
|
||||
public MockConfigurationDaoImpl() {
|
||||
_searchByGlobalName = createSearchBuilder();
|
||||
_searchByGlobalName.and("dcId", _searchByGlobalName.entity().getDataCenterId(), SearchCriteria.Op.NULL);
|
||||
@ -45,7 +45,7 @@ public class MockConfigurationDaoImpl extends GenericDaoBase<MockConfigurationVO
|
||||
_searchByGlobalName.and("hostId", _searchByGlobalName.entity().getHostId(), SearchCriteria.Op.NULL);
|
||||
_searchByGlobalName.and("name", _searchByGlobalName.entity().getName(), SearchCriteria.Op.EQ);
|
||||
_searchByGlobalName.done();
|
||||
|
||||
|
||||
_searchByDcIdName = createSearchBuilder();
|
||||
_searchByDcIdName.and("dcId", _searchByDcIdName.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
||||
_searchByDcIdName.and("podId", _searchByDcIdName.entity().getPodId(), SearchCriteria.Op.NULL);
|
||||
@ -53,7 +53,7 @@ public class MockConfigurationDaoImpl extends GenericDaoBase<MockConfigurationVO
|
||||
_searchByDcIdName.and("hostId", _searchByDcIdName.entity().getHostId(), SearchCriteria.Op.NULL);
|
||||
_searchByDcIdName.and("name", _searchByDcIdName.entity().getName(), SearchCriteria.Op.EQ);
|
||||
_searchByDcIdName.done();
|
||||
|
||||
|
||||
_searchByDcIDPodIdName = createSearchBuilder();
|
||||
_searchByDcIDPodIdName.and("dcId", _searchByDcIDPodIdName.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
||||
_searchByDcIDPodIdName.and("podId", _searchByDcIDPodIdName.entity().getPodId(), SearchCriteria.Op.EQ);
|
||||
@ -61,7 +61,7 @@ public class MockConfigurationDaoImpl extends GenericDaoBase<MockConfigurationVO
|
||||
_searchByDcIDPodIdName.and("hostId", _searchByDcIDPodIdName.entity().getHostId(), SearchCriteria.Op.NULL);
|
||||
_searchByDcIDPodIdName.and("name", _searchByDcIDPodIdName.entity().getName(), SearchCriteria.Op.EQ);
|
||||
_searchByDcIDPodIdName.done();
|
||||
|
||||
|
||||
_searchByDcIDPodIdClusterIdName = createSearchBuilder();
|
||||
_searchByDcIDPodIdClusterIdName.and("dcId", _searchByDcIDPodIdClusterIdName.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
||||
_searchByDcIDPodIdClusterIdName.and("podId", _searchByDcIDPodIdClusterIdName.entity().getPodId(), SearchCriteria.Op.EQ);
|
||||
@ -69,7 +69,7 @@ public class MockConfigurationDaoImpl extends GenericDaoBase<MockConfigurationVO
|
||||
_searchByDcIDPodIdClusterIdName.and("hostId", _searchByDcIDPodIdClusterIdName.entity().getHostId(), SearchCriteria.Op.NULL);
|
||||
_searchByDcIDPodIdClusterIdName.and("name", _searchByDcIDPodIdClusterIdName.entity().getName(), SearchCriteria.Op.EQ);
|
||||
_searchByDcIDPodIdClusterIdName.done();
|
||||
|
||||
|
||||
_searchByDcIDPodIdClusterIdHostIdName = createSearchBuilder();
|
||||
_searchByDcIDPodIdClusterIdHostIdName.and("dcId", _searchByDcIDPodIdClusterIdHostIdName.entity().getDataCenterId(), SearchCriteria.Op.EQ);
|
||||
_searchByDcIDPodIdClusterIdHostIdName.and("podId", _searchByDcIDPodIdClusterIdHostIdName.entity().getPodId(), SearchCriteria.Op.EQ);
|
||||
@ -80,7 +80,7 @@ public class MockConfigurationDaoImpl extends GenericDaoBase<MockConfigurationVO
|
||||
}
|
||||
@Override
|
||||
public MockConfigurationVO findByCommand(Long dcId, Long podId, Long clusterId, Long hostId, String name) {
|
||||
|
||||
|
||||
if (dcId == null) {
|
||||
SearchCriteria<MockConfigurationVO> sc = _searchByGlobalName.create();
|
||||
sc.setParameters("name", name);
|
||||
@ -113,19 +113,19 @@ public class MockConfigurationDaoImpl extends GenericDaoBase<MockConfigurationVO
|
||||
return findOneBy(sc);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public MockConfigurationVO findByNameBottomUP(Long dcId, Long podId, Long clusterId, Long hostId, String name) {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
StringBuilder search = new StringBuilder();
|
||||
Formatter formatter = new Formatter(search);
|
||||
formatter.format("select * from mockconfiguration where (name='%s') and ((data_center_id = %d and pod_id = %d and cluster_id = %d and host_id = %d)", name, dcId, podId, clusterId, hostId);
|
||||
formatter.format(" or (data_center_id = %d and pod_id = %d and cluster_id = %d and host_id is null)", dcId, podId, clusterId);
|
||||
formatter.format(" or (data_center_id = %d and pod_id = %d and cluster_id is null and host_id is null)", dcId, podId);
|
||||
formatter.format(" or (data_center_id = %d and pod_id is null and cluster_id is null and host_id is null)", dcId);
|
||||
formatter.format(" or (data_center_id is null and pod_id is null and cluster_id is null and host_id is null)) LIMIT 1");
|
||||
|
||||
PreparedStatement pstmt = null;
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
StringBuilder search = new StringBuilder();
|
||||
Formatter formatter = new Formatter(search);
|
||||
formatter.format("select * from mockconfiguration where (name='%s') and ((data_center_id = %d and pod_id = %d and cluster_id = %d and host_id = %d)", name, dcId, podId, clusterId, hostId);
|
||||
formatter.format(" or (data_center_id = %d and pod_id = %d and cluster_id = %d and host_id is null)", dcId, podId, clusterId);
|
||||
formatter.format(" or (data_center_id = %d and pod_id = %d and cluster_id is null and host_id is null)", dcId, podId);
|
||||
formatter.format(" or (data_center_id = %d and pod_id is null and cluster_id is null and host_id is null)", dcId);
|
||||
formatter.format(" or (data_center_id is null and pod_id is null and cluster_id is null and host_id is null)) LIMIT 1");
|
||||
|
||||
PreparedStatement pstmt = null;
|
||||
try {
|
||||
String sql = search.toString();
|
||||
pstmt = txn.prepareAutoCloseStatement(sql);
|
||||
@ -134,9 +134,9 @@ public class MockConfigurationDaoImpl extends GenericDaoBase<MockConfigurationVO
|
||||
return toEntityBean(rs, false);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -26,7 +26,7 @@ import com.cloud.utils.db.SearchCriteria;
|
||||
|
||||
@Local(value={MockHostDao.class})
|
||||
public class MockHostDaoImpl extends GenericDaoBase<MockHostVO, Long> implements MockHostDao {
|
||||
protected final SearchBuilder<MockHostVO> GuidSearch;
|
||||
protected final SearchBuilder<MockHostVO> GuidSearch;
|
||||
public MockHostDaoImpl() {
|
||||
GuidSearch = createSearchBuilder();
|
||||
GuidSearch.and("guid", GuidSearch.entity().getGuid(), SearchCriteria.Op.EQ);
|
||||
@ -25,14 +25,14 @@ import com.cloud.utils.db.SearchCriteria;
|
||||
|
||||
@Local(value={MockSecStorageDao.class})
|
||||
public class MockSecStorageDaoImpl extends GenericDaoBase<MockSecStorageVO, Long> implements MockSecStorageDao {
|
||||
protected final SearchBuilder<MockSecStorageVO> urlSearch;
|
||||
protected final SearchBuilder<MockSecStorageVO> urlSearch;
|
||||
@Override
|
||||
public MockSecStorageVO findByUrl(String url) {
|
||||
SearchCriteria<MockSecStorageVO> sc = urlSearch.create();
|
||||
sc.setParameters("url", url);
|
||||
return findOneBy(sc);
|
||||
}
|
||||
|
||||
|
||||
public MockSecStorageDaoImpl() {
|
||||
urlSearch = createSearchBuilder();
|
||||
urlSearch.and("url", urlSearch.entity().getUrl(), SearchCriteria.Op.EQ);
|
||||
@ -29,7 +29,7 @@ import com.cloud.utils.db.SearchCriteria;
|
||||
@Local(value={MockSecurityRulesDao.class})
|
||||
public class MockSecurityRulesDaoImpl extends GenericDaoBase<MockSecurityRulesVO, Long> implements MockSecurityRulesDao {
|
||||
protected SearchBuilder<MockSecurityRulesVO> vmIdSearch;
|
||||
protected SearchBuilder<MockSecurityRulesVO> hostSearch;
|
||||
protected SearchBuilder<MockSecurityRulesVO> hostSearch;
|
||||
@Override
|
||||
public MockSecurityRulesVO findByVmId(Long vmId) {
|
||||
SearchCriteria<MockSecurityRulesVO> sc = vmIdSearch.create();
|
||||
@ -43,18 +43,18 @@ public class MockSecurityRulesDaoImpl extends GenericDaoBase<MockSecurityRulesVO
|
||||
sc.setParameters("host", hostGuid);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||
vmIdSearch = createSearchBuilder();
|
||||
vmIdSearch.and("vmId", vmIdSearch.entity().getVmId(), SearchCriteria.Op.EQ);
|
||||
vmIdSearch.done();
|
||||
|
||||
|
||||
hostSearch = createSearchBuilder();
|
||||
hostSearch.and("host", hostSearch.entity().getHostId(), SearchCriteria.Op.EQ);
|
||||
hostSearch.done();
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -34,12 +34,12 @@ public class MockStoragePoolDaoImpl extends GenericDaoBase<MockStoragePoolVO, Lo
|
||||
sc.setParameters("uuid", uuid);
|
||||
return findOneBy(sc);
|
||||
}
|
||||
|
||||
|
||||
public MockStoragePoolDaoImpl() {
|
||||
uuidSearch = createSearchBuilder();
|
||||
uuidSearch.and("uuid", uuidSearch.entity().getUuid(), SearchCriteria.Op.EQ);
|
||||
uuidSearch.done();
|
||||
|
||||
|
||||
hostguidSearch = createSearchBuilder();
|
||||
hostguidSearch.and("hostguid", hostguidSearch.entity().getHostGuid(), SearchCriteria.Op.EQ);
|
||||
hostguidSearch.and("type", hostguidSearch.entity().getPoolType(), SearchCriteria.Op.EQ);
|
||||
@ -34,7 +34,7 @@ import com.cloud.vm.VirtualMachine;
|
||||
|
||||
@Local(value={MockVMDao.class})
|
||||
public class MockVMDaoImpl extends GenericDaoBase<MockVMVO, Long> implements MockVMDao {
|
||||
protected SearchBuilder<MockVMVO> GuidSearch;
|
||||
protected SearchBuilder<MockVMVO> GuidSearch;
|
||||
protected SearchBuilder<MockVMVO> vmNameSearch;
|
||||
protected SearchBuilder<MockVMVO> vmhostSearch;
|
||||
@Inject MockHostDao _mockHostDao;
|
||||
@ -57,7 +57,7 @@ public class MockVMDaoImpl extends GenericDaoBase<MockVMVO, Long> implements Moc
|
||||
sc.setParameters("state", VirtualMachine.State.Running);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public MockVMVO findByVmNameAndHost(String vmName, String hostGuid) {
|
||||
SearchCriteria<MockVMVO> sc = vmhostSearch.create();
|
||||
@ -65,28 +65,28 @@ public class MockVMDaoImpl extends GenericDaoBase<MockVMVO, Long> implements Moc
|
||||
sc.setParameters("name", vmName);
|
||||
return findOneBy(sc);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||
SearchBuilder<MockHostVO> host = _mockHostDao.createSearchBuilder();
|
||||
host.and("guid", host.entity().getGuid(), SearchCriteria.Op.EQ);
|
||||
|
||||
|
||||
GuidSearch = createSearchBuilder();
|
||||
GuidSearch.join("host", host, host.entity().getId(), GuidSearch.entity().getHostId(), JoinBuilder.JoinType.INNER);
|
||||
GuidSearch.and("state", GuidSearch.entity().getState(), SearchCriteria.Op.EQ);
|
||||
GuidSearch.done();
|
||||
|
||||
|
||||
vmNameSearch = createSearchBuilder();
|
||||
vmNameSearch.and("name", vmNameSearch.entity().getName(), SearchCriteria.Op.EQ);
|
||||
vmNameSearch.done();
|
||||
|
||||
|
||||
SearchBuilder<MockHostVO> newhost = _mockHostDao.createSearchBuilder();
|
||||
newhost.and("guid", newhost.entity().getGuid(), SearchCriteria.Op.EQ);
|
||||
vmhostSearch = createSearchBuilder();
|
||||
vmhostSearch.and("name", vmhostSearch.entity().getName(), SearchCriteria.Op.EQ);
|
||||
vmhostSearch.join("host", newhost, newhost.entity().getId(), vmhostSearch.entity().getHostId(), JoinBuilder.JoinType.INNER);
|
||||
vmhostSearch.done();
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -42,11 +42,11 @@ public class MockVolumeDaoImpl extends GenericDaoBase<MockVolumeVO, Long> implem
|
||||
sc.setParameters("type", type);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Long findTotalStorageId(long id) {
|
||||
SearchCriteria<Long> sc = totalSearch.create();
|
||||
|
||||
|
||||
sc.setParameters("poolId", id);
|
||||
return customSearch(sc, null).get(0);
|
||||
}
|
||||
@ -57,20 +57,20 @@ public class MockVolumeDaoImpl extends GenericDaoBase<MockVolumeVO, Long> implem
|
||||
sc.setParameters("path", "%" + path + "%");
|
||||
return findOneBy(sc);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public MockVolumeVO findByNameAndPool(String volumeName, String poolUUID) {
|
||||
SearchCriteria<MockVolumeVO> sc = namePoolSearch.create();
|
||||
sc.setParameters("name", volumeName);
|
||||
sc.setParameters("poolUuid", poolUUID);
|
||||
return findOneBy(sc);
|
||||
return findOneBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MockVolumeVO findByName(String volumeName) {
|
||||
SearchCriteria<MockVolumeVO> sc = nameSearch.create();
|
||||
sc.setParameters("name", volumeName);
|
||||
return findOneBy(sc);
|
||||
return findOneBy(sc);
|
||||
}
|
||||
|
||||
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("type", idTypeSearch.entity().getType(), SearchCriteria.Op.EQ);
|
||||
idTypeSearch.done();
|
||||
|
||||
|
||||
pathTypeSearch = createSearchBuilder();
|
||||
pathTypeSearch.and("path", pathTypeSearch.entity().getPath(), SearchCriteria.Op.LIKE);
|
||||
pathTypeSearch.done();
|
||||
|
||||
|
||||
namePoolSearch = createSearchBuilder();
|
||||
namePoolSearch.and("name", namePoolSearch.entity().getName(), SearchCriteria.Op.EQ);
|
||||
namePoolSearch.and("poolUuid", namePoolSearch.entity().getPoolId(), SearchCriteria.Op.EQ);
|
||||
namePoolSearch.done();
|
||||
|
||||
|
||||
nameSearch = createSearchBuilder();
|
||||
nameSearch.and("name", nameSearch.entity().getName(), SearchCriteria.Op.EQ);
|
||||
nameSearch.done();
|
||||
|
||||
|
||||
totalSearch = createSearchBuilder(Long.class);
|
||||
totalSearch.select(null, Func.SUM, totalSearch.entity().getSize());
|
||||
totalSearch.and("poolId", totalSearch.entity().getPoolId(), SearchCriteria.Op.EQ);
|
||||
totalSearch.done();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -38,6 +38,7 @@
|
||||
<module>hypervisors/ovm</module>
|
||||
<module>hypervisors/xen</module>
|
||||
<module>hypervisors/kvm</module>
|
||||
<module>hypervisors/simulator</module>
|
||||
<module>network-elements/elastic-loadbalancer</module>
|
||||
<module>network-elements/ovs</module>
|
||||
<module>network-elements/nicira-nvp</module>
|
||||
@ -124,6 +125,17 @@
|
||||
<module>hypervisors/vmware</module>
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>kvm</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>nonoss</name>
|
||||
</property>
|
||||
</activation>
|
||||
<modules>
|
||||
<module>hypervisors/simulator</module>
|
||||
</modules>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
</project>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user