Copy admin util scripts for notifs-backend01.
This commit is contained in:
parent
4dd084d85b
commit
6d8983a341
2 changed files with 53 additions and 0 deletions
47
roles/notifs/backend/files/bin/fmn-disable-account
Executable file
47
roles/notifs/backend/files/bin/fmn-disable-account
Executable file
|
@ -0,0 +1,47 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
""" fmn-disable-account USER
|
||||||
|
|
||||||
|
Disables the FMN account for a user.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
import fedmsg
|
||||||
|
import fedmsg.config
|
||||||
|
|
||||||
|
import fmn.lib
|
||||||
|
import fmn.lib.models
|
||||||
|
|
||||||
|
|
||||||
|
def parse_args():
|
||||||
|
parser = argparse.ArgumentParser(__doc__)
|
||||||
|
parser.add_argument('user', help='FAS username to disable.')
|
||||||
|
parser.add_argument('--context', nargs='+', default=['irc', 'email'],
|
||||||
|
help="Contexts to disable. Defaults to all.")
|
||||||
|
return parser.parse_args()
|
||||||
|
|
||||||
|
def disable(session, user, contexts):
|
||||||
|
openid = '%s.id.fedoraproject.org' % user
|
||||||
|
for context in contexts:
|
||||||
|
pref = fmn.lib.models.Preference.load(session, openid, context)
|
||||||
|
if pref:
|
||||||
|
print "Disabling %r for %r" % (context, openid)
|
||||||
|
pref.set_enabled(session, False)
|
||||||
|
else:
|
||||||
|
print "No context %r found for %r" % (context, openid)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
args = parse_args()
|
||||||
|
|
||||||
|
config = fedmsg.config.load_config()
|
||||||
|
config.update({
|
||||||
|
'active': True,
|
||||||
|
'name': 'relay_inbound',
|
||||||
|
'cert_prefix': 'fmn',
|
||||||
|
})
|
||||||
|
fedmsg.init(**config)
|
||||||
|
|
||||||
|
session = fmn.lib.models.init(config['fmn.sqlalchemy.uri'])
|
||||||
|
|
||||||
|
disable(session, args.user, args.context)
|
|
@ -34,3 +34,9 @@
|
||||||
tags:
|
tags:
|
||||||
- notifs
|
- notifs
|
||||||
- notifs/backend
|
- notifs/backend
|
||||||
|
|
||||||
|
- name: copy over admin utility scripts
|
||||||
|
synchronize: src=bin/ dest=/usr/local/bin/
|
||||||
|
tags:
|
||||||
|
- notifs
|
||||||
|
- notifs/backend
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue