Skip to content

Commit

Permalink
Import ec2 credentials from old keystone db
Browse files Browse the repository at this point in the history
Fix bug #1016056

Change-Id: Iebf31ccbdeff274b2c8f265911d3411963dd4844
  • Loading branch information
Dmitry Khovyakov committed Jul 18, 2012
1 parent 4b97716 commit ec363ac
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions keystone/common/sql/legacy.py
Expand Up @@ -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()

Expand Down Expand Up @@ -50,6 +56,7 @@ def __init__(self, db_string):
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 = {}
Expand All @@ -62,6 +69,7 @@ def migrate_all(self):
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."""
Expand Down Expand Up @@ -153,3 +161,14 @@ def _migrate_user_roles(self):

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)

0 comments on commit ec363ac

Please sign in to comment.