To properly map a Gerrit account to the corresponding Launchpad account, we piggyback on the only real existing relationship between them: authentication data. Here is an example of how we go about it in our infrastructure...
query = """SELECT t.external_id FROM account_external_ids t INNER JOIN ( SELECT t.account_id FROM account_external_ids t WHERE t.email_address = %s ) original ON t.account_id = original.account_id
AND t.external_id LIKE 'https://login.launchpad.net%%'"""
cursor = jeepyb.gerritdb.connect().cursor()
cursor.execute(query, searchkey)
data = cursor.fetchone()
if data:
assignee = launchpad.people.getByOpenIDIdentifier(identifier=data[0])
In short, look up the OpenID URL associated with the Gerrit account, then query the Launchpad API for the user belonging to that URL. The example above used direct MySQL queries to Gerrit's backend database, but something similar could almost certainly be accomplished via grsql queries through Gerrit's SSH API interface instead if sufficient privileges are already in place. Alternatively, I could set up a data dump containing this mapping on demand, given some advance warning.
To properly map a Gerrit account to the corresponding Launchpad account, we piggyback on the only real existing relationship between them: authentication data. Here is an example of how we go about it in our infrastructure...
https:/ /github. com/openstack- infra/jeepyb/ blob/master/ jeepyb/ cmd/update_ bug.py
query = """SELECT t.external_id FROM account_ external_ ids t
INNER JOIN (
SELECT t.account_id FROM account_ external_ ids t
WHERE t.email_address = %s )
original ON t.account_id = original.account_id /login. launchpad. net%%'""" gerritdb. connect( ).cursor( ) execute( query, searchkey) people. getByOpenIDIden tifier( identifier= data[0] )
AND t.external_id LIKE 'https:/
cursor = jeepyb.
cursor.
data = cursor.fetchone()
if data:
assignee = launchpad.
In short, look up the OpenID URL associated with the Gerrit account, then query the Launchpad API for the user belonging to that URL. The example above used direct MySQL queries to Gerrit's backend database, but something similar could almost certainly be accomplished via grsql queries through Gerrit's SSH API interface instead if sufficient privileges are already in place. Alternatively, I could set up a data dump containing this mapping on demand, given some advance warning.