Ejemplo n.º 1
0
    def addGTPe(self):
        bitmask = '0b'
        if self.useEFEDs:
            bitmask += self.FEDConfig.nSlices * '1'
            partitionId = 3
        elif self.useFMMForDAQ2:
            bitmask += '1'
            partitionId = 0
        else:
            bitmask += '1000'
            partitionId = 0

        ## convert '0b1000' into '0x8' etc.
        enableMask = str(hex(int(bitmask, 2)))
        index = 0
        fragmentname = 'GTPe.xml'
        GTPE = elementFromFile(self.fragmentdir + fragmentname)

        gtpens = self.xdaqappns % 'd2s::GTPeController'
        prop = GTPE.find(
            QN(self.xdaqns, 'Application').text + '/' +
            QN(gtpens, 'properties').text)
        prop.find(QN(gtpens, 'daqPartitionId').text).text = str(partitionId)
        prop.find(QN(gtpens,
                     'detPartitionEnableMask').text).text = (str(enableMask))
        prop.find(QN(gtpens, 'triggerRate').text).text = str(100.)
        if self.verbose > 0: print 70 * '-'
        if self.verbose > 0:
            print('GTPe partitionId %d, enableMask %s (%s)' %
                  (partitionId, enableMask, bitmask))

        self.config.append(GTPE)
Ejemplo n.º 2
0
    def addFMM(self, cards):
        fragmentname = 'FMM_context.xml'
        FMM_context = elementFromFile(self.fragmentdir + fragmentname)

        fmmns = self.xdaqappns % "tts::FMMController"
        fmm_config = FMM_context.find(
            QN(self.xdaqns, 'Application').text + '/' +
            QN(fmmns, 'properties').text + '/' + QN(fmmns, 'config').text)
        fmm_config.attrib[QN(self.soapencns,
                             'arrayType').text] = ("xsd:ur-type[%d]" %
                                                   (len(cards)))

        fmm_card_fragment = elementFromFile(self.fragmentdir +
                                            'FMM_card_eFED.xml')
        for n, (geoslot, inputmask, inputlabels, outputlabels,
                label) in enumerate(cards):
            cmm_card = deepcopy(fmm_card_fragment)
            cmm_card.attrib[QN(self.soapencns, 'position').text] = '[%d]' % n
            cmm_card.find(QN(fmmns, 'geoslot').text).text = (str(geoslot))
            cmm_card.find(QN(fmmns,
                             'inputEnableMask').text).text = (str(inputmask))
            cmm_card.find(QN(fmmns,
                             'inputLabels').text).text = (str(inputlabels))
            cmm_card.find(QN(fmmns,
                             'outputLabels').text).text = (str(outputlabels))
            cmm_card.find(QN(fmmns, 'label').text).text = (str(label))
            fmm_config.append(cmm_card)
        self.config.append(FMM_context)
Ejemplo n.º 3
0
    def addI2OProtocol(self):
        i2ons = "http://xdaq.web.cern.ch/xdaq/xsd/2004/I2OConfiguration-30"
        prot = Element(QN(i2ons, 'protocol').text)

        ## Add EVM:
        prot.append(
            Element(
                QN(i2ons, 'target').text, {
                    'class': '%s::EVM' % self.evbns,
                    'instance': "0",
                    "tid": "1"
                }))
        ## Add RUs:
        ru_instances_to_add = [n for n in range(self.nrus)]
        if self.evbns == 'evb': ru_instances_to_add.remove(0)
        for n in ru_instances_to_add:
            prot.append(
                Element(
                    QN(i2ons, 'target').text, {
                        'class': '%s::RU' % self.evbns,
                        'instance': "%d" % n,
                        'tid': '%d' % (RU_STARTING_TID + n)
                    }))
        ## Add BUs:
        for n in xrange(self.nbus):
            prot.append(
                Element(
                    QN(i2ons, 'target').text, {
                        'class': '%s::BU' % self.evbns,
                        'instance': "%d" % n,
                        'tid': '%d' % (BU_STARTING_TID + n)
                    }))

        self.config.append(prot)
Ejemplo n.º 4
0
    def makeEFED(self, feds):
        startid = 50
        fragmentname = 'eFED_context.xml'
        eFED_context = elementFromFile(self.fragmentdir + fragmentname)

        efedns = self.xdaqappns % "d2s::FEDEmulator"
        eFED_app_fragment = elementFromFile(self.fragmentdir +
                                            'eFED_application.xml')
        for n, (fedid, slot) in enumerate(feds):
            eFED_app = deepcopy(eFED_app_fragment)
            eFED_app.set('id', str(50 + n))
            eFED_app.set('instance', str(self.eFED_app_instance))
            eFED_app.find(
                QN(efedns, 'properties').text + '/' +
                QN(efedns, 'slot').text).text = str(slot)
            eFED_app.find(
                QN(efedns, 'properties').text + '/' +
                QN(efedns, 'FedSourceId').text).text = str(fedid)

            eFED_context.append(eFED_app)
            self.eFED_app_instance += 1

        eFED_context.set(
            'url',
            eFED_context.get('url') %
            (self.eFED_crate_counter, self.eFED_crate_counter))

        self.eFED_crate_counter += 1
        return eFED_context
Ejemplo n.º 5
0
    def removePropertyInApp(self, application, prop_name):
        try:
            ## Assume here that there is only one element, which
            ## is the properties
            properties = application[0]
            if not 'properties' in properties.tag:
                raise RuntimeError(
                    'Could not identify properties of %s'
                    'application in %s context.' %
                    (application.attrib['class'], context.attrib['url']))
            ## Extract namespace
            appns = re.match(r'\{(.*?)\}properties', properties.tag).group(1)
        except IndexError:  ## i.e. application[0] didn't work
            raise RuntimeError(
                'Application %s in context %s does not have'
                'properties.' %
                (application.attrib['class'], context.attrib['url']))

        prop = application.find(
            QN(appns, 'properties').text + '/' + QN(appns, prop_name).text)
        try:
            properties.remove(prop)
        except AssertionError:
            printError('Property %s of application %s not found.' %
                       (prop_name, application.attrib['class']),
                       instance=self)
            return
        except Exception, e:
            raise e
