summaryrefslogtreecommitdiff
path: root/nova/availability_zones.py
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2014-02-02 08:08:40 +0000
committerGerrit Code Review <review@openstack.org>2014-02-02 08:08:40 +0000
commit5315399d568f882dc5ca5c74c625d0ae0f41fa7b (patch)
treeaff71519a3d3c8f43e6ecb48fe42c606511df869 /nova/availability_zones.py
parent85c16a19e38f813fed2e94ad27a21fe15dd47dde (diff)
parentdb0831ec96a6806035c51d94ade1e51eafb42162 (diff)
downloadnova-5315399d568f882dc5ca5c74c625d0ae0f41fa7b.tar.gz
Merge "Fixing availability-zone not take effect error"
Diffstat (limited to 'nova/availability_zones.py')
-rw-r--r--nova/availability_zones.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/nova/availability_zones.py b/nova/availability_zones.py
index b0c81eaaed..19756210c1 100644
--- a/nova/availability_zones.py
+++ b/nova/availability_zones.py
@@ -74,10 +74,8 @@ def set_availability_zones(context, services):
else:
az = CONF.default_availability_zone
# update the cache
- cache = _get_cache()
- cache_key = _make_cache_key(service['host'])
- cache.delete(cache_key)
- cache.set(cache_key, az, AZ_CACHE_SECONDS)
+ update_host_availability_zone_cache(context,
+ service['host'], az)
service['availability_zone'] = az
return services
@@ -96,6 +94,15 @@ def get_host_availability_zone(context, host, conductor_api=None):
return az
+def update_host_availability_zone_cache(context, host, availability_zone=None):
+ if not availability_zone:
+ availability_zone = get_host_availability_zone(context, host)
+ cache = _get_cache()
+ cache_key = _make_cache_key(host)
+ cache.delete(cache_key)
+ cache.set(cache_key, availability_zone, AZ_CACHE_SECONDS)
+
+
def get_availability_zones(context, get_only_available=False):
"""Return available and unavailable zones on demand.