Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/nova/objects/instance.py b/nova/objects/instance.py
- index ca805b7..74785f5 100644
- --- a/nova/objects/instance.py
- +++ b/nova/objects/instance.py
- @@ -1362,46 +1362,51 @@ class InstanceList(base.ObjectListBase, base.NovaObject):
- instance.obj_reset_changes(['fault'])
- return faults_by_uuid.keys()
- @base.remotable_classmethod
- def get_uuids_by_host(cls, context, host):
- # NOTE(danms): We could potentially do this a little more efficiently
- # but for now just pull all the instances and scrape the uuids.
- db_instances = db.instance_get_all_by_host(context, host,
- columns_to_join=[])
- return [inst['uuid'] for inst in db_instances]
- @db_api.pick_context_manager_writer
- def _migrate_instance_keypairs(ctxt, count):
- db_extras = ctxt.session.query(models.InstanceExtra).\
- options(joinedload('instance')).\
- filter_by(keypairs=None).\
- filter_by(deleted=0).\
- limit(count).\
- all()
- count_all = len(db_extras)
- count_hit = 0
- for db_extra in db_extras:
- + if db_extra.instance is None:
- + LOG.warning(('Instance %(uuid)s is deleted, but has an undeleted '
- + 'InstanceExtra record. Ignoring'),
- + {'uuid': db_extra.instance_uuid})
- + continue
- key_name = db_extra.instance.key_name
- keypairs = objects.KeyPairList(objects=[])
- if key_name:
- try:
- key = objects.KeyPair.get_by_name(ctxt,
- db_extra.instance.user_id,
- key_name)
- keypairs.objects.append(key)
- except exception.KeypairNotFound:
- LOG.warning(
- _LW('Instance %(uuid)s keypair %(keyname)s not found'),
- {'uuid': db_extra.instance_uuid, 'keyname': key_name})
- db_extra.keypairs = jsonutils.dumps(keypairs.obj_to_primitive())
- db_extra.save(ctxt.session)
- count_hit += 1
- return count_all, count_hit
- def migrate_instance_keypairs(ctxt, count):
- return _migrate_instance_keypairs(ctxt, count)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement