~ubuntu-branches/ubuntu/trusty/heat/trusty-security

« back to all changes in this revision

Viewing changes to heat/engine/event.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2013-09-08 21:51:19 UTC
  • mto: This revision was merged to the branch mainline in revision 14.
  • Revision ID: package-import@ubuntu.com-20130908215119-7tcek6gn73275x5k
Tags: upstream-2013.2~b3
ImportĀ upstreamĀ versionĀ 2013.2~b3

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
class Event(object):
25
25
    '''Class representing a Resource state change.'''
26
26
 
27
 
    def __init__(self, context, stack, resource,
28
 
                 action, status, reason,
29
 
                 physical_resource_id, resource_properties,
30
 
                 timestamp=None, id=None):
 
27
    def __init__(self, context, stack, action, status, reason,
 
28
                 physical_resource_id, resource_properties, resource_name,
 
29
                 resource_type, timestamp=None, id=None):
31
30
        '''
32
 
        Initialise from a context, stack, resource, event information and
33
 
        current resource data. The timestamp and database ID may also be
34
 
        initialised if the event is already in the database.
 
31
        Initialise from a context, stack, and event information. The timestamp
 
32
        and database ID may also be initialised if the event is already in the
 
33
        database.
35
34
        '''
36
35
        self.context = context
37
 
        self.resource = resource
38
36
        self.stack = stack
39
37
        self.action = action
40
38
        self.status = status
41
39
        self.reason = reason
42
40
        self.physical_resource_id = physical_resource_id
 
41
        self.resource_name = resource_name
 
42
        self.resource_type = resource_type
43
43
        try:
44
44
            self.resource_properties = dict(resource_properties)
45
45
        except ValueError as ex:
60
60
 
61
61
        st = stack if stack is not None else\
62
62
            parser.Stack.load(context, ev.stack_id)
63
 
        resource = st[ev.logical_resource_id]
64
63
 
65
 
        return cls(context, st, resource,
66
 
                   ev.resource_action, ev.resource_status,
67
 
                   ev.resource_status_reason,
68
 
                   ev.physical_resource_id, ev.resource_properties,
69
 
                   ev.created_at, ev.id)
 
64
        return cls(context, st, ev.resource_action, ev.resource_status,
 
65
                   ev.resource_status_reason, ev.physical_resource_id,
 
66
                   ev.resource_properties, ev.resource_name,
 
67
                   ev.resource_type, ev.created_at, ev.id)
70
68
 
71
69
    def store(self):
72
70
        '''Store the Event in the database.'''
73
71
        ev = {
74
 
            'logical_resource_id': self.resource.name,
 
72
            'resource_name': self.resource_name,
75
73
            'physical_resource_id': self.physical_resource_id,
76
74
            'stack_id': self.stack.id,
77
75
            'resource_action': self.action,
78
76
            'resource_status': self.status,
79
77
            'resource_status_reason': self.reason,
80
 
            'resource_type': self.resource.type(),
 
78
            'resource_type': self.resource_type,
81
79
            'resource_properties': self.resource_properties,
82
80
        }
83
81
 
96
94
        if self.id is None:
97
95
            return None
98
96
 
99
 
        return identifier.EventIdentifier(event_id=str(self.id),
100
 
                                          **self.resource.identifier())
 
97
        res_id = identifier.ResourceIdentifier(
 
98
            resource_name=self.resource_name, **self.stack.identifier())
 
99
 
 
100
        return identifier.EventIdentifier(event_id=str(self.id), **res_id)