Ejemplo n.º 6
0
def propertyInApp(application, prop_name, prop_value=None):
    try:
        ## Assume here that there is only one element, which
        ## is the properties
        properties = application[0]
        if not 'properties' in properties.tag:
            raise RuntimeError(
                'Could not identify properties of %s application'
                'in %s context.' %
                (application.attrib['class'], context.attrib['url']))
        ## Extract namespace
        appns = re.match(r'\{(.*?)\}properties', properties.tag).group(1)
    except IndexError:  ## i.e. app[0] didn't work
        raise RuntimeError(
            'Application %s in context %s does not have'
            'properties.' %
            (application.attrib['class'], context.attrib['url']))

    prop = application.find(
        QN(appns, 'properties').text + '/' + QN(appns, prop_name).text)
    try:
        if prop_value is not None:  # if value is given, set it
            prop.text = str(prop_value)
            return True
        else:  # if not, return the existing value
            return prop.text
    except AttributeError:
        raise KeyError('Property %s of application %s '
                       'not found.' % (prop_name, application.attrib['class']))
Ejemplo n.º 7
0
    def makeServer(self, index):
        fragmentname = 'msio/server_context.xml'
        context = elementFromFile(os.path.join(self.fragmentdir, fragmentname))

        ## Add policy
        addFragmentFromFile(target=context,
                            filename=os.path.join(
                                self.fragmentdir,
                                'msio/server_policy_%s.xml' % (self.ptprot)),
                            index=0)
        ## Add pt application
        addFragmentFromFile(
            target=context,
            filename=os.path.join(
                self.fragmentdir,
                'msio/server_%s_application.xml' % (self.ptprot)),
            index=2)  ## add after the two endpoints

        ## Configure IBV application:
        if self.setDynamicIBVConfig:
            self.configureIBVApplication(context, self.BUIBVConfig)

        ## Add corresponding module
        module = Element(QN(self.xdaqns, 'Module').text)
        module.text = "$XDAQ_ROOT/lib/libpt%s.so" % self.ptprot
        context.insert(3, module)

        ## Add corresponding module
        module = Element(QN(self.xdaqns, 'Module').text)
        module.text = "$XDAQ_ROOT/lib/libxdaq2rc.so"
        context.insert(4, module)

        ## Server application
        bu_app = elementFromFile(filename=os.path.join(
            self.fragmentdir, 'msio/server_application.xml'))
        context.insert(5, bu_app)
        bu_app.set('instance', str(index))

        ## Add corresponding module
        module = Element(QN(self.xdaqns, 'Module').text)
        if self.evbns == 'msio':
            module.text = "$XDAQ_ROOT/lib/libmstreamio2g.so"
        context.insert(6, module)

        ## Set instance and url
        for app in context.findall(QN(self.xdaqns, 'Endpoint').text):
            if 'BU%d' in app.attrib['hostname']:
                app.set('hostname', app.get('hostname') % index)
            if 'BU%d' in app.attrib['port']:
                app.set('port', app.get('port') % index)
        context.set('url', context.get('url') % (index, index))

        ## Set instance and url
        for app in context.findall(QN(self.xdaqns, 'Application').text):
            if app.attrib['class'] != "%s::BU" % self.evbns: continue
            app.set('instance', str(index))
            break

        return context
Ejemplo n.º 8
0
	def printFerolParameter(self, param_name):
		for context in self.contexts:
			if not 'FEROLCONTROLLER' in context.attrib['url']: continue
			param = context.find(QN(self.xcns,'Application').text+'/'+QN(self.ferolns,'properties').text+'/'+QN(self.ferolns,param_name).text)
			try:
				print context.attrib['url'], param_name, param.text
			except AttributeError:
				raise KeyError('Ferol parameter '+param_name+' not found')
Ejemplo n.º 9
0
    def makeEVM(self):
        index = 0
        fragmentname = 'EVM/EVM_context.xml'
        context = elementFromFile(os.path.join(self.fragmentdir, fragmentname))

        ## Add policy
        addFragmentFromFile(
            target=context,
            filename=os.path.join(
                self.fragmentdir,
                'EVM/msio/EVM_policy_msio_%s.xml' % (self.ptprot)),
            index=0)
        ## Add builder network endpoint
        context.insert(
            3,
            Element(
                QN(self.xdaqns, 'Endpoint').text, {
                    'protocol': '%s' % self.ptprot,
                    'service': "i2o",
                    'hostname': 'EVM%d_I2O_HOST_NAME' % (index),
                    'port': 'EVM%d_I2O_PORT' % (index),
                    'network': 'infini'
                }))
        ## Add builder network pt application
        addFragmentFromFile(
            target=context,
            filename=os.path.join(
                self.fragmentdir,
                'EVM/msio/EVM_%s_application_msio.xml' % (self.ptprot)),
            index=4)  ## add after the two endpoints

        ## Configure IBV application:
        if self.setDynamicIBVConfig:
            self.configureIBVApplication(context, self.EVMIBVConfig)

        ## Add corresponding module
        module = Element(QN(self.xdaqns, 'Module').text)
        module.text = "$XDAQ_ROOT/lib/libpt%s.so" % self.ptprot
        context.insert(5, module)

        ## Add corresponding module
        module = Element(QN(self.xdaqns, 'Module').text)
        module.text = "$XDAQ_ROOT/lib/libxdaq2rc.so"
        context.insert(6, module)

        ## Set instance and url
        for app in context.findall(QN(self.xdaqns, 'Application').text):
            if app.attrib['class'] != "%s::EVM" % self.evbns: continue
            app.set('instance', str(index))
            break
        context.set('url', context.get('url') % (index, index))

        ## Change poolName in EVM application:
        self.setPropertyInAppInContext(context, 'gevb2g::EVM', 'poolName',
                                       'sibv')

        return context
