Merge "Fix inconsistent naming in db api"
This commit is contained in:
commit
aad16e9684
@ -1582,7 +1582,7 @@ def snapshot_delete(context, snapshot_id):
|
||||
|
||||
|
||||
@context_manager.reader
|
||||
def snapshot_get_all(context, stack_id):
|
||||
def snapshot_get_all_by_stack(context, stack_id):
|
||||
return context.session.query(models.Snapshot).filter_by(
|
||||
stack_id=stack_id, tenant=context.tenant_id)
|
||||
|
||||
|
@ -2198,7 +2198,7 @@ class EngineService(service.ServiceBase):
|
||||
@context.request_context
|
||||
def stack_list_snapshots(self, cnxt, stack_identity):
|
||||
s = self._get_stack(cnxt, stack_identity)
|
||||
data = snapshot_object.Snapshot.get_all(cnxt, s.id)
|
||||
data = snapshot_object.Snapshot.get_all_by_stack(cnxt, s.id)
|
||||
return [api.format_snapshot(snapshot) for snapshot in data]
|
||||
|
||||
@context.request_context
|
||||
|
@ -2132,7 +2132,8 @@ class Stack(collections.abc.Mapping):
|
||||
|
||||
def delete_all_snapshots(self):
|
||||
"""Remove all snapshots for this stack."""
|
||||
snapshots = snapshot_object.Snapshot.get_all(self.context, self.id)
|
||||
snapshots = snapshot_object.Snapshot.get_all_by_stack(
|
||||
self.context, self.id)
|
||||
for snapshot in snapshots:
|
||||
self.delete_snapshot(snapshot)
|
||||
snapshot_object.Snapshot.delete(self.context, snapshot.id)
|
||||
|
@ -70,6 +70,7 @@ class Snapshot(
|
||||
db_api.snapshot_delete(context, snapshot_id)
|
||||
|
||||
@classmethod
|
||||
def get_all(cls, context, stack_id):
|
||||
def get_all_by_stack(cls, context, stack_id):
|
||||
return [cls._from_db_object(context, cls(), db_snapshot)
|
||||
for db_snapshot in db_api.snapshot_get_all(context, stack_id)]
|
||||
for db_snapshot
|
||||
in db_api.snapshot_get_all_by_stack(context, stack_id)]
|
||||
|
@ -1421,7 +1421,7 @@ class SqlAlchemyTest(common.HeatTestCase):
|
||||
|
||||
self.assertIn(snapshot_id, str(err))
|
||||
|
||||
def test_snapshot_get_all(self):
|
||||
def test_snapshot_get_all_by_stack(self):
|
||||
template = create_raw_template(self.ctx)
|
||||
user_creds = create_user_creds(self.ctx)
|
||||
stack = create_stack(self.ctx, template, user_creds)
|
||||
@ -1429,7 +1429,7 @@ class SqlAlchemyTest(common.HeatTestCase):
|
||||
'stack_id': stack.id}
|
||||
snapshot = db_api.snapshot_create(self.ctx, values)
|
||||
self.assertIsNotNone(snapshot)
|
||||
[snapshot] = db_api.snapshot_get_all(self.ctx, stack.id)
|
||||
[snapshot] = db_api.snapshot_get_all_by_stack(self.ctx, stack.id)
|
||||
self.assertIsNotNone(snapshot)
|
||||
self.assertEqual(values['tenant'], snapshot.tenant)
|
||||
self.assertEqual(values['status'], snapshot.status)
|
||||
|
@ -549,14 +549,14 @@ class StackConvergenceCreateUpdateDeleteTest(common.HeatTestCase):
|
||||
|
||||
# Ensure that snapshot is not deleted on stack update
|
||||
stack.converge_stack(template=stack.t, action=stack.UPDATE)
|
||||
db_snapshot_obj = snapshot_objects.Snapshot.get_all(
|
||||
db_snapshot_obj = snapshot_objects.Snapshot.get_all_by_stack(
|
||||
stack.context, stack.id)
|
||||
self.assertEqual('fake_snapshot', db_snapshot_obj[0].name)
|
||||
self.assertEqual(stack.id, db_snapshot_obj[0].stack_id)
|
||||
|
||||
# Ensure that snapshot is deleted on stack delete
|
||||
stack.converge_stack(template=stack.t, action=stack.DELETE)
|
||||
self.assertEqual([], snapshot_objects.Snapshot.get_all(
|
||||
self.assertEqual([], snapshot_objects.Snapshot.get_all_by_stack(
|
||||
stack.context, stack.id))
|
||||
self.assertTrue(mock_cr.called)
|
||||
|
||||
|
@ -73,7 +73,7 @@ class StackTest(common.HeatTestCase):
|
||||
}
|
||||
snapshot_object.Snapshot.create(self.ctx, snapshot_fake)
|
||||
|
||||
self.assertIsNotNone(snapshot_object.Snapshot.get_all(
|
||||
self.assertIsNotNone(snapshot_object.Snapshot.get_all_by_stack(
|
||||
self.ctx, stack_id))
|
||||
|
||||
self.stack.delete()
|
||||
@ -81,7 +81,7 @@ class StackTest(common.HeatTestCase):
|
||||
self.assertIsNone(db_s)
|
||||
self.assertEqual((stack.Stack.DELETE, stack.Stack.COMPLETE),
|
||||
self.stack.state)
|
||||
self.assertEqual([], snapshot_object.Snapshot.get_all(
|
||||
self.assertEqual([], snapshot_object.Snapshot.get_all_by_stack(
|
||||
self.ctx, stack_id))
|
||||
|
||||
def test_delete_with_snapshot_after_stack_add_resource(self):
|
||||
@ -104,7 +104,7 @@ class StackTest(common.HeatTestCase):
|
||||
}
|
||||
snapshot_object.Snapshot.create(self.ctx, snapshot_fake)
|
||||
|
||||
self.assertIsNotNone(snapshot_object.Snapshot.get_all(
|
||||
self.assertIsNotNone(snapshot_object.Snapshot.get_all_by_stack(
|
||||
self.ctx, stack_id))
|
||||
|
||||
new_tmpl = {'heat_template_version': 'queens',
|
||||
@ -121,7 +121,7 @@ class StackTest(common.HeatTestCase):
|
||||
self.assertIsNone(db_s)
|
||||
self.assertEqual((stack.Stack.DELETE, stack.Stack.COMPLETE),
|
||||
self.stack.state)
|
||||
self.assertEqual([], snapshot_object.Snapshot.get_all(
|
||||
self.assertEqual([], snapshot_object.Snapshot.get_all_by_stack(
|
||||
self.ctx, stack_id))
|
||||
|
||||
def test_delete_user_creds(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user