mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 11:52:28 +01:00
Bug 11522 - New agent manager
initialize simulator test case
This commit is contained in:
parent
88b863d6e3
commit
58fefd2891
@ -24,6 +24,7 @@ import com.cloud.agent.api.CheckHealthCommand;
|
||||
import com.cloud.agent.api.GetHostStatsAnswer;
|
||||
import com.cloud.agent.api.GetHostStatsCommand;
|
||||
import com.cloud.agent.api.HostStatsEntry;
|
||||
import com.cloud.agent.api.MaintainAnswer;
|
||||
import com.cloud.agent.api.PingTestCommand;
|
||||
import com.cloud.agent.api.PrepareForMigrationAnswer;
|
||||
import com.cloud.agent.api.PrepareForMigrationCommand;
|
||||
@ -349,7 +350,7 @@ public class MockAgentManagerImpl implements MockAgentManager {
|
||||
|
||||
|
||||
@Override
|
||||
public Answer MaintainCommand(com.cloud.agent.api.MaintainCommand cmd) {
|
||||
return new Answer(cmd);
|
||||
public MaintainAnswer MaintainCommand(com.cloud.agent.api.MaintainCommand cmd) {
|
||||
return new MaintainAnswer(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,6 +38,7 @@ import com.cloud.agent.api.AgentControlCommand;
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.Command;
|
||||
import com.cloud.agent.api.StartupCommand;
|
||||
import com.cloud.agent.api.StartupRoutingCommand;
|
||||
import com.cloud.agent.manager.MockAgentManager;
|
||||
import com.cloud.agent.manager.MockStorageManager;
|
||||
import com.cloud.agent.manager.SimulatorManager;
|
||||
@ -66,7 +67,7 @@ import com.cloud.utils.component.Inject;
|
||||
*
|
||||
*/
|
||||
@Local(value = Discoverer.class)
|
||||
public class SimulatorDiscoverer extends DiscovererBase implements Discoverer, Listener {
|
||||
public class SimulatorDiscoverer extends DiscovererBase implements Discoverer, Listener, ResourceStateAdapter {
|
||||
private static final Logger s_logger = Logger
|
||||
.getLogger(SimulatorDiscoverer.class);
|
||||
|
||||
@ -78,6 +79,7 @@ public class SimulatorDiscoverer extends DiscovererBase implements Discoverer, L
|
||||
@Inject AgentManager _agentMgr = null;
|
||||
@Inject MockAgentManager _mockAgentMgr = null;
|
||||
@Inject MockStorageManager _mockStorageMgr = null;
|
||||
@Inject ResourceManager _resourceMgr;
|
||||
|
||||
/**
|
||||
* Finds ServerResources of an in-process simulator
|
||||
@ -243,7 +245,8 @@ public class SimulatorDiscoverer extends DiscovererBase implements Discoverer, L
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||
super.configure(name, params);
|
||||
_agentMgr.registerForHostEvents(this, true, false, false);
|
||||
_agentMgr.registerForHostEvents(this, true, false, false);
|
||||
_resourceMgr.registerResourceStateAdapter(this.getClass().getSimpleName(), this);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -304,5 +307,42 @@ public class SimulatorDiscoverer extends DiscovererBase implements Discoverer, L
|
||||
public boolean processTimeout(long agentId, long seq) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HostVO createHostVOForConnectedAgent(HostVO host,
|
||||
StartupCommand[] cmd) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HostVO createHostVOForDirectConnectAgent(HostVO host,
|
||||
StartupCommand[] startup, ServerResource resource,
|
||||
Map<String, String> details, List<String> hostTags) {
|
||||
StartupCommand firstCmd = startup[0];
|
||||
if (!(firstCmd instanceof StartupRoutingCommand)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
StartupRoutingCommand ssCmd = ((StartupRoutingCommand) firstCmd);
|
||||
if (ssCmd.getHypervisorType() != HypervisorType.Simulator) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return _resourceMgr.fillRoutingHostVO(host, ssCmd, HypervisorType.Simulator, details, hostTags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeleteHostAnswer deleteHost(HostVO host, boolean isForced,
|
||||
boolean isForceDeleteStorage) throws UnableDeleteHostException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stop() {
|
||||
_resourceMgr.unregisterResourceStateAdapter(this.getClass().getSimpleName());
|
||||
return super.stop();
|
||||
}
|
||||
|
||||
}
|
||||
0
tools/testClient/resourceMgrTest/__init__.py
Executable file
0
tools/testClient/resourceMgrTest/__init__.py
Executable file
73
tools/testClient/resourceMgrTest/setup.py
Executable file
73
tools/testClient/resourceMgrTest/setup.py
Executable file
@ -0,0 +1,73 @@
|
||||
'''
|
||||
Created on Oct 18, 2011
|
||||
|
||||
@author: frank
|
||||
'''
|
||||
from optparse import OptionParser
|
||||
from configGenerator import *
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = OptionParser()
|
||||
parser.add_option('-o', '--output', action='store', default='./setup.conf', dest='output', help='the path where the json config file generated')
|
||||
parser.add_option('-m', '--mshost', dest='mshost', help='hostname/ip of management server', action='store')
|
||||
|
||||
(opts, args) = parser.parse_args()
|
||||
mandatories = ['mshost']
|
||||
for m in mandatories:
|
||||
if not opts.__dict__[m]:
|
||||
parser.error("mandatory option - " + m +" missing")
|
||||
|
||||
zs = cloudstackConfiguration()
|
||||
|
||||
#Define Zone
|
||||
z = zone()
|
||||
z.dns1 = "8.8.8.8"
|
||||
z.dns2 = "4.4.4.4"
|
||||
z.internaldns1 = "192.168.110.254"
|
||||
z.internaldns2 = "192.168.110.253"
|
||||
z.name = "testZone"
|
||||
z.networktype = 'Basic'
|
||||
|
||||
#Define SecondaryStorage
|
||||
ss = secondaryStorage()
|
||||
ss.url ="nfs://172.16.15.32/export/share/secondary"
|
||||
z.secondaryStorages.append(ss)
|
||||
|
||||
p = pod()
|
||||
p.name = "POD-1"
|
||||
p.gateway = "10.223.64.1"
|
||||
p.netmask = "255.255.254.0"
|
||||
p.startip = "10.223.64.50"
|
||||
p.endip = "10.223.64.60"
|
||||
|
||||
ip = iprange()
|
||||
ip.vlan="untagged"
|
||||
ip.gateway = p.gateway
|
||||
ip.netmask = p.netmask
|
||||
ip.startip = "10.223.64.70"
|
||||
ip.endip = "10.223.64.220"
|
||||
p.guestIpRanges.append(ip)
|
||||
|
||||
c = cluster()
|
||||
c.clustername = "CLUSTER-1"
|
||||
c.clustertype = "CloudManaged"
|
||||
c.hypervisor = "Simulator"
|
||||
p.clusters.append(c)
|
||||
|
||||
z.pods.append(p)
|
||||
zs.zones.append(z)
|
||||
|
||||
'''Add one mgt server'''
|
||||
mgt = managementServer()
|
||||
mgt.mgtSvrIp = opts.mshost
|
||||
zs.mgtSvr.append(mgt)
|
||||
|
||||
'''Add a database'''
|
||||
db = dbServer()
|
||||
db.dbSvr = opts.mshost
|
||||
db.user = "root"
|
||||
db.passwd = ""
|
||||
zs.dbSvr = db
|
||||
|
||||
generate_setup_config(zs,opts.output)
|
||||
|
||||
22
tools/testClient/resourceMgrTest/testDeploy100Host.py
Executable file
22
tools/testClient/resourceMgrTest/testDeploy100Host.py
Executable file
@ -0,0 +1,22 @@
|
||||
'''
|
||||
Created on Oct 18, 2011
|
||||
|
||||
@author: frank
|
||||
'''
|
||||
from cloudstackTestCase import *
|
||||
from cloudstackAPI import *
|
||||
import uuid
|
||||
|
||||
class TestDeploy100Hosts(cloudstackTestCase):
|
||||
def test_deploy100Hosts(self):
|
||||
apiClient = self.testClient.getApiClient()
|
||||
addHostCmd = addHost.addHostCmd()
|
||||
addHostCmd.hypervisor = "simulator"
|
||||
addHostCmd.clusterid = 1
|
||||
addHostCmd.zoneid = 1
|
||||
addHostCmd.podid = 1
|
||||
addHostCmd.url = "http://sim/10.223.63.1"
|
||||
addHostCmd.username = "placeholder"
|
||||
addHostCmd.password = "placeholder"
|
||||
addHostResponce = apiClient.addHost(addHostCmd)
|
||||
return addHostResponce.id
|
||||
Loading…
x
Reference in New Issue
Block a user