diff options
| author | Andrew Bogott <abogott@wikimedia.org> | 2012-01-18 14:38:12 -0600 |
|---|---|---|
| committer | Andrew Bogott <abogott@wikimedia.org> | 2012-01-18 17:54:43 -0600 |
| commit | d69b64e27c63439a1880fc951066045e623c696f (patch) | |
| tree | 93b42d46a623ddf125660300efe58faa9820b573 /nova/api | |
| parent | 2ff3e0eca25a28f248e9cdc8149869003b818651 (diff) | |
Rename 'zone' to 'domain.'
This code was getting confusing because of the ambiguity
between dns zones and openstack availability zones. 'Domain'
seems a bit clearer than 'zone' in this context.
For blueprint public-and-private-dns.
Change-Id: I1d420be2e6f2054ee4392ce762775ece20a823b3
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/openstack/compute/contrib/floating_ip_dns.py | 130 |
1 files changed, 66 insertions, 64 deletions
diff --git a/nova/api/openstack/compute/contrib/floating_ip_dns.py b/nova/api/openstack/compute/contrib/floating_ip_dns.py index 99e4e4e47..a0ac9241f 100644 --- a/nova/api/openstack/compute/contrib/floating_ip_dns.py +++ b/nova/api/openstack/compute/contrib/floating_ip_dns.py @@ -33,12 +33,12 @@ def make_dns_entry(elem): elem.set('id') elem.set('ip') elem.set('type') - elem.set('zone') + elem.set('domain') elem.set('name') -def make_zone_entry(elem): - elem.set('zone') +def make_domain_entry(elem): + elem.set('domain') elem.set('scope') elem.set('project') elem.set('availability_zone') @@ -61,20 +61,20 @@ class FloatingIPDNSsTemplate(xmlutil.TemplateBuilder): return xmlutil.MasterTemplate(root, 1) -class ZoneTemplate(xmlutil.TemplateBuilder): +class DomainTemplate(xmlutil.TemplateBuilder): def construct(self): - root = xmlutil.TemplateElement('zone_entry', - selector='zone_entry') - make_zone_entry(root) + root = xmlutil.TemplateElement('domain_entry', + selector='domain_entry') + make_domain_entry(root) return xmlutil.MasterTemplate(root, 1) -class ZonesTemplate(xmlutil.TemplateBuilder): +class DomainsTemplate(xmlutil.TemplateBuilder): def construct(self): - root = xmlutil.TemplateElement('zone_entries') - elem = xmlutil.SubTemplateElement(root, 'zone_entry', - selector='zone_entries') - make_zone_entry(elem) + root = xmlutil.TemplateElement('domain_entries') + elem = xmlutil.SubTemplateElement(root, 'domain_entry', + selector='domain_entries') + make_domain_entry(elem) return xmlutil.MasterTemplate(root, 1) @@ -83,7 +83,7 @@ def _translate_dns_entry_view(dns_entry): result['ip'] = dns_entry.get('ip') result['id'] = dns_entry.get('id') result['type'] = dns_entry.get('type') - result['zone'] = dns_entry.get('zone') + result['domain'] = dns_entry.get('domain') result['name'] = dns_entry.get('name') return {'dns_entry': result} @@ -93,32 +93,33 @@ def _translate_dns_entries_view(dns_entries): for entry in dns_entries]} -def _translate_zone_entry_view(zone_entry): +def _translate_domain_entry_view(domain_entry): result = {} - result['domain'] = zone_entry.get('domain') - result['scope'] = zone_entry.get('scope') - result['project'] = zone_entry.get('project') - result['availability_zone'] = zone_entry.get('availability_zone') - return {'zone_entry': result} + result['domain'] = domain_entry.get('domain') + result['scope'] = domain_entry.get('scope') + result['project'] = domain_entry.get('project') + result['availability_zone'] = domain_entry.get('availability_zone') + return {'domain_entry': result} -def _translate_zone_entries_view(zone_entries): - return {'zone_entries': [_translate_zone_entry_view(entry)['zone_entry'] - for entry in zone_entries]} +def _translate_domain_entries_view(domain_entries): + return {'domain_entries': + [_translate_domain_entry_view(entry)['domain_entry'] + for entry in domain_entries]} -def _unquote_zone(zone): - """Unquoting function for receiving a zone name in a URL. +def _unquote_domain(domain): + """Unquoting function for receiving a domain name in a URL. - Zone names tend to have .'s in them. Urllib doesn't quote dots, + Domain names tend to have .'s in them. Urllib doesn't quote dots, but Routes tends to choke on them, so we need an extra level of by-hand quoting here. """ - return urllib.unquote(zone).replace('%2E', '.') + return urllib.unquote(domain).replace('%2E', '.') -def _create_dns_entry(ip, name, zone): - return {'ip': ip, 'name': name, 'zone': zone} +def _create_dns_entry(ip, name, domain): + return {'ip': ip, 'name': name, 'domain': domain} def _create_domain_entry(domain, scope=None, project=None, av_zone=None): @@ -133,26 +134,26 @@ class FloatingIPDNSDomainController(object): self.network_api = network.API() super(FloatingIPDNSDomainController, self).__init__() - @wsgi.serializers(xml=ZonesTemplate) + @wsgi.serializers(xml=DomainsTemplate) def index(self, req): - """Return a list of available DNS zones.""" + """Return a list of available DNS domains.""" context = req.environ['nova.context'] - zones = self.network_api.get_dns_zones(context) - zonelist = [_create_domain_entry(zone['domain'], - zone.get('scope'), - zone.get('project'), - zone.get('availability_zone')) - for zone in zones] + domains = self.network_api.get_dns_domains(context) + domainlist = [_create_domain_entry(domain['domain'], + domain.get('scope'), + domain.get('project'), + domain.get('availability_zone')) + for domain in domains] - return _translate_zone_entries_view(zonelist) + return _translate_domain_entries_view(domainlist) - @wsgi.serializers(xml=ZoneTemplate) + @wsgi.serializers(xml=DomainTemplate) def update(self, req, id, body): """Add or modify domain entry""" context = req.environ['nova.context'] - fqdomain = _unquote_zone(id) + fqdomain = _unquote_domain(id) try: - entry = body['zone_entry'] + entry = body['domain_entry'] scope = entry['scope'] except (TypeError, KeyError): raise webob.exc.HTTPUnprocessableEntity() @@ -168,14 +169,14 @@ class FloatingIPDNSDomainController(object): self.network_api.create_private_dns_domain(context, fqdomain, av_zone) - return _translate_zone_entry_view({'domain': fqdomain, + return _translate_domain_entry_view({'domain': fqdomain, 'scope': scope, 'availability_zone': av_zone}) else: self.network_api.create_public_dns_domain(context, fqdomain, project) - return _translate_zone_entry_view({'domain': fqdomain, + return _translate_domain_entry_view({'domain': fqdomain, 'scope': 'public', 'project': project}) except exception.NotAuthorized or exception.AdminRequired: @@ -185,11 +186,11 @@ class FloatingIPDNSDomainController(object): """Delete the domain identified by id. """ context = req.environ['nova.context'] params = req.str_GET - zone = _unquote_zone(id) + domain = _unquote_domain(id) # Delete the whole domain try: - self.network_api.delete_dns_domain(context, zone) + self.network_api.delete_dns_domain(context, domain) except exception.NotAuthorized or exception.AdminRequired: return webob.Response(status_int=403) except exception.NotFound: @@ -206,41 +207,41 @@ class FloatingIPDNSEntryController(object): super(FloatingIPDNSEntryController, self).__init__() @wsgi.serializers(xml=FloatingIPDNSTemplate) - def show(self, req, zone_id, id): - """Return the DNS entry that corresponds to zone_id and id.""" + def show(self, req, domain_id, id): + """Return the DNS entry that corresponds to domain_id and id.""" context = req.environ['nova.context'] - zone = _unquote_zone(zone_id) + domain = _unquote_domain(domain_id) name = id entries = self.network_api.get_dns_entries_by_name(context, - name, zone) - entry = _create_dns_entry(entries[0], name, zone) + name, domain) + entry = _create_dns_entry(entries[0], name, domain) return _translate_dns_entry_view(entry) @wsgi.serializers(xml=FloatingIPDNSsTemplate) - def index(self, req, zone_id): - """Return a list of dns entries for the specified zone and ip.""" + def index(self, req, domain_id): + """Return a list of dns entries for the specified domain and ip.""" context = req.environ['nova.context'] params = req.GET floating_ip = params.get('ip') - zone = _unquote_zone(zone_id) + domain = _unquote_domain(domain_id) if not floating_ip: raise webob.exc.HTTPUnprocessableEntity() entries = self.network_api.get_dns_entries_by_address(context, floating_ip, - zone) - entrylist = [_create_dns_entry(floating_ip, entry, zone) + domain) + entrylist = [_create_dns_entry(floating_ip, entry, domain) for entry in entries] return _translate_dns_entries_view(entrylist) @wsgi.serializers(xml=FloatingIPDNSTemplate) - def update(self, req, zone_id, id, body): + def update(self, req, domain_id, id, body): """Add or modify dns entry""" context = req.environ['nova.context'] - zone = _unquote_zone(zone_id) + domain = _unquote_domain(domain_id) name = id try: entry = body['dns_entry'] @@ -249,28 +250,29 @@ class FloatingIPDNSEntryController(object): except (TypeError, KeyError): raise webob.exc.HTTPUnprocessableEntity() - entries = self.network_api.get_dns_entries_by_name(context, name, zone) + entries = self.network_api.get_dns_entries_by_name(context, + name, domain) if not entries: # create! self.network_api.add_dns_entry(context, address, name, - dns_type, zone) + dns_type, domain) else: # modify! - self.network_api.modify_dns_entry(context, name, address, zone) + self.network_api.modify_dns_entry(context, name, address, domain) return _translate_dns_entry_view({'ip': address, 'name': name, 'type': dns_type, - 'zone': zone}) + 'domain': domain}) - def delete(self, req, zone_id, id): + def delete(self, req, domain_id, id): """Delete the entry identified by req and id. """ context = req.environ['nova.context'] - zone = _unquote_zone(zone_id) + domain = _unquote_domain(domain_id) name = id try: - self.network_api.delete_dns_entry(context, name, zone) + self.network_api.delete_dns_entry(context, name, domain) except exception.NotFound: return webob.Response(status_int=404) @@ -298,7 +300,7 @@ class Floating_ip_dns(extensions.ExtensionDescriptor): res = extensions.ResourceExtension('entries', FloatingIPDNSEntryController(), - parent={'member_name': 'zone', + parent={'member_name': 'domain', 'collection_name': 'os-floating-ip-dns'}) resources.append(res) |
