Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
ebb3491
CS.Registry: use VOMS VOs and IdP sessions caches, add getVOMSInfo,ge…
TaykYoku Jun 12, 2020
67febfa
CS.Registry: optimize
TaykYoku Jun 12, 2020
9c0f5a2
CS.Resources: use several methods instead of one
TaykYoku Jun 12, 2020
32e275a
CS.Utilities: rename method
TaykYoku Jun 12, 2020
fb5b2fd
CS: modify authenticated test
TaykYoku Jun 12, 2020
49dd454
CS: fix test
TaykYoku Jun 12, 2020
6aeb11a
CS.API: align according to changes in Registry
TaykYoku Jun 12, 2020
f4056c1
CS.DB: add DB version
TaykYoku Jun 12, 2020
8594275
Core.DISET: add delegatedID to BaseClient, not search the default gro…
TaykYoku Jun 12, 2020
4f144fa
Core.DISET: modify AuthManager, allow read IdP IDs, fix test
TaykYoku Jun 12, 2020
31e2797
Core.DISET: parse credDict in getRemoteCredentials
TaykYoku Jun 12, 2020
2182329
Core.DISET: use ID as IdP ID
TaykYoku Jun 12, 2020
8fe0f67
Core.DictCache: allow get all cache
TaykYoku Jun 12, 2020
1c22bdd
Core.MySQL: fix conn option
TaykYoku Jun 12, 2020
7d727a5
Core.Proxy: use username instead of DN, align according to changes in…
TaykYoku Jun 12, 2020
ef5574a
Core.Shifter: use username instead of DN, align according to changes …
TaykYoku Jun 12, 2020
2600481
Core.VOMSService: allow to set path
TaykYoku Jun 12, 2020
0184dbe
DMS: use username instead of DN, align according to changes in ProxyM…
TaykYoku Jun 12, 2020
86b2425
docs: decribe downloadablePersonalProxy
TaykYoku Jun 12, 2020
cc6a6e9
FS: use username instead of DN
TaykYoku Jun 12, 2020
867b04d
DiracAdmin: align according to changes in ProxyManager, docs
TaykYoku Jun 12, 2020
c6739a1
RMS: add attribute owner and use it instead of DN, align according to…
TaykYoku Jun 12, 2020
f99eabb
Resources: search DN for user/group, align according to changes in Re…
TaykYoku Jun 12, 2020
028d8b1
ProxyProvider: align according to changes in Resources
TaykYoku Jun 12, 2020
74ffdd5
IdProvider: allow use session manager inside, align according to chan…
TaykYoku Jun 12, 2020
d0f2f4b
tests: align according to changes in Registry and changes
TaykYoku Jun 12, 2020
5a3ac68
TS: align according to changes in Register, search DN for user/group,…
TaykYoku Jun 12, 2020
6b6f2ce
WMS: add attribute userPilot, use usernamr instead of DN, align with …
TaykYoku Jun 12, 2020
a2ac342
FS.ProxyManager: create VOMS info cache, modify logic
TaykYoku Jun 12, 2020
b298398
FS.scripts: align with ProxyManager, use username instead DN
TaykYoku Jun 12, 2020
864a6aa
FS.scripts: allow use IdP, align with changes
TaykYoku Jun 12, 2020
1c1dc88
add spiners
TaykYoku Jun 12, 2020
df77188
modify for RCAuth
TaykYoku Jun 12, 2020
dd91e9b
chenge mod method store
TaykYoku Jun 12, 2020
a54e411
fix bug
TaykYoku Jun 12, 2020
8252e7f
fix bug
TaykYoku Jun 12, 2020
2fa3663
fix bug
TaykYoku Jun 12, 2020
cbd7f9c
fix bug
TaykYoku Jun 12, 2020
4d2693f
fix bug
TaykYoku Jun 12, 2020
67de69c
fix bug
TaykYoku Jun 12, 2020
69dc77b
with proxy delete all groups
TaykYoku Jun 12, 2020
33123ef
fix bug
TaykYoku Jun 12, 2020
ebf7533
fix bug
TaykYoku Jun 12, 2020
918a9fd
fix bug
TaykYoku Jun 13, 2020
e63129b
fix bug
TaykYoku Jun 13, 2020
b79412e
fix bug
TaykYoku Jun 14, 2020
99903f7
fix bug
TaykYoku Jun 14, 2020
a24dd05
fix bug
TaykYoku Jun 14, 2020
db0047b
use proxyManager inside proxy providers
TaykYoku Jun 14, 2020
2b1e892
use proxyManager inside proxy providers
TaykYoku Jun 14, 2020
cb65b15
fix bug
TaykYoku Jun 14, 2020
0b4da9b
fix test
TaykYoku Jun 14, 2020
6739b77
use auth_ properties
TaykYoku Jun 16, 2020
1dbdca9
allow getProxy for user or DN
TaykYoku Jun 16, 2020
a725328
not allow upload proxies with group ext, use _storeProxy inside proxy…
TaykYoku Jun 16, 2020
e84df52
fix bug
TaykYoku Jun 16, 2020
f448eeb
fix test
TaykYoku Jun 16, 2020
0b669d1
fix test
TaykYoku Jun 16, 2020
a079cb4
fix test
TaykYoku Jun 16, 2020
06e5438
fix test
TaykYoku Jun 16, 2020
4a35623
fix test
TaykYoku Jun 16, 2020
765ca61
check dn for user/group
TaykYoku Jun 16, 2020
daa51fb
fix test
TaykYoku Jun 16, 2020
2c110ca
fix test
TaykYoku Jun 16, 2020
c244aef
fix test
TaykYoku Jun 16, 2020
a25d3f5
fix test and registry
TaykYoku Jun 17, 2020
1225ba6
fix test and registry
TaykYoku Jun 17, 2020
be66c71
suspended priority in CS
TaykYoku Jun 17, 2020
18a8dec
suspended priority in CS
TaykYoku Jun 17, 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
384 changes: 261 additions & 123 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 @@ -462,42 +462,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()
"""
if not of or of == "all":
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()
"""
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':
instances.append(section[:-9])
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)


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 @@ -698,14 +698,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
6 changes: 2 additions & 4 deletions ConfigurationSystem/Service/ConfigurationHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,11 @@ def export_publishSlaveServer(cls, sURL):
return S_OK()

