Store all event data in DB

Fixes #64

Signed-off-by: Zane Bitter <zbitter@redhat.com>
This commit is contained in:
Zane Bitter 2012-04-17 17:38:48 +02:00
parent c2ab4a39d1
commit 4993b5dfa0
4 changed files with 41 additions and 8 deletions

View File

@ -0,0 +1,24 @@
from sqlalchemy import *
from migrate import *
def upgrade(migrate_engine):
meta = MetaData(bind=migrate_engine)
event = Table('event', meta, autoload=True)
Column('logical_resource_id', String(255)).create(event)
Column('physical_resource_id', String(255)).create(event)
Column('resource_status_reason', String(255)).create(event)
Column('resource_type', String(255)).create(event)
Column('resource_properties', PickleType).create(event)
def downgrade(migrate_engine):
meta = MetaData(bind=migrate_engine)
event = Table('event', meta, autoload=True)
event.c.logical_resource_id.drop()
event.c.physical_resource_id.drop()
event.c.resource_status_reason.drop()
event.c.resource_type.drop()
event.c.resource_properties.drop()

View File

@ -144,6 +144,12 @@ class Event(BASE, HeatBase):
backref=backref('events'), cascade="all, delete", passive_deletes=True)
name = Column(String)
logical_resource_id = Column(String)
physical_resource_id = Column(String)
resource_status_reason = Column(String)
resource_type = Column(String)
resource_properties = Column(PickleType)
class Resource(BASE, HeatBase):

View File

@ -181,12 +181,15 @@ class EngineManager(manager.Manager):
def parse_event(e):
s = e.stack
# TODO Missing LogicalResourceId, PhysicalResourceId, ResourceType,
# ResourceStatusReason
return {'EventId': e.id,
'StackId': e.stack_id,
'StackName': s.name,
'Timestamp': str(e.created_at),
'ResourceStatus': str(e.name)}
'StackId': e.stack_id,
'StackName': s.name,
'Timestamp': str(e.created_at),
'LogicalResourceId': e.logical_resource_id,
'PhysicalResourceId': e.physical_resource_id,
'ResourceType': e.resource_type,
'ResourceStatusReason': e.resource_status_reason,
'ResourceProperties': e.resource_properties,
'ResourceStatus': e.name}
return {'events': [parse_event(e) for e in events]}

View File

@ -20,8 +20,8 @@ except ImportError:
'revision_id': 'LOCALREVISION',
'revno': 0}
GLANCE_VERSION = ['0.0', '1']
COUNT, REVSISION = GLANCE_VERSION
GLANCE_VERSION = ['0.0', '2']
COUNT, REVISION = GLANCE_VERSION
FINAL = False # This becomes true at Release Candidate time