Ejemplo n.º 10
0
    def makeBU(self, index):
        fragmentname = 'BU/BU_context.xml'
        bu_context = elementFromFile(self.fragmentdir + fragmentname)

        ## Add policy
        addFragmentFromFile(target=bu_context,
                            filename=self.fragmentdir +
                            ('/BU/%s/BU_policy_%s.xml' %
                             (self.evbns, self.ptprot)),
                            index=0)
        ## Add builder network endpoint
        bu_context.insert(
            3,
            Element(
                QN(self.xdaqns, 'Endpoint').text, {
                    'protocol': '%s' % self.ptprot,
                    'service': 'i2o',
                    'hostname': 'BU%d_I2O_HOST_NAME' % (index),
                    'port': 'BU%d_I2O_PORT' % (index),
                    'network': 'infini'
                }))
        ## Add builder network pt application
        addFragmentFromFile(target=bu_context,
                            filename=self.fragmentdir +
                            ('/BU/BU_%s_application.xml' % (self.ptprot)),
                            index=4)  ## add after the two endpoints
        ## Add corresponding module
        module = Element(QN(self.xdaqns, 'Module').text)
        module.text = "$XDAQ_ROOT/lib/libpt%s.so" % self.ptprot
        bu_context.insert(5, module)

        ## BU application
        bu_app = elementFromFile(filename=self.fragmentdir +
                                 ('/BU/%s/BU_application.xml' % self.evbns))
        bu_context.insert(7, bu_app)
        bu_app.set('instance', str(index))

        ## Set instance and url
        for app in bu_context.findall(QN(self.xdaqns, 'Application').text):
            if app.attrib['class'] != "%s::BU" % self.evbns: continue
            app.set('instance', str(index))
            break
        bu_context.set('url', bu_context.get('url') % (index, index))

        module = Element(QN(self.xdaqns, 'Module').text)
        module.text = ("$XDAQ_ROOT/lib/libevb.so" if self.evbns == 'evb' else
                       "$XDAQ_ROOT/lib/libgevb2g.so")
        bu_context.insert(8, module)

        ## Add libdat2 module in case of udapl
        if self.ptprot == 'udapl':
            module = Element(QN(self.xdaqns, 'Module').text)
            module.text = "/usr/lib64/libdat2.so"
            bu_context.insert(9, module)

        return bu_context
Ejemplo n.º 11
0
    def addInputEmulatorProtocol(self):
        i2ons = "http://xdaq.web.cern.ch/xdaq/xsd/2004/I2OConfiguration-30"
        prot = self.config.find(QN(i2ons, 'protocol').text)

        ## Add Inputemulators
        starting_tid = BU_STARTING_TID + 200
        for n in range(self.nrus):
            prot.append(
                Element(
                    QN(i2ons, 'target').text, {
                        'class': 'gevb2g::InputEmulator',
                        'instance': "%d" % n,
                        'tid': '%d' % (starting_tid + n)
                    }))
Ejemplo n.º 12
0
 def removePropertyInAppInContext(self, context, classname, prop_name):
     for app in context.findall(QN(self.xdaqns, 'Application').text):
         ## find correct application
         if not app.attrib['class'] == classname: continue
         self.removePropertyInApp(app, prop_name)
     else:
         raise RuntimeError('Application %s not found in context %s.' %
                            (classname, context.attrib['url']))
Ejemplo n.º 13
0
    def makeEVM(self):
        index = 0
        fragmentname = 'EVM/EVM_context.xml'
        evm_context = elementFromFile(self.fragmentdir + fragmentname)

        ## Add policy
        addFragmentFromFile(target=evm_context,
                            filename=self.fragmentdir +
                            '/EVM/EVM_policy_%s.xml' % (self.ptprot),
                            index=0)
        ## Add builder network endpoint
        evm_context.insert(
            3,
            Element(
                QN(self.xdaqns, 'Endpoint').text, {
                    'protocol': '%s' % self.ptprot,
                    'service': "i2o",
                    'hostname': 'EVM%d_I2O_HOST_NAME' % (index),
                    'port': 'EVM%d_I2O_PORT' % (index),
                    'network': 'infini'
                }))
        ## Add builder network pt application
        addFragmentFromFile(target=evm_context,
                            filename=self.fragmentdir +
                            '/EVM/EVM_%s_application.xml' % (self.ptprot),
                            index=4)  ## add after the two endpoints
        ## Add corresponding module
        module = Element(QN(self.xdaqns, 'Module').text)
        module.text = "$XDAQ_ROOT/lib/libpt%s.so" % self.ptprot
        evm_context.insert(5, module)

        ## Add libdat2 module in case of udapl
        if self.ptprot == 'udapl':
            module = Element(QN(self.xdaqns, 'Module').text)
            module.text = "/usr/lib64/libdat2.so"
            evm_context.insert(9, module)

        ## Set instance and url
        for app in evm_context.findall(QN(self.xdaqns, 'Application').text):
            if app.attrib['class'] != "%s::EVM" % self.evbns: continue
            app.set('instance', str(index))
            break

        evm_context.set('url', evm_context.get('url') % (index, index))

        return evm_context
Ejemplo n.º 14
0
    def makeClient(self, index):
        fragmentname = 'msio/client_context.xml'
        context = elementFromFile(os.path.join(self.fragmentdir, fragmentname))

        ## Add policy
        addFragmentFromFile(target=context,
                            filename=os.path.join(
                                self.fragmentdir,
                                'msio/client_policy_%s.xml' % self.ptprot),
                            index=0)
        polns = "http://xdaq.web.cern.ch/xdaq/xsd/2013/XDAQPolicy-10"
        for element in context.findall(
                QN(polns, "policy").text + '/' + QN(polns, "element").text):
            if 'RU%d' in element.get('pattern'):
                element.set(
                    'pattern',
                    element.get('pattern').replace('RU%d', 'RU%d' % (index)))
        ## Add pt application
        addFragmentFromFile(
            target=context,
            filename=os.path.join(
                self.fragmentdir,
                'msio/client_%s_application.xml' % self.ptprot),
            index=2)  ## add after policy and endpoint

        ## Configure IBV application:
        if self.setDynamicIBVConfig:
            self.configureIBVApplication(context, self.RUIBVConfig)

        ## Add corresponding module
        module = Element(QN(self.xdaqns, 'Module').text)
        module.text = "$XDAQ_ROOT/lib/libpt%s.so" % self.ptprot
        context.insert(3, module)

        ## Add corresponding module
        module = Element(QN(self.xdaqns, 'Module').text)
        module.text = "$XDAQ_ROOT/lib/libxdaq2rc.so"
        context.insert(4, module)

        ## Client application
        ru_app = elementFromFile(filename=os.path.join(
            self.fragmentdir, 'msio/client_application.xml'))
        context.insert(5, ru_app)
        ru_app.set('instance', str(index))

        ## Add corresponding module
        module = Element(QN(self.xdaqns, 'Module').text)
        if self.evbns == 'msio':
            module.text = "$XDAQ_ROOT/lib/libmstreamio2g.so"
        context.insert(6, module)

        ## Set instance and url
        for app in context.findall(QN(self.xdaqns, 'Endpoint').text):
            if 'RU%d' in app.attrib['hostname']:
                app.set('hostname', app.get('hostname') % index)
            if 'RU%d' in app.attrib['port']:
                app.set('port', app.get('port') % index)
        context.set('url', context.get('url') % (index, index))

        return context
