Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 27 additions & 22 deletions ConfigurationSystem/Client/CSAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def listHosts(self):
def describeUsers(self, users=None):
""" describe users by nickname

:param list users: list of users' nickanames
:param list users: list of users' nicknames
:return: a S_OK(description) of the users in input
"""
if users is None:
Expand Down Expand Up @@ -240,14 +240,14 @@ def addUser(self, username, properties):
"""
Add a user to the cs

:param str username: group name
:param dict properties: dictionary describing user properties:
:param str username: username
:param dict properties: dictionary describing user properties:

- DN
- groups
- <extra params>
- DN
- groups
- <extra params>

:return: True/False
:return: True/False
"""
if not self.__initialized['OK']:
return self.__initialized
Expand Down Expand Up @@ -279,14 +279,15 @@ def modifyUser(self, username, properties, createIfNonExistant=False):
"""
Modify a user

:param str username: group name
:param dict properties: dictionary describing user properties:
:param str username: group name
:param dict properties: dictionary describing user properties:

- DN
- Groups
- <extra params>

:return: S_OK, Value = True/False
:param bool createIfNonExistant: if true, registers the users if it did not exist
:return: S_OK, Value = True/False
"""
if not self.__initialized['OK']:
return self.__initialized
Expand Down Expand Up @@ -341,14 +342,14 @@ def addGroup(self, groupname, properties):
"""
Add a group to the cs

:param str groupname: group name
:param dict properties: dictionary describing group properties:
:param str groupname: group name
:param dict properties: dictionary describing group properties:

- Users
- Properties
- <extra params>

:return: True/False
:return: S_OK, Value = True/False
"""
if not self.__initialized['OK']:
return self.__initialized
Expand All @@ -366,14 +367,15 @@ def modifyGroup(self, groupname, properties, createIfNonExistant=False):
"""
Modify a group

:param str groupname: group name
:param dict properties: dictionary describing group properties:
:param str groupname: group name
:param dict properties: dictionary describing group properties:

- Users
- Properties
- <extra params>

:return: True/False
:param bool createIfNonExistant: if true, creates the group if it did not exist
:return: S_OK, Value = True/False
"""
if not self.__initialized['OK']:
return self.__initialized
Expand Down Expand Up @@ -401,14 +403,15 @@ def modifyGroup(self, groupname, properties, createIfNonExistant=False):
def addHost(self, hostname, properties):
"""
Add a host to the cs
:param str hostname: hostname name
:param dict properties: dictionary describing host properties:

:param str hostname: host name
:param dict properties: dictionary describing host properties:

- DN
- Properties
- <extra params>

:return: True/False
:return: S_OK, Value = True/False
"""
if not self.__initialized['OK']:
return self.__initialized
Expand Down Expand Up @@ -528,14 +531,16 @@ def getOpsSection():
def modifyHost(self, hostname, properties, createIfNonExistant=False):
"""
Modify a host
:param str hostname: hostname name
:param dict properties: dictionary describing host properties:

:param str hostname: hostname name
:param dict properties: dictionary describing host properties:

- DN
- Properties
- <extra params>

:return: True/False
:param bool createIfNonExistant: if true, creates the host if it did not exist
:return: S_OK, Value = True/False
"""
if not self.__initialized['OK']:
return self.__initialized
Expand Down
5 changes: 5 additions & 0 deletions ConfigurationSystem/Client/Config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@

from DIRAC.ConfigurationSystem.private.ConfigurationClient import ConfigurationClient

#: Global gConfig object of type :class:`~DIRAC.ConfigurationSystem.private.ConfigurationClient.ConfigurationClient`
gConfig = ConfigurationClient()


def getConfig():
"""
:returns: gConfig
:rtype: ~DIRAC.ConfigurationSystem.private.ConfigurationClient.ConfigurationClient
"""
return gConfig
13 changes: 13 additions & 0 deletions Interfaces/scripts/dirac-admin-add-host.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,19 @@ def addProperty( arg ):
errorList.append( ( "commit", result[ 'Message' ] ) )
exitCode = 255

if exitCode == 0:
from DIRAC.FrameworkSystem.Client.ComponentMonitoringClient import ComponentMonitoringClient
cmc = ComponentMonitoringClient()
ret = cmc.hostExists(dict(HostName=hostName))
if not ret['OK']:
Script.gLogger.error('Cannot check if host is registered in ComponentMonitoring', ret['Message'])
elif ret['Value']:
Script.gLogger.info('Host already registered in ComponentMonitoring')
else:
ret = cmc.addHost(dict(HostName=hostName, CPU='TO_COME'))
if not ret['OK']:
Script.gLogger.error('Failed to add Host to ComponentMonitoring', ret['Message'])

for error in errorList:
Script.gLogger.error( "%s: %s" % error )

Expand Down