Edited the host filter test case for extra specs

This commit is contained in:
Lorin Hochstein
2011-06-24 10:52:59 -04:00
parent a73ab1390d
commit 26cc4e4fd0
2 changed files with 16 additions and 4 deletions

View File

@@ -103,7 +103,7 @@ class InstanceTypeFilter(HostFilter):
# Note(lorinh): For now, we are just checking exact matching on the
# values. Later on, we want to handle numerical
# values so we can represent things like number of GPU cards
try:
for key, value in instance_type['extra_specs'].iteritems():
if capabilities[key] != value:
@@ -128,7 +128,7 @@ class InstanceTypeFilter(HostFilter):
if host_ram_mb >= spec_ram and \
disk_bytes >= spec_disk and \
self._satisfies_extra_specs(capabilities, instance_type):
selected_hosts.append((host, capabilities))
selected_hosts.append((host, capabilities))
return selected_hosts
#host entries (currently) are like:

View File

@@ -77,14 +77,26 @@ class HostFilterTestCase(test.TestCase):
swap=500,
rxtx_quota=30000,
rxtx_cap=200,
extra_specs={'gpu': 'nvidia'})
extra_specs={'xpu_arch': 'fermi',
'xpu_info': 'Tesla 2050'})
self.zone_manager = FakeZoneManager()
states = {}
for x in xrange(10):
states['host%02d' % (x + 1)] = {'compute': self._host_caps(x)}
self.zone_manager.service_states = states
self.zone_manager.service_states['host07']['compute']['gpu'] = 'nvidia'
# Add some extra capabilities to some hosts
host07 = self.zone_manager.service_states['host07']['compute']
host07['xpu_arch'] = 'fermi'
host07['xpu_info'] = 'Tesla 2050'
host08 = self.zone_manager.service_states['host08']['compute']
host08['xpu_arch'] = 'radeon'
host09 = self.zone_manager.service_states['host09']['compute']
host09['xpu_arch'] = 'fermi'
host09['xpu_info'] = 'Tesla 2150'
def tearDown(self):
FLAGS.default_host_filter = self.old_flag