Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dm-docs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hammonds
dm-docs
Commits
6b7c3818
Commit
6b7c3818
authored
8 years ago
by
sveseli
Browse files
Options
Downloads
Patches
Plain Diff
got dm user updates algorithm working
parent
b11a5dd2
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/python/dm/aps_user_db/cli/updateUsersFromApsDbCli.py
+14
-2
14 additions, 2 deletions
src/python/dm/aps_user_db/cli/updateUsersFromApsDbCli.py
src/python/dm/ds_web_service/api/userRestApi.py
+2
-2
2 additions, 2 deletions
src/python/dm/ds_web_service/api/userRestApi.py
with
16 additions
and
4 deletions
src/python/dm/aps_user_db/cli/updateUsersFromApsDbCli.py
+
14
−
2
View file @
6b7c3818
#!/usr/bin/env python
import
datetime
from
dm.common.exceptions.invalidRequest
import
InvalidRequest
from
dm.common.cli.dmCli
import
DmCli
from
dm.common.utility.configurationManager
import
ConfigurationManager
...
...
@@ -19,13 +20,14 @@ Description:
Updates all users in DM LDAP and database using information from APS DB.
"""
)
ConfigurationManager
.
getInstance
().
setConfigFile
(
'
/home/oxygen/SVESELI/Work/DM/etc/dm.conf
'
)
print
ConfigurationManager
.
getInstance
().
getConfigOption
(
'
DsRestApiFactory
'
,
'
username
'
)
self
.
logger
.
debug
(
'
Starting sync process
'
)
apsUserDbApi
=
ApsUserDbApi
()
userRestApi
=
DsRestApiFactory
.
getUserRestApi
()
self
.
logger
.
debug
(
'
Retrieving APS users
'
)
apsUsers
=
apsUserDbApi
.
getApsUsers
()
self
.
logger
.
debug
(
'
Number of APS Users: %s
'
%
len
(
apsUsers
))
self
.
logger
.
debug
(
'
Retrieving DM users
'
)
dmUsers
=
userRestApi
.
getUsers
()
self
.
logger
.
debug
(
'
Number of DM Users: %s
'
%
len
(
dmUsers
))
dmUserBadgeMap
=
{}
...
...
@@ -60,15 +62,25 @@ Description:
nCreatedUsers
+=
1
else
:
dmLastUpdate
=
dmUser
.
get
(
'
lastUpdate
'
)
if
dmLastUpdate
:
# need to convert DM last update time to datetime object
# datetime cannot handle time zone at the moment
timeZonePos
=
dmLastUpdate
.
rfind
(
'
-
'
)
dmLastUpdate
=
dmLastUpdate
[
0
:
timeZonePos
]
dmLastUpdate
=
datetime
.
datetime
.
strptime
(
dmLastUpdate
,
'
%Y-%m-%d %H:%M:%S
'
)
if
not
dmLastUpdate
or
dmLastUpdate
<
apsLastChangeDate
:
id
=
dmUser
.
get
(
'
id
'
)
self
.
logger
.
debug
(
'
Modifying user with badge %s: %s (DM id: %s)
'
%
(
badge
,
apsUser
[
'
name
'
],
id
))
print
apsUser
userRestApi
.
updateUser
(
id
,
username
,
firstName
,
lastName
,
middleName
,
email
,
badge
,
globusUsername
,
description
,
password
,
isLocalUser
,
lastUpdate
)
nUpdatedUsers
+=
1
else
:
# User is up to date
pass
self
.
logger
.
debug
(
'
Number of new DM users: %s
'
%
(
nCreatedUsers
))
self
.
logger
.
debug
(
'
Number of updated DM users: %s
'
%
(
nUpdatedUsers
))
self
.
logger
.
debug
(
'
Completed sync process
'
)
#ldapUserManager = LdapUserManager('ldaps://dmid-vm.xray.aps.anl.gov:636', 'uid=dmadmin,ou=People,o=aps.anl.gov,dc=aps,dc=anl,dc=gov', '/tmp/ldapPassword', userDnFormat='uid=%s,ou=DM,ou=People,o=aps.anl.gov,dc=aps,dc=anl,dc=gov', groupDnFormat='cn=%s,ou=DM,ou=Group,o=aps.anl.gov,dc=aps,dc=anl,dc=gov', minGidNumber=66000)
#ldapUser = ldapUserManager.getUserInfo(username)
...
...
This diff is collapsed.
Click to expand it.
src/python/dm/ds_web_service/api/userRestApi.py
+
2
−
2
View file @
6b7c3818
...
...
@@ -94,12 +94,12 @@ class UserRestApi(DsRestApi):
if
isLocalUser
:
url
+=
'
&isLocaUser=%s
'
%
isLocalUser
if
lastUpdate
:
url
+=
'
&lastUpdate=%s
'
%
lastUpdate
url
+=
'
&lastUpdate=%s
'
%
Encoder
.
encode
(
str
(
lastUpdate
))
if
not
url
:
raise
InvalidRequest
(
'
No user attributes have been modified.
'
)
# Remove first '&' character
url
=
'
%s/users/%s?%s
'
%
(
self
.
getContextRoot
(),
id
,
url
[
1
:])
responseData
=
self
.
sendSessionRequest
(
url
=
url
,
method
=
'
P
OS
T
'
)
responseData
=
self
.
sendSessionRequest
(
url
=
url
,
method
=
'
P
U
T
'
)
return
UserInfo
(
responseData
)
@DsRestApi.execute
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment