Skip to content

Commit

Permalink
Merge pull request #56 from JensTimmerman/cleanup
Browse files Browse the repository at this point in the history
use our own setup.cfg
  • Loading branch information
itkovian authored Sep 25, 2017
2 parents e261990 + eb4e660 commit 8f0d50f
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 27 deletions.
3 changes: 2 additions & 1 deletion bin/sync_django_ldap.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def main():
'nagios-check-interval-threshold': NAGIOS_CHECK_INTERVAL_THRESHOLD,
'start-timestamp': ("The timestamp form which to start, otherwise use the cached value", None, "store", None),
'access_token': ('OAuth2 token identifying the user with the accountpage', None, 'store', None),
'account_page_url': ('url for the account page', None, 'store', None),
}
# get access_token from conf file
ExtendedSimpleOption.CONFIGFILES_INIT = ['/etc/account_page.conf']
Expand Down Expand Up @@ -99,7 +100,7 @@ def main():
except OSError:
_log.raiseException("Could not drop privileges")

client = AccountpageClient(token=opts.options.access_token)
client = AccountpageClient(token=opts.options.access_token, url=opts.options.account_page_url + '/api/')
syncer = LdapSyncer(client)
last = int((datetime.strptime(last_timestamp, "%Y%m%d%H%M%SZ") - datetime(1970, 1, 1)).total_seconds())
altered_accounts = syncer.sync_altered_accounts(last, opts.options.dry_run)
Expand Down
6 changes: 3 additions & 3 deletions bin/sync_ugent_vsc_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# All rights reserved.
#
"""
This script synchronises the users and VO's from the HPC LDAP to the central
This script synchronises the users and VO's from the HPC account page to the central
UGent storage for home and data.
For each (active) user, the following tasks are done:
Expand Down Expand Up @@ -78,15 +78,15 @@ def main():
'user': ('process users', None, 'store_true', False),
'vo': ('process vos', None, 'store_true', False),
'access_token': ('OAuth2 token to access the account page REST API', None, 'store', None),
'account_page_url': ('URL of the account page REST API', None, 'store', None)
'account_page_url': ('URL of the account page where we can find the REST API', None, 'store', None)
}

opts = ExtendedSimpleOption(options)
stats = {}

try:
now = datetime.utcnow()
client = AccountpageClient(token=opts.options.access_token)
client = AccountpageClient(token=opts.options.access_token, url=opts.options.account_page_url + "/api/")

try:
last_timestamp = read_timestamp(SYNC_TIMESTAMP_FILENAME)
Expand Down
8 changes: 8 additions & 0 deletions lib/vsc/administration/ldapsync.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

from vsc.accountpage.wrappers import mkVscAccount, mkUserGroup, mkGroup, mkVo

from vsc.config.base import VSC
from vsc.ldap.entities import VscLdapUser, VscLdapGroup

from vsc.ldap.filters import CnFilter
Expand All @@ -40,6 +41,7 @@
UPDATED = 'updated'
ERROR = 'error'

VSC_CONFIG = VSC()

class LdapSyncer(object):
"""
Expand Down Expand Up @@ -141,6 +143,9 @@ def sync_altered_accounts(self, last, dry_run=True):
'loginShell': [str(account.login_shell)],
'researchField': [str(account.research_field[0])],
'status': [str(account.status)],
'homeQuota': ["1"],
'dataQuota': ["1"],
'scratchQuota': ["1"],
}
logging.debug('fetching quota')
quotas = self.client.account[account.vsc_id].quota.get()[1]
Expand Down Expand Up @@ -193,6 +198,9 @@ def sync_altered_groups(self, last, dry_run=True):
ldap_attributes['description'] = [str(vo.description)]
ldap_attributes['dataDirectory'] = [str(vo.data_path)]
ldap_attributes['scratchDirectory'] = [str(vo.scratch_path)]
# vsc40024 is moderator for all institute vo's
if vo.vsc_id in VSC_CONFIG.institute_vos.values():
ldap_attributes['moderator'] = ['vsc40024']

logging.debug("Proposed changes for group %s: %s", group.vsc_id, ldap_attributes)

