Merge "Fix NoneType has no attribute get error"

This commit is contained in:
Jenkins 2017-06-21 11:49:51 +00:00 committed by Gerrit Code Review
commit 42e6848551
3 changed files with 9 additions and 5 deletions

View File

@ -278,7 +278,7 @@ class FilterScheduler(driver.Scheduler):
# takes 'resource_XX' and 'volume_XX' as input respectively, copying
# 'volume_XX' to 'resource_XX' will make both filters happy.
volume_type = request_spec.get("volume_type")
resource_type = request_spec.get("volume_type", {})
resource_type = volume_type if volume_type is not None else {}
config_options = self._get_configuration_options()

View File

@ -46,7 +46,8 @@ class FakeHostManager(host_manager.HostManager):
'thick_provisioning_support': True,
'reserved_percentage': 10,
'volume_backend_name': 'lvm1',
'timestamp': UTC_NOW},
'timestamp': UTC_NOW,
'multiattach': True},
'host2': {'total_capacity_gb': 2048,
'free_capacity_gb': 300,
'allocated_capacity_gb': 1748,

View File

@ -334,15 +334,18 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase):
return (sched, fake_context)
@ddt.data(None, {'name': 'LVM_iSCSI'})
@mock.patch('cinder.db.service_get_all')
def test_backend_passes_filters_happy_day(self, _mock_service_get_topic):
def test_backend_passes_filters_happy_day(self, volume_type,
_mock_service_get_topic):
"""Do a successful pass through of with backend_passes_filters()."""
sched, ctx = self._backend_passes_filters_setup(
_mock_service_get_topic)
request_spec = {'volume_id': fake.VOLUME_ID,
'volume_type': {'name': 'LVM_iSCSI'},
'volume_type': volume_type,
'volume_properties': {'project_id': 1,
'size': 1}}
'size': 1,
'multiattach': True}}
request_spec = objects.RequestSpec.from_primitives(request_spec)
ret_host = sched.backend_passes_filters(ctx, 'host1#lvm1',
request_spec, {})