Esempio n. 1
0
def parseVo(voSrc, configFile, voName, eMsg, override):

	# Check the source of the VO Name
	if (voSrc == VO_SOURCE_CERT_EXTENSION or voSrc == VO_SOURCE_VO_OPT) and not configFile :
		# Only vo is provided, generate file name:
		configFile = generateVoPath(voName)	

	# Retrieve the configuration directory
	confDir = os.path.dirname(configFile)

	# Look for configuration Vo file
	if not os.path.isfile(configFile):
	
		if voSrc == VO_SOURCE_CERT_EXTENSION or voSrc == VO_SOURCE_VO_OPT:	
			# In these cases vo file was autogenerated user config file may not be there
			return [0, voName, 0, configFile]

		else: 
			errMsg(eMsg,'UI_FILE_NOT_FOUND', configFile)
			return [1, "", 0, configFile]
	
	# Parsing Ad VO file
	ad = AdWrapper(1)
	if ad.fromFile(configFile):
		errMsg(eMsg , "UI_JDL_ADD_ERROR", "Unable to parse Vo conf file (not a valid classad):\n " + configFile )
		return [1, "", 0, configFile] 

		
	#The VirtualOrganisation Attribute must match with the specified voName
	virtualOrganisation = ad.getVirtualOrganisation();
		
	# Check if the Virtual Organisation is present inside the AD
	if virtualOrganisation:

		# Check if the VO name has been set
		if voName:
			#The VirtualOrganisation Attribute must match with the specified voName
			if virtualOrganisation.lower()!=voName.lower():
				if override == 1:
					virtualOrganisation = voName
				else:
					errMsg(eMsg,'UI_JDL_VO_MATCH', voName , val ,configFile)
					return [1, "", 0, configFile]
		# SUCCESS
		return [0, virtualOrganisation , ad, configFile ]
	else:
		errMsg(eMsg,'UI_JDL_ADD_ERROR', "Missing VirtualOrganisation attribute inside JDL Default Attributes section \"JdlDefaultAttributes\" of configuration file " + configFile )
		return [1, "", 0, configFile]