Currently when creating a volume without a specified
volume_type, the capabilities_filter fails saying that
NoneType object has no attribute 'get'. This patch
will make that issue instead throw an exception telling
the user that they need to specify a volume type.
Change-Id: I89635f9e4f4f44d16f391284ccc027e86c552cdf
Closes-Bug: #
1446031
filter_properties = {}
self._populate_retry(filter_properties, resource_properties)
+ if resource_type is None:
+ msg = _("volume_type cannot be None")
+ raise exception.InvalidVolumeType(reason=msg)
+
filter_properties.update({'context': context,
'request_spec': request_spec,
'config_options': config_options,
request_spec,
{})
+ def test_create_volume_no_volume_type(self):
+ sched = fakes.FakeFilterScheduler()
+
+ fake_context = context.RequestContext('user', 'project')
+
+ # request_spec is missing 'volume_type'
+ request_spec = {'volume_properties': {'project_id': 1,
+ 'size': 1},
+ 'volume_id': ['fake-id1']}
+ self.assertRaises(exception.InvalidVolumeType,
+ sched.schedule_create_volume,
+ fake_context,
+ request_spec,
+ {})
+
@mock.patch('cinder.scheduler.host_manager.HostManager.'
'get_all_host_states')
def test_create_volume_non_admin(self, _mock_get_all_host_states):