From a7c1fdacd8d9556fd7d18109e9b6e124f689765f Mon Sep 17 00:00:00 2001 From: Andre Sailer Date: Mon, 8 Jun 2020 12:47:33 +0200 Subject: [PATCH 1/4] dirac-admin-add-host: adding host to ComponentMonitoring --- Interfaces/scripts/dirac-admin-add-host.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Interfaces/scripts/dirac-admin-add-host.py b/Interfaces/scripts/dirac-admin-add-host.py index 7d7ca02c25c..2ed1376f542 100755 --- a/Interfaces/scripts/dirac-admin-add-host.py +++ b/Interfaces/scripts/dirac-admin-add-host.py @@ -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 ComponentMoniroting', 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 ) From 52f597dd930cda913f1bd6b72beba6276d720562 Mon Sep 17 00:00:00 2001 From: Andre Sailer Date: Thu, 11 Jun 2020 09:53:10 +0200 Subject: [PATCH 2/4] CSAPI: fix and expand parameter docstrings indentation was off for some, causing failure to properly markup --- ConfigurationSystem/Client/CSAPI.py | 49 ++++++++++++++++------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/ConfigurationSystem/Client/CSAPI.py b/ConfigurationSystem/Client/CSAPI.py index dd052219262..f547b2b36f3 100644 --- a/ConfigurationSystem/Client/CSAPI.py +++ b/ConfigurationSystem/Client/CSAPI.py @@ -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: @@ -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 - - + - DN + - groups + - - :return: True/False + :return: True/False """ if not self.__initialized['OK']: return self.__initialized @@ -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 - - :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 @@ -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 - - :return: True/False + :return: S_OK, Value = True/False """ if not self.__initialized['OK']: return self.__initialized @@ -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 - - :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 @@ -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 - - :return: True/False + :return: S_OK, Value = True/False """ if not self.__initialized['OK']: return self.__initialized @@ -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 - - :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 From 6c669c1e47b267329e78a33cee6a4261ac5eb546 Mon Sep 17 00:00:00 2001 From: Andre Sailer Date: Thu, 11 Jun 2020 10:32:02 +0200 Subject: [PATCH 3/4] Config: add documentation for type of gConfig --- ConfigurationSystem/Client/Config.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ConfigurationSystem/Client/Config.py b/ConfigurationSystem/Client/Config.py index 11314f2a160..6363f77d4c5 100755 --- a/ConfigurationSystem/Client/Config.py +++ b/ConfigurationSystem/Client/Config.py @@ -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 From 97dd214d0df23342f514035b1aeb248e6da88d43 Mon Sep 17 00:00:00 2001 From: Andre Sailer Date: Mon, 22 Jun 2020 11:38:19 +0200 Subject: [PATCH 4/4] dirac-admin-add-host: Fix typo in log message Co-authored-by: fstagni --- Interfaces/scripts/dirac-admin-add-host.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Interfaces/scripts/dirac-admin-add-host.py b/Interfaces/scripts/dirac-admin-add-host.py index 2ed1376f542..04dc291493d 100755 --- a/Interfaces/scripts/dirac-admin-add-host.py +++ b/Interfaces/scripts/dirac-admin-add-host.py @@ -81,7 +81,7 @@ def addProperty( arg ): cmc = ComponentMonitoringClient() ret = cmc.hostExists(dict(HostName=hostName)) if not ret['OK']: - Script.gLogger.error('Cannot check if host is registered in ComponentMoniroting', ret['Message']) + 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: