Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
fc51002
CS: use PM and AM cli caches in Registry
TaykYoku Jun 30, 2020
ab8ed4d
CS: modify methods in Resources and Utilities
TaykYoku Jun 30, 2020
3e37bdf
CS: fix test
TaykYoku Jun 30, 2020
16a75e2
CS: add rest api
TaykYoku Jun 30, 2020
f3a5fa1
Core: align with new Registry
TaykYoku Jun 30, 2020
1b65282
Core: add DB version
TaykYoku Jun 30, 2020
08c6939
Core: allow to delegate through delegateID in BaseClient
TaykYoku Jun 30, 2020
5f75ca5
Core: modify AuthManager to use IDs, align with new Registry, fix test
TaykYoku Jun 30, 2020
8b0143a
Core: research connectingCredentials in getRemoteCredentials
TaykYoku Jun 30, 2020
cfc9088
Core: use ID as IdP ID in TreadConfig
TaykYoku Jun 30, 2020
1eb8396
Core: move WebApp cores to DIRAC
TaykYoku Jun 30, 2020
8f38425
Core: add proxyPath option to VOMSService
TaykYoku Jun 30, 2020
7bf1088
Core: add getDict method to DictCache
TaykYoku Jun 30, 2020
7a5121f
Core: align with ProxyManager
TaykYoku Jun 30, 2020
fe988f2
Core: Shifter align with ProxyManager and Registry
TaykYoku Jun 30, 2020
fb5febf
DMS: use username/group to get proxy
TaykYoku Jun 30, 2020
d40ddab
DMS: use userDN/group or username/group to get proxy
TaykYoku Jun 30, 2020
ff2f18c
DMS: search DNs for user in group
TaykYoku Jun 30, 2020
e525ff6
DMS: use userDN/group or username/group to get proxy
TaykYoku Jun 30, 2020
6f9dec0
docs: describe downloadablePersonalProxy parameter
TaykYoku Jun 30, 2020
f1fdbc1
docs
TaykYoku Jun 30, 2020
3b94e39
FS: optimize, add check
TaykYoku Jun 30, 2020
911f91a
FS: split proxy manager client
TaykYoku Jun 30, 2020
7a8e65c
FS: modify ProxyDB
TaykYoku Jun 30, 2020
10a17b0
FS: align with ProxyManager
TaykYoku Jun 30, 2020
14fbdbc
FS: align with ProxyManager
TaykYoku Jun 30, 2020
6655ecc
FS: align with ProxyManager
TaykYoku Jun 30, 2020
f717c56
FS: align with ProxyManager
TaykYoku Jun 30, 2020
089943f
FS: align with ProxyManager
TaykYoku Jun 30, 2020
d298dd4
FS: modify ProxyManager
TaykYoku Jun 30, 2020
5f88a9f
FS: add AuthManager service
TaykYoku Jun 30, 2020
94ab7f3
FS: add spiners
TaykYoku Jun 30, 2020
74eeb53
FS: add rest apis
TaykYoku Jun 30, 2020
844fa7d
FS: add OAuth helper class
TaykYoku Jun 30, 2020
f849019
FS: align with ProxyManager
TaykYoku Jun 30, 2020
cbecf4e
RmS: align with ProxyManager, use username instead dn
TaykYoku Jun 30, 2020
459204f
Resources: align with Registry, docs, fix test
TaykYoku Jun 30, 2020
be8d194
Resources: add OAuth2 resources
TaykYoku Jun 30, 2020
94ecc2e
test: fix ProxyDB test
TaykYoku Jun 30, 2020
d81e973
fix tests
TaykYoku Jun 30, 2020
42b3bc2
TS: align with Registry
TaykYoku Jun 30, 2020
66e2ed5
WMS: add use PilotUser instead dn, align with proxyManager/Registry
TaykYoku Jun 30, 2020
d9b6c02
some fixes
TaykYoku Jul 1, 2020
e060199
some fixes
TaykYoku Jul 1, 2020
3a8d740
some fixes
TaykYoku Jul 1, 2020
2f0e7b0
some fixes
TaykYoku Jul 1, 2020
e82d322
in progress
TaykYoku Jul 1, 2020
e615e6a
in progress
TaykYoku Jul 1, 2020
3db8952
in progress
TaykYoku Jul 1, 2020
6e8baff
in progress
TaykYoku Jul 1, 2020
46fcd95
in progress
TaykYoku Jul 1, 2020
db8aa7a
in progress
TaykYoku Jul 1, 2020
58025a5
in progress
TaykYoku Jul 1, 2020
9a7545c
in progress
TaykYoku Jul 1, 2020
c721f17
in progress
TaykYoku Jul 1, 2020
bd0204f
in progress
TaykYoku Jul 1, 2020
e061de2
in progress
TaykYoku Jul 1, 2020
f557276
in progress
TaykYoku Jul 1, 2020
70a4577
in progress
TaykYoku Jul 1, 2020
926d048
in progress
TaykYoku Jul 2, 2020
80046cf
in progress
TaykYoku Jul 2, 2020
745e788
in progress
TaykYoku Jul 2, 2020
ea1767c
in progress
TaykYoku Jul 2, 2020
63152b6
in progress
TaykYoku Jul 2, 2020
57a736a
in progress
TaykYoku Jul 2, 2020
d059ed3
in progress
TaykYoku Jul 2, 2020
518a257
in progress
TaykYoku Jul 2, 2020
6f3d653
in progress
TaykYoku Jul 2, 2020
5e48d62
in progress
TaykYoku Jul 2, 2020
7c2ed4f
in progress
TaykYoku Jul 2, 2020
878ac86
in progress
TaykYoku Jul 2, 2020
a3581be
fix test
TaykYoku Jul 3, 2020
816ef8c
fix test
TaykYoku Jul 3, 2020
599811f
fix test
TaykYoku Jul 4, 2020
03c1da3
fix test
TaykYoku Jul 5, 2020
14ec25d
fix test
TaykYoku Jul 5, 2020
c32656a
fix test
TaykYoku Jul 5, 2020
40a80e4
fix test
TaykYoku Jul 5, 2020
c0fd25e
fix test
TaykYoku Jul 5, 2020
8db7d91
fix test use real user
TaykYoku Jul 5, 2020
a85779b
fix test
TaykYoku Jul 5, 2020
e0aff8e
fix test
TaykYoku Jul 5, 2020
ae186f2
fix test
TaykYoku Jul 5, 2020
946108a
remove debugs
TaykYoku Jul 5, 2020
2761f3a
remove debugs
TaykYoku Jul 5, 2020
8e37390
debugs
TaykYoku Jul 6, 2020
63ac450
debugs
TaykYoku Jul 6, 2020
5fbd7a7
remove debugs
TaykYoku Jul 6, 2020
a90a59d
add docs
TaykYoku Jul 8, 2020
5beea6c
add docs
TaykYoku Jul 8, 2020
89a7e52
docs
TaykYoku Jul 8, 2020
710c3d8
fix bugs
TaykYoku Jul 8, 2020
a52f020
docs
TaykYoku Jul 10, 2020
bf8747e
fix bugs
TaykYoku Jul 22, 2020
33c1464
add number of connection error
TaykYoku Jul 22, 2020
b742934
CS/Registry: use deprecated, fix sort list
TaykYoku Aug 2, 2020
60458e9
backward compatibility
TaykYoku Aug 2, 2020
c1b3f03
rename option, use Client
TaykYoku Aug 2, 2020
c69dbee
use createClient
TaykYoku Aug 2, 2020
5454e63
escape params
TaykYoku Aug 2, 2020
ecddf74
docs
TaykYoku Aug 2, 2020
0af7a1c
add license halo
TaykYoku Aug 4, 2020
51e3e2f
fix metaclass
TaykYoku Aug 4, 2020
c7719c6
docs
TaykYoku Aug 11, 2020
edfffe3
docs
TaykYoku Aug 11, 2020
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
383 changes: 254 additions & 129 deletions ConfigurationSystem/Client/Helpers/Registry.py