Expand Down
19 changes: 9 additions & 10 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
[bdist_rpm]
requires = vsc-accountpage-clients >= 0.9.0
vsc-base >= 2.4.16
vsc-config >= 1.31.2
vsc-filesystems >= 0.19
vsc-ldap >= 1.1
python-ldap
vsc-ldap-extension >= 1.3
vsc-utils >= 1.4.4
lockfile >= 0.9.1
requires = python-vsc-accountpage-clients >= 0.9.0
python-vsc-base >= 2.4.16
python-vsc-config >= 1.31.2
python-vsc-filesystems >= 0.19
python-vsc-ldap >= 1.1
pytz
python-ldap
python-vsc-ldap-extension >= 1.3
python-vsc-utils >= 1.4.4
python-lockfile >= 0.9.1

[metadata]

description-file = README.md

16 changes: 4 additions & 12 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,38 +17,30 @@
vsc-administration distribution setup.py
@author: Andy Georges (Ghent University)
@author: Jens Timmerman (Ghent University)
"""

from vsc.install import shared_setup
from vsc.install.shared_setup import ag, jt

PACKAGE = {
'version': '1.0.1',
'version': '1.0.9',
'author': [ag, jt],
'maintainer': [ag, jt],
'tests_require': ['mock'],
'makesetupcfg': False, # use setup.cfg provided to get pytz instead of python-pytz
'install_requires': [
'vsc-accountpage-clients >= 0.9.0',
'vsc-base >= 2.4.16',
'vsc-config >= 1.31.2',
'vsc-filesystems >= 0.19',
'vsc-ldap >= 1.1',
'pytz',
'python-ldap',
'vsc-ldap-extension >= 1.3',
'vsc-utils >= 1.4.4',
'lockfile >= 0.9.1',
'pytz',
],
'dependency_links': [
"git+https://github.com/hpcugent/vsc-utils.git#egg=vsc-utils-1.8.2",
"git+https://github.com/hpcugent/vsc-filesystems.git#egg=vsc-filesystems-0.30.1",
"git+ssh://github.com/hpcugent/vsc-accountpage-clients.git#egg=vsc-accountpage-clients-0.7",
"git+ssh://github.com/hpcugent/vsc-ldap.git#egg=vsc-ldap-1.4.2",
"git+ssh://github.com/hpcugent/vsc-ldap-extension.git#egg=vsc-ldap-extensions-1.10.2",
],



}


Expand Down
2 changes: 1 addition & 1 deletion test/ldapsync.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def test_sync_altered_accounts(self, mock_add_or_update):
ldapsyncer = LdapSyncer(mock_client)
accounts = ldapsyncer.sync_altered_accounts(1)
self.assertEqual(accounts, {'error': set([]), 'new': set([]), 'updated': set([test_account.vsc_id])})
ldap_attrs = {'status': ['active'], 'dataDirectory': ['/user/data/gent/vsc400/vsc40075'], 'cn': 'vsc40075', 'homeQuota': ['5242880'], 'loginShell': ['/bin/bash'], 'uidNumber': ['2540075'], 'gidNumber': ['2540075'], 'instituteLogin': ['foobar'], 'uid': ['vsc40075'], 'scratchDirectory': ['/user/scratch/gent/vsc400/vsc40075'], 'institute': ['gent'], 'researchField': ['Bollocks'], 'gecos': ['Foo Bar'], 'homeDirectory': ['/user/home/gent/vsc400/vsc40075'], 'mail': ['foobar@ugent.be'], 'pubkey': ['pubkey1', 'pubkey2']}
ldap_attrs = {'status': ['active'], 'scratchDirectory': ['/user/scratch/gent/vsc400/vsc40075'], 'dataDirectory': ['/user/data/gent/vsc400/vsc40075'], 'cn': 'vsc40075', 'homeQuota': ['5242880'], 'institute': ['gent'], 'loginShell': ['/bin/bash'], 'uidNumber': ['2540075'], 'researchField': ['Bollocks'], 'gidNumber': ['2540075'], 'gecos': ['Foo Bar'], 'dataQuota': ['1'], 'homeDirectory': ['/user/home/gent/vsc400/vsc40075'], 'mail': ['[email protected]'], 'scratchQuota': ['1'], 'pubkey': ['pubkey1', 'pubkey2'], 'instituteLogin': ['foobar'], 'uid': ['vsc40075']}
mock_add_or_update.assert_called_with(VscLdapUser, test_account.vsc_id, ldap_attrs, True)

@mock.patch.object(vsc.administration.ldapsync.LdapSyncer, 'add_or_update')
Expand Down

0 comments on commit 8f0d50f

Please sign in to comment.