Ejemplo n.º 15
0
	def setProperty(self, context_list, classname, prop_name, prop_value):
		for context in self.contexts:
			if not self.urlToHostAndNumber(context.attrib['url'])[0] in context_list: continue
			for app in context.findall(QN(self.xcns, 'Application').text):
				if not app.attrib['class'] == classname: continue ## find correct application
				try:
					prop = app[0] ## Assume here that there is only one element, which is the properties
					if not 'properties' in prop.tag:
						raise RuntimeError('Could not identify properties of %s application in %s context.'%(app.attrib['class'], context.attrib['url']))
					appns = re.match(r'\{(.*?)\}properties', prop.tag).group(1) ## Extract namespace
				except IndexError: ## i.e. app[0] didn't work
					raise RuntimeError('Application %s in context %s does not have properties.'%(app.attrib['class'], context.attrib['url']))

				prop = app.find(QN(appns,'properties').text+'/'+QN(appns,prop_name).text)
				try:
					prop.text = str(prop_value)
				except AttributeError:
					raise KeyError('Property %s of application %s in context %s not found.'%(prop_name, app.attrib['class'], context.attrib['url']))
				break

			else:
				raise RuntimeError('Application %s not found in context %s.'%(classname, context.attrib['url']))
Ejemplo n.º 16
0
    def addMSIOI2OProtocol(self):
        i2ons = "http://xdaq.web.cern.ch/xdaq/xsd/2004/I2OConfiguration-30"
        prot = Element(QN(i2ons, 'protocol').text)

        ## Add Clients:
        for n in xrange(self.nrus):
            prot.append(
                Element(
                    QN(i2ons, 'target').text, {
                        'class': 'Client',
                        'instance': "%d" % n,
                        'tid': '%d' % (RU_STARTING_TID + n)
                    }))
        ## Add Servers:
        for n in xrange(self.nbus):
            prot.append(
                Element(
                    QN(i2ons, 'target').text, {
                        'class': 'Server',
                        'instance': "%d" % n,
                        'tid': '%d' % (BU_STARTING_TID + 2 * n)
                    }))

        self.config.append(prot)
Ejemplo n.º 17
0
    def propertyInAppInContext(self,
                               context,
                               classname,
                               prop_name,
                               prop_value=None,
                               instance=0):
        for app in context.findall(QN(self.xdaqns, 'Application').text):
            ## find correct application
            if not app.attrib['class'] == classname: continue
            if not app.attrib['instance'] == str(instance): continue

            return propertyInApp(app, prop_name, prop_value)

        else:
            raise RuntimeError('Application %s not found in context %s.' %
                               (classname, context.attrib['url']))
Ejemplo n.º 18
0
	def __init__(self, configFile, verbose=1):
		self.verbose = verbose
		self.configfile = configFile
		self.hosts      = [] ## a list of the hosts defined in the xml config
		self.FEROLs     = []
		self.eFEROLs    = []
		self.nStreams   = 0  ## total number of streams
		self.RUs        = []
		self.BUs        = []
		self.EVM        = []
		self.eFEDs      = []
		self.GTPe       = []
		self.FMM        = []
		self._hostTypes = {'FEROLCONTROLLER' : self.FEROLs,
		                   'FEROL'           : self.eFEROLs,
		                   'RU'              : self.RUs,
		                   'BU'              : self.BUs,
		                   'EVM'             : self.EVM,
		                   'EFED'            : self.eFEDs,
		                   'GTPE'            : self.GTPe,
		                   'FMM'             : self.FMM}

		self.config   = ET.parse(configFile)
		self.ETroot   = self.config.getroot()

		self.xcns     = re.match(r'\{(.*?)\}Partition', self.ETroot.tag).group(1) ## Extract xdaq namespace
		self.ferolns  = "urn:xdaq-application:ferol::FerolController"

		self.contexts = self.ETroot.getiterator(str(QN(self.xcns,'Context')))

		self.useMSIO = False
		self.useInputEmulator = False
		self.readXDAQConfigTemplate(configFile)
		self.useGTPe = False
		if len(self.GTPe) > 0:
			self.useGTPe = True

		self.setTestCase()
		if self.verbose>1: self.printHosts()
