Edited the host filter test case for extra specs
This commit is contained in:
@@ -103,7 +103,7 @@ class InstanceTypeFilter(HostFilter):
|
|||||||
# Note(lorinh): For now, we are just checking exact matching on the
|
# Note(lorinh): For now, we are just checking exact matching on the
|
||||||
# values. Later on, we want to handle numerical
|
# values. Later on, we want to handle numerical
|
||||||
# values so we can represent things like number of GPU cards
|
# values so we can represent things like number of GPU cards
|
||||||
|
|
||||||
try:
|
try:
|
||||||
for key, value in instance_type['extra_specs'].iteritems():
|
for key, value in instance_type['extra_specs'].iteritems():
|
||||||
if capabilities[key] != value:
|
if capabilities[key] != value:
|
||||||
@@ -128,7 +128,7 @@ class InstanceTypeFilter(HostFilter):
|
|||||||
if host_ram_mb >= spec_ram and \
|
if host_ram_mb >= spec_ram and \
|
||||||
disk_bytes >= spec_disk and \
|
disk_bytes >= spec_disk and \
|
||||||
self._satisfies_extra_specs(capabilities, instance_type):
|
self._satisfies_extra_specs(capabilities, instance_type):
|
||||||
selected_hosts.append((host, capabilities))
|
selected_hosts.append((host, capabilities))
|
||||||
return selected_hosts
|
return selected_hosts
|
||||||
|
|
||||||
#host entries (currently) are like:
|
#host entries (currently) are like:
|
||||||
|
|||||||
@@ -77,14 +77,26 @@ class HostFilterTestCase(test.TestCase):
|
|||||||
swap=500,
|
swap=500,
|
||||||
rxtx_quota=30000,
|
rxtx_quota=30000,
|
||||||
rxtx_cap=200,
|
rxtx_cap=200,
|
||||||
extra_specs={'gpu': 'nvidia'})
|
extra_specs={'xpu_arch': 'fermi',
|
||||||
|
'xpu_info': 'Tesla 2050'})
|
||||||
|
|
||||||
self.zone_manager = FakeZoneManager()
|
self.zone_manager = FakeZoneManager()
|
||||||
states = {}
|
states = {}
|
||||||
for x in xrange(10):
|
for x in xrange(10):
|
||||||
states['host%02d' % (x + 1)] = {'compute': self._host_caps(x)}
|
states['host%02d' % (x + 1)] = {'compute': self._host_caps(x)}
|
||||||
self.zone_manager.service_states = states
|
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):
|
def tearDown(self):
|
||||||
FLAGS.default_host_filter = self.old_flag
|
FLAGS.default_host_filter = self.old_flag
|
||||||
|
|||||||
Reference in New Issue
Block a user