Merge "DriverFilter: don't check volume_backend_name"

This commit is contained in:
Jenkins 2015-06-05 03:00:12 +00:00 committed by Gerrit Code Review
commit feef4309bb
2 changed files with 58 additions and 149 deletions

View File

@ -48,23 +48,8 @@ class DriverFilter(filters.BaseHostFilter):
Returns a tuple in the format (filter_passing, filter_invalid).
Both values are booleans.
"""
host_stats = stats['host_stats']
extra_specs = stats['extra_specs']
# Check that the volume types match
if (extra_specs is None or 'volume_backend_name' not in extra_specs):
LOG.warning(_LW("No 'volume_backend_name' key in extra_specs. "
"Skipping volume backend name check."))
elif (extra_specs['volume_backend_name'] !=
host_stats['volume_backend_name']):
LOG.warning(_LW("Volume backend names do not match: '%(target)s' "
"vs '%(current)s' :: Skipping"),
{'target': extra_specs['volume_backend_name'],
'current': host_stats['volume_backend_name']})
return False
if stats['filter_function'] is None:
LOG.warning(_LW("Filter function not set :: passing host"))
LOG.debug("Filter function not set :: passing host")
return True
try:

View File

@ -627,85 +627,6 @@ class DriverFilterTestCase(HostFiltersTestCase):
filt_cls = self.class_map['DriverFilter']()
host1 = fakes.FakeHostState(
'host1', {
'volume_backend_name': 'fake',
'capabilities': {
'filter_function': '1 == 1',
}
})
filter_properties = {
'volume_type': {
'extra_specs': {
'volume_backend_name': 'fake',
}
}
}
self.assertTrue(filt_cls.host_passes(host1, filter_properties))
def test_failing_function(self):
filt_cls = self.class_map['DriverFilter']()
host1 = fakes.FakeHostState(
'host1', {
'volume_backend_name': 'fake',
'capabilities': {
'filter_function': '1 == 2',
}
})
filter_properties = {
'volume_type': {
'extra_specs': {
'volume_backend_name': 'fake',
}
}
}
self.assertFalse(filt_cls.host_passes(host1, filter_properties))
def test_no_filter_function(self):
filt_cls = self.class_map['DriverFilter']()
host1 = fakes.FakeHostState(
'host1', {
'volume_backend_name': 'fake',
'capabilities': {
'filter_function': None,
}
})
filter_properties = {
'volume_type': {
'extra_specs': {
'volume_backend_name': 'fake',
}
}
}
self.assertTrue(filt_cls.host_passes(host1, filter_properties))
def test_not_implemented(self):
filt_cls = self.class_map['DriverFilter']()
host1 = fakes.FakeHostState(
'host1', {
'volume_backend_name': 'fake',
'capabilities': {}
})
filter_properties = {
'volume_type': {
'extra_specs': {
'volume_backend_name': 'fake',
}
}
}
self.assertTrue(filt_cls.host_passes(host1, filter_properties))
def test_no_volume_extra_specs(self):
filt_cls = self.class_map['DriverFilter']()
host1 = fakes.FakeHostState(
'host1', {
'volume_backend_name': 'fake',
'capabilities': {
'filter_function': '1 == 1',
}
@ -715,31 +636,60 @@ class DriverFilterTestCase(HostFiltersTestCase):
self.assertTrue(filt_cls.host_passes(host1, filter_properties))
def test_volume_backend_name_different(self):
def test_failing_function(self):
filt_cls = self.class_map['DriverFilter']()
host1 = fakes.FakeHostState(
'host1', {
'capabilities': {
'filter_function': '1 == 2',
}
})
filter_properties = {'volume_type': {}}
self.assertFalse(filt_cls.host_passes(host1, filter_properties))
def test_no_filter_function(self):
filt_cls = self.class_map['DriverFilter']()
host1 = fakes.FakeHostState(
'host1', {
'capabilities': {
'filter_function': None,
}
})
filter_properties = {'volume_type': {}}
self.assertTrue(filt_cls.host_passes(host1, filter_properties))
def test_not_implemented(self):
filt_cls = self.class_map['DriverFilter']()
host1 = fakes.FakeHostState(
'host1', {
'capabilities': {}
})
filter_properties = {'volume_type': {}}
self.assertTrue(filt_cls.host_passes(host1, filter_properties))
def test_no_volume_extra_specs(self):
filt_cls = self.class_map['DriverFilter']()
host1 = fakes.FakeHostState(
'host1', {
'volume_backend_name': 'fake',
'capabilities': {
'filter_function': '1 == 1',
}
})
filter_properties = {
'volume_type': {
'extra_specs': {
'volume_backend_name': 'fake2',
}
}
}
filter_properties = {'volume_type': {}}
self.assertFalse(filt_cls.host_passes(host1, filter_properties))
self.assertTrue(filt_cls.host_passes(host1, filter_properties))
def test_function_extra_spec_replacement(self):
filt_cls = self.class_map['DriverFilter']()
host1 = fakes.FakeHostState(
'host1', {
'volume_backend_name': 'fake',
'capabilities': {
'filter_function': 'extra.var == 1',
}
@ -748,7 +698,6 @@ class DriverFilterTestCase(HostFiltersTestCase):
filter_properties = {
'volume_type': {
'extra_specs': {
'volume_backend_name': 'fake',
'var': 1,
}
}
@ -760,20 +709,13 @@ class DriverFilterTestCase(HostFiltersTestCase):
filt_cls = self.class_map['DriverFilter']()
host1 = fakes.FakeHostState(
'host1', {
'volume_backend_name': 'fake',
'total_capacity_gb': 100,
'capabilities': {
'filter_function': 'stats.total_capacity_gb < 200',
}
})
filter_properties = {
'volume_type': {
'extra_specs': {
'volume_backend_name': 'fake',
}
}
}
filter_properties = {'volume_type': {}}
self.assertTrue(filt_cls.host_passes(host1, filter_properties))
@ -781,18 +723,12 @@ class DriverFilterTestCase(HostFiltersTestCase):
filt_cls = self.class_map['DriverFilter']()
host1 = fakes.FakeHostState(
'host1', {
'volume_backend_name': 'fake',
'capabilities': {
'filter_function': 'volume.size < 5',
}
})
filter_properties = {
'volume_type': {
'extra_specs': {
'volume_backend_name': 'fake',
}
},
'request_spec': {
'volume_properties': {
'size': 1
@ -806,18 +742,12 @@ class DriverFilterTestCase(HostFiltersTestCase):
filt_cls = self.class_map['DriverFilter']()
host1 = fakes.FakeHostState(
'host1', {
'volume_backend_name': 'fake',
'capabilities': {
'filter_function': 'qos.var == 1',
}
})
filter_properties = {
'volume_type': {
'extra_specs': {
'volume_backend_name': 'fake',
}
},
'qos_specs': {
'var': 1
}
@ -829,19 +759,12 @@ class DriverFilterTestCase(HostFiltersTestCase):
filt_cls = self.class_map['DriverFilter']()
host1 = fakes.FakeHostState(
'host1', {
'volume_backend_name': 'fake',
'capabilities': {
'filter_function': '1 / 0 == 0',
}
})
filter_properties = {
'volume_type': {
'extra_specs': {
'volume_backend_name': 'fake',
}
}
}
filter_properties = {}
self.assertFalse(filt_cls.host_passes(host1, filter_properties))
@ -849,18 +772,12 @@ class DriverFilterTestCase(HostFiltersTestCase):
filt_cls = self.class_map['DriverFilter']()
host1 = fakes.FakeHostState(
'host1', {
'volume_backend_name': 'fake',
'capabilities': {
'filter_function': 'qos.maxiops == 1',
}
})
filter_properties = {
'volume_type': {
'extra_specs': {
'volume_backend_name': 'fake',
}
},
'qos_specs': None
}
@ -870,23 +787,30 @@ class DriverFilterTestCase(HostFiltersTestCase):
filt_cls = self.class_map['DriverFilter']()
host1 = fakes.FakeHostState(
'host1', {
'volume_backend_name': 'fake',
'capabilities': {
'foo': 10,
'filter_function': 'capabilities.foo == 10',
},
})
filter_properties = {
'volume_type': {
'extra_specs': {
'volume_backend_name': 'fake',
}
}
}
filter_properties = {}
self.assertTrue(filt_cls.host_passes(host1, filter_properties))
def test_wrong_capabilities(self):
filt_cls = self.class_map['DriverFilter']()
host1 = fakes.FakeHostState(
'host1', {
'capabilities': {
'bar': 10,
'filter_function': 'capabilities.foo == 10',
},
})
filter_properties = {}
self.assertFalse(filt_cls.host_passes(host1, filter_properties))
class InstanceLocalityFilterTestCase(HostFiltersTestCase):
def setUp(self):