mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-11-04 00:02:37 +01:00 
			
		
		
		
	Reviving the simulator
* SSVM to act as a direct connect agent * Storage Resources handle SSVM commands * create-schema.sql already has simulator_network_label. removing the label from create-schema-simulator.sql
This commit is contained in:
		
							parent
							
								
									c3903673bc
								
							
						
					
					
						commit
						18f865fc3e
					
				
							
								
								
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@ -16,6 +16,7 @@ dist/
 | 
			
		||||
cloud-*.tar.bz2
 | 
			
		||||
*.log
 | 
			
		||||
*.pyc
 | 
			
		||||
*.cfg
 | 
			
		||||
build.number
 | 
			
		||||
api.log.*.gz
 | 
			
		||||
cloud.log.*.*
 | 
			
		||||
@ -23,4 +24,4 @@ unittest
 | 
			
		||||
deps/cloud.userlibraries
 | 
			
		||||
.DS_Store
 | 
			
		||||
.idea
 | 
			
		||||
*.iml
 | 
			
		||||
*.iml
 | 
			
		||||
 | 
			
		||||
@ -29,6 +29,7 @@ import com.cloud.agent.api.MaintainAnswer;
 | 
			
		||||
import com.cloud.agent.api.PingTestCommand;
 | 
			
		||||
import com.cloud.agent.api.PrepareForMigrationAnswer;
 | 
			
		||||
import com.cloud.agent.api.PrepareForMigrationCommand;
 | 
			
		||||
import com.cloud.agent.api.StartupCommand;
 | 
			
		||||
import com.cloud.dc.dao.HostPodDao;
 | 
			
		||||
import com.cloud.host.Host.Type;
 | 
			
		||||
import com.cloud.resource.AgentResourceBase;
 | 
			
		||||
@ -264,18 +265,15 @@ public class MockAgentManagerImpl implements MockAgentManager {
 | 
			
		||||
                    params.put("guid", this.guid);
 | 
			
		||||
                    storageResource.configure("secondaryStorage", params);
 | 
			
		||||
                    storageResource.start();
 | 
			
		||||
                    StartupCommand[] cmds = storageResource.initialize();
 | 
			
		||||
                    _resourceMgr.createHostVOForConnectedAgent(cmds);
 | 
			
		||||
                    _resources.put(this.guid, storageResource);
 | 
			
		||||
                } catch (ConfigurationException e) {
 | 
			
		||||
                    s_logger.debug("Failed to load secondary storage resource: " + e.toString());
 | 
			
		||||
                    return;
 | 
			
		||||
                }
 | 
			
		||||
                Map<String, String> details = new HashMap<String, String>();
 | 
			
		||||
                
 | 
			
		||||
                _resourceMgr.addHost(this.dcId, storageResource, Type.SecondaryStorageVM, details);
 | 
			
		||||
                _resources.put(this.guid, storageResource);
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
            }            
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
 | 
			
		||||
@ -18,6 +18,7 @@ import com.cloud.agent.api.ReadyAnswer;
 | 
			
		||||
import com.cloud.agent.api.ReadyCommand;
 | 
			
		||||
import com.cloud.agent.api.StartupCommand;
 | 
			
		||||
import com.cloud.agent.api.StartupSecondaryStorageCommand;
 | 
			
		||||
import com.cloud.agent.api.StartupStorageCommand;
 | 
			
		||||
import com.cloud.agent.api.storage.ssCommand;
 | 
			
		||||
import com.cloud.agent.manager.SimulatorManager;
 | 
			
		||||
import com.cloud.agent.manager.SimulatorManager.AgentType;
 | 
			
		||||
