Ensure that the user/project exist on alarm update

This patch ensure that the user and project exists before updating the
alarm.

Closes bug #1260776

Change-Id: I25cf55d91b78a32bda671426972b7f418bf85e21
This commit is contained in:
Mehdi Abaakouk 2013-12-13 16:56:43 +01:00
parent 6cb9b88f09
commit 3fb11bd84c

View File

@ -733,6 +733,10 @@ class Connection(base.Connection):
"""
session = sqlalchemy_session.get_session()
with session.begin():
Connection._create_or_update(session, models.User,
alarm.user_id)
Connection._create_or_update(session, models.Project,
alarm.project_id)
alarm_row = session.merge(models.Alarm(id=alarm.alarm_id))
alarm_row.update(alarm.as_dict())