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>
|
||||||
@ -57,7 +57,7 @@ public class MetricsCollector {
|
|||||||
|
|
||||||
vmNames.removeAll(currentVMs); //old vms - current vms --> leave non-running vms;
|
vmNames.removeAll(currentVMs); //old vms - current vms --> leave non-running vms;
|
||||||
for (String vm: vmNames) {
|
for (String vm: vmNames) {
|
||||||
removeVM(vm);
|
removeVM(vm);
|
||||||
}
|
}
|
||||||
|
|
||||||
vmNames.clear();
|
vmNames.clear();
|
||||||
@ -87,14 +87,14 @@ public class MetricsCollector {
|
|||||||
newVMnames.remove(vmName);
|
newVMnames.remove(vmName);
|
||||||
vmNames.remove(vmName);
|
vmNames.remove(vmName);
|
||||||
MockVmMetrics task = metricsMap.get(vmName);
|
MockVmMetrics task = metricsMap.get(vmName);
|
||||||
if (task != null) {
|
if (task != null) {
|
||||||
task.stop();
|
task.stop();
|
||||||
boolean r1= task.getFuture().cancel(false);
|
boolean r1= task.getFuture().cancel(false);
|
||||||
metricsMap.remove(vmName);
|
metricsMap.remove(vmName);
|
||||||
s_logger.debug("removeVM: cancel returned " + r1 + " for VM " + vmName);
|
s_logger.debug("removeVM: cancel returned " + r1 + " for VM " + vmName);
|
||||||
} else {
|
} else {
|
||||||
s_logger.warn("removeVM called for nonexistent VM " + vmName);
|
s_logger.warn("removeVM called for nonexistent VM " + vmName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized Set<String> getVMNames() {
|
public synchronized Set<String> getVMNames() {
|
||||||
@ -202,4 +202,3 @@ public class MockVmMetrics implements Runnable {
|
|||||||
this.stopped = true;
|
this.stopped = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,8 +72,8 @@ public class MockVmManagerImpl implements MockVmManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String startVM(String vmName, NicTO[] nics,
|
public String startVM(String vmName, NicTO[] nics,
|
||||||
int cpuHz, long ramSize,
|
int cpuHz, long ramSize,
|
||||||
String bootArgs, String hostGuid) {
|
String bootArgs, String hostGuid) {
|
||||||
|
|
||||||
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
|
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
|
||||||
MockHost host = null;
|
MockHost host = null;
|
||||||
@ -108,13 +108,13 @@ public class MockVmManagerImpl implements MockVmManager {
|
|||||||
vm.setVncPort(vncPort);
|
vm.setVncPort(vncPort);
|
||||||
vm.setHostId(host.getId());
|
vm.setHostId(host.getId());
|
||||||
if(vmName.startsWith("s-")) {
|
if(vmName.startsWith("s-")) {
|
||||||
vm.setType("SecondaryStorageVm");
|
vm.setType("SecondaryStorageVm");
|
||||||
} else if (vmName.startsWith("v-")) {
|
} else if (vmName.startsWith("v-")) {
|
||||||
vm.setType("ConsoleProxy");
|
vm.setType("ConsoleProxy");
|
||||||
} else if (vmName.startsWith("r-")) {
|
} else if (vmName.startsWith("r-")) {
|
||||||
vm.setType("DomainRouter");
|
vm.setType("DomainRouter");
|
||||||
} else if (vmName.startsWith("i-")) {
|
} else if (vmName.startsWith("i-")) {
|
||||||
vm.setType("User");
|
vm.setType("User");
|
||||||
}
|
}
|
||||||
txn = Transaction.open(Transaction.SIMULATOR_DB);
|
txn = Transaction.open(Transaction.SIMULATOR_DB);
|
||||||
try {
|
try {
|
||||||
@ -133,18 +133,18 @@ public class MockVmManagerImpl implements MockVmManager {
|
|||||||
if(vm.getState() == State.Stopped) {
|
if(vm.getState() == State.Stopped) {
|
||||||
vm.setState(State.Running);
|
vm.setState(State.Running);
|
||||||
txn = Transaction.open(Transaction.SIMULATOR_DB);
|
txn = Transaction.open(Transaction.SIMULATOR_DB);
|
||||||
try {
|
try {
|
||||||
txn.start();
|
txn.start();
|
||||||
_mockVmDao.update(vm.getId(), (MockVMVO)vm);
|
_mockVmDao.update(vm.getId(), (MockVMVO)vm);
|
||||||
txn.commit();
|
txn.commit();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
txn.rollback();
|
txn.rollback();
|
||||||
throw new CloudRuntimeException("unable to update vm " + vm.getName(), ex);
|
throw new CloudRuntimeException("unable to update vm " + vm.getName(), ex);
|
||||||
} finally {
|
} finally {
|
||||||
txn.close();
|
txn.close();
|
||||||
txn = Transaction.open(Transaction.CLOUD_DB);
|
txn = Transaction.open(Transaction.CLOUD_DB);
|
||||||
txn.close();
|
txn.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -370,7 +370,7 @@ public class MockVmManagerImpl implements MockVmManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Answer SetFirewallRules(SetFirewallRulesCommand cmd) {
|
public Answer SetFirewallRules(SetFirewallRulesCommand cmd) {
|
||||||
return new Answer(cmd);
|
return new Answer(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -519,13 +519,13 @@ public class MockVmManagerImpl implements MockVmManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GetDomRVersionAnswer getDomRVersion(GetDomRVersionCmd cmd) {
|
public GetDomRVersionAnswer getDomRVersion(GetDomRVersionCmd cmd) {
|
||||||
return new GetDomRVersionAnswer(cmd, null, null, null);
|
return new GetDomRVersionAnswer(cmd, null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SecurityGroupRuleAnswer AddSecurityGroupRules(SecurityGroupRulesCmd cmd, SimulatorInfo info) {
|
public SecurityGroupRuleAnswer AddSecurityGroupRules(SecurityGroupRulesCmd cmd, SimulatorInfo info) {
|
||||||
if (!info.isEnabled()) {
|
if (!info.isEnabled()) {
|
||||||
return new SecurityGroupRuleAnswer(cmd, false, "Disabled", SecurityGroupRuleAnswer.FailureReason.CANNOT_BRIDGE_FIREWALL);
|
return new SecurityGroupRuleAnswer(cmd, false, "Disabled", SecurityGroupRuleAnswer.FailureReason.CANNOT_BRIDGE_FIREWALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, Ternary<String,Long, Long>> rules = _securityRules.get(info.getHostUuid());
|
Map<String, Ternary<String,Long, Long>> rules = _securityRules.get(info.getHostUuid());
|
||||||
@ -23,7 +23,6 @@ import java.util.Map;
|
|||||||
import com.cloud.agent.api.Answer;
|
import com.cloud.agent.api.Answer;
|
||||||
import com.cloud.agent.api.Command;
|
import com.cloud.agent.api.Command;
|
||||||
import com.cloud.agent.api.StoragePoolInfo;
|
import com.cloud.agent.api.StoragePoolInfo;
|
||||||
import com.cloud.agent.mockvm.MockVm;
|
|
||||||
import com.cloud.simulator.MockVMVO;
|
import com.cloud.simulator.MockVMVO;
|
||||||
import com.cloud.utils.Pair;
|
import com.cloud.utils.Pair;
|
||||||
import com.cloud.utils.component.Manager;
|
import com.cloud.utils.component.Manager;
|
||||||
@ -127,7 +127,7 @@ public class SimulatorManagerImpl implements SimulatorManager {
|
|||||||
String cmdName = cmd.toString();
|
String cmdName = cmd.toString();
|
||||||
int index = cmdName.lastIndexOf(".");
|
int index = cmdName.lastIndexOf(".");
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
cmdName = cmdName.substring(index + 1);
|
cmdName = cmdName.substring(index + 1);
|
||||||
}
|
}
|
||||||
MockConfigurationVO config = _mockConfigDao.findByNameBottomUP(host.getDataCenterId(), host.getPodId(), host.getClusterId(), host.getId(), cmdName);
|
MockConfigurationVO config = _mockConfigDao.findByNameBottomUP(host.getDataCenterId(), host.getPodId(), host.getClusterId(), host.getId(), cmdName);
|
||||||
|
|
||||||
@ -137,24 +137,24 @@ public class SimulatorManagerImpl implements SimulatorManager {
|
|||||||
if (config != null) {
|
if (config != null) {
|
||||||
Map<String, String> configParameters = config.getParameters();
|
Map<String, String> configParameters = config.getParameters();
|
||||||
for (Map.Entry<String, String> entry : configParameters.entrySet()) {
|
for (Map.Entry<String, String> entry : configParameters.entrySet()) {
|
||||||
if (entry.getKey().equalsIgnoreCase("enabled")) {
|
if (entry.getKey().equalsIgnoreCase("enabled")) {
|
||||||
info.setEnabled(Boolean.parseBoolean(entry.getValue()));
|
info.setEnabled(Boolean.parseBoolean(entry.getValue()));
|
||||||
} else if (entry.getKey().equalsIgnoreCase("timeout")) {
|
} else if (entry.getKey().equalsIgnoreCase("timeout")) {
|
||||||
try {
|
try {
|
||||||
info.setTimeout(Integer.valueOf(entry.getValue()));
|
info.setTimeout(Integer.valueOf(entry.getValue()));
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
s_logger.debug("invalid timeout parameter: " + e.toString());
|
s_logger.debug("invalid timeout parameter: " + e.toString());
|
||||||
}
|
}
|
||||||
} else if (entry.getKey().equalsIgnoreCase("wait")) {
|
} else if (entry.getKey().equalsIgnoreCase("wait")) {
|
||||||
try {
|
try {
|
||||||
int wait = Integer.valueOf(entry.getValue());
|
int wait = Integer.valueOf(entry.getValue());
|
||||||
Thread.sleep(wait * 1000);
|
Thread.sleep(wait * 1000);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
s_logger.debug("invalid timeout parameter: " + e.toString());
|
s_logger.debug("invalid timeout parameter: " + e.toString());
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
s_logger.debug("thread is interrupted: " + e.toString());
|
s_logger.debug("thread is interrupted: " + e.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,7 +165,7 @@ public class SimulatorManagerImpl implements SimulatorManager {
|
|||||||
} else if (cmd instanceof PingTestCommand) {
|
} else if (cmd instanceof PingTestCommand) {
|
||||||
return _mockAgentMgr.pingTest((PingTestCommand)cmd);
|
return _mockAgentMgr.pingTest((PingTestCommand)cmd);
|
||||||
} else if (cmd instanceof PrepareForMigrationCommand) {
|
} else if (cmd instanceof PrepareForMigrationCommand) {
|
||||||
return _mockAgentMgr.prepareForMigrate((PrepareForMigrationCommand)cmd);
|
return _mockAgentMgr.prepareForMigrate((PrepareForMigrationCommand)cmd);
|
||||||
} else if (cmd instanceof MigrateCommand) {
|
} else if (cmd instanceof MigrateCommand) {
|
||||||
return _mockVmMgr.Migrate((MigrateCommand)cmd, info);
|
return _mockVmMgr.Migrate((MigrateCommand)cmd, info);
|
||||||
} else if (cmd instanceof StartCommand) {
|
} else if (cmd instanceof StartCommand) {
|
||||||
@ -173,11 +173,11 @@ public class SimulatorManagerImpl implements SimulatorManager {
|
|||||||
} else if (cmd instanceof CheckSshCommand) {
|
} else if (cmd instanceof CheckSshCommand) {
|
||||||
return _mockVmMgr.checkSshCommand((CheckSshCommand)cmd);
|
return _mockVmMgr.checkSshCommand((CheckSshCommand)cmd);
|
||||||
} else if (cmd instanceof CheckVirtualMachineCommand) {
|
} else if (cmd instanceof CheckVirtualMachineCommand) {
|
||||||
return _mockVmMgr.checkVmState((CheckVirtualMachineCommand)cmd);
|
return _mockVmMgr.checkVmState((CheckVirtualMachineCommand)cmd);
|
||||||
} else if (cmd instanceof SetStaticNatRulesCommand) {
|
} else if (cmd instanceof SetStaticNatRulesCommand) {
|
||||||
return _mockVmMgr.SetStaticNatRules((SetStaticNatRulesCommand)cmd);
|
return _mockVmMgr.SetStaticNatRules((SetStaticNatRulesCommand)cmd);
|
||||||
} else if (cmd instanceof SetFirewallRulesCommand) {
|
} else if (cmd instanceof SetFirewallRulesCommand) {
|
||||||
return _mockVmMgr.SetFirewallRules((SetFirewallRulesCommand)cmd);
|
return _mockVmMgr.SetFirewallRules((SetFirewallRulesCommand)cmd);
|
||||||
} else if (cmd instanceof SetPortForwardingRulesCommand) {
|
} else if (cmd instanceof SetPortForwardingRulesCommand) {
|
||||||
return _mockVmMgr.SetPortForwardingRules((SetPortForwardingRulesCommand)cmd);
|
return _mockVmMgr.SetPortForwardingRules((SetPortForwardingRulesCommand)cmd);
|
||||||
} else if (cmd instanceof NetworkUsageCommand) {
|
} else if (cmd instanceof NetworkUsageCommand) {
|
||||||
@ -193,7 +193,7 @@ public class SimulatorManagerImpl implements SimulatorManager {
|
|||||||
} else if (cmd instanceof CleanupNetworkRulesCmd) {
|
} else if (cmd instanceof CleanupNetworkRulesCmd) {
|
||||||
return _mockVmMgr.CleanupNetworkRules((CleanupNetworkRulesCmd)cmd, info);
|
return _mockVmMgr.CleanupNetworkRules((CleanupNetworkRulesCmd)cmd, info);
|
||||||
} else if (cmd instanceof CheckNetworkCommand) {
|
} else if (cmd instanceof CheckNetworkCommand) {
|
||||||
return _mockAgentMgr.checkNetworkCommand((CheckNetworkCommand) cmd);
|
return _mockAgentMgr.checkNetworkCommand((CheckNetworkCommand) cmd);
|
||||||
}else if (cmd instanceof StopCommand) {
|
}else if (cmd instanceof StopCommand) {
|
||||||
return _mockVmMgr.stopVM((StopCommand)cmd);
|
return _mockVmMgr.stopVM((StopCommand)cmd);
|
||||||
} else if (cmd instanceof RebootCommand) {
|
} else if (cmd instanceof RebootCommand) {
|
||||||
@ -261,12 +261,12 @@ public class SimulatorManagerImpl implements SimulatorManager {
|
|||||||
} else if (cmd instanceof BumpUpPriorityCommand) {
|
} else if (cmd instanceof BumpUpPriorityCommand) {
|
||||||
return _mockVmMgr.bumpPriority((BumpUpPriorityCommand) cmd);
|
return _mockVmMgr.bumpPriority((BumpUpPriorityCommand) cmd);
|
||||||
} else if (cmd instanceof GetDomRVersionCmd) {
|
} else if (cmd instanceof GetDomRVersionCmd) {
|
||||||
return _mockVmMgr.getDomRVersion((GetDomRVersionCmd) cmd);
|
return _mockVmMgr.getDomRVersion((GetDomRVersionCmd) cmd);
|
||||||
} else if (cmd instanceof ClusterSyncCommand) {
|
} else if (cmd instanceof ClusterSyncCommand) {
|
||||||
return new Answer(cmd);
|
return new Answer(cmd);
|
||||||
//return new ClusterSyncAnswer(((ClusterSyncCommand) cmd).getClusterId(), this.getVmStates(hostGuid));
|
//return new ClusterSyncAnswer(((ClusterSyncCommand) cmd).getClusterId(), this.getVmStates(hostGuid));
|
||||||
} else if (cmd instanceof CopyVolumeCommand) {
|
} else if (cmd instanceof CopyVolumeCommand) {
|
||||||
return _mockStorageMgr.CopyVolume((CopyVolumeCommand) cmd);
|
return _mockStorageMgr.CopyVolume((CopyVolumeCommand) cmd);
|
||||||
} else {
|
} else {
|
||||||
return Answer.createUnsupportedCommandAnswer(cmd);
|
return Answer.createUnsupportedCommandAnswer(cmd);
|
||||||
}
|
}
|
||||||
@ -288,19 +288,19 @@ public class SimulatorManagerImpl implements SimulatorManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, State> getVmStates(String hostGuid) {
|
public Map<String, State> getVmStates(String hostGuid) {
|
||||||
return _mockVmMgr.getVmStates(hostGuid);
|
return _mockVmMgr.getVmStates(hostGuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, MockVMVO> getVms(String hostGuid) {
|
public Map<String, MockVMVO> getVms(String hostGuid) {
|
||||||
return _mockVmMgr.getVms(hostGuid);
|
return _mockVmMgr.getVms(hostGuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HashMap<String, Pair<Long, Long>> syncNetworkGroups(String hostGuid) {
|
public HashMap<String, Pair<Long, Long>> syncNetworkGroups(String hostGuid) {
|
||||||
SimulatorInfo info = new SimulatorInfo();
|
SimulatorInfo info = new SimulatorInfo();
|
||||||
info.setHostUuid(hostGuid);
|
info.setHostUuid(hostGuid);
|
||||||
return _mockVmMgr.syncNetworkGroups(info);
|
return _mockVmMgr.syncNetworkGroups(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -111,10 +111,10 @@ public class AgentRoutingResource extends AgentStorageResource {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
synchronized (_vms) {
|
synchronized (_vms) {
|
||||||
if (_vms.size() == 0) {
|
if (_vms.size() == 0) {
|
||||||
//load vms state from database
|
//load vms state from database
|
||||||
_vms.putAll(_simMgr.getVmStates(hostGuid));
|
_vms.putAll(_simMgr.getVmStates(hostGuid));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final HashMap<String, State> newStates = sync();
|
final HashMap<String, State> newStates = sync();
|
||||||
HashMap<String, Pair<Long, Long>> nwGrpStates = _simMgr.syncNetworkGroups(hostGuid);
|
HashMap<String, Pair<Long, Long>> nwGrpStates = _simMgr.syncNetworkGroups(hostGuid);
|
||||||
@ -131,10 +131,10 @@ public class AgentRoutingResource extends AgentStorageResource {
|
|||||||
totalCpu = agentHost.getCpuCount() * agentHost.getCpuSpeed();
|
totalCpu = agentHost.getCpuCount() * agentHost.getCpuSpeed();
|
||||||
totalMem = agentHost.getMemorySize();
|
totalMem = agentHost.getMemorySize();
|
||||||
for (Map.Entry<String, MockVMVO> entry : vmsMaps.entrySet()) {
|
for (Map.Entry<String, MockVMVO> entry : vmsMaps.entrySet()) {
|
||||||
MockVMVO vm = entry.getValue();
|
MockVMVO vm = entry.getValue();
|
||||||
usedCpu += vm.getCpu();
|
usedCpu += vm.getCpu();
|
||||||
usedMem += vm.getMemory();
|
usedMem += vm.getMemory();
|
||||||
_runningVms.put(entry.getKey(), new Pair<Long, Long>(Long.valueOf(vm.getCpu()), vm.getMemory()));
|
_runningVms.put(entry.getKey(), new Pair<Long, Long>(Long.valueOf(vm.getCpu()), vm.getMemory()));
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Object> info = getHostInfo();
|
List<Object> info = getHostInfo();
|
||||||
@ -73,14 +73,14 @@ public class AgentStorageResource extends AgentResourceBase implements Secondary
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Type getType() {
|
public Type getType() {
|
||||||
if(SecondaryStorageVm.Role.templateProcessor.toString().equals(_role))
|
if(SecondaryStorageVm.Role.templateProcessor.toString().equals(_role))
|
||||||
return Host.Type.SecondaryStorage;
|
return Host.Type.SecondaryStorage;
|
||||||
return Host.Type.SecondaryStorageCmdExecutor;
|
return Host.Type.SecondaryStorageCmdExecutor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StartupCommand[] initialize() {
|
public StartupCommand[] initialize() {
|
||||||
StartupSecondaryStorageCommand cmd = new StartupSecondaryStorageCommand();
|
StartupSecondaryStorageCommand cmd = new StartupSecondaryStorageCommand();
|
||||||
|
|
||||||
cmd.setPrivateIpAddress(agentHost.getPrivateIpAddress());
|
cmd.setPrivateIpAddress(agentHost.getPrivateIpAddress());
|
||||||
cmd.setPrivateNetmask(agentHost.getPrivateNetMask());
|
cmd.setPrivateNetmask(agentHost.getPrivateNetMask());
|
||||||
@ -208,18 +208,18 @@ public class SimulatorDiscoverer extends DiscovererBase implements Discoverer, L
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void associateTemplatesToZone(long hostId, long dcId){
|
private void associateTemplatesToZone(long hostId, long dcId){
|
||||||
VMTemplateZoneVO tmpltZone;
|
VMTemplateZoneVO tmpltZone;
|
||||||
|
|
||||||
List<VMTemplateVO> allTemplates = _vmTemplateDao.listAll();
|
List<VMTemplateVO> allTemplates = _vmTemplateDao.listAll();
|
||||||
for (VMTemplateVO vt: allTemplates){
|
for (VMTemplateVO vt: allTemplates){
|
||||||
if (vt.isCrossZones()) {
|
if (vt.isCrossZones()) {
|
||||||
tmpltZone = _vmTemplateZoneDao.findByZoneTemplate(dcId, vt.getId());
|
tmpltZone = _vmTemplateZoneDao.findByZoneTemplate(dcId, vt.getId());
|
||||||
if (tmpltZone == null) {
|
if (tmpltZone == null) {
|
||||||
VMTemplateZoneVO vmTemplateZone = new VMTemplateZoneVO(dcId, vt.getId(), new Date());
|
VMTemplateZoneVO vmTemplateZone = new VMTemplateZoneVO(dcId, vt.getId(), new Date());
|
||||||
_vmTemplateZoneDao.persist(vmTemplateZone);
|
_vmTemplateZoneDao.persist(vmTemplateZone);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -259,7 +259,7 @@ public class SimulatorDiscoverer extends DiscovererBase implements Discoverer, L
|
|||||||
public void processConnect(HostVO host, StartupCommand cmd, boolean forRebalance) throws ConnectionException {
|
public void processConnect(HostVO host, StartupCommand cmd, boolean forRebalance) throws ConnectionException {
|
||||||
|
|
||||||
/*if(forRebalance)
|
/*if(forRebalance)
|
||||||
return;
|
return;
|
||||||
if ( Host.Type.SecondaryStorage == host.getType() ) {
|
if ( Host.Type.SecondaryStorage == host.getType() ) {
|
||||||
List<VMTemplateVO> tmplts = _vmTemplateDao.listAll();
|
List<VMTemplateVO> tmplts = _vmTemplateDao.listAll();
|
||||||
for( VMTemplateVO tmplt : tmplts ) {
|
for( VMTemplateVO tmplt : tmplts ) {
|
||||||
@ -329,7 +329,7 @@ public class SimulatorDiscoverer extends DiscovererBase implements Discoverer, L
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean stop() {
|
public boolean stop() {
|
||||||
_resourceMgr.unregisterResourceStateAdapter(this.getClass().getSimpleName());
|
_resourceMgr.unregisterResourceStateAdapter(this.getClass().getSimpleName());
|
||||||
return super.stop();
|
return super.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ public class SimulatorSecondaryDiscoverer extends SecondaryStorageDiscoverer imp
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||||
_agentMgr.registerForHostEvents(this, true, false, false);
|
_agentMgr.registerForHostEvents(this, true, false, false);
|
||||||
_resourceMgr.registerResourceStateAdapter(this.getClass().getSimpleName(), this);
|
_resourceMgr.registerResourceStateAdapter(this.getClass().getSimpleName(), this);
|
||||||
return super.configure(name, params);
|
return super.configure(name, params);
|
||||||
}
|
}
|
||||||
@ -74,7 +74,7 @@ public class SimulatorSecondaryDiscoverer extends SecondaryStorageDiscoverer imp
|
|||||||
//for detecting SSVM dispatch
|
//for detecting SSVM dispatch
|
||||||
StartupCommand firstCmd = startup[0];
|
StartupCommand firstCmd = startup[0];
|
||||||
if (!(firstCmd instanceof StartupSecondaryStorageCommand)) {
|
if (!(firstCmd instanceof StartupSecondaryStorageCommand)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
host.setType(com.cloud.host.Host.Type.SecondaryStorageVM);
|
host.setType(com.cloud.host.Host.Type.SecondaryStorageVM);
|
||||||
@ -103,7 +103,7 @@ public class SimulatorSecondaryDiscoverer extends SecondaryStorageDiscoverer imp
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean stop() {
|
public boolean stop() {
|
||||||
_resourceMgr.unregisterResourceStateAdapter(this.getClass().getSimpleName());
|
_resourceMgr.unregisterResourceStateAdapter(this.getClass().getSimpleName());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,4 +118,3 @@ public class MockConfigurationVO {
|
|||||||
this.values = values;
|
this.values = values;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ public class MockVMVO implements MockVm{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getType() {
|
public String getType() {
|
||||||
return this.vmType;
|
return this.vmType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setState(State state) {
|
public void setState(State state) {
|
||||||
@ -124,7 +124,7 @@ public class MockVMVO implements MockVm{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setType(String type) {
|
public void setType(String type) {
|
||||||
this.vmType = type;
|
this.vmType = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -42,4 +42,3 @@ public interface MockVm {
|
|||||||
public void setVncPort(int vncPort);
|
public void setVncPort(int vncPort);
|
||||||
public long getId();
|
public long getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,16 +116,16 @@ public class MockConfigurationDaoImpl extends GenericDaoBase<MockConfigurationVO
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MockConfigurationVO findByNameBottomUP(Long dcId, Long podId, Long clusterId, Long hostId, String name) {
|
public MockConfigurationVO findByNameBottomUP(Long dcId, Long podId, Long clusterId, Long hostId, String name) {
|
||||||
Transaction txn = Transaction.currentTxn();
|
Transaction txn = Transaction.currentTxn();
|
||||||
StringBuilder search = new StringBuilder();
|
StringBuilder search = new StringBuilder();
|
||||||
Formatter formatter = new Formatter(search);
|
Formatter formatter = new Formatter(search);
|
||||||
formatter.format("select * from mockconfiguration where (name='%s') and ((data_center_id = %d and pod_id = %d and cluster_id = %d and host_id = %d)", name, dcId, podId, clusterId, hostId);
|
formatter.format("select * from mockconfiguration where (name='%s') and ((data_center_id = %d and pod_id = %d and cluster_id = %d and host_id = %d)", name, dcId, podId, clusterId, hostId);
|
||||||
formatter.format(" or (data_center_id = %d and pod_id = %d and cluster_id = %d and host_id is null)", dcId, podId, clusterId);
|
formatter.format(" or (data_center_id = %d and pod_id = %d and cluster_id = %d and host_id is null)", dcId, podId, clusterId);
|
||||||
formatter.format(" or (data_center_id = %d and pod_id = %d and cluster_id is null and host_id is null)", dcId, podId);
|
formatter.format(" or (data_center_id = %d and pod_id = %d and cluster_id is null and host_id is null)", dcId, podId);
|
||||||
formatter.format(" or (data_center_id = %d and pod_id is null and cluster_id is null and host_id is null)", dcId);
|
formatter.format(" or (data_center_id = %d and pod_id is null and cluster_id is null and host_id is null)", dcId);
|
||||||
formatter.format(" or (data_center_id is null and pod_id is null and cluster_id is null and host_id is null)) LIMIT 1");
|
formatter.format(" or (data_center_id is null and pod_id is null and cluster_id is null and host_id is null)) LIMIT 1");
|
||||||
|
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
try {
|
try {
|
||||||
String sql = search.toString();
|
String sql = search.toString();
|
||||||
pstmt = txn.prepareAutoCloseStatement(sql);
|
pstmt = txn.prepareAutoCloseStatement(sql);
|
||||||
@ -38,6 +38,7 @@
|
|||||||
<module>hypervisors/ovm</module>
|
<module>hypervisors/ovm</module>
|
||||||
<module>hypervisors/xen</module>
|
<module>hypervisors/xen</module>
|
||||||
<module>hypervisors/kvm</module>
|
<module>hypervisors/kvm</module>
|
||||||
|
<module>hypervisors/simulator</module>
|
||||||
<module>network-elements/elastic-loadbalancer</module>
|
<module>network-elements/elastic-loadbalancer</module>
|
||||||
<module>network-elements/ovs</module>
|
<module>network-elements/ovs</module>
|
||||||
<module>network-elements/nicira-nvp</module>
|
<module>network-elements/nicira-nvp</module>
|
||||||
@ -124,6 +125,17 @@
|
|||||||
<module>hypervisors/vmware</module>
|
<module>hypervisors/vmware</module>
|
||||||
</modules>
|
</modules>
|
||||||
</profile>
|
</profile>
|
||||||
|
<profile>
|
||||||
|
<id>kvm</id>
|
||||||
|
<activation>
|
||||||
|
<property>
|
||||||
|
<name>nonoss</name>
|
||||||
|
</property>
|
||||||
|
</activation>
|
||||||
|
<modules>
|
||||||
|
<module>hypervisors/simulator</module>
|
||||||
|
</modules>
|
||||||
|
</profile>
|
||||||
</profiles>
|
</profiles>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user