diff --git a/AUTHORS b/AUTHORS index 9505fdf443..c2ced87fa5 100644 --- a/AUTHORS +++ b/AUTHORS @@ -27,6 +27,7 @@ Dean Troyer Deepak Garg Derek Higgins Devin Carlen +Dmitry Khovyakov Dolph Mathews Dolph Mathews Ed Leafe diff --git a/keystone/common/sql/legacy.py b/keystone/common/sql/legacy.py index 55e27b30b9..f69401f67e 100644 --- a/keystone/common/sql/legacy.py +++ b/keystone/common/sql/legacy.py @@ -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)