Merge "Fix volume creation with no volume type"

This commit is contained in:
Jenkins 2016-08-11 03:11:36 +00:00 committed by Gerrit Code Review
commit 451e4fcda4
3 changed files with 6 additions and 6 deletions

View File

@ -270,10 +270,6 @@ class FilterScheduler(driver.Scheduler):
self._populate_retry(filter_properties, self._populate_retry(filter_properties,
request_spec['volume_properties']) request_spec['volume_properties'])
if resource_type is None:
msg = _("volume_type cannot be None")
raise exception.InvalidVolumeType(reason=msg)
request_spec_dict = jsonutils.to_primitive(request_spec) request_spec_dict = jsonutils.to_primitive(request_spec)
filter_properties.update({'context': context, filter_properties.update({'context': context,
@ -427,7 +423,7 @@ class FilterScheduler(driver.Scheduler):
if not weighed_hosts: if not weighed_hosts:
LOG.warning(_LW('No weighed hosts found for volume ' LOG.warning(_LW('No weighed hosts found for volume '
'with properties: %s'), 'with properties: %s'),
filter_properties['request_spec']['volume_type']) filter_properties['request_spec'].get('volume_type'))
return None return None
return self._choose_top_host(weighed_hosts, request_spec) return self._choose_top_host(weighed_hosts, request_spec)

View File

@ -30,6 +30,10 @@ class CapabilitiesFilter(filters.BaseHostFilter):
Check that the capabilities provided by the services satisfy Check that the capabilities provided by the services satisfy
the extra specs associated with the resource type. the extra specs associated with the resource type.
""" """
if not resource_type:
return True
extra_specs = resource_type.get('extra_specs', []) extra_specs = resource_type.get('extra_specs', [])
if not extra_specs: if not extra_specs:
return True return True

View File

@ -147,7 +147,7 @@ class FilterSchedulerTestCase(test_scheduler.SchedulerTestCase):
'size': 1}, 'size': 1},
'volume_id': fake.VOLUME_ID} 'volume_id': fake.VOLUME_ID}
request_spec = objects.RequestSpec.from_primitives(request_spec) request_spec = objects.RequestSpec.from_primitives(request_spec)
self.assertRaises(exception.InvalidVolumeType, self.assertRaises(exception.NoValidHost,
sched.schedule_create_volume, sched.schedule_create_volume,
fake_context, fake_context,
request_spec, request_spec,