def alarm_create(self, values):
    if (not values.get('uuid')):
        values['uuid'] = utils.generate_uuid()
    alarm = models.Alarm()
    alarm.update(values)
    with _session_for_write() as session:
        try:
            session.add(alarm)
            session.flush()
        except db_exc.DBDuplicateEntry:
            raise exceptions.AlarmAlreadyExists(uuid=values['uuid'])
        return alarm
def alarm_create(self, values):
    if (not values.get('uuid')):
        values['uuid'] = utils.generate_uuid()
    alarm = models.Alarm()
    alarm.update(values)
    with _session_for_write() as session:
        try:
            session.add(alarm)
            session.flush()
        except db_exc.DBDuplicateEntry:
            raise exceptions.AlarmAlreadyExists(uuid=values['uuid'])
        return alarm