mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-25 14:20:22 -07:00
Assorted pylint fixes
This commit is contained in:
parent
8e0f95951d
commit
f9ab9b4d68
65 changed files with 343 additions and 473 deletions
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: UTF-8 -*-
|
||||
|
||||
# Copyright (c) 2016, Adfinis SyGroup AG
|
||||
# Copyright: (c) 2016, Adfinis SyGroup AG
|
||||
# Tobias Rueetschi <tobias.ruetschi@adfinis-sygroup.ch>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
|
@ -125,13 +125,13 @@ def main():
|
|||
changed = False
|
||||
|
||||
obj = list(ldap_search(
|
||||
'(&(objectClass=dNSZone)(zoneName={})(relativeDomainName={}))'.format(zone, name),
|
||||
'(&(objectClass=dNSZone)(zoneName={0})(relativeDomainName={1}))'.format(zone, name),
|
||||
attr=['dNSZone']
|
||||
))
|
||||
|
||||
exists = bool(len(obj))
|
||||
container = 'zoneName={},cn=dns,{}'.format(zone, base_dn())
|
||||
dn = 'relativeDomainName={},{}'.format(name, container)
|
||||
container = 'zoneName={0},cn=dns,{1}'.format(zone, base_dn())
|
||||
dn = 'relativeDomainName={0},{1}'.format(name, container)
|
||||
|
||||
if state == 'present':
|
||||
try:
|
||||
|
@ -139,17 +139,17 @@ def main():
|
|||
so = forward_zone.lookup(
|
||||
config(),
|
||||
uldap(),
|
||||
'(zone={})'.format(zone),
|
||||
'(zone={0})'.format(zone),
|
||||
scope='domain',
|
||||
) or reverse_zone.lookup(
|
||||
config(),
|
||||
uldap(),
|
||||
'(zone={})'.format(zone),
|
||||
'(zone={0})'.format(zone),
|
||||
scope='domain',
|
||||
)
|
||||
obj = umc_module_for_add('dns/{}'.format(type), container, superordinate=so[0])
|
||||
obj = umc_module_for_add('dns/{0}'.format(type), container, superordinate=so[0])
|
||||
else:
|
||||
obj = umc_module_for_edit('dns/{}'.format(type), dn)
|
||||
obj = umc_module_for_edit('dns/{0}'.format(type), dn)
|
||||
obj['name'] = name
|
||||
for k, v in data.items():
|
||||
obj[k] = v
|
||||
|
@ -162,18 +162,18 @@ def main():
|
|||
obj.modify()
|
||||
except Exception as e:
|
||||
module.fail_json(
|
||||
msg='Creating/editing dns entry {} in {} failed: {}'.format(name, container, e)
|
||||
msg='Creating/editing dns entry {0} in {1} failed: {2}'.format(name, container, e)
|
||||
)
|
||||
|
||||
if state == 'absent' and exists:
|
||||
try:
|
||||
obj = umc_module_for_edit('dns/{}'.format(type), dn)
|
||||
obj = umc_module_for_edit('dns/{0}'.format(type), dn)
|
||||
if not module.check_mode:
|
||||
obj.remove()
|
||||
changed = True
|
||||
except Exception as e:
|
||||
module.fail_json(
|
||||
msg='Removing dns entry {} in {} failed: {}'.format(name, container, e)
|
||||
msg='Removing dns entry {0} in {1} failed: {2}'.format(name, container, e)
|
||||
)
|
||||
|
||||
module.exit_json(
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: UTF-8 -*-
|
||||
|
||||
# Copyright (c) 2016, Adfinis SyGroup AG
|
||||
# Copyright: (c) 2016, Adfinis SyGroup AG
|
||||
# Tobias Rueetschi <tobias.ruetschi@adfinis-sygroup.ch>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
|
@ -122,7 +122,7 @@ def convert_time(time):
|
|||
return ('0', 'seconds')
|
||||
for unit in units:
|
||||
if time >= unit[0]:
|
||||
return ('{}'.format(time // unit[0]), unit[1])
|
||||
return ('{0}'.format(time // unit[0]), unit[1])
|
||||
|
||||
|
||||
def main():
|
||||
|
@ -172,22 +172,22 @@ def main():
|
|||
changed = False
|
||||
|
||||
obj = list(ldap_search(
|
||||
'(&(objectClass=dNSZone)(zoneName={}))'.format(zone),
|
||||
'(&(objectClass=dNSZone)(zoneName={0}))'.format(zone),
|
||||
attr=['dNSZone']
|
||||
))
|
||||
|
||||
exists = bool(len(obj))
|
||||
container = 'cn=dns,{}'.format(base_dn())
|
||||
dn = 'zoneName={},{}'.format(zone, container)
|
||||
container = 'cn=dns,{0}'.format(base_dn())
|
||||
dn = 'zoneName={0},{1}'.format(zone, container)
|
||||
if contact == '':
|
||||
contact = 'root@{}.'.format(zone)
|
||||
contact = 'root@{0}.'.format(zone)
|
||||
|
||||
if state == 'present':
|
||||
try:
|
||||
if not exists:
|
||||
obj = umc_module_for_add('dns/{}'.format(type), container)
|
||||
obj = umc_module_for_add('dns/{0}'.format(type), container)
|
||||
else:
|
||||
obj = umc_module_for_edit('dns/{}'.format(type), dn)
|
||||
obj = umc_module_for_edit('dns/{0}'.format(type), dn)
|
||||
obj['zone'] = zone
|
||||
obj['nameserver'] = nameserver
|
||||
obj['a'] = interfaces
|
||||
|
@ -211,18 +211,18 @@ def main():
|
|||
obj.modify()
|
||||
except Exception as e:
|
||||
module.fail_json(
|
||||
msg='Creating/editing dns zone {} failed: {}'.format(zone, e)
|
||||
msg='Creating/editing dns zone {0} failed: {1}'.format(zone, e)
|
||||
)
|
||||
|
||||
if state == 'absent' and exists:
|
||||
try:
|
||||
obj = umc_module_for_edit('dns/{}'.format(type), dn)
|
||||
obj = umc_module_for_edit('dns/{0}'.format(type), dn)
|
||||
if not module.check_mode:
|
||||
obj.remove()
|
||||
changed = True
|
||||
except Exception as e:
|
||||
module.fail_json(
|
||||
msg='Removing dns zone {} failed: {}'.format(zone, e)
|
||||
msg='Removing dns zone {0} failed: {1}'.format(zone, e)
|
||||
)
|
||||
|
||||
module.exit_json(
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: UTF-8 -*-
|
||||
|
||||
# Copyright (c) 2016, Adfinis SyGroup AG
|
||||
# Copyright: (c) 2016, Adfinis SyGroup AG
|
||||
# Tobias Rueetschi <tobias.ruetschi@adfinis-sygroup.ch>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
|
@ -114,18 +114,18 @@ def main():
|
|||
changed = False
|
||||
|
||||
groups = list(ldap_search(
|
||||
'(&(objectClass=posixGroup)(cn={}))'.format(name),
|
||||
'(&(objectClass=posixGroup)(cn={0}))'.format(name),
|
||||
attr=['cn']
|
||||
))
|
||||
if position != '':
|
||||
container = position
|
||||
else:
|
||||
if ou != '':
|
||||
ou = 'ou={},'.format(ou)
|
||||
ou = 'ou={0},'.format(ou)
|
||||
if subpath != '':
|
||||
subpath = '{},'.format(subpath)
|
||||
container = '{}{}{}'.format(subpath, ou, base_dn())
|
||||
group_dn = 'cn={},{}'.format(name, container)
|
||||
subpath = '{0},'.format(subpath)
|
||||
container = '{0}{1}{2}'.format(subpath, ou, base_dn())
|
||||
group_dn = 'cn={0},{1}'.format(name, container)
|
||||
|
||||
exists = bool(len(groups))
|
||||
|
||||
|
@ -146,7 +146,7 @@ def main():
|
|||
grp.modify()
|
||||
except Exception:
|
||||
module.fail_json(
|
||||
msg="Creating/editing group {} in {} failed".format(name, container)
|
||||
msg="Creating/editing group {0} in {1} failed".format(name, container)
|
||||
)
|
||||
|
||||
if state == 'absent' and exists:
|
||||
|
@ -157,7 +157,7 @@ def main():
|
|||
changed = True
|
||||
except Exception:
|
||||
module.fail_json(
|
||||
msg="Removing group {} failed".format(name)
|
||||
msg="Removing group {0} failed".format(name)
|
||||
)
|
||||
|
||||
module.exit_json(
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: UTF-8 -*-
|
||||
|
||||
# Copyright (c) 2016, Adfinis SyGroup AG
|
||||
# Copyright: (c) 2016, Adfinis SyGroup AG
|
||||
# Tobias Rueetschi <tobias.ruetschi@adfinis-sygroup.ch>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
|
@ -479,13 +479,13 @@ def main():
|
|||
changed = False
|
||||
|
||||
obj = list(ldap_search(
|
||||
'(&(objectClass=univentionShare)(cn={}))'.format(name),
|
||||
'(&(objectClass=univentionShare)(cn={0}))'.format(name),
|
||||
attr=['cn']
|
||||
))
|
||||
|
||||
exists = bool(len(obj))
|
||||
container = 'cn=shares,ou={},{}'.format(module.params['ou'], base_dn())
|
||||
dn = 'cn={},{}'.format(name, container)
|
||||
container = 'cn=shares,ou={0},{1}'.format(module.params['ou'], base_dn())
|
||||
dn = 'cn={0},{1}'.format(name, container)
|
||||
|
||||
if state == 'present':
|
||||
try:
|
||||
|
@ -494,7 +494,7 @@ def main():
|
|||
else:
|
||||
obj = umc_module_for_edit('shares/share', dn)
|
||||
|
||||
module.params['printablename'] = '{} ({})'.format(name, module.params['host'])
|
||||
module.params['printablename'] = '{0} ({1})'.format(name, module.params['host'])
|
||||
for k in obj.keys():
|
||||
if module.params[k] is True:
|
||||
module.params[k] = '1'
|
||||
|
@ -516,7 +516,7 @@ def main():
|
|||
obj.modify()
|
||||
except Exception as err:
|
||||
module.fail_json(
|
||||
msg='Creating/editing share {} in {} failed: {}'.format(
|
||||
msg='Creating/editing share {0} in {1} failed: {2}'.format(
|
||||
name,
|
||||
container,
|
||||
err,
|
||||
|
@ -531,7 +531,7 @@ def main():
|
|||
changed = True
|
||||
except Exception as err:
|
||||
module.fail_json(
|
||||
msg='Removing share {} in {} failed: {}'.format(
|
||||
msg='Removing share {0} in {1} failed: {2}'.format(
|
||||
name,
|
||||
container,
|
||||
err,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: UTF-8 -*-
|
||||
|
||||
# Copyright (c) 2016, Adfinis SyGroup AG
|
||||
# Copyright: (c) 2016, Adfinis SyGroup AG
|
||||
# Tobias Rueetschi <tobias.ruetschi@adfinis-sygroup.ch>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
|
@ -415,18 +415,18 @@ def main():
|
|||
changed = False
|
||||
|
||||
users = list(ldap_search(
|
||||
'(&(objectClass=posixAccount)(uid={}))'.format(username),
|
||||
'(&(objectClass=posixAccount)(uid={0}))'.format(username),
|
||||
attr=['uid']
|
||||
))
|
||||
if position != '':
|
||||
container = position
|
||||
else:
|
||||
if ou != '':
|
||||
ou = 'ou={},'.format(ou)
|
||||
ou = 'ou={0},'.format(ou)
|
||||
if subpath != '':
|
||||
subpath = '{},'.format(subpath)
|
||||
container = '{}{}{}'.format(subpath, ou, base_dn())
|
||||
user_dn = 'uid={},{}'.format(username, container)
|
||||
subpath = '{0},'.format(subpath)
|
||||
container = '{0}{1}{2}'.format(subpath, ou, base_dn())
|
||||
user_dn = 'uid={0},{1}'.format(username, container)
|
||||
|
||||
exists = bool(len(users))
|
||||
|
||||
|
@ -438,12 +438,12 @@ def main():
|
|||
obj = umc_module_for_edit('users/user', user_dn)
|
||||
|
||||
if module.params['displayName'] is None:
|
||||
module.params['displayName'] = '{} {}'.format(
|
||||
module.params['displayName'] = '{0} {1}'.format(
|
||||
module.params['firstname'],
|
||||
module.params['lastname']
|
||||
)
|
||||
if module.params['unixhome'] is None:
|
||||
module.params['unixhome'] = '/home/{}'.format(
|
||||
module.params['unixhome'] = '/home/{0}'.format(
|
||||
module.params['username']
|
||||
)
|
||||
for k in obj.keys():
|
||||
|
@ -479,7 +479,7 @@ def main():
|
|||
obj.modify()
|
||||
except Exception:
|
||||
module.fail_json(
|
||||
msg="Creating/editing user {} in {} failed".format(
|
||||
msg="Creating/editing user {0} in {1} failed".format(
|
||||
username,
|
||||
container
|
||||
)
|
||||
|
@ -487,7 +487,7 @@ def main():
|
|||
try:
|
||||
groups = module.params['groups']
|
||||
if groups:
|
||||
filter = '(&(objectClass=posixGroup)(|(cn={})))'.format(
|
||||
filter = '(&(objectClass=posixGroup)(|(cn={0})))'.format(
|
||||
')(cn='.join(groups)
|
||||
)
|
||||
group_dns = list(ldap_search(filter, attr=['dn']))
|
||||
|
@ -500,7 +500,7 @@ def main():
|
|||
changed = True
|
||||
except Exception:
|
||||
module.fail_json(
|
||||
msg="Adding groups to user {} failed".format(username)
|
||||
msg="Adding groups to user {0} failed".format(username)
|
||||
)
|
||||
|
||||
if state == 'absent' and exists:
|
||||
|
@ -511,7 +511,7 @@ def main():
|
|||
changed = True
|
||||
except Exception:
|
||||
module.fail_json(
|
||||
msg="Removing user {} failed".format(username)
|
||||
msg="Removing user {0} failed".format(username)
|
||||
)
|
||||
|
||||
module.exit_json(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue