Merge "Migrate nova_instance to physical_resource_id"
This commit is contained in:
commit
ccd0e86baa
@ -159,7 +159,7 @@ def resource_get_by_name_and_stack(context, resource_name, stack_id):
|
||||
|
||||
def resource_get_by_physical_resource_id(context, physical_resource_id):
|
||||
results = (model_query(context, models.Resource)
|
||||
.filter_by(nova_instance=physical_resource_id)
|
||||
.filter_by(physical_resource_id=physical_resource_id)
|
||||
.all())
|
||||
|
||||
for result in results:
|
||||
|
@ -280,7 +280,8 @@ class Resource(BASE, HeatBase, StateAware):
|
||||
default=lambda: str(uuid.uuid4()),
|
||||
unique=True)
|
||||
name = sqlalchemy.Column('name', sqlalchemy.String(255))
|
||||
nova_instance = sqlalchemy.Column('nova_instance', sqlalchemy.String(255))
|
||||
physical_resource_id = sqlalchemy.Column('nova_instance',
|
||||
sqlalchemy.String(255))
|
||||
# odd name as "metadata" is reserved
|
||||
rsrc_metadata = sqlalchemy.Column('rsrc_metadata', types.Json)
|
||||
|
||||
|
@ -246,7 +246,7 @@ class Resource(object):
|
||||
|
||||
def _load_data(self, resource):
|
||||
"""Load the resource state from its DB representation."""
|
||||
self.resource_id = resource.nova_instance
|
||||
self.resource_id = resource.physical_resource_id
|
||||
self.action = resource.action
|
||||
self.status = resource.status
|
||||
self.status_reason = resource.status_reason
|
||||
@ -1499,7 +1499,9 @@ class Resource(object):
|
||||
if self.id is not None:
|
||||
try:
|
||||
resource_objects.Resource.update_by_id(
|
||||
self.context, self.id, {'nova_instance': self.resource_id})
|
||||
self.context,
|
||||
self.id,
|
||||
{'physical_resource_id': self.resource_id})
|
||||
except Exception as ex:
|
||||
LOG.warning(_LW('db error %s'), ex)
|
||||
|
||||
@ -1516,7 +1518,7 @@ class Resource(object):
|
||||
'status': self.status,
|
||||
'status_reason': self.status_reason,
|
||||
'stack_id': self.stack.id,
|
||||
'nova_instance': self.resource_id,
|
||||
'physical_resource_id': self.resource_id,
|
||||
'name': self.name,
|
||||
'rsrc_metadata': metadata,
|
||||
'properties_data': properties_data,
|
||||
@ -1568,7 +1570,7 @@ class Resource(object):
|
||||
'replaces': self.replaces,
|
||||
'replaced_by': self.replaced_by,
|
||||
'current_template_id': self.current_template_id,
|
||||
'nova_instance': self.resource_id,
|
||||
'physical_resource_id': self.resource_id,
|
||||
'root_stack_id': self.root_stack_id
|
||||
}
|
||||
if prev_action == self.INIT:
|
||||
|
@ -53,7 +53,7 @@ class Resource(
|
||||
'stack_id': fields.StringField(),
|
||||
'created_at': fields.DateTimeField(read_only=True),
|
||||
'updated_at': fields.DateTimeField(nullable=True),
|
||||
'nova_instance': fields.StringField(nullable=True),
|
||||
'physical_resource_id': fields.StringField(nullable=True),
|
||||
'name': fields.StringField(nullable=True),
|
||||
'status': fields.StringField(nullable=True),
|
||||
'status_reason': fields.StringField(nullable=True),
|
||||
|
@ -39,7 +39,7 @@ def verify(test, reality, tmpl):
|
||||
|
||||
elif isinstance(prop_def, scenario_template.GetRes):
|
||||
targs = reality.resources_by_logical_name(prop_def.target_name)
|
||||
test.assertEqual(targs[0].nova_instance, real_value)
|
||||
test.assertEqual(targs[0].physical_resource_id, real_value)
|
||||
|
||||
else:
|
||||
test.assertEqual(prop_def, real_value)
|
||||
|
@ -1416,7 +1416,7 @@ def create_stack(ctx, template, user_creds, **kwargs):
|
||||
def create_resource(ctx, stack, **kwargs):
|
||||
values = {
|
||||
'name': 'test_resource_name',
|
||||
'nova_instance': UUID1,
|
||||
'physical_resource_id': UUID1,
|
||||
'action': 'create',
|
||||
'status': 'complete',
|
||||
'status_reason': 'create_complete',
|
||||
@ -2116,7 +2116,7 @@ class DBAPIResourceTest(common.HeatTestCase):
|
||||
ret_res = db_api.resource_get(self.ctx, res.id)
|
||||
self.assertIsNotNone(ret_res)
|
||||
self.assertEqual('test_resource_name', ret_res.name)
|
||||
self.assertEqual(UUID1, ret_res.nova_instance)
|
||||
self.assertEqual(UUID1, ret_res.physical_resource_id)
|
||||
self.assertEqual('create', ret_res.action)
|
||||
self.assertEqual('complete', ret_res.status)
|
||||
self.assertEqual('create_complete', ret_res.status_reason)
|
||||
@ -2151,7 +2151,7 @@ class DBAPIResourceTest(common.HeatTestCase):
|
||||
|
||||
ret_res = db_api.resource_get_by_physical_resource_id(self.ctx, UUID1)
|
||||
self.assertIsNotNone(ret_res)
|
||||
self.assertEqual(UUID1, ret_res.nova_instance)
|
||||
self.assertEqual(UUID1, ret_res.physical_resource_id)
|
||||
|
||||
self.assertIsNone(db_api.resource_get_by_physical_resource_id(self.ctx,
|
||||
UUID2))
|
||||
|
@ -537,7 +537,7 @@ class ResourceTest(common.HeatTestCase):
|
||||
|
||||
self.assertEqual(new_id, res.replaced_by)
|
||||
self.assertEqual(res.id, new_res.replaces)
|
||||
self.assertIsNone(new_res.nova_instance)
|
||||
self.assertIsNone(new_res.physical_resource_id)
|
||||
self.assertEqual(new_tmpl_id, new_res.current_template_id)
|
||||
|
||||
def test_parsed_template(self):
|
||||
|
Loading…
Reference in New Issue
Block a user