Back to home page

Project CMSSW displayed by LXR

 
 

    


Warning, /DQM/Integration/scripts/XMLcfgfiles/xmlcfgVerifier is written in an unsupported language. File is not indexed.

0001 #!/usr/bin/env python3
0002 """Syntax:
0003     xmlcfgVerifier [-fhv] XMLCfgFilename
0004 
0005 Description:
0006         Check if XMLCfgFilename is a valid XML configuration file to use with the 
0007         RCMS platform.
0008 Parameters:
0009         -f             Full Check up, tests the listed servers to see if they 
0010                        have Jobcontrol enabled.
0011         -v             Verbose mode.
0012         -h             This help message.
0013     XMLCfgFilename     XML file to be verified 
0014 """
0015 ################################################################################
0016 import sys, os.path
0017 import getopt as gop
0018 import ExtractAppInfoFromXML as appinf
0019 from xml.dom import minidom
0020 ################################################################################
0021 fullchk=False
0022 verbose=False
0023 DPservices={"hostname":{}}                      #"hostName_port":{hostname:count}
0024 DPapplications={}    #(hostname,port,instance):count
0025 DPexecutives={}      #(hostname,port,instance):count
0026 user = "dqmpro"                  #user that's configured oo t hte XML file
0027 ################################################################################
0028 def normalize(head):
0029         parent=head.parentNode
0030         if parent:
0031                 firstText=None
0032                 for brother in parent.childNodes:
0033                         if brother.nodeType == 3:
0034                                 if firstText:
0035                                         firstText.nodeValue+=str(brother.nodeValue).strip()
0036                                         brother=parent.removeChild(brother)
0037                                         brother.unlink()
0038                                 else:
0039                                         firstText=brother
0040                                         firstText.nodeValue=str(brother.nodeValue).strip()
0041                                 
0042         
0043 ################################################################################
0044 def xmlTrim(head):
0045         normalize(head)
0046         if head.hasChildNodes():
0047                 for child in head.childNodes:
0048                         xmlTrim(child)
0049         if head.nodeType == 8:   # Check if node is a comment
0050                 parent=head.parentNode
0051                 parent.removeChild(head)
0052                 head.unlink()
0053         return
0054 ################################################################################
0055 def userAutodetect(xmlTree):
0056         global user
0057         from EnviromentSettings import users
0058         verbose and sys.stdout.write("Detecting user configuration...\n")       
0059         xdaqE=xmlTree.getElementsByTagName("Configuration")
0060         if not len(xdaqE):
0061                 print "No Configuration found to retrive user continuing tests with default user:'"+user+"'"
0062                 return
0063         if not xdaqE[0].hasAttribute("user"):
0064                 print "No attribute 'user' found in Configuration continuing tests with default user:'"+user+"'"
0065                 return
0066         if not xdaqE[0].hasAttribute("user") not in users:
0067                 print "The specified 'user' found in Configuration is not one of the expected users:'"+"','".join(users)+"'\nContinuing tests with default user:'"+user+"'"
0068                 return
0069         user=xdaqE[0].attributes["user"].value
0070         verbose and sys.stdout.write("Detected user name = '"+user+"'\n")
0071         return
0072 ################################################################################
0073 def chkService(server):
0074         global fullchk,verbose
0075         result=[]
0076         if server.hasAttribute("hostname"):
0077                 if server.attributes["hostname"].value=="":
0078                         print "Attribute 'hostname' is empty"
0079                 else:
0080                         result=[server.attributes["hostname"].value]
0081         else:
0082                 print "No 'hostname' Attribute in Service element"
0083         if server.hasAttribute("name"):
0084                 if server.attributes["name"].value!="JobControl":
0085                         print "Attribute 'name' has an unexpected value of '"+server.attributes["name"].value+"', where the expected value is 'JobControl'"
0086                         result=[]
0087         else:
0088                 print "No 'name' Attribute in Service element"
0089                 result=[]
0090         if server.hasAttribute("port"):
0091                 if server.attributes["port"].value!="9999":
0092                         print "Warning!!! Attribute 'port' has an unexpected value of '"+server.attributes["port"].value+"', where the expected value is '9999'"
0093         else:
0094                 print "No 'port' Attribute in Service element"
0095                 result=[]
0096         if server.hasAttribute("urn"):
0097                 if server.attributes["urn"].value!="/urn:xdaq-application:lid=10":
0098                         print "Attribute 'urn' has an unexpected value of '"+server.attributes["urn"].value+"', where the expected value is '/urn:xdaq-application:lid=10'"
0099                         result=[]
0100         else:
0101                 print "No 'urn' Attribute in Service element"
0102                 result=[]
0103         if server.hasAttribute("qualifiedResourceType"):
0104                 if server.attributes["qualifiedResourceType"].value!="rcms.fm.resource.qualifiedresource.JobControl":
0105                         print "Attribute 'qualifiedResourceType' has an unexpected value of '"+server.attributes["qualifiedResourceType"].value+"', where the expected value is 'rcms.fm.resource.qualifiedresource.JobControl'"
0106                         result=[]
0107         else:
0108                 print "No 'qualifiedResourceType' Attribute in Service element" 
0109                 result=[]
0110         if server.hasAttribute("role"):
0111                 if server.attributes["role"].value!="DQM_TAGFILE":
0112                         print "Warning!!! Attribute 'role' has an unexpected value of '"+server.attributes["role"].value+"', where the expected value is 'DQM_TAGFILE'"
0113         else:
0114                 print "Warning!!! No 'role' Attribute in Service element"
0115         if result:
0116                 if server.attributes["hostname"].value in DPservices["hostname"]:
0117                         DPservices["hostname"][server.attributes["hostname"].value]+=1
0118                         print "There is already a service entry for server name: "+server.attributes["hostname"].value+" The count rises to:"+str(DPservices["hostname"][server.attributes["hostname"].value])
0119                         result=[]                       
0120                 else:
0121                         DPservices["hostname"][server.attributes["hostname"].value]=1
0122         #test if Job Control is actually running on server
0123         if result:
0124                 if fullchk:
0125                         cmd="ssh "+server.attributes["hostname"].value+" ps -ef | grep xdaq |grep daemon| grep 'p "+server.attributes["port"].value+"' | wc -l 2>&1"
0126                         livetest=os.popen(cmd)
0127                         isprocrunning=int(livetest.readline() or "0")
0128                         livetest.close()
0129                         if isprocrunning:
0130                                 verbose and sys.stdout.write( "Server is Running Xdaq process")
0131                         else:
0132                                 print "Server is not running Xdaq daemon for Job Control no apps will be started on this server"
0133                                 result=[]
0134         return result
0135 ################################################################################
0136 def chkConfigFile(cfgFile,executive):
0137         global fullchk,verbose,user
0138         result=True
0139         #i2o:target
0140         verbose and sys.stdout.write( "Checking ConfigFiles' i2o:targets")
0141         i2otargets=cfgFile.getElementsByTagName("i2o:target")
0142         if len(i2otargets) <= 1:
0143                 print "Insufficient i2o:targets please revise"
0144                 result=False
0145         else:
0146                 for item in i2otargets:
0147                         if not item.hasAttribute("class"):
0148                                 print "No 'class' attribute in i2o:target"
0149                                 result=False
0150                                 break
0151                         if not item.hasAttribute("instance"):
0152                                 print "No 'instance' attribute in i2o:target"
0153                                 result=False
0154                                 break
0155                         if item.attributes["class"].value!="RCMSStateListener":
0156                                 if item.attributes["instance"].value!=executive.attributes["instance"].value:
0157                                         print "Insufficient i2o:targets please revise"
0158                                         result=False
0159         #Context
0160         Contexts=cfgFile.getElementsByTagName("xc:Context")
0161         if len(Contexts) < 2:
0162                 print "There are no enough contexts please revise"
0163                 result=False
0164         else:
0165                 for item in Contexts:
0166                         if not item.hasAttribute("url"):
0167                                 print "No 'url' attribute in xc:Context"
0168                                 result=False
0169                                 break
0170                         #Context:Application
0171                         Applications=cfgFile.getElementsByTagName("xc:Context")
0172                         if len(Applications) < 1 and len(Applications)>1:
0173                                 print "Wrong number of applications in xc:Context with 'url' '"+item.attributes["url"].value+"' please revise"
0174                                 result=False
0175                                 break
0176                         #if Applications[0].attribute["class"].value!=
0177                         
0178                         expectedURL="http://"+executive.attributes["hostname"].value+":"+executive.attributes["port"].value
0179                         URLlist=[expectedURL]
0180                         if item.attributes["url"].value!=expectedURL:
0181                                 print "Attribute 'url' has an unexpected value of '"+item.attributes["url"].value+"', where the expected value is '"+expectedURL+"'"
0182                                 result=False
0183         
0184         
0185         
0186         
0187         
0188         return result
0189 ################################################################################
0190 def chkExecutives(executive):
0191         global fullchk,verbose,user
0192         from EnviromentSettings import users,pathsToExecutive,logURLs,knownlogLevels,environmentString
0193         pathToExecutive=str(pathsToExecutive[user])
0194         logURL=str(logURLs[user])
0195         result={}
0196         if executive.hasAttribute("hostname"):
0197                 if executive.attributes["hostname"].value=="":
0198                         print "Attribute 'hostname' is empty"
0199                         return {}
0200         else:
0201                 print "No 'hostname' Attribute in XdaqExecutive element"        
0202                 return {}
0203         
0204         if executive.hasAttribute("port"):
0205                 if executive.attributes["port"].value=="":
0206                         print "Attribute 'port' is empty"
0207                         return {}
0208         else:
0209                 print "No 'port' Attribute in XdaqExecutive element"    
0210                 return {}
0211         
0212         if executive.hasAttribute("instance"):
0213                 if executive.attributes["instance"].value=="":
0214                         print "Attribute 'instance' is empty"
0215                         return {}
0216         else:
0217                 print "No 'instance' Attribute in XdaqExecutive element"        
0218                 return {} 
0219         result={"server":executive.attributes["hostname"].value,"port":executive.attributes["port"].value,"instance":executive.attributes["instance"].value}
0220         uniqIndex=(executive.attributes["hostname"].value,executive.attributes["port"].value,executive.attributes["instance"].value)
0221         if uniqIndex in DPapplications:
0222                 if uniqIndex in DPexecutives:
0223                         DPexecutives[uniqIndex]+=1
0224                         print "There is already a XdaqExecutive with the following attributes:\n\tInstance => "+executive.attributes["instance"].value+\
0225                                         "\n\tHostname=>"+executive.attributes["hostname"].value +\
0226                                         "\n\tPort=>"+executive.attributes["port"].value +\
0227                         "\nThe count rises to:"+str(executive[uniqIndex])
0228                         return {}
0229                 else:
0230                         DPexecutives[uniqIndex]=1
0231         else:
0232                 print "There's no Application associated with this Executive: ("+",".join(uniqIndex)+") do not match those from any of the XdaqApplication elements processed"
0233                 return {}
0234         if executive.hasAttribute("urn"):
0235                 if executive.attributes["urn"].value!="/urn:xdaq-application:lid=0" :
0236                         print "Attribute 'urn' has an unexpected value of '"+executive.attributes["urn"].value+"', where the expected value is '/urn:xdaq-application:lid=0'"
0237                         result={}
0238         else:
0239                 print "No 'urn' Attribute in XdaqExecutive element"
0240                 result={}       
0241         if executive.hasAttribute("qualifiedResourceType"):
0242                 if executive.attributes["qualifiedResourceType"].value!="rcms.fm.resource.qualifiedresource.XdaqExecutive":
0243                         print "Attribute 'qualifiedResourceType' has an unexpected value of '"+executive.attributes["qualifiedResourceType"].value+"', where the expected value is 'rcms.fm.resource.qualifiedresource.XdaqExecutive'"
0244                         result={}
0245         else:
0246                 print "No 'qualifiedResourceType' Attribute in XdaqExecutive element"   
0247                 result={}
0248         if executive.hasAttribute("pathToExecutive"):
0249                 if executive.attributes["pathToExecutive"].value!=pathToExecutive:
0250                         print "Attribute 'pathToExecutive' has an unexpected value of '"+executive.attributes["pathToExecutive"].value+"', where the expected value is '"+pathToExecutive+"'"
0251                         result={}
0252         else:
0253                 print "No 'pathToExecutive' Attribute in XdaqExecutive element" 
0254                 result={}
0255         if executive.hasAttribute("unixUser"):
0256                 if executive.attributes["unixUser"].value!=user:
0257                         print "Attribute 'unixUser' has an unexpected value of '"+executive.attributes["unixUser"].value+"', where the expected value is '"+user+"'"
0258                         result={}
0259         else:
0260                 print "No 'unixUser' Attribute in XdaqExecutive element"        
0261                 result={}
0262         if executive.hasAttribute("logURL"):
0263                 if executive.attributes["logURL"].value!=logURL:
0264                         print "Attribute 'logURL' has an unexpected value of '"+executive.attributes["logURL"].value+"', where the expected value is '"+logURL+"'"
0265                         result={}
0266         else:
0267                 print "No 'logURL' Attribute in XdaqExecutive element"  
0268                 result={}
0269         if executive.hasAttribute("logLevel"):
0270                 if executive.attributes["logLevel"].value not in knownlogLevels:
0271                         print "Attribute 'logLevel' has an unexpected value of '"+executive.attributes["logLevel"].value+"', where the expected value is one of the following loglevels:'"+"','".join(knownlogLevels)+ "'"
0272                         result={}
0273         else:
0274                 print "No 'logURL' Attribute in XdaqExecutive element"  
0275                 result={}         
0276         cfgSection=executive.getElementsByTagName("configFile")
0277         if len(cfgSection) > 1:
0278                 print "Warning!!! more than one configFile element in XdaqExecutive only the first one will be checked"
0279         if len(cfgSection) == 0:
0280                 print "No configFile element in XdaqExecutive with the following attributes:\n\tInstance => "+executive.attributes["instance"].value+\
0281                                         "\n\tHostname=>"+executive.attributes["hostname"].value +\
0282                                         "\n\tPort=>"+executive.attributes["port"].value
0283                 return {}
0284                 
0285         if not chkConfigFile(cfgSection[0],executive):
0286                 print "configFile element check of the XdaqExecutive  with the following attributes:\n\tInstance => "+executive.attributes["instance"].value+\
0287                                         "\n\tHostname=>"+executive.attributes["hostname"].value +\
0288                                         "\n\tPort=>"+executive.attributes["port"].value +\
0289                                         "\nFAILED."
0290                 return {}       
0291         return result
0292 ################################################################################
0293 # DPapplications={}    #instance:{(hostname,port):count,count:count}
0294 ################################################################################
0295 def chkApplications(application,JCServers):
0296         global fullchk,verbose,user
0297         import EnviromentSettings
0298         EnviromentSettings.user=user
0299         knownclassNames=EnviromentSettings.knownclassNames()
0300         result={}
0301         if application.hasAttribute("hostname"):
0302                 if application.attributes["hostname"].value=="":
0303                         print "Attribute 'hostname' is empty"
0304                         return {}
0305                 elif application.attributes["hostname"].value not in JCServers :
0306                         print "Attribute 'hostname' doesn't point to a JobControlled server"
0307                         return {}
0308         else:
0309                 print "No 'hostname' Attribute in XdaqApplication element"      
0310                 return {}
0311         
0312         if application.hasAttribute("port"):
0313                 if application.attributes["port"].value=="":
0314                         print "Attribute 'port' is empty"
0315                         return {}
0316         else:
0317                 print "No 'port' Attribute in XdaqApplication element"  
0318                 return {}
0319         
0320         if application.hasAttribute("instance"):
0321                 if application.attributes["instance"].value=="":
0322                         print "Attribute 'instance' is empty"
0323                         return {}
0324         else:
0325                 print "No 'instance' Attribute in XdaqApplication element"      
0326                 return {} 
0327         result={"server":application.attributes["hostname"].value,"port":application.attributes["port"].value,"instance":application.attributes["instance"].value}
0328         uniqIndex=(application.attributes["hostname"].value,application.attributes["port"].value,application.attributes["instance"].value)
0329         if uniqIndex  in DPapplications:
0330                 DPapplications[uniqIndex]+=1
0331                 print "There is already a XdaqApplication with the following attributes:\n\tInstance => "+application.attributes["instance"].value+\
0332                                 "\n\tHostname=>"+application.attributes["hostname"].value +\
0333                                 "\n\tPort=>"+application.attributes["port"].value +\
0334                 "\nThe count rises to:"+str(DPapplications[uniqIndex])
0335                 return {}
0336         else:
0337                 DPapplications[uniqIndex]=1
0338         
0339         
0340         if application.hasAttribute("className"):
0341                 if application.attributes["className"].value not in knownclassNames:
0342                         print "Attribute 'urn' has an unexpected value of '"+application.attributes["className"].value+"', where the expected value is one of the following classNames:'"+"','".join(knownclassNames)+ "'"
0343                         result={}
0344         else:
0345                 print "No 'urn' Attribute in XdaqApplication element"
0346                 result={}
0347         
0348         if application.hasAttribute("urn"):
0349                 if application.attributes["urn"].value!=knownclassNames[application.attributes["className"].value]["urn"]:
0350                         print "Attribute 'urn' has an unexpected value of '"+application.attributes["urn"].value+"', where the expected value is '"+knownclassNames[application.attributes["className"].value]["urn"]+"'"
0351                         result={}
0352         else:
0353                 print "No 'urn' Attribute in XdaqApplication element"
0354                 result={}
0355         if application.hasAttribute("qualifiedResourceType"):
0356                 if application.attributes["qualifiedResourceType"].value!="rcms.fm.resource.qualifiedresource.XdaqApplication":
0357                         print "Attribute 'qualifiedResourceType' has an unexpected value of '"+application.attributes["qualifiedResourceType"].value+"', where the expected value is 'rcms.fm.resource.qualifiedresource.XdaqApplication'"
0358                         result={}
0359         else:
0360                 print "No 'qualifiedResourceType' Attribute in XdaqApplication element" 
0361                 result={}       
0362         if application.hasAttribute("modulePath"):
0363                 if application.attributes["modulePath"].value!=knownclassNames[application.attributes["className"].value]["modulePath"]:
0364                         print "Attribute 'modulePath' has an unexpected value of '"+application.attributes["modulePath"].value+"', where the expected value is: '"+knownclassNames[application.attributes["className"].value]["modulePath"]+"'"
0365                         result={}
0366         else:
0367                 print "No 'modulePath' Attribute in XdaqApplication element"    
0368                 result={}
0369         if application.hasAttribute("xdaqPath"):
0370                 if application.attributes["xdaqPath"].value!="/opt/xdaq":
0371                         print "Attribute 'xdaqPath' has an unexpected value of '"+application.attributes["xdaqPath"].value+"', where the expected value is '/opt/xdaq'"
0372                         result={}
0373         else:
0374                 print "No 'xdaqPath' Attribute in XdaqApplication element"      
0375                 result={}
0376         return result
0377 ################################################################################
0378 def verifyFile(filename):
0379         global verbose,user
0380         from EnviromentSettings import port,host,sourceURL
0381         verbose and sys.stdout.write("Parsing XML file...\n")
0382         xmldoc = minidom.parse(filename)
0383         verbose and sys.stdout.write("Trimming XML tree...\n")
0384         xmlTrim(xmldoc)
0385         verbose and sys.stdout.write("Converting configFele Element Text node into Tree nodes...\n")
0386         configfiles=xmldoc.getElementsByTagName("configFile")
0387         for item in configfiles:
0388                 try:
0389                         appinf.appendDataXML(item)
0390                 except :
0391                         sys.stderr.write("Parser Error while trying to append:\n")
0392                         sys.stderr.write("\n")
0393                         sys.stderr.write( item.firstChild.nodeValue)
0394         #Autodetect username
0395         userAutodetect(xmldoc)
0396         #Chk Configuration
0397         verbose and sys.stdout.write("Checking configuration element...\n")
0398         ConfigNode = xmldoc.getElementsByTagName("Configuration")
0399         result=True
0400         if len(ConfigNode) == 0:
0401                 print "No Configuration element in XMLfile"
0402                 return False
0403         if not ConfigNode[0].hasAttribute("user") or ConfigNode[0].attributes["user"]=="":
0404                 print "No user attribute or blank in Configuration element"
0405                 result=False 
0406         if not ConfigNode[0].hasAttribute("path") or \
0407                         ConfigNode[0].attributes["path"].value=="": 
0408                 print "No path attribute or blank in Configuration element"
0409                 result=False
0410         if not ConfigNode[0].hasAttribute("path") or \
0411                         os.path.basename(ConfigNode[0].attributes["path"].value) !=filename[:len(filename)-4]:
0412                 print "WARNING!!!!! path attribute doesn't match filename"
0413                 print "\t"+filename[:len(filename)-4] + " <> " + ConfigNode[0].attributes["path"].value
0414         #Chk ->Function Managers
0415         verbose and sys.stdout.write("Checking Function Manager element...\n")
0416         FmNode = ConfigNode[0].getElementsByTagName("FunctionManager")
0417         if len(FmNode) == 0:
0418                 print "No FunctionManager element in Configuration node"
0419                 return False
0420         message=[""]
0421         message+=FmNode[0].hasAttribute("name") and (FmNode[0].attributes["name"].value=="DQMtest" and [""] or False) or \
0422                         "No 'name' Attribute or value is not what is expected( DQMtest )\n"
0423         message+=FmNode[0].hasAttribute("hostname") and (FmNode[0].attributes["hostname"].value==host[user] and [""] or False) or \
0424                         "No 'hostname' Attribute or value is not what is expected( "+host[user]+" )\n"  
0425         message+=FmNode[0].hasAttribute("port") and (FmNode[0].attributes["port"].value==port[user] and [""] or False) or \
0426                         "No 'port' Attribute or value is not what is expected( "+port[user]+" )\n"  
0427         message+=FmNode[0].hasAttribute("qualifiedResourceType") and (FmNode[0].attributes["qualifiedResourceType"].value=="rcms.fm.resource.qualifiedresource.FunctionManager"  and [""] or False) or\
0428                         "No 'qualifiedResourceType' Attribute or value is not what is expected( rcms.fm.resource.qualifiedresource.FunctionManager )\n"  
0429         message+=FmNode[0].hasAttribute("role") and (FmNode[0].attributes["role"].value=="DQM" and [""] or False) or \
0430                         "No 'role' Attribute or value is not what is expected( DQM )\n"   
0431         message+=FmNode[0].hasAttribute("sourceURL") and (FmNode[0].attributes["sourceURL"].value==sourceURL[user] and [""] or False) or \
0432                         "No 'sourceURL' Attribute or value is not what is expected( "+sourceURL[user]+" )\n"   
0433         message+=FmNode[0].hasAttribute("className") and (FmNode[0].attributes["className"].value=="rcms.fm.app.dqm.MyFunctionManager" and [""] or False) or \
0434                         "No 'className' Attribute or value is not what is expected( rcms.fm.app.dqm.MyFunctionManager )\n"
0435         message="".join(message).strip()
0436         if message:
0437                 print message
0438                 result=False
0439         #Chk -->Services (JobControl)
0440         verbose and sys.stdout.write("Checking service nodes...\n")
0441         serviceNodes=FmNode[0].getElementsByTagName("Service")
0442         if len(FmNode) == 0:
0443                 print "No Service elements in FunctionManager node"
0444                 return False
0445         JCServers=[]
0446         verbose and sys.stdout.write("processing "+str(len(serviceNodes))+" service nodes...\n")
0447         for server in serviceNodes:
0448                 lastService=chkService(server)
0449                 if lastService:
0450                         JCServers+=lastService
0451                         verbose and sys.stdout.write("Service checked on server:"+JCServers[-1]+"...\n")
0452                 else:
0453                         verbose and sys.stdout.write("Service didn't pass the check\n")         
0454                         result=False
0455         
0456         #Chk -->Applications
0457         verbose and sys.stdout.write("Checking application nodes...\n")
0458         applicationNodes=FmNode[0].getElementsByTagName("XdaqApplication")
0459         numapps=len(applicationNodes)
0460         Apps=[]
0461         verbose and sys.stdout.write("processing "+str(numapps)+" XdaqApplication nodes...\n")
0462         for application in applicationNodes:
0463                 lastApp=chkApplications(application,JCServers) 
0464                 if lastApp:
0465                         Apps.append(lastApp)
0466                         verbose and sys.stdout.write("Application checked on server:"+lastApp["server"]+" port:"+lastApp["port"]+"...\n")
0467                 else:
0468                         verbose and sys.stdout.write("Application didn't pass the check\n")
0469                         result=False
0470         #Chk -->Executives
0471         verbose and sys.stdout.write("Checking Executive nodes...\n")
0472         executiveNodes=FmNode[0].getElementsByTagName("XdaqExecutive")
0473         numexec=len(executiveNodes)
0474         if numexec != numapps:
0475                 print "Warning!!! the number of applications is diferent from the number of executives"
0476         verbose and sys.stdout.write("processing "+str(numexec)+" XdaqExecutive nodes...\n")
0477         for executive in executiveNodes:
0478                 lastExec=chkExecutives(executive)
0479                 if lastExec:
0480                         verbose and sys.stdout.write("Executive checked on server:"+lastExec["server"]+" port:"+lastExec["port"]+"...\n")
0481                 else:
0482                         verbose and sys.stdout.write("Executive didn't pass the check\n")               
0483                         result=False
0484         #appinf.printXMLtree(xmldoc)
0485         
0486         return result
0487 ################################################################################
0488 #Script operation                                                              #
0489 ################################################################################
0490 if __name__ == "__main__":             
0491         try:
0492                 (args,filename)=gop.getopt(sys.argv[1:],"fhsv")
0493         except getopt.GetoptError:
0494                 sys.stderr.write(  "Sintax Error unrecognised option\n" )
0495                 sys.stderr.write( __doc__ )
0496                 sys.exit(2)
0497         
0498         for item in args:
0499                 if item[0]=="-h":
0500                         sys.stdout.write( __doc__ )
0501                         sys.exit()
0502                 elif item[0]=="-f":
0503                         fullchk=True
0504                 elif item[0]=="-v":
0505                         verbose=True
0506         if len(filename)==0:
0507                 sys.stderr.write(  "\nERROR: xdaq XML config file name not present, please specify\n\n" )
0508                 sys.stdout.write(__doc__)
0509         elif len(filename) > 1:
0510                 sys.stderr.write(  "\nERROR: Too many file names or other arguments, please specify only 1\n\n" )
0511                 sys.stdout.write(__doc__)
0512                 sys.exit(2)
0513         elif not os.path.exists(filename[0]):
0514                 sys.stderr.write(  "\nERROR: xdaq XML config file does not exist please verify\n\n" )
0515                 sys.stdout.write(__doc__)
0516                 sys.exit(2)
0517         if verifyFile(filename[0]):
0518                 print "Configuration file OK"
0519         else:
0520                 print "Configuration file FAILED verification, plese check output for details"