Import ec2 credentials from old keystone db

Fix bug #1016056

Change-Id: Iebf31ccbdeff274b2c8f265911d3411963dd4844
This commit is contained in:
Dmitry Khovyakov 2012-07-11 14:17:46 +03:00 committed by Alan Pevec
parent 0b95c3cf66
commit d56a3fb026
2 changed files with 20 additions and 0 deletions

View File

@ -27,6 +27,7 @@ Dean Troyer <dtroyer@gmail.com>
Deepak Garg <deepakgarg.iitg@gmail.com>
Derek Higgins <derekh@redhat.com>
Devin Carlen <devin.carlen@gmail.com>
Dmitry Khovyakov <dkhovyakov@griddynamics.com>
Dolph Mathews <dolph.mathews@gmail.com>
Dolph Mathews <dolph.mathews@rackspace.com>
Ed Leafe <ed@leafe.com>

View File

@ -17,10 +17,16 @@
import re
import sqlalchemy
from sqlalchemy import exc
from keystone.common import logging
from keystone.contrib.ec2.backends import sql as ec2_sql
from keystone.identity.backends import sql as identity_sql
LOG = logging.getLogger(__name__)
def export_db(db):
table_names = db.table_names()
@ -50,6 +56,7 @@ class LegacyMigration(object):
self.db = sqlalchemy.create_engine(db_string)
self.identity_driver = identity_sql.Identity()
self.identity_driver.db_sync()
self.ec2_driver = ec2_sql.Ec2()
self._data = {}
self._user_map = {}
self._tenant_map = {}
@ -62,6 +69,7 @@ class LegacyMigration(object):
self._migrate_roles()
self._migrate_user_roles()
self._migrate_tokens()
self._migrate_ec2()
def dump_catalog(self):
"""Generate the contents of a catalog templates file."""
@ -153,3 +161,14 @@ class LegacyMigration(object):
def _migrate_tokens(self):
pass
def _migrate_ec2(self):
for x in self._data['credentials']:
new_dict = {'user_id': x['user_id'],
'tenant_id': x['tenant_id'],
'access': x['key'],
'secret': x['secret']}
try:
self.ec2_driver.create_credential(None, new_dict)
except exc.IntegrityError:
LOG.exception('Cannot migrate EC2 credential: %s' % x)