Ejemplo n.º 19
0
	def makeRU(self, ruindex):
		fragmentname = 'RU/evb/RU_context_bare.xml'
		context = elementFromFile(os.path.join(self.fragmentdir,fragmentname))

		## Add policy
		addFragmentFromFile(target=context,
			                filename=os.path.join(self.fragmentdir,
			                'RU/evb/RU_policy_%s.xml'%
			                self.ptprot),
			                index=0)
		polns = "http://xdaq.web.cern.ch/xdaq/xsd/2013/XDAQPolicy-10"
		for element in context.findall(QN(polns,"policy").text+'/'+
			                              QN(polns,"element").text):
			if 'RU%d' in element.get('pattern'):
				element.set('pattern',element.get('pattern').replace(
					                         'RU%d', 'RU%d'%(ruindex)))
		## Add builder network endpoint
		context.insert(1,Element(QN(self.xdaqns, 'Endpoint').text,
			              {'protocol':'%s'%self.ptprot ,
			               'service':"i2o",
			               'hostname':'RU%d_I2O_HOST_NAME'%(ruindex),
			               'port':'RU%d_I2O_PORT'%(ruindex),
			               'network':"infini"}))
		## Add builder network pt application
		addFragmentFromFile(target=context,
		                    filename=os.path.join(self.fragmentdir,
		                    'RU/evb/RU_%s_application.xml'%
		                    self.ptprot),
		                    index=2) ## add after the two endpoints

		## Configure IBV application:
		if self.setDynamicIBVConfig:
			if ruindex == 0:
				self.configureIBVApplication(context, self.EVMIBVConfig,
					                         maxMessageSize=self.maxMessageSize)
			else:
				self.configureIBVApplication(context, self.RUIBVConfig,
					                         maxMessageSize=self.maxMessageSize)

		## Add corresponding module
		module = Element(QN(self.xdaqns, 'Module').text)
		module.text = "$XDAQ_ROOT/lib/libpt%s.so"%self.ptprot
		context.insert(3,module)

		## RU application
		ru_app_filename = os.path.join(self.fragmentdir,
			                  'RU/evb/RU_application.xml')
		if ruindex == 0:
			ru_app_filename = os.path.join(self.fragmentdir,
				              'RU/evb/RU_application_EVM.xml')

		ru_app = elementFromFile(filename=ru_app_filename)

		## Remove numberOfResponders, fragmentFIFOCapacity:
		self.removePropertyInApp(ru_app, 'numberOfResponders')
		self.removePropertyInApp(ru_app, 'fragmentFIFOCapacity')

		## Set inputSource to Local:
		self.setPropertyInApp(ru_app, 'inputSource', 'Local')

		## Set blockSize
		if self.maxMessageSize:
			newBlockSize = self.maxMessageSize/2**10*1000
			self.setPropertyInApp(ru_app, 'blockSize', str(newBlockSize))

		## Set maxTriggerRate (in Hz, 0 is unlimited):
		if not self.setRate == 0:
			self.setPropertyInApp(ru_app, 'maxTriggerRate', self.setRate)

		## fedSourceIds are created automatically, remove them
		# self.removePropertyInApp(ru_app, 'fedSourceIds')

		## Put one fedSourceId
		ruevbappns = (self.xdaqappns%'evb::RU' if
			          ruindex>0 else self.xdaqappns%'evb::EVM')
		fedSourceIds = ru_app.find(QN(ruevbappns, 'properties').text+'/'+
			                       QN(ruevbappns, 'fedSourceIds').text)
		fedSourceIds.attrib[QN(self.soapencns, 'arrayType').text] = (
			                       "xsd:ur-type[1]")
		item_element = fedSourceIds.find(QN(ruevbappns,'item').text)
		item_element.text = str(ruindex)

		# ## In case of EvB, add expected fedids
		# if self.evbns == 'evb':
		# 	ruevbappns = (self.xdaqappns%'evb::RU' if
		# 		          ru.index>0 else self.xdaqappns%'evb::EVM')
		# 	fedSourceIds = ru_app.find(QN(ruevbappns, 'properties').text+'/'+
		# 		                       QN(ruevbappns, 'fedSourceIds').text)
		# 	fedSourceIds.attrib[QN(self.soapencns, 'arrayType').text] = (
		# 		                       "xsd:ur-type[%d]"%(len(feds_to_add)))
		# 	item_element = fedSourceIds.find(QN(ruevbappns,'item').text)
		# 	fedSourceIds.remove(item_element)
		# 	for n,fed in enumerate(feds_to_add):
		# 		item_to_add = deepcopy(item_element)
		# 		item_to_add.attrib[QN(self.soapencns, 'position').text] = (
		# 			                                                '[%d]'%n)
		# 		item_to_add.text = str(fed)
		# 		fedSourceIds.append(item_to_add)

		context.insert(5,ru_app)
		ru_app.set('instance',str(ruindex))


		## Set instance and url
		for app in context.findall(QN(self.xdaqns, 'Endpoint').text):
			if 'RU%d' in app.attrib['hostname']:
				app.set('hostname', app.get('hostname')%ruindex)
			if 'RU%d' in app.attrib['port']:
				app.set('port', app.get('port')%ruindex)
		context.set('url', context.get('url')%(ruindex, ruindex))

		return context
Ejemplo n.º 20
0
    def makeBU(self, index):
        fragmentname = 'BU/BU_context.xml'
        context = elementFromFile(os.path.join(self.fragmentdir, fragmentname))

        ## Add policy
        addFragmentFromFile(
            target=context,
            filename=os.path.join(
                self.fragmentdir,
                'BU/gevb2g/msio/BU_policy_%s_msio.xml' % (self.ptprot)),
            index=0)
        ## Add builder network endpoint
        context.insert(
            1,
            Element(
                QN(self.xdaqns, 'Endpoint').text, {
                    'protocol': '%s' % self.ptprot,
                    'service': 'i2o',
                    'hostname': 'BU%d_I2O_HOST_NAME' % (index),
                    'port': 'BU%d_I2O_PORT' % (index),
                    'network': 'infini'
                }))
        ## Add builder network pt application
        addFragmentFromFile(
            target=context,
            filename=os.path.join(
                self.fragmentdir,
                'BU/gevb2g/msio/BU_%s_application_msio.xml' % (self.ptprot)),
            index=2)  ## add after the two endpoints

        ## Configure IBV application:
        if self.setDynamicIBVConfig:
            self.configureIBVApplication(context, self.BUIBVConfig)

        ## Add corresponding module
        module = Element(QN(self.xdaqns, 'Module').text)
        module.text = "$XDAQ_ROOT/lib/libpt%s.so" % self.ptprot
        context.insert(3, module)

        ## Add corresponding module
        module = Element(QN(self.xdaqns, 'Module').text)
        module.text = "$XDAQ_ROOT/lib/libxdaq2rc.so"
        context.insert(4, module)

        ## BU application
        bu_app = elementFromFile(filename=os.path.join(
            self.fragmentdir, 'BU/gevb2g/msio/BU_application_msio.xml'))
        context.insert(5, bu_app)
        bu_app.set('instance', str(index))

        ## Set instance and url
        for app in context.findall(QN(self.xdaqns, 'Application').text):
            if app.attrib['class'] != "%s::BU" % self.evbns: continue
            app.set('instance', str(index))
            break
        context.set('url', context.get('url') % (index, index))

        module = Element(QN(self.xdaqns, 'Module').text)
        module.text = "$XDAQ_ROOT/lib/libgevb2g.so"
        context.insert(6, module)

        return context
