Revert "Make compute_capabilities_filter use ..."
This reverts commit a4ad62ac9fdacecfbc5229e688a7d937d177889b. Nova baremetal architecture scheduling was broken by it. While workarounds exist it is backwards incompatible, and baremetal is supported since Grizzly. Fix bug: 1213967 Change-Id: I319b8a17f3ae7a3b527d388c6ff2954c0bcc0108
This commit is contained in:
		| @@ -28,8 +28,8 @@ class ComputeCapabilitiesFilter(filters.BaseHostFilter): | |||||||
|     # Instance type and host capabilities do not change within a request |     # Instance type and host capabilities do not change within a request | ||||||
|     run_filter_once_per_request = True |     run_filter_once_per_request = True | ||||||
|  |  | ||||||
|     def _satisfies_extra_specs(self, host_state, instance_type): |     def _satisfies_extra_specs(self, capabilities, instance_type): | ||||||
|         """Check that the host_state 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: |         if 'extra_specs' not in instance_type: | ||||||
| @@ -43,13 +43,10 @@ class ComputeCapabilitiesFilter(filters.BaseHostFilter): | |||||||
|                     continue |                     continue | ||||||
|                 else: |                 else: | ||||||
|                     del scope[0] |                     del scope[0] | ||||||
|             cap = host_state |             cap = capabilities | ||||||
|             for index in range(0, len(scope)): |             for index in range(0, len(scope)): | ||||||
|                 try: |                 try: | ||||||
|                     if type(cap) != dict: |                     cap = cap.get(scope[index], None) | ||||||
|                         cap = getattr(cap, scope[index], None) |  | ||||||
|                     else: |  | ||||||
|                         cap = cap.get(scope[index], None) |  | ||||||
|                 except AttributeError: |                 except AttributeError: | ||||||
|                     return False |                     return False | ||||||
|                 if cap is None: |                 if cap is None: | ||||||
| @@ -61,7 +58,7 @@ class ComputeCapabilitiesFilter(filters.BaseHostFilter): | |||||||
|     def host_passes(self, host_state, filter_properties): |     def host_passes(self, host_state, filter_properties): | ||||||
|         """Return a list of hosts that can create instance_type.""" |         """Return a list of hosts that can create instance_type.""" | ||||||
|         instance_type = filter_properties.get('instance_type') |         instance_type = filter_properties.get('instance_type') | ||||||
|         if not self._satisfies_extra_specs(host_state, |         if not self._satisfies_extra_specs(host_state.capabilities, | ||||||
|                 instance_type): |                 instance_type): | ||||||
|             LOG.debug(_("%(host_state)s fails instance_type extra_specs " |             LOG.debug(_("%(host_state)s fails instance_type extra_specs " | ||||||
|                     "requirements"), {'host_state': host_state}) |                     "requirements"), {'host_state': host_state}) | ||||||
|   | |||||||
| @@ -26,7 +26,6 @@ from nova.compute import vm_states | |||||||
| from nova import db | from nova import db | ||||||
| from nova import exception | from nova import exception | ||||||
| from nova.openstack.common.gettextutils import _ | from nova.openstack.common.gettextutils import _ | ||||||
| from nova.openstack.common import jsonutils |  | ||||||
| from nova.openstack.common import log as logging | from nova.openstack.common import log as logging | ||||||
| from nova.openstack.common import timeutils | from nova.openstack.common import timeutils | ||||||
| from nova.scheduler import filters | from nova.scheduler import filters | ||||||
| @@ -123,11 +122,6 @@ class HostState(object): | |||||||
|  |  | ||||||
|         # Other information |         # Other information | ||||||
|         self.host_ip = None |         self.host_ip = None | ||||||
|         self.hypervisor_type = None |  | ||||||
|         self.hypervisor_version = None |  | ||||||
|         self.hypervisor_hostname = None |  | ||||||
|         self.cpu_info = None |  | ||||||
|         self.supported_instances = None |  | ||||||
|  |  | ||||||
|         # Resource oversubscription values for the compute host: |         # Resource oversubscription values for the compute host: | ||||||
|         self.limits = {} |         self.limits = {} | ||||||
| @@ -167,15 +161,7 @@ class HostState(object): | |||||||
|         self.vcpus_used = compute['vcpus_used'] |         self.vcpus_used = compute['vcpus_used'] | ||||||
|         self.updated = compute['updated_at'] |         self.updated = compute['updated_at'] | ||||||
|  |  | ||||||
|         # All virt drivers report host_ip |  | ||||||
|         self.host_ip = compute['host_ip'] |         self.host_ip = compute['host_ip'] | ||||||
|         self.hypervisor_type = compute.get('hypervisor_type') |  | ||||||
|         self.hypervisor_version = compute.get('hypervisor_version') |  | ||||||
|         self.hypervisor_hostname = compute.get('hypervisor_hostname') |  | ||||||
|         self.cpu_info = compute.get('cpu_info') |  | ||||||
|         if compute.get('supported_instances'): |  | ||||||
|             self.supported_instances = jsonutils.loads( |  | ||||||
|                     compute.get('supported_instances')) |  | ||||||
|  |  | ||||||
|         stats = compute.get('stats', []) |         stats = compute.get('stats', []) | ||||||
|         statmap = self._statmap(stats) |         statmap = self._statmap(stats) | ||||||
|   | |||||||
| @@ -770,9 +770,9 @@ class HostFiltersTestCase(test.NoDBTestCase): | |||||||
|         service = {'disabled': False} |         service = {'disabled': False} | ||||||
|         filter_properties = {'instance_type': {'memory_mb': 1024, |         filter_properties = {'instance_type': {'memory_mb': 1024, | ||||||
|                                                'extra_specs': especs}} |                                                'extra_specs': especs}} | ||||||
|         host_state = {'free_ram_mb': 1024, 'service': service} |         host = fakes.FakeHostState('host1', 'node1', | ||||||
|         host_state.update(capabilities) |                 {'free_ram_mb': 1024, 'capabilities': capabilities, | ||||||
|         host = fakes.FakeHostState('host1', 'node1', host_state) |                  'service': service}) | ||||||
|         assertion = self.assertTrue if passes else self.assertFalse |         assertion = self.assertTrue if passes else self.assertFalse | ||||||
|         assertion(filt_cls.host_passes(host, filter_properties)) |         assertion(filt_cls.host_passes(host, filter_properties)) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -435,12 +435,9 @@ class HostStateTestCase(test.NoDBTestCase): | |||||||
|             dict(key='num_os_type_windoze', value='1'), |             dict(key='num_os_type_windoze', value='1'), | ||||||
|             dict(key='io_workload', value='42'), |             dict(key='io_workload', value='42'), | ||||||
|         ] |         ] | ||||||
|         compute = dict(stats=stats, memory_mb=1, free_disk_gb=0, local_gb=0, |         compute = dict(stats=stats, memory_mb=0, free_disk_gb=0, local_gb=0, | ||||||
|                        local_gb_used=0, free_ram_mb=0, vcpus=0, vcpus_used=0, |                        local_gb_used=0, free_ram_mb=0, vcpus=0, vcpus_used=0, | ||||||
|                        updated_at=None, host_ip='127.0.0.1', |                        updated_at=None, host_ip='127.0.0.1') | ||||||
|                        hypervisor_type='htype', hypervisor_version='1.1', |  | ||||||
|                        hypervisor_hostname='hostname', cpu_info='cpu_info', |  | ||||||
|                        supported_instances='{}') |  | ||||||
|  |  | ||||||
|         host = host_manager.HostState("fakehost", "fakenode") |         host = host_manager.HostState("fakehost", "fakenode") | ||||||
|         host.update_from_compute_node(compute) |         host.update_from_compute_node(compute) | ||||||
| @@ -456,13 +453,6 @@ class HostStateTestCase(test.NoDBTestCase): | |||||||
|         self.assertEqual(1, host.num_instances_by_os_type['windoze']) |         self.assertEqual(1, host.num_instances_by_os_type['windoze']) | ||||||
|         self.assertEqual(42, host.num_io_ops) |         self.assertEqual(42, host.num_io_ops) | ||||||
|  |  | ||||||
|         self.assertEqual('127.0.0.1', host.host_ip) |  | ||||||
|         self.assertEqual('htype', host.hypervisor_type) |  | ||||||
|         self.assertEqual('1.1', host.hypervisor_version) |  | ||||||
|         self.assertEqual('hostname', host.hypervisor_hostname) |  | ||||||
|         self.assertEqual('cpu_info', host.cpu_info) |  | ||||||
|         self.assertEqual({}, host.supported_instances) |  | ||||||
|  |  | ||||||
|     def test_stat_consumption_from_instance(self): |     def test_stat_consumption_from_instance(self): | ||||||
|         host = host_manager.HostState("fakehost", "fakenode") |         host = host_manager.HostState("fakehost", "fakenode") | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Robert Collins
					Robert Collins