Dealing with cases where extra_specs wasn't defined

This commit is contained in:
Lorin Hochstein
2011-06-24 01:44:22 -04:00
parent 101c2b0a9c
commit 2ee0bad326
2 changed files with 6 additions and 1 deletions

View File

@@ -97,9 +97,13 @@ class InstanceTypeFilter(HostFilter):
"""Check that the capabilities provided by the compute service """Check that the capabilities provided by the compute service
satisfy the extra specs associated with the instance type""" satisfy the extra specs associated with the instance type"""
if 'extra_specs' not in instance_type:
return True
# 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:

View File

@@ -67,7 +67,8 @@ class HostFilterTestCase(test.TestCase):
flavorid=1, flavorid=1,
swap=500, swap=500,
rxtx_quota=30000, rxtx_quota=30000,
rxtx_cap=200) rxtx_cap=200,
extra_specs={})
self.zone_manager = FakeZoneManager() self.zone_manager = FakeZoneManager()
states = {} states = {}