CSAPI

CSAPI exposes update functionalities to the Configuration.

Most of these functions can only be done by administrators

class DIRAC.ConfigurationSystem.Client.CSAPI.CSAPI

Bases: object

CSAPI objects need an initialization phase

__init__()

Initialization function

addCEtoSite(siteName, ceName, optionsDict=None)

Adds a new CE to a site definition in the CS. A CE normally has queues, so addQueueToCE should be called after this one.

Parameters
  • siteName (str) – FQN of the site (e.g. LCG.CERN.ch)

  • ceName (str) – FQN of the CE (e.g. ce503.cern.ch)

  • optionsDict (dict) – optional dictionary of options

Returns

S_OK/S_ERROR structure

addGroup(groupname, properties)

Add a group to the cs

Parameters
  • groupname (str) – group name

  • properties (dict) –

    dictionary describing group properties:

    • Users

    • Properties

    • <extra params>

Returns

S_OK, Value = True/False

addHost(hostname, properties)

Add a host to the cs

Parameters
  • hostname (str) – host name

  • properties (dict) –

    dictionary describing host properties:

    • DN

    • Properties

    • <extra params>

Returns

S_OK, Value = True/False

addQueueToCE(ceName, queueName, optionsDict=None)

Adds a new queue to a CE definition in the CS.

Parameters
  • ceName (str) – FQN of the CE (e.g. ce503.cern.ch)

  • queueName (str) – name of the queue (e.g. ce503.cern.ch-condor)

  • optionsDict (dict) – optional dictionary of options

Returns

S_OK/S_ERROR structure

addShifter(shifters=None)

Adds or modify one or more shifters. Also, adds the shifter section in case this is not present. Shifter identities are used in several places, mostly for running agents

Parameters

shifters (dict) – has to be in the form {‘ShifterRole’:{‘User’:’aUserName’, ‘Group’:’aDIRACGroup’}}

Returns

S_OK/S_ERROR

addSite(siteName, optionsDict=None)

Adds a new site to the CS. A site is a container for services, so after calling this function, at least addCEtoSite() should be called.

Parameters
  • siteName (str) – FQN of the site (e.g. LCG.CERN.ch)

  • optionsDict (dict) – optional dictionary of options

Returns

S_OK/S_ERROR structure

addUser(username, properties)

Add a user to the cs

Parameters
  • username (str) – username

  • properties (dict) –

    dictionary describing user properties:

    • DN

    • groups

    • <extra params>

Returns

True/False

checkForUnexistantUsersInGroups()
commit()

Commit the accumulated changes to the CS server

commitChanges(sortUsers=True)
copySection(originalPath, targetPath)

Copy a whole section to a new location

createSection(sectionPath, comment='')

Create a new section

delOption(optionPath)

Delete an option

delSection(sectionPath)

Delete a section

deleteUsers(users)

Delete a user/s can receive as a param either a string or a list

describeGroups(mask=None)

List all groups that are in the mask (or all if no mask) with their properties

describeHosts(hosts=None)
describeUsers(users=None)

describe users by nickname

Parameters

users (list) – list of users’ nicknames

Returns

a S_OK(description) of the users in input

downloadCSData()
forceGlobalConfigurationUpdate()

Force global update of configuration on all the registered services

Returns

S_OK/S_ERROR

getCurrentCFG()

Get the current CFG as it is

initialize()
listGroups()

List all groups

listHosts()
listUsers(group=False)
mergeCFGUnderSection(sectionPath, cfg)

Merge the given cfg under a certain section

mergeFromCFG(cfg)

Merge the internal CFG data with the input

mergeWithCFG(cfg)

Merge the given cfg with the current config

modifyGroup(groupname, properties, createIfNonExistant=False)

Modify a group

Parameters
  • groupname (str) – group name

  • properties (dict) –

    dictionary describing group properties:

    • Users

    • Properties

    • <extra params>

  • createIfNonExistant (bool) – if true, creates the group if it did not exist

Returns

S_OK, Value = True/False

modifyHost(hostname, properties, createIfNonExistant=False)

Modify a host

Parameters
  • hostname (str) – hostname name

  • properties (dict) –

    dictionary describing host properties:

    • DN

    • Properties

    • <extra params>

  • createIfNonExistant (bool) – if true, creates the host if it did not exist

Returns

S_OK, Value = True/False

modifyUser(username, properties, createIfNonExistant=False)

Modify a user

Parameters
  • username (str) – group name

  • properties (dict) –

    dictionary describing user properties:

    • DN

    • Groups

    • <extra params>

  • createIfNonExistant (bool) – if true, registers the users if it did not exist

Returns

S_OK, Value = True/False

modifyValue(optionPath, newValue)

Modify an existing value at the specified options path.

moveSection(originalPath, targetPath)

Move a whole section to a new location

setOption(optionPath, optionValue)

Create an option at the specified path.

setOptionComment(optionPath, comment)

Create an option at the specified path.

showDiff()

Just shows the differences accumulated within the Modificator object

sortUsersAndGroups()
syncUsersWithCFG(usersCFG)

Sync users with the cfg contents. Usernames have to be sections containing DN, Groups, and extra properties as parameters