Skip to content

Commit

Permalink
Call to instance_info_cache_delete to use uuid
Browse files Browse the repository at this point in the history
Fixes bug 903497
Also updated incorrect calls to instance_destroy that were using uuids.

Change-Id: I25eead020ceb7ebf7234c268543ad77d8ecf1185
  • Loading branch information
ameade committed Jan 11, 2012
1 parent 98e385e commit 26b7b94
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 72 deletions.
18 changes: 9 additions & 9 deletions nova/db/api.py
Expand Up @@ -654,32 +654,32 @@ def instance_info_cache_create(context, values):
return IMPL.instance_info_cache_create(context, values)


def instance_info_cache_get(context, instance_id, session=None):
def instance_info_cache_get(context, instance_uuid, session=None):
"""Gets an instance info cache from the table.
:param instance_id: = id of the info cache's instance
:param instance_uuid: = uuid of the info cache's instance
:param session: = optional session object
"""
return IMPL.instance_info_cache_get(context, instance_id, session=None)
return IMPL.instance_info_cache_get(context, instance_uuid, session=None)


def instance_info_cache_update(context, instance_id, values,
def instance_info_cache_update(context, instance_uuid, values,
session=None):
"""Update an instance info cache record in the table.
:param instance_id: = id of info cache's instance
:param instance_uuid: = uuid of info cache's instance
:param values: = dict containing column values to update
"""
return IMPL.instance_info_cache_update(context, instance_id, values,
return IMPL.instance_info_cache_update(context, instance_uuid, values,
session)


def instance_info_cache_delete(context, instance_id, session=None):
def instance_info_cache_delete(context, instance_uuid, session=None):
"""Deletes an existing instance_info_cache record
:param instance_id: = id of the instance tied to the cache record
:param instance_uuid: = uuid of the instance tied to the cache record
"""
return IMPL.instance_info_cache_delete(context, instance_id, session)
return IMPL.instance_info_cache_delete(context, instance_uuid, session)


###################
Expand Down
24 changes: 13 additions & 11 deletions nova/db/sqlalchemy/api.py
Expand Up @@ -1128,6 +1128,7 @@ def instance_data_get_for_project(context, project_id):
def instance_destroy(context, instance_id):
session = get_session()
with session.begin():
instance_ref = instance_get(context, instance_id, session=session)
session.query(models.Instance).\
filter_by(id=instance_id).\
update({'deleted': True,
Expand All @@ -1148,7 +1149,9 @@ def instance_destroy(context, instance_id):
update({'deleted': True,
'deleted_at': utils.utcnow(),
'updated_at': literal_column('updated_at')})
instance_info_cache_delete(context, instance_id, session=session)

instance_info_cache_delete(context, instance_ref['uuid'],
session=session)


@require_context
Expand Down Expand Up @@ -1426,7 +1429,6 @@ def instance_get_project_vpn(context, project_id):
def instance_get_fixed_addresses(context, instance_id):
session = get_session()
with session.begin():
instance_ref = instance_get(context, instance_id, session=session)
try:
fixed_ips = fixed_ip_get_by_instance(context, instance_id)
except exception.NotFound:
Expand Down Expand Up @@ -1590,31 +1592,31 @@ def instance_info_cache_create(context, values):


@require_context
def instance_info_cache_get(context, instance_id, session=None):
def instance_info_cache_get(context, instance_uuid, session=None):
"""Gets an instance info cache from the table.
:param instance_id: = uuid of the info cache's instance
:param instance_uuid: = uuid of the info cache's instance
:param session: = optional session object
"""
session = session or get_session()

info_cache = session.query(models.InstanceInfoCache).\
filter_by(instance_id=instance_id).\
filter_by(instance_id=instance_uuid).\
first()
return info_cache


@require_context
def instance_info_cache_update(context, instance_id, values,
def instance_info_cache_update(context, instance_uuid, values,
session=None):
"""Update an instance info cache record in the table.
:param instance_id: = uuid of info cache's instance
:param instance_uuid: = uuid of info cache's instance
:param values: = dict containing column values to update
:param session: = optional session object
"""
session = session or get_session()
info_cache = instance_info_cache_get(context, instance_id,
info_cache = instance_info_cache_get(context, instance_uuid,
session=session)

values['updated_at'] = literal_column('updated_at')
Expand All @@ -1626,15 +1628,15 @@ def instance_info_cache_update(context, instance_id, values,


@require_context
def instance_info_cache_delete(context, instance_id, session=None):
def instance_info_cache_delete(context, instance_uuid, session=None):
"""Deletes an existing instance_info_cache record
:param instance_id: = uuid of the instance tied to the cache record
:param instance_uuid: = uuid of the instance tied to the cache record
:param session: = optional session object
"""
values = {'deleted': True,
'deleted_at': utils.utcnow()}
instance_info_cache_update(context, instance_id, values, session)
instance_info_cache_update(context, instance_uuid, values, session)


###################
Expand Down
1 change: 0 additions & 1 deletion nova/db/sqlalchemy/models.py
Expand Up @@ -268,7 +268,6 @@ class InstanceInfoCache(BASE, NovaBase):
# text column used for storing a json object of network data for api
network_info = Column(Text)

# this is all uuid based, we have them might as well start using them
instance_id = Column(String(36), ForeignKey('instances.uuid'),
nullable=False, unique=True)
instance = relationship(Instance,
Expand Down

0 comments on commit 26b7b94

Please sign in to comment.