Rename event logical_resource_id to resource_name

This is to address an unimplemented comment at
https://review.openstack.org/#/c/41290/2/heat/engine/event.py
Bascically, there is a logical_resource_id/resource_name mismatch to
address, and this patch is trying to resolve that.

Change-Id: Idac696259af30f8db7816499474057c354d73800
This commit is contained in:
Liang Chen 2013-08-18 20:38:04 +08:00
parent 1623b03517
commit bef420b980
9 changed files with 72 additions and 43 deletions

View File

@ -0,0 +1,29 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import sqlalchemy
def upgrade(migrate_engine):
meta = sqlalchemy.MetaData()
meta.bind = migrate_engine
event = sqlalchemy.Table('event', meta, autoload=True)
event.c.logical_resource_id.alter(name='resource_name')
def downgrade(migrate_engine):
meta = sqlalchemy.MetaData()
meta.bind = migrate_engine
event = sqlalchemy.Table('event', meta, autoload=True)
event.c.resource_name.alter(name='logical_resource_id')

View File

@ -230,7 +230,7 @@ class Event(BASE, HeatBase):
resource_action = sqlalchemy.Column(sqlalchemy.String)
resource_status = sqlalchemy.Column(sqlalchemy.String)
logical_resource_id = sqlalchemy.Column(sqlalchemy.String)
resource_name = sqlalchemy.Column(sqlalchemy.String)
physical_resource_id = sqlalchemy.Column(sqlalchemy.String)
resource_status_reason = sqlalchemy.Column(sqlalchemy.String)
resource_type = sqlalchemy.Column(sqlalchemy.String)

View File

@ -127,7 +127,7 @@ def format_event(event):
api.EVENT_STACK_ID: dict(stack_identifier),
api.EVENT_STACK_NAME: stack_identifier.stack_name,
api.EVENT_TIMESTAMP: timeutils.isotime(event.timestamp),
api.EVENT_RES_NAME: event.logical_resource_id,
api.EVENT_RES_NAME: event.resource_name,
api.EVENT_RES_PHYSICAL_ID: event.physical_resource_id,
api.EVENT_RES_ACTION: event.action,
api.EVENT_RES_STATUS: event.status,

View File

@ -38,7 +38,7 @@ class Event(object):
self.status = status
self.reason = reason
self.physical_resource_id = physical_resource_id
self.logical_resource_id = resource_name
self.resource_name = resource_name
self.resource_type = resource_type
try:
self.resource_properties = dict(resource_properties)
@ -63,13 +63,13 @@ class Event(object):
return cls(context, st, ev.resource_action, ev.resource_status,
ev.resource_status_reason, ev.physical_resource_id,
ev.resource_properties, ev.logical_resource_id,
ev.resource_properties, ev.resource_name,
ev.resource_type, ev.created_at, ev.id)
def store(self):
'''Store the Event in the database.'''
ev = {
'logical_resource_id': self.logical_resource_id,
'resource_name': self.resource_name,
'physical_resource_id': self.physical_resource_id,
'stack_id': self.stack.id,
'resource_action': self.action,
@ -95,6 +95,6 @@ class Event(object):
return None
res_id = identifier.ResourceIdentifier(
resource_name=self.logical_resource_id, **self.stack.identifier())
resource_name=self.resource_name, **self.stack.identifier())
return identifier.EventIdentifier(event_id=str(self.id), **res_id)

View File