Large diffs are not rendered by default.

92 changes: 59 additions & 33 deletions ConfigurationSystem/Client/Helpers/Resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,42 +465,68 @@ def getFilterConfig(filterID):
return gConfig.getOptionsDict('Resources/LogFilters/%s' % filterID)


def getInfoAboutProviders(of=None, providerName=None, option='', section=''):
""" Get the information about providers

:param basestring of: provider of what(Id, Proxy or etc.) need to look,
None, "all" to get list of instance of what this providers
:param basestring providerName: provider name,
None, "all" to get list of providers names
:param basestring option: option name that need to get,
None, "all" to get all options in a section
:param basestring section: section path in root section of provider,
"all" to get options in all sections

:return: S_OK()/S_ERROR()
def getProvidersForInstance(instance, providerType=None):
""" Get providers for instance

:param str instance: instance of what this providers
:param str providerType: provider type

:return: S_OK(list)/S_ERROR()
"""
result = gConfig.getSections('%s/%sProviders' % (gBaseResourcesSection, instance))
if not result['OK'] or not result['Value'] or (result['OK'] and not providerType):
return result
data = []
for prov in result['Value']:
if providerType == gConfig.getValue('%s/%sProviders/%s/ProviderType' %
(gBaseResourcesSection, instance, prov)):
data.append(prov)
return S_OK(data)


def getProviderByAlias(alias, instance=None):
""" Find provider name by alias