Ejemplo n.º 21
0
    def makeRU(self, ruindex):
        fragmentname = 'RU/gevb2g/msio/RU_context_msio.xml'
        context = elementFromFile(os.path.join(self.fragmentdir, fragmentname))

        ## Add policy
        addFragmentFromFile(
            target=context,
            filename=os.path.join(
                self.fragmentdir,
                'RU/gevb2g/msio/RU_policy_%s_msio.xml' % self.ptprot),
            index=0)
        polns = "http://xdaq.web.cern.ch/xdaq/xsd/2013/XDAQPolicy-10"
        for element in context.findall(
                QN(polns, "policy").text + '/' + QN(polns, "element").text):
            if 'RU%d' in element.get('pattern'):
                element.set(
                    'pattern',
                    element.get('pattern').replace('RU%d', 'RU%d' % (ruindex)))
        ## Add builder network endpoint
        context.insert(
            1,
            Element(
                QN(self.xdaqns, 'Endpoint').text, {
                    'protocol': '%s' % self.ptprot,
                    'service': "i2o",
                    'hostname': 'RU%d_I2O_HOST_NAME' % (ruindex),
                    'port': 'RU%d_I2O_PORT' % (ruindex),
                    'network': "infini"
                }))
        ## Add builder network pt application
        addFragmentFromFile(
            target=context,
            filename=os.path.join(
                self.fragmentdir,
                'RU/gevb2g/msio/RU_%s_application_msio.xml' % self.ptprot),
            index=2)  ## add after the two endpoints

        ## Configure IBV application:
        if self.setDynamicIBVConfig:
            self.configureIBVApplication(context, self.RUIBVConfig)

        ## Add corresponding module
        module = Element(QN(self.xdaqns, 'Module').text)
        module.text = "$XDAQ_ROOT/lib/libpt%s.so" % self.ptprot
        context.insert(3, module)

        ## Add corresponding module
        module = Element(QN(self.xdaqns, 'Module').text)
        module.text = "$XDAQ_ROOT/lib/libxdaq2rc.so"
        context.insert(4, module)

        ## Add Inputemulator application
        inputemu_app = elementFromFile(filename=os.path.join(
            self.fragmentdir, 'RU/gevb2g/msio/RU_inputemulator.xml'))
        inputemu_app.set('instance', str(ruindex))
        context.insert(5, inputemu_app)

        ## RU application
        ru_app = elementFromFile(filename=os.path.join(
            self.fragmentdir, 'RU/gevb2g/msio/RU_application_msio.xml'))
        context.insert(6, ru_app)
        ru_app.set('instance', str(ruindex))

        ## Set instance and url
        for app in context.findall(QN(self.xdaqns, 'Endpoint').text):
            if 'RU%d' in app.attrib['hostname']:
                app.set('hostname', app.get('hostname') % ruindex)
            if 'RU%d' in app.attrib['port']:
                app.set('port', app.get('port') % ruindex)
        context.set('url', context.get('url') % (ruindex, ruindex))

        self.setPropertyInAppInContext(context,
                                       'gevb2g::InputEmulator',
                                       'destinationClassInstance',
                                       str(ruindex),
                                       instance=ruindex)

        return context
Ejemplo n.º 22
0
	def readXDAQConfigTemplate(self, configFile):
		if not os.path.exists(configFile):
			raise IOError('File '+configFile+' not found')

		## Check <i2o:protocol> element for evb: or gevb2g: tags to determine which of the two we're dealing with here:
		i2o_namespace = 'http://xdaq.web.cern.ch/xdaq/xsd/2004/I2OConfiguration-30'
		i2o_protocol = self.ETroot.find(QN(i2o_namespace, 'protocol').text)
		try:
			if 'gevb2g::' in i2o_protocol[0].attrib['class']: ## there is something with a gevb2g tag
				if self.verbose > 2 : print "Found a gevb2g configuration"
				self.useEvB = False
				self.useMSIO = False
				self.namespace = 'gevb2g::'
			elif 'evb::' in i2o_protocol[0].attrib['class']: ## there is something with a evb tag
				if self.verbose > 2 : print "Found an EvB configuration"
				self.useEvB = True
				self.useMSIO = False
				self.namespace = 'evb::'
			elif ('Client' in i2o_protocol[0].attrib['class'] or
			      'Server' in i20_protocol[0].attrib['class']):
				if self.verbose > 2 : print "Found an mstreamio configuration"
				self.useEvB = False
				self.useMSIO = True
				self.namespace = 'gevb2g::'
			else:
				raise RuntimeError("Couldn't determine EvB/gevb2g case!")
		except TypeError:
			raise RuntimeError("Did not find i2o protocol in config file!")

		maxsizes = []
		tcp_cwnd = []
		checked_ibv = False
		checked_evbie = False

		#### Scan <xc:Context>'s to extract configuration
		for context in self.contexts:
			apps = context.findall(QN(self.xcns, 'Application').text) ## all 'Application's of this context
			## Match context url
			h,n = self.urlToHostAndNumber(context.attrib['url'])
			try:
				if self.verbose > 2: print 'Adding', h+n
				ho = host(h+n, int(n), h)

				## Save a list of all applications and instances running in each context
				for app in apps:
					try:
						classname,instance = (str(app.attrib['class']), int(app.attrib['instance']))
					except KeyError:
						classname,instance = (str(app.attrib['class']), None)
					ho.applications.append((classname, instance))

				## For RU, check whether IVB or UDAPL (only do it once)
				## and whether there is an InputEmulator
				if h == 'RU' and not checked_ibv:
					self.useIBV = False
					for app in apps:
						if app.attrib['class'] == 'pt::ibv::Application':
							self.useIBV = True  ## Found IBV configuration
							if self.verbose > 2 : print "Found IBV peer transport protocol"
							break
						if app.attrib['class'] == 'pt::udapl::Application':
							self.useIBV = False ## Found UDAPL configuration
							if self.verbose > 2 : print "Found UDAPL peer transport protocol"
							break
					for app in apps:
						if app.attrib['class'] == 'gevb2g::InputEmulator':
							self.useInputEmulator = True
							if self.verbose > 2 : print "Found gevb2g InputEmulator"
							break
					checked_ibv = True

				## For evb RU (or EVM), check whether inputSource is set to Local
				if h == 'RU' and self.useEvB and not checked_evbie:
					for app in apps:
						if app.attrib['class'] == 'evb::EVM':
							if propertyInApp(app, 'inputSource') == 'Local':
								self.useInputEmulator = True
								if self.verbose > 2 : print "Found evb InputEmulator"
							break
					checked_evbie = True

				## For FEROLs, check which of the streams are enabled
				if h == 'FEROLCONTROLLER':
					for app in apps:
						if app.attrib['class'] == 'ferol::FerolController':
							prop = app.find(QN(self.ferolns,'properties').text)
							ho.__class__ = FEROL ## Make it a FEROL
							ho.setStreams(prop.find(QN(self.ferolns, 'enableStream0').text).text, prop.find(QN(self.ferolns, 'enableStream1').text).text)
							if ho.enableStream0:
								self.nStreams += 1
								maxsizes.append(int(prop.find(QN(self.ferolns, 'Event_Length_Max_bytes_FED0').text).text))
								tcp_cwnd.append(int(prop.find(QN(self.ferolns, 'TCP_CWND_FED0').text).text))
							if ho.enableStream1:
								self.nStreams += 1
								maxsizes.append(int(prop.find(QN(self.ferolns, 'Event_Length_Max_bytes_FED1').text).text))
								tcp_cwnd.append(int(prop.find(QN(self.ferolns, 'TCP_CWND_FED1').text).text))
							break

				## For eFEDs, count the number of enabled streams and their instances
				if h == 'EFED':
					ho.__class__ = eFED ## Make it an eFED
					for app in apps:
						if app.attrib['class'] == 'd2s::FEDEmulator':
							efedns = 'urn:xdaq-application:d2s::FEDEmulator'
							prop = app.find(QN(efedns,'properties').text)
							fedid    = int(prop.find(QN(efedns,'FedSourceId').text).text)
							slot     = int(prop.find(QN(efedns,'slot').text).text)
							instance = int(app.attrib['instance'])
							ho.addStream(instance, fedid, slot)

				## For FMM, check the different geoslots and input/output labels
				if h == 'FMM':
					ho.__class__ = FMM ## Make it an FMM
					for app in apps:
						if app.attrib['class'] == 'tts::FMMController':
							fmmns = 'urn:xdaq-application:tts::FMMController'
							prop = app.find(QN(fmmns,'properties').text)
							fmmconfig = prop.find(QN(fmmns,'config').text)
							for item in fmmconfig.findall(QN(fmmns,"item").text):
								geoslot = int(item.find(QN(fmmns,'geoslot').text).text)
								label   = str(item.find(QN(fmmns,'label').text).text)
								inputs  = str(item.find(QN(fmmns,'inputLabels').text).text)
								outputs = str(item.find(QN(fmmns,'outputLabels').text).text)
								ho.addSlot(geoslot, label, inputs, outputs)

				if h == 'FEROL': ## Misnomer, eFEROLs are called FEROLS
					self.nStreams += 1

				self._hostTypes[h].append(ho)
				self.hosts.append(ho)

			except KeyError as e:
				printError('Unknown host type %s. Aborting.' % h, self)
				raise e

		if self.verbose < 1: return
		if len(maxsizes) > 0:
			## Check whether they were all filled
			if len(maxsizes) != self.nStreams:
				raise RuntimeError("Didn't find all Event_Length_Max_bytes parameter in config file?!")

			## Check they are all the same:
			size_set = set(maxsizes)
			if len(size_set) > 1:
				message = """
WARNING: You have FEROLs with different
         Event_Length_Max_bytes parameters in your config file!

 That probably shouldn't be.
"""
				printWarningWithWait(message, instance=self)