@ -54,7 +54,7 @@ RES_KEYS = (
RES_REQUIRED_BY,
) = (
'description', 'updated_time',
'logical_resource_id', 'physical_resource_id', 'metadata',
'resource_name', 'physical_resource_id', 'metadata',
'resource_action', 'resource_status', 'resource_status_reason',
'resource_type', 'resource_identity', STACK_ID, STACK_NAME,
'required_by',

View File

@ -1207,7 +1207,7 @@ class CfnStackControllerTest(HeatTestCase):
u'stack_name': u'wordpress',
u'stack_id': u'6',
u'path': u''},
u'logical_resource_id': u'WikiDatabase',
u'resource_name': u'WikiDatabase',
u'resource_status_reason': u'state changed',
u'event_identity':
{u'tenant': u't',
@ -1322,7 +1322,7 @@ class CfnStackControllerTest(HeatTestCase):
u'path': u'resources/WikiDatabase'
},
u'stack_name': u'wordpress',
u'logical_resource_id': u'WikiDatabase',
u'resource_name': u'WikiDatabase',
u'resource_status_reason': None,
u'updated_time': u'2012-07-23T13:06:00Z',
u'stack_identity': {u'tenant': u't',
@ -1451,7 +1451,7 @@ class CfnStackControllerTest(HeatTestCase):
u'path': u'resources/WikiDatabase'
},
u'stack_name': u'wordpress',
u'logical_resource_id': u'WikiDatabase',
u'resource_name': u'WikiDatabase',
u'resource_status_reason': None,
u'updated_time': u'2012-07-23T13:06:00Z',
u'stack_identity': {u'tenant': u't',
@ -1544,7 +1544,7 @@ class CfnStackControllerTest(HeatTestCase):
u'path': u'resources/WikiDatabase'
},
u'stack_name': u'wordpress',
u'logical_resource_id': u'WikiDatabase',
u'resource_name': u'WikiDatabase',
u'resource_status_reason': None,
u'updated_time': u'2012-07-23T13:06:00Z',
u'stack_identity': {u'tenant': u't',
@ -1653,7 +1653,7 @@ class CfnStackControllerTest(HeatTestCase):
u'stack_id': u'6',
u'path': u'/resources/WikiDatabase'},
u'stack_name': u'wordpress',
u'logical_resource_id': u'WikiDatabase',
u'resource_name': u'WikiDatabase',
u'resource_status_reason': None,
u'updated_time': u'2012-07-23T13:06:00Z',
u'stack_identity': {u'tenant': u't',

View File

@ -1299,7 +1299,7 @@ class ResourceControllerTest(ControllerTest, HeatTestCase):
{
u'resource_identity': dict(res_identity),
u'stack_name': stack_identity.stack_name,
u'logical_resource_id': res_name,
u'resource_name': res_name,
u'resource_status_reason': None,
u'updated_time': u'2012-07-23T13:06:00Z',
u'stack_identity': stack_identity,
@ -1328,7 +1328,7 @@ class ResourceControllerTest(ControllerTest, HeatTestCase):
'rel': 'self'},
{'href': self._url(stack_identity),
'rel': 'stack'}],
u'logical_resource_id': res_name,
u'resource_name': res_name,
u'resource_status_reason': None,
u'updated_time': u'2012-07-23T13:06:00Z',
u'resource_status': u'CREATE_COMPLETE',
@ -1378,7 +1378,7 @@ class ResourceControllerTest(ControllerTest, HeatTestCase):
u'description': u'',
u'resource_identity': dict(res_identity),
u'stack_name': stack_identity.stack_name,
u'logical_resource_id': res_name,
u'resource_name': res_name,
u'resource_status_reason': None,
u'updated_time': u'2012-07-23T13:06:00Z',
u'stack_identity': dict(stack_identity),
@ -1411,7 +1411,7 @@ class ResourceControllerTest(ControllerTest, HeatTestCase):
{'href': self._url(stack_identity), 'rel': 'stack'},
],
u'description': u'',
u'logical_resource_id': res_name,
u'resource_name': res_name,
u'resource_status_reason': None,
u'updated_time': u'2012-07-23T13:06:00Z',
u'resource_status': u'CREATE_COMPLETE',
@ -1530,7 +1530,7 @@ class ResourceControllerTest(ControllerTest, HeatTestCase):
u'description': u'',
u'resource_identity': dict(res_identity),
u'stack_name': stack_identity.stack_name,
u'logical_resource_id': res_name,
u'resource_name': res_name,
u'resource_status_reason': None,
u'updated_time': u'2012-07-23T13:06:00Z',
u'stack_identity': dict(stack_identity),
@ -1658,7 +1658,7 @@ class EventControllerTest(ControllerTest, HeatTestCase):
u'stack_name': u'wordpress',
u'event_time': u'2012-07-23T13:05:39Z',
u'stack_identity': dict(stack_identity),
u'logical_resource_id': res_name,
u'resource_name': res_name,
u'resource_status_reason': u'state changed',
u'event_identity': dict(ev_identity),
u'resource_action': u'CREATE',
@ -1671,7 +1671,7 @@ class EventControllerTest(ControllerTest, HeatTestCase):
u'stack_name': u'wordpress',
u'event_time': u'2012-07-23T13:05:39Z',
u'stack_identity': dict(stack_identity),
u'logical_resource_id': 'SomeOtherResource',
u'resource_name': 'SomeOtherResource',
u'resource_status_reason': u'state changed',
u'event_identity': dict(ev_identity),
u'resource_action': u'CREATE',
@ -1704,7 +1704,7 @@ class EventControllerTest(ControllerTest, HeatTestCase):
{'href': self._url(res_identity), 'rel': 'resource'},
{'href': self._url(stack_identity), 'rel': 'stack'},
],
u'logical_resource_id': res_name,
u'resource_name': res_name,
u'resource_status_reason': u'state changed',
u'event_time': u'2012-07-23T13:05:39Z',
u'resource_status': u'CREATE_IN_PROGRESS',
@ -1733,7 +1733,7 @@ class EventControllerTest(ControllerTest, HeatTestCase):
u'stack_name': u'wordpress',
u'event_time': u'2012-07-23T13:05:39Z',
u'stack_identity': dict(stack_identity),
u'logical_resource_id': res_name,
u'resource_name': res_name,
u'resource_status_reason': u'state changed',
u'event_identity': dict(ev_identity),
u'resource_action': u'CREATE',
@ -1765,7 +1765,7 @@ class EventControllerTest(ControllerTest, HeatTestCase):
{'href': self._url(res_identity), 'rel': 'resource'},
{'href': self._url(stack_identity), 'rel': 'stack'},
],
u'logical_resource_id': res_name,
u'resource_name': res_name,
u'resource_status_reason': u'state changed',
u'event_time': u'2012-07-23T13:05:39Z',
u'resource_status': u'CREATE_IN_PROGRESS',
@ -1821,7 +1821,7 @@ class EventControllerTest(ControllerTest, HeatTestCase):
u'stack_name': u'wordpress',
u'event_time': u'2012-07-23T13:05:39Z',
u'stack_identity': dict(stack_identity),
u'logical_resource_id': 'SomeOtherResource',
u'resource_name': 'SomeOtherResource',
u'resource_status_reason': u'state changed',
u'event_identity': dict(ev_identity),
u'resource_action': u'CREATE',
@ -1868,7 +1868,7 @@ class EventControllerTest(ControllerTest, HeatTestCase):
u'stack_name': u'wordpress',
u'event_time': u'2012-07-23T13:05:39Z',
u'stack_identity': dict(stack_identity),
u'logical_resource_id': res_name,
u'resource_name': res_name,
u'resource_status_reason': u'state changed',
u'event_identity': dict(ev1_identity),
u'resource_action': u'CREATE',
@ -1881,7 +1881,7 @@ class EventControllerTest(ControllerTest, HeatTestCase):
u'stack_name': u'wordpress',
u'event_time': u'2012-07-23T13:06:00Z',
u'stack_identity': dict(stack_identity),
u'logical_resource_id': res_name,
u'resource_name': res_name,
u'resource_status_reason': u'state changed',
u'event_identity': dict(ev_identity),
u'resource_action': u'CREATE',
@ -1915,7 +1915,7 @@ class EventControllerTest(ControllerTest, HeatTestCase):
{'href': self._url(res_identity), 'rel': 'resource'},
{'href': self._url(stack_identity), 'rel': 'stack'},
],
u'logical_resource_id': res_name,
u'resource_name': res_name,
u'resource_status_reason': u'state changed',
u'event_time': u'2012-07-23T13:06:00Z',
u'resource_status': u'CREATE_COMPLETE',
@ -1947,7 +1947,7 @@ class EventControllerTest(ControllerTest, HeatTestCase):
u'stack_name': u'wordpress',
u'event_time': u'2012-07-23T13:05:39Z',
u'stack_identity': dict(stack_identity),
u'logical_resource_id': res_name,
u'resource_name': res_name,
u'resource_status_reason': u'state changed',
u'event_identity': dict(ev_identity),
u'resource_action': u'CREATE',
@ -1992,7 +1992,7 @@ class EventControllerTest(ControllerTest, HeatTestCase):
u'stack_name': u'wordpress',
u'event_time': u'2012-07-23T13:05:39Z',
u'stack_identity': dict(stack_identity),
u'logical_resource_id': 'SomeOtherResourceName',
u'resource_name': 'SomeOtherResourceName',
u'resource_status_reason': u'state changed',
u'event_identity': dict(ev_identity),
u'resource_action': u'CREATE',

