本文整理汇总了Python中DIRAC.ConfigurationSystem.Client.CSAPI.CSAPI.setOption方法的典型用法代码示例。如果您正苦于以下问题:Python CSAPI.setOption方法的具体用法?Python CSAPI.setOption怎么用?Python CSAPI.setOption使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DIRAC.ConfigurationSystem.Client.CSAPI.CSAPI
的用法示例。
在下文中一共展示了CSAPI.setOption方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __setCSElementStatus
# 需要导入模块: from DIRAC.ConfigurationSystem.Client.CSAPI import CSAPI [as 别名]
# 或者: from DIRAC.ConfigurationSystem.Client.CSAPI.CSAPI import setOption [as 别名]
def __setCSElementStatus(self, elementName, elementType, statusType, status):
"""
Sets on the CS the Elements status
"""
# DIRAC doesn't store the status of ComputingElements nor FTS in the CS, so here we can just do nothing
if elementType in ('ComputingElement', 'FTS'):
return S_OK()
# If we are here it is because elementType is either 'StorageElement' or 'Catalog'
statuses = self.rssConfig.getConfigStatusType(elementType)
if statusType not in statuses:
gLogger.error("%s is not a valid statusType" % statusType)
return S_ERROR("%s is not a valid statusType: %s" % (statusType, statuses))
if elementType == 'StorageElement':
cs_path = "/Resources/StorageElements"
elif elementType == 'Catalog':
cs_path = "/Resources/FileCatalogs"
# FIXME: This a probably outdated location (new one is in /Operations/[]/Services/Catalogs)
# but needs to be VO-aware
statusType = 'Status'
csAPI = CSAPI()
csAPI.setOption("%s/%s/%s/%s" % (cs_path, elementName, elementType, statusType), status)
res = csAPI.commitChanges()
if not res['OK']:
gLogger.warn('CS: %s' % res['Message'])
return res
示例2: updateCS
# 需要导入模块: from DIRAC.ConfigurationSystem.Client.CSAPI import CSAPI [as 别名]
# 或者: from DIRAC.ConfigurationSystem.Client.CSAPI.CSAPI import setOption [as 别名]
def updateCS( changeSet ):
global vo, dry, ceBdiiDict
changeList = list( changeSet )
changeList.sort()
if dry:
gLogger.notice( 'The following needed changes are detected:\n' )
else:
gLogger.notice( 'We are about to make the following changes to CS:\n' )
for entry in changeList:
gLogger.notice( "%s/%s %s -> %s" % entry )
if not dry:
csAPI = CSAPI()
csAPI.initialize()
result = csAPI.downloadCSData()
if not result['OK']:
gLogger.error( 'Failed to initialize CSAPI object', result['Message'] )
DIRACExit( -1 )
for section, option, value, new_value in changeSet:
if value == 'Unknown' or not value:
csAPI.setOption( cfgPath( section, option ), new_value )
else:
csAPI.modifyValue( cfgPath( section, option ), new_value )
yn = raw_input( 'Do you want to commit changes to CS ? [default yes] [yes|no]: ' )
if yn == '' or yn.lower().startswith( 'y' ):
result = csAPI.commit()
if not result['OK']:
gLogger.error( "Error while commit to CS", result['Message'] )
else:
gLogger.notice( "Successfully committed %d changes to CS" % len( changeSet ) )
示例3: __setCSStorageElementStatus
# 需要导入模块: from DIRAC.ConfigurationSystem.Client.CSAPI import CSAPI [as 别名]
# 或者: from DIRAC.ConfigurationSystem.Client.CSAPI.CSAPI import setOption [as 别名]
def __setCSStorageElementStatus( self, elementName, statusType, status ):
"""
Sets on the CS the StorageElements status
"""
statuses = self.rssConfig.getConfigStatusType( 'StorageElement' )
if not statusType in statuses:
gLogger.error( "%s is not a valid statusType" % statusType )
return S_ERROR( "%s is not a valid statusType: %s" % ( statusType, statuses ) )
csAPI = CSAPI()
cs_path = "/Resources/StorageElements"
csAPI.setOption( "%s/%s/%s" % ( cs_path, elementName, statusType ), status )
res = csAPI.commitChanges()
if not res[ 'OK' ]:
gLogger.warn( 'CS: %s' % res[ 'Message' ] )
return res
示例4: Bdii2CSAgent
# 需要导入模块: from DIRAC.ConfigurationSystem.Client.CSAPI import CSAPI [as 别名]
# 或者: from DIRAC.ConfigurationSystem.Client.CSAPI.CSAPI import setOption [as 别名]
#.........这里部分代码省略.........
if diracSiteName['Value'] in self.selectedSites:
continue
self.log.info("Dropping site %s, aka %s" % (site, diracSiteName))
ceBdiiDict.pop(site)
return
def __updateCS(self, bdiiChangeSet):
queueVODict = {}
changeSet = set()
for entry in bdiiChangeSet:
section, option, _value, new_value = entry
if option == "VO":
queueVODict.setdefault(section, set())
queueVODict[section] = queueVODict[section].union(set(new_value.split(',')))
else:
changeSet.add(entry)
for section, VOs in queueVODict.items():
changeSet.add((section, 'VO', '', ','.join(VOs)))
if changeSet:
changeList = sorted(changeSet)
body = '\n'.join(["%s/%s %s -> %s" % entry for entry in changeList])
if body and self.addressTo and self.addressFrom:
notification = NotificationClient()
result = notification.sendMail(self.addressTo, self.subject, body, self.addressFrom, localAttempt=False)
if body:
self.log.info('The following configuration changes were detected:')
self.log.info(body)
for section, option, value, new_value in changeSet:
if value == 'Unknown' or not value:
self.csAPI.setOption(cfgPath(section, option), new_value)
else:
self.csAPI.modifyValue(cfgPath(section, option), new_value)
if self.dryRun:
self.log.info("Dry Run: CS won't be updated")
self.csAPI.showDiff()
else:
result = self.csAPI.commit()
if not result['OK']:
self.log.error("Error while committing to CS", result['Message'])
else:
self.log.info("Successfully committed %d changes to CS" % len(changeList))
return result
else:
self.log.info("No changes found")
return S_OK()
def __lookForNewSEs(self):
""" Look up BDII for SEs not yet present in the DIRAC CS
"""
bannedSEs = self.am_getOption('BannedSEs', [])
result = getSEsFromCS()
if not result['OK']:
return result
knownSEs = set(result['Value'])
knownSEs = knownSEs.union(set(bannedSEs))
for vo in self.voName:
result = self.__getBdiiSEInfo(vo)
if not result['OK']:
continue
示例5: CVMFSAdder
# 需要导入模块: from DIRAC.ConfigurationSystem.Client.CSAPI import CSAPI [as 别名]
# 或者: from DIRAC.ConfigurationSystem.Client.CSAPI.CSAPI import setOption [as 别名]
#.........这里部分代码省略.........
for application in self.applications:
av_apps = gConfig.getSections("%(softSec)s/%(platform)s/" % self.parameter + str(application), [])
if not av_apps['OK']:
gLogger.error("Could not find this application in the CS: '%s'" % application)
gLogger.error("Add its section to the CS, if it is missing")
return S_ERROR()
gLogger.notice("All OK, continuing...")
return S_OK()
def commitToCS(self):
"""write changes to the CS to the server"""
if self.modifiedCS and not self.cliParams.dryRun:
gLogger.notice("Commiting changes to the CS")
result = self.csAPI.commit()
if not result[ 'OK' ]:
gLogger.error('Commit failed with message = %s' % (result[ 'Message' ]))
return S_ERROR("Failed to commit to CS")
gLogger.info('Successfully committed changes to CS')
else:
gLogger.info('No modifications to CS required')
return S_OK()
def addAllToCS(self):
"""add all the applications to the CS, take care of special cases (mokka, ildconfig, ddsim,...)"""
from ILCDIRAC.ILCTransformationSystem.Utilities.ReleaseHelper import insertCSSection
for application in self.applications:
csParameter = dict( CVMFSEnvScript = self.cliParams.initScriptLocation,
CVMFSPath = self.parameter['basepath']
)
if application == 'mokka':
csParameter['CVMFSDBSlice'] = self.cliParams.dbSliceLocation
if application == 'ddsim':
self.findDDSimDetectorModels()
csPathModels = "Operations/Defaults/DDSimDetectorModels"
csModels = { self.parameter["version"] : self.detmodels }
insertCSSection( self.csAPI, csPathModels, csModels )
self.modifiedCS = True
elif application.endswith('config'):
del csParameter['CVMFSEnvScript']
csParameter['CVMFSPath'] = self.cliParams.configPath
if self.cliParams.dbSliceLocation:
csParameter['CVMFSDBSlice'] = self.cliParams.dbSliceLocation
resInsert = self.insertApplicationToCS(application, csParameter)
if not resInsert['OK']:
return resInsert
return S_OK()
def insertApplicationToCS(self, name, csParameter):
"""add given application found via CVMFS to the CS"""
pars = dict(self.parameter)
pars['name'] = name
gLogger.notice("%(name)s: Adding version %(version)s to the CS" % pars)
existingVersions = gConfig.getSections("%(softSec)s/%(platform)s/%(name)s" % pars, [])
if not existingVersions['OK']:
gLogger.error("Could not find all versions available in CS: %s" % existingVersions['Message'])
dexit(255)
if pars['version'] in existingVersions['Value']:
gLogger.always('Application %s %s for %s already in CS, nothing to do' % (name.lower(),
pars['version'],
pars['platform']))
return S_OK()
csPath = self.softSec + ("/%(platform)s/%(name)s/%(version)s/" % pars)
for par, val in csParameter.iteritems():
gLogger.notice("Add: %s = %s" %(csPath+par, val))
result = self.csAPI.setOption(csPath+par, val)
if result['OK']:
self.modifiedCS = True
else:
gLogger.error("Failure to add to CS", result['Message'])
return S_ERROR("")
return S_OK()
def addSoftware(self):
"""run all the steps to add software to grid and CS"""
resAdd = self.addAllToCS()
if not resAdd['OK']:
return resAdd
resCommit = self.commitToCS()
if not resCommit['OK']:
return resCommit
return S_OK()
示例6:
# 需要导入模块: from DIRAC.ConfigurationSystem.Client.CSAPI import CSAPI [as 别名]
# 或者: from DIRAC.ConfigurationSystem.Client.CSAPI.CSAPI import setOption [as 别名]
ses.extend( res['Value']['SE'].replace( ' ', '' ).split( ',' ) )
if not ses:
gLogger.error( "There were no SEs provided" )
DIRAC.exit()
readAllowed = []
writeAllowed = []
storageCFGBase = "/Resources/StorageElements"
for se in ses:
res = gConfig.getOptionsDict( "%s/%s" % ( storageCFGBase, se ) )
if not res['OK']:
gLogger.error( "Storage Element %s does not exist" % se )
continue
existingOptions = res['Value']
if read and existingOptions['ReadAccess'] == "InActive":
res = csAPI.setOption( "%s/%s/ReadAccess" % ( storageCFGBase, se ), "Active" )
if not res['OK']:
gLogger.error( "Failed to update %s read access to Active" % se )
else:
gLogger.debug( "Successfully updated %s read access to Active" % se )
readAllowed.append( se )
if write and existingOptions['WriteAccess'] == "InActive":
res = csAPI.setOption( "%s/%s/WriteAccess" % ( storageCFGBase, se ), "Active" )
if not res['OK']:
gLogger.error( "Failed to update %s write access to Active" % se )
else:
gLogger.debug( "Successfully updated %s write access to Active" % se )
writeAllowed.append( se )
res = csAPI.commitChanges()
if not res['OK']:
gLogger.error( "Failed to commit changes to CS", res['Message'] )
示例7: CE2CSAgent
# 需要导入模块: from DIRAC.ConfigurationSystem.Client.CSAPI import CSAPI [as 别名]
# 或者: from DIRAC.ConfigurationSystem.Client.CSAPI.CSAPI import setOption [as 别名]
class CE2CSAgent(AgentModule):
addressTo = ""
addressFrom = ""
voName = ""
subject = "CE2CSAgent"
alternativeBDIIs = []
def initialize(self):
# TODO: Have no default and if no mail is found then use the diracAdmin group
# and resolve all associated mail addresses.
self.addressTo = self.am_getOption("MailTo", self.addressTo)
self.addressFrom = self.am_getOption("MailFrom", self.addressFrom)
# Create a list of alternative bdii urls
self.alternativeBDIIs = self.am_getOption("AlternativeBDIIs", [])
# Check if the bdii url is appended by a port number, if not append the default 2170
for index, url in enumerate(self.alternativeBDIIs):
if not url.split(":")[-1].isdigit():
self.alternativeBDIIs[index] += ":2170"
if self.addressTo and self.addressFrom:
self.log.info("MailTo", self.addressTo)
self.log.info("MailFrom", self.addressFrom)
if self.alternativeBDIIs:
self.log.info("AlternativeBDII URLs:", self.alternativeBDIIs)
self.subject = "CE2CSAgent"
# This sets the Default Proxy to used as that defined under
# /Operations/Shifter/TestManager
# the shifterProxy option in the Configuration can be used to change this default.
self.am_setOption("shifterProxy", "TestManager")
self.voName = self.am_getOption("VirtualOrganization", [])
if not self.voName:
vo = getVO()
if vo:
self.voName = [vo]
if self.voName:
self.log.info("Agent will manage VO(s) %s" % self.voName)
else:
self.log.fatal("VirtualOrganization option not defined for agent")
return S_ERROR()
self.csAPI = CSAPI()
return self.csAPI.initialize()
def execute(self):
self.log.info("Start Execution")
result = getProxyInfo()
if not result["OK"]:
return result
infoDict = result["Value"]
self.log.info(formatProxyInfoAsString(infoDict))
# Get a "fresh" copy of the CS data
result = self.csAPI.downloadCSData()
if not result["OK"]:
self.log.warn("Could not download a fresh copy of the CS data", result["Message"])
self.__lookForCE()
self.__infoFromCE()
self.log.info("End Execution")
return S_OK()
def __checkAlternativeBDIISite(self, fun, *args):
if self.alternativeBDIIs:
self.log.warn("Trying to use alternative BDII sites")
for site in self.alternativeBDIIs:
self.log.info("Trying to contact alternative BDII", site)
if len(args) == 1:
result = fun(args[0], host=site)
elif len(args) == 2:
result = fun(args[0], vo=args[1], host=site)
if not result["OK"]:
self.log.error("Problem contacting alternative BDII", result["Message"])
elif result["OK"]:
return result
self.log.warn("Also checking alternative BDII sites failed")
return result
def __lookForCE(self):
knownCEs = self.am_getOption("BannedCEs", [])
result = gConfig.getSections("/Resources/Sites")
if not result["OK"]:
return
grids = result["Value"]
for grid in grids:
result = gConfig.getSections("/Resources/Sites/%s" % grid)
if not result["OK"]:
return
sites = result["Value"]
for site in sites:
opt = gConfig.getOptionsDict("/Resources/Sites/%s/%s" % (grid, site))["Value"]
ces = List.fromChar(opt.get("CE", ""))
#.........这里部分代码省略.........
示例8: Bdii2CSAgent
# 需要导入模块: from DIRAC.ConfigurationSystem.Client.CSAPI import CSAPI [as 别名]
# 或者: from DIRAC.ConfigurationSystem.Client.CSAPI.CSAPI import setOption [as 别名]
#.........这里部分代码省略.........
# We have collected all the changes, consolidate VO settings
result = self.__updateCS( bdiiChangeSet )
return result
def __updateCS( self, bdiiChangeSet ):
queueVODict = {}
changeSet = set()
for entry in bdiiChangeSet:
section, option , _value, new_value = entry
if option == "VO":
queueVODict.setdefault( section, set() )
queueVODict[section] = queueVODict[section].union( set( new_value.split( ',' ) ) )
else:
changeSet.add( entry )
for section, VOs in queueVODict.items():
changeSet.add( ( section, 'VO', '', ','.join( VOs ) ) )
if changeSet:
changeList = list( changeSet )
changeList.sort()
body = '\n'.join( [ "%s/%s %s -> %s" % entry for entry in changeList ] )
if body and self.addressTo and self.addressFrom:
notification = NotificationClient()
result = notification.sendMail( self.addressTo, self.subject, body, self.addressFrom, localAttempt = False )
if body:
self.log.info( 'The following configuration changes were detected:' )
self.log.info( body )
for section, option, value, new_value in changeSet:
if value == 'Unknown' or not value:
self.csAPI.setOption( cfgPath( section, option ), new_value )
else:
self.csAPI.modifyValue( cfgPath( section, option ), new_value )
result = self.csAPI.commit()
if not result['OK']:
self.log.error( "Error while committing to CS", result['Message'] )
else:
self.log.info( "Successfully committed %d changes to CS" % len( changeList ) )
return result
else:
self.log.info( "No changes found" )
return S_OK()
def __lookForNewSEs( self ):
""" Look up BDII for SEs not yet present in the DIRAC CS
"""
bannedSEs = self.am_getOption( 'BannedSEs', [] )
result = getSEsFromCS()
if not result['OK']:
return result
knownSEs = set( result['Value'] )
knownSEs = knownSEs.union( set( bannedSEs ) )
for vo in self.voName:
result = self.__getBdiiSEInfo( vo )
if not result['OK']:
continue
bdiiInfo = result['Value']
result = getGridSRMs( vo, bdiiInfo = bdiiInfo, srmBlackList = knownSEs )
if not result['OK']:
continue
示例9: DDSimTarMaker
# 需要导入模块: from DIRAC.ConfigurationSystem.Client.CSAPI import CSAPI [as 别名]
# 或者: from DIRAC.ConfigurationSystem.Client.CSAPI.CSAPI import setOption [as 别名]
#.........这里部分代码省略.........
pprint(csModels)
result = self.insertCSSection( csPathModels, csModels )
if self.csapi is not None:
resProxy = checkOrGetGroupProxy( "diracAdmin" )
if not resProxy['OK']:
gLogger.error( "Failed to get AdminProxy", resProxy['Message'] )
raise RuntimeError( "Failed to get diracAdminProxy" )
self.csapi.commit()
if not result['OK']:
gLogger.error( "Failed to create CS Section", result['Message'] )
raise RuntimeError( "Failed to create CS Section" )
def insertCSSection( self, path, pardict ):
""" insert a section and values (or subsections) into the CS
:param str path: full path of the new section
:param str pardict: dictionary of key values in the new section, values can also be dictionaries
:return: S_OK(), S_ERROR()
"""
from DIRAC.ConfigurationSystem.Client.CSAPI import CSAPI
if self.csapi is None:
self.csapi = CSAPI()
for key, value in pardict.iteritems():
newSectionPath = os.path.join(path,key)
gLogger.debug( "Adding to cs %s : %s " % ( newSectionPath, value ) )
self.csapi.createSection( path )
if isinstance( value, dict ):
res = self.insertCSSection( newSectionPath, value )
else:
res = self.csapi.setOption( newSectionPath, value )
if not res['OK']:
return res
else:
gLogger.notice( "Added to CS: %s " % res['Value'] )
return S_OK("Added all things to cs")
def createDDSimTarBall( self ):
""" do everything to create the DDSim tarball"""
self.parseArgs()
ddBase, lcgeoBase, _rootsys = self.checkEnvironment()
realTargetFolder = os.path.join( os.getcwd(), self.name+self.version )
targetFolder = os.path.join( os.getcwd(), "temp", self.name+self.version )
for folder in (targetFolder, targetFolder+"/lib"):
try:
os.makedirs( folder )
except OSError:
pass
libraries = set()
rootmaps = set()
dd4hepLibPath = getLibraryPath( ddBase )
lcgeoPath = getLibraryPath( lcgeoBase )
self.copyDetectorModels( lcgeoBase, "CLIC" , targetFolder+"/detectors" )
self.copyDetectorModels( lcgeoBase, "ILD" , targetFolder+"/detectors" )
copyFolder( ddBase+"/DDDetectors/compact", realTargetFolder.rstrip("/")+"/DDDetectors")
示例10: DiracAdmin
# 需要导入模块: from DIRAC.ConfigurationSystem.Client.CSAPI import CSAPI [as 别名]
# 或者: from DIRAC.ConfigurationSystem.Client.CSAPI.CSAPI import setOption [as 别名]
#.........这里部分代码省略.........
return S_OK()
for se in siteSEs:
sections = gConfig.getSections( '/Resources/StorageElements/%s/' % ( se ) )
if not sections['OK']:
return sections
for section in sections['Value']:
if gConfig.getValue( '/Resources/StorageElements/%s/%s/ProtocolName' % ( se, section ), '' ) == 'SRM2':
path = '/Resources/StorageElements/%s/%s/ProtocolsList' % ( se, section )
self.log.verbose( 'Setting %s to %s' % ( path, ', '.join( protocolsList ) ) )
result = self.csSetOption( path, ', '.join( protocolsList ) )
if not result['OK']:
return result
modifiedCS = True
if modifiedCS:
result = self.csCommitChanges( False )
if not result[ 'OK' ]:
return S_ERROR( 'CS Commit failed with message = %s' % ( result[ 'Message' ] ) )
else:
if printOutput:
print 'Successfully committed changes to CS'
else:
if printOutput:
print 'No modifications to CS required'
return S_OK()
#############################################################################
def csSetOption( self, optionPath, optionValue ):
"""
Function to modify an existing value in the CS.
"""
return self.csAPI.setOption( optionPath, optionValue )
#############################################################################
def csSetOptionComment( self, optionPath, comment ):
"""
Function to modify an existing value in the CS.
"""
return self.csAPI.setOptionComment( optionPath, comment )
#############################################################################
def csModifyValue( self, optionPath, newValue ):
"""
Function to modify an existing value in the CS.
"""
return self.csAPI.modifyValue( optionPath, newValue )
#############################################################################
def csRegisterUser( self, username, properties ):
"""
Registers a user in the CS.
- username: Username of the user (easy;)
- properties: Dict containing:
- DN
- groups : list/tuple of groups the user belongs to
- <others> : More properties of the user, like mail
"""
return self.csAPI.addUser( username, properties )
#############################################################################
def csDeleteUser( self, user ):
"""
示例11: GOCDB2CSAgent
# 需要导入模块: from DIRAC.ConfigurationSystem.Client.CSAPI import CSAPI [as 别名]
# 或者: from DIRAC.ConfigurationSystem.Client.CSAPI.CSAPI import setOption [as 别名]
#.........这里部分代码省略.........
def __addDIRACSiteName(self, inputList):
"""
Extend given list of GOCDB endpoints with DIRAC site name, i.e.
add an entry "DIRACSITENAME" in dictionaries that describe endpoints.
If given site name could not be found "DIRACSITENAME" is set to 'None'.
:return: List of perfSONAR endpoints (dictionaries).
"""
log = self.log.getSubLogger('__addDIRACSiteName')
log.debug('Begin function ...')
# get site name dictionary
result = getDIRACGOCDictionary()
if not result['OK']:
log.error("getDIRACGOCDictionary() failed with message: %s" % result['Message'])
return S_ERROR('Could not get site name dictionary')
# reverse the dictionary (assume 1 to 1 relation)
DIRACGOCDict = result['Value']
GOCDIRACDict = dict(zip(DIRACGOCDict.values(), DIRACGOCDict.keys()))
# add DIRAC site names
outputList = []
for entry in inputList:
try:
entry['DIRACSITENAME'] = GOCDIRACDict[entry['SITENAME']]
except KeyError:
self.log.warn("No dictionary entry for %s. " % entry['SITENAME'])
entry['DIRACSITENAME'] = None
outputList.append(entry)
log.debug('End function.')
return S_OK(outputList)
def __updateConfiguration(self, setElements=None, delElements=None):
"""
Update configuration stored by CS.
"""
if setElements is None:
setElements = {}
if delElements is None:
delElements = []
log = self.log.getSubLogger('__updateConfiguration')
log.debug('Begin function ...')
# assure existence and proper value of a section or an option
for path, value in setElements.iteritems():
if value is None:
section = path
else:
split = path.rsplit('/', 1)
section = split[0]
try:
result = self.csAPI.createSection(section)
if not result['OK']:
log.error("createSection() failed with message: %s" % result['Message'])
except Exception as e:
log.error("Exception in createSection(): %s" % repr(e).replace(',)', ')'))
if value is not None:
try:
result = self.csAPI.setOption(path, value)
if not result['OK']:
log.error("setOption() failed with message: %s" % result['Message'])
except Exception as e:
log.error("Exception in setOption(): %s" % repr(e).replace(',)', ')'))
# delete elements in the configuration
for path in delElements:
result = self.csAPI.delOption(path)
if not result['OK']:
log.warn("delOption() failed with message: %s" % result['Message'])
result = self.csAPI.delSection(path)
if not result['OK']:
log.warn("delSection() failed with message: %s" % result['Message'])
if self.dryRun:
log.info("Dry Run: CS won't be updated")
self.csAPI.showDiff()
else:
# update configuration stored by CS
result = self.csAPI.commit()
if not result['OK']:
log.error("commit() failed with message: %s" % result['Message'])
return S_ERROR("Could not commit changes to CS.")
else:
log.info("Committed changes to CS")
log.debug('End function.')
return S_OK()
# define mapping between an agent option in the configuration and a function call
__functionMap = {'UpdatePerfSONARS': updatePerfSONARConfiguration,
}
示例12: site
# 需要导入模块: from DIRAC.ConfigurationSystem.Client.CSAPI import CSAPI [as 别名]
# 或者: from DIRAC.ConfigurationSystem.Client.CSAPI.CSAPI import setOption [as 别名]
userName = res["Value"]["username"]
group = res["Value"]["group"]
if not sites:
Script.showHelp()
DIRAC.exit(-1)
catalogCFGBase = "/Resources/FileCatalogs/LcgFileCatalogCombined"
banned = []
for site in sites:
res = gConfig.getOptionsDict("%s/%s" % (catalogCFGBase, site))
if not res["OK"]:
gLogger.error("The provided site (%s) does not have an associated catalog." % site)
continue
res = csAPI.setOption("%s/%s/Status" % (storageCFGBase, site), "InActive")
if not res["OK"]:
gLogger.error("Failed to update %s catalog status to InActive" % site)
else:
gLogger.debug("Successfully updated %s catalog status to InActive" % site)
banned.append(site)
if not banned:
gLogger.error("Failed to ban any catalog mirrors")
DIRAC.exit(-1)
res = csAPI.commitChanges()
if not res["OK"]:
gLogger.error("Failed to commit changes to CS", res["Message"])
DIRAC.exit(-1)
示例13: CSAPI
# 需要导入模块: from DIRAC.ConfigurationSystem.Client.CSAPI import CSAPI [as 别名]
# 或者: from DIRAC.ConfigurationSystem.Client.CSAPI.CSAPI import setOption [as 别名]
# SecurityManager = FullSecurityManager
# }
# }
# Databases
# {
# FileCatalogDB
# {
# DBName = FileCatalogDB
# }
# }
# }
# }
from DIRAC.ConfigurationSystem.Client.CSAPI import CSAPI
csAPI = CSAPI()
for sct in ['Systems/DataManagement',
'Systems/DataManagement/Production',
'Systems/DataManagement/Production/Databases',
'Systems/DataManagement/Production/Databases/FileCatalogDB' ]:
res = csAPI.createSection( sct )
if not res['OK']:
print res['Message']
exit( 1 )
csAPI.setOption( 'Systems/DataManagement/Production/Databases/FileCatalogDB/DBName', 'FileCatalogDB' )
csAPI.setOption( 'Systems/DataManagement/Production/Databases/FileCatalogDB/Host', 'db-50098.cern.ch' )
csAPI.setOption( 'Systems/DataManagement/Production/Databases/FileCatalogDB/Port', '5501' )
csAPI.commit()
示例14: CSAPI
# 需要导入模块: from DIRAC.ConfigurationSystem.Client.CSAPI import CSAPI [as 别名]
# 或者: from DIRAC.ConfigurationSystem.Client.CSAPI.CSAPI import setOption [as 别名]
# }
# }
# Databases
# {
# FileCatalogDB
# {
# DBName = FileCatalogDB
# }
# }
# }
# }
from DIRAC.ConfigurationSystem.Client.CSAPI import CSAPI
csAPI = CSAPI()
for sct in ['Systems/DataManagement/Production/Services',
'Systems/DataManagement/Production/Services/FileCatalog' ]:
res = csAPI.createSection( sct )
if not res['OK']:
print res['Message']
exit( 1 )
csAPI.setOption( 'Systems/DataManagement/Production/Services/FileCatalog/DirectoryManager', 'DirectoryClosure' )
csAPI.setOption( 'Systems/DataManagement/Production/Services/FileCatalog/FileManager', 'FileManagerPs' )
csAPI.setOption( 'Systems/DataManagement/Production/Services/FileCatalog/OldSecurityManager', 'DirectorySecurityManagerWithDelete' )
csAPI.setOption( 'Systems/DataManagement/Production/Services/FileCatalog/SecurityManager', 'PolicyBasedSecurityManager' )
csAPI.setOption( 'Systems/DataManagement/Production/Services/FileCatalog/SecurityPolicy', 'DIRAC/DataManagementSystem/DB/FileCatalogComponents/SecurityPolicies/VOMSPolicy' )
csAPI.setOption( 'Systems/DataManagement/Production/Services/FileCatalog/UniqueGUID', True )
csAPI.commit()
示例15: site
# 需要导入模块: from DIRAC.ConfigurationSystem.Client.CSAPI import CSAPI [as 别名]
# 或者: from DIRAC.ConfigurationSystem.Client.CSAPI.CSAPI import setOption [as 别名]
userName = res['Value']['username']
group = res['Value']['group']
if not sites:
Script.showHelp()
DIRAC.exit( -1 )
catalogCFGBase = "/Resources/FileCatalogs/LcgFileCatalogCombined"
allowed = []
for site in sites:
res = gConfig.getOptionsDict( '%s/%s' % ( catalogCFGBase, site ) )
if not res['OK']:
gLogger.error( "The provided site (%s) does not have an associated catalog." % site )
continue
res = csAPI.setOption( "%s/%s/Status" % ( catalogCFGBase, site ), "Active" )
if not res['OK']:
gLogger.error( "Failed to update %s catalog status to Active" % site )
else:
gLogger.debug( "Successfully updated %s catalog status to Active" % site )
allowed.append( site )
if not allowed:
gLogger.error( "Failed to allow any catalog mirrors" )
DIRAC.exit( -1 )
res = csAPI.commitChanges()
if not res['OK']:
gLogger.error( "Failed to commit changes to CS", res['Message'] )
DIRAC.exit( -1 )