Merge "Fix AttributeError without share type provided"
This commit is contained in:
commit
14c18049f7
|
@ -122,6 +122,12 @@ class FilterScheduler(driver.Scheduler):
|
|||
# 'volume_XX' to 'resource_XX' will make both filters happy.
|
||||
resource_properties = share_properties.copy()
|
||||
share_type = request_spec.get("share_type", {})
|
||||
if not share_type:
|
||||
msg = _("You must create a share type in advance,"
|
||||
" and specify in request body or"
|
||||
" set default_share_type in manila.conf.")
|
||||
LOG.error(msg)
|
||||
raise exception.InvalidParameterValue(err=msg)
|
||||
|
||||
extra_specs = share_type.get('extra_specs', {})
|
||||
|
||||
|
|
|
@ -132,6 +132,16 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase):
|
|||
self.assertIsNone(weighed_host)
|
||||
self.assertTrue(_mock_service_get_all_by_topic.called)
|
||||
|
||||
def test_schedule_share_type_is_none(self):
|
||||
sched = fakes.FakeFilterScheduler()
|
||||
request_spec = {
|
||||
'share_type': None,
|
||||
'share_properties': {'project_id': 1, 'size': 1},
|
||||
}
|
||||
self.assertRaises(exception.InvalidParameterValue,
|
||||
sched._schedule_share,
|
||||
self.context, request_spec)
|
||||
|
||||
def test_max_attempts(self):
|
||||
self.flags(scheduler_max_attempts=4)
|
||||
sched = fakes.FakeFilterScheduler()
|
||||
|
|
Loading…
Reference in New Issue