View File

@ -679,8 +679,8 @@ class StackServiceTest(HeatTestCase):
self.assertEqual(dict, type(ev['event_identity']))
self.assertTrue(ev['event_identity']['path'].rsplit('/', 1)[1])
self.assertTrue('logical_resource_id' in ev)
self.assertEqual('WebServer', ev['logical_resource_id'])
self.assertTrue('resource_name' in ev)
self.assertEqual('WebServer', ev['resource_name'])
self.assertTrue('physical_resource_id' in ev)
@ -750,7 +750,7 @@ class StackServiceTest(HeatTestCase):
self.assertEqual(dict, type(ev['event_identity']))
self.assertTrue(ev['event_identity']['path'].rsplit('/', 1)[1])
self.assertIn('logical_resource_id', ev)
self.assertIn('resource_name', ev)
self.assertIn('physical_resource_id', ev)
self.assertIn('resource_properties', ev)
self.assertIn('resource_status_reason', ev)
@ -781,8 +781,8 @@ class StackServiceTest(HeatTestCase):
self.assertThat(ev['event_identity'], matchers.IsInstance(dict))
self.assertTrue(ev['event_identity']['path'].rsplit('/', 1)[1])
self.assertTrue('logical_resource_id' in ev)
self.assertEqual('WebServer', ev['logical_resource_id'])
self.assertTrue('resource_name' in ev)
self.assertEqual('WebServer', ev['resource_name'])
self.assertTrue('physical_resource_id' in ev)
@ -969,8 +969,8 @@ class StackServiceTest(HeatTestCase):
self.assertTrue('resource_status_reason' in r)
self.assertTrue('resource_type' in r)
self.assertTrue('physical_resource_id' in r)
self.assertTrue('logical_resource_id' in r)
self.assertEqual('WebServer', r['logical_resource_id'])
self.assertTrue('resource_name' in r)
self.assertEqual('WebServer', r['resource_name'])
self.m.VerifyAll()
@ -1070,8 +1070,8 @@ class StackServiceTest(HeatTestCase):
self.assertTrue('resource_status_reason' in r)
self.assertTrue('resource_type' in r)
self.assertTrue('physical_resource_id' in r)
self.assertTrue('logical_resource_id' in r)
self.assertEqual('WebServer', r['logical_resource_id'])
self.assertTrue('resource_name' in r)
self.assertEqual('WebServer', r['resource_name'])
self.m.VerifyAll()
@ -1088,8 +1088,8 @@ class StackServiceTest(HeatTestCase):
self.assertEqual(1, len(resources))
r = resources[0]
self.assertTrue('logical_resource_id' in r)
self.assertEqual('WebServer', r['logical_resource_id'])
self.assertTrue('resource_name' in r)
self.assertEqual('WebServer', r['resource_name'])
self.m.VerifyAll()
@ -1146,8 +1146,8 @@ class StackServiceTest(HeatTestCase):
self.assertTrue('resource_identity' in r)
self.assertTrue('updated_time' in r)
self.assertTrue('physical_resource_id' in r)
self.assertTrue('logical_resource_id' in r)
self.assertEqual('WebServer', r['logical_resource_id'])
self.assertTrue('resource_name' in r)
self.assertEqual('WebServer', r['resource_name'])
self.assertTrue('resource_status' in r)
self.assertTrue('resource_status_reason' in r)
self.assertTrue('resource_type' in r)

View File

@ -69,7 +69,7 @@ class EventTest(HeatTestCase):
loaded_e = event.Event.load(self.ctx, e.id)
self.assertEqual(self.stack.id, loaded_e.stack.id)
self.assertEqual(self.resource.name, loaded_e.logical_resource_id)
self.assertEqual(self.resource.name, loaded_e.resource_name)
self.assertEqual('wibble', loaded_e.physical_resource_id)
self.assertEqual('TEST', loaded_e.action)
self.assertEqual('IN_PROGRESS', loaded_e.status)
@ -92,7 +92,7 @@ class EventTest(HeatTestCase):
loaded_e = event.Event.load(self.ctx, e.id, stack=self.stack, event=ev)
self.assertEqual(self.stack.id, loaded_e.stack.id)
self.assertEqual(self.resource.name, loaded_e.logical_resource_id)
self.assertEqual(self.resource.name, loaded_e.resource_name)
self.assertEqual('wibble', loaded_e.physical_resource_id)
self.assertEqual('TEST', loaded_e.action)
self.assertEqual('IN_PROGRESS', loaded_e.status)