Merge "Make host_aggregate_map dictionary case-insensitive"
This commit is contained in:
commit
d07694b28c
@ -375,7 +375,7 @@ class HostManager(object):
|
|||||||
for agg in aggs:
|
for agg in aggs:
|
||||||
self.aggs_by_id[agg.id] = agg
|
self.aggs_by_id[agg.id] = agg
|
||||||
for host in agg.hosts:
|
for host in agg.hosts:
|
||||||
self.host_aggregates_map[host].add(agg.id)
|
self.host_aggregates_map[host.lower()].add(agg.id)
|
||||||
|
|
||||||
def update_aggregates(self, aggregates):
|
def update_aggregates(self, aggregates):
|
||||||
"""Updates internal HostManager information about aggregates."""
|
"""Updates internal HostManager information about aggregates."""
|
||||||
@ -394,7 +394,7 @@ class HostManager(object):
|
|||||||
for host in self.host_aggregates_map:
|
for host in self.host_aggregates_map:
|
||||||
if (aggregate.id in self.host_aggregates_map[host]
|
if (aggregate.id in self.host_aggregates_map[host]
|
||||||
and host not in aggregate.hosts):
|
and host not in aggregate.hosts):
|
||||||
self.host_aggregates_map[host].remove(aggregate.id)
|
self.host_aggregates_map[host.lower()].remove(aggregate.id)
|
||||||
|
|
||||||
def delete_aggregate(self, aggregate):
|
def delete_aggregate(self, aggregate):
|
||||||
"""Deletes internal HostManager information about a specific aggregate.
|
"""Deletes internal HostManager information about a specific aggregate.
|
||||||
@ -740,7 +740,7 @@ class HostManager(object):
|
|||||||
|
|
||||||
def _get_aggregates_info(self, host):
|
def _get_aggregates_info(self, host):
|
||||||
return [self.aggs_by_id[agg_id] for agg_id in
|
return [self.aggs_by_id[agg_id] for agg_id in
|
||||||
self.host_aggregates_map[host]]
|
self.host_aggregates_map[host.lower()]]
|
||||||
|
|
||||||
def _get_instances_by_host(self, context, host_name):
|
def _get_instances_by_host(self, context, host_name):
|
||||||
try:
|
try:
|
||||||
|
@ -224,6 +224,17 @@ class HostManagerTestCase(test.NoDBTestCase):
|
|||||||
self.assertEqual({'fake-host': set([1])},
|
self.assertEqual({'fake-host': set([1])},
|
||||||
self.host_manager.host_aggregates_map)
|
self.host_manager.host_aggregates_map)
|
||||||
|
|
||||||
|
@mock.patch.object(host_manager.HostManager, '_init_instance_info')
|
||||||
|
@mock.patch.object(objects.AggregateList, 'get_all')
|
||||||
|
def test_init_aggregates_one_agg_with_hosts_upper_case(self, agg_get_all,
|
||||||
|
mock_init_info):
|
||||||
|
fake_agg = objects.Aggregate(id=1, hosts=['FAKE-host'])
|
||||||
|
agg_get_all.return_value = [fake_agg]
|
||||||
|
self.host_manager = host_manager.HostManager()
|
||||||
|
self.assertEqual({1: fake_agg}, self.host_manager.aggs_by_id)
|
||||||
|
self.assertEqual({'fake-host': set([1])},
|
||||||
|
self.host_manager.host_aggregates_map)
|
||||||
|
|
||||||
def test_update_aggregates(self):
|
def test_update_aggregates(self):
|
||||||
fake_agg = objects.Aggregate(id=1, hosts=['fake-host'])
|
fake_agg = objects.Aggregate(id=1, hosts=['fake-host'])
|
||||||
self.host_manager.update_aggregates([fake_agg])
|
self.host_manager.update_aggregates([fake_agg])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user