Merge "Add members in InstanceGroup object members field"
This commit is contained in:
commit
c9690c02da
@ -988,9 +988,12 @@ class API(base.Base):
|
|||||||
"group")
|
"group")
|
||||||
raise exception.QuotaError(msg)
|
raise exception.QuotaError(msg)
|
||||||
|
|
||||||
objects.InstanceGroup.add_members(context,
|
members = objects.InstanceGroup.add_members(
|
||||||
instance_group.uuid,
|
context, instance_group.uuid, [instance.uuid])
|
||||||
[instance.uuid])
|
# list of members added to servers group in this iteration
|
||||||
|
# is needed to check quota of server group during add next
|
||||||
|
# instance
|
||||||
|
instance_group.members.extend(members)
|
||||||
|
|
||||||
# send a state update notification for the initial create to
|
# send a state update notification for the initial create to
|
||||||
# show it going from non-existent to BUILDING
|
# show it going from non-existent to BUILDING
|
||||||
|
@ -7869,7 +7869,8 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
|
|
||||||
self.assertEqual(ref[0]['hostname'], hostname)
|
self.assertEqual(ref[0]['hostname'], hostname)
|
||||||
|
|
||||||
def test_instance_create_adds_to_instance_group(self):
|
@mock.patch('nova.compute.api.API._get_requested_instance_group')
|
||||||
|
def test_instance_create_adds_to_instance_group(self, get_group_mock):
|
||||||
self.stub_out('nova.tests.unit.image.fake._FakeImageService.show',
|
self.stub_out('nova.tests.unit.image.fake._FakeImageService.show',
|
||||||
self.fake_show)
|
self.fake_show)
|
||||||
|
|
||||||
@ -7878,11 +7879,13 @@ class ComputeAPITestCase(BaseTestCase):
|
|||||||
group.project_id = self.context.project_id
|
group.project_id = self.context.project_id
|
||||||
group.user_id = self.context.user_id
|
group.user_id = self.context.user_id
|
||||||
group.create()
|
group.create()
|
||||||
|
get_group_mock.return_value = group
|
||||||
|
|
||||||
inst_type = flavors.get_default_flavor()
|
inst_type = flavors.get_default_flavor()
|
||||||
(refs, resv_id) = self.compute_api.create(
|
(refs, resv_id) = self.compute_api.create(
|
||||||
self.context, inst_type, self.fake_image['id'],
|
self.context, inst_type, self.fake_image['id'],
|
||||||
scheduler_hints={'group': group.uuid})
|
scheduler_hints={'group': group.uuid})
|
||||||
|
self.assertEqual(len(refs), len(group.members))
|
||||||
|
|
||||||
group = objects.InstanceGroup.get_by_uuid(self.context, group.uuid)
|
group = objects.InstanceGroup.get_by_uuid(self.context, group.uuid)
|
||||||
self.assertIn(refs[0]['uuid'], group.members)
|
self.assertIn(refs[0]['uuid'], group.members)
|
||||||
|
Loading…
Reference in New Issue
Block a user