@ -67,7 +68,7 @@ public class AgentStorageResource extends AgentResourceBase implements Secondary
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public StartupCommand[] initialize() {
 | 
			
		||||
        StartupSecondaryStorageCommand cmd = new StartupSecondaryStorageCommand();
 | 
			
		||||
    	StartupStorageCommand cmd = new StartupStorageCommand();
 | 
			
		||||
 | 
			
		||||
        cmd.setPrivateIpAddress(agentHost.getPrivateIpAddress());
 | 
			
		||||
        cmd.setPrivateNetmask(agentHost.getPrivateNetMask());
 | 
			
		||||
 | 
			
		||||
@ -6,4 +6,4 @@ DBHOST=localhost
 | 
			
		||||
AGENTLOGDIR=logs
 | 
			
		||||
AGENTLOG=logs/agent.log
 | 
			
		||||
MSMNTDIR=/mnt
 | 
			
		||||
COMPONENTS-SPEC=components-premium.xml
 | 
			
		||||
COMPONENTS-SPEC=components-simulator.xml
 | 
			
		||||
 | 
			
		||||
@ -103,7 +103,3 @@ CREATE TABLE `cloud`.`mocksecurityrules` (
 | 
			
		||||
  INDEX `i_mocksecurityrules__vmid`(`vmid`),
 | 
			
		||||
  INDEX `i_mocksecurityrules__hostid`(`hostid`)
 | 
			
		||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
-- Some alterations reqd for the simulator to work with a regular DB
 | 
			
		||||
ALTER TABLE `cloud`.`physical_network_traffic_types` ADD COLUMN `simulator_network_label` varchar(255) COMMENT  'The name labels needed for identifying the simulator'
 | 
			
		||||
 | 
			
		||||
@ -142,6 +142,8 @@ class deployDataCenters():
 | 
			
		||||
            self.createVlanIpRanges("Advanced", ipranges, zoneId, networkId=networkId)
 | 
			
		||||
 | 
			
		||||
    def configureProviders(self, providers, zoneid, networktype):
 | 
			
		||||
        if providers == None:
 | 
			
		||||
            return
 | 
			
		||||
        for prov in providers:
 | 
			
		||||
            pnets = listPhysicalNetworks.listPhysicalNetworksCmd()
 | 
			
		||||
            pnets.zoneid = zoneid
 | 
			
		||||
 | 
			
		||||
@ -15,22 +15,22 @@ check.pod.cidrs=true
 | 
			
		||||
secstorage.allowed.internal.sites=10.147.28.0/24
 | 
			
		||||
[environment]
 | 
			
		||||
dns=10.147.28.6
 | 
			
		||||
mshost=localhost
 | 
			
		||||
mshost=10.147.29.110
 | 
			
		||||
database=localhost
 | 
			
		||||
hypervisor=XenServer
 | 
			
		||||
[cloudstack]
 | 
			
		||||
guest.vlan=675-679
 | 
			
		||||
guest.vlan=670-674
 | 
			
		||||
#pod configuration
 | 
			
		||||
private.gateway=10.147.29.1
 | 
			
		||||
private.pod.startip=10.147.29.150
 | 
			
		||||
private.pod.endip=10.147.29.159
 | 
			
		||||
private.pod.startip=10.147.29.140
 | 
			
		||||
private.pod.endip=10.147.29.149
 | 
			
		||||
#public vlan range
 | 
			
		||||
public.gateway=10.147.31.1
 | 
			
		||||
public.vlan=31
 | 
			
		||||
public.vlan.startip=10.147.31.150
 | 
			
		||||
public.vlan.endip=10.147.31.159
 | 
			
		||||
public.vlan.startip=10.147.31.140
 | 
			
		||||
public.vlan.endip=10.147.31.149
 | 
			
		||||
#hosts
 | 
			
		||||
host=10.147.29.57
 | 
			
		||||
host=10.147.29.56
 | 
			
		||||
#pools
 | 
			
		||||
pool=nfs://10.147.28.6:/export/home/prasanna/budhgaya
 | 
			
		||||
secondary=nfs://10.147.28.6:/export/home/prasanna/sstor
 | 
			
		||||
pool=nfs://10.147.28.6:/export/home/prasanna/taxila
 | 
			
		||||
secondary=nfs://10.147.28.6:/export/home/prasanna/secondary
 | 
			
		||||
 | 
			
		||||
@ -8,106 +8,87 @@
 | 
			
		||||
############################################################
 | 
			
		||||
'''
 | 
			
		||||
 | 
			
		||||
from ConfigParser import SafeConfigParser
 | 
			
		||||
from optparse import OptionParser
 | 
			
		||||
from configGenerator import *
 | 
			
		||||
import random
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def getGlobalSettings():
 | 
			
		||||
    global_settings = {'expunge.delay': '60',
 | 
			
		||||
                       'expunge.interval': '60',
 | 
			
		||||
                       'expunge.workers': '3',
 | 
			
		||||
                       'workers': '10',
 | 
			
		||||
                       'use.user.concentrated.pod.allocation': 'false',
 | 
			
		||||
                       'vm.allocation.algorithm': 'random',
 | 
			
		||||
                       'vm.op.wait.interval': '5',
 | 
			
		||||
                       'guest.domain.suffix': 'sandbox.simulator',
 | 
			
		||||
                       'instance.name': 'SIMQA',
 | 
			
		||||
                       'direct.agent.load.size': '1000',
 | 
			
		||||
                       'default.page.size': '10000',
 | 
			
		||||
                       'linkLocalIp.nums': '10',
 | 
			
		||||
                       'check.pod.cidrs': 'false',
 | 
			
		||||
                      }
 | 
			
		||||
    for k, v in global_settings.iteritems():
 | 
			
		||||
def getGlobalSettings(config):
 | 
			
		||||
   for k, v in dict(config.items('globals')).iteritems():
 | 
			
		||||
        cfg = configuration()
 | 
			
		||||
        cfg.name = k
 | 
			
		||||
        cfg.value = v
 | 
			
		||||
        yield cfg
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def describeResources(dbnode='localhost', mshost='localhost'):
 | 
			
		||||
def describeResources(config):
 | 
			
		||||
    zs = cloudstackConfiguration()
 | 
			
		||||
    numberofpods = 1
 | 
			
		||||
 | 
			
		||||
    clustersPerPod = 10
 | 
			
		||||
    hostsPerCluster = 2
 | 
			
		||||
 | 
			
		||||
    z = zone()
 | 
			
		||||
    z.dns1 = '4.2.2.2'
 | 
			
		||||
    z.dns2 = '10.223.110.254'
 | 
			
		||||
    z.internaldns1 = '10.147.28.6'
 | 
			
		||||
    z.internaldns2 = '10.223.110.254'
 | 
			
		||||
    z.name = 'Sandbox-Simulator'
 | 
			
		||||
    z.dns1 = config.get('environment', 'dns')
 | 
			
		||||
    z.internaldns1 = config.get('environment', 'dns')
 | 
			
		||||
    z.name = 'Sandbox-%s'%(config.get('environment', 'hypervisor'))
 | 
			
		||||
    z.networktype = 'Advanced'
 | 
			
		||||
    z.guestcidraddress = '10.1.1.0/24'
 | 
			
		||||
    z.vlan='100-300'
 | 
			
		||||
 | 
			
		||||
    prov = provider()
 | 
			
		||||
    prov.vlan = config.get('cloudstack','guest.vlan')
 | 
			
		||||
    z.providers.append(prov)
 | 
			
		||||
 | 
			
		||||
    p = pod()
 | 
			
		||||
    p.name = 'POD0'
 | 
			
		||||
    p.gateway = '172.1.1.1'
 | 
			
		||||
    p.startip = '172.1.1.2'
 | 
			
		||||
    p.endip = '172.1.1.200'
 | 
			
		||||
    p.gateway = config.get('cloudstack', 'private.gateway')
 | 
			
		||||
    p.startip =  config.get('cloudstack', 'private.pod.startip')
 | 
			
		||||
    p.endip =  config.get('cloudstack', 'private.pod.endip')
 | 
			
		||||
    p.netmask = '255.255.255.0'
 | 
			
		||||
 | 
			
		||||
    v = iprange()
 | 
			
		||||
    v.vlan = '30'
 | 
			
		||||
    v.gateway = '172.1.2.1'
 | 
			
		||||
    v.startip = '172.1.2.2'
 | 
			
		||||
    v.endip = '172.1.2.200'
 | 
			
		||||
    v.gateway = config.get('cloudstack', 'public.gateway')
 | 
			
		||||
    v.startip = config.get('cloudstack', 'public.vlan.startip')
 | 
			
		||||
    v.endip = config.get('cloudstack', 'public.vlan.endip') 
 | 
			
		||||
    v.netmask = '255.255.255.0'
 | 
			
		||||
    v.vlan = config.get('cloudstack', 'public.vlan')
 | 
			
		||||
    z.ipranges.append(v)
 | 
			
		||||
 | 
			
		||||
    curhost = 1
 | 
			
		||||
    for i in range(1, clustersPerPod + 1):
 | 
			
		||||
        c = cluster()
 | 
			
		||||
        c.clustername = 'POD1-CLUSTER' + str(i)
 | 
			
		||||
        c.hypervisor = 'Simulator'
 | 
			
		||||
        c.clustertype = 'CloudManaged'
 | 
			
		||||
    c = cluster()
 | 
			
		||||
    c.clustername = 'C0'
 | 
			
		||||
    c.hypervisor = config.get('environment', 'hypervisor')
 | 
			
		||||
    c.clustertype = 'CloudManaged'
 | 
			
		||||
 | 
			
		||||
        for j in range(1, hostsPerCluster + 1):
 | 
			
		||||
            h = host()
 | 
			
		||||
            h.username = 'root'
 | 
			
		||||
            h.password = 'password'
 | 
			
		||||
            h.url = 'http://sim/test-%d'%(curhost)
 | 
			
		||||
            c.hosts.append(h)
 | 
			
		||||
            curhost = curhost + 1
 | 
			
		||||
    h = host()
 | 
			
		||||
    h.username = 'root'
 | 
			
		||||
    h.password = 'password'
 | 
			
		||||
    h.url = 'http://%s'%(config.get('cloudstack', 'host'))
 | 
			
		||||
    c.hosts.append(h)
 | 
			
		||||
 | 
			
		||||
        ps = primaryStorage()
 | 
			
		||||
        ps.name = 'spool'+str(i)
 | 
			
		||||
        ps.url = 'nfs://172.16.24.32/export/path/'+str(i)
 | 
			
		||||
        c.primaryStorages.append(ps)
 | 
			
		||||
        p.clusters.append(c)
 | 
			
		||||
    ps = primaryStorage()
 | 
			
		||||
    ps.name = 'PS0'
 | 
			
		||||
    ps.url = config.get('cloudstack', 'pool')
 | 
			
		||||
    c.primaryStorages.append(ps)
 | 
			
		||||
 | 
			
		||||
    p.clusters.append(c)
 | 
			
		||||
    z.pods.append(p)
 | 
			
		||||
 | 
			
		||||
    secondary = secondaryStorage()
 | 
			
		||||
    secondary.url = 'nfs://172.16.25.32/secondary/path'
 | 
			
		||||
 | 
			
		||||
    z.pods.append(p)
 | 
			
		||||
    z.ipranges.append(v)
 | 
			
		||||
    secondary.url = config.get('cloudstack', 'secondary')
 | 
			
		||||
    z.secondaryStorages.append(secondary)
 | 
			
		||||
 | 
			
		||||
    '''Add zone'''
 | 
			
		||||
    zs.zones.append(z)
 | 
			
		||||
 | 
			
		||||
    '''Add mgt server'''
 | 
			
		||||
    mgt = managementServer()
 | 
			
		||||
    mgt.mgtSvrIp = mshost
 | 
			
		||||
    mgt.mgtSvrIp = config.get('environment', 'mshost')
 | 
			
		||||
    zs.mgtSvr.append(mgt)
 | 
			
		||||
 | 
			
		||||
    '''Add a database'''
 | 
			
		||||
    db = dbServer()
 | 
			
		||||
    db.dbSvr = opts.dbnode
 | 
			
		||||
    db.dbSvr = config.get('environment', 'database')
 | 
			
		||||
    zs.dbSvr = db
 | 
			
		||||
 | 
			
		||||
    '''Add some configuration'''
 | 
			
		||||
    [zs.globalConfig.append(cfg) for cfg in getGlobalSettings()]
 | 
			
		||||
    [zs.globalConfig.append(cfg) for cfg in getGlobalSettings(config)]
 | 
			
		||||
 | 
			
		||||
    ''''add loggers'''
 | 
			
		||||
    testClientLogger = logger()
 | 
			
		||||
@ -125,10 +106,16 @@ def describeResources(dbnode='localhost', mshost='localhost'):
 | 
			
		||||
 | 
			
		||||
if __name__ == '__main__':
 | 
			
		||||
    parser = OptionParser()
 | 
			
		||||
    parser.add_option('-o', '--output', action='store', default='./sandbox.cfg', dest='output', help='the path where the json config file generated')
 | 
			
		||||
    parser.add_option('-d', '--dbnode', dest='dbnode', help='hostname/ip of the database node', action='store')
 | 
			
		||||
    parser.add_option('-m', '--mshost', dest='mshost', help='hostname/ip of management server', action='store')
 | 
			
		||||
    parser.add_option('-i', '--input', action='store', default='setup.properties', \
 | 
			
		||||
                      dest='input', help='file containing environment setup information')
 | 
			
		||||
    parser.add_option('-o', '--output', action='store', default='./sandbox.cfg', \
 | 
			
		||||
                      dest='output', help='path where environment json will be generated')
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    (opts, args) = parser.parse_args()
 | 
			
		||||
    cfg = describeResources(opts.dbnode, opts.mshost)
 | 
			
		||||
 | 
			
		||||
    cfg_parser = SafeConfigParser()
 | 
			
		||||
    cfg_parser.read(opts.input)
 | 
			
		||||
 | 
			
		||||
    cfg = describeResources(cfg_parser)
 | 
			
		||||
    generate_setup_config(cfg, opts.output)
 | 
			
		||||
 | 
			
		||||
@ -1,9 +1,4 @@
 | 
			
		||||
#!/usr/bin/env python
 | 
			
		||||
try:
 | 
			
		||||
    import unittest2 as unittest
 | 
			
		||||
except ImportError:
 | 
			
		||||
    import unittest
 | 
			
		||||
 | 
			
		||||
import random
 | 
			
		||||
import hashlib
 | 
			
		||||
from cloudstackTestCase import *
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user