diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-06-10 20:49:51 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-06-10 20:49:51 +0000 |
| commit | c3a12e6eafc4563ef44101629f1f4363c9cefdab (patch) | |
| tree | f9266c3d168adcd2c4d9504993d8b5cfdbd24e6f | |
| parent | c952a8cb1bb775aef5eb6fd10aad81cdd445d01b (diff) | |
| parent | a1f430d30149637e07a288c70b40edd57600f8b8 (diff) | |
Merge " Fixes bug lp:999928"
| -rw-r--r-- | nova/compute/manager.py | 1 | ||||
| -rw-r--r-- | nova/scheduler/filters/affinity_filter.py | 7 | ||||
| -rw-r--r-- | nova/tests/scheduler/test_host_filters.py | 10 |
3 files changed, 9 insertions, 9 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 522cb77cc..e13d46cce 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -2385,6 +2385,7 @@ class ComputeManager(manager.SchedulerDependentManager): # This will grab info about the host and queue it # to be sent to the Schedulers. capabilities = _get_additional_capabilities() + capabilities['host_ip'] = FLAGS.my_ip capabilities.update(self.driver.get_host_stats(refresh=True)) self.update_service_capabilities(capabilities) diff --git a/nova/scheduler/filters/affinity_filter.py b/nova/scheduler/filters/affinity_filter.py index e774d7e17..b4e1a3034 100644 --- a/nova/scheduler/filters/affinity_filter.py +++ b/nova/scheduler/filters/affinity_filter.py @@ -40,8 +40,7 @@ class DifferentHostFilter(AffinityFilter): affinity_uuids = scheduler_hints.get('different_host', []) if affinity_uuids: - return not any([i for i - in affinity_uuids + return not any([i for i in affinity_uuids if self._affinity_host(context, i) == me]) # With no different_host key return True @@ -72,10 +71,12 @@ class SimpleCIDRAffinityFilter(AffinityFilter): affinity_cidr = scheduler_hints.get('cidr', '/24') affinity_host_addr = scheduler_hints.get('build_near_host_ip') + host_ip = host_state.capabilities.get('host_ip') if affinity_host_addr: affinity_net = netaddr.IPNetwork(str.join('', (affinity_host_addr, affinity_cidr))) - return netaddr.IPAddress(flags.FLAGS.my_ip) in affinity_net + + return netaddr.IPAddress(host_ip) in affinity_net # We don't have an affinity host address. return True diff --git a/nova/tests/scheduler/test_host_filters.py b/nova/tests/scheduler/test_host_filters.py index 59e424fed..60f3577ac 100644 --- a/nova/tests/scheduler/test_host_filters.py +++ b/nova/tests/scheduler/test_host_filters.py @@ -190,10 +190,9 @@ class HostFiltersTestCase(test.TestCase): def test_affinity_simple_cidr_filter_passes(self): filt_cls = self.class_map['SimpleCIDRAffinityFilter']() host = fakes.FakeHostState('host1', 'compute', {}) + host.capabilities = {'host_ip': '10.8.1.1'} - affinity_ip = flags.FLAGS.my_ip.split('.')[0:3] - affinity_ip.append('100') - affinity_ip = str.join('.', affinity_ip) + affinity_ip = "10.8.1.100" filter_properties = {'context': self.context.elevated(), 'scheduler_hints': { @@ -205,10 +204,9 @@ class HostFiltersTestCase(test.TestCase): def test_affinity_simple_cidr_filter_fails(self): filt_cls = self.class_map['SimpleCIDRAffinityFilter']() host = fakes.FakeHostState('host1', 'compute', {}) + host.capabilities = {'host_ip': '10.8.1.1'} - affinity_ip = flags.FLAGS.my_ip.split('.') - affinity_ip[-1] = '100' if affinity_ip[-1] != '100' else '101' - affinity_ip = str.join('.', affinity_ip) + affinity_ip = "10.8.1.100" filter_properties = {'context': self.context.elevated(), 'scheduler_hints': { |
