Clone cleaning and configure CI to run tests
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
This commit is contained in:
parent
7d7069d5e2
commit
ebedffb14c
3 changed files with 35 additions and 11 deletions
3
.pylintrc
Normal file
3
.pylintrc
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
[MESSAGES CONTROL]
|
||||||
|
disable=consider-using-f-string,
|
||||||
|
invalid-name,
|
13
.woodpecker.yml
Normal file
13
.woodpecker.yml
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
pipeline:
|
||||||
|
test-pylint:
|
||||||
|
group: test
|
||||||
|
image: pipelinecomponents/pylint
|
||||||
|
commands:
|
||||||
|
- pip install https://gitea.zionetrix.net/bn8/python-mylib.git
|
||||||
|
- pylint check_ceph_usage
|
||||||
|
|
||||||
|
test-flake8:
|
||||||
|
group: test
|
||||||
|
image: pipelinecomponents/flake8
|
||||||
|
commands:
|
||||||
|
- flake8 check_ceph_usage
|
|
@ -1,6 +1,8 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
"""
|
||||||
""" Tool to force update memberOf attributes of users on OpenLDAP directory using memberOf overlay """
|
Tool to force update memberOf attributes of users on OpenLDAP directory using
|
||||||
|
memberOf overlay
|
||||||
|
"""
|
||||||
|
|
||||||
import getpass
|
import getpass
|
||||||
import logging
|
import logging
|
||||||
|
@ -15,7 +17,8 @@ default_host = 'ldapi:///'
|
||||||
default_filter = '(objectClass=posixGroup)'
|
default_filter = '(objectClass=posixGroup)'
|
||||||
default_attr = 'uniqueMember'
|
default_attr = 'uniqueMember'
|
||||||
|
|
||||||
parser = get_opts_parser(desc="Update memberOf attributes", just_try=True, progress=True)
|
parser = get_opts_parser(
|
||||||
|
desc="Update memberOf attributes", just_try=True, progress=True)
|
||||||
|
|
||||||
# options
|
# options
|
||||||
ldap_opts = parser.add_argument_group('LDAP options')
|
ldap_opts = parser.add_argument_group('LDAP options')
|
||||||
|
@ -86,13 +89,17 @@ init_logging(options, "Update memberOf")
|
||||||
if options.dn and not options.pwd:
|
if options.dn and not options.pwd:
|
||||||
options.pwd = getpass.getpass()
|
options.pwd = getpass.getpass()
|
||||||
|
|
||||||
|
|
||||||
class MyLdapClient(LdapClient):
|
class MyLdapClient(LdapClient):
|
||||||
""" Implement a custom LdapClient to handle group objects """
|
""" Implement a custom LdapClient to handle group objects """
|
||||||
|
|
||||||
def __init__(self, scripts_options): # pylint: disable=super-init-not-called
|
# pylint: disable=super-init-not-called
|
||||||
|
def __init__(self, scripts_options):
|
||||||
self.options = scripts_options
|
self.options = scripts_options
|
||||||
logging.info(u"Connect to LDAP server %s", self.options.host)
|
logging.info(u"Connect to LDAP server %s", self.options.host)
|
||||||
self.cnx = LdapServer(self.options.host, dn=self.options.dn, pwd=self.options.pwd, v2=self.options.ldapv2)
|
self.cnx = LdapServer(
|
||||||
|
self.options.host, dn=self.options.dn, pwd=self.options.pwd,
|
||||||
|
v2=self.options.ldapv2)
|
||||||
self.cnx.connect()
|
self.cnx.connect()
|
||||||
|
|
||||||
def get_groups(self):
|
def get_groups(self):
|
||||||
|
@ -101,7 +108,7 @@ class MyLdapClient(LdapClient):
|
||||||
'group',
|
'group',
|
||||||
self.options.filter,
|
self.options.filter,
|
||||||
self.options.base,
|
self.options.base,
|
||||||
[ self.options.attr ]
|
[self.options.attr]
|
||||||
)
|
)
|
||||||
|
|
||||||
def touch_group_members(self, obj):
|
def touch_group_members(self, obj):
|
||||||
|
@ -121,6 +128,7 @@ class MyLdapClient(LdapClient):
|
||||||
return myldap.update_object(obj, changes)
|
return myldap.update_object(obj, changes)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
# Start LDAP connection
|
# Start LDAP connection
|
||||||
myldap = MyLdapClient(options)
|
myldap = MyLdapClient(options)
|
||||||
groups = myldap.get_groups()
|
groups = myldap.get_groups()
|
||||||
|
|
Loading…
Reference in a new issue