# 			## Check they are correct and alert
# 			if not checkMaxSize(maxsizes[0], self.nStreams//len(self.RUs)):
# 			# if maxsizes[0] != SIZE_LIMIT_TABLE[self.nStreams//len(self.RUs)][0]:
# 				message = """
# WARNING: Event_Length_Max_bytes for FEROLs seems to be set
#          to the wrong value in your config .xml file!

#  Is set to: %d in config. Expected value: %d
# """ % (int(maxsizes[0]), int(SIZE_LIMIT_TABLE[self.nStreams//len(self.RUs)][0]))
# 				printWarningWithWait(message, instance=self)

		if len(tcp_cwnd) > 0:
			## Check whether they were all filled
			if len(tcp_cwnd) != self.nStreams:
				raise RuntimeError("Didn't find all TCP_CWND_FEDX parameters in config file?!")

			## Check they are all the same:
			cwnd_set = set()
			for x in tcp_cwnd: cwnd_set.add(x)
			if len(cwnd_set) > 1:
				message = """
WARNING: You have FEROLs with different
         TCP_CWND_FEDX parameters in your config file!

 That probably shouldn't be.
"""
				printWarningWithWait(message, instance=self)


			## Check they are correct and alert in case:
			message = """
WARNING: TCP_CWND_FEDX for FEROLs seems to be set
         to the wrong value in your config .xml file!

 Is set to: %d in config. Expected value: %d
"""
			cwnd = cwnd_set.pop()
			if self.nStreams == len(self.FEROLs) and cwnd not in [80000]:
				printWarningWithWait(message%(cwnd, 80000), instance=self, waittime=2)
			if self.nStreams == 2*len(self.FEROLs) and cwnd not in [80000]:
				printWarningWithWait(message%(cwnd, 80000), instance=self, waittime=2)
