Re: Problems with bugzilla and FAS account

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 05/23/2009 08:32 AM, Ricky Zhou wrote:
On 2009-05-23 12:08:30 PM, Michael Schwendt wrote:
If the FAS backend managed to create a new account in bugzilla, why would
I need to _change_ an existing one myself? Can't it sync bugzilla with my
email change in FAS? (which is what I expected it to do)
This is because at the time of writing, there was no XMLRPC method
exposed for changing a user's email.  I just checked now, and there
might be a new method available that we can use.  I'll look at
adding this to our scripts soon.

Anyone who changes email in FAS gets a new bugzilla account for the changed
email address? Is that how it's implemented currently?
This is currently implemented as follows: When a user changes their
email in FAS, or changes their membership in the fedorabugs group, a
trigger runs which adds the user to a special queue table.  We then run
a script periodically that empties out the queue and creates a BZ
account if one doesn't already exist, and grants privileges to the
accounts.  The relevant code for this is in the FAS repo:
git://git.fedorahosted.org/git/fas.git
in scripts/export-bugzilla.* and fas2.sql.


Apologies for not joining in sooner. What ricky's outlined as the current situation is correct. Michael, what you outlined as a way to keep the accounts straight would work. I think making the script not create new accounts (forcing the user to reconcile the fas email and lack of bugzilla account manually) is the way to go.

Here's an untested, updated export-bugzilla.py script. It emails the users when an account mismatch occurs (I believe this runs in cron hourly, so this would send an email once an hour). Does this look good to you guys?

I'm going to a family reunion this weekend. If someone wants to update the script sooner, they can (It will need an infrastructure change request if we put this in place before the release but should be fairly low risk/easy to revert.)

-Toshio
#!/usr/bin/python -t
__requires__ = 'TurboGears'
import pkg_resources
pkg_resources.require('CherryPy >= 2.0, < 3.0alpha')

import sys
import getopt
import xmlrpclib
import smtplib
from email.Message import Message
import turbogears
import bugzilla
from turbogears import config
turbogears.update_config(configfile="/etc/export-bugzilla.cfg")
from turbogears.database import session
from fas.model import BugzillaQueue

BZSERVER = config.get('bugzilla.url', 'https://bugdev.devel.redhat.com/bugzilla-cvs/xmlrpc.cgi')
BZUSER = config.get('bugzilla.username')
BZPASS = config.get('bugzilla.password')
MAILSERVER = config.get('mail.server', localhost)
ADMINEMAIL = config.get(mail.admin_email, 'admin@xxxxxxxxxxxxxxxxx')

if __name__ == '__main__':
    opts, args = getopt.getopt(sys.argv[1:], '', ('usage', 'help'))
    if len(args) != 2 or ('--usage','') in opts or ('--help','') in opts:
        print """
    Usage: export-bugzilla.py GROUP BUGZILLA_GROUP
    """
        sys.exit(1)
    ourGroup = args[0]
    bzGroup = args[1]

    server = bugzilla.Bugzilla(url=BZSERVER, user=BZUSER, password=BZPASS)
    bugzilla_queue = BugzillaQueue.query.join('group').filter_by(
            name=ourGroup)

    no_bz_account = []
    for entry in bugzilla_queue:
        # Make sure we have a record for this user in bugzilla
        if entry.action == 'r':
            # Remove the user's bugzilla group
            try:
                server.updateperms(entry.email, 'rem', (bzGroup,))
            except xmlrpclib.Fault, e:
                if e.faultCode == 504:
                    # It's okay, not having this user is equivalent to setting
                    # them to not have this group.
                    pass
                else:
                    raise

        elif entry.action == 'a':
            # Make sure the user exists
            try:
                server.getuser(entry.email)
            except xmlrpclib.Fault, e:
                if e.faultCode == 51:
                    # This user doesn't have a bugzilla account yet
                    # add them to a list and we'll let them know.
                    no_bz_account.append(entry)
                    continue
                else:
                    print 'Error:', e, entry.email, entry.person.human_name
                    raise
            server.updateperms(entry.email, 'add', (bzGroup,))
        else:
            print 'Unrecognized action code: %s %s %s %s %s' % (entry.action,
                    entry.email, entry.person.human_name, entry.person.username, entry.group.name)
        
        # Remove them from the queue
        session.delete(entry)
        session.flush()

    # Mail the people without bugzilla accounts
    msg = Message()
    for person in no_bz_account:
        smtplib.SMTP(MAILSERVER)
        message = '''Hello, %(name)s,

As a Fedora packager, we grant you permissions to make changes to bugs in
bugzilla to all Fedora bugs.  This lets you work together with other Fedora
developers in an easier fashion.  However, to enable this functionality, we
need to have your bugzilla email address stored in the Fedora Account System.
At the moment you have:

    %(email)s

which bugzilla is telling us is not an account in bugzilla.  If you could
please set up an account in bugzilla with this address or change your email
address on your Fedora Account to match an existing bugzilla account this would
let us go forward.

Note: this message is being generated by an automated script.  You'll continue
getting this message until the problem is resolved.  Sorry for the
inconvenience.

Thank you,
The Fedora Account System
%(admin_email)s
''' % {'name': entry.person.human_name, 'email': entry.email,
        admin_email: ADMINEMAIL}

    msg.add_header('To', entry.email)
    msg.add_header('From', ADMINEMAIL)
    msg.add_header('Subject', 'Fedora Account System and Bugzilla Mistmatch')
    msg.set_payload(message)
    smtp = smtplib.SMTP(MAILSERVER)
    smtp.sendmail(ADMINEMAIL, [], msg.as_string())
    smtp.quit()
_______________________________________________
Fedora-infrastructure-list mailing list
Fedora-infrastructure-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/fedora-infrastructure-list

[Index of Archives]     [Fedora Development]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]

  Powered by Linux