diff options
| author | Joe Gordon <jogo@cloudscaling.com> | 2012-12-20 03:13:01 +0000 |
|---|---|---|
| committer | Joe Gordon <jogo@cloudscaling.com> | 2013-01-08 14:01:30 -0800 |
| commit | 1ab2fc6477c402e29a95fbc93fe4a67950c083df (patch) | |
| tree | ed42c15787905fe9e42ca3058bc8db3737d2fcbb /nova/api | |
| parent | 9f4534ab584faeee1e24d4c1bb38a2b194f24626 (diff) | |
| download | nova-1ab2fc6477c402e29a95fbc93fe4a67950c083df.tar.gz nova-1ab2fc6477c402e29a95fbc93fe4a67950c083df.tar.xz nova-1ab2fc6477c402e29a95fbc93fe4a67950c083df.zip | |
Remove availability_zones from service table
This is the final step in enabling availability_zones using aggregate
metadata. Previously all services had an availability_zone, but the
availability_zone is only used for nova-compute. Services such as
nova-scheduler, nova-network, nova-conductor have always spanned all
availability_zones.
After this change only compute nodes (nova-compute), will have an
availability_zone. In order to preserve current APIs, when running:
* nova host-list (os-hosts)
* euca-describe-availability-zones verbose
* nova-manage service list
Internal services will appear in there own internal availability_zone
(CONF.internal_service_availability_zone)
Internal zone is hidden in euca-describe-availability_zones
(non-verbose)
CONF.node_availability_zone has been renamed to
CONF.default_availability_zone and is only used by the nova-api and
nova-scheduler. CONF.node_availability_zone still works but is
deprecated
DocImpact
Completes blueprint aggregate-based-availability-zones
Change-Id: Ib772df5f9ac2865f20df479f8ddce575a9ce3aff
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/ec2/cloud.py | 43 | ||||
| -rw-r--r-- | nova/api/ec2/ec2utils.py | 3 | ||||
| -rw-r--r-- | nova/api/openstack/compute/contrib/hosts.py | 2 |
3 files changed, 25 insertions, 23 deletions
diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index 208574903..a7162a101 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -28,6 +28,7 @@ import time from nova.api.ec2 import ec2utils from nova.api.ec2 import inst_state from nova.api import validator +from nova import availability_zones from nova import block_device from nova import compute from nova.compute import api as compute_api @@ -72,6 +73,8 @@ CONF.register_opts(ec2_opts) CONF.import_opt('my_ip', 'nova.config') CONF.import_opt('vpn_image_id', 'nova.config') CONF.import_opt('vpn_key_suffix', 'nova.config') +CONF.import_opt('internal_service_availability_zone', + 'nova.availability_zones') LOG = logging.getLogger(__name__) @@ -250,6 +253,10 @@ class CloudController(object): """Return available and unavailable zones.""" enabled_services = db.service_get_all(context, False) disabled_services = db.service_get_all(context, True) + enabled_services = availability_zones.set_availability_zones(context, + enabled_services) + disabled_services = availability_zones.set_availability_zones(context, + disabled_services) available_zones = [] for zone in [service['availability_zone'] for service @@ -257,17 +264,11 @@ class CloudController(object): if not zone in available_zones: available_zones.append(zone) - # aggregate based availability_zones - metadata = db.aggregate_host_get_by_metadata_key(context, - key='availability_zone') - for zone_set in metadata.values(): - for zone in zone_set: - if zone not in available_zones: - available_zones.append(zone) not_available_zones = [] - for zone in [service.availability_zone for service in disabled_services - if not service['availability_zone'] in available_zones]: - if not zone in not_available_zones: + zones = [service['available_zones'] for service in disabled_services + if service['available_zones'] not in available_zones] + for zone in zones: + if zone not in not_available_zones: not_available_zones.append(zone) return (available_zones, not_available_zones) @@ -277,6 +278,9 @@ class CloudController(object): result = [] for zone in available_zones: + # Hide internal_service_availability_zone + if zone == CONF.internal_service_availability_zone: + continue result.append({'zoneName': zone, 'zoneState': "available"}) for zone in not_available_zones: @@ -290,6 +294,8 @@ class CloudController(object): # Available services enabled_services = db.service_get_all(context, False) + enabled_services = availability_zones.set_availability_zones(context, + enabled_services) zone_hosts = {} host_services = {} for service in enabled_services: @@ -298,17 +304,10 @@ class CloudController(object): zone_hosts[service['availability_zone']].append( service['host']) - host_services.setdefault(service['host'], []) - host_services[service['host']].append(service) - # aggregate based available_zones - metadata = db.aggregate_host_get_by_metadata_key(context, - key='availability_zone') - # metdata: {machine: set( az1, az2 )} - for host, zones in metadata.items(): - for zone in zones: - zone_hosts.setdefault(zone, []) - if host not in zone_hosts[zone]: - zone_hosts[zone].append(host) + host_services.setdefault(service['availability_zone'] + + service['host'], []) + host_services[service['availability_zone'] + service['host']].\ + append(service) result = [] for zone in available_zones: @@ -318,7 +317,7 @@ class CloudController(object): result.append({'zoneName': '|- %s' % host, 'zoneState': ''}) - for service in host_services[host]: + for service in host_services[zone + host]: alive = self.servicegroup_api.service_is_up(service) art = (alive and ":-)") or "XXX" active = 'enabled' diff --git a/nova/api/ec2/ec2utils.py b/nova/api/ec2/ec2utils.py index 1c2ceea6f..f86642ff6 100644 --- a/nova/api/ec2/ec2utils.py +++ b/nova/api/ec2/ec2utils.py @@ -18,6 +18,7 @@ import re +from nova import availability_zones from nova import context from nova import db from nova import exception @@ -116,7 +117,7 @@ def get_ip_info_for_instance(context, instance): def get_availability_zone_by_host(services, host): if len(services) > 0: - return services[0]['availability_zone'] + return availability_zones.get_host_availability_zone(context, host) return 'unknown zone' diff --git a/nova/api/openstack/compute/contrib/hosts.py b/nova/api/openstack/compute/contrib/hosts.py index 7da596a78..2401147f4 100644 --- a/nova/api/openstack/compute/contrib/hosts.py +++ b/nova/api/openstack/compute/contrib/hosts.py @@ -22,6 +22,7 @@ from xml.parsers import expat from nova.api.openstack import extensions from nova.api.openstack import wsgi from nova.api.openstack import xmlutil +from nova import availability_zones from nova.compute import api as compute_api from nova import db from nova import exception @@ -99,6 +100,7 @@ def _list_hosts(req): """ context = req.environ['nova.context'] services = db.service_get_all(context, False) + services = availability_zones.set_availability_zones(context, services) zone = '' if 'zone' in req.GET: zone = req.GET['zone'] |