Ejemplo n.º 23
0
    def makeRU(self, ru):
        fragmentname = 'RU/%s/RU_context.xml' % self.evbns
        ru_context = elementFromFile(self.fragmentdir + fragmentname)

        ## Add policy
        addFragmentFromFile(target=ru_context,
                            filename=self.fragmentdir +
                            '/RU/%s/RU_policy_%s.xml' %
                            (self.evbns, self.ptprot),
                            index=0)
        polns = "http://xdaq.web.cern.ch/xdaq/xsd/2013/XDAQPolicy-10"
        for element in ru_context.findall(
                QN(polns, "policy").text + '/' + QN(polns, "element").text):
            if 'RU%d' in element.get('pattern'):
                element.set(
                    'pattern',
                    element.get('pattern').replace('RU%d',
                                                   'RU%d' % (ru.index)))
        ## Add builder network endpoint
        ru_context.insert(
            3,
            Element(
                QN(self.xdaqns, 'Endpoint').text, {
                    'protocol': '%s' % self.ptprot,
                    'service': "i2o",
                    'hostname': 'RU%d_I2O_HOST_NAME' % (ru.index),
                    'port': 'RU%d_I2O_PORT' % (ru.index),
                    'network': "infini"
                }))
        ## Add builder network pt application
        addFragmentFromFile(target=ru_context,
                            filename=self.fragmentdir +
                            '/RU/%s/RU_%s_application.xml' %
                            (self.evbns, self.ptprot),
                            index=4)  ## add after the two endpoints
        ## Add corresponding module
        module = Element(QN(self.xdaqns, 'Module').text)
        module.text = "$XDAQ_ROOT/lib/libpt%s.so" % self.ptprot
        ru_context.insert(5, module)

        ## Add frl routing
        feds_to_add = ru.getFedIds()
        pt_frl_ns = self.xdaqappns % "pt::frl::Application"
        frl_routing_element = ru_context.find(
            QN(self.xdaqns, 'Application').text + '/' +
            QN(pt_frl_ns, 'properties').text + '/' +
            QN(pt_frl_ns, 'frlRouting').text)
        frl_routing_element.attrib[QN(self.soapencns,
                                      'arrayType').text] = ("xsd:ur-type[%d]" %
                                                            (len(feds_to_add)))
        item_element = elementFromFile(self.fragmentdir +
                                       '/RU/RU_frl_routing.xml')
        classname_to_add = ("%s::EVM" % self.evbns if ru.index == 0
                            and self.evbns == 'evb' else "%s::RU" % self.evbns)
        item_element.find(QN(pt_frl_ns,
                             'className').text).text = (classname_to_add)
        item_element.find(QN(pt_frl_ns,
                             'instance').text).text = ("%d" % ru.index)

        for n, fed in enumerate(feds_to_add):
            item_to_add = deepcopy(item_element)
            item_to_add.attrib[QN(self.soapencns,
                                  'position').text] = ('[%d]' % n)
            item_to_add.find(QN(pt_frl_ns, 'fedid').text).text = str(fed)
            frl_routing_element.append(item_to_add)

        ## RU application
        ru_app = elementFromFile(filename=self.fragmentdir +
                                 '/RU/%s/RU_application.xml' % self.evbns)
        ## make the first one an EVM in case of EvB
        if self.evbns == 'evb' and ru.index == 0:
            ru_app = elementFromFile(filename=self.fragmentdir +
                                     '/RU/evb/RU_application_EVM.xml')
        ru_context.insert(7, ru_app)
        ru_app.set('instance', str(ru.index))

        ## In case of EvB, add expected fedids
        if self.evbns == 'evb':
            ruevbappns = (self.xdaqappns %
                          'evb::RU' if ru.index > 0 else self.xdaqappns %
                          'evb::EVM')
            fedSourceIds = ru_app.find(
                QN(ruevbappns, 'properties').text + '/' +
                QN(ruevbappns, 'fedSourceIds').text)
            fedSourceIds.attrib[QN(self.soapencns,
                                   'arrayType').text] = ("xsd:ur-type[%d]" %
                                                         (len(feds_to_add)))
            item_element = fedSourceIds.find(QN(ruevbappns, 'item').text)
            fedSourceIds.remove(item_element)
            for n, fed in enumerate(feds_to_add):
                item_to_add = deepcopy(item_element)
                item_to_add.attrib[QN(self.soapencns,
                                      'position').text] = ('[%d]' % n)
                item_to_add.text = str(fed)
                fedSourceIds.append(item_to_add)

        ## Add libdat2 module in case of udapl
        if self.ptprot == 'udapl':
            module = Element(QN(self.xdaqns, 'Module').text)
            module.text = "/usr/lib64/libdat2.so"
            ru_context.insert(8, module)

        ## Set instance and url
        for app in ru_context.findall(QN(self.xdaqns, 'Endpoint').text):
            if 'RU%d' in app.attrib['hostname']:
                app.set('hostname', app.get('hostname') % ru.index)
            if 'RU%d' in app.attrib['port']:
                app.set('port', app.get('port') % ru.index)
        ru_context.set('url', ru_context.get('url') % (ru.index, ru.index))

        return ru_context
Ejemplo n.º 24
0
	def makeBU(self, index):
		fragmentname = 'BU/BU_context.xml'
		context = elementFromFile(os.path.join(self.fragmentdir,
			                                      fragmentname))

		## Add policy
		addFragmentFromFile(target=context,
			                filename=os.path.join(self.fragmentdir,
			                	'BU/evb/BU_policy_%s.xml'%(
			                	self.ptprot)),
			                index=0)
		## Add builder network endpoint
		context.insert(1,Element(QN(self.xdaqns, 'Endpoint').text, {
			                        'protocol':'%s'%self.ptprot ,
			                        'service':'i2o',
			                        'hostname':'BU%d_I2O_HOST_NAME'%(index),
			                        'port':'BU%d_I2O_PORT'%(index),
			                        'network':'infini'}))
		## Add builder network pt application
		addFragmentFromFile(target=context,
		                    filename=os.path.join(self.fragmentdir,
		                        'BU/BU_%s_application.xml'%(
		                        self.ptprot)),
		                    index=2) ## add after the two endpoints

		## Configure IBV application:
		if self.setDynamicIBVConfig:
			self.configureIBVApplication(context, self.BUIBVConfig,
				                         maxMessageSize=self.maxMessageSize)

		## Add corresponding module
		module = Element(QN(self.xdaqns, 'Module').text)
		module.text = "$XDAQ_ROOT/lib/libpt%s.so"%self.ptprot
		context.insert(3,module)

		## BU application
		bu_app = elementFromFile(filename=os.path.join(self.fragmentdir,
			                     'BU/evb/BU_application.xml'))
		# self.removePropertyInApp(bu_app, 'maxEvtsUnderConstruction')
		# self.removePropertyInApp(bu_app, 'eventsPerRequest')
		if self.maxEvtsUnderConstruction is not None:
			self.setPropertyInApp(bu_app, 'maxEvtsUnderConstruction',
				                  self.maxEvtsUnderConstruction)
		if self.numberOfBuilders is not None:
			self.setPropertyInApp(bu_app, 'numberOfBuilders',
				                  self.numberOfBuilders)

		context.insert(4,bu_app)
		bu_app.set('instance',str(index))

		## Set instance and url
		for app in context.findall(QN(self.xdaqns, 'Application').text):
			if app.attrib['class'] != "%s::BU"%self.evbns: continue
			app.set('instance', str(index))
			break
		context.set('url', context.get('url')%(index, index))

		module = Element(QN(self.xdaqns, 'Module').text)
		module.text = "$XDAQ_ROOT/lib/libevb.so"
		context.insert(5,module)

		return context