Example #1
0
def migrate_keypairs_to_api_db(context, count):
    bad_instances = _count_unmigrated_instances(context)
    if bad_instances:
        LOG.error(
            _LE('Some instances are still missing keypair '
                'information. Unable to run keypair migration '
                'at this time.'))
        return 0, 0

    main_keypairs = _get_main_keypairs(context, count)
    done = 0
    for db_keypair in main_keypairs:
        kp = objects.KeyPair(context=context,
                             user_id=db_keypair.user_id,
                             name=db_keypair.name,
                             fingerprint=db_keypair.fingerprint,
                             public_key=db_keypair.public_key,
                             type=db_keypair.type)
        try:
            kp._create()
        except exception.KeyPairExists:
            # NOTE(danms): If this got created somehow in the API DB,
            # then it's newer and we just continue on to destroy the
            # old one in the cell DB.
            pass
        db_api.key_pair_destroy(context, db_keypair.user_id, db_keypair.name)
        done += 1

    return len(main_keypairs), done
Example #2
0
def migrate_keypairs_to_api_db(context, count):
    bad_instances = _count_unmigrated_instances(context)
    if bad_instances:
        LOG.error('Some instances are still missing keypair '
                  'information. Unable to run keypair migration '
                  'at this time.')
        return 0, 0

    main_keypairs = _get_main_keypairs(context, count)
    done = 0
    for db_keypair in main_keypairs:
        kp = objects.KeyPair(context=context,
                             user_id=db_keypair.user_id,
                             name=db_keypair.name,
                             fingerprint=db_keypair.fingerprint,
                             public_key=db_keypair.public_key,
                             type=db_keypair.type)
        try:
            kp._create()
        except exception.KeyPairExists:
            # NOTE(danms): If this got created somehow in the API DB,
            # then it's newer and we just continue on to destroy the
            # old one in the cell DB.
            pass
        db_api.key_pair_destroy(context, db_keypair.user_id, db_keypair.name)
        done += 1

    return len(main_keypairs), done
Example #3
0
 def test_upgrade_with_deleted_keypairs(self):
     keypair = db_api.key_pair_create(self.context, self.keypair_values)
     db_api.key_pair_destroy(self.context, keypair['user_id'],
                             keypair['name'])
     self.migration.upgrade(self.engine)
 def test_upgrade_with_deleted_keypairs(self):
     keypair = db_api.key_pair_create(self.context, self.keypair_values)
     db_api.key_pair_destroy(self.context,
                             keypair['user_id'], keypair['name'])
     self.migration.upgrade(self.engine)