:param str alias: other registered provider name
:param str instance: provider of what

:return: S_OK(str)/S_ERROR()
"""
if not of or of == "all":
instances = [instance] or []
if not instances:
result = gConfig.getSections(gBaseResourcesSection)
if not result['OK']:
return result
return S_OK([i.replace('Providers', '') for i in result['Value']])
if not providerName or providerName == "all":
return gConfig.getSections('%s/%sProviders' % (gBaseResourcesSection, of))
if not option or option == 'all':
if not section:
return gConfig.getOptionsDict("%s/%sProviders/%s" % (gBaseResourcesSection, of, providerName))
elif section == "all":
resDict = {}
relPath = "%s/%sProviders/%s/" % (gBaseResourcesSection, of, providerName)
result = gConfig.getConfigurationTree(relPath)
for section in result['Value']:
if section[-9:] == 'Providers':
Comment thread
TaykYoku marked this conversation as resolved.
instances.append(section[:-9])
Comment thread
TaykYoku marked this conversation as resolved.
for instance in instances:
result = getProvidersForInstance(instance)
if not result['OK']:
return result
for provider in result['Value']:
if alias in gConfig.getValue("%s/%sProviders/%s/Aliases" % (gBaseResourcesSection,
instance, provider), []):
return S_OK(provider)
return S_ERROR('No found any provider for %s' % alias)
Comment thread
TaykYoku marked this conversation as resolved.


def getProviderInfo(provider):
""" Get provider info

:param str provider: provider

:return: S_OK(dict)/S_ERROR()
"""
result = gConfig.getSections(gBaseResourcesSection)
if not result['OK']:
return result
for section in result['Value']:
if section[-9:] == 'Providers':
result = getProvidersForInstance(section[:-9])
if not result['OK']:
return result
for key, value in result['Value'].items(): # can be an iterator
if value:
resDict[key.replace(relPath, '')] = value
return S_OK(resDict)
else:
return gConfig.getSections('%s/%sProviders/%s/%s/' % (gBaseResourcesSection, of, providerName, section))
else:
return S_OK(gConfig.getValue('%s/%sProviders/%s/%s/%s' % (gBaseResourcesSection, of, providerName,
section, option)))
if provider in result['Value']:
return gConfig.getOptionsDictRecursively("%s/%s/%s/" % (gBaseResourcesSection,
section, provider))
return S_ERROR('%s provider not found.' % provider)
6 changes: 3 additions & 3 deletions ConfigurationSystem/Client/Utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -701,14 +701,14 @@ def getElasticDBParameters(fullname):
return S_OK(parameters)


def getOAuthAPI(instance='Production'):
""" Get OAuth API url
def getAuthAPI(instance='Production'):
""" Get Auth REST API url

:param str instance: instance

:return: str
"""
return gConfig.getValue("/Systems/Framework/%s/URLs/OAuthAPI" % instance)
return gConfig.getValue("/Systems/Framework/%s/URLs/AuthAPI" % instance)


def getDIRACGOCDictionary():
Expand Down
96 changes: 96 additions & 0 deletions ConfigurationSystem/Utilities/ConfigurationHandler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
""" HTTP API of the DIRAC configuration data, rewrite from the RESTDIRAC project
"""
Comment thread
TaykYoku marked this conversation as resolved.
import re
import json

from tornado import web, gen
from tornado.template import Template

