Merge "Remove unused conductor parameter from get_host_availability_zone()"
This commit is contained in:
@@ -75,14 +75,6 @@ def _build_metadata_by_host(aggregates, hosts=None):
|
|||||||
return metadata
|
return metadata
|
||||||
|
|
||||||
|
|
||||||
def _build_metadata_by_key(aggregates):
|
|
||||||
metadata = collections.defaultdict(set)
|
|
||||||
for aggregate in aggregates:
|
|
||||||
for key, value in aggregate.metadata.iteritems():
|
|
||||||
metadata[key].add(value)
|
|
||||||
return metadata
|
|
||||||
|
|
||||||
|
|
||||||
def set_availability_zones(context, services):
|
def set_availability_zones(context, services):
|
||||||
# Makes sure services isn't a sqlalchemy object
|
# Makes sure services isn't a sqlalchemy object
|
||||||
services = [dict(service.iteritems()) for service in services]
|
services = [dict(service.iteritems()) for service in services]
|
||||||
@@ -105,16 +97,11 @@ def set_availability_zones(context, services):
|
|||||||
return services
|
return services
|
||||||
|
|
||||||
|
|
||||||
def get_host_availability_zone(context, host, conductor_api=None):
|
def get_host_availability_zone(context, host):
|
||||||
if conductor_api:
|
aggregates = objects.AggregateList.get_by_host(context, host,
|
||||||
metadata = conductor_api.aggregate_metadata_get_by_host(
|
key='availability_zone')
|
||||||
context, host, key='availability_zone')
|
if aggregates:
|
||||||
else:
|
az = aggregates[0].metadata['availability_zone']
|
||||||
aggregates = objects.AggregateList.get_by_host(context, host,
|
|
||||||
key='availability_zone')
|
|
||||||
metadata = _build_metadata_by_key(aggregates)
|
|
||||||
if 'availability_zone' in metadata:
|
|
||||||
az = list(metadata['availability_zone'])[0]
|
|
||||||
else:
|
else:
|
||||||
az = CONF.default_availability_zone
|
az = CONF.default_availability_zone
|
||||||
return az
|
return az
|
||||||
|
|||||||
Reference in New Issue
Block a user