types_commitNewData = [basestring]
auth_commitNewData = ['authenticated']

def export_commitNewData(self, sData):
global gPilotSynchronizer
credDict = self.getRemoteCredentials()
if 'DN' not in credDict or 'username' not in credDict:
return S_ERROR("You must be authenticated!")
res = gServiceInterface.updateConfiguration(sData, credDict['username'])
if not res['OK']:
return res
Expand Down Expand Up @@ -136,14 +135,13 @@ def export_getVersionContents(cls, versionList):
return S_OK(contentsList)

types_rollbackToVersion = [basestring]
auth_rollbackToVersion = ['authenticated']

def export_rollbackToVersion(self, version):
retVal = gServiceInterface.getVersionContents(version)
if not retVal['OK']:
return S_ERROR("Can't get contents for version %s: %s" % (version, retVal['Message']))
credDict = self.getRemoteCredentials()
if 'DN' not in credDict or 'username' not in credDict:
return S_ERROR("You must be authenticated!")
return gServiceInterface.updateConfiguration(retVal['Value'],
credDict['username'],
updateVersionOption=True)
2 changes: 1 addition & 1 deletion ConfigurationSystem/test/Test_agentOptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,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 @@ -7,7 +7,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 @@ -139,9 +139,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 @@ -2,7 +2,7 @@
It uniforms the way the database objects are constructed
"""

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 @@ -15,9 +15,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 @@ -41,6 +48,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 @@ -51,5 +75,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