from DIRAC import S_OK, S_ERROR, gConfig, gLogger
from DIRAC.ConfigurationSystem.Client.Helpers import Resources, Registry
from DIRAC.ConfigurationSystem.Client.ConfigurationData import gConfigurationData
from DIRAC.FrameworkSystem.Client.ProxyManagerClient import gProxyManager

from DIRAC.Core.Web.WebHandler import WebHandler, asyncGen, WErr

__RCSID__ = "$Id$"


class ConfigurationHandler(WebHandler):
OVERPATH = True
AUTH_PROPS = "all"
LOCATION = "/"

def initialize(self):
super(ConfigurationHandler, self).initialize()
self.args = {}
for arg in self.request.arguments:
if len(self.request.arguments[arg]) > 1:
self.args[arg] = self.request.arguments[arg]
else:
self.args[arg] = self.request.arguments[arg][0] or ''
return S_OK()

@asyncGen
def web_conf(self):
""" REST endpoint for configuration system:

**GET** /conf/<key>?<options> -- get configuration information

Options:
* *path* -- path in the configuration structure, by default it's "/".
* *version* -- the configuration version of the requester, if *version* is newer
than the one present on the server, an empty result will be returned

Response:
+-----------+---------------------------------------+------------------------+
| *key* | Description | Type |
+-----------+---------------------------------------+------------------------+
| dump | Current CFG() | encoded in json format |
+-----------+---------------------------------------+------------------------+
| option | Option value | text |
+-----------+---------------------------------------+------------------------+
| options | Options list in a section | encoded in json format |
+-----------+---------------------------------------+------------------------+
| dict | Options with values in a section | encoded in json format |
+-----------+---------------------------------------+------------------------+
| sections | Sections list in a section | text |
+-----------+---------------------------------------+------------------------+
"""
self.log.notice('Request configuration information')
optns = self.overpath.strip('/').split('/')
path = self.args.get('path', '/')
if not optns or len(optns) > 1:
raise WErr(404, "You forgot to set attribute.")

result = S_ERROR('%s request unsuported' % optns[0])
if 'version' in self.args and (self.args.get('version') or '0') >= gConfigurationData.getVersion():
self.finish()
if optns[0] == 'dump':
remoteCFG = yield self.threadTask(gConfigurationData.getRemoteCFG)
result['Value'] = str(remoteCFG)
elif optns[0] == 'option':
result = yield self.threadTask(gConfig.getOption, path)
elif optns[0] == 'dict':
result = yield self.threadTask(gConfig.getOptionsDict, path)
elif optns[0] == 'options':
result = yield self.threadTask(gConfig.getOptions, path)
elif optns[0] == 'sections':
result = yield self.threadTask(gConfig.getSections, path)
elif optns[0] == 'getGroupsStatusByUsername':
result = yield self.threadTask(gProxyManager.getGroupsStatusByUsername, **self.args)
elif any([optns[0] == m and re.match('^[a-z][A-z]+', m) for m in dir(Registry)]) and self.isRegisteredUser():
result = yield self.threadTask(getattr(Registry, optns[0]), **self.args)
else:
raise WErr(500, '%s request unsuported' % optns[0])
# result = yield self.threadTask(getattr(Registry, optns[0]), **self.args)

if not result['OK']:
raise WErr(404, result['Message'])
self.finishJEncode(result['Value'])

@asyncGen
def post(self):
""" Post method
"""
pass
5 changes: 5 additions & 0 deletions ConfigurationSystem/Utilities/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
# $HeadURL$
__RCSID__ = "$Id$"
2 changes: 1 addition & 1 deletion ConfigurationSystem/test/Test_agentOptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
('DIRAC.WorkloadManagementSystem.Agent.StatesAccountingAgent', {}),
('DIRAC.WorkloadManagementSystem.Agent.StatesMonitoringAgent', {}),
('DIRAC.WorkloadManagementSystem.Agent.SiteDirector',
{'SpecialMocks': {'findGenericPilotCredentials': S_OK(('a', 'b'))}}),
{'SpecialMocks': {'findGenericPilotCredentials': S_OK(('a', 'b', 'c'))}}),
# ('DIRAC.WorkloadManagementSystem.Agent.MultiProcessorSiteDirector', {}), # not inheriting from AgentModule
]

