Task cleanup_running_deleted_instances can now use slave

Deployments that have a slave_connection configured can offload
read queries generated by this periodic task there. For
deployments with no slave, behavior remains the same.

Partially-implements: blueprint periodic-tasks-to-db-slave
Change-Id: Ie1e6cdfbefab096a2af62ef636786a5c8f659b13
This commit is contained in:
Michael Wilson
2014-03-06 14:02:00 -07:00
parent dcd65f6756
commit 7e1b935acb
16 changed files with 48 additions and 31 deletions

View File

@@ -2379,7 +2379,8 @@ class CloudTestCase(test.TestCase):
self.stubs.Set(fake._FakeImageService, 'show', fake_show)
def fake_block_device_mapping_get_all_by_instance(context, inst_id):
def fake_block_device_mapping_get_all_by_instance(context, inst_id,
use_slave=False):
return [fake_block_device.FakeDbBlockDeviceDict(
{'volume_id': volumes[0],
'snapshot_id': snapshots[0],
@@ -2453,7 +2454,8 @@ class CloudTestCase(test.TestCase):
'max_count': 1}
ec2_instance_id = self._run_instance(**kwargs)
def fake_block_device_mapping_get_all_by_instance(context, inst_id):
def fake_block_device_mapping_get_all_by_instance(context, inst_id,
use_slave=False):
return [fake_block_device.FakeDbBlockDeviceDict(
{'volume_id': volumes[0],
'snapshot_id': snapshots[0],

View File

@@ -95,7 +95,7 @@ def fake_compute_volume_snapshot_create(self, context, volume_id,
pass
def fake_bdms_get_all_by_instance(context, instance_uuid):
def fake_bdms_get_all_by_instance(context, instance_uuid, use_slave=False):
return [fake_block_device.FakeDbBlockDeviceDict(
{'id': 1,
'instance_uuid': instance_uuid,

View File

@@ -855,7 +855,8 @@ class ServerActionsControllerTest(test.TestCase):
image_service.create(None, original_image)
def fake_block_device_mapping_get_all_by_instance(context, inst_id):
def fake_block_device_mapping_get_all_by_instance(context, inst_id,
use_slave=False):
return [fake_block_device.FakeDbBlockDeviceDict(
{'volume_id': _fake_id('a'),
'source_type': 'snapshot',
@@ -929,7 +930,8 @@ class ServerActionsControllerTest(test.TestCase):
image_service = glance.get_default_image_service()
def fake_block_device_mapping_get_all_by_instance(context, inst_id):
def fake_block_device_mapping_get_all_by_instance(context, inst_id,
use_slave=False):
return [fake_block_device.FakeDbBlockDeviceDict(
{'volume_id': _fake_id('a'),
'source_type': 'snapshot',

View File

@@ -1021,7 +1021,8 @@ class ServerActionsControllerTest(test.TestCase):
image_service.create(None, original_image)
def fake_block_device_mapping_get_all_by_instance(context, inst_id):
def fake_block_device_mapping_get_all_by_instance(context, inst_id,
use_slave=False):
return [fake_block_device.FakeDbBlockDeviceDict(
{'volume_id': _fake_id('a'),
'source_type': 'snapshot',
@@ -1095,7 +1096,8 @@ class ServerActionsControllerTest(test.TestCase):
image_service = glance.get_default_image_service()
def fake_block_device_mapping_get_all_by_instance(context, inst_id):
def fake_block_device_mapping_get_all_by_instance(context, inst_id,
use_slave=False):
return [fake_block_device.FakeDbBlockDeviceDict(
{'volume_id': _fake_id('a'),
'source_type': 'snapshot',

View File

@@ -709,7 +709,7 @@ def stub_snapshot_get_all(self, context):
stub_snapshot(102, project_id='superduperfake')]
def stub_bdm_get_all_by_instance(context, instance_uuid):
def stub_bdm_get_all_by_instance(context, instance_uuid, use_slave=False):
return [fake_block_device.FakeDbBlockDeviceDict(
{'id': 1, 'source_type': 'volume', 'destination_type': 'volume',
'volume_id': 'volume_id1', 'instance_uuid': instance_uuid}),