Expand Down
10 changes: 6 additions & 4 deletions Core/Base/API.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from DIRAC import gLogger, gConfig, S_OK, S_ERROR
from DIRAC.Core.Security.ProxyInfo import getProxyInfo, formatProxyInfoAsString
from DIRAC.ConfigurationSystem.Client.Helpers.Registry import getDNForUsername
from DIRAC.ConfigurationSystem.Client.Helpers.Registry import getDNsForUsername
from DIRAC.Core.Utilities.Version import getCurrentVersion

__RCSID__ = '$Id$'
Expand Down Expand Up @@ -141,9 +141,11 @@ def _getCurrentUser(self):
gLogger.debug(formatProxyInfoAsString(proxyInfo))
if 'group' not in proxyInfo:
return self._errorReport('Proxy information does not contain the group', res['Message'])
res = getDNForUsername(proxyInfo['username'])
if not res['OK']:
return self._errorReport('Failed to get proxies for user', res['Message'])
result = getDNsForUsername(proxyInfo['username'])
if not result['OK']:
return self._errorReport('Failed to get proxies for user', result['Message'])
if not result['Value']:
return self._errorReport('Failed to get proxies for user', "No DNs found for %s" % proxyInfo['username'])
return S_OK(proxyInfo['username'])

#############################################################################
Expand Down
48 changes: 47 additions & 1 deletion Core/Base/DB.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from __future__ import division
from __future__ import print_function

from DIRAC import gLogger, gConfig
from DIRAC import gLogger, gConfig, S_OK, S_ERROR
from DIRAC.Core.Utilities.MySQL import MySQL
from DIRAC.ConfigurationSystem.Client.Utilities import getDBParameters
from DIRAC.ConfigurationSystem.Client.PathFinder import getDatabaseSection
Expand All @@ -18,9 +18,16 @@ class DB(MySQL):
"""

def __init__(self, dbname, fullname, debug=False):
""" C'or

:param str dbname: database name
:param str fullname: full name
:param bool debug: debug mode
"""
self.versionDB = 0
self.fullname = fullname
database_name = dbname
self.versionTable = '%s_Version' % database_name
self.log = gLogger.getSubLogger(database_name)

result = getDBParameters(fullname)
Expand All @@ -44,6 +51,23 @@ def __init__(self, dbname, fullname, debug=False):
if not self._connected:
raise RuntimeError("Can not connect to DB '%s', exiting..." % self.dbName)

# Initialize version
result = self._query("show tables")
if result['OK']:
if self.versionTable not in [t[0] for t in result['Value']]:
result = self._createTables({self.versionTable: {'Fields': {'Version': 'INTEGER NOT NULL'},
'PrimaryKey': 'Version'}})
if not result['OK']:
raise RuntimeError("Can not initialize %s version: %s" % (self.dbName, result['Message']))
result = self._query("SELECT Version FROM `%s`" % self.versionTable)
if result['OK']:
if len(result['Value']) > 0:
self.versionDB = result['Value'][0][0]
else:
result = self._update("INSERT INTO `%s` (Version) VALUES (%s)" % (self.versionTable, self.versionDB))
if not result['OK']:
raise RuntimeError("Can not initialize %s version: %s" % (self.dbName, result['Message']))

self.log.info("===================== MySQL ======================")
self.log.info("User: " + self.dbUser)
self.log.info("Host: " + self.dbHost)
Expand All @@ -54,5 +78,27 @@ def __init__(self, dbname, fullname, debug=False):

#############################################################################
def getCSOption(self, optionName, defaultValue=None):
""" Get option from CS

:param str optionName: option name
:param defaultValue: default value

:return: value that inherits the defaultValue type
"""
cs_path = getDatabaseSection(self.fullname)
return gConfig.getValue("/%s/%s" % (cs_path, optionName), defaultValue)

def updateDBVersion(self, version):
""" Update DB version

:param int version: version number

:return: S_OK()/S_ERROR()
"""
result = self._query('DELETE FROM `%s_Version`' % self.dbName)
if result['OK']:
result = self._update("INSERT INTO `%s_Version` (Version) VALUES (%s)" % (self.dbName, version))
if not result['OK']:
return S_ERROR("Can not initialize %s version: %s" % (self.dbName, result['Message']))
self.versionDB = version
return S_OK()
Loading