From c5949ccb2825128dc3f9c51cc333407246cf12a9 Mon Sep 17 00:00:00 2001 From: Graham Hayes Date: Tue, 10 Nov 2015 19:42:29 +0000 Subject: [PATCH] Rename all references of Domain to Zone This is a pretty invasive change :) A non complete list of changes: * Database Tables * Database Columns * Designate Objects and fields on Objects * Designate Objects Adaptors stop doing some of the renames * All RPCAPI versions are bumped - totally backward incompatable (function names have changed) Change-Id: Ib99e918998a3909fa4aa92bf1ee0475f8a519196 --- contrib/archive/backends/impl_ipa/__init__.py | 30 +- contrib/archive/backends/impl_multi.py | 52 +- contrib/ipaextractor.py | 2 +- contrib/tempest/config.py | 2 +- .../dns_clients/json/domains_client.py | 8 +- contrib/tempest/dns_tests/test_domains.py | 22 +- contrib/tempest/dns_tests/test_records.py | 10 +- designate/agent/handler.py | 46 +- designate/api/admin/views/base.py | 2 +- .../api/admin/views/extensions/quotas.py | 17 +- .../api/admin/views/extensions/reports.py | 6 +- designate/api/v1/domains.py | 18 +- designate/api/v1/extensions/reports.py | 4 +- designate/api/v1/extensions/sync.py | 4 +- designate/api/v1/extensions/touch.py | 2 +- designate/api/v1/limits.py | 4 +- designate/api/v1/records.py | 28 +- designate/api/v2/controllers/limits.py | 8 +- designate/api/v2/controllers/recordsets.py | 14 +- .../api/v2/controllers/zones/__init__.py | 14 +- .../api/v2/controllers/zones/nameservers.py | 2 +- .../api/v2/controllers/zones/tasks/abandon.py | 2 +- .../api/v2/controllers/zones/tasks/exports.py | 2 +- .../api/v2/controllers/zones/tasks/xfr.py | 2 +- designate/backend/agent.py | 34 +- designate/backend/agent_backend/base.py | 20 +- designate/backend/agent_backend/impl_bind9.py | 48 +- .../backend/agent_backend/impl_denominator.py | 88 +- designate/backend/agent_backend/impl_fake.py | 16 +- designate/backend/base.py | 22 +- designate/backend/impl_akamai.py | 30 +- designate/backend/impl_bind9.py | 20 +- designate/backend/impl_designate.py | 18 +- designate/backend/impl_dynect.py | 42 +- designate/backend/impl_fake.py | 8 +- designate/backend/impl_infoblox/__init__.py | 12 +- designate/backend/impl_nsd4.py | 16 +- designate/backend/impl_powerdns/__init__.py | 28 +- designate/central/__init__.py | 4 +- designate/central/rpcapi.py | 137 +- designate/central/service.py | 1055 +++++----- designate/context.py | 2 +- designate/dnsutils.py | 4 +- designate/exceptions.py | 32 +- designate/manage/akamai.py | 6 +- designate/mdns/handler.py | 66 +- designate/mdns/notify.py | 48 +- designate/mdns/rpcapi.py | 24 +- designate/mdns/xfr.py | 16 +- designate/notification_handler/base.py | 36 +- designate/notification_handler/neutron.py | 12 +- designate/notification_handler/nova.py | 10 +- designate/objects/__init__.py | 8 +- designate/objects/adapters/__init__.py | 4 +- .../objects/adapters/api_v2/recordset.py | 2 +- .../adapters/api_v2/{domain.py => zone.py} | 12 +- .../objects/adapters/api_v2/zone_export.py | 2 +- .../objects/adapters/api_v2/zone_import.py | 2 +- .../{domain_master.py => zone_master.py} | 8 +- .../adapters/api_v2/zone_transfer_accept.py | 2 +- .../adapters/api_v2/zone_transfer_request.py | 2 - designate/objects/adapters/base.py | 2 +- designate/objects/pool_manager_status.py | 4 +- designate/objects/record.py | 2 +- designate/objects/recordset.py | 4 +- designate/objects/tenant.py | 4 +- designate/objects/{domain.py => zone.py} | 20 +- ...{domain_attribute.py => zone_attribute.py} | 12 +- designate/objects/zone_export.py | 2 +- designate/objects/zone_import.py | 2 +- .../{domain_master.py => zone_master.py} | 10 +- designate/objects/zone_transfer_accept.py | 4 +- designate/objects/zone_transfer_request.py | 6 +- designate/pool_manager/__init__.py | 2 +- designate/pool_manager/cache/base.py | 4 +- .../cache/impl_memcache/__init__.py | 8 +- .../pool_manager/cache/impl_noop/__init__.py | 2 +- .../cache/impl_sqlalchemy/__init__.py | 6 +- .../versions/008_domain_to_zone_rename.py | 34 + .../cache/impl_sqlalchemy/tables.py | 6 +- designate/pool_manager/rpcapi.py | 45 +- designate/pool_manager/service.py | 268 +-- designate/quota/__init__.py | 12 +- designate/quota/base.py | 12 +- .../resources/templates/export-zone.jinja2 | 4 +- designate/schema/format.py | 12 +- designate/sqlalchemy/base.py | 8 +- designate/storage/base.py | 56 +- designate/storage/impl_sqlalchemy/__init__.py | 468 ++--- .../versions/080_domain_to_zone_rename.py | 139 ++ .../migrate_repo/versions/081_add_FKs.py | 66 + designate/storage/impl_sqlalchemy/tables.py | 46 +- designate/tests/__init__.py | 58 +- .../test_agent/test_backends/test_bind9.py | 26 +- .../test_backends/test_denominator.py | 30 +- .../test_agent/test_backends/test_fake.py | 20 +- designate/tests/test_agent/test_handler.py | 4 +- .../test_admin/extensions/test_quotas.py | 4 +- .../test_admin/extensions/test_reports.py | 28 +- designate/tests/test_api/test_middleware.py | 2 +- .../tests/test_api/test_v1/test_domains.py | 332 ++-- .../tests/test_api/test_v1/test_records.py | 298 +-- .../test_api/test_v2/test_floatingips.py | 16 +- .../test_api/test_v2/test_hostheaders.py | 2 +- .../tests/test_api/test_v2/test_limits.py | 6 +- .../tests/test_api/test_v2/test_recordsets.py | 294 +-- .../test_api/test_v2/test_zone_transfers.py | 30 +- .../tests/test_api/test_v2/test_zones.py | 132 +- designate/tests/test_backend/test_dynect.py | 14 +- designate/tests/test_backend/test_infoblox.py | 24 +- designate/tests/test_backend/test_nsd4.py | 34 +- designate/tests/test_backend/test_powerdns.py | 38 +- .../tests/test_central/_test_service_ipa.py | 60 +- designate/tests/test_central/test_service.py | 1744 ++++++++--------- designate/tests/test_mdns/test_handler.py | 108 +- designate/tests/test_mdns/test_notify.py | 26 +- .../test_notification_handler/test_neutron.py | 28 +- .../test_notification_handler/test_nova.py | 26 +- .../tests/test_pool_manager/cache/__init__.py | 6 +- .../test_pool_manager/cache/test_memcache.py | 10 +- .../test_pool_manager/cache/test_noop.py | 2 +- .../cache/test_sqlalchemy.py | 4 +- .../tests/test_pool_manager/test_rpcapi.py | 38 +- .../tests/test_pool_manager/test_service.py | 178 +- designate/tests/test_quota/test_quota.py | 40 +- designate/tests/test_quota/test_storage.py | 24 +- designate/tests/test_schema/__init__.py | 4 +- designate/tests/test_schema/test_format.py | 14 +- designate/tests/test_storage/__init__.py | 646 +++--- .../tests/test_zone_manager/test_tasks.py | 38 +- .../tests/unit/test_backend/test_designate.py | 22 +- .../tests/unit/test_central/test_basic.py | 607 +++--- .../tests/unit/test_objects/test_domain.py | 88 +- .../unit/test_zone_manager/test_tasks.py | 24 +- designate/zone_manager/rpcapi.py | 4 +- designate/zone_manager/service.py | 10 +- designate/zone_manager/tasks.py | 24 +- etc/designate/policy.json | 36 +- .../api/v2/test_zone_ownership_transfers.py | 2 +- setup.cfg | 2 +- 140 files changed, 4444 insertions(+), 4230 deletions(-) rename designate/objects/adapters/api_v2/{domain.py => zone.py} (89%) rename designate/objects/adapters/api_v2/{domain_master.py => zone_master.py} (93%) rename designate/objects/{domain.py => zone.py} (93%) rename designate/objects/{domain_attribute.py => zone_attribute.py} (72%) rename designate/objects/{domain_master.py => zone_master.py} (86%) create mode 100644 designate/pool_manager/cache/impl_sqlalchemy/migrate_repo/versions/008_domain_to_zone_rename.py create mode 100644 designate/storage/impl_sqlalchemy/migrate_repo/versions/080_domain_to_zone_rename.py create mode 100644 designate/storage/impl_sqlalchemy/migrate_repo/versions/081_add_FKs.py diff --git a/contrib/archive/backends/impl_ipa/__init__.py b/contrib/archive/backends/impl_ipa/__init__.py index 74c9b947..2e5bc5dd 100644 --- a/contrib/archive/backends/impl_ipa/__init__.py +++ b/contrib/archive/backends/impl_ipa/__init__.py @@ -213,11 +213,11 @@ class IPABackend(base.Backend): self.ntries = cfg.CONF[self.name].ipa_connect_retries self.force = cfg.CONF[self.name].ipa_force_ns_use - def create_domain(self, context, domain): - LOG.debug('Create Domain %r' % domain) + def create_zone(self, context, zone): + LOG.debug('Create Zone %r' % zone) ipareq = {'method': 'dnszone_add', 'id': 0} - params = [domain['name']] - servers = self.central_service.get_domain_servers(self.admin_context) + params = [zone['name']] + servers = self.central_service.get_zone_ns_records(self.admin_context) # just use the first one for zone creation - add the others # later, below - use force because designate assumes the NS # already exists somewhere, is resolvable, and already has @@ -226,35 +226,35 @@ class IPABackend(base.Backend): if self.force: args['force'] = True for dkey, ipakey in list(domain2ipa.items()): - if dkey in domain: - args[ipakey] = domain[dkey] + if dkey in zone: + args[ipakey] = zone[dkey] ipareq['params'] = [params, args] self._call_and_handle_error(ipareq) # add NS records for all of the other servers if len(servers) > 1: ipareq = {'method': 'dnsrecord_add', 'id': 0} - params = [domain['name'], "@"] + params = [zone['name'], "@"] args = {'nsrecord': servers[1:]} if self.force: args['force'] = True ipareq['params'] = [params, args] self._call_and_handle_error(ipareq) - def update_domain(self, context, domain): - LOG.debug('Update Domain %r' % domain) + def update_zone(self, context, zone): + LOG.debug('Update Zone %r' % zone) ipareq = {'method': 'dnszone_mod', 'id': 0} - params = [domain['name']] + params = [zone['name']] args = {} for dkey, ipakey in list(domain2ipa.items()): - if dkey in domain: - args[ipakey] = domain[dkey] + if dkey in zone: + args[ipakey] = zone[dkey] ipareq['params'] = [params, args] self._call_and_handle_error(ipareq) - def delete_domain(self, context, domain): - LOG.debug('Delete Domain %r' % domain) + def delete_zone(self, context, zone): + LOG.debug('Delete Zone %r' % zone) ipareq = {'method': 'dnszone_del', 'id': 0} - params = [domain['name']] + params = [zone['name']] args = {} ipareq['params'] = [params, args] self._call_and_handle_error(ipareq) diff --git a/contrib/archive/backends/impl_multi.py b/contrib/archive/backends/impl_multi.py index 3a65a932..d977d148 100644 --- a/contrib/archive/backends/impl_multi.py +++ b/contrib/archive/backends/impl_multi.py @@ -97,54 +97,54 @@ class MultiBackend(base.Backend): with excutils.save_and_reraise_exception(): self.slave.create_tsigkey(context, tsigkey) - def create_domain(self, context, domain): - self.master.create_domain(context, domain) + def create_zone(self, context, zone): + self.master.create_zone(context, zone) try: - self.slave.create_domain(context, domain) + self.slave.create_zone(context, zone) except Exception: with excutils.save_and_reraise_exception(): - self.master.delete_domain(context, domain) + self.master.delete_zone(context, zone) - def update_domain(self, context, domain): - self.master.update_domain(context, domain) + def update_zone(self, context, zone): + self.master.update_zone(context, zone) - def delete_domain(self, context, domain): - # Fetch the full domain from Central first, as we may + def delete_zone(self, context, zone): + # Fetch the full zone from Central first, as we may # have to recreate it on slave if delete on master fails deleted_context = context.deepcopy() deleted_context.show_deleted = True - full_domain = self.central.find_domain( - deleted_context, {'id': domain['id']}) + full_domain = self.central.find_zone( + deleted_context, {'id': zone['id']}) - self.slave.delete_domain(context, domain) + self.slave.delete_zone(context, zone) try: - self.master.delete_domain(context, domain) + self.master.delete_zone(context, zone) except Exception: with excutils.save_and_reraise_exception(): - self.slave.create_domain(context, domain) + self.slave.create_zone(context, zone) - [self.slave.create_record(context, domain, record) + [self.slave.create_record(context, zone, record) for record in self.central.find_records( context, {'domain_id': full_domain['id']})] - def create_recordset(self, context, domain, recordset): - self.master.create_recordset(context, domain, recordset) + def create_recordset(self, context, zone, recordset): + self.master.create_recordset(context, zone, recordset) - def update_recordset(self, context, domain, recordset): - self.master.update_recordset(context, domain, recordset) + def update_recordset(self, context, zone, recordset): + self.master.update_recordset(context, zone, recordset) - def delete_recordset(self, context, domain, recordset): - self.master.delete_recordset(context, domain, recordset) + def delete_recordset(self, context, zone, recordset): + self.master.delete_recordset(context, zone, recordset) - def create_record(self, context, domain, recordset, record): - self.master.create_record(context, domain, recordset, record) + def create_record(self, context, zone, recordset, record): + self.master.create_record(context, zone, recordset, record) - def update_record(self, context, domain, recordset, record): - self.master.update_record(context, domain, recordset, record) + def update_record(self, context, zone, recordset, record): + self.master.update_record(context, zone, recordset, record) - def delete_record(self, context, domain, recordset, record): - self.master.delete_record(context, domain, recordset, record) + def delete_record(self, context, zone, recordset, record): + self.master.delete_record(context, zone, recordset, record) def ping(self, context): return { diff --git a/contrib/ipaextractor.py b/contrib/ipaextractor.py index f5d3a715..5f1dcbef 100644 --- a/contrib/ipaextractor.py +++ b/contrib/ipaextractor.py @@ -242,7 +242,7 @@ def main(): # create a fake domain in IPA # create a fake server in Designate # try to create the same fake domain in Designate - # if we get a DuplicateDomain error from Designate, then + # if we get a DuplicateZone error from Designate, then # raise the CannotUseIPABackend error, after deleting # the fake server and fake domain # find the first non-reverse zone diff --git a/contrib/tempest/config.py b/contrib/tempest/config.py index 13ce75a3..3ebd3cdb 100644 --- a/contrib/tempest/config.py +++ b/contrib/tempest/config.py @@ -305,7 +305,7 @@ ComputeAdminGroup = [ help="API key to use when authenticating as admin.", secret=True), cfg.StrOpt('domain_name', - help="Domain name for authentication as admin (Keystone V3)." + help="Zone name for authentication as admin (Keystone V3)." "The same domain applies to user and project"), ] diff --git a/contrib/tempest/dns_clients/json/domains_client.py b/contrib/tempest/dns_clients/json/domains_client.py index 668e1060..ab304fa1 100644 --- a/contrib/tempest/dns_clients/json/domains_client.py +++ b/contrib/tempest/dns_clients/json/domains_client.py @@ -39,13 +39,13 @@ class DomainsClientJSON(rest_client.RestClient): """Get the details of a domain.""" resp, body = self.get("v1/domains/%s" % str(domain_id)) body = json.loads(body) - self.validate_response(schema.get_domain, resp, body) + self.validate_response(schema.get_zone, resp, body) return resp, body def delete_domain(self, domain_id): """Delete the given domain.""" resp, body = self.delete("v1/domains/%s" % str(domain_id)) - self.validate_response(schema.delete_domain, resp, body) + self.validate_response(schema.delete_zone, resp, body) return resp, body def create_domain(self, name, email, **kwargs): @@ -61,7 +61,7 @@ class DomainsClientJSON(rest_client.RestClient): post_body[post_param] = value resp, body = self.post('v1/domains', json.dumps(post_body)) body = json.loads(body) - self.validate_response(schema.create_domain, resp, body) + self.validate_response(schema.create_zone, resp, body) return resp, body def update_domain(self, domain_id, **kwargs): @@ -75,5 +75,5 @@ class DomainsClientJSON(rest_client.RestClient): resp, body = self.put('v1/domains/%s' % domain_id, json.dumps(post_body)) body = json.loads(body) - self.validate_response(schema.update_domain, resp, body) + self.validate_response(schema.update_zone, resp, body) return resp, body diff --git a/contrib/tempest/dns_tests/test_domains.py b/contrib/tempest/dns_tests/test_domains.py index 0448a911..153d8864 100644 --- a/contrib/tempest/dns_tests/test_domains.py +++ b/contrib/tempest/dns_tests/test_domains.py @@ -30,19 +30,19 @@ class DnsDomainsTest(base.BaseDnsTest): for i in range(2): name = data_utils.rand_name('domain') + '.com.' email = data_utils.rand_name('dns') + '@testmail.com' - _, domain = cls.client.create_domain(name, email) + _, domain = cls.client.create_zone(name, email) cls.setup_domains.append(domain) @classmethod def tearDownClass(cls): for domain in cls.setup_domains: - cls.client.delete_domain(domain['id']) + cls.client.delete_zone(domain['id']) super(DnsDomainsTest, cls).tearDownClass() def _delete_domain(self, domain_id): - self.client.delete_domain(domain_id) + self.client.delete_zone(domain_id) self.assertRaises(exceptions.NotFound, - self.client.get_domain, domain_id) + self.client.get_zone, domain_id) @test.attr(type='gate') def test_list_domains(self): @@ -54,20 +54,20 @@ class DnsDomainsTest(base.BaseDnsTest): @test.attr(type='smoke') def test_create_update_get_domain(self): - # Create Domain + # Create Zone d_name = data_utils.rand_name('domain') + '.com.' d_email = data_utils.rand_name('dns') + '@testmail.com' - _, domain = self.client.create_domain(name=d_name, email=d_email) + _, domain = self.client.create_zone(name=d_name, email=d_email) self.addCleanup(self._delete_domain, domain['id']) self.assertEqual(d_name, domain['name']) self.assertEqual(d_email, domain['email']) - # Update Domain with ttl + # Update Zone with ttl d_ttl = 3600 - _, update_domain = self.client.update_domain(domain['id'], - ttl=d_ttl) + _, update_domain = self.client.update_zone(domain['id'], + ttl=d_ttl) self.assertEqual(d_ttl, update_domain['ttl']) - # Get the details of Domain - _, get_domain = self.client.get_domain(domain['id']) + # Get the details of Zone + _, get_domain = self.client.get_zone(domain['id']) self.assertEqual(update_domain['name'], get_domain['name']) self.assertEqual(update_domain['email'], get_domain['email']) self.assertEqual(update_domain['ttl'], get_domain['ttl']) diff --git a/contrib/tempest/dns_tests/test_records.py b/contrib/tempest/dns_tests/test_records.py index 06b44a43..4b83cf21 100644 --- a/contrib/tempest/dns_tests/test_records.py +++ b/contrib/tempest/dns_tests/test_records.py @@ -30,7 +30,7 @@ class RecordsTest(base.BaseDnsTest): cls.setup_records = list() name = data_utils.rand_name('domain') + '.com.' email = data_utils.rand_name('dns') + '@testmail.com' - _, cls.domain = cls.dns_domains_client.create_domain(name, email) + _, cls.domain = cls.dns_domains_client.create_zone(name, email) # Creates a record with type as A r_name = 'www.' + name data1 = "192.0.2.3" @@ -49,7 +49,7 @@ class RecordsTest(base.BaseDnsTest): def tearDownClass(cls): for record in cls.setup_records: cls.client.delete_record(cls.domain['id'], record['id']) - cls.dns_domains_client.delete_domain(cls.domain['id']) + cls.dns_domains_client.delete_zone(cls.domain['id']) def _delete_record(self, domain_id, record_id): self.client.delete_record(domain_id, record_id) @@ -66,11 +66,11 @@ class RecordsTest(base.BaseDnsTest): @test.attr(type='smoke') def test_create_update_get_delete_record(self): - # Create Domain + # Create Zone name = data_utils.rand_name('domain') + '.com.' email = data_utils.rand_name('dns') + '@testmail.com' - _, domain = self.dns_domains_client.create_domain(name, email) - self.addCleanup(self.dns_domains_client.delete_domain, domain['id']) + _, domain = self.dns_domains_client.create_zone(name, email) + self.addCleanup(self.dns_domains_client.delete_zone, domain['id']) # Create Record r_name = 'www.' + name r_data = "192.0.2.4" diff --git a/designate/agent/handler.py b/designate/agent/handler.py index f6610297..afe7ebba 100644 --- a/designate/agent/handler.py +++ b/designate/agent/handler.py @@ -108,28 +108,28 @@ class RequestHandler(object): question = request.question[0] requester = request.environ['addr'][0] - domain_name = question.name.to_text() + zone_name = question.name.to_text() - if not self._allowed(request, requester, "CREATE", domain_name): + if not self._allowed(request, requester, "CREATE", zone_name): response.set_rcode(dns.rcode.from_text("REFUSED")) return response - serial = self.backend.find_domain_serial(domain_name) + serial = self.backend.find_zone_serial(zone_name) if serial is not None: LOG.warn(_LW("Not creating %(name)s, zone already exists") % - {'name': domain_name}) + {'name': zone_name}) # Provide an authoritative answer response.flags |= dns.flags.AA return response LOG.debug("Received %(verb)s for %(name)s from %(host)s" % - {'verb': "CREATE", 'name': domain_name, 'host': requester}) + {'verb': "CREATE", 'name': zone_name, 'host': requester}) try: - zone = dnsutils.do_axfr(domain_name, self.masters, + zone = dnsutils.do_axfr(zone_name, self.masters, source=self.transfer_source) - self.backend.create_domain(zone) + self.backend.create_zone(zone) except Exception: response.set_rcode(dns.rcode.from_text("SERVFAIL")) return response @@ -152,35 +152,35 @@ class RequestHandler(object): question = request.question[0] requester = request.environ['addr'][0] - domain_name = question.name.to_text() + zone_name = question.name.to_text() - if not self._allowed(request, requester, "NOTIFY", domain_name): + if not self._allowed(request, requester, "NOTIFY", zone_name): response.set_rcode(dns.rcode.from_text("REFUSED")) return response - serial = self.backend.find_domain_serial(domain_name) + serial = self.backend.find_zone_serial(zone_name) if serial is None: LOG.warn(_LW("Refusing NOTIFY for %(name)s, doesn't exist") % - {'name': domain_name}) + {'name': zone_name}) response.set_rcode(dns.rcode.from_text("REFUSED")) return response LOG.debug("Received %(verb)s for %(name)s from %(host)s" % - {'verb': "NOTIFY", 'name': domain_name, 'host': requester}) + {'verb': "NOTIFY", 'name': zone_name, 'host': requester}) # According to RFC we should query the server that sent the NOTIFY # TODO(Tim): Reenable this when it makes more sense # resolver = dns.resolver.Resolver() # resolver.nameservers = [requester] # This assumes that the Master is running on port 53 - # soa_answer = resolver.query(domain_name, 'SOA') + # soa_answer = resolver.query(zone_name, 'SOA') # Check that the serial is < serial above try: - zone = dnsutils.do_axfr(domain_name, self.masters, + zone = dnsutils.do_axfr(zone_name, self.masters, source=self.transfer_source) - self.backend.update_domain(zone) + self.backend.update_zone(zone) except Exception: response.set_rcode(dns.rcode.from_text("SERVFAIL")) return response @@ -203,44 +203,44 @@ class RequestHandler(object): question = request.question[0] requester = request.environ['addr'][0] - domain_name = question.name.to_text() + zone_name = question.name.to_text() - if not self._allowed(request, requester, "DELETE", domain_name): + if not self._allowed(request, requester, "DELETE", zone_name): response.set_rcode(dns.rcode.from_text("REFUSED")) return response - serial = self.backend.find_domain_serial(domain_name) + serial = self.backend.find_zone_serial(zone_name) if serial is None: LOG.warn(_LW("Not deleting %(name)s, zone doesn't exist") % - {'name': domain_name}) + {'name': zone_name}) # Provide an authoritative answer response.flags |= dns.flags.AA return response LOG.debug("Received DELETE for %(name)s from %(host)s" % - {'name': domain_name, 'host': requester}) + {'name': zone_name, 'host': requester}) # Provide an authoritative answer response.flags |= dns.flags.AA # Call into the backend to Delete try: - self.backend.delete_domain(domain_name) + self.backend.delete_zone(zone_name) except Exception: response.set_rcode(dns.rcode.from_text("SERVFAIL")) return response return response - def _allowed(self, request, requester, op, domain_name): + def _allowed(self, request, requester, op, zone_name): # If there are no explict notifiers specified, allow all if not self.allow_notify: return True if requester not in self.allow_notify: LOG.warn(_LW("%(verb)s for %(name)s from %(server)s refused") % - {'verb': op, 'name': domain_name, 'server': requester}) + {'verb': op, 'name': zone_name, 'server': requester}) return False return True diff --git a/designate/api/admin/views/base.py b/designate/api/admin/views/base.py index 618dfe3a..71196dd1 100644 --- a/designate/api/admin/views/base.py +++ b/designate/api/admin/views/base.py @@ -33,7 +33,7 @@ class BaseView(object): as part of the API call. For example, in the V2 API, we did s/domain/zone/. Adapting a record - resources "domain_id" <-> "zone_id" is the responsibility of a View. + resources "tenant_id" <-> "project_id" is the responsibility of a View. """ _resource_name = None _collection_name = None diff --git a/designate/api/admin/views/extensions/quotas.py b/designate/api/admin/views/extensions/quotas.py index baa4d01e..9a6954cd 100644 --- a/designate/api/admin/views/extensions/quotas.py +++ b/designate/api/admin/views/extensions/quotas.py @@ -30,24 +30,15 @@ class QuotasView(base_view.BaseView): def show_basic(self, context, request, quota): """Basic view of a quota""" return { - "zones": quota['domains'], - "zone_records": quota['domain_records'], - "zone_recordsets": quota['domain_recordsets'], + "zones": quota['zones'], + "zone_records": quota['zone_records'], + "zone_recordsets": quota['zone_recordsets'], "recordset_records": quota['recordset_records'] } def load(self, context, request, body): """Extract a "central" compatible dict from an API call""" - valid_keys = ('domain_records', 'domain_recordsets', 'domains', + valid_keys = ('zone_records', 'zone_recordsets', 'zones', 'recordset_records') - mapping = { - 'zones': 'domains', - 'zone_records': 'domain_records', - 'zone_recordsets': 'domain_recordsets', - 'recordset_records': 'recordset_records' - } - - body["quota"] = {mapping[k]: body["quota"][k] for k in body["quota"]} - return self._load(context, request, body, valid_keys) diff --git a/designate/api/admin/views/extensions/reports.py b/designate/api/admin/views/extensions/reports.py index c82ca7cb..f544ded9 100644 --- a/designate/api/admin/views/extensions/reports.py +++ b/designate/api/admin/views/extensions/reports.py @@ -51,7 +51,7 @@ class TenantsView(base_view.BaseView): """Basic view of the Tenants Report""" return { - "zone_count": tenants['domain_count'], + "zone_count": tenants['zone_count'], "id": tenants['id'], "links": self._get_resource_links(request, tenants) } @@ -60,8 +60,8 @@ class TenantsView(base_view.BaseView): """Detail view of the Tenants Report""" return { - "zones_count": tenant['domain_count'], - "zones": tenant['domains'], + "zones_count": tenant['zone_count'], + "zones": tenant['zones'], "id": tenant['id'], "links": self._get_resource_links(request, tenant) } diff --git a/designate/api/v1/domains.py b/designate/api/v1/domains.py index 57e5ff7c..1d22026a 100644 --- a/designate/api/v1/domains.py +++ b/designate/api/v1/domains.py @@ -65,7 +65,7 @@ def create_domain(): # A V1 zone only supports being a primary (No notion of a type) values['type'] = 'PRIMARY' - domain = central_api.create_domain(context, objects.Domain(**values)) + domain = central_api.create_zone(context, objects.Zone(**values)) response = flask.jsonify(domain_schema.filter(domain)) response.status_int = 201 @@ -80,7 +80,7 @@ def get_domains(): central_api = central_rpcapi.CentralAPI.get_instance() - domains = central_api.find_domains(context, criterion={"type": "PRIMARY"}) + domains = central_api.find_zones(context, criterion={"type": "PRIMARY"}) return flask.jsonify(domains_schema.filter({'domains': domains})) @@ -92,7 +92,7 @@ def get_domain(domain_id): central_api = central_rpcapi.CentralAPI.get_instance() criterion = {"id": domain_id, "type": "PRIMARY"} - domain = central_api.find_domain(context, criterion=criterion) + domain = central_api.find_zone(context, criterion=criterion) return flask.jsonify(domain_schema.filter(domain)) @@ -106,7 +106,7 @@ def update_domain(domain_id): # Fetch the existing resource criterion = {"id": domain_id, "type": "PRIMARY"} - domain = central_api.find_domain(context, criterion=criterion) + domain = central_api.find_zone(context, criterion=criterion) # Prepare a dict of fields for validation domain_data = domain_schema.filter(domain) @@ -117,7 +117,7 @@ def update_domain(domain_id): # Update and persist the resource domain.update(values) - domain = central_api.update_domain(context, domain) + domain = central_api.update_zone(context, domain) return flask.jsonify(domain_schema.filter(domain)) @@ -130,9 +130,9 @@ def delete_domain(domain_id): # TODO(ekarlso): Fix this to something better. criterion = {"id": domain_id, "type": "PRIMARY"} - central_api.find_domain(context, criterion=criterion) + central_api.find_zone(context, criterion=criterion) - central_api.delete_domain(context, domain_id) + central_api.delete_zone(context, domain_id) return flask.Response(status=200) @@ -145,9 +145,9 @@ def get_domain_servers(domain_id): # TODO(ekarlso): Fix this to something better. criterion = {"id": domain_id, "type": "PRIMARY"} - central_api.find_domain(context, criterion=criterion) + central_api.find_zone(context, criterion=criterion) - nameservers = central_api.get_domain_servers(context, domain_id) + nameservers = central_api.get_zone_ns_records(context, domain_id) servers = objects.ServerList() diff --git a/designate/api/v1/extensions/reports.py b/designate/api/v1/extensions/reports.py index e071f50c..8def1930 100644 --- a/designate/api/v1/extensions/reports.py +++ b/designate/api/v1/extensions/reports.py @@ -47,7 +47,7 @@ def reports_counts(): context = flask.request.environ.get('context') tenants = central_api.count_tenants(context) - domains = central_api.count_domains(context) + domains = central_api.count_zones(context) records = central_api.count_records(context) return flask.jsonify(tenants=tenants, domains=domains, records=records) @@ -66,7 +66,7 @@ def reports_counts_tenants(): def reports_counts_domains(): context = flask.request.environ.get('context') - count = central_api.count_domains(context) + count = central_api.count_zones(context) return flask.jsonify(domains=count) diff --git a/designate/api/v1/extensions/sync.py b/designate/api/v1/extensions/sync.py index 2df0ec2b..a592494d 100644 --- a/designate/api/v1/extensions/sync.py +++ b/designate/api/v1/extensions/sync.py @@ -28,7 +28,7 @@ blueprint = flask.Blueprint('sync', __name__) def sync_domains(): context = flask.request.environ.get('context') - central_api.sync_domains(context) + central_api.sync_zones(context) return flask.Response(status=200) @@ -37,7 +37,7 @@ def sync_domains(): def sync_domain(domain_id): context = flask.request.environ.get('context') - central_api.sync_domain(context, domain_id) + central_api.sync_zone(context, domain_id) return flask.Response(status=200) diff --git a/designate/api/v1/extensions/touch.py b/designate/api/v1/extensions/touch.py index 46f1aa9e..1a500729 100644 --- a/designate/api/v1/extensions/touch.py +++ b/designate/api/v1/extensions/touch.py @@ -26,6 +26,6 @@ blueprint = flask.Blueprint('touch', __name__) def touch_domain(domain_id): context = flask.request.environ.get('context') - central_api.touch_domain(context, domain_id) + central_api.touch_zone(context, domain_id) return flask.Response(status=200) diff --git a/designate/api/v1/limits.py b/designate/api/v1/limits.py index ad741a91..41021926 100644 --- a/designate/api/v1/limits.py +++ b/designate/api/v1/limits.py @@ -41,8 +41,8 @@ def get_limits(): return flask.jsonify(limits_schema.filter({ "limits": { "absolute": { - "maxDomains": absolute_limits['domains'], - "maxDomainRecords": absolute_limits['domain_records'] + "maxDomains": absolute_limits['zones'], + "maxDomainRecords": absolute_limits['zone_records'] } } })) diff --git a/designate/api/v1/records.py b/designate/api/v1/records.py index c47982ae..8a019d89 100644 --- a/designate/api/v1/records.py +++ b/designate/api/v1/records.py @@ -33,7 +33,7 @@ def _find_recordset(context, domain_id, name, type): central_api = central_rpcapi.CentralAPI.get_instance() return central_api.find_recordset(context, { - 'domain_id': domain_id, + 'zone_id': domain_id, 'name': name, 'type': type, }) @@ -43,7 +43,7 @@ def _find_or_create_recordset(context, domain_id, name, type, ttl): central_api = central_rpcapi.CentralAPI.get_instance() criterion = {"id": domain_id, "type": "PRIMARY"} - central_api.find_domain(context, criterion=criterion) + central_api.find_zone(context, criterion=criterion) try: # Attempt to create an empty recordset @@ -83,6 +83,10 @@ def _format_record_v1(record, recordset): record['priority'], record['data'] = utils.extract_priority_from_data( recordset.type, record) + record['domain_id'] = record['zone_id'] + + del record['zone_id'] + record.update({ 'name': recordset['name'], 'type': recordset['type'], @@ -122,8 +126,8 @@ def create_record(domain_id): central_api = central_rpcapi.CentralAPI.get_instance() record = central_api.create_record(context, domain_id, - recordset['id'], - record) + recordset['id'], + record) record = _format_record_v1(record, recordset) @@ -143,9 +147,9 @@ def get_records(domain_id): # NOTE: We need to ensure the domain actually exists, otherwise we may # return an empty records array instead of a domain not found - central_api.get_domain(context, domain_id) + central_api.get_zone(context, domain_id) - recordsets = central_api.find_recordsets(context, {'domain_id': domain_id}) + recordsets = central_api.find_recordsets(context, {'zone_id': domain_id}) records = [] @@ -164,9 +168,9 @@ def get_record(domain_id, record_id): # NOTE: We need to ensure the domain actually exists, otherwise we may # return an record not found instead of a domain not found - central_api.get_domain(context, domain_id) + central_api.get_zone(context, domain_id) - criterion = {'domain_id': domain_id, 'id': record_id} + criterion = {'zone_id': domain_id, 'id': record_id} record = central_api.find_record(context, criterion) recordset = central_api.get_recordset( @@ -188,12 +192,12 @@ def update_record(domain_id, record_id): # NOTE: We need to ensure the domain actually exists, otherwise we may # return a record not found instead of a domain not found criterion = {"id": domain_id, "type": "PRIMARY"} - central_api.find_domain(context, criterion) + central_api.find_zone(context, criterion) # Fetch the existing resource # NOTE(kiall): We use "find_record" rather than "get_record" as we do not # have the recordset_id. - criterion = {'domain_id': domain_id, 'id': record_id} + criterion = {'zone_id': domain_id, 'id': record_id} record = central_api.find_record(context, criterion) # TODO(graham): Move this further down the stack @@ -247,10 +251,10 @@ def delete_record(domain_id, record_id): # NOTE: We need to ensure the domain actually exists, otherwise we may # return a record not found instead of a domain not found criterion = {"id": domain_id, "type": "PRIMARY"} - central_api.find_domain(context, criterion=criterion) + central_api.find_zone(context, criterion=criterion) # Find the record - criterion = {'domain_id': domain_id, 'id': record_id} + criterion = {'zone_id': domain_id, 'id': record_id} record = central_api.find_record(context, criterion) central_api.delete_record( diff --git a/designate/api/v2/controllers/limits.py b/designate/api/v2/controllers/limits.py index 6152e1da..07e6c7e3 100644 --- a/designate/api/v2/controllers/limits.py +++ b/designate/api/v2/controllers/limits.py @@ -35,15 +35,15 @@ class LimitsController(rest.RestController): return { # Resource Creation Limits - "max_zones": absolute_limits['domains'], - "max_zone_recordsets": absolute_limits['domain_recordsets'], - "max_zone_records": absolute_limits['domain_records'], + "max_zones": absolute_limits['zones'], + "max_zone_recordsets": absolute_limits['zone_recordsets'], + "max_zone_records": absolute_limits['zone_records'], "max_recordset_records": absolute_limits['recordset_records'], # Resource Field Value Limits "min_ttl": CONF['service:central'].min_ttl, "max_zone_name_length": - CONF['service:central'].max_domain_name_len, + CONF['service:central'].max_zone_name_len, "max_recordset_name_length": CONF['service:central'].max_recordset_name_len, diff --git a/designate/api/v2/controllers/recordsets.py b/designate/api/v2/controllers/recordsets.py index f92b639e..e1545b54 100644 --- a/designate/api/v2/controllers/recordsets.py +++ b/designate/api/v2/controllers/recordsets.py @@ -27,7 +27,7 @@ LOG = logging.getLogger(__name__) class RecordSetsController(rest.RestController): - SORT_KEYS = ['created_at', 'id', 'updated_at', 'domain_id', 'tenant_id', + SORT_KEYS = ['created_at', 'id', 'updated_at', 'zone_id', 'tenant_id', 'name', 'type', 'ttl', 'records'] @pecan.expose(template='json:', content_type='application/json') @@ -50,9 +50,9 @@ class RecordSetsController(rest.RestController): request = pecan.request context = request.environ['context'] - # NOTE: We need to ensure the domain actually exists, otherwise we may - # return deleted recordsets instead of a domain not found - self.central_api.get_domain(context, zone_id) + # NOTE: We need to ensure the zone actually exists, otherwise we may + # return deleted recordsets instead of a zone not found + self.central_api.get_zone(context, zone_id) # Extract the pagination params marker, limit, sort_key, sort_dir = utils.get_paging_params( @@ -64,7 +64,7 @@ class RecordSetsController(rest.RestController): criterion = self._apply_filter_params( params, accepted_filters, {}) - criterion['domain_id'] = zone_id + criterion['zone_id'] = zone_id # Data must be filtered separately, through the Records table data = criterion.pop('data', None) @@ -77,7 +77,7 @@ class RecordSetsController(rest.RestController): # 'data' filter param: only return recordsets with matching data if data: records = self.central_api.find_records( - context, criterion={'data': data, 'domain_id': zone_id}) + context, criterion={'data': data, 'zone_id': zone_id}) recordset_with_data_ids = set(record.recordset_id for record in records) @@ -163,7 +163,7 @@ class RecordSetsController(rest.RestController): # NS recordsets at the zone root cannot be manually updated if recordset['type'] == 'NS': - zone = self.central_api.get_domain(context, zone_id) + zone = self.central_api.get_zone(context, zone_id) if recordset['name'] == zone['name']: raise exceptions.BadRequest( 'Updating a root zone NS record is not allowed') diff --git a/designate/api/v2/controllers/zones/__init__.py b/designate/api/v2/controllers/zones/__init__.py index 2e55955c..da556c1e 100644 --- a/designate/api/v2/controllers/zones/__init__.py +++ b/designate/api/v2/controllers/zones/__init__.py @@ -49,7 +49,7 @@ class ZonesController(rest.RestController): return DesignateAdapter.render( 'API_v2', - self.central_api.get_domain(context, zone_id), + self.central_api.get_zone(context, zone_id), request=request) @pecan.expose(template='json:', content_type='application/json') @@ -70,7 +70,7 @@ class ZonesController(rest.RestController): return DesignateAdapter.render( 'API_v2', - self.central_api.find_domains( + self.central_api.find_zones( context, criterion, marker, limit, sort_key, sort_dir), request=request) @@ -90,7 +90,7 @@ class ZonesController(rest.RestController): if 'type' not in zone: zone['type'] = 'PRIMARY' - zone = DesignateAdapter.parse('API_v2', zone, objects.Domain()) + zone = DesignateAdapter.parse('API_v2', zone, objects.Zone()) zone.validate() if zone.type == 'SECONDARY': @@ -98,7 +98,7 @@ class ZonesController(rest.RestController): zone['email'] = mgmt_email # Create the zone - zone = self.central_api.create_domain(context, zone) + zone = self.central_api.create_zone(context, zone) # Prepare the response headers # If the zone has been created asynchronously @@ -129,7 +129,7 @@ class ZonesController(rest.RestController): # TODO(kiall): Validate we have a sane UUID for zone_id # Fetch the existing zone - zone = self.central_api.get_domain(context, zone_id) + zone = self.central_api.get_zone(context, zone_id) # Don't allow updates to zones that are being deleted if zone.action == "DELETE": @@ -166,7 +166,7 @@ class ZonesController(rest.RestController): raise exceptions.InvalidObject(msg) increment_serial = zone.type == 'PRIMARY' - zone = self.central_api.update_domain( + zone = self.central_api.update_zone( context, zone, increment_serial=increment_serial) if zone.status == 'PENDING': @@ -184,7 +184,7 @@ class ZonesController(rest.RestController): response = pecan.response context = request.environ['context'] - zone = self.central_api.delete_domain(context, zone_id) + zone = self.central_api.delete_zone(context, zone_id) response.status_int = 202 return DesignateAdapter.render('API_v2', zone, request=request) diff --git a/designate/api/v2/controllers/zones/nameservers.py b/designate/api/v2/controllers/zones/nameservers.py index 0ecd530b..0a6a8696 100644 --- a/designate/api/v2/controllers/zones/nameservers.py +++ b/designate/api/v2/controllers/zones/nameservers.py @@ -37,5 +37,5 @@ class NameServersController(rest.RestController): return { "nameservers": DesignateAdapter.render( 'API_v2', - self.central_api.get_domain_servers(context, zone_id), + self.central_api.get_zone_ns_records(context, zone_id), request=request)} diff --git a/designate/api/v2/controllers/zones/tasks/abandon.py b/designate/api/v2/controllers/zones/tasks/abandon.py index 935678ac..a6c92d1a 100644 --- a/designate/api/v2/controllers/zones/tasks/abandon.py +++ b/designate/api/v2/controllers/zones/tasks/abandon.py @@ -30,7 +30,7 @@ class AbandonController(rest.RestController): context.abandon = 'True' # abandon the zone - zone = self.central_api.delete_domain(context, zone_id) + zone = self.central_api.delete_zone(context, zone_id) if zone.deleted_at: response.status_int = 204 else: diff --git a/designate/api/v2/controllers/zones/tasks/exports.py b/designate/api/v2/controllers/zones/tasks/exports.py index d123c885..cc1b33d5 100644 --- a/designate/api/v2/controllers/zones/tasks/exports.py +++ b/designate/api/v2/controllers/zones/tasks/exports.py @@ -40,7 +40,7 @@ class ZoneExportController(rest.RestController): if export.location and export.location.startswith('designate://'): return self.zone_manager_api.\ - render_zone(context, export['domain_id']) + render_zone(context, export['zone_id']) else: msg = 'Zone can not be exported synchronously' raise exceptions.BadRequest(msg) diff --git a/designate/api/v2/controllers/zones/tasks/xfr.py b/designate/api/v2/controllers/zones/tasks/xfr.py index 55d319fe..54d6c1ba 100644 --- a/designate/api/v2/controllers/zones/tasks/xfr.py +++ b/designate/api/v2/controllers/zones/tasks/xfr.py @@ -29,7 +29,7 @@ class XfrController(rest.RestController): response = pecan.response context = request.environ['context'] - self.central_api.xfr_domain(context, zone_id) + self.central_api.xfr_zone(context, zone_id) response.status_int = 202 # NOTE: This is a hack and a half.. But Pecan needs it. diff --git a/designate/backend/agent.py b/designate/backend/agent.py index 964eb702..d5945b98 100644 --- a/designate/backend/agent.py +++ b/designate/backend/agent.py @@ -67,10 +67,10 @@ class AgentPoolBackend(base.Backend): def mdns_api(self): return mdns_api.MdnsAPI.get_instance() - def create_domain(self, context, domain): - LOG.debug('Create Domain') + def create_zone(self, context, zone): + LOG.debug('Create Zone') response, retry = self._make_and_send_dns_message( - domain.name, + zone.name, self.timeout, CC, CREATE, @@ -81,12 +81,12 @@ class AgentPoolBackend(base.Backend): if response is None: raise exceptions.Backend() - def update_domain(self, context, domain): - LOG.debug('Update Domain') + def update_zone(self, context, zone): + LOG.debug('Update Zone') self.mdns_api.notify_zone_changed( context, - domain, + zone, self.host, self.port, self.timeout, @@ -95,10 +95,10 @@ class AgentPoolBackend(base.Backend): self.delay ) - def delete_domain(self, context, domain): - LOG.debug('Delete Domain') + def delete_zone(self, context, zone): + LOG.debug('Delete Zone') response, retry = self._make_and_send_dns_message( - domain.name, + zone.name, self.timeout, CC, DELETE, @@ -109,10 +109,10 @@ class AgentPoolBackend(base.Backend): if response is None: raise exceptions.Backend() - def _make_and_send_dns_message(self, domain_name, timeout, opcode, - rdatatype, rdclass, dest_ip, - dest_port): - dns_message = self._make_dns_message(domain_name, opcode, rdatatype, + def _make_and_send_dns_message(self, zone_name, timeout, opcode, + rdatatype, rdclass, dest_ip, + dest_port): + dns_message = self._make_dns_message(zone_name, opcode, rdatatype, rdclass) retry = 0 @@ -121,7 +121,7 @@ class AgentPoolBackend(base.Backend): LOG.info(_LI("Sending '%(msg)s' for '%(zone)s' to '%(server)s:" "%(port)d'.") % {'msg': str(opcode), - 'zone': domain_name, 'server': dest_ip, + 'zone': zone_name, 'server': dest_ip, 'port': dest_port}) response = self._send_dns_message( dns_message, dest_ip, dest_port, timeout) @@ -131,7 +131,7 @@ class AgentPoolBackend(base.Backend): "'%(zone)s' to '%(server)s:%(port)d'. Timeout=" "'%(timeout)d' seconds. Retry='%(retry)d'") % {'msg': str(opcode), - 'zone': domain_name, 'server': dest_ip, + 'zone': zone_name, 'server': dest_ip, 'port': dest_port, 'timeout': timeout, 'retry': retry}) response = None @@ -140,7 +140,7 @@ class AgentPoolBackend(base.Backend): "for '%(zone)s' to '%(server)s:%(port)d'. Timeout" "='%(timeout)d' seconds. Retry='%(retry)d'") % {'msg': str(opcode), - 'zone': domain_name, 'server': dest_ip, + 'zone': zone_name, 'server': dest_ip, 'port': dest_port, 'timeout': timeout, 'retry': retry}) response = None @@ -153,7 +153,7 @@ class AgentPoolBackend(base.Backend): "send '%(msg)s' for '%(zone)s' to '%(server)s:" "%(port)d'. Response message: %(resp)s") % {'msg': str(opcode), - 'zone': domain_name, 'server': dest_ip, + 'zone': zone_name, 'server': dest_ip, 'port': dest_port, 'resp': str(response)}) response = None return (response, retry) diff --git a/designate/backend/agent_backend/base.py b/designate/backend/agent_backend/base.py index d3057302..bd22cb79 100644 --- a/designate/backend/agent_backend/base.py +++ b/designate/backend/agent_backend/base.py @@ -39,19 +39,19 @@ class AgentBackend(DriverPlugin): pass @abc.abstractmethod - def find_domain_serial(self, domain_name): - """Find a DNS Domain""" + def find_zone_serial(self, zone_name): + """Find a DNS Zone""" @abc.abstractmethod - def create_domain(self, domain): - """Create a DNS domain""" - """Domain is a DNSPython Zone object""" + def create_zone(self, zone): + """Create a DNS zone""" + """Zone is a DNSPython Zone object""" @abc.abstractmethod - def update_domain(self, domain): - """Update a DNS domain""" - """Domain is a DNSPython Zone object""" + def update_zone(self, zone): + """Update a DNS zone""" + """Zone is a DNSPython Zone object""" @abc.abstractmethod - def delete_domain(self, domain_name): - """Delete a DNS domain""" + def delete_zone(self, zone_name): + """Delete a DNS zone""" diff --git a/designate/backend/agent_backend/impl_bind9.py b/designate/backend/agent_backend/impl_bind9.py index f439662f..d0973a17 100644 --- a/designate/backend/agent_backend/impl_bind9.py +++ b/designate/backend/agent_backend/impl_bind9.py @@ -50,7 +50,7 @@ class Bind9Backend(base.AgentBackend): cfg.StrOpt('zone-file-path', default='$state_path/zones', help='Path where zone files are stored'), cfg.StrOpt('query-destination', default='127.0.0.1', - help='Host to query when finding domains') + help='Host to query when finding zones') ] return [(group, opts)] @@ -58,30 +58,30 @@ class Bind9Backend(base.AgentBackend): def start(self): LOG.info(_LI("Started bind9 backend")) - def find_domain_serial(self, domain_name): - LOG.debug("Finding %s" % domain_name) + def find_zone_serial(self, zone_name): + LOG.debug("Finding %s" % zone_name) resolver = dns.resolver.Resolver() resolver.nameservers = [cfg.CONF[CFG_GROUP].query_destination] try: - rdata = resolver.query(domain_name, 'SOA')[0] + rdata = resolver.query(zone_name, 'SOA')[0] except Exception: return None return rdata.serial - def create_domain(self, domain): - LOG.debug("Creating %s" % domain.origin.to_text()) - self._sync_domain(domain, new_domain_flag=True) + def create_zone(self, zone): + LOG.debug("Creating %s" % zone.origin.to_text()) + self._sync_zone(zone, new_zone_flag=True) - def update_domain(self, domain): - LOG.debug("Updating %s" % domain.origin.to_text()) - self._sync_domain(domain) + def update_zone(self, zone): + LOG.debug("Updating %s" % zone.origin.to_text()) + self._sync_zone(zone) - def delete_domain(self, domain_name): - LOG.debug('Delete Domain: %s' % domain_name) + def delete_zone(self, zone_name): + LOG.debug('Delete Zone: %s' % zone_name) rndc_op = 'delzone' - # RNDC doesn't like the trailing dot on the domain name - rndc_call = self._rndc_base() + [rndc_op, domain_name.rstrip('.')] + # RNDC doesn't like the trailing dot on the zone name + rndc_call = self._rndc_base() + [rndc_op, zone_name.rstrip('.')] utils.execute(*rndc_call) @@ -102,39 +102,39 @@ class Bind9Backend(base.AgentBackend): return rndc_call - def _sync_domain(self, domain, new_domain_flag=False): - """Sync a single domain's zone file and reload bind config""" + def _sync_zone(self, zone, new_zone_flag=False): + """Sync a single zone's zone file and reload bind config""" # NOTE: Different versions of BIND9 behave differently with a trailing # dot, so we're just going to take it off. - domain_name = domain.origin.to_text().rstrip('.') + zone_name = zone.origin.to_text().rstrip('.') # NOTE: Only one thread should be working with the Zonefile at a given # time. The sleep(1) below introduces a not insignificant risk # of more than 1 thread working with a zonefile at a given time. - with lockutils.lock('bind9-%s' % domain_name): - LOG.debug('Synchronising Domain: %s' % domain_name) + with lockutils.lock('bind9-%s' % zone_name): + LOG.debug('Synchronising Zone: %s' % zone_name) zone_path = cfg.CONF[CFG_GROUP].zone_file_path output_path = os.path.join(zone_path, - '%s.zone' % domain_name) + '%s.zone' % zone_name) - domain.to_file(output_path, relativize=False) + zone.to_file(output_path, relativize=False) rndc_call = self._rndc_base() - if new_domain_flag: + if new_zone_flag: rndc_op = [ 'addzone', - '%s { type master; file "%s"; };' % (domain_name, + '%s { type master; file "%s"; };' % (zone_name, output_path), ] rndc_call.extend(rndc_op) else: rndc_op = 'reload' rndc_call.extend([rndc_op]) - rndc_call.extend([domain_name]) + rndc_call.extend([zone_name]) LOG.debug('Calling RNDC with: %s' % " ".join(rndc_call)) self._execute_rndc(rndc_call) diff --git a/designate/backend/agent_backend/impl_denominator.py b/designate/backend/agent_backend/impl_denominator.py index 1b92b0f6..dc488990 100644 --- a/designate/backend/agent_backend/impl_denominator.py +++ b/designate/backend/agent_backend/impl_denominator.py @@ -118,14 +118,14 @@ class DenominatorBackend(base.AgentBackend): def stop(self): LOG.info(_LI("Stopped Denominator backend")) - def find_domain_serial(self, domain_name): - LOG.debug("Finding %s" % domain_name) + def find_zone_serial(self, zone_name): + LOG.debug("Finding %s" % zone_name) - domain_name = domain_name.rstrip('.') + zone_name = zone_name.rstrip('.') output = self.denominator.get_record( - zone=domain_name, + zone=zone_name, type='SOA', - name=domain_name) + name=zone_name) try: text = ' '.join(output.split()[3:]) rdata = dns.rdata.from_text(dns.rdataclass.IN, @@ -135,109 +135,109 @@ class DenominatorBackend(base.AgentBackend): return None return rdata.serial - def create_domain(self, domain): - LOG.debug("Creating %s" % domain.origin.to_text()) - domain_name = domain.origin.to_text(omit_final_dot=True) + def create_zone(self, zone): + LOG.debug("Creating %s" % zone.origin.to_text()) + zone_name = zone.origin.to_text(omit_final_dot=True) # Use SOA TTL as zone default TTL - soa_record = domain.find_rrset(domain.origin, dns.rdatatype.SOA) - rname = soa_record.items[0].rname.derelativize(origin=domain.origin) + soa_record = zone.find_rrset(zone.origin, dns.rdatatype.SOA) + rname = soa_record.items[0].rname.derelativize(origin=zone.origin) - # Lock domain to prevent concurrent changes. - with self._sync_domain(domain.origin): + # Lock zone to prevent concurrent changes. + with self._sync_zone(zone.origin): # NOTE: If zone already exists, denominator will update it with # new values, in other a duplicate zone will be created if # provider supports such functionality. self.denominator.create_zone( - name=domain_name, + name=zone_name, ttl=soa_record.ttl, email=rname) # Add records one by one. - for name, ttl, rtype, data in self._iterate_records(domain): + for name, ttl, rtype, data in self._iterate_records(zone): # Some providers do not support creationg of SOA record. rdatatype = dns.rdatatype.from_text(rtype) if rdatatype == dns.rdatatype.SOA: continue self.denominator.create_record( - zone=domain_name, + zone=zone_name, name=name, type=rtype, ttl=ttl, data=data) - def update_domain(self, domain): - LOG.debug("Updating %s" % domain.origin) - domain_name = domain.origin.to_text(omit_final_dot=True) + def update_zone(self, zone): + LOG.debug("Updating %s" % zone.origin) + zone_name = zone.origin.to_text(omit_final_dot=True) - soa_record = domain.find_rrset(domain.origin, dns.rdatatype.SOA) - rname = soa_record.items[0].rname.derelativize(origin=domain.origin) + soa_record = zone.find_rrset(zone.origin, dns.rdatatype.SOA) + rname = soa_record.items[0].rname.derelativize(origin=zone.origin) - with self._sync_domain(domain.origin): + with self._sync_zone(zone.origin): # Update zone with a new parameters self.denominator.update_zone( - id=domain_name, + id=zone_name, ttl=soa_record.ttl, email=rname) # Fetch records to create a differential update of a zone. - output = self.denominator.get_records(domain_name) - subdomains = dict() + output = self.denominator.get_records(zone_name) + subzones = dict() - # Subdomains dict will contain names of subdomains without + # subzones dict will contain names of subzones without # trailing dot. for raw in output.splitlines(): data = raw.split() name, rtype = data[0], data[1] - rtypes = subdomains.get(name, set()) + rtypes = subzones.get(name, set()) rtypes.add(rtype) - subdomains[name] = rtypes + subzones[name] = rtypes - for name, ttl, rtype, data in self._iterate_records(domain): + for name, ttl, rtype, data in self._iterate_records(zone): record_action = self.denominator.create_record - if name in subdomains and rtype in subdomains[name]: + if name in subzones and rtype in subzones[name]: # When RR set already exists, replace it with a new one. rdatatype = dns.rdatatype.from_text(rtype) record_action = self.denominator.update_record # So next call will ADD a new record to record set # instead of replacing of the existing one. - subdomains[name].remove(rtype) + subzones[name].remove(rtype) # NOTE: DynECT does not support deleting of the SOA # record. Skip updating of the SOA record. if rdatatype == dns.rdatatype.SOA: continue - record_action(zone=domain_name, + record_action(zone=zone_name, name=name, type=rtype, ttl=ttl, data=data) # Remaining records should be deleted - for name, types in subdomains.items(): + for name, types in subzones.items(): for rtype in types: self.denominator.delete_record( - zone=domain_name, id=name, type=rtype) + zone=zone_name, id=name, type=rtype) - def delete_domain(self, domain_name): - LOG.debug('Delete Domain: %s' % domain_name) + def delete_zone(self, zone_name): + LOG.debug('Delete Zone: %s' % zone_name) - with self._sync_domain(domain_name): - self.denominator.delete_zone(id=domain_name) + with self._sync_zone(zone_name): + self.denominator.delete_zone(id=zone_name) - def _sync_domain(self, domain_name): - LOG.debug('Synchronising domain: %s' % domain_name) - return lockutils.lock('denominator-%s' % domain_name) + def _sync_zone(self, zone_name): + LOG.debug('Synchronising zone: %s' % zone_name) + return lockutils.lock('denominator-%s' % zone_name) - def _iterate_records(self, domain): - for rname, ttl, rdata in domain.iterate_rdatas(): - name = rname.derelativize(origin=domain.origin) + def _iterate_records(self, zone): + for rname, ttl, rdata in zone.iterate_rdatas(): + name = rname.derelativize(origin=zone.origin) name = name.to_text(omit_final_dot=True) - data = rdata.to_text(origin=domain.origin, relativize=False) + data = rdata.to_text(origin=zone.origin, relativize=False) yield name, ttl, dns.rdatatype.to_text(rdata.rdtype), data diff --git a/designate/backend/agent_backend/impl_fake.py b/designate/backend/agent_backend/impl_fake.py index f4adb840..4ed2d57a 100644 --- a/designate/backend/agent_backend/impl_fake.py +++ b/designate/backend/agent_backend/impl_fake.py @@ -30,15 +30,15 @@ class FakeBackend(base.AgentBackend): def stop(self): LOG.info(_LI("Stopped fake backend")) - def find_domain_serial(self, domain_name): - LOG.debug("Finding %s" % domain_name) + def find_zone_serial(self, zone_name): + LOG.debug("Finding %s" % zone_name) return 0 - def create_domain(self, domain): - LOG.debug("Creating %s" % domain.origin.to_text()) + def create_zone(self, zone): + LOG.debug("Creating %s" % zone.origin.to_text()) - def update_domain(self, domain): - LOG.debug("Updating %s" % domain.origin.to_text()) + def update_zone(self, zone): + LOG.debug("Updating %s" % zone.origin.to_text()) - def delete_domain(self, domain_name): - LOG.debug('Delete Domain: %s' % domain_name) + def delete_zone(self, zone_name): + LOG.debug('Delete Zone: %s' % zone_name) diff --git a/designate/backend/base.py b/designate/backend/base.py index dd9ec19c..f646fc77 100644 --- a/designate/backend/base.py +++ b/designate/backend/base.py @@ -67,34 +67,34 @@ class Backend(DriverPlugin): # Core Backend Interface @abc.abstractmethod - def create_domain(self, context, domain): + def create_zone(self, context, zone): """ - Create a DNS domain. + Create a DNS zone. :param context: Security context information. - :param domain: the DNS domain. + :param zone: the DNS zone. """ - def update_domain(self, context, domain): + def update_zone(self, context, zone): """ - Update a DNS domain. + Update a DNS zone. :param context: Security context information. - :param domain: the DNS domain. + :param zone: the DNS zone. """ - LOG.debug('Update Domain') + LOG.debug('Update Zone') self.mdns_api.notify_zone_changed( - context, domain, self.host, self.port, self.timeout, + context, zone, self.host, self.port, self.timeout, self.retry_interval, self.max_retries, self.delay) @abc.abstractmethod - def delete_domain(self, context, domain): + def delete_zone(self, context, zone): """ - Delete a DNS domain. + Delete a DNS zone. :param context: Security context information. - :param domain: the DNS domain. + :param zone: the DNS zone. """ def ping(self, context): diff --git a/designate/backend/impl_akamai.py b/designate/backend/impl_akamai.py index 26953e6d..c5272285 100644 --- a/designate/backend/impl_akamai.py +++ b/designate/backend/impl_akamai.py @@ -47,7 +47,7 @@ class DelegationExists(exceptions.BadRequest, EnhancedDNSException): error_type = 'delegation_exists' -class DuplicateDomain(exceptions.DuplicateDomain, EnhancedDNSException): +class DuplicateZone(exceptions.DuplicateZone, EnhancedDNSException): """ Raised when an attempt to create a zone which is registered to another Akamai account is made @@ -60,7 +60,7 @@ class Forbidden(exceptions.Forbidden, EnhancedDNSException): Raised when an attempt to modify a zone which is registered to another Akamai account is made. - This appears to be returned when creating a new subdomain of domain which + This appears to be returned when creating a new subzone of zone which already exists in another Akamai account. """ pass @@ -142,7 +142,7 @@ class EnhancedDNSClient(object): return self.client.service.setZones(zones=zones) except Exception as e: if 'You do not have permission to view this zone' in str(e): - raise DuplicateDomain() + raise DuplicateZone() elif 'You do not have access to edit this zone' in str(e): raise Forbidden() elif 'basic auth failed' in str(e): @@ -158,7 +158,7 @@ class EnhancedDNSClient(object): self.client.service.setZone(zone=zone) except Exception as e: if 'You do not have permission to view this zone' in str(e): - raise DuplicateDomain() + raise DuplicateZone() elif 'You do not have access to edit this zone' in str(e): raise Forbidden() elif 'basic auth failed' in str(e): @@ -197,22 +197,22 @@ class EnhancedDNSClient(object): return zoneName.rstrip('.').lower() -def build_zone(client, target, domain): +def build_zone(client, target, zone): masters = [m.host for m in target.masters] if target.options.get("tsig_key_name", None): return client.buildZone( - domain.name, + zone.name, masters, - domain.id, + zone.id, target.options["tsig_key_name"], target.options.get("tsig_key_secret", None), target.options.get("tsig_key_algorithm", None)) else: return client.buildZone( - domain.name, + zone.name, masters, - domain.id) + zone.id) class AkamaiBackend(base.Backend): @@ -247,12 +247,12 @@ class AkamaiBackend(base.Backend): raise exceptions.ConfigurationError( "Akamai only supports mDNS instances on port 53") - def create_domain(self, context, domain): - """Create a DNS domain""" - zone = build_zone(self.client, self.target, domain) + def create_zone(self, context, zone): + """Create a DNS zone""" + zone = build_zone(self.client, self.target, zone) self.client.setZone(zone=zone) - def delete_domain(self, context, domain): - """Delete a DNS domain""" - self.client.deleteZone(zoneName=domain['name']) + def delete_zone(self, context, zone): + """Delete a DNS zone""" + self.client.deleteZone(zoneName=zone['name']) diff --git a/designate/backend/impl_bind9.py b/designate/backend/impl_bind9.py index 3397783f..e0d2c1cb 100644 --- a/designate/backend/impl_bind9.py +++ b/designate/backend/impl_bind9.py @@ -48,8 +48,8 @@ class Bind9Backend(base.Backend): self.clean_zonefile = strutils.bool_from_string( self.options.get('clean_zonefile', 'false')) - def create_domain(self, context, domain): - LOG.debug('Create Domain') + def create_zone(self, context, zone): + LOG.debug('Create Zone') masters = [] for master in self.masters: host = master['host'] @@ -62,26 +62,26 @@ class Bind9Backend(base.Backend): rndc_op = [ 'addzone', '%s { type slave; masters { %s;}; file "slave.%s%s"; };' % - (domain['name'].rstrip('.'), '; '.join(masters), domain['name'], - domain['id']), + (zone['name'].rstrip('.'), '; '.join(masters), zone['name'], + zone['id']), ] try: self._execute_rndc(rndc_op) except exceptions.Backend as e: - # If create fails because the domain exists, don't reraise + # If create fails because the zone exists, don't reraise if "already exists" not in six.text_type(e): raise self.mdns_api.notify_zone_changed( - context, domain, self.host, self.port, self.timeout, + context, zone, self.host, self.port, self.timeout, self.retry_interval, self.max_retries, self.delay) - def delete_domain(self, context, domain): - LOG.debug('Delete Domain') + def delete_zone(self, context, zone): + LOG.debug('Delete Zone') rndc_op = [ 'delzone', - '%s' % domain['name'].rstrip('.'), + '%s' % zone['name'].rstrip('.'), ] if self.clean_zonefile: rndc_op.insert(1, '-clean') @@ -89,7 +89,7 @@ class Bind9Backend(base.Backend): try: self._execute_rndc(rndc_op) except exceptions.Backend as e: - # If domain is already deleted, don't reraise + # If zone is already deleted, don't reraise if "not found" not in six.text_type(e): raise diff --git a/designate/backend/impl_designate.py b/designate/backend/impl_designate.py index 0ca0f1dc..1ed23438 100644 --- a/designate/backend/impl_designate.py +++ b/designate/backend/impl_designate.py @@ -87,20 +87,20 @@ class DesignateBackend(base.Backend): session=session, service_type=self.service_type) return self._client - def create_domain(self, context, domain): - msg = _LI('Creating domain %(d_id)s / %(d_name)s') - LOG.info(msg, {'d_id': domain['id'], 'd_name': domain['name']}) + def create_zone(self, context, zone): + msg = _LI('Creating zone %(d_id)s / %(d_name)s') + LOG.info(msg, {'d_id': zone['id'], 'd_name': zone['name']}) masters = ["%s:%s" % (i.host, i.port) for i in self.masters] self.client.zones.create( - domain.name, 'SECONDARY', masters=masters) + zone.name, 'SECONDARY', masters=masters) - def delete_domain(self, context, domain): - msg = _LI('Deleting domain %(d_id)s / %(d_name)s') - LOG.info(msg, {'d_id': domain['id'], 'd_name': domain['name']}) + def delete_zone(self, context, zone): + msg = _LI('Deleting zone %(d_id)s / %(d_name)s') + LOG.info(msg, {'d_id': zone['id'], 'd_name': zone['name']}) try: - self.client.zones.delete(domain.name) + self.client.zones.delete(zone.name) except exceptions.NotFound: msg = _LW("Zone %s not found on remote Designate, Ignoring") - LOG.warn(msg, domain.id) + LOG.warn(msg, zone.id) diff --git a/designate/backend/impl_dynect.py b/designate/backend/impl_dynect.py index 8d4b62f6..ed9b3ae2 100644 --- a/designate/backend/impl_dynect.py +++ b/designate/backend/impl_dynect.py @@ -344,11 +344,11 @@ class DynECTBackend(base.Backend): timeout=CONF[CFG_GROUP].timeout, timings=CONF[CFG_GROUP].timings) - def create_domain(self, context, domain): - LOG.info(_LI('Creating domain %(d_id)s / %(d_name)s') % - {'d_id': domain['id'], 'd_name': domain['name']}) + def create_zone(self, context, zone): + LOG.info(_LI('Creating zone %(d_id)s / %(d_name)s') % + {'d_id': zone['id'], 'd_name': zone['name']}) - url = '/Secondary/%s' % domain['name'].rstrip('.') + url = '/Secondary/%s' % zone['name'].rstrip('.') data = { 'masters': [m.host for m in self.masters] } @@ -366,9 +366,9 @@ class DynECTBackend(base.Backend): except DynClientError as e: for emsg in e.msgs: if emsg['ERR_CD'] == 'TARGET_EXISTS': - msg = _LI("Domain already exists, updating existing " - "domain instead %s") - LOG.info(msg % domain['name']) + msg = _LI("Zone already exists, updating existing " + "zone instead %s") + LOG.info(msg % zone['name']) client.put(url, data=data) break else: @@ -377,10 +377,10 @@ class DynECTBackend(base.Backend): client.put(url, data={'activate': True}) client.logout() - def delete_domain(self, context, domain): - LOG.info(_LI('Deleting domain %(d_id)s / %(d_name)s') % - {'d_id': domain['id'], 'd_name': domain['name']}) - url = '/Zone/%s' % domain['name'].rstrip('.') + def delete_zone(self, context, zone): + LOG.info(_LI('Deleting zone %(d_id)s / %(d_name)s') % + {'d_id': zone['id'], 'd_name': zone['name']}) + url = '/Zone/%s' % zone['name'].rstrip('.') client = self.get_client() try: client.delete(url) @@ -388,26 +388,8 @@ class DynECTBackend(base.Backend): if e.http_status == 404: LOG.warn(_LW("Attempt to delete %(d_id)s / %(d_name)s " "caused 404, ignoring.") % - {'d_id': domain['id'], 'd_name': domain['name']}) + {'d_id': zone['id'], 'd_name': zone['name']}) pass else: raise client.logout() - - def create_recordset(self, context, domain, recordset): - LOG.debug('Discarding create_recordset call, not-applicable') - - def update_recordset(self, context, domain, recordset): - LOG.debug('Discarding update_recordset call, not-applicable') - - def delete_recordset(self, context, domain, recordset): - LOG.debug('Discarding delete_recordset call, not-applicable') - - def create_record(self, context, domain, recordset, record): - LOG.debug('Discarding create_record call, not-applicable') - - def update_record(self, context, domain, recordset, record): - LOG.debug('Discarding update_record call, not-applicable') - - def delete_record(self, context, domain, recordset, record): - LOG.debug('Discarding delete_record call, not-applicable') diff --git a/designate/backend/impl_fake.py b/designate/backend/impl_fake.py index 21709df7..d961dfda 100644 --- a/designate/backend/impl_fake.py +++ b/designate/backend/impl_fake.py @@ -25,8 +25,8 @@ LOG = logging.getLogger(__name__) class FakeBackend(base.Backend): __plugin_name__ = 'fake' - def create_domain(self, context, domain): - LOG.info(_LI('Create Domain %r') % domain) + def create_zone(self, context, zone): + LOG.info(_LI('Create Zone %r') % zone) - def delete_domain(self, context, domain): - LOG.info(_LI('Delete Domain %r') % domain) + def delete_zone(self, context, zone): + LOG.info(_LI('Delete Zone %r') % zone) diff --git a/designate/backend/impl_infoblox/__init__.py b/designate/backend/impl_infoblox/__init__.py index eecfb618..cd5956b5 100644 --- a/designate/backend/impl_infoblox/__init__.py +++ b/designate/backend/impl_infoblox/__init__.py @@ -42,18 +42,18 @@ class InfobloxBackend(base.Backend): raise exceptions.ConfigurationError( "Infoblox only supports mDNS instances on port 53") - def create_domain(self, context, domain): - LOG.info(_LI('Create Domain %r') % domain) + def create_zone(self, context, zone): + LOG.info(_LI('Create Zone %r') % zone) dns_net_view = self.infoblox.get_dns_view(context.tenant) self.infoblox.create_zone_auth( - fqdn=domain['name'][0:-1], + fqdn=zone['name'][0:-1], dns_view=dns_net_view ) - def delete_domain(self, context, domain): - LOG.info(_LI('Delete Domain %r') % domain) - self.infoblox.delete_zone_auth(domain['name'][0:-1]) + def delete_zone(self, context, zone): + LOG.info(_LI('Delete Zone %r') % zone) + self.infoblox.delete_zone_auth(zone['name'][0:-1]) def ping(self, context): LOG.info(_LI('Ping')) diff --git a/designate/backend/impl_nsd4.py b/designate/backend/impl_nsd4.py index f43c8a13..d868264c 100644 --- a/designate/backend/impl_nsd4.py +++ b/designate/backend/impl_nsd4.py @@ -75,8 +75,8 @@ class NSD4Backend(base.Backend): if result != 'ok': raise exceptions.Backend(result) - def create_domain(self, context, domain): - LOG.debug('Create Domain') + def create_zone(self, context, zone): + LOG.debug('Create Zone') masters = [] for master in self.masters: host = master['host'] @@ -86,22 +86,22 @@ class NSD4Backend(base.Backend): # Ensure different MiniDNS instances are targeted for AXFRs random.shuffle(masters) - command = 'addzone %s %s' % (domain['name'], self.pattern) + command = 'addzone %s %s' % (zone['name'], self.pattern) try: self._execute_nsd4(command) except exceptions.Backend as e: - # If create fails because the domain exists, don't reraise + # If create fails because the zone exists, don't reraise if "already exists" not in six.text_type(e): raise - def delete_domain(self, context, domain): - LOG.debug('Delete Domain') - command = 'delzone %s' % domain['name'] + def delete_zone(self, context, zone): + LOG.debug('Delete Zone') + command = 'delzone %s' % zone['name'] try: self._execute_nsd4(command) except exceptions.Backend as e: - # If domain is already deleted, don't reraise + # If zone is already deleted, don't reraise if "not found" not in six.text_type(e): raise diff --git a/designate/backend/impl_powerdns/__init__.py b/designate/backend/impl_powerdns/__init__.py index fc890ff8..d819457f 100644 --- a/designate/backend/impl_powerdns/__init__.py +++ b/designate/backend/impl_powerdns/__init__.py @@ -118,8 +118,8 @@ class PowerDNSBackend(base.Backend): if resultproxy.rowcount != 1: raise exc_notfound() - # Domain Methods - def create_domain(self, context, domain): + # Zone Methods + def create_zone(self, context, zone): try: self.session.begin() @@ -128,8 +128,8 @@ class PowerDNSBackend(base.Backend): masters = six.moves.map(_parse_master, self.masters) domain_values = { - 'designate_id': domain['id'], - 'name': domain['name'].rstrip('.'), + 'designate_id': zone['id'], + 'name': zone['name'].rstrip('.'), 'master': ','.join(masters), 'type': 'SLAVE', 'account': context.tenant @@ -143,23 +143,23 @@ class PowerDNSBackend(base.Backend): self.session.commit() self.mdns_api.notify_zone_changed( - context, domain, self.host, self.port, self.timeout, + context, zone, self.host, self.port, self.timeout, self.retry_interval, self.max_retries, self.delay) - def delete_domain(self, context, domain): - # TODO(kiall): We should make this match create_domain with regard to + def delete_zone(self, context, zone): + # TODO(kiall): We should make this match create_zone with regard to # transactions. try: - self._get(tables.domains, domain['id'], exceptions.DomainNotFound, + self._get(tables.domains, zone['id'], exceptions.ZoneNotFound, id_col=tables.domains.c.designate_id) - except exceptions.DomainNotFound: - # If the Domain is already gone, that's ok. We're deleting it + except exceptions.ZoneNotFound: + # If the Zone is already gone, that's ok. We're deleting it # anyway, so just log and continue. - LOG.critical(_LC('Attempted to delete a domain which is ' + LOG.critical(_LC('Attempted to delete a zone which is ' 'not present in the backend. ID: %s') % - domain['id']) + zone['id']) return - self._delete(tables.domains, domain['id'], - exceptions.DomainNotFound, + self._delete(tables.domains, zone['id'], + exceptions.ZoneNotFound, id_col=tables.domains.c.designate_id) diff --git a/designate/central/__init__.py b/designate/central/__init__.py index 74bbb81f..fffa399a 100644 --- a/designate/central/__init__.py +++ b/designate/central/__init__.py @@ -28,8 +28,8 @@ cfg.CONF.register_opts([ help='The storage driver to use'), cfg.ListOpt('enabled-notification-handlers', default=[], help='Enabled Notification Handlers'), - cfg.IntOpt('max_domain_name_len', default=255, - help="Maximum domain name length"), + cfg.IntOpt('max_zone_name_len', default=255, + help="Maximum zone name length"), cfg.IntOpt('max_recordset_name_len', default=255, help="Maximum recordset name length", deprecated_name='max_record_name_len'), diff --git a/designate/central/rpcapi.py b/designate/central/rpcapi.py index 769e6fb4..00762885 100644 --- a/designate/central/rpcapi.py +++ b/designate/central/rpcapi.py @@ -47,20 +47,21 @@ class CentralAPI(object): 4.2 - Add methods for pool manager integration 4.3 - Added Zone Transfer Methods 5.0 - Remove dead server code - 5.1 - Add xfr_domain + 5.1 - Add xfr_zone 5.2 - Add Zone Import methods 5.3 - Add Zone Export method 5.4 - Add asynchronous Zone Export methods 5.5 - Add deleted zone purging task - 5.6 - Changed 'purge_domains' function args + 5.6 - Changed 'purge_zones' function args + 6.0 - Renamed domains to zones """ - RPC_API_VERSION = '5.6' + RPC_API_VERSION = '6.0' def __init__(self, topic=None): topic = topic if topic else cfg.CONF.central_topic target = messaging.Target(topic=topic, version=self.RPC_API_VERSION) - self.client = rpc.get_client(target, version_cap='5.6') + self.client = rpc.get_client(target, version_cap='6.0') @classmethod def get_instance(cls): @@ -144,56 +145,55 @@ class CentralAPI(object): LOG.info(_LI("count_tenants: Calling central's count_tenants.")) return self.client.call(context, 'count_tenants') - # Domain Methods - def create_domain(self, context, domain): - LOG.info(_LI("create_domain: Calling central's create_domain.")) - return self.client.call(context, 'create_domain', domain=domain) + # Zone Methods + def create_zone(self, context, zone): + LOG.info(_LI("create_zone: Calling central's create_zone.")) + return self.client.call(context, 'create_zone', zone=zone) - def get_domain(self, context, domain_id): - LOG.info(_LI("get_domain: Calling central's get_domain.")) - return self.client.call(context, 'get_domain', domain_id=domain_id) + def get_zone(self, context, zone_id): + LOG.info(_LI("get_zone: Calling central's get_zone.")) + return self.client.call(context, 'get_zone', zone_id=zone_id) - def get_domain_servers(self, context, domain_id): - LOG.info(_LI("get_domain_servers: " - "Calling central's get_domain_servers.")) - return self.client.call(context, 'get_domain_servers', - domain_id=domain_id) + def get_zone_ns_records(self, context, zone_id): + LOG.info(_LI("get_zone_ns_records: " + "Calling central's get_zone_ns_records.")) + return self.client.call(context, 'get_zone_ns_records', + zone_id=zone_id) - def find_domains(self, context, criterion=None, marker=None, limit=None, - sort_key=None, sort_dir=None): - LOG.info(_LI("find_domains: Calling central's find_domains.")) - return self.client.call(context, 'find_domains', criterion=criterion, + def find_zones(self, context, criterion=None, marker=None, limit=None, + sort_key=None, sort_dir=None): + LOG.info(_LI("find_zones: Calling central's find_zones.")) + return self.client.call(context, 'find_zones', criterion=criterion, marker=marker, limit=limit, sort_key=sort_key, sort_dir=sort_dir) - def find_domain(self, context, criterion=None): - LOG.info(_LI("find_domain: Calling central's find_domain.")) - return self.client.call(context, 'find_domain', criterion=criterion) + def find_zone(self, context, criterion=None): + LOG.info(_LI("find_zone: Calling central's find_zone.")) + return self.client.call(context, 'find_zone', criterion=criterion) - def update_domain(self, context, domain, increment_serial=True): - LOG.info(_LI("update_domain: Calling central's update_domain.")) - return self.client.call(context, 'update_domain', domain=domain, + def update_zone(self, context, zone, increment_serial=True): + LOG.info(_LI("update_zone: Calling central's update_zone.")) + return self.client.call(context, 'update_zone', zone=zone, increment_serial=increment_serial) - def delete_domain(self, context, domain_id): - LOG.info(_LI("delete_domain: Calling central's delete_domain.")) - return self.client.call(context, 'delete_domain', domain_id=domain_id) + def delete_zone(self, context, zone_id): + LOG.info(_LI("delete_zone: Calling central's delete_zone.")) + return self.client.call(context, 'delete_zone', zone_id=zone_id) - def purge_domains(self, context, criterion, limit=None): + def purge_zones(self, context, criterion, limit=None): LOG.info(_LI( - "purge_domains: Calling central's purge_domains." + "purge_zones: Calling central's purge_zones." )) - cctxt = self.client.prepare(version='5.6') - return cctxt.call(context, 'purge_domains', + return self.client.call(context, 'purge_zones', criterion=criterion, limit=limit) - def count_domains(self, context, criterion=None): - LOG.info(_LI("count_domains: Calling central's count_domains.")) - return self.client.call(context, 'count_domains', criterion=criterion) + def count_zones(self, context, criterion=None): + LOG.info(_LI("count_zones: Calling central's count_zones.")) + return self.client.call(context, 'count_zones', criterion=criterion) - def touch_domain(self, context, domain_id): - LOG.info(_LI("touch_domain: Calling central's touch_domain.")) - return self.client.call(context, 'touch_domain', domain_id=domain_id) + def touch_zone(self, context, zone_id): + LOG.info(_LI("touch_zone: Calling central's touch_zone.")) + return self.client.call(context, 'touch_zone', zone_id=zone_id) # TLD Methods def create_tld(self, context, tld): @@ -220,14 +220,14 @@ class CentralAPI(object): return self.client.call(context, 'delete_tld', tld_id=tld_id) # RecordSet Methods - def create_recordset(self, context, domain_id, recordset): + def create_recordset(self, context, zone_id, recordset): LOG.info(_LI("create_recordset: Calling central's create_recordset.")) return self.client.call(context, 'create_recordset', - domain_id=domain_id, recordset=recordset) + zone_id=zone_id, recordset=recordset) - def get_recordset(self, context, domain_id, recordset_id): + def get_recordset(self, context, zone_id, recordset_id): LOG.info(_LI("get_recordset: Calling central's get_recordset.")) - return self.client.call(context, 'get_recordset', domain_id=domain_id, + return self.client.call(context, 'get_recordset', zone_id=zone_id, recordset_id=recordset_id) def find_recordsets(self, context, criterion=None, marker=None, limit=None, @@ -252,11 +252,11 @@ class CentralAPI(object): recordset=recordset, increment_serial=increment_serial) - def delete_recordset(self, context, domain_id, recordset_id, + def delete_recordset(self, context, zone_id, recordset_id, increment_serial=True): LOG.info(_LI("delete_recordset: Calling central's delete_recordset.")) return self.client.call(context, 'delete_recordset', - domain_id=domain_id, + zone_id=zone_id, recordset_id=recordset_id, increment_serial=increment_serial) @@ -266,19 +266,19 @@ class CentralAPI(object): criterion=criterion) # Record Methods - def create_record(self, context, domain_id, recordset_id, record, + def create_record(self, context, zone_id, recordset_id, record, increment_serial=True): LOG.info(_LI("create_record: Calling central's create_record.")) return self.client.call(context, 'create_record', - domain_id=domain_id, + zone_id=zone_id, recordset_id=recordset_id, record=record, increment_serial=increment_serial) - def get_record(self, context, domain_id, recordset_id, record_id): + def get_record(self, context, zone_id, recordset_id, record_id): LOG.info(_LI("get_record: Calling central's get_record.")) return self.client.call(context, 'get_record', - domain_id=domain_id, + zone_id=zone_id, recordset_id=recordset_id, record_id=record_id) @@ -299,11 +299,11 @@ class CentralAPI(object): record=record, increment_serial=increment_serial) - def delete_record(self, context, domain_id, recordset_id, record_id, + def delete_record(self, context, zone_id, recordset_id, record_id, increment_serial=True): LOG.info(_LI("delete_record: Calling central's delete_record.")) return self.client.call(context, 'delete_record', - domain_id=domain_id, + zone_id=zone_id, recordset_id=recordset_id, record_id=record_id, increment_serial=increment_serial) @@ -312,24 +312,24 @@ class CentralAPI(object): LOG.info(_LI("count_records: Calling central's count_records.")) return self.client.call(context, 'count_records', criterion=criterion) - # Misc. Report combining counts for tenants, domains and records + # Misc. Report combining counts for tenants, zones and records def count_report(self, context, criterion=None): LOG.info(_LI("count_report: Calling central's count_report.")) return self.client.call(context, 'count_report', criterion=criterion) # Sync Methods - def sync_domains(self, context): - LOG.info(_LI("sync_domains: Calling central's sync_domains.")) - return self.client.call(context, 'sync_domains') + def sync_zones(self, context): + LOG.info(_LI("sync_zones: Calling central's sync_zones.")) + return self.client.call(context, 'sync_zones') - def sync_domain(self, context, domain_id): - LOG.info(_LI("sync_domain: Calling central's sync_domains.")) - return self.client.call(context, 'sync_domain', domain_id=domain_id) + def sync_zone(self, context, zone_id): + LOG.info(_LI("sync_zone: Calling central's sync_zones.")) + return self.client.call(context, 'sync_zone', zone_id=zone_id) - def sync_record(self, context, domain_id, recordset_id, record_id): + def sync_record(self, context, zone_id, recordset_id, record_id): LOG.info(_LI("sync_record: Calling central's sync_record.")) return self.client.call(context, 'sync_record', - domain_id=domain_id, + zone_id=zone_id, recordset_id=recordset_id, record_id=record_id) @@ -348,7 +348,7 @@ class CentralAPI(object): return self.client.call(context, 'update_floatingip', region=region, floatingip_id=floatingip_id, values=values) - # Blacklisted Domain Methods + # Blacklisted Zone Methods def create_blacklist(self, context, blacklist): LOG.info(_LI("create_blacklist: Calling central's create_blacklist")) return self.client.call(context, 'create_blacklist', @@ -409,11 +409,11 @@ class CentralAPI(object): return self.client.call(context, 'delete_pool', pool_id=pool_id) # Pool Manager Integration Methods - def update_status(self, context, domain_id, status, serial): + def update_status(self, context, zone_id, status, serial): LOG.info(_LI("update_status: Calling central's update_status " - "for %(domain_id)s : %(status)s : %(serial)s") % - {'domain_id': domain_id, 'status': status, 'serial': serial}) - self.client.cast(context, 'update_status', domain_id=domain_id, + "for %(zone_id)s : %(status)s : %(serial)s") % + {'zone_id': zone_id, 'status': status, 'serial': serial}) + self.client.cast(context, 'update_status', zone_id=zone_id, status=status, serial=serial) # Zone Ownership Transfers @@ -509,10 +509,9 @@ class CentralAPI(object): 'delete_zone_transfer_accept', zone_transfer_accept_id=zone_transfer_accept_id) - def xfr_domain(self, context, domain_id): - LOG.info(_LI("xfr_domain: Calling central's xfr_domain")) - cctxt = self.client.prepare(version='5.3') - return cctxt.call(context, 'xfr_domain', domain_id=domain_id) + def xfr_zone(self, context, zone_id): + LOG.info(_LI("xfr_zone: Calling central's xfr_zone")) + return self.client.call(context, 'xfr_zone', zone_id=zone_id) # Zone Import Methods def create_zone_import(self, context, request_body): diff --git a/designate/central/service.py b/designate/central/service.py index 24874c41..a891428e 100644 --- a/designate/central/service.py +++ b/designate/central/service.py @@ -55,7 +55,7 @@ from designate.zone_manager import rpcapi as zone_manager_rpcapi LOG = logging.getLogger(__name__) -DOMAIN_LOCKS = threading.local() +ZONE_LOCKS = threading.local() NOTIFICATION_BUFFER = threading.local() RETRY_STATE = threading.local() @@ -136,40 +136,40 @@ def transaction(f): return transaction_wrapper -def synchronized_domain(domain_arg=1, new_domain=False): - """Ensures only a single operation is in progress for each domain +def synchronized_zone(zone_arg=1, new_zone=False): + """Ensures only a single operation is in progress for each zone A Decorator which ensures only a single operation can be happening - on a single domain at once, within the current designate-central instance + on a single zone at once, within the current designate-central instance """ def outer(f): @functools.wraps(f) def sync_wrapper(self, *args, **kwargs): - if not hasattr(DOMAIN_LOCKS, 'held'): + if not hasattr(ZONE_LOCKS, 'held'): # Create the held set if necessary - DOMAIN_LOCKS.held = set() + ZONE_LOCKS.held = set() - domain_id = None + zone_id = None - if 'domain_id' in kwargs: - domain_id = kwargs['domain_id'] + if 'zone_id' in kwargs: + zone_id = kwargs['zone_id'] - elif 'domain' in kwargs: - domain_id = kwargs['domain'].id + elif 'zone' in kwargs: + zone_id = kwargs['zone'].id elif 'recordset' in kwargs: - domain_id = kwargs['recordset'].domain_id + zone_id = kwargs['recordset'].zone_id elif 'record' in kwargs: - domain_id = kwargs['record'].domain_id + zone_id = kwargs['record'].zone_id # The various objects won't always have an ID set, we should # attempt to locate an Object containing the ID. - if domain_id is None: + if zone_id is None: for arg in itertools.chain(kwargs.values(), args): - if isinstance(arg, objects.Domain): - domain_id = arg.id - if domain_id is not None: + if isinstance(arg, objects.Zone): + zone_id = arg.id + if zone_id is not None: break elif (isinstance(arg, objects.RecordSet) or @@ -177,38 +177,38 @@ def synchronized_domain(domain_arg=1, new_domain=False): isinstance(arg, objects.ZoneTransferRequest) or isinstance(arg, objects.ZoneTransferAccept)): - domain_id = arg.domain_id - if domain_id is not None: + zone_id = arg.zone_id + if zone_id is not None: break # If we still don't have an ID, find the Nth argument as - # defined by the domain_arg decorator option. - if domain_id is None and len(args) > domain_arg: - domain_id = args[domain_arg] + # defined by the zone_arg decorator option. + if zone_id is None and len(args) > zone_arg: + zone_id = args[zone_arg] - if isinstance(domain_id, objects.Domain): - # If the value is a Domain object, extract it's ID. - domain_id = domain_id.id + if isinstance(zone_id, objects.Zone): + # If the value is a Zone object, extract it's ID. + zone_id = zone_id.id - if not new_domain and domain_id is None: - raise Exception('Failed to determine domain id for ' + if not new_zone and zone_id is None: + raise Exception('Failed to determine zone id for ' 'synchronized operation') - if domain_id in DOMAIN_LOCKS.held: + if zone_id in ZONE_LOCKS.held: # Call the wrapped function return f(self, *args, **kwargs) else: - with lockutils.lock('domain-%s' % domain_id): - DOMAIN_LOCKS.held.add(domain_id) + with lockutils.lock('zone-%s' % zone_id): + ZONE_LOCKS.held.add(zone_id) # Call the wrapped function result = f(self, *args, **kwargs) - DOMAIN_LOCKS.held.remove(domain_id) + ZONE_LOCKS.held.remove(zone_id) return result sync_wrapper.__wrapped_function = f - sync_wrapper.__wrapper_name = 'synchronized_domain' + sync_wrapper.__wrapper_name = 'synchronized_zone' return sync_wrapper return outer @@ -261,7 +261,7 @@ def notification(notification_type): class Service(service.RPCService, service.Service): - RPC_API_VERSION = '5.6' + RPC_API_VERSION = '6.0' target = messaging.Target(version=RPC_API_VERSION) @@ -313,48 +313,48 @@ class Service(service.RPCService, service.Service): def zone_manager_api(self): return zone_manager_rpcapi.ZoneManagerAPI.get_instance() - def _is_valid_domain_name(self, context, domain_name): - # Validate domain name length - if len(domain_name) > cfg.CONF['service:central'].max_domain_name_len: - raise exceptions.InvalidDomainName('Name too long') + def _is_valid_zone_name(self, context, zone_name): + # Validate zone name length + if len(zone_name) > cfg.CONF['service:central'].max_zone_name_len: + raise exceptions.InvalidZoneName('Name too long') - # Break the domain name up into its component labels - domain_labels = domain_name.strip('.').split('.') + # Break the zone name up into its component labels + zone_labels = zone_name.strip('.').split('.') # We need more than 1 label. - if len(domain_labels) <= 1: - raise exceptions.InvalidDomainName('More than one label is ' - 'required') + if len(zone_labels) <= 1: + raise exceptions.InvalidZoneName('More than one label is ' + 'required') # Check the TLD for validity if there are entries in the database if self.check_for_tlds: try: - self.storage.find_tld(context, {'name': domain_labels[-1]}) + self.storage.find_tld(context, {'name': zone_labels[-1]}) except exceptions.TldNotFound: - raise exceptions.InvalidDomainName('Invalid TLD') + raise exceptions.InvalidZoneName('Invalid TLD') - # Now check that the domain name is not the same as a TLD + # Now check that the zone name is not the same as a TLD try: - stripped_domain_name = domain_name.rstrip('.').lower() + stripped_zone_name = zone_name.rstrip('.').lower() self.storage.find_tld( context, - {'name': stripped_domain_name}) + {'name': stripped_zone_name}) except exceptions.TldNotFound: pass else: - raise exceptions.InvalidDomainName( - 'Domain name cannot be the same as a TLD') + raise exceptions.InvalidZoneName( + 'Zone name cannot be the same as a TLD') - # Check domain name blacklist - if self._is_blacklisted_domain_name(context, domain_name): + # Check zone name blacklist + if self._is_blacklisted_zone_name(context, zone_name): # Some users are allowed bypass the blacklist.. Is this one? - if not policy.check('use_blacklisted_domain', context, + if not policy.check('use_blacklisted_zone', context, do_raise=False): - raise exceptions.InvalidDomainName('Blacklisted domain name') + raise exceptions.InvalidZoneName('Blacklisted zone name') return True - def _is_valid_recordset_name(self, context, domain, recordset_name): + def _is_valid_recordset_name(self, context, zone, recordset_name): if not recordset_name.endswith('.'): raise ValueError('Please supply a FQDN') @@ -364,21 +364,21 @@ class Service(service.RPCService, service.Service): raise exceptions.InvalidRecordSetName('Name too long') # RecordSets must be contained in the parent zone - if (recordset_name != domain['name'] - and not recordset_name.endswith("." + domain['name'])): + if (recordset_name != zone['name'] + and not recordset_name.endswith("." + zone['name'])): raise exceptions.InvalidRecordSetLocation( - 'RecordSet is not contained within it\'s parent domain') + 'RecordSet is not contained within it\'s parent zone') - def _is_valid_recordset_placement(self, context, domain, recordset_name, + def _is_valid_recordset_placement(self, context, zone, recordset_name, recordset_type, recordset_id=None): # CNAME's must not be created at the zone apex. - if recordset_type == 'CNAME' and recordset_name == domain.name: + if recordset_type == 'CNAME' and recordset_name == zone.name: raise exceptions.InvalidRecordSetLocation( 'CNAME recordsets may not be created at the zone apex') # CNAME's must not share a name with other recordsets criterion = { - 'domain_id': domain.id, + 'zone_id': zone.id, 'name': recordset_name, } @@ -394,35 +394,35 @@ class Service(service.RPCService, service.Service): return True - def _is_valid_recordset_placement_subdomain(self, context, domain, - recordset_name, - criterion=None): + def _is_valid_recordset_placement_subzone(self, context, zone, + recordset_name, + criterion=None): """ Check that the placement of the requested rrset belongs to any of the - domains subdomains.. + zones subzones.. """ - LOG.debug("Checking if %s belongs in any of %s subdomains" % - (recordset_name, domain.name)) + LOG.debug("Checking if %s belongs in any of %s subzones" % + (recordset_name, zone.name)) criterion = criterion or {} context = context.elevated() context.all_tenants = True - if domain.name == recordset_name: + if zone.name == recordset_name: return - child_domains = self.storage.find_domains( - context, {"parent_domain_id": domain.id}) - for child_domain in child_domains: + child_zones = self.storage.find_zones( + context, {"parent_zone_id": zone.id}) + for child_zone in child_zones: try: self._is_valid_recordset_name( - context, child_domain, recordset_name) + context, child_zone, recordset_name) except Exception: continue else: msg = 'RecordSet belongs in a child zone: %s' % \ - child_domain['name'] + child_zone['name'] raise exceptions.InvalidRecordSetLocation(msg) def _is_valid_recordset_records(self, recordset): @@ -436,9 +436,9 @@ class Service(service.RPCService, service.Service): 'CNAME recordsets may not have more than 1 record' ) - def _is_blacklisted_domain_name(self, context, domain_name): + def _is_blacklisted_zone_name(self, context, zone_name): """ - Ensures the provided domain_name is not blacklisted. + Ensures the provided zone_name is not blacklisted. """ blacklists = self.storage.find_blacklists(context) @@ -455,7 +455,7 @@ class Service(service.RPCService, service.Service): signal.setitimer(signal.ITIMER_REAL, 0.02) try: - if bool(re.search(blacklist.pattern, domain_name)): + if bool(re.search(blacklist.pattern, zone_name)): return True finally: signal.setitimer(signal.ITIMER_REAL, 0) @@ -464,55 +464,59 @@ class Service(service.RPCService, service.Service): LOG.critical(_LC( 'Blacklist regex (%(pattern)s) took too long to evaluate ' 'against zone name (%(zone_name)s') % - {'pattern': blacklist.pattern, 'zone_name': domain_name}) + { + 'pattern': blacklist.pattern, + 'zone_name': zone_name + } + ) return True return False - def _is_subdomain(self, context, domain_name, pool_id): + def _is_subzone(self, context, zone_name, pool_id): """ - Ensures the provided domain_name is the subdomain - of an existing domain (checks across all tenants) + Ensures the provided zone_name is the subzone + of an existing zone (checks across all tenants) """ context = context.elevated() context.all_tenants = True # Break the name up into it's component labels - labels = domain_name.split(".") + labels = zone_name.split(".") criterion = {"pool_id": pool_id} i = 1 - # Starting with label #2, search for matching domain's in the database + # Starting with label #2, search for matching zone's in the database while (i < len(labels)): name = '.'.join(labels[i:]) criterion["name"] = name try: - domain = self.storage.find_domain(context, criterion) - except exceptions.DomainNotFound: + zone = self.storage.find_zone(context, criterion) + except exceptions.ZoneNotFound: i += 1 else: - return domain + return zone return False - def _is_superdomain(self, context, domain_name, pool_id): + def _is_superzone(self, context, zone_name, pool_id): """ - Ensures the provided domain_name is the parent domain - of an existing subdomain (checks across all tenants) + Ensures the provided zone_name is the parent zone + of an existing subzone (checks across all tenants) """ context = context.elevated() context.all_tenants = True - # Create wildcard term to catch all subdomains - search_term = "%%.%(name)s" % {"name": domain_name} + # Create wildcard term to catch all subzones + search_term = "%%.%(name)s" % {"name": zone_name} criterion = {'name': search_term, "pool_id": pool_id} - subdomains = self.storage.find_domains(context, criterion) + subzones = self.storage.find_zones(context, criterion) - return subdomains + return subzones def _is_valid_ttl(self, context, ttl): min_ttl = cfg.CONF['service:central'].min_ttl @@ -523,16 +527,16 @@ class Service(service.RPCService, service.Service): raise exceptions.InvalidTTL('TTL is below the minimum: %s' % min_ttl) - def _increment_domain_serial(self, context, domain): + def _increment_zone_serial(self, context, zone): # Increment the serial number - domain.serial = utils.increment_serial(domain.serial) - domain = self.storage.update_domain(context, domain) + zone.serial = utils.increment_serial(zone.serial) + zone = self.storage.update_zone(context, zone) # Update SOA record - self._update_soa(context, domain) + self._update_soa(context, zone) - return domain + return zone # SOA Recordset Methods def _build_soa_record(self, zone, ns_records): @@ -578,7 +582,7 @@ class Service(service.RPCService, service.Service): pool = self.storage.get_pool(elevated_context, zone.pool_id) soa = self.find_recordset(context, - criterion={'domain_id': zone['id'], + criterion={'zone_id': zone['id'], 'type': "SOA"}) soa.records[0].data = self._build_soa_record(zone, pool.ns_records) @@ -610,7 +614,7 @@ class Service(service.RPCService, service.Service): # Get NS recordset # If the zone doesn't have an NS recordset yet, create one recordsets = self.find_recordsets( - context, criterion={'domain_id': zone['id'], 'type': "NS"} + context, criterion={'zone_id': zone['id'], 'type': "NS"} ) managed = [] @@ -634,7 +638,7 @@ class Service(service.RPCService, service.Service): def _delete_ns(self, context, zone, ns_record): ns_recordset = self.find_recordset( - context, criterion={'domain_id': zone['id'], 'type': "NS"}) + context, criterion={'zone_id': zone['id'], 'type': "NS"}) for record in copy.deepcopy(ns_recordset.records): if record.data == ns_record: @@ -643,33 +647,33 @@ class Service(service.RPCService, service.Service): self._update_recordset_in_storage(context, zone, ns_recordset) # Quota Enforcement Methods - def _enforce_domain_quota(self, context, tenant_id): + def _enforce_zone_quota(self, context, tenant_id): criterion = {'tenant_id': tenant_id} - count = self.storage.count_domains(context, criterion) + count = self.storage.count_zones(context, criterion) - self.quota.limit_check(context, tenant_id, domains=count) + self.quota.limit_check(context, tenant_id, zones=count) - def _enforce_recordset_quota(self, context, domain): - # Ensure the recordsets per domain quota is OK - criterion = {'domain_id': domain.id} + def _enforce_recordset_quota(self, context, zone): + # Ensure the recordsets per zone quota is OK + criterion = {'zone_id': zone.id} count = self.storage.count_recordsets(context, criterion) self.quota.limit_check( - context, domain.tenant_id, domain_recordsets=count) + context, zone.tenant_id, zone_recordsets=count) - def _enforce_record_quota(self, context, domain, recordset): - # Ensure the records per domain quota is OK - criterion = {'domain_id': domain.id} + def _enforce_record_quota(self, context, zone, recordset): + # Ensure the records per zone quota is OK + criterion = {'zone_id': zone.id} count = self.storage.count_records(context, criterion) - self.quota.limit_check(context, domain.tenant_id, - domain_records=count) + self.quota.limit_check(context, zone.tenant_id, + zone_records=count) # Ensure the records per recordset quota is OK criterion = {'recordset_id': recordset.id} count = self.storage.count_records(context, criterion) - self.quota.limit_check(context, domain.tenant_id, + self.quota.limit_check(context, zone.tenant_id, recordset_records=count) # Misc Methods @@ -757,7 +761,7 @@ class Service(service.RPCService, service.Service): tld = self.storage.delete_tld(context, tld_id) # We need to ensure that if there's no more TLD's we'll not break - # domain creation. + # zone creation. if not self.storage.find_tlds(context, limit=1): self.check_for_tlds = False @@ -830,146 +834,147 @@ class Service(service.RPCService, service.Service): policy.check('count_tenants', context) return self.storage.count_tenants(context) - # Domain Methods + # Zone Methods @notification('dns.domain.create') - @synchronized_domain(new_domain=True) - def create_domain(self, context, domain): + @notification('dns.zone.create') + @synchronized_zone(new_zone=True) + def create_zone(self, context, zone): # TODO(kiall): Refactor this method into *MUCH* smaller chunks. # Default to creating in the current users tenant - if domain.tenant_id is None: - domain.tenant_id = context.tenant + if zone.tenant_id is None: + zone.tenant_id = context.tenant target = { - 'tenant_id': domain.tenant_id, - 'domain_name': domain.name + 'tenant_id': zone.tenant_id, + 'zone_name': zone.name } - policy.check('create_domain', context, target) + policy.check('create_zone', context, target) # Ensure the tenant has enough quota to continue - self._enforce_domain_quota(context, domain.tenant_id) + self._enforce_zone_quota(context, zone.tenant_id) - # Ensure the domain name is valid - self._is_valid_domain_name(context, domain.name) + # Ensure the zone name is valid + self._is_valid_zone_name(context, zone.name) # Ensure TTL is above the minimum - if domain.ttl is not None: - self._is_valid_ttl(context, domain.ttl) + if zone.ttl is not None: + self._is_valid_ttl(context, zone.ttl) # Get the default pool_id default_pool_id = cfg.CONF['service:central'].default_pool_id - if domain.pool_id is None: - domain.pool_id = default_pool_id + if zone.pool_id is None: + zone.pool_id = default_pool_id - # Handle sub-domains appropriately - parent_domain = self._is_subdomain( - context, domain.name, domain.pool_id) - if parent_domain: - if parent_domain.tenant_id == domain.tenant_id: - # Record the Parent Domain ID - domain.parent_domain_id = parent_domain.id + # Handle sub-zones appropriately + parent_zone = self._is_subzone( + context, zone.name, zone.pool_id) + if parent_zone: + if parent_zone.tenant_id == zone.tenant_id: + # Record the Parent Zone ID + zone.parent_zone_id = parent_zone.id else: - raise exceptions.IllegalChildDomain('Unable to create' - 'subdomain in another ' - 'tenants domain') + raise exceptions.IllegalChildZone('Unable to create' + 'subzone in another ' + 'tenants zone') - # Handle super-domains appropriately - subdomains = self._is_superdomain(context, domain.name, domain.pool_id) - if subdomains: - LOG.debug("Domain '{0}' is a superdomain.".format(domain.name)) - for subdomain in subdomains: - if subdomain.tenant_id != domain.tenant_id: - raise exceptions.IllegalParentDomain('Unable to create ' - 'domain because another ' - 'tenant owns a subdomain ' - 'of the domain') - # If this succeeds, subdomain parent IDs will be updated - # after domain is created + # Handle super-zones appropriately + subzones = self._is_superzone(context, zone.name, zone.pool_id) + if subzones: + LOG.debug("Zone '{0}' is a superzone.".format(zone.name)) + for subzone in subzones: + if subzone.tenant_id != zone.tenant_id: + raise exceptions.IllegalParentZone('Unable to create ' + 'zone because another ' + 'tenant owns a subzone ' + 'of the zone') + # If this succeeds, subzone parent IDs will be updated + # after zone is created - # NOTE(kiall): Fetch the servers before creating the domain, this way - # we can prevent domain creation if no servers are + # NOTE(kiall): Fetch the servers before creating the zone, this way + # we can prevent zone creation if no servers are # configured. elevated_context = context.elevated() elevated_context.all_tenants = True - pool = self.storage.get_pool(elevated_context, domain.pool_id) + pool = self.storage.get_pool(elevated_context, zone.pool_id) if len(pool.ns_records) == 0: LOG.critical(_LC('No nameservers configured. ' 'Please create at least one nameserver')) raise exceptions.NoServersConfigured() - if domain.type == 'SECONDARY' and domain.serial is None: - domain.serial = 1 + if zone.type == 'SECONDARY' and zone.serial is None: + zone.serial = 1 - domain = self._create_domain_in_storage(context, domain) + zone = self._create_zone_in_storage(context, zone) - self.pool_manager_api.create_domain(context, domain) + self.pool_manager_api.create_zone(context, zone) - if domain.type == 'SECONDARY': - self.mdns_api.perform_zone_xfr(context, domain) + if zone.type == 'SECONDARY': + self.mdns_api.perform_zone_xfr(context, zone) - # If domain is a superdomain, update subdomains + # If zone is a superzone, update subzones # with new parent IDs - for subdomain in subdomains: - LOG.debug("Updating subdomain '{0}' parent ID " - "using superdomain ID '{1}'" - .format(subdomain.name, domain.id)) - subdomain.parent_domain_id = domain.id - self.update_domain(context, subdomain) + for subzone in subzones: + LOG.debug("Updating subzone '{0}' parent ID " + "using superzone ID '{1}'" + .format(subzone.name, zone.id)) + subzone.parent_zone_id = zone.id + self.update_zone(context, subzone) - return domain + return zone @transaction - def _create_domain_in_storage(self, context, domain): + def _create_zone_in_storage(self, context, zone): - domain.action = 'CREATE' - domain.status = 'PENDING' + zone.action = 'CREATE' + zone.status = 'PENDING' - domain = self.storage.create_domain(context, domain) - pool_ns_records = self.get_domain_servers(context, domain['id']) + zone = self.storage.create_zone(context, zone) + pool_ns_records = self.get_zone_ns_records(context, zone['id']) - # Create the SOA and NS recordsets for the new domain. The SOA - # record will always be the first 'created_at' record for a domain. - self._create_soa(context, domain) - self._create_ns(context, domain, [n.hostname for n in pool_ns_records]) + # Create the SOA and NS recordsets for the new zone. The SOA + # record will always be the first 'created_at' record for a zone. + self._create_soa(context, zone) + self._create_ns(context, zone, [n.hostname for n in pool_ns_records]) - if domain.obj_attr_is_set('recordsets'): - for rrset in domain.recordsets: + if zone.obj_attr_is_set('recordsets'): + for rrset in zone.recordsets: # This allows eventlet to yield, as this looping operation # can be very long-lived. time.sleep(0) self._create_recordset_in_storage( - context, domain, rrset, increment_serial=False) + context, zone, rrset, increment_serial=False) - return domain + return zone - def get_domain(self, context, domain_id): - domain = self.storage.get_domain(context, domain_id) + def get_zone(self, context, zone_id): + zone = self.storage.get_zone(context, zone_id) target = { - 'domain_id': domain_id, - 'domain_name': domain.name, - 'tenant_id': domain.tenant_id + 'zone_id': zone_id, + 'zone_name': zone.name, + 'tenant_id': zone.tenant_id } - policy.check('get_domain', context, target) + policy.check('get_zone', context, target) - return domain + return zone - def get_domain_servers(self, context, domain_id=None, criterion=None): + def get_zone_ns_records(self, context, zone_id=None, criterion=None): - if domain_id is None: - policy.check('get_domain_servers', context) + if zone_id is None: + policy.check('get_zone_ns_records', context) pool_id = cfg.CONF['service:central'].default_pool_id else: - domain = self.storage.get_domain(context, domain_id) + zone = self.storage.get_zone(context, zone_id) target = { - 'domain_id': domain_id, - 'domain_name': domain.name, - 'tenant_id': domain.tenant_id + 'zone_id': zone_id, + 'zone_name': zone.name, + 'tenant_id': zone.tenant_id } - pool_id = domain.pool_id + pool_id = zone.pool_id - policy.check('get_domain_servers', context, target) + policy.check('get_zone_ns_records', context, target) # Need elevated context to get the pool elevated_context = context.elevated() @@ -980,170 +985,172 @@ class Service(service.RPCService, service.Service): return pool.ns_records - def find_domains(self, context, criterion=None, marker=None, limit=None, - sort_key=None, sort_dir=None): + def find_zones(self, context, criterion=None, marker=None, limit=None, + sort_key=None, sort_dir=None): target = {'tenant_id': context.tenant} - policy.check('find_domains', context, target) + policy.check('find_zones', context, target) - return self.storage.find_domains(context, criterion, marker, limit, - sort_key, sort_dir) + return self.storage.find_zones(context, criterion, marker, limit, + sort_key, sort_dir) - def find_domain(self, context, criterion=None): + def find_zone(self, context, criterion=None): target = {'tenant_id': context.tenant} - policy.check('find_domain', context, target) + policy.check('find_zone', context, target) - return self.storage.find_domain(context, criterion) + return self.storage.find_zone(context, criterion) @notification('dns.domain.update') - @synchronized_domain() - def update_domain(self, context, domain, increment_serial=True): + @notification('dns.zone.update') + @synchronized_zone() + def update_zone(self, context, zone, increment_serial=True): # TODO(kiall): Refactor this method into *MUCH* smaller chunks. target = { - 'domain_id': domain.obj_get_original_value('id'), - 'domain_name': domain.obj_get_original_value('name'), - 'tenant_id': domain.obj_get_original_value('tenant_id'), + 'zone_id': zone.obj_get_original_value('id'), + 'zone_name': zone.obj_get_original_value('name'), + 'tenant_id': zone.obj_get_original_value('tenant_id'), } - policy.check('update_domain', context, target) + policy.check('update_zone', context, target) - changes = domain.obj_get_changes() + changes = zone.obj_get_changes() # Ensure immutable fields are not changed if 'tenant_id' in changes: # TODO(kiall): Moving between tenants should be allowed, but the # current code will not take into account that # RecordSets and Records must also be moved. - raise exceptions.BadRequest('Moving a domain between tenants is ' + raise exceptions.BadRequest('Moving a zone between tenants is ' 'not allowed') if 'name' in changes: - raise exceptions.BadRequest('Renaming a domain is not allowed') + raise exceptions.BadRequest('Renaming a zone is not allowed') # Ensure TTL is above the minimum ttl = changes.get('ttl', None) if ttl is not None: self._is_valid_ttl(context, ttl) - domain = self._update_domain_in_storage( - context, domain, increment_serial=increment_serial) + zone = self._update_zone_in_storage( + context, zone, increment_serial=increment_serial) # Fire off a XFR if 'masters' in changes: - self.mdns_api.perform_zone_xfr(context, domain) + self.mdns_api.perform_zone_xfr(context, zone) - self.pool_manager_api.update_domain(context, domain) + self.pool_manager_api.update_zone(context, zone) - return domain + return zone @transaction - def _update_domain_in_storage(self, context, domain, - increment_serial=True): + def _update_zone_in_storage(self, context, zone, + increment_serial=True): - domain.action = 'UPDATE' - domain.status = 'PENDING' + zone.action = 'UPDATE' + zone.status = 'PENDING' if increment_serial: - # _increment_domain_serial increments and updates the domain - domain = self._increment_domain_serial(context, domain) + # _increment_zone_serial increments and updates the zone + zone = self._increment_zone_serial(context, zone) else: - domain = self.storage.update_domain(context, domain) + zone = self.storage.update_zone(context, zone) - return domain + return zone @notification('dns.domain.delete') - @synchronized_domain() - def delete_domain(self, context, domain_id): - """Delete or abandon a domain - On abandon, delete the domain from the DB immediately. + @notification('dns.zone.delete') + @synchronized_zone() + def delete_zone(self, context, zone_id): + """Delete or abandon a zone + On abandon, delete the zone from the DB immediately. Otherwise, set action to DELETE and status to PENDING and poke - Pool Manager's "delete_domain" to update the resolvers. PM will then + Pool Manager's "delete_zone" to update the resolvers. PM will then poke back to set action to NONE and status to DELETED """ - domain = self.storage.get_domain(context, domain_id) + zone = self.storage.get_zone(context, zone_id) target = { - 'domain_id': domain_id, - 'domain_name': domain.name, - 'tenant_id': domain.tenant_id + 'zone_id': zone_id, + 'zone_name': zone.name, + 'tenant_id': zone.tenant_id } if hasattr(context, 'abandon') and context.abandon: - policy.check('abandon_domain', context, target) + policy.check('abandon_zone', context, target) else: - policy.check('delete_domain', context, target) + policy.check('delete_zone', context, target) # Prevent deletion of a zone which has child zones - criterion = {'parent_domain_id': domain_id} + criterion = {'parent_zone_id': zone_id} - if self.storage.count_domains(context, criterion) > 0: - raise exceptions.DomainHasSubdomain('Please delete any subdomains ' - 'before deleting this domain') + if self.storage.count_zones(context, criterion) > 0: + raise exceptions.ZoneHasSubZone('Please delete any subzones ' + 'before deleting this zone') if hasattr(context, 'abandon') and context.abandon: - LOG.info(_LW("Abandoning zone '%(zone)s'") % {'zone': domain.name}) - domain = self.storage.delete_domain(context, domain.id) + LOG.info(_LW("Abandoning zone '%(zone)s'") % {'zone': zone.name}) + zone = self.storage.delete_zone(context, zone.id) else: - domain = self._delete_domain_in_storage(context, domain) - self.pool_manager_api.delete_domain(context, domain) + zone = self._delete_zone_in_storage(context, zone) + self.pool_manager_api.delete_zone(context, zone) - return domain + return zone @transaction - def _delete_domain_in_storage(self, context, domain): - """Set domain action to DELETE and status to PENDING - to have the domain soft-deleted later on + def _delete_zone_in_storage(self, context, zone): + """Set zone action to DELETE and status to PENDING + to have the zone soft-deleted later on """ - domain.action = 'DELETE' - domain.status = 'PENDING' + zone.action = 'DELETE' + zone.status = 'PENDING' - domain = self.storage.update_domain(context, domain) + zone = self.storage.update_zone(context, zone) - return domain + return zone - def purge_domains(self, context, criterion, limit=None): + def purge_zones(self, context, criterion, limit=None): """Purge deleted zones. - :returns: number of purged domains + :returns: number of purged zones """ - policy.check('purge_domains', context, criterion) + policy.check('purge_zones', context, criterion) LOG.debug("Performing purge with limit of %r and criterion of %r" % (limit, criterion)) - return self.storage.purge_domains(context, criterion, limit) + return self.storage.purge_zones(context, criterion, limit) - def xfr_domain(self, context, domain_id): - domain = self.storage.get_domain(context, domain_id) + def xfr_zone(self, context, zone_id): + zone = self.storage.get_zone(context, zone_id) target = { - 'domain_id': domain_id, - 'domain_name': domain.name, - 'tenant_id': domain.tenant_id + 'zone_id': zone_id, + 'zone_name': zone.name, + 'tenant_id': zone.tenant_id } - policy.check('xfr_domain', context, target) + policy.check('xfr_zone', context, target) - if domain.type != 'SECONDARY': + if zone.type != 'SECONDARY': msg = "Can't XFR a non Secondary zone." raise exceptions.BadRequest(msg) # Ensure the format of the servers are correct, then poll the # serial - srv = random.choice(domain.masters) + srv = random.choice(zone.masters) status, serial, retries = self.mdns_api.get_serial_number( - context, domain, srv.host, srv.port, 3, 1, 3, 0) + context, zone, srv.host, srv.port, 3, 1, 3, 0) # Perform XFR if serial's are not equal - if serial > domain.serial: + if serial > zone.serial: msg = _LI( "Serial %(srv_serial)d is not equal to zone's %(serial)d," " performing AXFR") LOG.info( - msg % {"srv_serial": serial, "serial": domain.serial}) - self.mdns_api.perform_zone_xfr(context, domain) + msg % {"srv_serial": serial, "serial": zone.serial}) + self.mdns_api.perform_zone_xfr(context, zone) - def count_domains(self, context, criterion=None): + def count_zones(self, context, criterion=None): if criterion is None: criterion = {} @@ -1151,9 +1158,9 @@ class Service(service.RPCService, service.Service): 'tenant_id': criterion.get('tenant_id', None) } - policy.check('count_domains', context, target) + policy.check('count_zones', context, target) - return self.storage.count_domains(context, criterion) + return self.storage.count_zones(context, criterion) # Report combining all the count reports based on criterion def count_report(self, context, criterion=None): @@ -1161,11 +1168,11 @@ class Service(service.RPCService, service.Service): if criterion is None: # Get all the reports - reports.append({'zones': self.count_domains(context), + reports.append({'zones': self.count_zones(context), 'records': self.count_records(context), 'tenants': self.count_tenants(context)}) elif criterion == 'zones': - reports.append({'zones': self.count_domains(context)}) + reports.append({'zones': self.count_zones(context)}) elif criterion == 'records': reports.append({'records': self.count_records(context)}) elif criterion == 'tenants': @@ -1175,66 +1182,66 @@ class Service(service.RPCService, service.Service): return reports - @notification('dns.domain.touch') - @synchronized_domain() - def touch_domain(self, context, domain_id): - domain = self.storage.get_domain(context, domain_id) + @notification('dns.zone.touch') + @synchronized_zone() + def touch_zone(self, context, zone_id): + zone = self.storage.get_zone(context, zone_id) target = { - 'domain_id': domain_id, - 'domain_name': domain.name, - 'tenant_id': domain.tenant_id + 'zone_id': zone_id, + 'zone_name': zone.name, + 'tenant_id': zone.tenant_id } - policy.check('touch_domain', context, target) + policy.check('touch_zone', context, target) - self._touch_domain_in_storage(context, domain) + self._touch_zone_in_storage(context, zone) - self.pool_manager_api.update_domain(context, domain) + self.pool_manager_api.update_zone(context, zone) - return domain + return zone @transaction - def _touch_domain_in_storage(self, context, domain): + def _touch_zone_in_storage(self, context, zone): - domain = self._increment_domain_serial(context, domain) + zone = self._increment_zone_serial(context, zone) - return domain + return zone # RecordSet Methods @notification('dns.recordset.create') - @synchronized_domain() - def create_recordset(self, context, domain_id, recordset, + @synchronized_zone() + def create_recordset(self, context, zone_id, recordset, increment_serial=True): - domain = self.storage.get_domain(context, domain_id) + zone = self.storage.get_zone(context, zone_id) # Don't allow updates to zones that are being deleted - if domain.action == 'DELETE': + if zone.action == 'DELETE': raise exceptions.BadRequest('Can not update a deleting zone') target = { - 'domain_id': domain_id, - 'domain_name': domain.name, - 'domain_type': domain.type, + 'zone_id': zone_id, + 'zone_name': zone.name, + 'zone_type': zone.type, 'recordset_name': recordset.name, - 'tenant_id': domain.tenant_id, + 'tenant_id': zone.tenant_id, } policy.check('create_recordset', context, target) - recordset, domain = self._create_recordset_in_storage( - context, domain, recordset, increment_serial=increment_serial) + recordset, zone = self._create_recordset_in_storage( + context, zone, recordset, increment_serial=increment_serial) - self.pool_manager_api.update_domain(context, domain) + self.pool_manager_api.update_zone(context, zone) return recordset @transaction - def _create_recordset_in_storage(self, context, domain, recordset, + def _create_recordset_in_storage(self, context, zone, recordset, increment_serial=True): # Ensure the tenant has enough quota to continue - self._enforce_recordset_quota(context, domain) + self._enforce_recordset_quota(context, zone) # Ensure TTL is above the minimum ttl = getattr(recordset, 'ttl', None) @@ -1242,43 +1249,43 @@ class Service(service.RPCService, service.Service): self._is_valid_ttl(context, ttl) # Ensure the recordset name and placement is valid - self._is_valid_recordset_name(context, domain, recordset.name) - self._is_valid_recordset_placement(context, domain, recordset.name, + self._is_valid_recordset_name(context, zone, recordset.name) + self._is_valid_recordset_placement(context, zone, recordset.name, recordset.type) - self._is_valid_recordset_placement_subdomain( - context, domain, recordset.name) + self._is_valid_recordset_placement_subzone( + context, zone, recordset.name) self._is_valid_recordset_records(recordset) if recordset.obj_attr_is_set('records') and len(recordset.records) > 0: if increment_serial: # update the zone's status and increment the serial - domain = self._update_domain_in_storage( - context, domain, increment_serial) + zone = self._update_zone_in_storage( + context, zone, increment_serial) for record in recordset.records: record.action = 'CREATE' record.status = 'PENDING' - record.serial = domain.serial + record.serial = zone.serial - recordset = self.storage.create_recordset(context, domain.id, + recordset = self.storage.create_recordset(context, zone.id, recordset) - # Return the domain too in case it was updated - return (recordset, domain) + # Return the zone too in case it was updated + return (recordset, zone) - def get_recordset(self, context, domain_id, recordset_id): - domain = self.storage.get_domain(context, domain_id) + def get_recordset(self, context, zone_id, recordset_id): + zone = self.storage.get_zone(context, zone_id) recordset = self.storage.get_recordset(context, recordset_id) - # Ensure the domain_id matches the record's domain_id - if domain.id != recordset.domain_id: + # Ensure the zone_id matches the record's zone_id + if zone.id != recordset.zone_id: raise exceptions.RecordSetNotFound() target = { - 'domain_id': domain_id, - 'domain_name': domain.name, + 'zone_id': zone_id, + 'zone_name': zone.name, 'recordset_id': recordset.id, - 'tenant_id': domain.tenant_id, + 'tenant_id': zone.tenant_id, } policy.check('get_recordset', context, target) @@ -1306,20 +1313,20 @@ class Service(service.RPCService, service.Service): return recordset def export_zone(self, context, zone_id): - domain = self.get_domain(context, zone_id) + zone = self.get_zone(context, zone_id) - criterion = {'domain_id': zone_id} + criterion = {'zone_id': zone_id} recordsets = self.storage.find_recordsets_export(context, criterion) return utils.render_template('export-zone.jinja2', - domain=domain, + zone=zone, recordsets=recordsets) @notification('dns.recordset.update') - @synchronized_domain() + @synchronized_zone() def update_recordset(self, context, recordset, increment_serial=True): - domain_id = recordset.obj_get_original_value('domain_id') - domain = self.storage.get_domain(context, domain_id) + zone_id = recordset.obj_get_original_value('zone_id') + zone = self.storage.get_zone(context, zone_id) changes = recordset.obj_get_changes() @@ -1328,8 +1335,8 @@ class Service(service.RPCService, service.Service): raise exceptions.BadRequest('Moving a recordset between tenants ' 'is not allowed') - if 'domain_id' in changes: - raise exceptions.BadRequest('Moving a recordset between domains ' + if 'zone_id' in changes: + raise exceptions.BadRequest('Moving a recordset between zones ' 'is not allowed') if 'type' in changes: @@ -1337,15 +1344,15 @@ class Service(service.RPCService, service.Service): 'allowed') # Don't allow updates to zones that are being deleted - if domain.action == 'DELETE': + if zone.action == 'DELETE': raise exceptions.BadRequest('Can not update a deleting zone') target = { - 'domain_id': recordset.obj_get_original_value('domain_id'), - 'domain_type': domain.type, + 'zone_id': recordset.obj_get_original_value('zone_id'), + 'zone_type': zone.type, 'recordset_id': recordset.obj_get_original_value('id'), - 'domain_name': domain.name, - 'tenant_id': domain.tenant_id + 'zone_name': zone.name, + 'tenant_id': zone.tenant_id } policy.check('update_recordset', context, target) @@ -1353,25 +1360,25 @@ class Service(service.RPCService, service.Service): if recordset.managed and not context.edit_managed_records: raise exceptions.BadRequest('Managed records may not be updated') - recordset, domain = self._update_recordset_in_storage( - context, domain, recordset, increment_serial=increment_serial) + recordset, zone = self._update_recordset_in_storage( + context, zone, recordset, increment_serial=increment_serial) - self.pool_manager_api.update_domain(context, domain) + self.pool_manager_api.update_zone(context, zone) return recordset @transaction - def _update_recordset_in_storage(self, context, domain, recordset, + def _update_recordset_in_storage(self, context, zone, recordset, increment_serial=True): changes = recordset.obj_get_changes() # Ensure the record name is valid - self._is_valid_recordset_name(context, domain, recordset.name) - self._is_valid_recordset_placement(context, domain, recordset.name, + self._is_valid_recordset_name(context, zone, recordset.name) + self._is_valid_recordset_placement(context, zone, recordset.name, recordset.type, recordset.id) - self._is_valid_recordset_placement_subdomain( - context, domain, recordset.name) + self._is_valid_recordset_placement_subzone( + context, zone, recordset.name) self._is_valid_recordset_records(recordset) # Ensure TTL is above the minimum @@ -1381,42 +1388,42 @@ class Service(service.RPCService, service.Service): if increment_serial: # update the zone's status and increment the serial - domain = self._update_domain_in_storage( - context, domain, increment_serial) + zone = self._update_zone_in_storage( + context, zone, increment_serial) if recordset.records: for record in recordset.records: if record.action != 'DELETE': record.action = 'UPDATE' record.status = 'PENDING' - record.serial = domain.serial + record.serial = zone.serial # Update the recordset recordset = self.storage.update_recordset(context, recordset) - return (recordset, domain) + return (recordset, zone) @notification('dns.recordset.delete') - @synchronized_domain() - def delete_recordset(self, context, domain_id, recordset_id, + @synchronized_zone() + def delete_recordset(self, context, zone_id, recordset_id, increment_serial=True): - domain = self.storage.get_domain(context, domain_id) + zone = self.storage.get_zone(context, zone_id) recordset = self.storage.get_recordset(context, recordset_id) - # Ensure the domain_id matches the recordset's domain_id - if domain.id != recordset.domain_id: + # Ensure the zone_id matches the recordset's zone_id + if zone.id != recordset.zone_id: raise exceptions.RecordSetNotFound() # Don't allow updates to zones that are being deleted - if domain.action == 'DELETE': + if zone.action == 'DELETE': raise exceptions.BadRequest('Can not update a deleting zone') target = { - 'domain_id': domain_id, - 'domain_name': domain.name, - 'domain_type': domain.type, + 'zone_id': zone_id, + 'zone_name': zone.name, + 'zone_type': zone.type, 'recordset_id': recordset.id, - 'tenant_id': domain.tenant_id + 'tenant_id': zone.tenant_id } policy.check('delete_recordset', context, target) @@ -1424,33 +1431,33 @@ class Service(service.RPCService, service.Service): if recordset.managed and not context.edit_managed_records: raise exceptions.BadRequest('Managed records may not be updated') - recordset, domain = self._delete_recordset_in_storage( - context, domain, recordset, increment_serial=increment_serial) + recordset, zone = self._delete_recordset_in_storage( + context, zone, recordset, increment_serial=increment_serial) - self.pool_manager_api.update_domain(context, domain) + self.pool_manager_api.update_zone(context, zone) return recordset @transaction - def _delete_recordset_in_storage(self, context, domain, recordset, + def _delete_recordset_in_storage(self, context, zone, recordset, increment_serial=True): if increment_serial: # update the zone's status and increment the serial - domain = self._update_domain_in_storage( - context, domain, increment_serial) + zone = self._update_zone_in_storage( + context, zone, increment_serial) if recordset.records: for record in recordset.records: record.action = 'DELETE' record.status = 'PENDING' - record.serial = domain.serial + record.serial = zone.serial # Update the recordset's action/status and then delete it self.storage.update_recordset(context, recordset) recordset = self.storage.delete_recordset(context, recordset.id) - return (recordset, domain) + return (recordset, zone) def count_recordsets(self, context, criterion=None): if criterion is None: @@ -1466,64 +1473,64 @@ class Service(service.RPCService, service.Service): # Record Methods @notification('dns.record.create') - @synchronized_domain() - def create_record(self, context, domain_id, recordset_id, record, + @synchronized_zone() + def create_record(self, context, zone_id, recordset_id, record, increment_serial=True): - domain = self.storage.get_domain(context, domain_id) + zone = self.storage.get_zone(context, zone_id) # Don't allow updates to zones that are being deleted - if domain.action == 'DELETE': + if zone.action == 'DELETE': raise exceptions.BadRequest('Can not update a deleting zone') recordset = self.storage.get_recordset(context, recordset_id) target = { - 'domain_id': domain_id, - 'domain_name': domain.name, - 'domain_type': domain.type, + 'zone_id': zone_id, + 'zone_name': zone.name, + 'zone_type': zone.type, 'recordset_id': recordset_id, 'recordset_name': recordset.name, - 'tenant_id': domain.tenant_id + 'tenant_id': zone.tenant_id } policy.check('create_record', context, target) - record, domain = self._create_record_in_storage( - context, domain, recordset, record, + record, zone = self._create_record_in_storage( + context, zone, recordset, record, increment_serial=increment_serial) - self.pool_manager_api.update_domain(context, domain) + self.pool_manager_api.update_zone(context, zone) return record @transaction - def _create_record_in_storage(self, context, domain, recordset, record, + def _create_record_in_storage(self, context, zone, recordset, record, increment_serial=True): # Ensure the tenant has enough quota to continue - self._enforce_record_quota(context, domain, recordset) + self._enforce_record_quota(context, zone, recordset) if increment_serial: # update the zone's status and increment the serial - domain = self._update_domain_in_storage( - context, domain, increment_serial) + zone = self._update_zone_in_storage( + context, zone, increment_serial) record.action = 'CREATE' record.status = 'PENDING' - record.serial = domain.serial + record.serial = zone.serial - record = self.storage.create_record(context, domain.id, recordset.id, + record = self.storage.create_record(context, zone.id, recordset.id, record) - return (record, domain) + return (record, zone) - def get_record(self, context, domain_id, recordset_id, record_id): - domain = self.storage.get_domain(context, domain_id) + def get_record(self, context, zone_id, recordset_id, record_id): + zone = self.storage.get_zone(context, zone_id) recordset = self.storage.get_recordset(context, recordset_id) record = self.storage.get_record(context, record_id) - # Ensure the domain_id matches the record's domain_id - if domain.id != record.domain_id: + # Ensure the zone_id matches the record's zone_id + if zone.id != record.zone_id: raise exceptions.RecordNotFound() # Ensure the recordset_id matches the record's recordset_id @@ -1531,12 +1538,12 @@ class Service(service.RPCService, service.Service): raise exceptions.RecordNotFound() target = { - 'domain_id': domain_id, - 'domain_name': domain.name, + 'zone_id': zone_id, + 'zone_name': zone.name, 'recordset_id': recordset_id, 'recordset_name': recordset.name, 'record_id': record.id, - 'tenant_id': domain.tenant_id + 'tenant_id': zone.tenant_id } policy.check('get_record', context, target) @@ -1558,13 +1565,13 @@ class Service(service.RPCService, service.Service): return self.storage.find_record(context, criterion) @notification('dns.record.update') - @synchronized_domain() + @synchronized_zone() def update_record(self, context, record, increment_serial=True): - domain_id = record.obj_get_original_value('domain_id') - domain = self.storage.get_domain(context, domain_id) + zone_id = record.obj_get_original_value('zone_id') + zone = self.storage.get_zone(context, zone_id) # Don't allow updates to zones that are being deleted - if domain.action == 'DELETE': + if zone.action == 'DELETE': raise exceptions.BadRequest('Can not update a deleting zone') recordset_id = record.obj_get_original_value('recordset_id') @@ -1577,8 +1584,8 @@ class Service(service.RPCService, service.Service): raise exceptions.BadRequest('Moving a recordset between tenants ' 'is not allowed') - if 'domain_id' in changes: - raise exceptions.BadRequest('Moving a recordset between domains ' + if 'zone_id' in changes: + raise exceptions.BadRequest('Moving a recordset between zones ' 'is not allowed') if 'recordset_id' in changes: @@ -1586,13 +1593,13 @@ class Service(service.RPCService, service.Service): 'recordsets is not allowed') target = { - 'domain_id': record.obj_get_original_value('domain_id'), - 'domain_name': domain.name, - 'domain_type': domain.type, + 'zone_id': record.obj_get_original_value('zone_id'), + 'zone_name': zone.name, + 'zone_type': zone.type, 'recordset_id': record.obj_get_original_value('recordset_id'), 'recordset_name': recordset.name, 'record_id': record.obj_get_original_value('id'), - 'tenant_id': domain.tenant_id + 'tenant_id': zone.tenant_id } policy.check('update_record', context, target) @@ -1600,46 +1607,46 @@ class Service(service.RPCService, service.Service): if recordset.managed and not context.edit_managed_records: raise exceptions.BadRequest('Managed records may not be updated') - record, domain = self._update_record_in_storage( - context, domain, record, increment_serial=increment_serial) + record, zone = self._update_record_in_storage( + context, zone, record, increment_serial=increment_serial) - self.pool_manager_api.update_domain(context, domain) + self.pool_manager_api.update_zone(context, zone) return record @transaction - def _update_record_in_storage(self, context, domain, record, + def _update_record_in_storage(self, context, zone, record, increment_serial=True): if increment_serial: # update the zone's status and increment the serial - domain = self._update_domain_in_storage( - context, domain, increment_serial) + zone = self._update_zone_in_storage( + context, zone, increment_serial) record.action = 'UPDATE' record.status = 'PENDING' - record.serial = domain.serial + record.serial = zone.serial # Update the record record = self.storage.update_record(context, record) - return (record, domain) + return (record, zone) @notification('dns.record.delete') - @synchronized_domain() - def delete_record(self, context, domain_id, recordset_id, record_id, + @synchronized_zone() + def delete_record(self, context, zone_id, recordset_id, record_id, increment_serial=True): - domain = self.storage.get_domain(context, domain_id) + zone = self.storage.get_zone(context, zone_id) # Don't allow updates to zones that are being deleted - if domain.action == 'DELETE': + if zone.action == 'DELETE': raise exceptions.BadRequest('Can not update a deleting zone') recordset = self.storage.get_recordset(context, recordset_id) record = self.storage.get_record(context, record_id) - # Ensure the domain_id matches the record's domain_id - if domain.id != record.domain_id: + # Ensure the zone_id matches the record's zone_id + if zone.id != record.zone_id: raise exceptions.RecordNotFound() # Ensure the recordset_id matches the record's recordset_id @@ -1647,13 +1654,13 @@ class Service(service.RPCService, service.Service): raise exceptions.RecordNotFound() target = { - 'domain_id': domain_id, - 'domain_name': domain.name, - 'domain_type': domain.type, + 'zone_id': zone_id, + 'zone_name': zone.name, + 'zone_type': zone.type, 'recordset_id': recordset_id, 'recordset_name': recordset.name, 'record_id': record.id, - 'tenant_id': domain.tenant_id + 'tenant_id': zone.tenant_id } policy.check('delete_record', context, target) @@ -1661,29 +1668,29 @@ class Service(service.RPCService, service.Service): if recordset.managed and not context.edit_managed_records: raise exceptions.BadRequest('Managed records may not be updated') - record, domain = self._delete_record_in_storage( - context, domain, record, increment_serial=increment_serial) + record, zone = self._delete_record_in_storage( + context, zone, record, increment_serial=increment_serial) - self.pool_manager_api.update_domain(context, domain) + self.pool_manager_api.update_zone(context, zone) return record @transaction - def _delete_record_in_storage(self, context, domain, record, + def _delete_record_in_storage(self, context, zone, record, increment_serial=True): if increment_serial: # update the zone's status and increment the serial - domain = self._update_domain_in_storage( - context, domain, increment_serial) + zone = self._update_zone_in_storage( + context, zone, increment_serial) record.action = 'DELETE' record.status = 'PENDING' - record.serial = domain.serial + record.serial = zone.serial record = self.storage.update_record(context, record) - return (record, domain) + return (record, zone) def count_records(self, context, criterion=None): if criterion is None: @@ -1697,52 +1704,52 @@ class Service(service.RPCService, service.Service): return self.storage.count_records(context, criterion) # Diagnostics Methods - def _sync_domain(self, context, domain): - return self.pool_manager_api.update_domain(context, domain) + def _sync_zone(self, context, zone): + return self.pool_manager_api.update_zone(context, zone) @transaction - def sync_domains(self, context): - policy.check('diagnostics_sync_domains', context) + def sync_zones(self, context): + policy.check('diagnostics_sync_zones', context) - domains = self.storage.find_domains(context) + zones = self.storage.find_zones(context) results = {} - for domain in domains: - results[domain.id] = self._sync_domain(context, domain) + for zone in zones: + results[zone.id] = self._sync_zone(context, zone) return results @transaction - def sync_domain(self, context, domain_id): - domain = self.storage.get_domain(context, domain_id) + def sync_zone(self, context, zone_id): + zone = self.storage.get_zone(context, zone_id) target = { - 'domain_id': domain_id, - 'domain_name': domain.name, - 'tenant_id': domain.tenant_id + 'zone_id': zone_id, + 'zone_name': zone.name, + 'tenant_id': zone.tenant_id } - policy.check('diagnostics_sync_domain', context, target) + policy.check('diagnostics_sync_zone', context, target) - return self._sync_domain(context, domain) + return self._sync_zone(context, zone) @transaction - def sync_record(self, context, domain_id, recordset_id, record_id): - domain = self.storage.get_domain(context, domain_id) + def sync_record(self, context, zone_id, recordset_id, record_id): + zone = self.storage.get_zone(context, zone_id) recordset = self.storage.get_recordset(context, recordset_id) target = { - 'domain_id': domain_id, - 'domain_name': domain.name, + 'zone_id': zone_id, + 'zone_name': zone.name, 'recordset_id': recordset_id, 'recordset_name': recordset.name, 'record_id': record_id, - 'tenant_id': domain.tenant_id + 'tenant_id': zone.tenant_id } policy.check('diagnostics_sync_record', context, target) - self.pool_manager_api.update_domain(context, domain) + self.pool_manager_api.update_zone(context, zone) def ping(self, context): policy.check('diagnostics_ping', context) @@ -1830,7 +1837,7 @@ class Service(service.RPCService, service.Service): for r in records: msg = 'Deleting record %s for FIP %s' LOG.debug(msg, r['id'], r['managed_resource_id']) - self.delete_record(elevated_context, r['domain_id'], + self.delete_record(elevated_context, r['zone_id'], r['recordset_id'], r['id']) def _format_floatingips(self, context, data, recordsets=None): @@ -1873,8 +1880,8 @@ class Service(service.RPCService, service.Service): if recordset['ttl'] is not None: fip_ptr['ttl'] = recordset['ttl'] else: - zone = self.get_domain( - elevated_context, record['domain_id']) + zone = self.get_zone( + elevated_context, record['zone_id']) fip_ptr['ttl'] = zone['ttl'] fip_ptr['ptrdname'] = record['data'] @@ -1961,9 +1968,9 @@ class Service(service.RPCService, service.Service): # NOTE: Find existing zone or create it.. try: - zone = self.storage.find_domain( + zone = self.storage.find_zone( elevated_context, {'name': zone_name}) - except exceptions.DomainNotFound: + except exceptions.ZoneNotFound: msg = _LI( 'Creating zone for %(fip_id)s:%(region)s - ' '%(fip_addr)s zone %(zonename)s') % \ @@ -1981,8 +1988,8 @@ class Service(service.RPCService, service.Service): 'tenant_id': tenant_id } - zone = self.create_domain( - elevated_context, objects.Domain(**zone_values)) + zone = self.create_zone( + elevated_context, objects.Zone(**zone_values)) record_name = self.network_api.address_name(fip['address']) @@ -2000,7 +2007,7 @@ class Service(service.RPCService, service.Service): recordset.name = recordset_values['name'] recordset.type = recordset_values['type'] recordset.ttl = recordset_values['ttl'] - recordset.domain_id = zone['id'] + recordset.zone_id = zone['id'] recordset = self.update_recordset( elevated_context, recordset=recordset) @@ -2010,14 +2017,14 @@ class Service(service.RPCService, service.Service): for record in recordset.records: self.delete_record( elevated_context, - domain_id=recordset['domain_id'], + zone_id=recordset['zone_id'], recordset_id=recordset['id'], record_id=record['id']) except exceptions.RecordSetNotFound: recordset = self.create_recordset( elevated_context, - domain_id=zone['id'], + zone_id=zone['id'], recordset=objects.RecordSet(**recordset_values)) record_values = { @@ -2033,7 +2040,7 @@ class Service(service.RPCService, service.Service): record = self.create_record( elevated_context, - domain_id=zone['id'], + zone_id=zone['id'], recordset_id=recordset['id'], record=objects.Record(**record_values)) @@ -2068,7 +2075,7 @@ class Service(service.RPCService, service.Service): self.delete_record( elevated_context, - domain_id=record['domain_id'], + zone_id=record['zone_id'], recordset_id=record['recordset_id'], record_id=record['id']) @@ -2085,7 +2092,7 @@ class Service(service.RPCService, service.Service): return self._set_floatingip_reverse( context, region, floatingip_id, values) - # Blacklisted Domains + # Blacklisted zones @notification('dns.blacklist.create') @transaction def create_blacklist(self, context, blacklist): @@ -2208,7 +2215,7 @@ class Service(service.RPCService, service.Service): # After the update, handle new ns_records for ns in create_ns: # Create new NS recordsets for every zone - zones = self.find_domains( + zones = self.find_zones( context=elevated_context, criterion={'pool_id': pool.id, 'action': '!DELETE'}) for z in zones: @@ -2223,7 +2230,7 @@ class Service(service.RPCService, service.Service): ) # Delete the NS record for every zone - zones = self.find_domains( + zones = self.find_zones( context=elevated_context, criterion={'pool_id': pool.id}) for z in zones: @@ -2240,7 +2247,7 @@ class Service(service.RPCService, service.Service): # Make sure that there are no existing zones in the pool elevated_context = context.elevated() elevated_context.all_tenants = True - zones = self.find_domains( + zones = self.find_zones( context=elevated_context, criterion={'pool_id': pool_id, 'action': '!DELETE'}) @@ -2255,41 +2262,41 @@ class Service(service.RPCService, service.Service): # Pool Manager Integration @transaction - def update_status(self, context, domain_id, status, serial): + def update_status(self, context, zone_id, status, serial): """ :param context: Security context information. - :param domain_id: The ID of the designate domain. + :param zone_id: The ID of the designate zone. :param status: The status, 'SUCCESS' or 'ERROR'. - :param serial: The consensus serial number for the domain. + :param serial: The consensus serial number for the zone. :return: None """ # TODO(kiall): If the status is SUCCESS and the zone is already ACTIVE, # we likely don't need to do anything. - self._update_record_status(context, domain_id, status, serial) - self._update_domain_status(context, domain_id, status, serial) + self._update_record_status(context, zone_id, status, serial) + self._update_zone_status(context, zone_id, status, serial) - def _update_domain_status(self, context, domain_id, status, serial): - domain = self.storage.get_domain(context, domain_id) + def _update_zone_status(self, context, zone_id, status, serial): + zone = self.storage.get_zone(context, zone_id) - domain, deleted = self._update_domain_or_record_status( - domain, status, serial) + zone, deleted = self._update_zone_or_record_status( + zone, status, serial) - LOG.debug('Setting domain %s, serial %s: action %s, status %s' - % (domain.id, domain.serial, domain.action, domain.status)) - self.storage.update_domain(context, domain) + LOG.debug('Setting zone %s, serial %s: action %s, status %s' + % (zone.id, zone.serial, zone.action, zone.status)) + self.storage.update_zone(context, zone) # TODO(Ron): Including this to retain the current logic. - # We should NOT be deleting domains. The domain status should be - # used to indicate the domain has been deleted and not the deleted + # We should NOT be deleting zones. The zone status should be + # used to indicate the zone has been deleted and not the deleted # column. The deleted column is needed for unique constraints. if deleted: - # TODO(vinod): Pass a domain to delete_domain rather than id so + # TODO(vinod): Pass a zone to delete_zone rather than id so # that the action, status and serial are updated correctly. - self.storage.delete_domain(context, domain.id) + self.storage.delete_zone(context, zone.id) - def _update_record_status(self, context, domain_id, status, serial): + def _update_record_status(self, context, zone_id, status, serial): criterion = { - 'domain_id': domain_id + 'zone_id': zone_id } if status == 'SUCCESS': @@ -2312,7 +2319,7 @@ class Service(service.RPCService, service.Service): records = self.storage.find_records(context, criterion=criterion) for record in records: - record, deleted = self._update_domain_or_record_status( + record, deleted = self._update_zone_or_record_status( record, status, serial) if record.obj_what_changed(): @@ -2337,36 +2344,36 @@ class Service(service.RPCService, service.Service): self.storage.delete_recordset(context, recordset.id) @staticmethod - def _update_domain_or_record_status(domain_or_record, status, serial): + def _update_zone_or_record_status(zone_or_record, status, serial): deleted = False if status == 'SUCCESS': - if domain_or_record.action in ['CREATE', 'UPDATE'] \ - and domain_or_record.status in ['PENDING', 'ERROR'] \ - and serial >= domain_or_record.serial: - domain_or_record.action = 'NONE' - domain_or_record.status = 'ACTIVE' - elif domain_or_record.action == 'DELETE' \ - and domain_or_record.status in ['PENDING', 'ERROR'] \ - and serial >= domain_or_record.serial: - domain_or_record.action = 'NONE' - domain_or_record.status = 'DELETED' + if zone_or_record.action in ['CREATE', 'UPDATE'] \ + and zone_or_record.status in ['PENDING', 'ERROR'] \ + and serial >= zone_or_record.serial: + zone_or_record.action = 'NONE' + zone_or_record.status = 'ACTIVE' + elif zone_or_record.action == 'DELETE' \ + and zone_or_record.status in ['PENDING', 'ERROR'] \ + and serial >= zone_or_record.serial: + zone_or_record.action = 'NONE' + zone_or_record.status = 'DELETED' deleted = True elif status == 'ERROR': - if domain_or_record.status == 'PENDING' \ - and (serial >= domain_or_record.serial or serial == 0): - domain_or_record.status = 'ERROR' + if zone_or_record.status == 'PENDING' \ + and (serial >= zone_or_record.serial or serial == 0): + zone_or_record.status = 'ERROR' - elif status == 'NO_DOMAIN': - if domain_or_record.action in ['CREATE', 'UPDATE']: - domain_or_record.action = 'CREATE' - domain_or_record.status = 'ERROR' - elif domain_or_record.action == 'DELETE': - domain_or_record.action = 'NONE' - domain_or_record.status = 'DELETED' + elif status == 'NO_zone': + if zone_or_record.action in ['CREATE', 'UPDATE']: + zone_or_record.action = 'CREATE' + zone_or_record.status = 'ERROR' + elif zone_or_record.action == 'DELETE': + zone_or_record.action = 'NONE' + zone_or_record.status = 'DELETED' deleted = True - return domain_or_record, deleted + return zone_or_record, deleted # Zone Transfers def _transfer_key_generator(self, size=8): @@ -2381,7 +2388,7 @@ class Service(service.RPCService, service.Service): elevated_context.all_tenants = True # get zone - zone = self.get_domain(context, zone_transfer_request.domain_id) + zone = self.get_zone(context, zone_transfer_request.zone_id) # Don't allow transfers for zones that are being deleted if zone.action == 'DELETE': @@ -2444,8 +2451,8 @@ class Service(service.RPCService, service.Service): @transaction def update_zone_transfer_request(self, context, zone_transfer_request): - if 'domain_id' in zone_transfer_request.obj_what_changed(): - raise exceptions.InvalidOperation('Domain cannot be changed') + if 'zone_id' in zone_transfer_request.obj_what_changed(): + raise exceptions.InvalidOperation('Zone cannot be changed') target = { 'tenant_id': zone_transfer_request.tenant_id, @@ -2478,7 +2485,7 @@ class Service(service.RPCService, service.Service): zone_transfer_request = self.get_zone_transfer_request( context, zone_transfer_accept.zone_transfer_request_id) - zone_transfer_accept.domain_id = zone_transfer_request.domain_id + zone_transfer_accept.zone_id = zone_transfer_request.zone_id if zone_transfer_request.status != 'ACTIVE': if zone_transfer_request.status == 'COMPLETE': @@ -2504,16 +2511,16 @@ class Service(service.RPCService, service.Service): context, zone_transfer_accept) try: - domain = self.storage.get_domain( + zone = self.storage.get_zone( elevated_context, - zone_transfer_request.domain_id) + zone_transfer_request.zone_id) # Don't allow transfers for zones that are being deleted - if domain.action == 'DELETE': + if zone.action == 'DELETE': raise exceptions.BadRequest('Can not transfer a deleting zone') - domain.tenant_id = zone_transfer_accept.tenant_id - self.storage.update_domain(elevated_context, domain) + zone.tenant_id = zone_transfer_accept.tenant_id + self.storage.update_zone(elevated_context, zone) except Exception: created_zone_transfer_accept.status = 'ERROR' @@ -2590,7 +2597,7 @@ class Service(service.RPCService, service.Service): values = { 'status': 'PENDING', 'message': None, - 'domain_id': None, + 'zone_id': None, 'tenant_id': context.tenant, 'task_type': 'IMPORT' } @@ -2610,7 +2617,7 @@ class Service(service.RPCService, service.Service): # Dnspython needs a str instead of a unicode object if six.PY2: request_body = str(request_body) - domain = None + zone = None try: dnspython_zone = dnszone.from_text( request_body, @@ -2619,12 +2626,12 @@ class Service(service.RPCService, service.Service): # Dont check origin, we allow missing NS records # (missing SOA records are taken care of in _create_zone). check_origin=False) - domain = dnsutils.from_dnspython_zone(dnspython_zone) - domain.type = 'PRIMARY' + zone = dnsutils.from_dnspython_zone(dnspython_zone) + zone.type = 'PRIMARY' - for rrset in list(domain.recordsets): + for rrset in list(zone.recordsets): if rrset.type in ('NS', 'SOA'): - domain.recordsets.remove(rrset) + zone.recordsets.remove(rrset) except dnszone.UnknownOrigin: zone_import.message = ('The $ORIGIN statement is required and' @@ -2641,21 +2648,21 @@ class Service(service.RPCService, service.Service): zone_import.message = 'An undefined error occured.' zone_import.status = 'ERROR' - return domain, zone_import + return zone, zone_import # Execute the import in a real Python thread - domain, zone_import = tpool.execute(_import, self, context, + zone, zone_import = tpool.execute(_import, self, context, zone_import, request_body) - # If the zone import was valid, create the domain + # If the zone import was valid, create the zone if zone_import.status != 'ERROR': try: - zone = self.create_domain(context, domain) + zone = self.create_zone(context, zone) zone_import.status = 'COMPLETE' - zone_import.domain_id = zone.id + zone_import.zone_id = zone.id zone_import.message = '%(name)s imported' % {'name': zone.name} - except exceptions.DuplicateDomain: + except exceptions.DuplicateZone: zone_import.status = 'ERROR' zone_import.message = 'Duplicate zone.' except exceptions.InvalidTTL as e: @@ -2708,8 +2715,8 @@ class Service(service.RPCService, service.Service): # Zone Export Methods @notification('dns.zone_export.create') def create_zone_export(self, context, zone_id): - # Try getting the domain to ensure it exists - domain = self.storage.get_domain(context, zone_id) + # Try getting the zone to ensure it exists + zone = self.storage.get_zone(context, zone_id) target = {'tenant_id': context.tenant} policy.check('create_zone_export', context, target) @@ -2717,7 +2724,7 @@ class Service(service.RPCService, service.Service): values = { 'status': 'PENDING', 'message': None, - 'domain_id': zone_id, + 'zone_id': zone_id, 'tenant_id': context.tenant, 'task_type': 'EXPORT' } @@ -2726,7 +2733,7 @@ class Service(service.RPCService, service.Service): created_zone_export = self.storage.create_zone_export(context, zone_export) - self.zone_manager_api.start_zone_export(context, domain, + self.zone_manager_api.start_zone_export(context, zone, created_zone_export) return created_zone_export diff --git a/designate/context.py b/designate/context.py index dfe98dde..5f446564 100644 --- a/designate/context.py +++ b/designate/context.py @@ -169,7 +169,7 @@ class DesignateContext(context.RequestContext): @abandon.setter def abandon(self, value): if value: - policy.check('abandon_domain', self) + policy.check('abandon_zone', self) self._abandon = value @property diff --git a/designate/dnsutils.py b/designate/dnsutils.py index 6d8634f3..5c65165a 100644 --- a/designate/dnsutils.py +++ b/designate/dnsutils.py @@ -281,7 +281,7 @@ def from_dnspython_zone(dnspython_zone): 'expire': soa[0].expire } - zone = objects.Domain(**values) + zone = objects.Zone(**values) rrsets = dnspyrecords_to_recordsetlist(dnspython_zone.nodes) zone.recordsets = rrsets @@ -348,7 +348,7 @@ def do_axfr(zone_name, servers, timeout=None, source=None): LOG.error(msg % log_info) continue except dns.exception.FormError: - msg = _LE("Domain %(name)s is not present on %(host)s." + msg = _LE("Zone %(name)s is not present on %(host)s." "Trying next server.") LOG.error(msg % log_info) except socket.error: diff --git a/designate/exceptions.py b/designate/exceptions.py index 1d3a9d67..06a5f7ff 100644 --- a/designate/exceptions.py +++ b/designate/exceptions.py @@ -179,9 +179,9 @@ class UnsupportedContentType(BadRequest): error_type = 'unsupported_content_type' -class InvalidDomainName(Base): +class InvalidZoneName(Base): error_code = 400 - error_type = 'invalid_domain_name' + error_type = 'invalid_zone_name' expected = True @@ -205,9 +205,9 @@ class InvalidTTL(Base): error_type = 'invalid_ttl' -class DomainHasSubdomain(Base): +class ZoneHasSubZone(Base): error_code = 400 - error_type = 'domain_has_subdomain' + error_type = 'zone_has_sub_zone' class Forbidden(Base): @@ -216,11 +216,11 @@ class Forbidden(Base): expected = True -class IllegalChildDomain(Forbidden): +class IllegalChildZone(Forbidden): error_type = 'illegal_child' -class IllegalParentDomain(Forbidden): +class IllegalParentZone(Forbidden): error_type = 'illegal_parent' @@ -246,8 +246,8 @@ class DuplicateTsigKey(Duplicate): error_type = 'duplicate_tsigkey' -class DuplicateDomain(Duplicate): - error_type = 'duplicate_domain' +class DuplicateZone(Duplicate): + error_type = 'duplicate_zone' class DuplicateTld(Duplicate): @@ -278,8 +278,8 @@ class DuplicatePoolAttribute(Duplicate): error_type = 'duplicate_pool_attribute' -class DuplicateDomainAttribute(Duplicate): - error_type = 'duplicate_domain_attribute' +class DuplicateZoneAttribute(Duplicate): + error_type = 'duplicate_zone_attribute' class DuplicatePoolNsRecord(Duplicate): @@ -330,16 +330,16 @@ class BlacklistNotFound(NotFound): error_type = 'blacklist_not_found' -class DomainNotFound(NotFound): - error_type = 'domain_not_found' +class ZoneNotFound(NotFound): + error_type = 'zone_not_found' -class DomainMasterNotFound(NotFound): - error_type = 'domain_master_not_found' +class ZoneMasterNotFound(NotFound): + error_type = 'zone_master_not_found' -class DomainAttributeNotFound(NotFound): - error_type = 'domain_attribute_not_found' +class ZoneAttributeNotFound(NotFound): + error_type = 'zone_attribute_not_found' class TldNotFound(NotFound): diff --git a/designate/manage/akamai.py b/designate/manage/akamai.py index 0e30fbc1..34cf838b 100644 --- a/designate/manage/akamai.py +++ b/designate/manage/akamai.py @@ -61,7 +61,7 @@ class AkamaiCommands(base.Commands): client = impl_akamai.EnhancedDNSClient( target.options.get("username"), target.options.get("password")) - zone = self.central_api.find_domain(self.context, {"name": zone_name}) + zone = self.central_api.find_zone(self.context, {"name": zone_name}) akamai_zone = client.getZone(zone_name) print("Designate zone\n%s" % pformat(zone.to_dict())) @@ -70,7 +70,7 @@ class AkamaiCommands(base.Commands): @base.args('pool-id', help="Pool to Sync", type=str) @base.args('pool-target-id', help="Pool Target to Sync", type=str) @base.args('--batch-size', default=20, type=int) - def sync_domains(self, pool_id, pool_target_id, batch_size): + def sync_zones(self, pool_id, pool_target_id, batch_size): pool, target = self._get_config(pool_id, pool_target_id) client = impl_akamai.EnhancedDNSClient( @@ -82,7 +82,7 @@ class AkamaiCommands(base.Commands): marker = None while (marker is not False): - zones = self.central_api.find_domains( + zones = self.central_api.find_zones( self.context, criterion, limit=batch_size, marker=marker) update = [] diff --git a/designate/mdns/handler.py b/designate/mdns/handler.py index 8bb4f698..8a61c432 100644 --- a/designate/mdns/handler.py +++ b/designate/mdns/handler.py @@ -116,8 +116,8 @@ class RequestHandler(xfr.XFRMixin): } try: - domain = self.storage.find_domain(context, criterion) - except exceptions.DomainNotFound: + zone = self.storage.find_zone(context, criterion) + except exceptions.ZoneNotFound: response.set_rcode(dns.rcode.NOTAUTH) yield response raise StopIteration @@ -127,11 +127,11 @@ class RequestHandler(xfr.XFRMixin): # We check if the src_master which is the assumed master for the zone # that is sending this NOTIFY OP is actually the master. If it's not # We'll reply but don't do anything with the NOTIFY. - master_addr = domain.get_master_by_ip(notify_addr) + master_addr = zone.get_master_by_ip(notify_addr) if not master_addr: msg = _LW("NOTIFY for %(name)s from non-master server " "%(addr)s, ignoring.") - LOG.warn(msg % {"name": domain.name, "addr": notify_addr}) + LOG.warn(msg % {"name": zone.name, "addr": notify_addr}) response.set_rcode(dns.rcode.REFUSED) yield response raise StopIteration @@ -140,17 +140,17 @@ class RequestHandler(xfr.XFRMixin): # According to RFC we should query the server that sent the NOTIFY resolver.nameservers = [notify_addr] - soa_answer = resolver.query(domain.name, 'SOA') + soa_answer = resolver.query(zone.name, 'SOA') soa_serial = soa_answer[0].serial - if soa_serial == domain.serial: + if soa_serial == zone.serial: msg = _LI("Serial %(serial)s is the same for master and us for " - "%(domain_id)s") - LOG.info(msg % {"serial": soa_serial, "domain_id": domain.id}) + "%(zone_id)s") + LOG.info(msg % {"serial": soa_serial, "zone_id": zone.id}) else: - msg = _LI("Scheduling AXFR for %(domain_id)s from %(master_addr)s") - info = {"domain_id": domain.id, "master_addr": master_addr} + msg = _LI("Scheduling AXFR for %(zone_id)s from %(master_addr)s") + info = {"zone_id": zone.id, "master_addr": master_addr} LOG.info(msg % info) - self.tg.add_thread(self.domain_sync, context, domain, + self.tg.add_thread(self.zone_sync, context, zone, [master_addr]) response.flags |= dns.flags.AA @@ -170,7 +170,7 @@ class RequestHandler(xfr.XFRMixin): return response - def _domain_criterion_from_request(self, request, criterion=None): + def _zone_criterion_from_request(self, request, criterion=None): """Builds a bare criterion dict based on the request attributes""" criterion = criterion or {} @@ -197,12 +197,12 @@ class RequestHandler(xfr.XFRMixin): return criterion - def _convert_to_rrset(self, domain, recordset): - # Fetch the domain or the config ttl if the recordset ttl is null + def _convert_to_rrset(self, zone, recordset): + # Fetch the zone or the config ttl if the recordset ttl is null if recordset.ttl: ttl = recordset.ttl else: - ttl = domain.ttl + ttl = zone.ttl # construct rdata from all the records rdata = [] @@ -233,12 +233,12 @@ class RequestHandler(xfr.XFRMixin): # TODO(vinod) once validation is separated from the api, # validate the parameters try: - criterion = self._domain_criterion_from_request( + criterion = self._zone_criterion_from_request( request, {'name': q_rrset.name.to_text()}) - domain = self.storage.find_domain(context, criterion) + zone = self.storage.find_zone(context, criterion) - except exceptions.DomainNotFound: - LOG.warning(_LW("DomainNotFound while handling axfr request. " + except exceptions.ZoneNotFound: + LOG.warning(_LW("ZoneNotFound while handling axfr request. " "Question was %(qr)s") % {'qr': q_rrset}) yield self._handle_query_error(request, dns.rcode.REFUSED) @@ -252,11 +252,11 @@ class RequestHandler(xfr.XFRMixin): raise StopIteration # The AXFR response needs to have a SOA at the beginning and end. - criterion = {'domain_id': domain.id, 'type': 'SOA'} + criterion = {'zone_id': zone.id, 'type': 'SOA'} soa_records = self.storage.find_recordsets_axfr(context, criterion) # Get all the records other than SOA - criterion = {'domain_id': domain.id, 'type': '!SOA'} + criterion = {'zone_id': zone.id, 'type': '!SOA'} records = self.storage.find_recordsets_axfr(context, criterion) # Place the SOA RRSet at the front and end of the RRSet list @@ -296,7 +296,7 @@ class RequestHandler(xfr.XFRMixin): # Build a DNSPython RRSet from the RR rrset = dns.rrset.from_text_list( str(record[3]), # name - int(record[2]) if record[2] is not None else domain.ttl, # ttl + int(record[2]) if record[2] is not None else zone.ttl, # ttl dns.rdataclass.IN, # class str(record[1]), # rrtype [str(record[4])], # rdata @@ -309,10 +309,10 @@ class RequestHandler(xfr.XFRMixin): if renderer.counts[dns.renderer.ANSWER] == 0: # We've received a TooBig from the first attempted RRSet in # this packet. Log a warning and abort the AXFR. - LOG.warning(_LW('Aborted AXFR of %(domain)s, a single RR ' + LOG.warning(_LW('Aborted AXFR of %(zone)s, a single RR ' '(%(rrset_type)s %(rrset_name)s) ' 'exceeded the max message size.'), - {'domain': domain.name, + {'zone': zone.name, 'rrset_type': record[1], 'rrset_name': record[3]}) @@ -356,17 +356,17 @@ class RequestHandler(xfr.XFRMixin): criterion = { 'name': q_rrset.name.to_text(), 'type': dns.rdatatype.to_text(q_rrset.rdtype), - 'domains_deleted': False + 'zones_deleted': False } recordset = self.storage.find_recordset(context, criterion) try: - criterion = self._domain_criterion_from_request( - request, {'id': recordset.domain_id}) - domain = self.storage.find_domain(context, criterion) + criterion = self._zone_criterion_from_request( + request, {'id': recordset.zone_id}) + zone = self.storage.find_zone(context, criterion) - except exceptions.DomainNotFound: - LOG.warning(_LW("DomainNotFound while handling query request" + except exceptions.ZoneNotFound: + LOG.warning(_LW("ZoneNotFound while handling query request" ". Question was %(qr)s") % {'qr': q_rrset}) yield self._handle_query_error(request, dns.rcode.REFUSED) @@ -379,7 +379,7 @@ class RequestHandler(xfr.XFRMixin): yield self._handle_query_error(request, dns.rcode.REFUSED) raise StopIteration - r_rrset = self._convert_to_rrset(domain, recordset) + r_rrset = self._convert_to_rrset(zone, recordset) response.set_rcode(dns.rcode.NOERROR) response.answer = [r_rrset] # For all the data stored in designate mdns is Authoritative @@ -396,9 +396,9 @@ class RequestHandler(xfr.XFRMixin): # However, an authoritative nameserver shouldn't return NXDOMAIN # for a zone it isn't authoritative for. It would be more # appropriate for it to return REFUSED. It should still return - # NXDOMAIN if it is authoritative for a domain but the FQDN doesn't + # NXDOMAIN if it is authoritative for a zone but the FQDN doesn't # exist, like abcdef.rackspace.com. Of course, a wildcard within a - # domain would mean that NXDOMAIN isn't ever returned for a domain. + # zone would mean that NXDOMAIN isn't ever returned for a zone. # # To simply things currently this returns a REFUSED in all cases. # If zone transfers needs different errors, we could revisit this. diff --git a/designate/mdns/notify.py b/designate/mdns/notify.py index ac632bab..1df8b2f2 100644 --- a/designate/mdns/notify.py +++ b/designate/mdns/notify.py @@ -40,11 +40,11 @@ class NotifyEndpoint(base.BaseEndpoint): RPC_API_VERSION = '2.0' RPC_API_NAMESPACE = 'notify' - def notify_zone_changed(self, context, domain, host, port, timeout, + def notify_zone_changed(self, context, zone, host, port, timeout, retry_interval, max_retries, delay): """ :param context: The user context. - :param domain: The designate domain object. This contains the domain + :param zone: The designate zone object. This contains the zone name. :param host: A notify is sent to this host. :param port: A notify is sent to this port. @@ -61,15 +61,15 @@ class NotifyEndpoint(base.BaseEndpoint): """ time.sleep(delay) return self._make_and_send_dns_message( - domain, host, port, timeout, retry_interval, max_retries, + zone, host, port, timeout, retry_interval, max_retries, notify=True) - def poll_for_serial_number(self, context, domain, nameserver, timeout, + def poll_for_serial_number(self, context, zone, nameserver, timeout, retry_interval, max_retries, delay): """ :param context: The user context. - :param domain: The designate domain object. This contains the domain - name. domain.serial = expected_serial + :param zone: The designate zone object. This contains the zone + name. zone.serial = expected_serial :param nameserver: Destination for the poll :param timeout: The time (in seconds) to wait for a SOA response from nameserver. @@ -81,17 +81,17 @@ class NotifyEndpoint(base.BaseEndpoint): :return: The pool manager is informed of the status with update_status. """ (status, actual_serial, retries) = self.get_serial_number( - context, domain, nameserver.host, nameserver.port, timeout, + context, zone, nameserver.host, nameserver.port, timeout, retry_interval, max_retries, delay) self.pool_manager_api.update_status( - context, domain, nameserver, status, actual_serial) + context, zone, nameserver, status, actual_serial) - def get_serial_number(self, context, domain, host, port, timeout, + def get_serial_number(self, context, zone, host, port, timeout, retry_interval, max_retries, delay): """ :param context: The user context. - :param domain: The designate domain object. This contains the domain - name. domain.serial = expected_serial + :param zone: The designate zone object. This contains the zone + name. zone.serial = expected_serial :param host: A notify is sent to this host. :param port: A notify is sent to this port. :param timeout: The time (in seconds) to wait for a SOA response from @@ -115,26 +115,26 @@ class NotifyEndpoint(base.BaseEndpoint): time.sleep(delay) while (True): (response, retry) = self._make_and_send_dns_message( - domain, host, port, timeout, retry_interval, retries) + zone, host, port, timeout, retry_interval, retries) if response and response.rcode() in ( dns.rcode.NXDOMAIN, dns.rcode.REFUSED, dns.rcode.SERVFAIL): status = 'NO_DOMAIN' elif response and len(response.answer) == 1 \ - and str(response.answer[0].name) == str(domain.name) \ + and str(response.answer[0].name) == str(zone.name) \ and response.answer[0].rdclass == dns.rdataclass.IN \ and response.answer[0].rdtype == dns.rdatatype.SOA: # parse the SOA response and get the serial number rrset = response.answer[0] actual_serial = rrset.to_rdataset().items[0].serial - if actual_serial is None or actual_serial < domain.serial: + if actual_serial is None or actual_serial < zone.serial: # TODO(vinod): Account for serial number wrap around. retries = retries - retry LOG.warn(_LW("Got lower serial for '%(zone)s' to '%(host)s:" "%(port)s'. Expected:'%(es)d'. Got:'%(as)s'." "Retries left='%(retries)d'") % - {'zone': domain.name, 'host': host, - 'port': port, 'es': domain.serial, + {'zone': zone.name, 'host': host, + 'port': port, 'es': zone.serial, 'as': actual_serial, 'retries': retries}) if retries > 0: # retry again @@ -150,10 +150,10 @@ class NotifyEndpoint(base.BaseEndpoint): # Return retries for testing purposes. return (status, actual_serial, retries) - def _make_and_send_dns_message(self, domain, host, port, timeout, + def _make_and_send_dns_message(self, zone, host, port, timeout, retry_interval, max_retries, notify=False): """ - :param domain: The designate domain object. This contains the domain + :param zone: The designate zone object. This contains the zone name. :param host: The destination host for the dns message. :param port: The destination port for the dns message. @@ -168,7 +168,7 @@ class NotifyEndpoint(base.BaseEndpoint): response is the response on success or None on failure. current_retry is the current retry number """ - dns_message = self._make_dns_message(domain.name, notify=notify) + dns_message = self._make_dns_message(zone.name, notify=notify) retry = 0 response = None @@ -178,7 +178,7 @@ class NotifyEndpoint(base.BaseEndpoint): LOG.info(_LI("Sending '%(msg)s' for '%(zone)s' to '%(server)s:" "%(port)d'.") % {'msg': 'NOTIFY' if notify else 'SOA', - 'zone': domain.name, 'server': host, + 'zone': zone.name, 'server': host, 'port': port}) response = self._send_dns_message( dns_message, host, port, timeout) @@ -188,7 +188,7 @@ class NotifyEndpoint(base.BaseEndpoint): "'%(zone)s' to '%(server)s:%(port)d'. Timeout=" "'%(timeout)d' seconds. Retry='%(retry)d'") % {'msg': 'NOTIFY' if notify else 'SOA', - 'zone': domain.name, 'server': host, + 'zone': zone.name, 'server': host, 'port': port, 'timeout': timeout, 'retry': retry}) response = None @@ -200,7 +200,7 @@ class NotifyEndpoint(base.BaseEndpoint): "for '%(zone)s' to '%(server)s:%(port)d'. Timeout" "='%(timeout)d' seconds. Retry='%(retry)d'") % {'msg': 'NOTIFY' if notify else 'SOA', - 'zone': domain.name, 'server': host, + 'zone': zone.name, 'server': host, 'port': port, 'timeout': timeout, 'retry': retry}) response = None @@ -210,7 +210,7 @@ class NotifyEndpoint(base.BaseEndpoint): elif response.rcode() in (dns.rcode.NXDOMAIN, dns.rcode.REFUSED, dns.rcode.SERVFAIL): LOG.info(_LI("%(zone)s not found on %(server)s:%(port)d") % - {'zone': domain.name, 'server': host, + {'zone': zone.name, 'server': host, 'port': port}) break elif not (response.flags & dns.flags.AA) or dns.rcode.from_flags( @@ -219,7 +219,7 @@ class NotifyEndpoint(base.BaseEndpoint): "send '%(msg)s' for '%(zone)s' to '%(server)s:" "%(port)d'.\nResponse message:\n%(resp)s\n") % {'msg': 'NOTIFY' if notify else 'SOA', - 'zone': domain.name, 'server': host, + 'zone': zone.name, 'server': host, 'port': port, 'resp': str(response)}) response = None break diff --git a/designate/mdns/rpcapi.py b/designate/mdns/rpcapi.py index 7c9e7985..e71dea4a 100644 --- a/designate/mdns/rpcapi.py +++ b/designate/mdns/rpcapi.py @@ -69,51 +69,51 @@ class MdnsAPI(object): MDNS_API = cls() return MDNS_API - def notify_zone_changed(self, context, domain, host, port, timeout, + def notify_zone_changed(self, context, zone, host, port, timeout, retry_interval, max_retries, delay): LOG.info(_LI("notify_zone_changed: Calling mdns for zone '%(zone)s', " "serial '%(serial)s' to nameserver '%(host)s:%(port)s'") % - {'zone': domain.name, 'serial': domain.serial, + {'zone': zone.name, 'serial': zone.serial, 'host': host, 'port': port}) # The notify_zone_changed method is a cast rather than a call since the # caller need not wait for the notify to complete. return self.notify_client.cast( - context, 'notify_zone_changed', domain=domain, + context, 'notify_zone_changed', zone=zone, host=host, port=port, timeout=timeout, retry_interval=retry_interval, max_retries=max_retries, delay=delay) - def poll_for_serial_number(self, context, domain, nameserver, timeout, + def poll_for_serial_number(self, context, zone, nameserver, timeout, retry_interval, max_retries, delay): LOG.info( _LI("poll_for_serial_number: Calling mdns for zone '%(zone)s', " "serial '%(serial)s' on nameserver '%(host)s:%(port)s'") % - {'zone': domain.name, 'serial': domain.serial, + {'zone': zone.name, 'serial': zone.serial, 'host': nameserver.host, 'port': nameserver.port}) # The poll_for_serial_number method is a cast rather than a call since # the caller need not wait for the poll to complete. Mdns informs pool # manager of the return value using update_status return self.notify_client.cast( - context, 'poll_for_serial_number', domain=domain, + context, 'poll_for_serial_number', zone=zone, nameserver=nameserver, timeout=timeout, retry_interval=retry_interval, max_retries=max_retries, delay=delay) - def get_serial_number(self, context, domain, host, port, timeout, + def get_serial_number(self, context, zone, host, port, timeout, retry_interval, max_retries, delay): LOG.info( _LI("get_serial_number: Calling mdns for zone '%(zone)s', serial " "%(serial)s' on nameserver '%(host)s:%(port)s'") % - {'zone': domain.name, 'serial': domain.serial, + {'zone': zone.name, 'serial': zone.serial, 'host': host, 'port': port}) cctxt = self.notify_client.prepare() return cctxt.call( - context, 'get_serial_number', domain=domain, + context, 'get_serial_number', zone=zone, host=host, port=port, timeout=timeout, retry_interval=retry_interval, max_retries=max_retries, delay=delay) - def perform_zone_xfr(self, context, domain): + def perform_zone_xfr(self, context, zone): LOG.info(_LI("perform_zone_xfr: Calling mdns for zone %(zone)s") % - {"zone": domain.name}) - return self.xfr_client.cast(context, 'perform_zone_xfr', domain=domain) + {"zone": zone.name}) + return self.xfr_client.cast(context, 'perform_zone_xfr', zone=zone) diff --git a/designate/mdns/xfr.py b/designate/mdns/xfr.py index 26bc81cc..f3df2954 100644 --- a/designate/mdns/xfr.py +++ b/designate/mdns/xfr.py @@ -29,29 +29,29 @@ class XFRMixin(object): """ Utility mixin that holds common methods for XFR functionality. """ - def domain_sync(self, context, domain, servers=None): - servers = servers or domain.masters + def zone_sync(self, context, zone, servers=None): + servers = servers or zone.masters servers = servers.to_list() timeout = cfg.CONF["service:mdns"].xfr_timeout try: - dnspython_zone = dnsutils.do_axfr(domain.name, servers, + dnspython_zone = dnsutils.do_axfr(zone.name, servers, timeout=timeout) except exceptions.XFRFailure as e: LOG.warning(e.message) return zone = dnsutils.from_dnspython_zone(dnspython_zone) - domain.update(zone) + zone.update(zone) - domain.transferred_at = timeutils.utcnow() + zone.transferred_at = timeutils.utcnow() - self.central_api.update_domain(context, domain, increment_serial=False) + self.central_api.update_zone(context, zone, increment_serial=False) class XfrEndpoint(base.BaseEndpoint, XFRMixin): RPC_API_VERSION = '1.0' RPC_API_NAMESPACE = 'xfr' - def perform_zone_xfr(self, context, domain): - self.domain_sync(context, domain) + def perform_zone_xfr(self, context, zone): + self.zone_sync(context, zone) diff --git a/designate/notification_handler/base.py b/designate/notification_handler/base.py index 2cc62e47..91b28c0a 100644 --- a/designate/notification_handler/base.py +++ b/designate/notification_handler/base.py @@ -57,14 +57,14 @@ class NotificationHandler(ExtensionPlugin): def process_notification(self, context, event_type, payload): """Processes a given notification""" - def get_domain(self, domain_id): + def get_zone(self, zone_id): """ - Return the domain for this context + Return the zone for this context """ context = DesignateContext.get_admin_context(all_tenants=True) - return self.central_api.get_domain(context, domain_id) + return self.central_api.get_zone(context, zone_id) - def _find_or_create_recordset(self, context, domain_id, name, type, + def _find_or_create_recordset(self, context, zone_id, name, type, ttl=None): name = name.encode('idna').decode('utf-8') @@ -76,12 +76,12 @@ class NotificationHandler(ExtensionPlugin): 'ttl': ttl, } recordset = self.central_api.create_recordset( - context, domain_id, RecordSet(**values)) + context, zone_id, RecordSet(**values)) except exceptions.DuplicateRecordSet: # Fetch the existing recordset recordset = self.central_api.find_recordset(context, { - 'domain_id': domain_id, + 'zone_id': zone_id, 'name': name, 'type': type, }) @@ -106,7 +106,7 @@ class BaseAddressHandler(NotificationHandler): data["octet%s" % i] = ip_data[i] return data - def _create(self, addresses, extra, domain_id, managed=True, + def _create(self, addresses, extra, zone_id, managed=True, resource_type=None, resource_id=None): """ Create a a record from addresses @@ -123,13 +123,13 @@ class BaseAddressHandler(NotificationHandler): 'Deprecation notice: Unmanaged designate-sink records are ' 'being deprecated please update the call ' 'to remove managed=False')) - LOG.debug('Using DomainID: %s' % domain_id) - domain = self.get_domain(domain_id) - LOG.debug('Domain: %r' % domain) + LOG.debug('Using Zone ID: %s' % zone_id) + zone = self.get_zone(zone_id) + LOG.debug('Zone: %r' % zone) data = extra.copy() LOG.debug('Event data: %s' % data) - data['domain'] = domain['name'] + data['zone'] = zone['name'] context = DesignateContext().elevated() context.all_tenants = True @@ -141,7 +141,7 @@ class BaseAddressHandler(NotificationHandler): for fmt in cfg.CONF[self.name].get('format'): recordset_values = { - 'domain_id': domain['id'], + 'zone_id': zone['id'], 'name': fmt % event_data, 'type': 'A' if addr['version'] == 4 else 'AAAA'} @@ -160,16 +160,16 @@ class BaseAddressHandler(NotificationHandler): 'managed_resource_id': resource_id}) LOG.debug('Creating record in %s / %s with values %r' % - (domain['id'], recordset['id'], record_values)) + (zone['id'], recordset['id'], record_values)) self.central_api.create_record(context, - domain['id'], + zone['id'], recordset['id'], Record(**record_values)) - def _delete(self, domain_id, managed=True, resource_id=None, + def _delete(self, zone_id, managed=True, resource_id=None, resource_type='instance', criterion=None): """ - Handle a generic delete of a fixed ip within a domain + Handle a generic delete of a fixed ip within a zone :param criterion: Criterion to search and destroy records """ @@ -184,7 +184,7 @@ class BaseAddressHandler(NotificationHandler): context.all_tenants = True context.edit_managed_records = True - criterion.update({'domain_id': domain_id}) + criterion.update({'zone_id': zone_id}) if managed: criterion.update({ @@ -201,6 +201,6 @@ class BaseAddressHandler(NotificationHandler): LOG.debug('Deleting record %s' % record['id']) self.central_api.delete_record(context, - domain_id, + zone_id, record['recordset_id'], record['id']) diff --git a/designate/notification_handler/neutron.py b/designate/notification_handler/neutron.py index 7f644076..fcabf2fd 100644 --- a/designate/notification_handler/neutron.py +++ b/designate/notification_handler/neutron.py @@ -29,9 +29,9 @@ cfg.CONF.register_group(cfg.OptGroup( cfg.CONF.register_opts([ cfg.ListOpt('notification-topics', default=['notifications']), cfg.StrOpt('control-exchange', default='neutron'), - cfg.StrOpt('domain-id'), + cfg.StrOpt('zone-id'), cfg.MultiStrOpt('format', default=[ - '%(octet0)s-%(octet1)s-%(octet2)s-%(octet3)s.%(domain)s']) + '%(octet0)s-%(octet1)s-%(octet2)s-%(octet3)s.%(zone)s']) ], group='handler:neutron_floatingip') @@ -56,9 +56,9 @@ class NeutronFloatingHandler(BaseAddressHandler): LOG.debug('%s received notification - %s' % (self.get_canonical_name(), event_type)) - domain_id = cfg.CONF[self.name].domain_id + zone_id = cfg.CONF[self.name].zone_id if event_type.startswith('floatingip.delete'): - self._delete(domain_id=domain_id, + self._delete(zone_id=zone_id, resource_id=payload['floatingip_id'], resource_type='floatingip') elif event_type.startswith('floatingip.update'): @@ -69,10 +69,10 @@ class NeutronFloatingHandler(BaseAddressHandler): } self._create(addresses=[address], extra=payload['floatingip'], - domain_id=domain_id, + zone_id=zone_id, resource_id=payload['floatingip']['id'], resource_type='floatingip') elif not payload['floatingip']['fixed_ip_address']: - self._delete(domain_id=domain_id, + self._delete(zone_id=zone_id, resource_id=payload['floatingip']['id'], resource_type='floatingip') diff --git a/designate/notification_handler/nova.py b/designate/notification_handler/nova.py index 58e3e41b..1abb5e19 100644 --- a/designate/notification_handler/nova.py +++ b/designate/notification_handler/nova.py @@ -29,9 +29,9 @@ cfg.CONF.register_group(cfg.OptGroup( cfg.CONF.register_opts([ cfg.ListOpt('notification-topics', default=['notifications']), cfg.StrOpt('control-exchange', default='nova'), - cfg.StrOpt('domain-id'), + cfg.StrOpt('zone-id'), cfg.MultiStrOpt('format', default=[ - '%(octet0)s-%(octet1)s-%(octet2)s-%(octet3)s.%(domain)s']) + '%(octet0)s-%(octet1)s-%(octet2)s-%(octet3)s.%(zone)s']) ], group='handler:nova_fixed') @@ -60,15 +60,15 @@ class NovaFixedHandler(BaseAddressHandler): def process_notification(self, context, event_type, payload): LOG.debug('NovaFixedHandler received notification - %s' % event_type) - domain_id = cfg.CONF[self.name].domain_id + zone_id = cfg.CONF[self.name].zone_id if event_type == 'compute.instance.create.end': self._create(addresses=payload['fixed_ips'], extra=payload, - domain_id=domain_id, + zone_id=zone_id, resource_id=payload['instance_id'], resource_type='instance') elif event_type == 'compute.instance.delete.start': - self._delete(domain_id=domain_id, + self._delete(zone_id=zone_id, resource_id=payload['instance_id'], resource_type='instance') diff --git a/designate/objects/__init__.py b/designate/objects/__init__.py index 68d40fc8..315e244d 100644 --- a/designate/objects/__init__.py +++ b/designate/objects/__init__.py @@ -12,16 +12,14 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. - - from designate.objects.base import DesignateObject # noqa from designate.objects.base import DictObjectMixin # noqa from designate.objects.base import ListObjectMixin # noqa from designate.objects.base import PagedListObjectMixin # noqa from designate.objects.blacklist import Blacklist, BlacklistList # noqa -from designate.objects.domain import Domain, DomainList # noqa -from designate.objects.domain_attribute import DomainAttribute, DomainAttributeList # noqa -from designate.objects.domain_master import DomainMaster, DomainMasterList # noqa +from designate.objects.zone import Zone, ZoneList # noqa +from designate.objects.zone_attribute import ZoneAttribute, ZoneAttributeList # noqa +from designate.objects.zone_master import ZoneMaster, ZoneMasterList # noqa from designate.objects.floating_ip import FloatingIP, FloatingIPList # noqa from designate.objects.pool_manager_status import PoolManagerStatus, PoolManagerStatusList # noqa from designate.objects.pool import Pool, PoolList # noqa diff --git a/designate/objects/adapters/__init__.py b/designate/objects/adapters/__init__.py index 8f56604a..1f178bf2 100644 --- a/designate/objects/adapters/__init__.py +++ b/designate/objects/adapters/__init__.py @@ -15,8 +15,8 @@ from designate.objects.adapters.base import DesignateAdapter # noqa # API v2 from designate.objects.adapters.api_v2.blacklist import BlacklistAPIv2Adapter, BlacklistListAPIv2Adapter # noqa -from designate.objects.adapters.api_v2.domain import DomainAPIv2Adapter, DomainListAPIv2Adapter # noqa -from designate.objects.adapters.api_v2.domain_master import DomainMasterAPIv2Adapter, DomainMasterListAPIv2Adapter # noqa +from designate.objects.adapters.api_v2.zone import ZoneAPIv2Adapter, ZoneListAPIv2Adapter # noqa +from designate.objects.adapters.api_v2.zone_master import ZoneMasterAPIv2Adapter, ZoneMasterListAPIv2Adapter # noqa from designate.objects.adapters.api_v2.floating_ip import FloatingIPAPIv2Adapter, FloatingIPListAPIv2Adapter # noqa from designate.objects.adapters.api_v2.record import RecordAPIv2Adapter, RecordListAPIv2Adapter # noqa from designate.objects.adapters.api_v2.recordset import RecordSetAPIv2Adapter, RecordSetListAPIv2Adapter # noqa diff --git a/designate/objects/adapters/api_v2/recordset.py b/designate/objects/adapters/api_v2/recordset.py index 33d4d055..c2e42a54 100644 --- a/designate/objects/adapters/api_v2/recordset.py +++ b/designate/objects/adapters/api_v2/recordset.py @@ -27,7 +27,7 @@ class RecordSetAPIv2Adapter(base.APIv2Adapter): 'fields': { "id": {}, "zone_id": { - 'rename': 'domain_id' + 'rename': 'zone_id' }, "name": { 'immutable': True diff --git a/designate/objects/adapters/api_v2/domain.py b/designate/objects/adapters/api_v2/zone.py similarity index 89% rename from designate/objects/adapters/api_v2/domain.py rename to designate/objects/adapters/api_v2/zone.py index 2fafceee..bd740ee7 100644 --- a/designate/objects/adapters/api_v2/domain.py +++ b/designate/objects/adapters/api_v2/zone.py @@ -19,9 +19,9 @@ from designate import objects LOG = logging.getLogger(__name__) -class DomainAPIv2Adapter(base.APIv2Adapter): +class ZoneAPIv2Adapter(base.APIv2Adapter): - ADAPTER_OBJECT = objects.Domain + ADAPTER_OBJECT = objects.Zone MODIFICATIONS = { 'fields': { @@ -69,18 +69,18 @@ class DomainAPIv2Adapter(base.APIv2Adapter): object.masters = objects.adapters.DesignateAdapter.parse( cls.ADAPTER_FORMAT, values['masters'], - objects.DomainMasterList(), + objects.ZoneMasterList(), *args, **kwargs) del values['masters'] - return super(DomainAPIv2Adapter, cls)._parse_object( + return super(ZoneAPIv2Adapter, cls)._parse_object( values, object, *args, **kwargs) -class DomainListAPIv2Adapter(base.APIv2Adapter): +class ZoneListAPIv2Adapter(base.APIv2Adapter): - ADAPTER_OBJECT = objects.DomainList + ADAPTER_OBJECT = objects.ZoneList MODIFICATIONS = { 'options': { diff --git a/designate/objects/adapters/api_v2/zone_export.py b/designate/objects/adapters/api_v2/zone_export.py index f46a44b1..185af385 100644 --- a/designate/objects/adapters/api_v2/zone_export.py +++ b/designate/objects/adapters/api_v2/zone_export.py @@ -31,7 +31,7 @@ class ZoneExportAPIv2Adapter(base.APIv2Adapter): "message": {}, "location": {}, "zone_id": { - 'rename': 'domain_id', + 'rename': 'zone_id', }, "project_id": { 'rename': 'tenant_id' diff --git a/designate/objects/adapters/api_v2/zone_import.py b/designate/objects/adapters/api_v2/zone_import.py index 2f25403a..ab955c26 100644 --- a/designate/objects/adapters/api_v2/zone_import.py +++ b/designate/objects/adapters/api_v2/zone_import.py @@ -30,7 +30,7 @@ class ZoneImportAPIv2Adapter(base.APIv2Adapter): "status": {}, "message": {}, "zone_id": { - 'rename': 'domain_id', + 'rename': 'zone_id', }, "project_id": { 'rename': 'tenant_id' diff --git a/designate/objects/adapters/api_v2/domain_master.py b/designate/objects/adapters/api_v2/zone_master.py similarity index 93% rename from designate/objects/adapters/api_v2/domain_master.py rename to designate/objects/adapters/api_v2/zone_master.py index 4ef725c1..73a97eec 100644 --- a/designate/objects/adapters/api_v2/domain_master.py +++ b/designate/objects/adapters/api_v2/zone_master.py @@ -19,9 +19,9 @@ from designate import utils LOG = logging.getLogger(__name__) -class DomainMasterAPIv2Adapter(base.APIv2Adapter): +class ZoneMasterAPIv2Adapter(base.APIv2Adapter): - ADAPTER_OBJECT = objects.DomainMaster + ADAPTER_OBJECT = objects.ZoneMaster MODIFICATIONS = { 'fields': { @@ -49,9 +49,9 @@ class DomainMasterAPIv2Adapter(base.APIv2Adapter): return object -class DomainMasterListAPIv2Adapter(base.APIv2Adapter): +class ZoneMasterListAPIv2Adapter(base.APIv2Adapter): - ADAPTER_OBJECT = objects.DomainMasterList + ADAPTER_OBJECT = objects.ZoneMasterList MODIFICATIONS = { 'options': { diff --git a/designate/objects/adapters/api_v2/zone_transfer_accept.py b/designate/objects/adapters/api_v2/zone_transfer_accept.py index 72c731ee..d2263bba 100644 --- a/designate/objects/adapters/api_v2/zone_transfer_accept.py +++ b/designate/objects/adapters/api_v2/zone_transfer_accept.py @@ -36,7 +36,7 @@ class ZoneTransferAcceptAPIv2Adapter(base.APIv2Adapter): }, "status": {}, "zone_id": { - 'rename': 'domain_id', + 'rename': 'zone_id', }, "created_at": {}, "updated_at": {}, diff --git a/designate/objects/adapters/api_v2/zone_transfer_request.py b/designate/objects/adapters/api_v2/zone_transfer_request.py index 3e4efae0..e7ea939c 100644 --- a/designate/objects/adapters/api_v2/zone_transfer_request.py +++ b/designate/objects/adapters/api_v2/zone_transfer_request.py @@ -30,7 +30,6 @@ class ZoneTransferRequestAPIv2Adapter(base.APIv2Adapter): 'protected': False }, "zone_id": { - 'rename': 'domain_id', 'immutable': True, 'protected': False }, @@ -50,7 +49,6 @@ class ZoneTransferRequestAPIv2Adapter(base.APIv2Adapter): 'protected': False }, "zone_name": { - 'rename': 'domain_name', 'protected': False }, "created_at": {}, diff --git a/designate/objects/adapters/base.py b/designate/objects/adapters/base.py index 2038eee6..7935657c 100644 --- a/designate/objects/adapters/base.py +++ b/designate/objects/adapters/base.py @@ -209,7 +209,7 @@ class DesignateAdapter(object): ############################################################## # Check if the field should be allowed change after it is - # initially set (eg domain name) + # initially set (eg zone name) if cls.MODIFICATIONS['fields'][key].get('immutable', False): if getattr(output_object, obj_key, False) and \ getattr(output_object, obj_key) != value: diff --git a/designate/objects/pool_manager_status.py b/designate/objects/pool_manager_status.py index 250d2264..65af45a4 100644 --- a/designate/objects/pool_manager_status.py +++ b/designate/objects/pool_manager_status.py @@ -26,7 +26,7 @@ class PoolManagerStatus(base.DictObjectMixin, base.PersistentObjectMixin, }, 'required': True }, - 'domain_id': { + 'zone_id': { 'schema': { 'type': 'string', 'format': 'uuid', @@ -54,7 +54,7 @@ class PoolManagerStatus(base.DictObjectMixin, base.PersistentObjectMixin, } STRING_KEYS = [ - 'id', 'action', 'status', 'server_id', 'domain_id' + 'id', 'action', 'status', 'server_id', 'zone_id' ] diff --git a/designate/objects/record.py b/designate/objects/record.py index 300b7977..afd20f65 100644 --- a/designate/objects/record.py +++ b/designate/objects/record.py @@ -28,7 +28,7 @@ class Record(base.DictObjectMixin, base.PersistentObjectMixin, } }, 'data': {}, - 'domain_id': { + 'zone_id': { 'schema': { 'type': 'string', 'format': 'uuid', diff --git a/designate/objects/recordset.py b/designate/objects/recordset.py index fb849a22..38682248 100644 --- a/designate/objects/recordset.py +++ b/designate/objects/recordset.py @@ -84,7 +84,7 @@ class RecordSet(base.DictObjectMixin, base.PersistentObjectMixin, }, 'read_only': True }, - 'domain_id': { + 'zone_id': { 'schema': { 'type': 'string', 'description': 'Zone identifier', @@ -277,7 +277,7 @@ class RecordSet(base.DictObjectMixin, base.PersistentObjectMixin, self.records = old_records STRING_KEYS = [ - 'id', 'type', 'name', 'domain_id' + 'id', 'type', 'name', 'zone_id' ] diff --git a/designate/objects/tenant.py b/designate/objects/tenant.py index cc0452fc..8939d418 100644 --- a/designate/objects/tenant.py +++ b/designate/objects/tenant.py @@ -18,8 +18,8 @@ from designate.objects import base class Tenant(base.DictObjectMixin, base.DesignateObject): FIELDS = { 'id': {}, - 'domain_count': {}, - 'domains': {} + 'zone_count': {}, + 'zones': {} } STRING_KEYS = [ diff --git a/designate/objects/domain.py b/designate/objects/zone.py similarity index 93% rename from designate/objects/domain.py rename to designate/objects/zone.py index 82e7f358..866c53ee 100644 --- a/designate/objects/domain.py +++ b/designate/objects/zone.py @@ -19,8 +19,8 @@ from designate.objects.validation_error import ValidationError from designate.objects.validation_error import ValidationErrorList -class Domain(base.DictObjectMixin, base.SoftDeleteObjectMixin, - base.PersistentObjectMixin, base.DesignateObject): +class Zone(base.DictObjectMixin, base.SoftDeleteObjectMixin, + base.PersistentObjectMixin, base.DesignateObject): FIELDS = { 'shard': { 'schema': { @@ -93,7 +93,7 @@ class Domain(base.DictObjectMixin, base.SoftDeleteObjectMixin, }, 'read_only': True }, - 'parent_domain_id': { + 'parent_zone_id': { 'schema': { 'type': ['string', 'null'], 'format': 'uuid' @@ -141,11 +141,11 @@ class Domain(base.DictObjectMixin, base.SoftDeleteObjectMixin, }, 'attributes': { 'relation': True, - 'relation_cls': 'DomainAttributeList' + 'relation_cls': 'ZoneAttributeList' }, 'masters': { 'relation': True, - 'relation_cls': 'DomainMasterList' + 'relation_cls': 'ZoneMasterList' }, 'type': { 'schema': { @@ -169,7 +169,7 @@ class Domain(base.DictObjectMixin, base.SoftDeleteObjectMixin, def get_master_by_ip(self, host): """ - Utility to get the master by it's ip for this domain. + Utility to get the master by it's ip for this zone. """ for srv in self.masters: srv_host, _ = utils.split_host_port(srv.to_data()) @@ -224,7 +224,7 @@ class Domain(base.DictObjectMixin, base.SoftDeleteObjectMixin, errors.append(e) self._raise(errors) - super(Domain, self).validate() + super(Zone, self).validate() except exceptions.RelationNotLoaded as ex: errors = ValidationErrorList() e = ValidationError() @@ -236,6 +236,6 @@ class Domain(base.DictObjectMixin, base.SoftDeleteObjectMixin, self._raise(errors) -class DomainList(base.ListObjectMixin, base.DesignateObject, - base.PagedListObjectMixin): - LIST_ITEM_TYPE = Domain +class ZoneList(base.ListObjectMixin, base.DesignateObject, + base.PagedListObjectMixin): + LIST_ITEM_TYPE = Zone diff --git a/designate/objects/domain_attribute.py b/designate/objects/zone_attribute.py similarity index 72% rename from designate/objects/domain_attribute.py rename to designate/objects/zone_attribute.py index 21fffd58..10543a2e 100644 --- a/designate/objects/domain_attribute.py +++ b/designate/objects/zone_attribute.py @@ -16,18 +16,18 @@ from designate.objects import base -class DomainAttribute(base.DictObjectMixin, base.PersistentObjectMixin, - base.DesignateObject): +class ZoneAttribute(base.DictObjectMixin, base.PersistentObjectMixin, + base.DesignateObject): FIELDS = { - 'domain_id': {}, + 'zone_id': {}, 'key': {}, 'value': {} } STRING_KEYS = [ - 'id', 'key', 'value', 'domain_id' + 'id', 'key', 'value', 'zone_id' ] -class DomainAttributeList(base.ListObjectMixin, base.DesignateObject): - LIST_ITEM_TYPE = DomainAttribute +class ZoneAttributeList(base.ListObjectMixin, base.DesignateObject): + LIST_ITEM_TYPE = ZoneAttribute diff --git a/designate/objects/zone_export.py b/designate/objects/zone_export.py index ed4867f5..d5446a36 100644 --- a/designate/objects/zone_export.py +++ b/designate/objects/zone_export.py @@ -53,7 +53,7 @@ class ZoneExport(base.DictObjectMixin, base.PersistentObjectMixin, }, 'read_only': True }, - 'domain_id': { + 'zone_id': { 'schema': { "type": "string", "format": "uuid" diff --git a/designate/objects/zone_import.py b/designate/objects/zone_import.py index 44be88ba..27d10d3e 100644 --- a/designate/objects/zone_import.py +++ b/designate/objects/zone_import.py @@ -46,7 +46,7 @@ class ZoneImport(base.DictObjectMixin, base.PersistentObjectMixin, }, 'read_only': True }, - 'domain_id': { + 'zone_id': { 'schema': { "type": "string", "format": "uuid" diff --git a/designate/objects/domain_master.py b/designate/objects/zone_master.py similarity index 86% rename from designate/objects/domain_master.py rename to designate/objects/zone_master.py index 348ee49f..a48312c0 100644 --- a/designate/objects/domain_master.py +++ b/designate/objects/zone_master.py @@ -17,10 +17,10 @@ from designate.objects import base from designate import utils -class DomainMaster(base.DictObjectMixin, base.PersistentObjectMixin, - base.DesignateObject): +class ZoneMaster(base.DictObjectMixin, base.PersistentObjectMixin, + base.DesignateObject): FIELDS = { - 'domain_id': {}, + 'zone_id': {}, 'host': { 'schema': { 'type': 'string', @@ -47,8 +47,8 @@ class DomainMaster(base.DictObjectMixin, base.PersistentObjectMixin, return cls.from_dict({"host": host, "port": port}) -class DomainMasterList(base.ListObjectMixin, base.DesignateObject): - LIST_ITEM_TYPE = DomainMaster +class ZoneMasterList(base.ListObjectMixin, base.DesignateObject): + LIST_ITEM_TYPE = ZoneMaster def to_data(self): rlist = [] diff --git a/designate/objects/zone_transfer_accept.py b/designate/objects/zone_transfer_accept.py index d7edec96..b9a12a09 100644 --- a/designate/objects/zone_transfer_accept.py +++ b/designate/objects/zone_transfer_accept.py @@ -46,7 +46,7 @@ class ZoneTransferAccept(base.DictObjectMixin, base.PersistentObjectMixin, }, 'required': True }, - 'domain_id': { + 'zone_id': { 'schema': { "type": "string", "format": "uuid" @@ -56,7 +56,7 @@ class ZoneTransferAccept(base.DictObjectMixin, base.PersistentObjectMixin, } STRING_KEYS = [ - 'id', 'domain_id', 'tenant_id', 'zone_transfer_request_id' + 'id', 'zone_id', 'tenant_id', 'zone_transfer_request_id' ] diff --git a/designate/objects/zone_transfer_request.py b/designate/objects/zone_transfer_request.py index db7dd532..0b599d44 100644 --- a/designate/objects/zone_transfer_request.py +++ b/designate/objects/zone_transfer_request.py @@ -25,7 +25,7 @@ class ZoneTransferRequest(base.DictObjectMixin, base.PersistentObjectMixin, "maxLength": 160 }, }, - 'domain_id': { + 'zone_id': { 'schema': { "type": "string", "description": "Zone identifier", @@ -57,7 +57,7 @@ class ZoneTransferRequest(base.DictObjectMixin, base.PersistentObjectMixin, "enum": ["ACTIVE", "PENDING", "DELETED", "ERROR", "COMPLETE"], } }, - 'domain_name': { + 'zone_name': { 'schema': { "type": ["string", "null"], "maxLength": 255, @@ -67,7 +67,7 @@ class ZoneTransferRequest(base.DictObjectMixin, base.PersistentObjectMixin, } STRING_KEYS = [ - 'id', 'domain_id', 'domain_name', 'target_tenant_id' + 'id', 'zone_id', 'zone_name', 'target_tenant_id' ] diff --git a/designate/pool_manager/__init__.py b/designate/pool_manager/__init__.py index 7c07cfd8..eec03411 100644 --- a/designate/pool_manager/__init__.py +++ b/designate/pool_manager/__init__.py @@ -31,7 +31,7 @@ OPTS = [ 'Pool Manager'), cfg.IntOpt('threshold-percentage', default=100, help='The percentage of servers requiring a successful update ' - 'for a domain change to be considered active'), + 'for a zone change to be considered active'), cfg.IntOpt('poll-timeout', default=30, help='The time to wait for a response from a server'), cfg.IntOpt('poll-retry-interval', default=15, diff --git a/designate/pool_manager/cache/base.py b/designate/pool_manager/cache/base.py index 52390dd2..744e6206 100644 --- a/designate/pool_manager/cache/base.py +++ b/designate/pool_manager/cache/base.py @@ -49,7 +49,7 @@ class PoolManagerCache(DriverPlugin): """ @abc.abstractmethod - def retrieve(self, context, nameserver_id, domain_id, action): + def retrieve(self, context, nameserver_id, zone_id, action): """ Retrieve the pool manager status object. @@ -57,7 +57,7 @@ class PoolManagerCache(DriverPlugin): :param context: Security context information :param nameserver_id: the nameserver ID of the pool manager status object - :param domain_id: the domain ID of the pool manger status object + :param zone_id: the zone ID of the pool manger status object :param action: the action of the pool manager status object :return: the pool manager status object """ diff --git a/designate/pool_manager/cache/impl_memcache/__init__.py b/designate/pool_manager/cache/impl_memcache/__init__.py index 19eda182..28e0a56f 100644 --- a/designate/pool_manager/cache/impl_memcache/__init__.py +++ b/designate/pool_manager/cache/impl_memcache/__init__.py @@ -75,10 +75,10 @@ class MemcachePoolManagerCache(cache_base.PoolManagerCache): serial_number_key, pool_manager_status.serial_number, self.expiration) - def retrieve(self, context, nameserver_id, domain_id, action): + def retrieve(self, context, nameserver_id, zone_id, action): values = { 'nameserver_id': nameserver_id, - 'domain_id': domain_id, + 'zone_id': zone_id, 'action': action, } pool_manager_status = objects.PoolManagerStatus(**values) @@ -103,9 +103,9 @@ class MemcachePoolManagerCache(cache_base.PoolManagerCache): @staticmethod def _status_key(pool_manager_status, tail): - key = '{nameserver}-{domain}-{action}-{tail}'.format( + key = '{nameserver}-{zone}-{action}-{tail}'.format( nameserver=pool_manager_status.nameserver_id, - domain=pool_manager_status.domain_id, + zone=pool_manager_status.zone_id, action=pool_manager_status.action, tail=tail ) diff --git a/designate/pool_manager/cache/impl_noop/__init__.py b/designate/pool_manager/cache/impl_noop/__init__.py index 2ec11d35..f640b544 100644 --- a/designate/pool_manager/cache/impl_noop/__init__.py +++ b/designate/pool_manager/cache/impl_noop/__init__.py @@ -32,5 +32,5 @@ class NoopPoolManagerCache(cache_base.PoolManagerCache): def store(self, context, pool_manager_status): pass - def retrieve(self, context, nameserver_id, domain_id, action): + def retrieve(self, context, nameserver_id, zone_id, action): raise exceptions.PoolManagerStatusNotFound diff --git a/designate/pool_manager/cache/impl_sqlalchemy/__init__.py b/designate/pool_manager/cache/impl_sqlalchemy/__init__.py index d23a3cfd..925f8dee 100644 --- a/designate/pool_manager/cache/impl_sqlalchemy/__init__.py +++ b/designate/pool_manager/cache/impl_sqlalchemy/__init__.py @@ -50,7 +50,7 @@ class SQLAlchemyPoolManagerCache(sqlalchemy_base.SQLAlchemy, if not pool_manager_status.id: pool_manager_status = self.retrieve( context, pool_manager_status.nameserver_id, - pool_manager_status.domain_id, pool_manager_status.action) + pool_manager_status.zone_id, pool_manager_status.action) self._delete( context, tables.pool_manager_statuses, pool_manager_status, exceptions.PoolManagerStatusNotFound) @@ -66,10 +66,10 @@ class SQLAlchemyPoolManagerCache(sqlalchemy_base.SQLAlchemy, tables.pool_manager_statuses, pool_manager_status, exceptions.DuplicatePoolManagerStatus) - def retrieve(self, context, nameserver_id, domain_id, action): + def retrieve(self, context, nameserver_id, zone_id, action): criterion = { 'nameserver_id': nameserver_id, - 'domain_id': domain_id, + 'zone_id': zone_id, 'action': action } return self._find( diff --git a/designate/pool_manager/cache/impl_sqlalchemy/migrate_repo/versions/008_domain_to_zone_rename.py b/designate/pool_manager/cache/impl_sqlalchemy/migrate_repo/versions/008_domain_to_zone_rename.py new file mode 100644 index 00000000..0270e908 --- /dev/null +++ b/designate/pool_manager/cache/impl_sqlalchemy/migrate_repo/versions/008_domain_to_zone_rename.py @@ -0,0 +1,34 @@ +# Copyright 2015 Hewlett-Packard Development Company, L.P. +# +# Author: Kiall Mac Innes +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# See https://blueprints.launchpad.net/nova/+spec/backportable-db-migrations +# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html +from sqlalchemy.schema import Table, MetaData + + +meta = MetaData() + + +def upgrade(migrate_engine): + meta.bind = migrate_engine + + status_table = Table('pool_manager_statuses', meta, autoload=True) + + status_table.c.domain_id.alter(name='zone_id') + + +def downgrade(migration_engine): + pass diff --git a/designate/pool_manager/cache/impl_sqlalchemy/tables.py b/designate/pool_manager/cache/impl_sqlalchemy/tables.py index 0b89d7b5..97383f54 100644 --- a/designate/pool_manager/cache/impl_sqlalchemy/tables.py +++ b/designate/pool_manager/cache/impl_sqlalchemy/tables.py @@ -33,7 +33,7 @@ pool_manager_statuses = Table( Column('created_at', DateTime, default=lambda: timeutils.utcnow()), Column('updated_at', DateTime, onupdate=lambda: timeutils.utcnow()), Column('nameserver_id', UUID, nullable=False), - Column('domain_id', UUID, nullable=False), + Column('zone_id', UUID, nullable=False), Column('action', Enum(name='update_actions', *UPDATE_ACTIONS), nullable=False), Column('status', Enum(name='update_statuses', *UPDATE_STATUSES), @@ -41,9 +41,9 @@ pool_manager_statuses = Table( Column('serial_number', Integer, nullable=False), - UniqueConstraint('nameserver_id', 'domain_id', 'action', + UniqueConstraint('nameserver_id', 'zone_id', 'action', name='unique_pool_manager_status'), - ForeignKeyConstraint(['domain_id'], ['domains.id']), + ForeignKeyConstraint(['zone_id'], ['zones.id']), mysql_engine='InnoDB', mysql_charset='utf8', diff --git a/designate/pool_manager/rpcapi.py b/designate/pool_manager/rpcapi.py index 01f866da..6982d041 100644 --- a/designate/pool_manager/rpcapi.py +++ b/designate/pool_manager/rpcapi.py @@ -35,15 +35,16 @@ class PoolManagerAPI(object): API version history: 1.0 - Initial version + 2.0 - Rename domains to zones """ - RPC_API_VERSION = '1.0' + RPC_API_VERSION = '2.0' def __init__(self, topic=None): self.topic = topic if topic else cfg.CONF.pool_manager_topic target = messaging.Target(topic=self.topic, version=self.RPC_API_VERSION) - self.client = rpc.get_client(target, version_cap='1.0') + self.client = rpc.get_client(target, version_cap='2.0') @classmethod def get_instance(cls): @@ -59,51 +60,51 @@ class PoolManagerAPI(object): MNGR_API = cls() return MNGR_API - def create_domain(self, context, domain): - LOG.info(_LI("create_domain: Calling pool manager for %(domain)s, " + def create_zone(self, context, zone): + LOG.info(_LI("create_zone: Calling pool manager for %(zone)s, " "serial:%(serial)s") % - {'domain': domain.name, 'serial': domain.serial}) + {'zone': zone.name, 'serial': zone.serial}) # Modifying the topic so it is pool manager instance specific. - topic = '%s.%s' % (self.topic, domain.pool_id) + topic = '%s.%s' % (self.topic, zone.pool_id) cctxt = self.client.prepare(topic=topic) return cctxt.cast( - context, 'create_domain', domain=domain) + context, 'create_zone', zone=zone) - def delete_domain(self, context, domain): - LOG.info(_LI("delete_domain: Calling pool manager for %(domain)s, " + def delete_zone(self, context, zone): + LOG.info(_LI("delete_zone: Calling pool manager for %(zone)s, " "serial:%(serial)s") % - {'domain': domain.name, 'serial': domain.serial}) + {'zone': zone.name, 'serial': zone.serial}) # Modifying the topic so it is pool manager instance specific. - topic = '%s.%s' % (self.topic, domain.pool_id) + topic = '%s.%s' % (self.topic, zone.pool_id) cctxt = self.client.prepare(topic=topic) return cctxt.cast( - context, 'delete_domain', domain=domain) + context, 'delete_zone', zone=zone) - def update_domain(self, context, domain): - LOG.info(_LI("update_domain: Calling pool manager for %(domain)s, " + def update_zone(self, context, zone): + LOG.info(_LI("update_zone: Calling pool manager for %(zone)s, " "serial:%(serial)s") % - {'domain': domain.name, 'serial': domain.serial}) + {'zone': zone.name, 'serial': zone.serial}) # Modifying the topic so it is pool manager instance specific. - topic = '%s.%s' % (self.topic, domain.pool_id) + topic = '%s.%s' % (self.topic, zone.pool_id) cctxt = self.client.prepare(topic=topic) return cctxt.cast( - context, 'update_domain', domain=domain) + context, 'update_zone', zone=zone) - def update_status(self, context, domain, nameserver, status, + def update_status(self, context, zone, nameserver, status, actual_serial): - LOG.info(_LI("update_status: Calling pool manager for %(domain)s : " + LOG.info(_LI("update_status: Calling pool manager for %(zone)s : " "%(action)s : %(status)s : %(serial)s on nameserver " "'%(host)s:%(port)s'") % - {'domain': domain.name, 'action': domain.action, + {'zone': zone.name, 'action': zone.action, 'status': status, 'serial': actual_serial, 'host': nameserver.host, 'port': nameserver.port}) # Modifying the topic so it is pool manager instance specific. - topic = '%s.%s' % (self.topic, domain.pool_id) + topic = '%s.%s' % (self.topic, zone.pool_id) cctxt = self.client.prepare(topic=topic) return cctxt.cast( - context, 'update_status', domain=domain, nameserver=nameserver, + context, 'update_status', zone=zone, nameserver=nameserver, status=status, actual_serial=actual_serial) diff --git a/designate/pool_manager/service.py b/designate/pool_manager/service.py index d90dd59a..2086625d 100644 --- a/designate/pool_manager/service.py +++ b/designate/pool_manager/service.py @@ -71,7 +71,7 @@ class Service(service.RPCService, coordination.CoordinationMixin, 1.0 - Initial version """ - RPC_API_VERSION = '1.0' + RPC_API_VERSION = '2.0' target = messaging.Target(version=RPC_API_VERSION) @@ -180,22 +180,22 @@ class Service(service.RPCService, coordination.CoordinationMixin, try: # Handle Deletion Failures - domains = self._get_failed_domains(context, DELETE_ACTION) + zones = self._get_failed_zones(context, DELETE_ACTION) - for domain in domains: - self.delete_domain(context, domain) + for zone in zones: + self.delete_zone(context, zone) # Handle Creation Failures - domains = self._get_failed_domains(context, CREATE_ACTION) + zones = self._get_failed_zones(context, CREATE_ACTION) - for domain in domains: - self.create_domain(context, domain) + for zone in zones: + self.create_zone(context, zone) # Handle Update Failures - domains = self._get_failed_domains(context, UPDATE_ACTION) + zones = self._get_failed_zones(context, UPDATE_ACTION) - for domain in domains: - self.update_domain(context, domain) + for zone in zones: + self.update_zone(context, zone) except Exception: LOG.exception(_LE('An unhandled exception in periodic ' @@ -224,14 +224,14 @@ class Service(service.RPCService, coordination.CoordinationMixin, current = utils.increment_serial() criterion['serial'] = ">%s" % (current - periodic_sync_seconds) - domains = self.central_api.find_domains(context, criterion) + zones = self.central_api.find_zones(context, criterion) try: - for domain in domains: - # TODO(kiall): If the domain was created within the last + for zone in zones: + # TODO(kiall): If the zone was created within the last # periodic_sync_seconds, attempt to recreate # to fill in targets which may have failed. - self.update_domain(context, domain) + self.update_zone(context, zone) except Exception: LOG.exception(_LE('An unhandled exception in periodic ' @@ -239,73 +239,73 @@ class Service(service.RPCService, coordination.CoordinationMixin, # Standard Create/Update/Delete Methods - def create_domain(self, context, domain): + def create_zone(self, context, zone): """ :param context: Security context information. - :param domain: Domain to be created + :param zone: Zone to be created :return: None """ - LOG.info(_LI("Creating new domain %s"), domain.name) + LOG.info(_LI("Creating new zone %s"), zone.name) results = [] - # Create the domain on each of the Pool Targets + # Create the zone on each of the Pool Targets for target in self.pool.targets: results.append( - self._create_domain_on_target(context, target, domain) + self._create_zone_on_target(context, target, zone) ) if self._exceed_or_meet_threshold(results.count(True)): - LOG.debug('Consensus reached for creating domain %(domain)s ' - 'on pool targets' % {'domain': domain.name}) + LOG.debug('Consensus reached for creating zone %(zone)s ' + 'on pool targets' % {'zone': zone.name}) else: - LOG.warn(_LW('Consensus not reached for creating domain %(domain)s' - ' on pool targets') % {'domain': domain.name}) + LOG.warn(_LW('Consensus not reached for creating zone %(zone)s' + ' on pool targets') % {'zone': zone.name}) self.central_api.update_status( - context, domain.id, ERROR_STATUS, domain.serial) + context, zone.id, ERROR_STATUS, zone.serial) return # Send a NOTIFY to each also-notifies for also_notify in self.pool.also_notifies: - self._update_domain_on_also_notify(context, also_notify, domain) + self._update_zone_on_also_notify(context, also_notify, zone) # Send a NOTIFY to each nameserver for nameserver in self.pool.nameservers: create_status = self._build_status_object( - nameserver, domain, CREATE_ACTION) + nameserver, zone, CREATE_ACTION) self.cache.store(context, create_status) self.mdns_api.poll_for_serial_number( - context, domain, nameserver, self.timeout, + context, zone, nameserver, self.timeout, self.retry_interval, self.max_retries, self.delay) - def _create_domain_on_target(self, context, target, domain): + def _create_zone_on_target(self, context, target, zone): """ :param context: Security context information. - :param target: Target to create Domain on - :param domain: Domain to be created + :param target: Target to create Zone on + :param zone: Zone to be created :return: True/False """ - LOG.debug("Creating domain %s on target %s", domain.name, target.id) + LOG.debug("Creating zone %s on target %s", zone.name, target.id) backend = self.target_backends[target.id] retries = 0 while retries < self.max_retries: try: - backend.create_domain(context, domain) + backend.create_zone(context, zone) return True except Exception: retries += 1 - LOG.exception(_LE("Failed to create domain %(domain)s on " + LOG.exception(_LE("Failed to create zone %(zone)s on " "target %(target)s on attempt %(attempt)d"), { - 'domain': domain.name, + 'zone': zone.name, 'target': target.id, 'attempt': retries }) @@ -313,140 +313,140 @@ class Service(service.RPCService, coordination.CoordinationMixin, return False - def update_domain(self, context, domain): + def update_zone(self, context, zone): """ :param context: Security context information. - :param domain: Domain to be updated + :param zone: Zone to be updated :return: None """ - LOG.info(_LI("Updating domain %s"), domain.name) + LOG.info(_LI("Updating zone %s"), zone.name) results = [] - # Update the domain on each of the Pool Targets + # Update the zone on each of the Pool Targets for target in self.pool.targets: results.append( - self._update_domain_on_target(context, target, domain)) + self._update_zone_on_target(context, target, zone)) if self._exceed_or_meet_threshold(results.count(True)): - LOG.debug('Consensus reached for updating domain %(domain)s ' - 'on pool targets' % {'domain': domain.name}) + LOG.debug('Consensus reached for updating zone %(zone)s ' + 'on pool targets' % {'zone': zone.name}) else: - LOG.warn(_LW('Consensus not reached for updating domain %(domain)s' - ' on pool targets') % {'domain': domain.name}) + LOG.warn(_LW('Consensus not reached for updating zone %(zone)s' + ' on pool targets') % {'zone': zone.name}) self.central_api.update_status( - context, domain.id, ERROR_STATUS, domain.serial) + context, zone.id, ERROR_STATUS, zone.serial) return # Send a NOTIFY to each also-notifies for also_notify in self.pool.also_notifies: - self._update_domain_on_also_notify(context, also_notify, domain) + self._update_zone_on_also_notify(context, also_notify, zone) # Ensure the change has propogated to each nameserver for nameserver in self.pool.nameservers: # See if there is already another update in progress try: update_status = self.cache.retrieve( - context, nameserver.id, domain.id, UPDATE_ACTION) + context, nameserver.id, zone.id, UPDATE_ACTION) except exceptions.PoolManagerStatusNotFound: update_status = self._build_status_object( - nameserver, domain, UPDATE_ACTION) + nameserver, zone, UPDATE_ACTION) self.cache.store(context, update_status) self.mdns_api.poll_for_serial_number( - context, domain, nameserver, self.timeout, + context, zone, nameserver, self.timeout, self.retry_interval, self.max_retries, self.delay) - def _update_domain_on_target(self, context, target, domain): + def _update_zone_on_target(self, context, target, zone): """ :param context: Security context information. - :param target: Target to update Domain on - :param domain: Domain to be updated + :param target: Target to update Zone on + :param zone: Zone to be updated :return: True/False """ - LOG.debug("Updating domain %s on target %s", domain.name, target.id) + LOG.debug("Updating zone %s on target %s", zone.name, target.id) backend = self.target_backends[target.id] try: - backend.update_domain(context, domain) + backend.update_zone(context, zone) return True except Exception: - LOG.exception(_LE("Failed to update domain %(domain)s on target " + LOG.exception(_LE("Failed to update zone %(zone)s on target " "%(target)s"), - {'domain': domain.name, 'target': target.id}) + {'zone': zone.name, 'target': target.id}) return False - def _update_domain_on_also_notify(self, context, also_notify, domain): - LOG.info(_LI('Updating domain %(domain)s on also_notify %(server)s.') % - {'domain': domain.name, + def _update_zone_on_also_notify(self, context, also_notify, zone): + LOG.info(_LI('Updating zone %(zone)s on also_notify %(server)s.') % + {'zone': zone.name, 'server': self._get_destination(also_notify)}) self.mdns_api.notify_zone_changed( - context, domain, also_notify.host, also_notify.port, self.timeout, + context, zone, also_notify.host, also_notify.port, self.timeout, self.retry_interval, self.max_retries, 0) - def delete_domain(self, context, domain): + def delete_zone(self, context, zone): """ :param context: Security context information. - :param domain: Domain to be deleted + :param zone: Zone to be deleted :return: None """ - LOG.info(_LI("Deleting domain %s"), domain.name) + LOG.info(_LI("Deleting zone %s"), zone.name) results = [] - # Delete the domain on each of the Pool Targets + # Delete the zone on each of the Pool Targets for target in self.pool.targets: results.append( - self._delete_domain_on_target(context, target, domain)) + self._delete_zone_on_target(context, target, zone)) - # TODO(kiall): We should monitor that the Domain is actually deleted + # TODO(kiall): We should monitor that the Zone is actually deleted # correctly on each of the nameservers, rather than # assuming a successful delete-on-target is OK as we have # in the past. if self._exceed_or_meet_threshold( results.count(True), MAXIMUM_THRESHOLD): - LOG.debug('Consensus reached for deleting domain %(domain)s ' - 'on pool targets' % {'domain': domain.name}) + LOG.debug('Consensus reached for deleting zone %(zone)s ' + 'on pool targets' % {'zone': zone.name}) self.central_api.update_status( - context, domain.id, SUCCESS_STATUS, domain.serial) + context, zone.id, SUCCESS_STATUS, zone.serial) else: - LOG.warn(_LW('Consensus not reached for deleting domain %(domain)s' - ' on pool targets') % {'domain': domain.name}) + LOG.warn(_LW('Consensus not reached for deleting zone %(zone)s' + ' on pool targets') % {'zone': zone.name}) self.central_api.update_status( - context, domain.id, ERROR_STATUS, domain.serial) + context, zone.id, ERROR_STATUS, zone.serial) - def _delete_domain_on_target(self, context, target, domain): + def _delete_zone_on_target(self, context, target, zone): """ :param context: Security context information. - :param target: Target to delete Domain from - :param domain: Domain to be deleted + :param target: Target to delete Zone from + :param zone: Zone to be deleted :return: True/False """ - LOG.debug("Deleting domain %s on target %s", domain.name, target.id) + LOG.debug("Deleting zone %s on target %s", zone.name, target.id) backend = self.target_backends[target.id] retries = 0 while retries < self.max_retries: try: - backend.delete_domain(context, domain) + backend.delete_zone(context, zone) return True except Exception: retries += 1 - LOG.exception(_LE("Failed to delete domain %(domain)s on " + LOG.exception(_LE("Failed to delete zone %(zone)s on " "target %(target)s on attempt %(attempt)d"), { - 'domain': domain.name, + 'zone': zone.name, 'target': target.id, 'attempt': retries }) @@ -454,38 +454,38 @@ class Service(service.RPCService, coordination.CoordinationMixin, return False - def update_status(self, context, domain, nameserver, status, + def update_status(self, context, zone, nameserver, status, actual_serial): """ update_status is called by mdns for creates and updates. deletes are handled by the backend entirely and status is determined at the time of delete itself. :param context: Security context information. - :param domain: The designate domain object. + :param zone: The designate zone object. :param nameserver: The nameserver for which a status update is being sent. :param status: The status, 'SUCCESS' or 'ERROR'. :param actual_serial: The actual serial number received from the name - server for the domain. + server for the zone. :return: None """ LOG.debug("Calling update_status for %s : %s : %s : %s" % - (domain.name, domain.action, status, actual_serial)) - action = UPDATE_ACTION if domain.action == 'NONE' else domain.action + (zone.name, zone.action, status, actual_serial)) + action = UPDATE_ACTION if zone.action == 'NONE' else zone.action - with lockutils.lock('update-status-%s' % domain.id): + with lockutils.lock('update-status-%s' % zone.id): try: current_status = self.cache.retrieve( - context, nameserver.id, domain.id, action) + context, nameserver.id, zone.id, action) except exceptions.PoolManagerStatusNotFound: current_status = self._build_status_object( - nameserver, domain, action) + nameserver, zone, action) self.cache.store(context, current_status) cache_serial = current_status.serial_number - LOG.debug('For domain %s : %s on nameserver %s the cache serial ' + LOG.debug('For zone %s : %s on nameserver %s the cache serial ' 'is %s and the actual serial is %s.' % - (domain.name, action, + (zone.name, action, self._get_destination(nameserver), cache_serial, actual_serial)) if actual_serial and cache_serial <= actual_serial: @@ -493,51 +493,51 @@ class Service(service.RPCService, coordination.CoordinationMixin, current_status.serial_number = actual_serial self.cache.store(context, current_status) - consensus_serial = self._get_consensus_serial(context, domain) + consensus_serial = self._get_consensus_serial(context, zone) # If there is a valid consensus serial we can still send a success # for that serial. # If there is a higher error serial we can also send an error for # the error serial. if consensus_serial != 0 and cache_serial <= consensus_serial \ - and domain.status != 'ACTIVE': - LOG.info(_LI('For domain %(domain)s ' + and zone.status != 'ACTIVE': + LOG.info(_LI('For zone %(zone)s ' 'the consensus serial is %(consensus_serial)s.') % - {'domain': domain.name, + {'zone': zone.name, 'consensus_serial': consensus_serial}) self.central_api.update_status( - context, domain.id, SUCCESS_STATUS, consensus_serial) + context, zone.id, SUCCESS_STATUS, consensus_serial) if status == ERROR_STATUS: error_serial = self._get_error_serial( - context, domain, consensus_serial) + context, zone, consensus_serial) if error_serial > consensus_serial or error_serial == 0: - LOG.warn(_LW('For domain %(domain)s ' + LOG.warn(_LW('For zone %(zone)s ' 'the error serial is %(error_serial)s.') % - {'domain': domain.name, + {'zone': zone.name, 'error_serial': error_serial}) self.central_api.update_status( - context, domain.id, ERROR_STATUS, error_serial) + context, zone.id, ERROR_STATUS, error_serial) if status == NO_DOMAIN_STATUS and action != DELETE_ACTION: - LOG.warn(_LW('Domain %(domain)s is not present in some ' - 'targets') % {'domain': domain.name}) + LOG.warn(_LW('Zone %(zone)s is not present in some ' + 'targets') % {'zone': zone.name}) self.central_api.update_status( - context, domain.id, NO_DOMAIN_STATUS, 0) + context, zone.id, NO_DOMAIN_STATUS, 0) - if consensus_serial == domain.serial and self._is_consensus( - context, domain, action, SUCCESS_STATUS, + if consensus_serial == zone.serial and self._is_consensus( + context, zone, action, SUCCESS_STATUS, MAXIMUM_THRESHOLD): - self._clear_cache(context, domain, action) + self._clear_cache(context, zone, action) # Utility Methods - def _get_failed_domains(self, context, action): + def _get_failed_zones(self, context, action): criterion = { 'pool_id': CONF['service:pool_manager'].pool_id, 'action': action, 'status': 'ERROR' } - return self.central_api.find_domains(context, criterion) + return self.central_api.find_zones(context, criterion) @staticmethod def _get_destination(nameserver): @@ -567,10 +567,10 @@ class Service(service.RPCService, coordination.CoordinationMixin, def _get_serials_descending(self, pool_manager_statuses): return self._get_sorted_serials(pool_manager_statuses, descending=True) - def _is_consensus(self, context, domain, action, status, threshold=None): + def _is_consensus(self, context, zone, action, status, threshold=None): status_count = 0 pool_manager_statuses = self._retrieve_statuses( - context, domain, action) + context, zone, action) for pool_manager_status in pool_manager_statuses: if pool_manager_status.status == status: status_count += 1 @@ -578,11 +578,11 @@ class Service(service.RPCService, coordination.CoordinationMixin, threshold = self.threshold return self._exceed_or_meet_threshold(status_count, threshold) - def _get_consensus_serial(self, context, domain): + def _get_consensus_serial(self, context, zone): consensus_serial = 0 - action = UPDATE_ACTION if domain.action == 'NONE' else domain.action + action = UPDATE_ACTION if zone.action == 'NONE' else zone.action - pm_statuses = self._retrieve_statuses(context, domain, action) + pm_statuses = self._retrieve_statuses(context, zone, action) for serial in self._get_serials_descending(pm_statuses): serial_count = 0 for pm_status in pm_statuses: @@ -593,12 +593,12 @@ class Service(service.RPCService, coordination.CoordinationMixin, break return consensus_serial - def _get_error_serial(self, context, domain, consensus_serial): + def _get_error_serial(self, context, zone, consensus_serial): error_serial = 0 - action = UPDATE_ACTION if domain.action == 'NONE' else domain.action + action = UPDATE_ACTION if zone.action == 'NONE' else zone.action - if self._is_consensus(context, domain, action, ERROR_STATUS): - pm_statuses = self._retrieve_statuses(context, domain, action) + if self._is_consensus(context, zone, action, ERROR_STATUS): + pm_statuses = self._retrieve_statuses(context, zone, action) for serial in self._get_serials_ascending(pm_statuses): if serial > consensus_serial: error_serial = serial @@ -608,10 +608,10 @@ class Service(service.RPCService, coordination.CoordinationMixin, # When we hear back from the nameserver, the serial_number is set to the # value the nameserver @staticmethod - def _build_status_object(nameserver, domain, action): + def _build_status_object(nameserver, zone, action): values = { 'nameserver_id': nameserver.id, - 'domain_id': domain.id, + 'zone_id': zone.id, 'status': None, 'serial_number': 0, 'action': action @@ -619,9 +619,9 @@ class Service(service.RPCService, coordination.CoordinationMixin, return objects.PoolManagerStatus(**values) # Methods for manipulating the cache. - def _clear_cache(self, context, domain, action=None): - LOG.debug('Clearing cache for domain %s with action %s.' % - (domain.name, action)) + def _clear_cache(self, context, zone, action=None): + LOG.debug('Clearing cache for zone %s with action %s.' % + (zone.name, action)) pool_manager_statuses = [] if action: @@ -632,7 +632,7 @@ class Service(service.RPCService, coordination.CoordinationMixin, for nameserver in self.pool.nameservers: for action in actions: pool_manager_status = self._build_status_object( - nameserver, domain, action) + nameserver, zone, action) pool_manager_statuses.append(pool_manager_status) for pool_manager_status in pool_manager_statuses: @@ -642,22 +642,22 @@ class Service(service.RPCService, coordination.CoordinationMixin, except exceptions.PoolManagerStatusNotFound: pass - def _retrieve_from_mdns(self, context, nameserver, domain, action): + def _retrieve_from_mdns(self, context, nameserver, zone, action): try: (status, actual_serial, retries) = \ self.mdns_api.get_serial_number( - context, domain, nameserver.host, nameserver.port, + context, zone, nameserver.host, nameserver.port, self.timeout, self.retry_interval, self.max_retries, self.delay) except messaging.MessagingException as msg_ex: - LOG.debug('Could not retrieve status and serial for domain %s on ' + LOG.debug('Could not retrieve status and serial for zone %s on ' 'nameserver %s with action %s (%s: %s)' % - (domain.name, self._get_destination(nameserver), action, + (zone.name, self._get_destination(nameserver), action, type(msg_ex), str(msg_ex))) return None pool_manager_status = self._build_status_object( - nameserver, domain, action) + nameserver, zone, action) if status == NO_DOMAIN_STATUS: if action == CREATE_ACTION: @@ -671,37 +671,37 @@ class Service(service.RPCService, coordination.CoordinationMixin, pool_manager_status.status = status pool_manager_status.serial_number = actual_serial \ if actual_serial is not None else 0 - LOG.debug('Retrieved status %s and serial %s for domain %s ' + LOG.debug('Retrieved status %s and serial %s for zone %s ' 'on nameserver %s with action %s from mdns.' % (pool_manager_status.status, pool_manager_status.serial_number, - domain.name, self._get_destination(nameserver), action)) + zone.name, self._get_destination(nameserver), action)) self.cache.store(context, pool_manager_status) return pool_manager_status - def _retrieve_statuses(self, context, domain, action): + def _retrieve_statuses(self, context, zone, action): pool_manager_statuses = [] for nameserver in self.pool.nameservers: try: pool_manager_status = self.cache.retrieve( - context, nameserver.id, domain.id, action) + context, nameserver.id, zone.id, action) LOG.debug('Cache hit! Retrieved status %s and serial %s ' - 'for domain %s on nameserver %s with action %s from ' + 'for zone %s on nameserver %s with action %s from ' 'the cache.' % (pool_manager_status.status, pool_manager_status.serial_number, - domain.name, + zone.name, self._get_destination(nameserver), action)) except exceptions.PoolManagerStatusNotFound: LOG.debug('Cache miss! Did not retrieve status and serial ' - 'for domain %s on nameserver %s with action %s from ' + 'for zone %s on nameserver %s with action %s from ' 'the cache. Getting it from the server.' % - (domain.name, + (zone.name, self._get_destination(nameserver), action)) pool_manager_status = self._retrieve_from_mdns( - context, nameserver, domain, action) + context, nameserver, zone, action) if pool_manager_status is not None: pool_manager_statuses.append(pool_manager_status) diff --git a/designate/quota/__init__.py b/designate/quota/__init__.py index 452eb363..71e5db48 100644 --- a/designate/quota/__init__.py +++ b/designate/quota/__init__.py @@ -24,12 +24,12 @@ LOG = logging.getLogger(__name__) cfg.CONF.register_opts([ cfg.StrOpt('quota-driver', default='storage', help='Quota driver to use'), - cfg.IntOpt('quota-domains', default=10, - help='Number of domains allowed per tenant'), - cfg.IntOpt('quota-domain-recordsets', default=500, - help='Number of recordsets allowed per domain'), - cfg.IntOpt('quota-domain-records', default=500, - help='Number of records allowed per domain'), + cfg.IntOpt('quota-zones', default=10, + help='Number of zones allowed per tenant'), + cfg.IntOpt('quota-zone-recordsets', default=500, + help='Number of recordsets allowed per zone'), + cfg.IntOpt('quota-zone-records', default=500, + help='Number of records allowed per zone'), cfg.IntOpt('quota-recordset-records', default=20, help='Number of records allowed per recordset'), cfg.IntOpt('quota-api-export-size', default=1000, diff --git a/designate/quota/base.py b/designate/quota/base.py index 9a8b18a1..744d5088 100644 --- a/designate/quota/base.py +++ b/designate/quota/base.py @@ -36,7 +36,8 @@ class Quota(DriverPlugin): if value >= quotas[resource]: raise exceptions.OverQuota() else: - raise exceptions.QuotaResourceUnknown() + raise exceptions.QuotaResourceUnknown("%s is not a valid quota" + " resource", resource) def get_quotas(self, context, tenant_id): quotas = self.get_default_quotas(context) @@ -51,9 +52,9 @@ class Quota(DriverPlugin): def get_default_quotas(self, context): return { - 'domains': cfg.CONF.quota_domains, - 'domain_recordsets': cfg.CONF.quota_domain_recordsets, - 'domain_records': cfg.CONF.quota_domain_records, + 'zones': cfg.CONF.quota_zones, + 'zone_recordsets': cfg.CONF.quota_zone_recordsets, + 'zone_records': cfg.CONF.quota_zone_records, 'recordset_records': cfg.CONF.quota_recordset_records, 'api_export_size': cfg.CONF.quota_api_export_size, } @@ -62,7 +63,8 @@ class Quota(DriverPlugin): quotas = self._get_quotas(context, tenant_id) if resource not in quotas: - raise exceptions.QuotaResourceUnknown() + raise exceptions.QuotaResourceUnknown("%s is not a valid quota " + "resource", resource) return quotas[resource] diff --git a/designate/resources/templates/export-zone.jinja2 b/designate/resources/templates/export-zone.jinja2 index 027fd630..4a9b60ed 100644 --- a/designate/resources/templates/export-zone.jinja2 +++ b/designate/resources/templates/export-zone.jinja2 @@ -1,5 +1,5 @@ -$ORIGIN {{ domain.name }} -$TTL {{ domain.ttl }} +$ORIGIN {{ zone.name }} +$TTL {{ zone.ttl }} {% for recordset in recordsets -%} {{recordset[0]}} {{recordset[1] or ''}} IN {{recordset[2]}} {{recordset[3]}} diff --git a/designate/schema/format.py b/designate/schema/format.py index 49691aa1..a5cd5ab2 100644 --- a/designate/schema/format.py +++ b/designate/schema/format.py @@ -27,7 +27,7 @@ LOG = logging.getLogger(__name__) # "\Z", rather than simply "$" to ensure a string with a # trailing newline is NOT matched. See bug #1471158. -RE_DOMAINNAME = r'^(?!.{255,})(?:(?!\-)[A-Za-z0-9_\-]{1,63}(? +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# See https://blueprints.launchpad.net/nova/+spec/backportable-db-migrations +# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html +from sqlalchemy.schema import MetaData, Table, Index +from migrate.changeset.constraint import UniqueConstraint, \ + ForeignKeyConstraint, PathNotFoundError + + +# This migration removes all references to domain from our Database. +# We rename the domains and domain_attribute tables, and rename any columns +# that had "domain" in the name.as +# There is a follow on patch to recreate the FKs for the newly renamed +# tables as the lib we use doesn't seem to like creating FKs on renamed +# tables until after the migration is complete. + +meta = MetaData() + + +def index_exists(index): + table = index[1]._get_table() + cols = sorted([str(x).split('.')[1] for x in index[1:]]) + + for idx in table.indexes: + if sorted(idx.columns.keys()) == cols: + return True + return False + + +def drop_index(index): + if index_exists(index): + index = Index(*index) + index.drop() + + +def drop_foreign_key(fk_def): + + table = fk_def[0]._get_table() + + col = fk_def[0] + ref_col = fk_def[1] + + # Use .copy() to avoid the set changing during the for operation + for fk in table.foreign_keys.copy(): + # Check if the fk is the one we want + if fk.column == col and fk.parent == ref_col: + + fkc = ForeignKeyConstraint([fk.column], [fk.parent], + name=fk.constraint.name) + fkc.drop() + # Check if the fk is the one we want (sometimes it seems the parent + # / col is switched + if fk.parent == col and fk.column == ref_col: + + fkc = ForeignKeyConstraint([fk.parent], [fk.column], + name=fk.constraint.name) + fkc.drop() + + +def drop_unique_constraint(uc_def): + uc = UniqueConstraint(*uc_def[2], table=uc_def[0], name=uc_def[1]) + try: + uc.drop() + except PathNotFoundError: + pass + + +def upgrade(migrate_engine): + meta.bind = migrate_engine + + # Get all the tables + domains_table = Table('domains', meta, autoload=True) + domain_attrib_table = Table('domain_attributes', meta, autoload=True) + recordsets_table = Table('recordsets', meta, autoload=True) + records_table = Table('records', meta, autoload=True) + ztr_table = Table('zone_transfer_requests', meta, autoload=True) + zta_table = Table('zone_transfer_accepts', meta, autoload=True) + zt_table = Table('zone_tasks', meta, autoload=True) + + # Remove the affected FKs + # Define FKs + fks = [ + [domains_table.c.id, domains_table.c.parent_domain_id], + [domain_attrib_table.c.domain_id, + domains_table.c.id], + [recordsets_table.c.domain_id, domains_table.c.id], + [records_table.c.domain_id, domains_table.c.id], + [ztr_table.c.domain_id, domains_table.c.id], + [zta_table.c.domain_id, domains_table.c.id] + ] + + # Drop FKs + for fk in fks: + drop_foreign_key(fk) + + # Change the table structures + + # Domains Table changes + domains_table.c.parent_domain_id.alter(name='parent_zone_id') + domains_table.rename('zones') + + # Domain Attributes + domain_attrib_table.c.domain_id.alter(name='zone_id') + domain_attrib_table.rename('zone_attributes') + + # Recordsets + recordsets_table.c.domain_id.alter(name='zone_id') + recordsets_table.c.domain_shard.alter(name='zone_shard') + + # Records + records_table.c.domain_id.alter(name="zone_id") + records_table.c.domain_shard.alter(name="zone_shard") + + # Zone Transfer Requests + ztr_table.c.domain_id.alter(name='zone_id') + + # Zone Transfer Requests + zta_table.c.domain_id.alter(name='zone_id') + + # Zone Tasks + zt_table.c.domain_id.alter(name='zone_id') + + +def downgrade(migration_engine): + pass diff --git a/designate/storage/impl_sqlalchemy/migrate_repo/versions/081_add_FKs.py b/designate/storage/impl_sqlalchemy/migrate_repo/versions/081_add_FKs.py new file mode 100644 index 00000000..d9b8d224 --- /dev/null +++ b/designate/storage/impl_sqlalchemy/migrate_repo/versions/081_add_FKs.py @@ -0,0 +1,66 @@ +# Copyright 2015 Hewlett-Packard Development Company, L.P. +# +# Author: Graham Hayes +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# See https://blueprints.launchpad.net/nova/+spec/backportable-db-migrations +# http://lists.openstack.org/pipermail/openstack-dev/2013-March/006827.html + +from migrate.changeset.constraint import ForeignKeyConstraint +from sqlalchemy.schema import MetaData, Table + +# This migration adds back the FKs removed in migration 80, as sqlalchemy +# migrate seems to need to wait to add FKs to renamed tables. + +meta = MetaData() + + +def upgrade(migrate_engine): + + meta.bind = migrate_engine + + # Get all the tables + zones_table = Table('zones', meta, autoload=True) + zone_attrib_table = Table('zone_attributes', meta, autoload=True) + recordsets_table = Table('recordsets', meta, autoload=True) + records_table = Table('records', meta, autoload=True) + ztr_table = Table('zone_transfer_requests', meta, autoload=True) + zta_table = Table('zone_transfer_accepts', meta, autoload=True) + zt_table = Table('zone_tasks', meta, autoload=True) + + # Create new FKs + + fks = [] + + fks.append(ForeignKeyConstraint([zones_table.c.parent_zone_id], + [zones_table.c.id], ondelete='SET NULL')) + fks.append(ForeignKeyConstraint([zone_attrib_table.c.zone_id], + [zones_table.c.id], ondelete='CASCADE')) + fks.append(ForeignKeyConstraint([recordsets_table.c.zone_id], + [zones_table.c.id], ondelete='CASCADE')) + fks.append(ForeignKeyConstraint([records_table.c.zone_id], + [zones_table.c.id], ondelete='CASCADE')) + fks.append(ForeignKeyConstraint([ztr_table.c.zone_id], + [zones_table.c.id], ondelete='CASCADE')) + fks.append(ForeignKeyConstraint([zta_table.c.zone_id], + [zones_table.c.id], ondelete='CASCADE')) + fks.append(ForeignKeyConstraint([zt_table.c.zone_id], + [zones_table.c.id], ondelete='CASCADE')) + + for fk in fks: + fk.create() + + +def downgrade(migration_engine): + pass diff --git a/designate/storage/impl_sqlalchemy/tables.py b/designate/storage/impl_sqlalchemy/tables.py index 6edd29ea..21456eb7 100644 --- a/designate/storage/impl_sqlalchemy/tables.py +++ b/designate/storage/impl_sqlalchemy/tables.py @@ -76,7 +76,7 @@ tlds = Table('tlds', metadata, mysql_charset='utf8', ) -domains = Table('domains', metadata, +zones = Table('zones', metadata, Column('id', UUID, default=utils.generate_uuid, primary_key=True), Column('version', Integer(), default=1, nullable=False), Column('created_at', DateTime, default=lambda: timeutils.utcnow()), @@ -104,22 +104,22 @@ domains = Table('domains', metadata, nullable=False), Column('status', Enum(name='resource_statuses', *RESOURCE_STATUSES), nullable=False, server_default='PENDING', default='PENDING'), - Column('parent_domain_id', UUID, default=None, nullable=True), + Column('parent_zone_id', UUID, default=None, nullable=True), Column('action', Enum(name='actions', *ACTIONS), default='CREATE', server_default='CREATE', nullable=False), Column('pool_id', UUID, default=None, nullable=True), Column('reverse_name', String(255), nullable=False), - UniqueConstraint('name', 'deleted', 'pool_id', name='unique_domain_name'), - ForeignKeyConstraint(['parent_domain_id'], - ['domains.id'], + UniqueConstraint('name', 'deleted', 'pool_id', name='unique_zone_name'), + ForeignKeyConstraint(['parent_zone_id'], + ['zones.id'], ondelete='SET NULL'), mysql_engine='InnoDB', mysql_charset='utf8', ) -domain_attributes = Table('domain_attributes', metadata, +zone_attributes = Table('zone_attributes', metadata, Column('id', UUID(), default=utils.generate_uuid, primary_key=True), Column('version', Integer(), default=1, nullable=False), Column('created_at', DateTime, default=lambda: timeutils.utcnow()), @@ -127,10 +127,10 @@ domain_attributes = Table('domain_attributes', metadata, Column('key', Enum(name='key', *ZONE_ATTRIBUTE_KEYS)), Column('value', String(255), nullable=False), - Column('domain_id', UUID(), nullable=False), + Column('zone_id', UUID(), nullable=False), - UniqueConstraint('key', 'value', 'domain_id', name='unique_attributes'), - ForeignKeyConstraint(['domain_id'], ['domains.id'], ondelete='CASCADE'), + UniqueConstraint('key', 'value', 'zone_id', name='unique_attributes'), + ForeignKeyConstraint(['zone_id'], ['zones.id'], ondelete='CASCADE'), mysql_engine='INNODB', mysql_charset='utf8' @@ -141,19 +141,19 @@ recordsets = Table('recordsets', metadata, Column('version', Integer(), default=1, nullable=False), Column('created_at', DateTime, default=lambda: timeutils.utcnow()), Column('updated_at', DateTime, onupdate=lambda: timeutils.utcnow()), - Column('domain_shard', SmallInteger(), nullable=False, - default=lambda ctxt: default_shard(ctxt, 'domain_id')), + Column('zone_shard', SmallInteger(), nullable=False, + default=lambda ctxt: default_shard(ctxt, 'zone_id')), Column('tenant_id', String(36), default=None, nullable=True), - Column('domain_id', UUID, nullable=False), + Column('zone_id', UUID, nullable=False), Column('name', String(255), nullable=False), Column('type', Enum(name='record_types', *RECORD_TYPES), nullable=False), Column('ttl', Integer, default=None, nullable=True), Column('description', Unicode(160), nullable=True), Column('reverse_name', String(255), nullable=False, default=''), - UniqueConstraint('domain_id', 'name', 'type', name='unique_recordset'), - ForeignKeyConstraint(['domain_id'], ['domains.id'], ondelete='CASCADE'), + UniqueConstraint('zone_id', 'name', 'type', name='unique_recordset'), + ForeignKeyConstraint(['zone_id'], ['zones.id'], ondelete='CASCADE'), mysql_engine='InnoDB', mysql_charset='utf8', @@ -164,11 +164,11 @@ records = Table('records', metadata, Column('version', Integer(), default=1, nullable=False), Column('created_at', DateTime, default=lambda: timeutils.utcnow()), Column('updated_at', DateTime, onupdate=lambda: timeutils.utcnow()), - Column('domain_shard', SmallInteger(), nullable=False, - default=lambda ctxt: default_shard(ctxt, 'domain_id')), + Column('zone_shard', SmallInteger(), nullable=False, + default=lambda ctxt: default_shard(ctxt, 'zone_id')), Column('tenant_id', String(36), default=None, nullable=True), - Column('domain_id', UUID, nullable=False), + Column('zone_id', UUID, nullable=False), Column('recordset_id', UUID, nullable=False), Column('data', Text, nullable=False), Column('description', Unicode(160), nullable=True), @@ -189,7 +189,7 @@ records = Table('records', metadata, Column('serial', Integer(), server_default='1', nullable=False), UniqueConstraint('hash', name='unique_record'), - ForeignKeyConstraint(['domain_id'], ['domains.id'], ondelete='CASCADE'), + ForeignKeyConstraint(['zone_id'], ['zones.id'], ondelete='CASCADE'), ForeignKeyConstraint(['recordset_id'], ['recordsets.id'], ondelete='CASCADE'), @@ -282,7 +282,7 @@ zone_transfer_requests = Table('zone_transfer_requests', metadata, Column('created_at', DateTime, default=lambda: timeutils.utcnow()), Column('updated_at', DateTime, onupdate=lambda: timeutils.utcnow()), - Column('domain_id', UUID, nullable=False), + Column('zone_id', UUID, nullable=False), Column("key", String(255), nullable=False), Column("description", String(255), nullable=False), Column("tenant_id", String(36), default=None, nullable=False), @@ -291,7 +291,7 @@ zone_transfer_requests = Table('zone_transfer_requests', metadata, nullable=False, server_default='ACTIVE', default='ACTIVE'), - ForeignKeyConstraint(['domain_id'], ['domains.id'], ondelete='CASCADE'), + ForeignKeyConstraint(['zone_id'], ['zones.id'], ondelete='CASCADE'), mysql_engine='InnoDB', mysql_charset='utf8', @@ -303,14 +303,14 @@ zone_transfer_accepts = Table('zone_transfer_accepts', metadata, Column('created_at', DateTime, default=lambda: timeutils.utcnow()), Column('updated_at', DateTime, onupdate=lambda: timeutils.utcnow()), - Column('domain_id', UUID, nullable=False), + Column('zone_id', UUID, nullable=False), Column('zone_transfer_request_id', UUID, nullable=False), Column("tenant_id", String(36), default=None, nullable=False), Column("status", Enum(name='resource_statuses', *TASK_STATUSES), nullable=False, server_default='ACTIVE', default='ACTIVE'), - ForeignKeyConstraint(['domain_id'], ['domains.id'], ondelete='CASCADE'), + ForeignKeyConstraint(['zone_id'], ['zones.id'], ondelete='CASCADE'), ForeignKeyConstraint( ['zone_transfer_request_id'], ['zone_transfer_requests.id'], @@ -327,7 +327,7 @@ zone_tasks = Table('zone_tasks', metadata, Column('version', Integer(), default=1, nullable=False), Column('tenant_id', String(36), default=None, nullable=True), - Column('domain_id', UUID(), nullable=True), + Column('zone_id', UUID(), nullable=True), Column('task_type', Enum(name='task_types', *ZONE_TASK_TYPES), nullable=True), Column('message', String(160), nullable=True), diff --git a/designate/tests/__init__.py b/designate/tests/__init__.py index 27ca7899..0c7b4feb 100644 --- a/designate/tests/__init__.py +++ b/designate/tests/__init__.py @@ -62,7 +62,7 @@ class TestTimeoutError(Exception): class TestCase(base.BaseTestCase): quota_fixtures = [{ - 'resource': 'domains', + 'resource': 'zones', 'hard_limit': 5, }, { 'resource': 'records', @@ -108,8 +108,8 @@ class TestCase(base.BaseTestCase): 'resource_id': '7fbb6304-5e74-4691-bd80-cef3cff5fe2f', }] - # The last domain is invalid - domain_fixtures = { + # The last zone is invalid + zone_fixtures = { 'PRIMARY': [ { 'name': 'example.com.', @@ -179,8 +179,8 @@ class TestCase(base.BaseTestCase): {'data': '10 1 5060 server2.example.org.'}, ], 'CNAME': [ - {'data': 'www.somedomain.org.'}, - {'data': 'www.someotherdomain.com.'}, + {'data': 'www.somezone.org.'}, + {'data': 'www.someotherzone.com.'}, ] } @@ -247,17 +247,17 @@ class TestCase(base.BaseTestCase): zone_import_fixtures = [{ 'status': 'PENDING', - 'domain_id': None, + 'zone_id': None, 'message': None, 'task_type': 'IMPORT' }, { 'status': 'ERROR', - 'domain_id': None, + 'zone_id': None, 'message': None, 'task_type': 'IMPORT' }, { 'status': 'COMPLETE', - 'domain_id': '6ca6baef-3305-4ad0-a52b-a82df5752b62', + 'zone_id': '6ca6baef-3305-4ad0-a52b-a82df5752b62', 'message': None, 'task_type': 'IMPORT' }] @@ -431,16 +431,16 @@ class TestCase(base.BaseTestCase): _values.update(values) return _values - def get_domain_fixture(self, domain_type=None, fixture=0, values=None): - domain_type = domain_type or 'PRIMARY' + def get_zone_fixture(self, zone_type=None, fixture=0, values=None): + zone_type = zone_type or 'PRIMARY' - _values = copy.copy(self.domain_fixtures[domain_type][fixture]) + _values = copy.copy(self.zone_fixtures[zone_type][fixture]) if values: _values.update(values) return _values - def get_recordset_fixture(self, domain_name, type='A', fixture=0, + def get_recordset_fixture(self, zone_name, type='A', fixture=0, values=None): values = values or {} @@ -448,7 +448,7 @@ class TestCase(base.BaseTestCase): _values.update(values) try: - _values['name'] = _values['name'] % domain_name + _values['name'] = _values['name'] % zone_name except TypeError: pass @@ -569,34 +569,34 @@ class TestCase(base.BaseTestCase): return self.central_service.create_tsigkey( context, objects.TsigKey.from_dict(values)) - def create_domain(self, **kwargs): + def create_zone(self, **kwargs): context = kwargs.pop('context', self.admin_context) fixture = kwargs.pop('fixture', 0) - domain_type = kwargs.pop('type', None) + zone_type = kwargs.pop('type', None) - values = self.get_domain_fixture(domain_type=domain_type, - fixture=fixture, values=kwargs) + values = self.get_zone_fixture(zone_type=zone_type, + fixture=fixture, values=kwargs) if 'tenant_id' not in values: values['tenant_id'] = context.tenant - return self.central_service.create_domain( - context, objects.Domain.from_dict(values)) + return self.central_service.create_zone( + context, objects.Zone.from_dict(values)) - def create_recordset(self, domain, type='A', increment_serial=True, + def create_recordset(self, zone, type='A', increment_serial=True, **kwargs): context = kwargs.pop('context', self.admin_context) fixture = kwargs.pop('fixture', 0) - values = self.get_recordset_fixture(domain['name'], type=type, + values = self.get_recordset_fixture(zone['name'], type=type, fixture=fixture, values=kwargs) return self.central_service.create_recordset( - context, domain['id'], objects.RecordSet.from_dict(values), + context, zone['id'], objects.RecordSet.from_dict(values), increment_serial=increment_serial) - def create_record(self, domain, recordset, increment_serial=True, + def create_record(self, zone, recordset, increment_serial=True, **kwargs): context = kwargs.pop('context', self.admin_context) fixture = kwargs.pop('fixture', 0) @@ -605,7 +605,7 @@ class TestCase(base.BaseTestCase): values=kwargs) return self.central_service.create_record( - context, domain['id'], recordset['id'], + context, zone['id'], recordset['id'], objects.Record.from_dict(values), increment_serial=increment_serial) @@ -645,15 +645,15 @@ class TestCase(base.BaseTestCase): context, default_pool_id, objects.PoolAttribute.from_dict(values)) - def create_zone_transfer_request(self, domain, **kwargs): + def create_zone_transfer_request(self, zone, **kwargs): context = kwargs.pop('context', self.admin_context) fixture = kwargs.pop('fixture', 0) values = self.get_zone_transfer_request_fixture( fixture=fixture, values=kwargs) - if 'domain_id' not in values: - values['domain_id'] = domain.id + if 'zone_id' not in values: + values['zone_id'] = zone.id return self.central_service.create_zone_transfer_request( context, objects.ZoneTransferRequest.from_dict(values)) @@ -669,8 +669,8 @@ class TestCase(base.BaseTestCase): if 'zone_transfer_request_id' not in values: values['zone_transfer_request_id'] = zone_transfer_request.id - if 'domain_id' not in values: - values['domain_id'] = zone_transfer_request.domain_id + if 'zone_id' not in values: + values['zone_id'] = zone_transfer_request.zone_id if 'key' not in values: values['key'] = zone_transfer_request.key diff --git a/designate/tests/test_agent/test_backends/test_bind9.py b/designate/tests/test_agent/test_backends/test_bind9.py index 7b5f8a03..fef30e06 100644 --- a/designate/tests/test_agent/test_backends/test_bind9.py +++ b/designate/tests/test_agent/test_backends/test_bind9.py @@ -37,28 +37,28 @@ class Bind9AgentBackendTestCase(TestCase, BackendTestMixin): self.backend.agent_service.stop() self.backend.stop() - def test_find_domain_serial(self): - self.backend.find_domain_serial('example.org.') + def test_find_zone_serial(self): + self.backend.find_zone_serial('example.org.') @mock.patch('designate.utils.execute') @mock.patch(('designate.backend.agent_backend.impl_bind9.Bind9Backend' - '._sync_domain')) - def test_create_domain(self, execute, sync): - domain = self._create_dnspy_zone('example.org') - self.backend.create_domain(domain) + '._sync_zone')) + def test_create_zone(self, execute, sync): + zone = self._create_dnspy_zone('example.org') + self.backend.create_zone(zone) @mock.patch('designate.utils.execute') @mock.patch(('designate.backend.agent_backend.impl_bind9.Bind9Backend' - '._sync_domain')) - def test_update_domain(self, execute, sync): - domain = self._create_dnspy_zone('example.org') - self.backend.update_domain(domain) + '._sync_zone')) + def test_update_zone(self, execute, sync): + zone = self._create_dnspy_zone('example.org') + self.backend.update_zone(zone) @mock.patch('designate.utils.execute') @mock.patch(('designate.backend.agent_backend.impl_bind9.Bind9Backend' - '._sync_domain')) - def test_delete_domain(self, execute, sync): - self.backend.delete_domain('example.org.') + '._sync_zone')) + def test_delete_zone(self, execute, sync): + self.backend.delete_zone('example.org.') # Helper def _create_dnspy_zone(self, name): diff --git a/designate/tests/test_agent/test_backends/test_denominator.py b/designate/tests/test_agent/test_backends/test_denominator.py index 2b93b2bc..eb94a100 100644 --- a/designate/tests/test_agent/test_backends/test_denominator.py +++ b/designate/tests/test_agent/test_backends/test_denominator.py @@ -40,8 +40,8 @@ class DenominatorAgentBackendTestCase(TestCase, BackendTestMixin): @mock.patch('designate.utils.execute', return_value=( 'example.org SOA 86400 ns1.designate.com. ' 'hostmaster@example.org. 475 3600 600 604800 1800', None)) - def test_find_domain_serial(self, execute): - serial = self.backend.find_domain_serial('example.org.') + def test_find_zone_serial(self, execute): + serial = self.backend.find_zone_serial('example.org.') # Ensure returned right serial number self.assertEqual(475, serial) @@ -51,22 +51,22 @@ class DenominatorAgentBackendTestCase(TestCase, BackendTestMixin): self.assertIn('get', execute.call_args[0]) @mock.patch('designate.utils.execute', return_value=('', None)) - def test_find_domain_serial_fail(self, execute): - serial = self.backend.find_domain_serial('example.org.') + def test_find_zone_serial_fail(self, execute): + serial = self.backend.find_zone_serial('example.org.') self.assertIsNone(serial) @mock.patch('designate.utils.execute', return_value=(None, None)) - def test_create_domain(self, execute): - domain = self._create_dnspy_zone('example.org.') - self.backend.create_domain(domain) + def test_create_zone(self, execute): + zone = self._create_dnspy_zone('example.org.') + self.backend.create_zone(zone) # Ensure denominator called for each record (except SOA) # plus one to update zone data - self.assertEqual(len(list(domain.iterate_rdatas())), + self.assertEqual(len(list(zone.iterate_rdatas())), execute.call_count) @mock.patch('designate.utils.execute') - def test_update_domain(self, execute): + def test_update_zone(self, execute): # Output from 'designate record list' command records = ('example.org SOA 86400 ns1.designate.com. ' 'hostmaster@example.org. 475 3600 600 604800 1800\n' @@ -74,12 +74,12 @@ class DenominatorAgentBackendTestCase(TestCase, BackendTestMixin): 'example.org NS 86400 ns2.designator.net.\n' 'example.org MX 86400 10 mx1.designator.net.') - # That should force update_domain to delete A and AAAA records + # That should force update_zone to delete A and AAAA records # from the zone and create a new MX record. execute.return_value = (records, None) - domain = self._create_dnspy_zone('example.org.') - self.backend.update_domain(domain) + zone = self._create_dnspy_zone('example.org.') + self.backend.update_zone(zone) # Ensure denominator called to: # *update zone info @@ -99,7 +99,7 @@ class DenominatorAgentBackendTestCase(TestCase, BackendTestMixin): setattr(self.backend.denominator, method, mock.Mock( return_value=records)) - self.backend.update_domain(domain) + self.backend.update_zone(zone) self.assertEqual(1, self.backend.denominator.update_zone.call_count) self.assertEqual(1, self.backend.denominator.get_records.call_count) self.assertEqual(4, self.backend.denominator.create_record.call_count) @@ -107,8 +107,8 @@ class DenominatorAgentBackendTestCase(TestCase, BackendTestMixin): self.assertEqual(1, self.backend.denominator.delete_record.call_count) @mock.patch('designate.utils.execute', return_value=(None, None)) - def test_delete_domain(self, execute): - self.backend.delete_domain('example.org.') + def test_delete_zone(self, execute): + self.backend.delete_zone('example.org.') # Ensure called 'denominator zone delete' self.assertEqual(1, execute.call_count) diff --git a/designate/tests/test_agent/test_backends/test_fake.py b/designate/tests/test_agent/test_backends/test_fake.py index ba0c0492..a6f66f82 100644 --- a/designate/tests/test_agent/test_backends/test_fake.py +++ b/designate/tests/test_agent/test_backends/test_fake.py @@ -36,19 +36,19 @@ class FakeAgentBackendTestCase(TestCase, BackendTestMixin): self.backend.agent_service.stop() self.backend.stop() - def test_find_domain_serial(self): - self.backend.find_domain_serial('example.org.') + def test_find_zone_serial(self): + self.backend.find_zone_serial('example.org.') - def test_create_domain(self): - domain = self._create_dnspy_zone('example.org') - self.backend.create_domain(domain) + def test_create_zone(self): + zone = self._create_dnspy_zone('example.org') + self.backend.create_zone(zone) - def test_update_domain(self): - domain = self._create_dnspy_zone('example.org') - self.backend.update_domain(domain) + def test_update_zone(self): + zone = self._create_dnspy_zone('example.org') + self.backend.update_zone(zone) - def test_delete_domain(self): - self.backend.delete_domain('example.org.') + def test_delete_zone(self): + self.backend.delete_zone('example.org.') # Helper def _create_dnspy_zone(self, name): diff --git a/designate/tests/test_agent/test_handler.py b/designate/tests/test_agent/test_handler.py index e62f67aa..666928ff 100644 --- a/designate/tests/test_agent/test_handler.py +++ b/designate/tests/test_agent/test_handler.py @@ -106,7 +106,7 @@ class AgentRequestHandlerTest(AgentTestCase): request.environ = {'addr': ["0.0.0.0", 1234]} with mock.patch.object( designate.backend.agent_backend.impl_fake.FakeBackend, - 'find_domain_serial', return_value=None): + 'find_zone_serial', return_value=None): response = next(self.handler(request)).to_wire() self.assertEqual(expected_response, binascii.b2a_hex(response)) @@ -205,7 +205,7 @@ class AgentRequestHandlerTest(AgentTestCase): request.environ = {'addr': ["0.0.0.0", 1234]} with mock.patch.object( designate.backend.agent_backend.impl_fake.FakeBackend, - 'find_domain_serial', return_value=None): + 'find_zone_serial', return_value=None): response = next(self.handler(request)).to_wire() doaxfr.assert_called_with('example.com.', [], source="1.2.3.4") self.assertEqual(expected_response, binascii.b2a_hex(response)) diff --git a/designate/tests/test_api/test_admin/extensions/test_quotas.py b/designate/tests/test_api/test_admin/extensions/test_quotas.py index fcb34cdc..4c25d79a 100644 --- a/designate/tests/test_api/test_admin/extensions/test_quotas.py +++ b/designate/tests/test_api/test_admin/extensions/test_quotas.py @@ -46,8 +46,8 @@ class AdminApiQuotasTest(AdminApiTestCase): max_zones = response.json['quota']['zones'] max_zone_records = response.json['quota']['zone_records'] - self.assertEqual(cfg.CONF.quota_domains, max_zones) - self.assertEqual(cfg.CONF.quota_domain_records, max_zone_records) + self.assertEqual(cfg.CONF.quota_zones, max_zones) + self.assertEqual(cfg.CONF.quota_zone_records, max_zone_records) def test_patch_quotas(self): self.policy({'set_quotas': '@'}) diff --git a/designate/tests/test_api/test_admin/extensions/test_reports.py b/designate/tests/test_api/test_admin/extensions/test_reports.py index 2258159d..8c1c75cf 100644 --- a/designate/tests/test_api/test_admin/extensions/test_reports.py +++ b/designate/tests/test_api/test_admin/extensions/test_reports.py @@ -45,10 +45,10 @@ class AdminApiReportsTest(AdminApiTestCase): self.assertEqual(0, response.json['counts'][0]['records']) self.assertEqual(0, response.json['counts'][0]['tenants']) - # Add a domain and check the counts - self.create_domain() + # Add a zone and check the counts + self.create_zone() response = self.client.get('/reports/counts') - # Should be one domain + # Should be one zone self.assertEqual(1, response.json['counts'][0]['zones']) # Should be 1 NS and 1 SOA records self.assertEqual(2, response.json['counts'][0]['records']) @@ -56,7 +56,7 @@ class AdminApiReportsTest(AdminApiTestCase): self.assertEqual(1, response.json['counts'][0]['tenants']) def test_get_counts_zones(self): - self.policy({'count_domains': '@'}) + self.policy({'count_zones': '@'}) response = self.client.get('/reports/counts/zones') self.assertEqual(200, response.status_int) @@ -67,9 +67,9 @@ class AdminApiReportsTest(AdminApiTestCase): self.assertEqual(0, response.json['counts'][0]['zones']) - # Create 2 domains - self.create_domain(fixture=0) - self.create_domain(fixture=1) + # Create 2 zones + self.create_zone(fixture=0) + self.create_zone(fixture=1) response = self.client.get('/reports/counts/zones') @@ -87,8 +87,8 @@ class AdminApiReportsTest(AdminApiTestCase): self.assertEqual(0, response.json['counts'][0]['records']) - # Create a domain - self.create_domain() + # Create a zone + self.create_zone() response = self.client.get('/reports/counts/records') @@ -107,8 +107,8 @@ class AdminApiReportsTest(AdminApiTestCase): self.assertEqual(0, response.json['counts'][0]['tenants']) - # Create a domain - self.create_domain() + # Create a zone + self.create_zone() response = self.client.get('/reports/counts/tenants') @@ -117,7 +117,7 @@ class AdminApiReportsTest(AdminApiTestCase): def test_get_tenants(self): self.policy({'find_tenants': '@'}) - self.create_domain() + self.create_zone() response = self.client.get('/reports/tenants') @@ -131,8 +131,8 @@ class AdminApiReportsTest(AdminApiTestCase): def test_get_tenant(self): self.policy({'find_tenants': '@'}) - domain = self.create_domain() - tenant = domain.tenant_id + zone = self.create_zone() + tenant = zone.tenant_id response = self.client.get('/reports/tenants/%s' % tenant) self.assertEqual(200, response.status_int) diff --git a/designate/tests/test_api/test_middleware.py b/designate/tests/test_api/test_middleware.py index 661eeea7..616250aa 100644 --- a/designate/tests/test_api/test_middleware.py +++ b/designate/tests/test_api/test_middleware.py @@ -230,7 +230,7 @@ class FaultMiddlewareTest(ApiTestCase): class RaisingRequest(FakeRequest): def get_response(self, request): - raise exceptions.DuplicateDomain() + raise exceptions.DuplicateZone() request = RaisingRequest() ctxt = context.DesignateContext() diff --git a/designate/tests/test_api/test_v1/test_domains.py b/designate/tests/test_api/test_v1/test_domains.py index ccc70689..55d3d20a 100644 --- a/designate/tests/test_api/test_v1/test_domains.py +++ b/designate/tests/test_api/test_v1/test_domains.py @@ -29,8 +29,8 @@ from designate.tests.test_api.test_v1 import ApiV1Test LOG = logging.getLogger(__name__) -class ApiV1DomainsTest(ApiV1Test): - def test_get_domain_schema(self): +class ApiV1zonesTest(ApiV1Test): + def test_get_zone_schema(self): response = self.get('schemas/domain') self.assertIn('description', response.json) self.assertIn('links', response.json) @@ -46,7 +46,7 @@ class ApiV1DomainsTest(ApiV1Test): self.assertIn('ttl', response.json['properties']) self.assertIn('serial', response.json['properties']) - def test_get_domains_schema(self): + def test_get_zones_schema(self): response = self.get('schemas/domains') self.assertIn('description', response.json) self.assertIn('additionalProperties', response.json) @@ -54,9 +54,9 @@ class ApiV1DomainsTest(ApiV1Test): self.assertIn('title', response.json) self.assertIn('id', response.json) - def test_create_domain(self): - # Create a domain - fixture = self.get_domain_fixture(0) + def test_create_zone(self): + # Create a zone + fixture = self.get_zone_fixture(0) # V1 doesn't have these del fixture['type'] @@ -67,9 +67,9 @@ class ApiV1DomainsTest(ApiV1Test): self.assertIn('name', response.json) self.assertEqual(response.json['name'], fixture['name']) - def test_create_domain_junk(self): - # Create a domain - fixture = self.get_domain_fixture(0) + def test_create_zone_junk(self): + # Create a zone + fixture = self.get_zone_fixture(0) # Add a junk property fixture['junk'] = 'Junk Field' @@ -77,60 +77,60 @@ class ApiV1DomainsTest(ApiV1Test): # Ensure it fails with a 400 self.post('domains', data=fixture, status_code=400) - @patch.object(central_service.Service, 'create_domain', + @patch.object(central_service.Service, 'create_zone', side_effect=messaging.MessagingTimeout()) - def test_create_domain_timeout(self, _): - # Create a domain - fixture = self.get_domain_fixture(0) + def test_create_zone_timeout(self, _): + # Create a zone + fixture = self.get_zone_fixture(0) # V1 doesn't have these del fixture['type'] self.post('domains', data=fixture, status_code=504) - @patch.object(central_service.Service, 'create_domain', - side_effect=exceptions.DuplicateDomain()) - def test_create_domain_duplicate(self, _): - # Create a domain - fixture = self.get_domain_fixture(0) + @patch.object(central_service.Service, 'create_zone', + side_effect=exceptions.DuplicateZone()) + def test_create_zone_duplicate(self, _): + # Create a zone + fixture = self.get_zone_fixture(0) # V1 doesn't have these del fixture['type'] self.post('domains', data=fixture, status_code=409) - def test_create_domain_null_ttl(self): - # Create a domain - fixture = self.get_domain_fixture(0) + def test_create_zone_null_ttl(self): + # Create a zone + fixture = self.get_zone_fixture(0) fixture['ttl'] = None self.post('domains', data=fixture, status_code=400) - def test_create_domain_negative_ttl(self): - # Create a domain - fixture = self.get_domain_fixture(0) + def test_create_zone_negative_ttl(self): + # Create a zone + fixture = self.get_zone_fixture(0) fixture['ttl'] = -1 self.post('domains', data=fixture, status_code=400) - def test_create_domain_zero_ttl(self): - # Create a domain - fixture = self.get_domain_fixture(0) + def test_create_zone_zero_ttl(self): + # Create a zone + fixture = self.get_zone_fixture(0) fixture['ttl'] = 0 self.post('domains', data=fixture, status_code=400) - def test_create_domain_invalid_ttl(self): - # Create a domain - fixture = self.get_domain_fixture(0) + def test_create_zone_invalid_ttl(self): + # Create a zone + fixture = self.get_zone_fixture(0) fixture['ttl'] = "$?>&" self.post('domains', data=fixture, status_code=400) - def test_create_domain_ttl_greater_than_max(self): - fixture = self.get_domain_fixture(0) + def test_create_zone_ttl_greater_than_max(self): + fixture = self.get_zone_fixture(0) fixture['ttl'] = 2147483648 self.post('domains', data=fixture, status_code=400) - def test_create_domain_utf_description(self): - # Create a domain - fixture = self.get_domain_fixture(0) + def test_create_zone_utf_description(self): + # Create a zone + fixture = self.get_zone_fixture(0) # V1 doesn't have type del fixture['type'] @@ -138,27 +138,27 @@ class ApiV1DomainsTest(ApiV1Test): # Give it a UTF-8 filled description fixture['description'] = "utf-8:2H₂+O₂⇌2H₂O,R=4.7kΩ,⌀200mm∮E⋅da=Q,n" \ ",∑f(i)=∏g(i),∀x∈ℝ:⌈x⌉" - # Create the domain, ensuring it succeeds, thus UTF-8 is supported + # Create the zone, ensuring it succeeds, thus UTF-8 is supported self.post('domains', data=fixture) - def test_create_domain_description_too_long(self): - # Create a domain - fixture = self.get_domain_fixture(0) + def test_create_zone_description_too_long(self): + # Create a zone + fixture = self.get_zone_fixture(0) fixture['description'] = "x" * 161 - # Create the domain, ensuring it fails with a 400 + # Create the zone, ensuring it fails with a 400 self.post('domains', data=fixture, status_code=400) - def test_create_domain_with_unwanted_attributes(self): + def test_create_zone_with_unwanted_attributes(self): - domain_id = "2d1d1d1d-1324-4a80-aa32-1f69a91bf2c8" + zone_id = "2d1d1d1d-1324-4a80-aa32-1f69a91bf2c8" created_at = datetime.datetime(2014, 6, 22, 21, 50, 0) updated_at = datetime.datetime(2014, 6, 22, 21, 50, 0) serial = 1234567 - # Create a domain - fixture = self.get_domain_fixture(0) - fixture['id'] = domain_id + # Create a zone + fixture = self.get_zone_fixture(0) + fixture['id'] = zone_id fixture['created_at'] = created_at fixture['updated_at'] = updated_at fixture['serial'] = serial @@ -166,8 +166,8 @@ class ApiV1DomainsTest(ApiV1Test): self.post('domains', data=fixture, status_code=400) def test_create_invalid_name(self): - # Prepare a domain - fixture = self.get_domain_fixture(0) + # Prepare a zone + fixture = self.get_zone_fixture(0) invalid_names = [ 'org', @@ -183,8 +183,8 @@ class ApiV1DomainsTest(ApiV1Test): self.assertNotIn('id', response.json) - def test_create_domain_name_too_long(self): - fixture = self.get_domain_fixture(0) + def test_create_zone_name_too_long(self): + fixture = self.get_zone_fixture(0) long_name = 'a' * 255 + ".org." fixture['name'] = long_name @@ -193,14 +193,14 @@ class ApiV1DomainsTest(ApiV1Test): self.assertNotIn('id', response.json) - def test_create_domain_name_is_not_present(self): - fixture = self.get_domain_fixture(0) + def test_create_zone_name_is_not_present(self): + fixture = self.get_zone_fixture(0) del fixture['name'] self.post('domains', data=fixture, status_code=400) def test_create_invalid_email(self): - # Prepare a domain - fixture = self.get_domain_fixture(0) + # Prepare a zone + fixture = self.get_zone_fixture(0) invalid_emails = [ 'org', @@ -220,8 +220,8 @@ class ApiV1DomainsTest(ApiV1Test): self.assertNotIn('id', response.json) - def test_create_domain_email_too_long(self): - fixture = self.get_domain_fixture(0) + def test_create_zone_email_too_long(self): + fixture = self.get_zone_fixture(0) long_email = 'a' * 255 + "@org.com" fixture['email'] = long_email @@ -230,154 +230,154 @@ class ApiV1DomainsTest(ApiV1Test): self.assertNotIn('id', response.json) - def test_create_domain_email_not_present(self): - fixture = self.get_domain_fixture(0) + def test_create_zone_email_not_present(self): + fixture = self.get_zone_fixture(0) del fixture['email'] self.post('domains', data=fixture, status_code=400) - def test_get_domains(self): + def test_get_zones(self): response = self.get('domains') self.assertIn('domains', response.json) self.assertEqual(0, len(response.json['domains'])) - # Create a domain - self.create_domain() + # Create a zone + self.create_zone() response = self.get('domains') self.assertIn('domains', response.json) self.assertEqual(1, len(response.json['domains'])) - # Create a second domain - self.create_domain(fixture=1) + # Create a second zone + self.create_zone(fixture=1) response = self.get('domains') self.assertIn('domains', response.json) self.assertEqual(2, len(response.json['domains'])) - def test_get_domain_servers(self): - # Create a domain - domain = self.create_domain() - response = self.get('domains/%s/servers' % domain['id']) - # Verify length of domain servers + def test_get_zone_servers(self): + # Create a zone + zone = self.create_zone() + response = self.get('domains/%s/servers' % zone['id']) + # Verify length of zone servers self.assertEqual(1, len(response.json['servers'])) - @patch.object(central_service.Service, 'find_domains', + @patch.object(central_service.Service, 'find_zones', side_effect=messaging.MessagingTimeout()) - def test_get_domains_timeout(self, _): + def test_get_zones_timeout(self, _): self.get('domains', status_code=504) - def test_get_domain(self): - # Create a domain - domain = self.create_domain() + def test_get_zone(self): + # Create a zone + zone = self.create_zone() - response = self.get('domains/%s' % domain['id']) + response = self.get('domains/%s' % zone['id']) self.assertIn('id', response.json) - self.assertEqual(response.json['id'], domain['id']) + self.assertEqual(response.json['id'], zone['id']) - @patch.object(central_service.Service, 'find_domain', + @patch.object(central_service.Service, 'find_zone', side_effect=messaging.MessagingTimeout()) - def test_get_domain_timeout(self, _): - # Create a domain - domain = self.create_domain() + def test_get_zone_timeout(self, _): + # Create a zone + zone = self.create_zone() - self.get('domains/%s' % domain['id'], status_code=504) + self.get('domains/%s' % zone['id'], status_code=504) - def test_get_domain_missing(self): + def test_get_zone_missing(self): self.get('domains/2fdadfb1-cf96-4259-ac6b-bb7b6d2ff980', status_code=404) - def test_get_domain_invalid_id(self): + def test_get_zone_invalid_id(self): # The letter "G" is not valid in a UUID self.get('domains/2fdadfb1-cf96-4259-ac6b-bb7b6d2ff9GG', status_code=404) self.get('domains/2fdadfb1cf964259ac6bbb7b6d2ff980', status_code=404) - def test_update_domain(self): - # Create a domain - domain = self.create_domain() + def test_update_zone(self): + # Create a zone + zone = self.create_zone() - data = {'email': 'prefix-%s' % domain['email']} + data = {'email': 'prefix-%s' % zone['email']} - response = self.put('domains/%s' % domain['id'], data=data) + response = self.put('domains/%s' % zone['id'], data=data) self.assertIn('id', response.json) - self.assertEqual(response.json['id'], domain['id']) + self.assertEqual(response.json['id'], zone['id']) self.assertIn('email', response.json) - self.assertEqual('prefix-%s' % domain['email'], response.json['email']) + self.assertEqual('prefix-%s' % zone['email'], response.json['email']) - def test_update_domain_junk(self): - # Create a domain - domain = self.create_domain() + def test_update_zone_junk(self): + # Create a zone + zone = self.create_zone() - data = {'email': 'prefix-%s' % domain['email'], 'junk': 'Junk Field'} + data = {'email': 'prefix-%s' % zone['email'], 'junk': 'Junk Field'} - self.put('domains/%s' % domain['id'], data=data, status_code=400) + self.put('domains/%s' % zone['id'], data=data, status_code=400) - def test_update_domain_name_fail(self): - # Create a domain - domain = self.create_domain() + def test_update_zone_name_fail(self): + # Create a zone + zone = self.create_zone() data = {'name': 'renamed.com.'} - self.put('domains/%s' % domain['id'], data=data, status_code=400) + self.put('domains/%s' % zone['id'], data=data, status_code=400) - def test_update_domain_null_ttl(self): - # Create a domain - domain = self.create_domain() + def test_update_zone_null_ttl(self): + # Create a zone + zone = self.create_zone() data = {'ttl': None} - self.put('domains/%s' % domain['id'], data=data, status_code=400) + self.put('domains/%s' % zone['id'], data=data, status_code=400) - def test_update_domain_negative_ttl(self): - # Create a domain - domain = self.create_domain() + def test_update_zone_negative_ttl(self): + # Create a zone + zone = self.create_zone() data = {'ttl': -1} - self.put('domains/%s' % domain['id'], data=data, status_code=400) + self.put('domains/%s' % zone['id'], data=data, status_code=400) - def test_update_domain_zero_ttl(self): - # Create a domain - domain = self.create_domain() + def test_update_zone_zero_ttl(self): + # Create a zone + zone = self.create_zone() data = {'ttl': 0} - self.put('domains/%s' % domain['id'], data=data, status_code=400) + self.put('domains/%s' % zone['id'], data=data, status_code=400) - @patch.object(central_service.Service, 'update_domain', + @patch.object(central_service.Service, 'update_zone', side_effect=messaging.MessagingTimeout()) - def test_update_domain_timeout(self, _): - # Create a domain - domain = self.create_domain() + def test_update_zone_timeout(self, _): + # Create a zone + zone = self.create_zone() - data = {'email': 'prefix-%s' % domain['email']} + data = {'email': 'prefix-%s' % zone['email']} - self.put('domains/%s' % domain['id'], data=data, status_code=504) + self.put('domains/%s' % zone['id'], data=data, status_code=504) - @patch.object(central_service.Service, 'update_domain', - side_effect=exceptions.DuplicateDomain()) - def test_update_domain_duplicate(self, _): - # Create a domain - domain = self.create_domain() + @patch.object(central_service.Service, 'update_zone', + side_effect=exceptions.DuplicateZone()) + def test_update_zone_duplicate(self, _): + # Create a zone + zone = self.create_zone() - data = {'email': 'prefix-%s' % domain['email']} + data = {'email': 'prefix-%s' % zone['email']} - self.put('domains/%s' % domain['id'], data=data, status_code=409) + self.put('domains/%s' % zone['id'], data=data, status_code=409) - def test_update_domain_missing(self): + def test_update_zone_missing(self): data = {'email': 'bla@bla.com'} self.put('domains/2fdadfb1-cf96-4259-ac6b-bb7b6d2ff980', data=data, status_code=404) - def test_update_domain_invalid_id(self): + def test_update_zone_invalid_id(self): data = {'email': 'bla@bla.com'} # The letter "G" is not valid in a UUID @@ -387,17 +387,17 @@ class ApiV1DomainsTest(ApiV1Test): self.put('domains/2fdadfb1cf964259ac6bbb7b6d2ff980', data=data, status_code=404) - def test_update_domain_ttl_greter_than_max(self): - # Create a domain - domain = self.create_domain() + def test_update_zone_ttl_greter_than_max(self): + # Create a zone + zone = self.create_zone() data = {'ttl': 2147483648} - self.put('domains/%s' % domain['id'], data=data, status_code=400) + self.put('domains/%s' % zone['id'], data=data, status_code=400) - def test_update_domain_invalid_email(self): - # Create a domain - domain = self.create_domain() + def test_update_zone_invalid_email(self): + # Create a zone + zone = self.create_zone() invalid_emails = [ 'org', @@ -413,45 +413,45 @@ class ApiV1DomainsTest(ApiV1Test): for invalid_email in invalid_emails: data = {'email': invalid_email} - self.put('domains/%s' % domain['id'], data=data, status_code=400) + self.put('domains/%s' % zone['id'], data=data, status_code=400) - def test_update_domain_description_too_long(self): - # Create a domain - domain = self.create_domain() + def test_update_zone_description_too_long(self): + # Create a zone + zone = self.create_zone() invalid_des = 'a' * 165 data = {'description': invalid_des} - self.put('domains/%s' % domain['id'], data=data, status_code=400) + self.put('domains/%s' % zone['id'], data=data, status_code=400) - def test_delete_domain(self): - # Create a domain - domain = self.create_domain() + def test_delete_zone(self): + # Create a zone + zone = self.create_zone() - self.delete('domains/%s' % domain['id']) + self.delete('domains/%s' % zone['id']) - # Simulate the domain having been deleted on the backend - domain_serial = self.central_service.get_domain( - self.admin_context, domain['id']).serial + # Simulate the zone having been deleted on the backend + zone_serial = self.central_service.get_zone( + self.admin_context, zone['id']).serial self.central_service.update_status( - self.admin_context, domain['id'], "SUCCESS", domain_serial) + self.admin_context, zone['id'], "SUCCESS", zone_serial) - # Ensure we can no longer fetch the domain - self.get('domains/%s' % domain['id'], status_code=404) + # Ensure we can no longer fetch the zone + self.get('domains/%s' % zone['id'], status_code=404) - @patch.object(central_service.Service, 'delete_domain', + @patch.object(central_service.Service, 'delete_zone', side_effect=messaging.MessagingTimeout()) - def test_delete_domain_timeout(self, _): - # Create a domain - domain = self.create_domain() + def test_delete_zone_timeout(self, _): + # Create a zone + zone = self.create_zone() - self.delete('domains/%s' % domain['id'], status_code=504) + self.delete('domains/%s' % zone['id'], status_code=504) - def test_delete_domain_missing(self): + def test_delete_zone_missing(self): self.delete('domains/2fdadfb1-cf96-4259-ac6b-bb7b6d2ff980', status_code=404) - def test_delete_domain_invalid_id(self): + def test_delete_zone_invalid_id(self): # The letter "G" is not valid in a UUID self.delete('domains/2fdadfb1-cf96-4259-ac6b-bb7b6d2ff9GG', status_code=404) @@ -460,31 +460,31 @@ class ApiV1DomainsTest(ApiV1Test): status_code=404) def test_get_secondary_missing(self): - fixture = self.get_domain_fixture('SECONDARY', 0) + fixture = self.get_zone_fixture('SECONDARY', 0) fixture['email'] = cfg.CONF['service:central'].managed_resource_email - domain = self.create_domain(**fixture) + zone = self.create_zone(**fixture) - self.get('domains/%s' % domain.id, status_code=404) + self.get('domains/%s' % zone.id, status_code=404) def test_update_secondary_missing(self): - fixture = self.get_domain_fixture('SECONDARY', 0) + fixture = self.get_zone_fixture('SECONDARY', 0) fixture['email'] = cfg.CONF['service:central'].managed_resource_email - domain = self.create_domain(**fixture) + zone = self.create_zone(**fixture) - self.put('domains/%s' % domain.id, {}, status_code=404) + self.put('domains/%s' % zone.id, {}, status_code=404) def test_delete_secondary_missing(self): - fixture = self.get_domain_fixture('SECONDARY', 0) + fixture = self.get_zone_fixture('SECONDARY', 0) fixture['email'] = cfg.CONF['service:central'].managed_resource_email - domain = self.create_domain(**fixture) - self.delete('domains/%s' % domain.id, status_code=404) + zone = self.create_zone(**fixture) + self.delete('domains/%s' % zone.id, status_code=404) - def test_get_domain_servers_from_secondary(self): - fixture = self.get_domain_fixture('SECONDARY', 0) + def test_get_zone_servers_from_secondary(self): + fixture = self.get_zone_fixture('SECONDARY', 0) fixture['email'] = cfg.CONF['service:central'].managed_resource_email - domain = self.create_domain(**fixture) - self.get('domains/%s/servers' % domain.id, status_code=404) + zone = self.create_zone(**fixture) + self.get('domains/%s/servers' % zone.id, status_code=404) diff --git a/designate/tests/test_api/test_v1/test_records.py b/designate/tests/test_api/test_v1/test_records.py index e336efd8..461b2eb4 100644 --- a/designate/tests/test_api/test_v1/test_records.py +++ b/designate/tests/test_api/test_v1/test_records.py @@ -29,8 +29,8 @@ class ApiV1RecordsTest(ApiV1Test): def setUp(self): super(ApiV1RecordsTest, self).setUp() - self.domain = self.create_domain() - self.recordset = self.create_recordset(self.domain, 'A') + self.zone = self.create_zone() + self.recordset = self.create_recordset(self.zone, 'A') def test_get_record_schema(self): response = self.get('schemas/record') @@ -62,7 +62,7 @@ class ApiV1RecordsTest(ApiV1Test): def test_create_record(self): recordset_fixture = self.get_recordset_fixture( - self.domain['name']) + self.zone['name']) fixture = self.get_record_fixture(recordset_fixture['type']) fixture.update({ @@ -71,7 +71,7 @@ class ApiV1RecordsTest(ApiV1Test): }) # Create a record - response = self.post('domains/%s/records' % self.domain['id'], + response = self.post('domains/%s/records' % self.zone['id'], data=fixture) self.assertIn('id', response.json) @@ -86,7 +86,7 @@ class ApiV1RecordsTest(ApiV1Test): }) # Create a record - response = self.post('domains/%s/records' % self.domain['id'], + response = self.post('domains/%s/records' % self.zone['id'], data=fixture) self.assertIn('id', response.json) @@ -107,38 +107,38 @@ class ApiV1RecordsTest(ApiV1Test): }) # Create 2 records - record_1 = self.post('domains/%s/records' % self.domain['id'], + record_1 = self.post('domains/%s/records' % self.zone['id'], data=fixture_1) - record_2 = self.post('domains/%s/records' % self.domain['id'], + record_2 = self.post('domains/%s/records' % self.zone['id'], data=fixture_2) # Delete record 1, this should not have any side effects - self.delete('domains/%s/records/%s' % (self.domain['id'], + self.delete('domains/%s/records/%s' % (self.zone['id'], record_1.json['id'])) # Simulate the record 1 having been deleted on the backend - domain_serial = self.central_service.get_domain( - self.admin_context, self.domain['id']).serial + zone_serial = self.central_service.get_zone( + self.admin_context, self.zone['id']).serial self.central_service.update_status( - self.admin_context, self.domain['id'], "SUCCESS", domain_serial) + self.admin_context, self.zone['id'], "SUCCESS", zone_serial) # Get the record 2 to ensure recordset did not get deleted rec_2_get_response = self.get('domains/%s/records/%s' % - (self.domain['id'], record_2.json['id'])) + (self.zone['id'], record_2.json['id'])) self.assertIn('id', rec_2_get_response.json) self.assertIn('name', rec_2_get_response.json) self.assertEqual(rec_2_get_response.json['name'], fixture_1['name']) # Delete record 2, this should delete the null recordset too - self.delete('domains/%s/records/%s' % (self.domain['id'], + self.delete('domains/%s/records/%s' % (self.zone['id'], record_2.json['id'])) # Simulate the record 2 having been deleted on the backend - domain_serial = self.central_service.get_domain( - self.admin_context, self.domain['id']).serial + zone_serial = self.central_service.get_zone( + self.admin_context, self.zone['id']).serial self.central_service.update_status( - self.admin_context, self.domain['id'], "SUCCESS", domain_serial) + self.admin_context, self.zone['id'], "SUCCESS", zone_serial) # Re-create as a different type, but use the same name fixture = self.get_record_fixture('CNAME') @@ -147,7 +147,7 @@ class ApiV1RecordsTest(ApiV1Test): 'type': 'CNAME' }) - response = self.post('domains/%s/records' % self.domain['id'], + response = self.post('domains/%s/records' % self.zone['id'], data=fixture) self.assertIn('id', response.json) @@ -165,27 +165,27 @@ class ApiV1RecordsTest(ApiV1Test): fixture['junk'] = 'Junk Field' # Create a record, Ensuring it fails with a 400 - self.post('domains/%s/records' % self.domain['id'], data=fixture, + self.post('domains/%s/records' % self.zone['id'], data=fixture, status_code=400) def test_create_wildcard_record_after_named(self): # We want to test that a wildcard record rs doesnt use the previous one # https://bugs.launchpad.net/designate/+bug/1391426 - name = "foo.%s" % self.domain.name + name = "foo.%s" % self.zone.name fixture = { "name": name, "type": "A", "data": "10.0.0.1" } - self.post('domains/%s/records' % self.domain['id'], + self.post('domains/%s/records' % self.zone['id'], data=fixture) - wildcard_name = '*.%s' % self.domain["name"] + wildcard_name = '*.%s' % self.zone["name"] fixture['name'] = wildcard_name - self.post('domains/%s/records' % self.domain['id'], + self.post('domains/%s/records' % self.zone['id'], data=fixture) named_rs = self.central_service.find_recordset( @@ -208,7 +208,7 @@ class ApiV1RecordsTest(ApiV1Test): ",∑f(i)=∏g(i),∀x∈ℝ:⌈x⌉" # Create a record, Ensuring it succeeds - self.post('domains/%s/records' % self.domain['id'], data=fixture) + self.post('domains/%s/records' % self.zone['id'], data=fixture) def test_create_record_description_too_long(self): fixture = self.get_record_fixture(self.recordset['type']) @@ -221,32 +221,32 @@ class ApiV1RecordsTest(ApiV1Test): fixture['description'] = "x" * 161 # Create a record, Ensuring it Fails with a 400 - self.post('domains/%s/records' % self.domain['id'], data=fixture, + self.post('domains/%s/records' % self.zone['id'], data=fixture, status_code=400) def test_create_record_name_too_long(self): fixture = self.get_record_fixture(self.recordset['type']) fixture.update({'type': self.recordset['type']}) - fixture['name'] = 'w' * 255 + ".%s" % self.domain.name - self.post('domains/%s/records' % self.domain['id'], data=fixture, + fixture['name'] = 'w' * 255 + ".%s" % self.zone.name + self.post('domains/%s/records' % self.zone['id'], data=fixture, status_code=400) def test_create_record_name_is_missing(self): fixture = self.get_record_fixture(self.recordset['type']) fixture.update({'type': self.recordset['type']}) - self.post('domains/%s/records' % self.domain['id'], data=fixture, + self.post('domains/%s/records' % self.zone['id'], data=fixture, status_code=400) def test_create_record_type_is_missing(self): fixture = self.get_record_fixture(self.recordset['type']) - fixture['name'] = "www.%s" % self.domain.name - self.post('domains/%s/records' % self.domain['id'], data=fixture, + fixture['name'] = "www.%s" % self.zone.name + self.post('domains/%s/records' % self.zone['id'], data=fixture, status_code=400) def test_create_record_invalid_type(self): fixture = self.get_record_fixture(self.recordset['type']) fixture.update({'type': "ABC", 'name': self.recordset['name']}) - self.post('domains/%s/records' % self.domain['id'], data=fixture, + self.post('domains/%s/records' % self.zone['id'], data=fixture, status_code=400) def test_create_record_data_is_missing(self): @@ -254,7 +254,7 @@ class ApiV1RecordsTest(ApiV1Test): fixture.update({'type': self.recordset['type'], 'name': self.recordset['name']}) del fixture['data'] - self.post('domains/%s/records' % self.domain['id'], data=fixture, + self.post('domains/%s/records' % self.zone['id'], data=fixture, status_code=400) def test_create_record_ttl_greater_than_max(self): @@ -265,7 +265,7 @@ class ApiV1RecordsTest(ApiV1Test): }) fixture['ttl'] = 2174483648 - self.post('domains/%s/records' % self.domain['id'], data=fixture, + self.post('domains/%s/records' % self.zone['id'], data=fixture, status_code=400) def test_create_record_negative_ttl(self): @@ -279,7 +279,7 @@ class ApiV1RecordsTest(ApiV1Test): fixture['ttl'] = -1 # Create a record, Ensuring it Fails with a 400 - self.post('domains/%s/records' % self.domain['id'], data=fixture, + self.post('domains/%s/records' % self.zone['id'], data=fixture, status_code=400) def test_create_record_zero_ttl(self): @@ -293,7 +293,7 @@ class ApiV1RecordsTest(ApiV1Test): fixture['ttl'] = 0 # Create a record, Ensuring it Fails with a 400 - self.post('domains/%s/records' % self.domain['id'], data=fixture, + self.post('domains/%s/records' % self.zone['id'], data=fixture, status_code=400) def test_create_record_invalid_ttl(self): @@ -307,7 +307,7 @@ class ApiV1RecordsTest(ApiV1Test): fixture['ttl'] = "$?!." # Create a record, Ensuring it Fails with a 400 - self.post('domains/%s/records' % self.domain['id'], data=fixture, + self.post('domains/%s/records' % self.zone['id'], data=fixture, status_code=400) def test_create_record_invalid_priority(self): @@ -317,7 +317,7 @@ class ApiV1RecordsTest(ApiV1Test): 'type': self.recordset['type'], }) fixture['priority'] = "$?!." - self.post('domains/%s/records' % self.domain['id'], data=fixture, + self.post('domains/%s/records' % self.zone['id'], data=fixture, status_code=400) def test_create_record_negative_priority(self): @@ -327,7 +327,7 @@ class ApiV1RecordsTest(ApiV1Test): 'type': self.recordset['type'], }) fixture['priority'] = -1 - self.post('domains/%s/records' % self.domain['id'], data=fixture, + self.post('domains/%s/records' % self.zone['id'], data=fixture, status_code=400) def test_create_record_priority_greater_than_max(self): @@ -337,7 +337,7 @@ class ApiV1RecordsTest(ApiV1Test): 'type': self.recordset['type'], }) fixture['priority'] = 65536 - self.post('domains/%s/records' % self.domain['id'], data=fixture, + self.post('domains/%s/records' % self.zone['id'], data=fixture, status_code=400) @patch.object(central_service.Service, 'create_record', @@ -350,7 +350,7 @@ class ApiV1RecordsTest(ApiV1Test): }) # Create a record - self.post('domains/%s/records' % self.domain['id'], data=fixture, + self.post('domains/%s/records' % self.zone['id'], data=fixture, status_code=504) def test_create_wildcard_record(self): @@ -362,7 +362,7 @@ class ApiV1RecordsTest(ApiV1Test): }) # Create a record - response = self.post('domains/%s/records' % self.domain['id'], + response = self.post('domains/%s/records' % self.zone['id'], data=fixture) self.assertIn('id', response.json) @@ -371,7 +371,7 @@ class ApiV1RecordsTest(ApiV1Test): def test_create_srv_record(self): recordset_fixture = self.get_recordset_fixture( - self.domain['name'], 'SRV') + self.zone['name'], 'SRV') fixture = self.get_record_fixture(recordset_fixture['type']) priority, _, data = fixture['data'].partition(" ") @@ -384,7 +384,7 @@ class ApiV1RecordsTest(ApiV1Test): }) # Create a record - response = self.post('domains/%s/records' % self.domain['id'], + response = self.post('domains/%s/records' % self.zone['id'], data=fixture) self.assertIn('id', response.json) @@ -396,7 +396,7 @@ class ApiV1RecordsTest(ApiV1Test): def test_create_invalid_data_srv_record(self): recordset_fixture = self.get_recordset_fixture( - self.domain['name'], 'SRV') + self.zone['name'], 'SRV') fixture = self.get_record_fixture(recordset_fixture['type']) fixture.update({ @@ -405,23 +405,23 @@ class ApiV1RecordsTest(ApiV1Test): }) invalid_datas = [ - 'I 5060 sip.%s' % self.domain['name'], - '5060 sip.%s' % self.domain['name'], - '5060 I sip.%s' % self.domain['name'], + 'I 5060 sip.%s' % self.zone['name'], + '5060 sip.%s' % self.zone['name'], + '5060 I sip.%s' % self.zone['name'], '0 5060 sip', 'sip', - 'sip.%s' % self.domain['name'], + 'sip.%s' % self.zone['name'], ] for invalid_data in invalid_datas: fixture['data'] = invalid_data # Attempt to create the record - self.post('domains/%s/records' % self.domain['id'], data=fixture, + self.post('domains/%s/records' % self.zone['id'], data=fixture, status_code=400) def test_create_invalid_name_srv_record(self): recordset_fixture = self.get_recordset_fixture( - self.domain['name'], 'SRV') + self.zone['name'], 'SRV') fixture = self.get_record_fixture(recordset_fixture['type']) fixture.update({ @@ -430,17 +430,17 @@ class ApiV1RecordsTest(ApiV1Test): }) invalid_names = [ - '%s' % self.domain['name'], - '_udp.%s' % self.domain['name'], - 'sip._udp.%s' % self.domain['name'], - '_sip.udp.%s' % self.domain['name'], + '%s' % self.zone['name'], + '_udp.%s' % self.zone['name'], + 'sip._udp.%s' % self.zone['name'], + '_sip.udp.%s' % self.zone['name'], ] for invalid_name in invalid_names: fixture['name'] = invalid_name # Attempt to create the record - self.post('domains/%s/records' % self.domain['id'], data=fixture, + self.post('domains/%s/records' % self.zone['id'], data=fixture, status_code=400) def test_create_invalid_name(self): @@ -464,65 +464,65 @@ class ApiV1RecordsTest(ApiV1Test): fixture['name'] = invalid_name # Create a record - response = self.post('domains/%s/records' % self.domain['id'], + response = self.post('domains/%s/records' % self.zone['id'], data=fixture, status_code=400) self.assertNotIn('id', response.json) def test_get_records(self): - response = self.get('domains/%s/records' % self.domain['id']) + response = self.get('domains/%s/records' % self.zone['id']) # Verify that the SOA & NS records are already created self.assertIn('records', response.json) self.assertEqual(2, len(response.json['records'])) # Create a record - self.create_record(self.domain, self.recordset) + self.create_record(self.zone, self.recordset) - response = self.get('domains/%s/records' % self.domain['id']) + response = self.get('domains/%s/records' % self.zone['id']) # Verify that one more record has been added self.assertIn('records', response.json) self.assertEqual(3, len(response.json['records'])) # Create a second record - self.create_record(self.domain, self.recordset, fixture=1) + self.create_record(self.zone, self.recordset, fixture=1) - response = self.get('domains/%s/records' % self.domain['id']) + response = self.get('domains/%s/records' % self.zone['id']) # Verfiy that all 4 records are there self.assertIn('records', response.json) self.assertEqual(4, len(response.json['records'])) - @patch.object(central_service.Service, 'get_domain', + @patch.object(central_service.Service, 'get_zone', side_effect=messaging.MessagingTimeout()) def test_get_records_timeout(self, _): - self.get('domains/%s/records' % self.domain['id'], + self.get('domains/%s/records' % self.zone['id'], status_code=504) - def test_get_records_missing_domain(self): + def test_get_records_missing_zone(self): self.get('domains/2fdadfb1-cf96-4259-ac6b-bb7b6d2ff980/records', status_code=404) - def test_get_records_invalid_domain_id(self): + def test_get_records_invalid_zone_id(self): self.get('domains/2fdadfb1cf964259ac6bbb7b6d2ff980/records', status_code=404) def test_get_record_missing(self): self.get('domains/%s/records/2fdadfb1-cf96-4259-ac6b-' - 'bb7b6d2ff980' % self.domain['id'], + 'bb7b6d2ff980' % self.zone['id'], status_code=404) def test_get_record_with_invalid_id(self): self.get('domains/%s/records/2fdadfb1-cf96-4259-ac6b-' - 'bb7b6d2ff980GH' % self.domain['id'], + 'bb7b6d2ff980GH' % self.zone['id'], status_code=404) def test_get_record(self): # Create a record - record = self.create_record(self.domain, self.recordset) + record = self.create_record(self.zone, self.recordset) - response = self.get('domains/%s/records/%s' % (self.domain['id'], + response = self.get('domains/%s/records/%s' % (self.zone['id'], record['id'])) self.assertIn('id', response.json) @@ -532,14 +532,14 @@ class ApiV1RecordsTest(ApiV1Test): def test_update_record(self): # Create a record - record = self.create_record(self.domain, self.recordset) + record = self.create_record(self.zone, self.recordset) # Fetch another fixture to use in the update fixture = self.get_record_fixture(self.recordset['type'], fixture=1) # Update the record data = {'data': fixture['data']} - response = self.put('domains/%s/records/%s' % (self.domain['id'], + response = self.put('domains/%s/records/%s' % (self.zone['id'], record['id']), data=data) @@ -550,11 +550,11 @@ class ApiV1RecordsTest(ApiV1Test): def test_update_record_ttl(self): # Create a record - record = self.create_record(self.domain, self.recordset) + record = self.create_record(self.zone, self.recordset) # Update the record data = {'ttl': 100} - response = self.put('domains/%s/records/%s' % (self.domain['id'], + response = self.put('domains/%s/records/%s' % (self.zone['id'], record['id']), data=data) @@ -566,113 +566,113 @@ class ApiV1RecordsTest(ApiV1Test): def test_update_record_junk(self): # Create a record - record = self.create_record(self.domain, self.recordset) + record = self.create_record(self.zone, self.recordset) data = {'ttl': 100, 'junk': 'Junk Field'} - self.put('domains/%s/records/%s' % (self.domain['id'], record['id']), + self.put('domains/%s/records/%s' % (self.zone['id'], record['id']), data=data, status_code=400) def test_update_record_negative_ttl(self): # Create a record - record = self.create_record(self.domain, self.recordset) + record = self.create_record(self.zone, self.recordset) data = {'ttl': -1} - self.put('domains/%s/records/%s' % (self.domain['id'], record['id']), + self.put('domains/%s/records/%s' % (self.zone['id'], record['id']), data=data, status_code=400) def test_update_record_ttl_greater_than_max(self): - record = self.create_record(self.domain, self.recordset) + record = self.create_record(self.zone, self.recordset) data = {'ttl': 2174483648} - self.put('domains/%s/records/%s' % (self.domain['id'], record['id']), + self.put('domains/%s/records/%s' % (self.zone['id'], record['id']), data=data, status_code=400) def test_update_record_zero_ttl(self): # Create a record - record = self.create_record(self.domain, self.recordset) + record = self.create_record(self.zone, self.recordset) data = {'ttl': 0} - self.put('domains/%s/records/%s' % (self.domain['id'], record['id']), + self.put('domains/%s/records/%s' % (self.zone['id'], record['id']), data=data, status_code=400) def test_update_record_invalid_ttl(self): # Create a record - record = self.create_record(self.domain, self.recordset) + record = self.create_record(self.zone, self.recordset) data = {'ttl': "$?>%"} - self.put('domains/%s/records/%s' % (self.domain['id'], record['id']), + self.put('domains/%s/records/%s' % (self.zone['id'], record['id']), data=data, status_code=400) def test_update_record_description_too_long(self): - record = self.create_record(self.domain, self.recordset) + record = self.create_record(self.zone, self.recordset) data = {'description': 'x' * 165} - self.put('domains/%s/records/%s' % (self.domain['id'], record['id']), + self.put('domains/%s/records/%s' % (self.zone['id'], record['id']), data=data, status_code=400) def test_update_record_negative_priority(self): - record = self.create_record(self.domain, self.recordset) + record = self.create_record(self.zone, self.recordset) data = {'priority': -1} - self.put('domains/%s/records/%s' % (self.domain['id'], record['id']), + self.put('domains/%s/records/%s' % (self.zone['id'], record['id']), data=data, status_code=400) def test_update_record_invalid_priority(self): - record = self.create_record(self.domain, self.recordset) + record = self.create_record(self.zone, self.recordset) data = {'priority': "?!:>"} - self.put('domains/%s/records/%s' % (self.domain['id'], record['id']), + self.put('domains/%s/records/%s' % (self.zone['id'], record['id']), data=data, status_code=400) def test_update_record_priority_greater_than_max(self): - record = self.create_record(self.domain, self.recordset) + record = self.create_record(self.zone, self.recordset) data = {'priority': 65536} - self.put('domains/%s/records/%s' % (self.domain['id'], record['id']), + self.put('domains/%s/records/%s' % (self.zone['id'], record['id']), data=data, status_code=400) def test_update_record_name_too_long(self): - record = self.create_record(self.domain, self.recordset) - data = {'name': 'w' * 256 + ".%s" % self.domain.name} - self.put('domains/%s/records/%s' % (self.domain['id'], record['id']), + record = self.create_record(self.zone, self.recordset) + data = {'name': 'w' * 256 + ".%s" % self.zone.name} + self.put('domains/%s/records/%s' % (self.zone['id'], record['id']), data=data, status_code=400) def test_update_record_invalid_type(self): - record = self.create_record(self.domain, self.recordset) + record = self.create_record(self.zone, self.recordset) data = {'type': 'ABC'} - self.put('domains/%s/records/%s' % (self.domain['id'], record['id']), + self.put('domains/%s/records/%s' % (self.zone['id'], record['id']), data=data, status_code=400) def test_update_record_data_too_long(self): - record = self.create_record(self.domain, self.recordset) + record = self.create_record(self.zone, self.recordset) data = {'data': '1' * 255 + '.2.3.4'} - self.put('domains/%s/records/%s' % (self.domain['id'], record['id']), + self.put('domains/%s/records/%s' % (self.zone['id'], record['id']), data=data, status_code=400) - def test_update_record_outside_domain_fail(self): + def test_update_record_outside_zone_fail(self): # Create a record - record = self.create_record(self.domain, self.recordset) + record = self.create_record(self.zone, self.recordset) - data = {'name': 'test.someotherdomain.com.'} + data = {'name': 'test.someotherzone.com.'} - self.put('domains/%s/records/%s' % (self.domain['id'], record['id']), + self.put('domains/%s/records/%s' % (self.zone['id'], record['id']), data=data, status_code=400) - @patch.object(central_service.Service, 'find_domain', + @patch.object(central_service.Service, 'find_zone', side_effect=messaging.MessagingTimeout()) def test_update_record_timeout(self, _): # Create a record - record = self.create_record(self.domain, self.recordset) + record = self.create_record(self.zone, self.recordset) data = {'name': 'test.example.org.'} - self.put('domains/%s/records/%s' % (self.domain['id'], record['id']), + self.put('domains/%s/records/%s' % (self.zone['id'], record['id']), data=data, status_code=504) def test_update_record_missing(self): data = {'name': 'test.example.org.'} self.put('domains/%s/records/2fdadfb1-cf96-4259-ac6b-' - 'bb7b6d2ff980' % self.domain['id'], + 'bb7b6d2ff980' % self.zone['id'], data=data, status_code=404) @@ -680,11 +680,11 @@ class ApiV1RecordsTest(ApiV1Test): data = {'name': 'test.example.org.'} self.put('domains/%s/records/2fdadfb1cf964259ac6bbb7b6d2ff980' % - self.domain['id'], + self.zone['id'], data=data, status_code=404) - def test_update_record_missing_domain(self): + def test_update_record_missing_zone(self): data = {'name': 'test.example.org.'} self.put('domains/2fdadfb1-cf96-4259-ac6b-bb7b6d2ff980/records/' @@ -692,7 +692,7 @@ class ApiV1RecordsTest(ApiV1Test): data=data, status_code=404) - def test_update_record_invalid_domain_id(self): + def test_update_record_invalid_zone_id(self): data = {'name': 'test.example.org.'} self.put('domains/2fdadfb1cf964259ac6bbb7b6d2ff980/records/' @@ -702,103 +702,103 @@ class ApiV1RecordsTest(ApiV1Test): def test_delete_record(self): # Create a record - record = self.create_record(self.domain, self.recordset) + record = self.create_record(self.zone, self.recordset) - self.delete('domains/%s/records/%s' % (self.domain['id'], + self.delete('domains/%s/records/%s' % (self.zone['id'], record['id'])) # Simulate the record having been deleted on the backend - domain_serial = self.central_service.get_domain( - self.admin_context, self.domain['id']).serial + zone_serial = self.central_service.get_zone( + self.admin_context, self.zone['id']).serial self.central_service.update_status( - self.admin_context, self.domain['id'], "SUCCESS", domain_serial) + self.admin_context, self.zone['id'], "SUCCESS", zone_serial) # Ensure we can no longer fetch the record - self.get('domains/%s/records/%s' % (self.domain['id'], + self.get('domains/%s/records/%s' % (self.zone['id'], record['id']), status_code=404) - @patch.object(central_service.Service, 'find_domain', + @patch.object(central_service.Service, 'find_zone', side_effect=messaging.MessagingTimeout()) def test_delete_record_timeout(self, _): # Create a record - record = self.create_record(self.domain, self.recordset) + record = self.create_record(self.zone, self.recordset) - self.delete('domains/%s/records/%s' % (self.domain['id'], + self.delete('domains/%s/records/%s' % (self.zone['id'], record['id']), status_code=504) def test_delete_record_missing(self): self.delete('domains/%s/records/2fdadfb1-cf96-4259-ac6b-' - 'bb7b6d2ff980' % self.domain['id'], + 'bb7b6d2ff980' % self.zone['id'], status_code=404) - def test_delete_record_missing_domain(self): + def test_delete_record_missing_zone(self): self.delete('domains/2fdadfb1-cf96-4259-ac6b-bb7b6d2ff980/records/' '2fdadfb1-cf96-4259-ac6b-bb7b6d2ff980', status_code=404) - def test_delete_record_invalid_domain_id(self): + def test_delete_record_invalid_zone_id(self): self.delete('domains/2fdadfb1cf964259ac6bbb7b6d2ff980/records/' '2fdadfb1-cf96-4259-ac6b-bb7b6d2ff980', status_code=404) def test_delete_record_invalid_id(self): self.delete('domains/%s/records/2fdadfb1-cf96-4259-ac6b-' - 'bb7b6d2ff980GH' % self.domain['id'], + 'bb7b6d2ff980GH' % self.zone['id'], status_code=404) def test_get_record_in_secondary(self): - fixture = self.get_domain_fixture('SECONDARY', 1) + fixture = self.get_zone_fixture('SECONDARY', 1) fixture['email'] = "root@example.com" - domain = self.create_domain(**fixture) + zone = self.create_zone(**fixture) - record = self.create_record(domain, self.recordset) + record = self.create_record(zone, self.recordset) - url = 'domains/%s/records/%s' % (domain.id, record.id) + url = 'zones/%s/records/%s' % (zone.id, record.id) self.get(url, status_code=404) def test_create_record_in_secondary(self): - fixture = self.get_domain_fixture('SECONDARY', 1) + fixture = self.get_zone_fixture('SECONDARY', 1) fixture['email'] = "root@example.com" - domain = self.create_domain(**fixture) + zone = self.create_zone(**fixture) record = { - "name": "foo.%s" % domain.name, + "name": "foo.%s" % zone.name, "type": "A", "data": "10.0.0.1" } - url = 'domains/%s/records' % domain.id + url = 'zones/%s/records' % zone.id self.post(url, record, status_code=404) def test_update_record_in_secondary(self): - fixture = self.get_domain_fixture('SECONDARY', 1) + fixture = self.get_zone_fixture('SECONDARY', 1) fixture['email'] = "root@example.com" - domain = self.create_domain(**fixture) + zone = self.create_zone(**fixture) - record = self.create_record(domain, self.recordset) + record = self.create_record(zone, self.recordset) - url = 'domains/%s/records/%s' % (domain.id, record.id) + url = 'zones/%s/records/%s' % (zone.id, record.id) self.put(url, {"data": "10.0.0.1"}, status_code=404) def test_delete_record_in_secondary(self): - fixture = self.get_domain_fixture('SECONDARY', 1) + fixture = self.get_zone_fixture('SECONDARY', 1) fixture['email'] = "root@example.com" - domain = self.create_domain(**fixture) + zone = self.create_zone(**fixture) - record = self.create_record(domain, self.recordset) + record = self.create_record(zone, self.recordset) - url = 'domains/%s/records/%s' % (domain.id, record.id) + url = 'zones/%s/records/%s' % (zone.id, record.id) self.delete(url, status_code=404) - def test_create_record_deleting_domain(self): + def test_create_record_deleting_zone(self): recordset_fixture = self.get_recordset_fixture( - self.domain['name']) + self.zone['name']) fixture = self.get_record_fixture(recordset_fixture['type']) fixture.update({ @@ -806,29 +806,29 @@ class ApiV1RecordsTest(ApiV1Test): 'type': recordset_fixture['type'], }) - self.delete('/domains/%s' % self.domain['id']) - self.post('domains/%s/records' % self.domain['id'], + self.delete('/domains/%s' % self.zone['id']) + self.post('domains/%s/records' % self.zone['id'], data=fixture, status_code=400) - def test_update_record_deleting_domain(self): + def test_update_record_deleting_zone(self): # Create a record - record = self.create_record(self.domain, self.recordset) + record = self.create_record(self.zone, self.recordset) # Fetch another fixture to use in the update fixture = self.get_record_fixture(self.recordset['type'], fixture=1) # Update the record data = {'data': fixture['data']} - self.delete('/domains/%s' % self.domain['id']) - self.put('domains/%s/records/%s' % (self.domain['id'], + self.delete('/domains/%s' % self.zone['id']) + self.put('domains/%s/records/%s' % (self.zone['id'], record['id']), data=data, status_code=400) - def test_delete_record_deleting_domain(self): + def test_delete_record_deleting_zone(self): # Create a record - record = self.create_record(self.domain, self.recordset) + record = self.create_record(self.zone, self.recordset) - self.delete('/domains/%s' % self.domain['id']) - self.delete('domains/%s/records/%s' % (self.domain['id'], + self.delete('/domains/%s' % self.zone['id']) + self.delete('domains/%s/records/%s' % (self.zone['id'], record['id']), status_code=400) diff --git a/designate/tests/test_api/test_v2/test_floatingips.py b/designate/tests/test_api/test_v2/test_floatingips.py index 9039e2e9..622b6e55 100644 --- a/designate/tests/test_api/test_v2/test_floatingips.py +++ b/designate/tests/test_api/test_v2/test_floatingips.py @@ -201,14 +201,14 @@ class ApiV2ReverseFloatingIPTest(ApiV2TestCase): 'managed_resource_id': fip['id'], 'managed_tenant_id': context.tenant } - domain_id = self.central_service.find_record( - elevated_context, criterion=criterion).domain_id + zone_id = self.central_service.find_record( + elevated_context, criterion=criterion).zone_id # Simulate the update on the backend - domain_serial = self.central_service.get_domain( - elevated_context, domain_id).serial + zone_serial = self.central_service.get_zone( + elevated_context, zone_id).serial self.central_service.update_status( - elevated_context, domain_id, "SUCCESS", domain_serial) + elevated_context, zone_id, "SUCCESS", zone_serial) # Unset PTR ('ptrdname' is None aka null in JSON) response = self.client.patch_json( @@ -219,10 +219,10 @@ class ApiV2ReverseFloatingIPTest(ApiV2TestCase): self.assertEqual(202, response.status_int) # Simulate the unset on the backend - domain_serial = self.central_service.get_domain( - elevated_context, domain_id).serial + zone_serial = self.central_service.get_zone( + elevated_context, zone_id).serial self.central_service.update_status( - elevated_context, domain_id, "SUCCESS", domain_serial) + elevated_context, zone_id, "SUCCESS", zone_serial) fip = self.central_service.get_floatingip( context, fip['region'], fip['id']) diff --git a/designate/tests/test_api/test_v2/test_hostheaders.py b/designate/tests/test_api/test_v2/test_hostheaders.py index 57ab637c..65d83739 100644 --- a/designate/tests/test_api/test_v2/test_hostheaders.py +++ b/designate/tests/test_api/test_v2/test_hostheaders.py @@ -27,7 +27,7 @@ class ApiV2HostHeadersTest(ApiV2TestCase): def test_host_header(self): # Create a zone with host header - fixture = self.get_domain_fixture(fixture=0) + fixture = self.get_zone_fixture(fixture=0) response = self.client.post_json('/zones/', fixture, headers={'Host': 'testhost.com'}) diff --git a/designate/tests/test_api/test_v2/test_limits.py b/designate/tests/test_api/test_v2/test_limits.py index 72789124..fc11f9bf 100644 --- a/designate/tests/test_api/test_v2/test_limits.py +++ b/designate/tests/test_api/test_v2/test_limits.py @@ -41,12 +41,12 @@ class ApiV2LimitsTest(ApiV2TestCase): absolutelimits = response.json - self.assertEqual(cfg.CONF.quota_domains, absolutelimits['max_zones']) - self.assertEqual(cfg.CONF.quota_domain_records, + self.assertEqual(cfg.CONF.quota_zones, absolutelimits['max_zones']) + self.assertEqual(cfg.CONF.quota_zone_records, absolutelimits['max_zone_recordsets']) self.assertEqual(cfg.CONF['service:central'].min_ttl, absolutelimits['min_ttl']) - self.assertEqual(cfg.CONF['service:central'].max_domain_name_len, + self.assertEqual(cfg.CONF['service:central'].max_zone_name_len, absolutelimits['max_zone_name_length']) self.assertEqual(cfg.CONF['service:central'].max_recordset_name_len, absolutelimits['max_recordset_name_length']) diff --git a/designate/tests/test_api/test_v2/test_recordsets.py b/designate/tests/test_api/test_v2/test_recordsets.py index 044427d2..3ad6bb5a 100644 --- a/designate/tests/test_api/test_v2/test_recordsets.py +++ b/designate/tests/test_api/test_v2/test_recordsets.py @@ -29,14 +29,14 @@ class ApiV2RecordSetsTest(ApiV2TestCase): def setUp(self): super(ApiV2RecordSetsTest, self).setUp() - # Create a domain - self.domain = self.create_domain() + # Create a zone + self.zone = self.create_zone() def test_create_recordset(self): # Prepare a RecordSet fixture - fixture = self.get_recordset_fixture(self.domain['name'], fixture=0) + fixture = self.get_recordset_fixture(self.zone['name'], fixture=0) response = self.client.post_json( - '/zones/%s/recordsets' % self.domain['id'], fixture) + '/zones/%s/recordsets' % self.zone['id'], fixture) # Check the headers are what we expect self.assertEqual(201, response.status_int) @@ -58,14 +58,14 @@ class ApiV2RecordSetsTest(ApiV2TestCase): def test_create_recordset_with_records(self): # Prepare a RecordSet fixture fixture = self.get_recordset_fixture( - self.domain['name'], 'A', fixture=0, values={'records': [ + self.zone['name'], 'A', fixture=0, values={'records': [ '192.0.2.1', '192.0.2.2', ]} ) response = self.client.post_json( - '/zones/%s/recordsets' % self.domain['id'], fixture) + '/zones/%s/recordsets' % self.zone['id'], fixture) # Check the headers are what we expect self.assertEqual(202, response.status_int) @@ -78,7 +78,7 @@ class ApiV2RecordSetsTest(ApiV2TestCase): self.assertEqual('PENDING', response.json['status']) # Check the zone's status is as expected - response = self.client.get('/zones/%s' % self.domain['id'], + response = self.client.get('/zones/%s' % self.zone['id'], headers=[('Accept', 'application/json')]) # Check the headers are what we expect self.assertEqual(200, response.status_int) @@ -90,11 +90,11 @@ class ApiV2RecordSetsTest(ApiV2TestCase): def test_create_recordset_with_invalid_name(self): # Prepare a RecordSet fixture body = self.get_recordset_fixture( - self.domain['name'], + self.zone['name'], 'A', fixture=0, values={ - 'name': '`invalid`label`.%s' % self.domain['name'], + 'name': '`invalid`label`.%s' % self.zone['name'], 'records': [ '192.0.2.1', '192.0.2.2', @@ -102,36 +102,36 @@ class ApiV2RecordSetsTest(ApiV2TestCase): } ) - url = '/zones/%s/recordsets' % self.domain['id'] + url = '/zones/%s/recordsets' % self.zone['id'] # Ensure it fails with a 400 self._assert_exception( 'invalid_object', 400, self.client.post_json, url, body) def test_create_recordset_with_name_too_long(self): - fixture = self.get_recordset_fixture(self.domain['name'], fixture=0) - fixture['name'] = 'x' * 255 + ".%s" % self.domain['name'] + fixture = self.get_recordset_fixture(self.zone['name'], fixture=0) + fixture['name'] = 'x' * 255 + ".%s" % self.zone['name'] body = fixture - url = '/zones/%s/recordsets' % self.domain['id'] + url = '/zones/%s/recordsets' % self.zone['id'] self._assert_exception( 'invalid_object', 400, self.client.post_json, url, body) def test_create_recordset_with_name_missing(self): - fixture = self.get_recordset_fixture(self.domain['name'], fixture=0) + fixture = self.get_recordset_fixture(self.zone['name'], fixture=0) del fixture['name'] body = fixture - url = '/zones/%s/recordsets' % self.domain['id'] + url = '/zones/%s/recordsets' % self.zone['id'] self._assert_exception( 'invalid_object', 400, self.client.post_json, url, body) def test_create_recordset_type_is_missing(self): # Prepare a RecordSet fixture body = self.get_recordset_fixture( - self.domain['name'], + self.zone['name'], 'A', fixture=0, values={ - 'name': 'name.%s' % self.domain['name'], + 'name': 'name.%s' % self.zone['name'], 'records': [ '192.0.2.1', '192.0.2.2', @@ -141,57 +141,57 @@ class ApiV2RecordSetsTest(ApiV2TestCase): del body['type'] - url = '/zones/%s/recordsets' % self.domain['id'] + url = '/zones/%s/recordsets' % self.zone['id'] # Ensure it fails with a 400 self._assert_exception( 'invalid_object', 400, self.client.post_json, url, body) def test_create_recordset_with_invalid_type(self): - fixture = self.get_recordset_fixture(self.domain['name'], fixture=0) + fixture = self.get_recordset_fixture(self.zone['name'], fixture=0) fixture['type'] = "ABC" body = fixture - url = '/zones/%s/recordsets' % self.domain['id'] + url = '/zones/%s/recordsets' % self.zone['id'] self._assert_exception( 'invalid_object', 400, self.client.post_json, url, body) def test_create_recordset_description_too_long(self): - fixture = self.get_recordset_fixture(self.domain['name'], fixture=0) + fixture = self.get_recordset_fixture(self.zone['name'], fixture=0) fixture['description'] = "x" * 161 body = fixture - url = '/zones/%s/recordsets' % self.domain['id'] + url = '/zones/%s/recordsets' % self.zone['id'] self._assert_exception( 'invalid_object', 400, self.client.post_json, url, body) def test_create_recordset_with_negative_ttl(self): - fixture = self.get_recordset_fixture(self.domain['name'], fixture=0) + fixture = self.get_recordset_fixture(self.zone['name'], fixture=0) fixture['ttl'] = -1 body = fixture - url = '/zones/%s/recordsets' % self.domain['id'] + url = '/zones/%s/recordsets' % self.zone['id'] self._assert_exception( 'invalid_object', 400, self.client.post_json, url, body) def test_create_recordset_with_zero_ttl(self): - fixture = self.get_recordset_fixture(self.domain['name'], fixture=0) + fixture = self.get_recordset_fixture(self.zone['name'], fixture=0) fixture['ttl'] = 0 body = fixture - url = '/zones/%s/recordsets' % self.domain['id'] + url = '/zones/%s/recordsets' % self.zone['id'] self._assert_exception( 'invalid_object', 400, self.client.post_json, url, body) def test_create_recordset_with_ttl_greater_than_max(self): - fixture = self.get_recordset_fixture(self.domain['name'], fixture=0) + fixture = self.get_recordset_fixture(self.zone['name'], fixture=0) fixture['ttl'] = 2147483648 body = fixture - url = '/zones/%s/recordsets' % self.domain['id'] + url = '/zones/%s/recordsets' % self.zone['id'] self._assert_exception( 'invalid_object', 400, self.client.post_json, url, body) def test_create_recordset_with_invalid_ttl(self): - fixture = self.get_recordset_fixture(self.domain['name'], fixture=0) + fixture = self.get_recordset_fixture(self.zone['name'], fixture=0) fixture['ttl'] = ">?!?" body = fixture - url = '/zones/%s/recordsets' % self.domain['id'] + url = '/zones/%s/recordsets' % self.zone['id'] self._assert_exception( 'invalid_object', 400, self.client.post_json, url, body) @@ -202,9 +202,9 @@ class ApiV2RecordSetsTest(ApiV2TestCase): # NOTE: The schemas should be tested separatly to the API. So we # don't need to test every variation via the API itself. # Fetch a fixture - fixture = self.get_recordset_fixture(self.domain['name'], fixture=0) + fixture = self.get_recordset_fixture(self.zone['name'], fixture=0) - url = '/zones/%s/recordsets' % self.domain['id'] + url = '/zones/%s/recordsets' % self.zone['id'] # Add a junk field to the body fixture['junk'] = 'Junk Field' @@ -217,11 +217,11 @@ class ApiV2RecordSetsTest(ApiV2TestCase): @patch.object(central_service.Service, 'create_recordset', side_effect=messaging.MessagingTimeout()) def test_create_recordset_timeout(self, _): - fixture = self.get_recordset_fixture(self.domain['name'], fixture=0) + fixture = self.get_recordset_fixture(self.zone['name'], fixture=0) body = fixture - url = '/zones/%s/recordsets' % self.domain['id'] + url = '/zones/%s/recordsets' % self.zone['id'] self._assert_exception('timeout', 504, self.client.post_json, url, body) @@ -229,23 +229,23 @@ class ApiV2RecordSetsTest(ApiV2TestCase): @patch.object(central_service.Service, 'create_recordset', side_effect=exceptions.DuplicateRecordSet()) def test_create_recordset_duplicate(self, _): - fixture = self.get_recordset_fixture(self.domain['name'], fixture=0) + fixture = self.get_recordset_fixture(self.zone['name'], fixture=0) body = fixture - url = '/zones/%s/recordsets' % self.domain['id'] + url = '/zones/%s/recordsets' % self.zone['id'] self._assert_exception('duplicate_recordset', 409, self.client.post_json, url, body) - def test_create_recordset_invalid_domain(self): - fixture = self.get_recordset_fixture(self.domain['name'], fixture=0) + def test_create_recordset_invalid_zone(self): + fixture = self.get_recordset_fixture(self.zone['name'], fixture=0) body = fixture url = '/zones/ba751950-6193-11e3-949a-0800200c9a66/recordsets' - self._assert_exception('domain_not_found', 404, self.client.post_json, + self._assert_exception('zone_not_found', 404, self.client.post_json, url, body) def test_recordsets_invalid_url(self): @@ -261,7 +261,7 @@ class ApiV2RecordSetsTest(ApiV2TestCase): self.assertEqual(405, response.status_int) def test_get_recordsets(self): - url = '/zones/%s/recordsets' % self.domain['id'] + url = '/zones/%s/recordsets' % self.zone['id'] response = self.client.get(url) @@ -282,13 +282,13 @@ class ApiV2RecordSetsTest(ApiV2TestCase): self.assertEqual('PENDING', recordset['status']) soa = self.central_service.find_recordset( - self.admin_context, criterion={'domain_id': self.domain['id'], + self.admin_context, criterion={'zone_id': self.zone['id'], 'type': 'SOA'}) ns = self.central_service.find_recordset( - self.admin_context, criterion={'domain_id': self.domain['id'], + self.admin_context, criterion={'zone_id': self.zone['id'], 'type': 'NS'}) - data = [self.create_recordset(self.domain, - name='x-%s.%s' % (i, self.domain['name'])) + data = [self.create_recordset(self.zone, + name='x-%s.%s' % (i, self.zone['name'])) for i in range(0, 10)] data.insert(0, ns) data.insert(0, soa) @@ -301,14 +301,14 @@ class ApiV2RecordSetsTest(ApiV2TestCase): # Add recordsets for testing fixtures = [ self.get_recordset_fixture( - self.domain['name'], 'A', fixture=0, values={ + self.zone['name'], 'A', fixture=0, values={ 'records': ['192.0.2.1', '192.0.2.2'], 'description': 'Tester1', 'ttl': 3600 } ), self.get_recordset_fixture( - self.domain['name'], 'A', fixture=1, values={ + self.zone['name'], 'A', fixture=1, values={ 'records': ['192.0.2.1'], 'description': 'Tester2', 'ttl': 4000 @@ -318,30 +318,30 @@ class ApiV2RecordSetsTest(ApiV2TestCase): for fixture in fixtures: response = self.client.post_json( - '/zones/%s/recordsets' % self.domain['id'], + '/zones/%s/recordsets' % self.zone['id'], fixture) get_urls = [ # Filter by Name '/zones/%s/recordsets?name=%s' % ( - self.domain['id'], fixtures[0]['name']), + self.zone['id'], fixtures[0]['name']), '/zones/%s/recordsets?data=192.0.2.1&name=%s' % ( - self.domain['id'], fixtures[1]['name']), + self.zone['id'], fixtures[1]['name']), # Filter by Type - '/zones/%s/recordsets?type=A' % self.domain['id'], + '/zones/%s/recordsets?type=A' % self.zone['id'], '/zones/%s/recordsets?type=A&name=%s' % ( - self.domain['id'], fixtures[0]['name']), + self.zone['id'], fixtures[0]['name']), # Filter by TTL - '/zones/%s/recordsets?ttl=3600' % self.domain['id'], + '/zones/%s/recordsets?ttl=3600' % self.zone['id'], # Filter by Data - '/zones/%s/recordsets?data=192.0.2.1' % self.domain['id'], - '/zones/%s/recordsets?data=192.0.2.2' % self.domain['id'], + '/zones/%s/recordsets?data=192.0.2.1' % self.zone['id'], + '/zones/%s/recordsets?data=192.0.2.2' % self.zone['id'], # Filter by Description - '/zones/%s/recordsets?description=Tester1' % self.domain['id'] + '/zones/%s/recordsets?description=Tester1' % self.zone['id'] ] correct_results = [1, 1, 2, 1, 1, 2, 1, 1] @@ -361,7 +361,7 @@ class ApiV2RecordSetsTest(ApiV2TestCase): def test_get_recordsets_invalid_id(self): self._assert_invalid_uuid(self.client.get, '/zones/%s/recordsets') - @patch.object(central_service.Service, 'get_domain', + @patch.object(central_service.Service, 'get_zone', side_effect=messaging.MessagingTimeout()) def test_get_recordsets_timeout(self, _): url = '/zones/ba751950-6193-11e3-949a-0800200c9a66/recordsets' @@ -369,7 +369,7 @@ class ApiV2RecordSetsTest(ApiV2TestCase): self._assert_exception('timeout', 504, self.client.get, url) def test_get_deleted_recordsets(self): - zone = self.create_domain(fixture=1) + zone = self.create_zone(fixture=1) self.create_recordset(zone) url = '/zones/%s/recordsets' % zone['id'] @@ -378,23 +378,23 @@ class ApiV2RecordSetsTest(ApiV2TestCase): # Check the headers are what we expect self.assertEqual(200, response.status_int) - # now delete the domain and get the recordsets + # now delete the zone and get the recordsets self.client.delete('/zones/%s' % zone['id'], status=202) - # Simulate the domain having been deleted on the backend - domain_serial = self.central_service.get_domain( + # Simulate the zone having been deleted on the backend + zone_serial = self.central_service.get_zone( self.admin_context, zone['id']).serial self.central_service.update_status( - self.admin_context, zone['id'], "SUCCESS", domain_serial) + self.admin_context, zone['id'], "SUCCESS", zone_serial) - # Check that we get a domain_not_found error - self._assert_exception('domain_not_found', 404, self.client.get, url) + # Check that we get a zone_not_found error + self._assert_exception('zone_not_found', 404, self.client.get, url) def test_get_recordset(self): # Create a recordset - recordset = self.create_recordset(self.domain) + recordset = self.create_recordset(self.zone) - url = '/zones/%s/recordsets/%s' % (self.domain['id'], recordset['id']) + url = '/zones/%s/recordsets/%s' % (self.zone['id'], recordset['id']) response = self.client.get(url) # Check the headers are what we expect @@ -421,7 +421,7 @@ class ApiV2RecordSetsTest(ApiV2TestCase): side_effect=messaging.MessagingTimeout()) def test_get_recordset_timeout(self, _): url = '/zones/%s/recordsets/ba751950-6193-11e3-949a-0800200c9a66' % ( - self.domain['id']) + self.zone['id']) self._assert_exception('timeout', 504, self.client.get, url, headers={'Accept': 'application/json'}) @@ -430,7 +430,7 @@ class ApiV2RecordSetsTest(ApiV2TestCase): side_effect=exceptions.RecordSetNotFound()) def test_get_recordset_missing(self, _): url = '/zones/%s/recordsets/ba751950-6193-11e3-949a-0800200c9a66' % ( - self.domain['id']) + self.zone['id']) self._assert_exception('recordset_not_found', 404, self.client.get, url, @@ -438,12 +438,12 @@ class ApiV2RecordSetsTest(ApiV2TestCase): def test_update_recordset(self): # Create a recordset - recordset = self.create_recordset(self.domain) + recordset = self.create_recordset(self.zone) # Prepare an update body body = {'description': 'Tester'} - url = '/zones/%s/recordsets/%s' % (recordset['domain_id'], + url = '/zones/%s/recordsets/%s' % (recordset['zone_id'], recordset['id']) response = self.client.put_json(url, body, status=200) @@ -464,7 +464,7 @@ class ApiV2RecordSetsTest(ApiV2TestCase): self.assertEqual('ACTIVE', response.json['status']) # Check the zone's status is as expected - response = self.client.get('/zones/%s' % recordset['domain_id'], + response = self.client.get('/zones/%s' % recordset['zone_id'], headers=[('Accept', 'application/json')]) # Check the headers are what we expect self.assertEqual(200, response.status_int) @@ -475,7 +475,7 @@ class ApiV2RecordSetsTest(ApiV2TestCase): def test_update_recordset_with_record_create(self): # Create a recordset - recordset = self.create_recordset(self.domain, 'A') + recordset = self.create_recordset(self.zone, 'A') # The action and status are NONE and ACTIVE as there are no records self.assertEqual('NONE', recordset['action']) @@ -486,7 +486,7 @@ class ApiV2RecordSetsTest(ApiV2TestCase): 'type': 'A', 'records': ['192.0.2.1', '192.0.2.2']} - url = '/zones/%s/recordsets/%s' % (recordset['domain_id'], + url = '/zones/%s/recordsets/%s' % (recordset['zone_id'], recordset['id']) response = self.client.put_json(url, body, status=202) @@ -503,7 +503,7 @@ class ApiV2RecordSetsTest(ApiV2TestCase): self.assertEqual('PENDING', response.json['status']) # Check the zone's status is as expected - response = self.client.get('/zones/%s' % recordset['domain_id'], + response = self.client.get('/zones/%s' % recordset['zone_id'], headers=[('Accept', 'application/json')]) # Check the headers are what we expect self.assertEqual(200, response.status_int) @@ -514,14 +514,14 @@ class ApiV2RecordSetsTest(ApiV2TestCase): def test_update_recordset_with_record_replace(self): # Create a recordset with one record - recordset = self.create_recordset(self.domain, 'A') - self.create_record(self.domain, recordset) + recordset = self.create_recordset(self.zone, 'A') + self.create_record(self.zone, recordset) # Prepare an update body body = {'description': 'Tester', 'records': ['192.0.2.201', '192.0.2.202']} - url = '/zones/%s/recordsets/%s' % (recordset['domain_id'], + url = '/zones/%s/recordsets/%s' % (recordset['zone_id'], recordset['id']) response = self.client.put_json(url, body, status=202) @@ -536,7 +536,7 @@ class ApiV2RecordSetsTest(ApiV2TestCase): set(response.json['records'])) # Check the zone's status is as expected - response = self.client.get('/zones/%s' % recordset['domain_id'], + response = self.client.get('/zones/%s' % recordset['zone_id'], headers=[('Accept', 'application/json')]) # Check the headers are what we expect self.assertEqual(200, response.status_int) @@ -547,13 +547,13 @@ class ApiV2RecordSetsTest(ApiV2TestCase): def test_update_recordset_with_record_clear(self): # Create a recordset with one record - recordset = self.create_recordset(self.domain, 'A') - self.create_record(self.domain, recordset) + recordset = self.create_recordset(self.zone, 'A') + self.create_record(self.zone, recordset) # Prepare an update body body = {'description': 'Tester', 'records': []} - url = '/zones/%s/recordsets/%s' % (recordset['domain_id'], + url = '/zones/%s/recordsets/%s' % (recordset['zone_id'], recordset['id']) response = self.client.put_json(url, body, status=200) @@ -566,7 +566,7 @@ class ApiV2RecordSetsTest(ApiV2TestCase): self.assertEqual(0, len(response.json['records'])) # Check the zone's status is as expected - response = self.client.get('/zones/%s' % recordset['domain_id'], + response = self.client.get('/zones/%s' % recordset['zone_id'], headers=[('Accept', 'application/json')]) # Check the headers are what we expect self.assertEqual(200, response.status_int) @@ -583,7 +583,7 @@ class ApiV2RecordSetsTest(ApiV2TestCase): # NOTE: The schemas should be tested separatly to the API. So we # don't need to test every variation via the API itself. # Create a zone - recordset = self.create_recordset(self.domain) + recordset = self.create_recordset(self.zone) # Prepare an update body with junk in the wrapper body = {'description': 'Tester', @@ -591,7 +591,7 @@ class ApiV2RecordSetsTest(ApiV2TestCase): 'junk': 'Junk Field'} # Ensure it fails with a 400 - url = '/zones/%s/recordsets/%s' % (recordset['domain_id'], + url = '/zones/%s/recordsets/%s' % (recordset['zone_id'], recordset['id']) self._assert_exception('invalid_object', 400, self.client.put_json, @@ -612,7 +612,7 @@ class ApiV2RecordSetsTest(ApiV2TestCase): # Ensure it fails with a 409 url = ('/zones/%s/recordsets/ba751950-6193-11e3-949a-0800200c9a66' - % (self.domain['id'])) + % (self.zone['id'])) self._assert_exception('duplicate_recordset', 409, self.client.put_json, url, body) @@ -625,7 +625,7 @@ class ApiV2RecordSetsTest(ApiV2TestCase): # Ensure it fails with a 504 url = ('/zones/%s/recordsets/ba751950-6193-11e3-949a-0800200c9a66' - % (self.domain['id'])) + % (self.zone['id'])) self._assert_exception('timeout', 504, self.client.put_json, url, body) @@ -638,55 +638,55 @@ class ApiV2RecordSetsTest(ApiV2TestCase): # Ensure it fails with a 404 url = ('/zones/%s/recordsets/ba751950-6193-11e3-949a-0800200c9a66' - % (self.domain['id'])) + % (self.zone['id'])) self._assert_exception('recordset_not_found', 404, self.client.put_json, url, body) def test_update_recordset_invalid_ttl(self): - recordset = self.create_recordset(self.domain) + recordset = self.create_recordset(self.zone) body = {'ttl': '>?!@'} - url = '/zones/%s/recordsets/%s' % (recordset['domain_id'], + url = '/zones/%s/recordsets/%s' % (recordset['zone_id'], recordset['id']) self._assert_exception('invalid_object', 400, self.client.put_json, url, body) def test_update_recordset_zero_ttl(self): - recordset = self.create_recordset(self.domain) + recordset = self.create_recordset(self.zone) body = {'ttl': 0} - url = '/zones/%s/recordsets/%s' % (recordset['domain_id'], + url = '/zones/%s/recordsets/%s' % (recordset['zone_id'], recordset['id']) self._assert_exception('invalid_object', 400, self.client.put_json, url, body) def test_update_recordset_negative_ttl(self): - recordset = self.create_recordset(self.domain) + recordset = self.create_recordset(self.zone) body = {'ttl': -1} - url = '/zones/%s/recordsets/%s' % (recordset['domain_id'], + url = '/zones/%s/recordsets/%s' % (recordset['zone_id'], recordset['id']) self._assert_exception('invalid_object', 400, self.client.put_json, url, body) def test_update_recordset_ttl_greater_than_max(self): - recordset = self.create_recordset(self.domain) + recordset = self.create_recordset(self.zone) body = {'ttl': 2174483648} - url = '/zones/%s/recordsets/%s' % (recordset['domain_id'], + url = '/zones/%s/recordsets/%s' % (recordset['zone_id'], recordset['id']) self._assert_exception('invalid_object', 400, self.client.put_json, url, body) def test_update_recordset_description_too_long(self): - recordset = self.create_recordset(self.domain) + recordset = self.create_recordset(self.zone) body = {'description': 'x' * 161} - url = '/zones/%s/recordsets/%s' % (recordset['domain_id'], + url = '/zones/%s/recordsets/%s' % (recordset['zone_id'], recordset['id']) self._assert_exception('invalid_object', 400, self.client.put_json, url, body) def test_delete_recordset(self): - recordset = self.create_recordset(self.domain) + recordset = self.create_recordset(self.zone) - url = '/zones/%s/recordsets/%s' % (recordset['domain_id'], + url = '/zones/%s/recordsets/%s' % (recordset['zone_id'], recordset['id']) response = self.client.delete(url, status=202) @@ -697,7 +697,7 @@ class ApiV2RecordSetsTest(ApiV2TestCase): self.assertEqual('ACTIVE', response.json['status']) # Check the zone's status is as expected - response = self.client.get('/zones/%s' % recordset['domain_id'], + response = self.client.get('/zones/%s' % recordset['zone_id'], headers=[('Accept', 'application/json')]) # Check the headers are what we expect self.assertEqual(200, response.status_int) @@ -708,10 +708,10 @@ class ApiV2RecordSetsTest(ApiV2TestCase): def test_delete_recordset_with_records(self): # Create a recordset with one record - recordset = self.create_recordset(self.domain, 'A') - self.create_record(self.domain, recordset) + recordset = self.create_recordset(self.zone, 'A') + self.create_record(self.zone, recordset) - url = '/zones/%s/recordsets/%s' % (recordset['domain_id'], + url = '/zones/%s/recordsets/%s' % (recordset['zone_id'], recordset['id']) response = self.client.delete(url, status=202) @@ -720,7 +720,7 @@ class ApiV2RecordSetsTest(ApiV2TestCase): self.assertEqual('PENDING', response.json['status']) # Check the zone's status is as expected - response = self.client.get('/zones/%s' % recordset['domain_id'], + response = self.client.get('/zones/%s' % recordset['zone_id'], headers=[('Accept', 'application/json')]) # Check the headers are what we expect self.assertEqual(200, response.status_int) @@ -733,7 +733,7 @@ class ApiV2RecordSetsTest(ApiV2TestCase): side_effect=exceptions.RecordSetNotFound()) def test_delete_recordset_missing(self, _): url = ('/zones/%s/recordsets/ba751950-6193-11e3-949a-0800200c9a66' - % (self.domain['id'])) + % (self.zone['id'])) self._assert_exception('recordset_not_found', 404, self.client.delete, url) @@ -743,7 +743,7 @@ class ApiV2RecordSetsTest(ApiV2TestCase): self.client.delete, '/zones/%s/recordsets/%s') def test_metadata_exists(self): - url = '/zones/%s/recordsets' % self.domain['id'] + url = '/zones/%s/recordsets' % self.zone['id'] response = self.client.get(url) @@ -752,7 +752,7 @@ class ApiV2RecordSetsTest(ApiV2TestCase): self.assertIn('total_count', response.json['metadata']) def test_total_count(self): - url = '/zones/%s/recordsets' % self.domain['id'] + url = '/zones/%s/recordsets' % self.zone['id'] response = self.client.get(url) @@ -760,9 +760,9 @@ class ApiV2RecordSetsTest(ApiV2TestCase): self.assertEqual(2, response.json['metadata']['total_count']) # Create a recordset - fixture = self.get_recordset_fixture(self.domain['name'], fixture=0) + fixture = self.get_recordset_fixture(self.zone['name'], fixture=0) response = self.client.post_json( - '/zones/%s/recordsets' % self.domain['id'], fixture) + '/zones/%s/recordsets' % self.zone['id'], fixture) response = self.client.get(url) @@ -771,52 +771,52 @@ class ApiV2RecordSetsTest(ApiV2TestCase): def test_total_count_filtered_by_data(self): # Closes bug 1447325 - url = '/zones/%s/recordsets' % self.domain['id'] + url = '/zones/%s/recordsets' % self.zone['id'] # Create a recordset - fixture = self.get_recordset_fixture(self.domain['name'], fixture=0) + fixture = self.get_recordset_fixture(self.zone['name'], fixture=0) response = self.client.post_json( - '/zones/%s/recordsets' % self.domain['id'], fixture) + '/zones/%s/recordsets' % self.zone['id'], fixture) response = self.client.get(url) # Make sure total_count picked up the change self.assertEqual(3, response.json['metadata']['total_count']) - url = '/zones/%s/recordsets?data=nyan' % self.domain['id'] + url = '/zones/%s/recordsets?data=nyan' % self.zone['id'] response = self.client.get(url) self.assertEqual(0, response.json['metadata']['total_count']) - url = '/zones/%s/recordsets?data=ns1.example.org.' % self.domain['id'] + url = '/zones/%s/recordsets?data=ns1.example.org.' % self.zone['id'] response = self.client.get(url) self.assertEqual(1, response.json['metadata']['total_count']) # Test paging - new_domain = self.create_domain(name='example.net.') - recordset = self.create_recordset(new_domain, 'A') - self.create_record(new_domain, recordset, data='nyan') + new_zone = self.create_zone(name='example.net.') + recordset = self.create_recordset(new_zone, 'A') + self.create_record(new_zone, recordset, data='nyan') - recordset = self.create_recordset(new_domain, 'CNAME') - self.create_record(new_domain, recordset, data='nyan') + recordset = self.create_recordset(new_zone, 'CNAME') + self.create_record(new_zone, recordset, data='nyan') # Even with paging enabled, total_count is still the total number of # recordsets matching the "data" filter - url = '/zones/%s/recordsets?limit=1&data=nyan' % new_domain.id + url = '/zones/%s/recordsets?limit=1&data=nyan' % new_zone.id response = self.client.get(url) self.assertEqual(2, response.json['metadata']['total_count']) def test_total_count_pagination(self): # Create two recordsets - fixture = self.get_recordset_fixture(self.domain['name'], fixture=0) + fixture = self.get_recordset_fixture(self.zone['name'], fixture=0) response = self.client.post_json( - '/zones/%s/recordsets' % self.domain['id'], fixture) + '/zones/%s/recordsets' % self.zone['id'], fixture) - fixture = self.get_recordset_fixture(self.domain['name'], fixture=1) + fixture = self.get_recordset_fixture(self.zone['name'], fixture=1) response = self.client.post_json( - '/zones/%s/recordsets' % self.domain['id'], fixture) + '/zones/%s/recordsets' % self.zone['id'], fixture) # Paginate the recordsets to two, there should be four now - url = '/zones/%s/recordsets?limit=2' % self.domain['id'] + url = '/zones/%s/recordsets?limit=2' % self.zone['id'] response = self.client.get(url) @@ -828,9 +828,9 @@ class ApiV2RecordSetsTest(ApiV2TestCase): # Secondary Zones specific tests def test_get_secondary_zone_recordset(self): - fixture = self.get_domain_fixture('SECONDARY', 1) + fixture = self.get_zone_fixture('SECONDARY', 1) fixture['email'] = 'root@example.com' - secondary = self.create_domain(**fixture) + secondary = self.create_zone(**fixture) # Create a recordset recordset = self.create_recordset(secondary) @@ -853,9 +853,9 @@ class ApiV2RecordSetsTest(ApiV2TestCase): self.assertEqual(recordset['type'], response.json['type']) def test_get_secondary_zone_recordsets(self): - fixture = self.get_domain_fixture('SECONDARY', 1) + fixture = self.get_zone_fixture('SECONDARY', 1) fixture['email'] = 'foo@bar.io' - secondary = self.create_domain(**fixture) + secondary = self.create_zone(**fixture) url = '/zones/%s/recordsets' % secondary['id'] @@ -874,7 +874,7 @@ class ApiV2RecordSetsTest(ApiV2TestCase): self.assertEqual(1, len(response.json['recordsets'])) soa = self.central_service.find_recordset( - self.admin_context, criterion={'domain_id': secondary['id'], + self.admin_context, criterion={'zone_id': secondary['id'], 'type': 'SOA'}) data = [self.create_recordset(secondary, name='x-%s.%s' % (i, secondary['name'])) @@ -886,9 +886,9 @@ class ApiV2RecordSetsTest(ApiV2TestCase): self._assert_invalid_paging(data, url, key='recordsets') def test_create_secondary_zone_recordset(self): - fixture = self.get_domain_fixture('SECONDARY', 1) + fixture = self.get_zone_fixture('SECONDARY', 1) fixture['email'] = 'foo@bar.io' - secondary = self.create_domain(**fixture) + secondary = self.create_zone(**fixture) fixture = self.get_recordset_fixture(secondary['name'], fixture=0) @@ -897,65 +897,65 @@ class ApiV2RecordSetsTest(ApiV2TestCase): fixture) def test_update_secondary_zone_recordset(self): - fixture = self.get_domain_fixture('SECONDARY', 1) + fixture = self.get_zone_fixture('SECONDARY', 1) fixture['email'] = 'foo@bar.io' - secondary = self.create_domain(**fixture) + secondary = self.create_zone(**fixture) # Set the context so that we can create a RRSet recordset = self.create_recordset(secondary) - url = '/zones/%s/recordsets/%s' % (recordset['domain_id'], + url = '/zones/%s/recordsets/%s' % (recordset['zone_id'], recordset['id']) self._assert_exception('forbidden', 403, self.client.put_json, url, {'ttl': 100}) def test_delete_secondary_zone_recordset(self): - fixture = self.get_domain_fixture('SECONDARY', 1) + fixture = self.get_zone_fixture('SECONDARY', 1) fixture['email'] = 'foo@bar.io' - secondary = self.create_domain(**fixture) + secondary = self.create_zone(**fixture) # Set the context so that we can create a RRSet recordset = self.create_recordset(secondary) - url = '/zones/%s/recordsets/%s' % (recordset['domain_id'], + url = '/zones/%s/recordsets/%s' % (recordset['zone_id'], recordset['id']) self._assert_exception('forbidden', 403, self.client.delete, url) def test_no_create_rs_deleting_zone(self): # Prepare a create - fixture = self.get_recordset_fixture(self.domain['name'], fixture=0) + fixture = self.get_recordset_fixture(self.zone['name'], fixture=0) body = fixture - self.client.delete('/zones/%s' % self.domain['id'], status=202) + self.client.delete('/zones/%s' % self.zone['id'], status=202) self._assert_exception('bad_request', 400, self.client.post_json, - '/zones/%s/recordsets' % self.domain['id'], + '/zones/%s/recordsets' % self.zone['id'], body) def test_no_update_rs_deleting_zone(self): # Create a recordset - recordset = self.create_recordset(self.domain) + recordset = self.create_recordset(self.zone) # Prepare an update body body = {'description': 'Tester'} - url = '/zones/%s/recordsets/%s' % (recordset['domain_id'], + url = '/zones/%s/recordsets/%s' % (recordset['zone_id'], recordset['id']) - self.client.delete('/zones/%s' % self.domain['id'], status=202) + self.client.delete('/zones/%s' % self.zone['id'], status=202) self._assert_exception('bad_request', 400, self.client.put_json, url, body) def test_no_delete_rs_deleting_zone(self): # Create a recordset - recordset = self.create_recordset(self.domain) + recordset = self.create_recordset(self.zone) - url = '/zones/%s/recordsets/%s' % (recordset['domain_id'], + url = '/zones/%s/recordsets/%s' % (recordset['zone_id'], recordset['id']) - self.client.delete('/zones/%s' % self.domain['id'], status=202) + self.client.delete('/zones/%s' % self.zone['id'], status=202) self._assert_exception('bad_request', 400, self.client.delete, url) def test_invalid_recordset_filter(self): - invalid_url = '/zones/%s/recordsets?action=NONE' % self.domain['id'] + invalid_url = '/zones/%s/recordsets?action=NONE' % self.zone['id'] self._assert_exception( 'bad_request', 400, self.client.get, invalid_url) diff --git a/designate/tests/test_api/test_v2/test_zone_transfers.py b/designate/tests/test_api/test_v2/test_zone_transfers.py index 14274f36..0cdecb80 100644 --- a/designate/tests/test_api/test_v2/test_zone_transfers.py +++ b/designate/tests/test_api/test_v2/test_zone_transfers.py @@ -20,13 +20,13 @@ class ApiV2ZoneTransfersTest(ApiV2TestCase): def setUp(self): super(ApiV2ZoneTransfersTest, self).setUp() - self.domain = self.create_domain() + self.zone = self.create_zone() self.tenant_1_context = self.get_context(tenant=1) self.tenant_2_context = self.get_context(tenant=2) def test_create_zone_transfer_request(self): response = self.client.post_json( - '/zones/%s/tasks/transfer_requests' % (self.domain.id), + '/zones/%s/tasks/transfer_requests' % (self.zone.id), {}) # Check the headers are what we expect @@ -42,13 +42,13 @@ class ApiV2ZoneTransfersTest(ApiV2TestCase): self.assertIn('created_at', response.json) self.assertEqual('ACTIVE', response.json['status']) self.assertEqual( - self.domain.id, + self.zone.id, response.json['zone_id']) self.assertIsNone(response.json['updated_at']) def test_create_zone_transfer_request_scoped(self): response = self.client.post_json( - '/zones/%s/tasks/transfer_requests' % (self.domain.id), + '/zones/%s/tasks/transfer_requests' % (self.zone.id), {'target_project_id': str(self.tenant_1_context.tenant)}) # Check the headers are what we expect @@ -67,13 +67,13 @@ class ApiV2ZoneTransfersTest(ApiV2TestCase): str(self.tenant_1_context.tenant), response.json['target_project_id']) self.assertEqual( - self.domain.id, + self.zone.id, response.json['zone_id']) self.assertIsNone(response.json['updated_at']) def test_get_zone_transfer_request(self): initial = self.client.post_json( - '/zones/%s/tasks/transfer_requests' % (self.domain.id), + '/zones/%s/tasks/transfer_requests' % (self.zone.id), {}) response = self.client.get( @@ -93,13 +93,13 @@ class ApiV2ZoneTransfersTest(ApiV2TestCase): self.assertIn('created_at', response.json) self.assertEqual('ACTIVE', response.json['status']) self.assertEqual( - self.domain.id, + self.zone.id, response.json['zone_id']) self.assertIn('updated_at', response.json) def test_update_zone_transfer_request(self): initial = self.client.post_json( - '/zones/%s/tasks/transfer_requests' % (self.domain.id), + '/zones/%s/tasks/transfer_requests' % (self.zone.id), {}) response = self.client.patch_json( @@ -120,7 +120,7 @@ class ApiV2ZoneTransfersTest(ApiV2TestCase): self.assertIn('created_at', response.json) self.assertEqual('ACTIVE', response.json['status']) self.assertEqual( - self.domain.id, + self.zone.id, response.json['zone_id']) self.assertEqual( 'TEST', response.json['description']) @@ -128,7 +128,7 @@ class ApiV2ZoneTransfersTest(ApiV2TestCase): def test_delete_zone_transfer_request(self): initial = self.client.post_json( - '/zones/%s/tasks/transfer_requests' % (self.domain.id), + '/zones/%s/tasks/transfer_requests' % (self.zone.id), {}) response = self.client.delete( @@ -140,7 +140,7 @@ class ApiV2ZoneTransfersTest(ApiV2TestCase): def test_create_zone_transfer_accept(self): initial = self.client.post_json( - '/zones/%s/tasks/transfer_requests' % (self.domain.id), + '/zones/%s/tasks/transfer_requests' % (self.zone.id), {}) response = self.client.post_json( @@ -175,15 +175,15 @@ class ApiV2ZoneTransfersTest(ApiV2TestCase): new_ztr.json['status']) def test_create_zone_transfer_request_deleting_zone(self): - url = '/zones/%s/tasks/transfer_requests' % (self.domain.id) + url = '/zones/%s/tasks/transfer_requests' % (self.zone.id) body = {} - self.client.delete('/zones/%s' % self.domain['id'], status=202) + self.client.delete('/zones/%s' % self.zone['id'], status=202) self._assert_exception('bad_request', 400, self.client.post_json, url, body) def test_create_zone_transfer_accept_deleting_zone(self): - url = '/zones/%s/tasks/transfer_requests' % (self.domain.id) + url = '/zones/%s/tasks/transfer_requests' % (self.zone.id) body = {} - self.client.delete('/zones/%s' % self.domain['id'], status=202) + self.client.delete('/zones/%s' % self.zone['id'], status=202) self._assert_exception('bad_request', 400, self.client.post_json, url, body) diff --git a/designate/tests/test_api/test_v2/test_zones.py b/designate/tests/test_api/test_v2/test_zones.py index 4b3306ea..1e2a6524 100644 --- a/designate/tests/test_api/test_v2/test_zones.py +++ b/designate/tests/test_api/test_v2/test_zones.py @@ -38,7 +38,7 @@ class ApiV2ZonesTest(ApiV2TestCase): def test_create_zone(self): # Create a zone - fixture = self.get_domain_fixture(fixture=0) + fixture = self.get_zone_fixture(fixture=0) response = self.client.post_json('/zones/', fixture) # Check the headers are what we expect self.assertEqual(202, response.status_int) @@ -61,7 +61,7 @@ class ApiV2ZonesTest(ApiV2TestCase): def test_create_zone_no_type(self): # Create a zone - fixture = self.get_domain_fixture(fixture=0) + fixture = self.get_zone_fixture(fixture=0) del fixture['type'] response = self.client.post_json('/zones/', fixture) @@ -89,7 +89,7 @@ class ApiV2ZonesTest(ApiV2TestCase): # NOTE: The schemas should be tested separately to the API. So we # don't need to test every variation via the API itself. # Fetch a fixture - fixture = self.get_domain_fixture(fixture=0) + fixture = self.get_zone_fixture(fixture=0) # Add a junk field to the body fixture['junk'] = 'Junk Field' @@ -101,7 +101,7 @@ class ApiV2ZonesTest(ApiV2TestCase): '/zones', body) def test_create_zone_email_too_long(self): - fixture = self.get_domain_fixture(fixture=0) + fixture = self.get_zone_fixture(fixture=0) fixture.update({'email': 'a' * 255 + '@abc.com'}) body = fixture self._assert_exception('invalid_object', 400, self.client.post_json, @@ -116,7 +116,7 @@ class ApiV2ZonesTest(ApiV2TestCase): 'example.org.', 'bla.example.org.', ] - fixture = self.get_domain_fixture(fixture=0) + fixture = self.get_zone_fixture(fixture=0) for email in invalid_emails: fixture.update({'email': email}) body = fixture @@ -125,70 +125,70 @@ class ApiV2ZonesTest(ApiV2TestCase): '/zones', body) def test_create_zone_email_missing(self): - fixture = self.get_domain_fixture(fixture=0) + fixture = self.get_zone_fixture(fixture=0) del fixture['email'] body = fixture self._assert_exception('invalid_object', 400, self.client.post_json, '/zones', body) def test_create_zone_ttl_less_than_zero(self): - fixture = self.get_domain_fixture(fixture=0) + fixture = self.get_zone_fixture(fixture=0) fixture['ttl'] = -1 body = fixture self._assert_exception('invalid_object', 400, self.client.post_json, '/zones', body) def test_create_zone_ttl_is_zero(self): - fixture = self.get_domain_fixture(fixture=0) + fixture = self.get_zone_fixture(fixture=0) fixture['ttl'] = 0 body = fixture self._assert_exception('invalid_object', 400, self.client.post_json, '/zones', body) def test_create_zone_ttl_is_greater_than_max(self): - fixture = self.get_domain_fixture(fixture=0) + fixture = self.get_zone_fixture(fixture=0) fixture['ttl'] = 2174483648 body = fixture self._assert_exception('invalid_object', 400, self.client.post_json, '/zones', body) def test_create_zone_ttl_is_invalid(self): - fixture = self.get_domain_fixture(fixture=0) + fixture = self.get_zone_fixture(fixture=0) fixture['ttl'] = "!@?>" body = fixture self._assert_exception('invalid_object', 400, self.client.post_json, '/zones', body) def test_create_zone_ttl_is_not_required_field(self): - fixture = self.get_domain_fixture(fixture=0) + fixture = self.get_zone_fixture(fixture=0) body = fixture response = self.client.post_json('/zones', body) self.assertEqual(202, response.status_int) self.assertEqual('application/json', response.content_type) def test_create_zone_description_too_long(self): - fixture = self.get_domain_fixture(fixture=0) + fixture = self.get_zone_fixture(fixture=0) fixture['description'] = "a" * 161 body = fixture self._assert_exception('invalid_object', 400, self.client.post_json, '/zones', body) def test_create_zone_name_is_missing(self): - fixture = self.get_domain_fixture(fixture=0) + fixture = self.get_zone_fixture(fixture=0) del fixture['name'] body = fixture self._assert_exception('invalid_object', 400, self.client.post_json, '/zones', body) def test_create_zone_name_too_long(self): - fixture = self.get_domain_fixture(fixture=0) + fixture = self.get_zone_fixture(fixture=0) fixture['name'] = 'x' * 255 + ".com" body = fixture self._assert_exception('invalid_object', 400, self.client.post_json, '/zones', body) def test_create_zone_body_validation(self): - fixture = self.get_domain_fixture(fixture=0) + fixture = self.get_zone_fixture(fixture=0) # Add id to the body fixture['id'] = '2fdadfb1-cf96-4259-ac6b-bb7b6d2ff980' # Ensure it fails with a 400 @@ -196,7 +196,7 @@ class ApiV2ZonesTest(ApiV2TestCase): self._assert_exception('invalid_object', 400, self.client.post_json, '/zones', body) - fixture = self.get_domain_fixture(fixture=0) + fixture = self.get_zone_fixture(fixture=0) # Add created_at to the body fixture['created_at'] = '2014-03-12T19:07:53.000000' # Ensure it fails with a 400 @@ -206,30 +206,30 @@ class ApiV2ZonesTest(ApiV2TestCase): def test_create_zone_invalid_name(self): # Try to create a zone with an invalid name - fixture = self.get_domain_fixture(fixture=-1) + fixture = self.get_zone_fixture(fixture=-1) # Ensure it fails with a 400 self._assert_exception('invalid_object', 400, self.client.post_json, '/zones', fixture) - @patch.object(central_service.Service, 'create_domain', + @patch.object(central_service.Service, 'create_zone', side_effect=messaging.MessagingTimeout()) def test_create_zone_timeout(self, _): - fixture = self.get_domain_fixture(fixture=0) + fixture = self.get_zone_fixture(fixture=0) body = fixture self._assert_exception('timeout', 504, self.client.post_json, '/zones/', body) - @patch.object(central_service.Service, 'create_domain', - side_effect=exceptions.DuplicateDomain()) + @patch.object(central_service.Service, 'create_zone', + side_effect=exceptions.DuplicateZone()) def test_create_zone_duplicate(self, _): - fixture = self.get_domain_fixture(fixture=0) + fixture = self.get_zone_fixture(fixture=0) body = fixture - self._assert_exception('duplicate_domain', 409, self.client.post_json, + self._assert_exception('duplicate_zone', 409, self.client.post_json, '/zones/', body) def test_create_zone_missing_content_type(self): @@ -270,20 +270,20 @@ class ApiV2ZonesTest(ApiV2TestCase): # We should start with 0 zones self.assertEqual(0, len(response.json['zones'])) - data = [self.create_domain(name='x-%s.com.' % i) + data = [self.create_zone(name='x-%s.com.' % i) for i in 'abcdefghij'] self._assert_paging(data, '/zones', key='zones') self._assert_invalid_paging(data, '/zones', key='zones') - @patch.object(central_service.Service, 'find_domains', + @patch.object(central_service.Service, 'find_zones', side_effect=messaging.MessagingTimeout()) def test_get_zones_timeout(self, _): self._assert_exception('timeout', 504, self.client.get, '/zones/') def test_get_zone(self): # Create a zone - zone = self.create_domain() + zone = self.create_zone() response = self.client.get('/zones/%s' % zone['id'], headers=[('Accept', 'application/json')]) @@ -307,18 +307,18 @@ class ApiV2ZonesTest(ApiV2TestCase): def test_get_zone_invalid_id(self): self._assert_invalid_uuid(self.client.get, '/zones/%s') - @patch.object(central_service.Service, 'get_domain', + @patch.object(central_service.Service, 'get_zone', side_effect=messaging.MessagingTimeout()) def test_get_zone_timeout(self, _): url = '/zones/2fdadfb1-cf96-4259-ac6b-bb7b6d2ff980' self._assert_exception('timeout', 504, self.client.get, url, headers={'Accept': 'application/json'}) - @patch.object(central_service.Service, 'get_domain', - side_effect=exceptions.DomainNotFound()) + @patch.object(central_service.Service, 'get_zone', + side_effect=exceptions.ZoneNotFound()) def test_get_zone_missing(self, _): url = '/zones/2fdadfb1-cf96-4259-ac6b-bb7b6d2ff980' - self._assert_exception('domain_not_found', 404, self.client.get, url, + self._assert_exception('zone_not_found', 404, self.client.get, url, headers={'Accept': 'application/json'}) def test_get_zone_bad_accept(self): @@ -328,7 +328,7 @@ class ApiV2ZonesTest(ApiV2TestCase): def test_update_zone(self): # Create a zone - zone = self.create_domain() + zone = self.create_zone() # Prepare an update body body = {'email': 'prefix-%s' % zone['email']} @@ -358,7 +358,7 @@ class ApiV2ZonesTest(ApiV2TestCase): # NOTE: The schemas should be tested separatly to the API. So we # don't need to test every variation via the API itself. # Create a zone - zone = self.create_domain() + zone = self.create_zone() # Prepare an update body with junk in the body body = {'email': 'prefix-%s' % zone['email'], @@ -386,8 +386,8 @@ class ApiV2ZonesTest(ApiV2TestCase): self._assert_exception('invalid_object', 400, self.client.patch_json, url, body) - @patch.object(central_service.Service, 'get_domain', - side_effect=exceptions.DuplicateDomain()) + @patch.object(central_service.Service, 'get_zone', + side_effect=exceptions.DuplicateZone()) def test_update_zone_duplicate(self, _): # Prepare an update body body = {'email': 'example@example.org'} @@ -395,10 +395,10 @@ class ApiV2ZonesTest(ApiV2TestCase): url = '/zones/2fdadfb1-cf96-4259-ac6b-bb7b6d2ff980' # Ensure it fails with a 409 - self._assert_exception('duplicate_domain', 409, self.client.patch_json, + self._assert_exception('duplicate_zone', 409, self.client.patch_json, url, body) - @patch.object(central_service.Service, 'get_domain', + @patch.object(central_service.Service, 'get_zone', side_effect=messaging.MessagingTimeout()) def test_update_zone_timeout(self, _): # Prepare an update body @@ -410,8 +410,8 @@ class ApiV2ZonesTest(ApiV2TestCase): self._assert_exception('timeout', 504, self.client.patch_json, url, body) - @patch.object(central_service.Service, 'get_domain', - side_effect=exceptions.DomainNotFound()) + @patch.object(central_service.Service, 'get_zone', + side_effect=exceptions.ZoneNotFound()) def test_update_zone_missing(self, _): # Prepare an update body body = {'email': 'example@example.org'} @@ -419,11 +419,11 @@ class ApiV2ZonesTest(ApiV2TestCase): url = '/zones/2fdadfb1-cf96-4259-ac6b-bb7b6d2ff980' # Ensure it fails with a 404 - self._assert_exception('domain_not_found', 404, self.client.patch_json, + self._assert_exception('zone_not_found', 404, self.client.patch_json, url, body) def test_delete_zone(self): - zone = self.create_domain() + zone = self.create_zone() response = self.client.delete('/zones/%s' % zone['id'], status=202) @@ -436,35 +436,35 @@ class ApiV2ZonesTest(ApiV2TestCase): def test_delete_zone_invalid_id(self): self._assert_invalid_uuid(self.client.delete, '/zones/%s') - @patch.object(central_service.Service, 'delete_domain', + @patch.object(central_service.Service, 'delete_zone', side_effect=messaging.MessagingTimeout()) def test_delete_zone_timeout(self, _): url = '/zones/2fdadfb1-cf96-4259-ac6b-bb7b6d2ff980' self._assert_exception('timeout', 504, self.client.delete, url) - @patch.object(central_service.Service, 'delete_domain', - side_effect=exceptions.DomainNotFound()) + @patch.object(central_service.Service, 'delete_zone', + side_effect=exceptions.ZoneNotFound()) def test_delete_zone_missing(self, _): url = '/zones/2fdadfb1-cf96-4259-ac6b-bb7b6d2ff980' - self._assert_exception('domain_not_found', 404, self.client.delete, + self._assert_exception('zone_not_found', 404, self.client.delete, url) def test_post_abandon_zone(self): - zone = self.create_domain() + zone = self.create_zone() url = '/zones/%s/tasks/abandon' % zone.id # Ensure that we get permission denied self._assert_exception('forbidden', 403, self.client.post_json, url) # Ensure that abandon zone succeeds with the right policy - self.policy({'abandon_domain': '@'}) + self.policy({'abandon_zone': '@'}) response = self.client.post_json(url) self.assertEqual(204, response.status_int) def test_get_abandon_zone(self): - zone = self.create_domain() + zone = self.create_zone() url = '/zones/%s/tasks/abandon' % zone.id self._assert_exception('method_not_allowed', 405, self.client.get, url) @@ -475,13 +475,13 @@ class ApiV2ZonesTest(ApiV2TestCase): def test_get_zone_tasks(self): # This is an invalid endpoint - should return 404 - zone = self.create_domain() + zone = self.create_zone() url = '/zones/%s/tasks' % zone.id self._assert_exception('not_found', 404, self.client.get, url) def test_create_secondary(self): # Create a zone - fixture = self.get_domain_fixture('SECONDARY', 0) + fixture = self.get_zone_fixture('SECONDARY', 0) fixture['masters'] = ["10.0.0.1"] response = self.client.post_json('/zones/', fixture) @@ -512,20 +512,20 @@ class ApiV2ZonesTest(ApiV2TestCase): def test_create_secondary_no_masters(self): # Create a zone - fixture = self.get_domain_fixture('SECONDARY', 0) + fixture = self.get_zone_fixture('SECONDARY', 0) self._assert_exception('invalid_object', 400, self.client.post_json, '/zones/', fixture) def test_update_secondary(self): # Create a zone - fixture = self.get_domain_fixture('SECONDARY', 0) + fixture = self.get_zone_fixture('SECONDARY', 0) - domain = objects.Domain(**fixture) - domain.email = cfg.CONF['service:central'].managed_resource_email + zone = objects.Zone(**fixture) + zone.email = cfg.CONF['service:central'].managed_resource_email # Create a zone - zone = self.central_service.create_domain(self.admin_context, domain) + zone = self.central_service.create_zone(self.admin_context, zone) masters = ['10.0.0.1', '10.0.0.2'] @@ -552,12 +552,12 @@ class ApiV2ZonesTest(ApiV2TestCase): def test_xfr_request(self): # Create a zone - fixture = self.get_domain_fixture('SECONDARY', 0) + fixture = self.get_zone_fixture('SECONDARY', 0) fixture['email'] = cfg.CONF['service:central'].managed_resource_email fixture['attributes'] = [{"key": "master", "value": "10.0.0.10"}] # Create a zone - zone = self.create_domain(**fixture) + zone = self.create_zone(**fixture) mdns = mock.Mock() with mock.patch.object(mdns_api.MdnsAPI, 'get_instance') as get_mdns: @@ -577,7 +577,7 @@ class ApiV2ZonesTest(ApiV2TestCase): def test_invalid_xfr_request(self): # Create a zone - zone = self.create_domain() + zone = self.create_zone() response = self.client.post_json( '/zones/%s/tasks/xfr' % zone['id'], @@ -589,11 +589,11 @@ class ApiV2ZonesTest(ApiV2TestCase): def test_update_secondary_email_invalid_object(self): # Create a zone - fixture = self.get_domain_fixture('SECONDARY', 0) + fixture = self.get_zone_fixture('SECONDARY', 0) fixture['email'] = cfg.CONF['service:central'].managed_resource_email # Create a zone - zone = self.create_domain(**fixture) + zone = self.create_zone(**fixture) body = {'email': 'foo@bar.io'} @@ -615,7 +615,7 @@ class ApiV2ZonesTest(ApiV2TestCase): self.assertEqual(0, response.json['metadata']['total_count']) # Create a zone - fixture = self.get_domain_fixture(fixture=0) + fixture = self.get_zone_fixture(fixture=0) response = self.client.post_json('/zones/', fixture) response = self.client.get('/zones/') @@ -625,10 +625,10 @@ class ApiV2ZonesTest(ApiV2TestCase): def test_total_count_pagination(self): # Create two zones - fixture = self.get_domain_fixture(fixture=0) + fixture = self.get_zone_fixture(fixture=0) response = self.client.post_json('/zones/', fixture) - fixture = self.get_domain_fixture(fixture=1) + fixture = self.get_zone_fixture(fixture=1) response = self.client.post_json('/zones/', fixture) # Paginate so that there is only one zone returned @@ -641,7 +641,7 @@ class ApiV2ZonesTest(ApiV2TestCase): def test_no_update_deleting(self): # Create a zone - zone = self.create_domain() + zone = self.create_zone() # Prepare an update body body = {'zone': {'email': 'prefix-%s' % zone['email']}} @@ -652,7 +652,7 @@ class ApiV2ZonesTest(ApiV2TestCase): def test_get_nameservers(self): # Create a zone - zone = self.create_domain() + zone = self.create_zone() # Prepare an update body @@ -667,13 +667,13 @@ class ApiV2ZonesTest(ApiV2TestCase): def test_get_zones_filter(self): # Add zones for testing fixtures = [ - self.get_domain_fixture( + self.get_zone_fixture( 'PRIMARY', fixture=0, values={ 'ttl': 3600, 'description': 'test1' } ), - self.get_domain_fixture( + self.get_zone_fixture( 'PRIMARY', fixture=1, values={ 'ttl': 4000, 'description': 'test2' diff --git a/designate/tests/test_backend/test_dynect.py b/designate/tests/test_backend/test_dynect.py index 6d0a8079..3fe8e05b 100644 --- a/designate/tests/test_backend/test_dynect.py +++ b/designate/tests/test_backend/test_dynect.py @@ -153,9 +153,9 @@ class DynECTTestsCase(BackendTestCase): self.stub_url('POST', ['/Session'], json=LOGIN_SUCCESS) self.stub_url('DELETE', ['/Session'], json=LOGIN_SUCCESS) - def test_create_domain_raise_dynclienterror(self): + def test_create_zone_raise_dynclienterror(self): context = self.get_context() - domain = self.create_domain() + zone = self.create_zone() self._stub_login() @@ -165,15 +165,15 @@ class DynECTTestsCase(BackendTestCase): status_code=400) with testtools.ExpectedException(impl_dynect.DynClientError): - self.backend.create_domain(context, domain) + self.backend.create_zone(context, zone) - def test_create_domain_duplicate_updates_existing(self): + def test_create_zone_duplicate_updates_existing(self): context = self.get_context() - domain = self.create_domain() + zone = self.create_zone() self._stub_login() - parts = ['/Secondary', '/%s' % domain['name'].rstrip('.')] + parts = ['/Secondary', '/%s' % zone['name'].rstrip('.')] self.stub_url( 'POST', parts, @@ -182,6 +182,6 @@ class DynECTTestsCase(BackendTestCase): update = self.stub_url('PUT', parts, json=ACTIVATE_SUCCESS) - self.backend.create_domain(context, domain) + self.backend.create_zone(context, zone) self.assertTrue(update.called) diff --git a/designate/tests/test_backend/test_infoblox.py b/designate/tests/test_backend/test_infoblox.py index cebbed19..de3fe576 100644 --- a/designate/tests/test_backend/test_infoblox.py +++ b/designate/tests/test_backend/test_infoblox.py @@ -24,8 +24,8 @@ from designate.backend.impl_infoblox import ibexceptions class InfobloxBackendTestCase(BackendTestCase): - def get_domain_fixture(self): - return super(InfobloxBackendTestCase, self).get_domain_fixture( + def get_zone_fixture(self): + return super(InfobloxBackendTestCase, self).get_zone_fixture( values={ 'name': 'test.example.com.' } @@ -65,28 +65,28 @@ class InfobloxBackendTestCase(BackendTestCase): self.backend.start() self.backend.infoblox = MagicMock() - def test_create_domain(self): + def test_create_zone(self): self.set_up_backend() context = self.get_context() - domain = self.get_domain_fixture() + zone = self.get_zone_fixture() self.backend.infoblox.get_dns_view = MagicMock(return_value='default') - self.backend.create_domain(context, domain) + self.backend.create_zone(context, zone) self.backend.infoblox.create_zone_auth.assert_called_once_with( fqdn='test.example.com', dns_view='default') - def test_update_domain(self): + def test_update_zone(self): self.set_up_backend() context = self.get_context() - domain = objects.Domain().from_dict(self.get_domain_fixture()) - self.backend.update_domain(context, domain) + zone = objects.Zone().from_dict(self.get_zone_fixture()) + self.backend.update_zone(context, zone) - def test_delete_domain(self): + def test_delete_zone(self): self.set_up_backend() context = self.get_context() - domain = self.get_domain_fixture() - self.backend.create_domain(context, domain) - self.backend.delete_domain(context, domain) + zone = self.get_zone_fixture() + self.backend.create_zone(context, zone) + self.backend.delete_zone(context, zone) self.backend.infoblox.delete_zone_auth.assert_called_once_with( 'test.example.com') diff --git a/designate/tests/test_backend/test_nsd4.py b/designate/tests/test_backend/test_nsd4.py index bd89b093..e20be5db 100644 --- a/designate/tests/test_backend/test_nsd4.py +++ b/designate/tests/test_backend/test_nsd4.py @@ -99,40 +99,40 @@ class NSD4BackendTestCase(BackendTestCase): self.backend = impl_nsd4.NSD4Backend(self.target) - def test_create_domain(self): + def test_create_zone(self): context = self.get_context() - domain = self.get_domain_fixture() - self.backend.create_domain(context, domain) - command = 'NSDCT1 addzone %s test-pattern\n' % domain['name'] + zone = self.get_zone_fixture() + self.backend.create_zone(context, zone) + command = 'NSDCT1 addzone %s test-pattern\n' % zone['name'] self.assertEqual(command, self.server_fixture.server.recved_command) - def test_delete_domain(self): + def test_delete_zone(self): context = self.get_context() - domain = self.get_domain_fixture() - self.backend.delete_domain(context, domain) - command = 'NSDCT1 delzone %s\n' % domain['name'] + zone = self.get_zone_fixture() + self.backend.delete_zone(context, zone) + command = 'NSDCT1 delzone %s\n' % zone['name'] self.assertEqual(command, self.server_fixture.server.recved_command) def test_server_not_ok(self): self.server_fixture.server.response = 'goat' context = self.get_context() - domain = self.get_domain_fixture() + zone = self.get_zone_fixture() self.assertRaises(exceptions.Backend, - self.backend.create_domain, - context, domain) + self.backend.create_zone, + context, zone) def test_ssl_error(self): self.backend._command = MagicMock(side_effect=ssl.SSLError) context = self.get_context() - domain = self.get_domain_fixture() + zone = self.get_zone_fixture() self.assertRaises(exceptions.Backend, - self.backend.create_domain, - context, domain) + self.backend.create_zone, + context, zone) def test_socket_error(self): self.backend._command = MagicMock(side_effect=socket.error) context = self.get_context() - domain = self.get_domain_fixture() + zone = self.get_zone_fixture() self.assertRaises(exceptions.Backend, - self.backend.create_domain, - context, domain) + self.backend.create_zone, + context, zone) diff --git a/designate/tests/test_backend/test_powerdns.py b/designate/tests/test_backend/test_powerdns.py index 8f84fdc9..74c2d8a6 100644 --- a/designate/tests/test_backend/test_powerdns.py +++ b/designate/tests/test_backend/test_powerdns.py @@ -28,9 +28,9 @@ class PowerDNSBackendTestCase(BackendTestCase): def setUp(self): super(PowerDNSBackendTestCase, self).setUp() - self.domain = objects.Domain(id='e2bed4dc-9d01-11e4-89d3-123b93f75cba', - name='example.com.', - email='example@example.com') + self.zone = objects.Zone(id='e2bed4dc-9d01-11e4-89d3-123b93f75cba', + name='example.com.', + email='example@example.com') self.target = objects.PoolTarget.from_dict({ 'id': '4588652b-50e7-46b9-b688-a9bad40a873e', @@ -55,9 +55,9 @@ class PowerDNSBackendTestCase(BackendTestCase): # Tests for Public Methpds @mock.patch.object(impl_powerdns.PowerDNSBackend, 'session', new_callable=mock.MagicMock) - def test_create_domain(self, session_mock): + def test_create_zone(self, session_mock): context = self.get_context() - self.backend.create_domain(context, self.domain) + self.backend.create_zone(context, self.zone) self.assertSessionTransactionCalls( session_mock, begin=1, commit=1, rollback=0) @@ -71,9 +71,9 @@ class PowerDNSBackendTestCase(BackendTestCase): self.assertDictContainsSubset( {'type': 'SLAVE', - 'designate_id': self.domain.id, + 'designate_id': self.zone.id, 'master': '192.0.2.1:53,192.0.2.2:35', - 'name': self.domain.name.rstrip('.')}, + 'name': self.zone.name.rstrip('.')}, session_mock.execute.call_args_list[0][0][1]) self.assertIsInstance( @@ -84,9 +84,9 @@ class PowerDNSBackendTestCase(BackendTestCase): new_callable=mock.Mock) @mock.patch.object(impl_powerdns.PowerDNSBackend, '_create', side_effect=Exception) - def test_create_domain_failure_on_create(self, create_mock, session_mock): + def test_create_zone_failure_on_create(self, create_mock, session_mock): with testtools.ExpectedException(Exception): - self.backend.create_domain(self.get_context(), self.domain) + self.backend.create_zone(self.get_context(), self.zone) self.assertSessionTransactionCalls( session_mock, begin=1, commit=0, rollback=1) @@ -98,12 +98,12 @@ class PowerDNSBackendTestCase(BackendTestCase): new_callable=mock.Mock) @mock.patch.object(impl_powerdns.PowerDNSBackend, '_create', return_value=None) - def test_create_domain_failure_on_commit(self, create_mock, session_mock): + def test_create_zone_failure_on_commit(self, create_mock, session_mock): # Configure the Session mocks's commit method to raise an exception session_mock.commit.side_effect = Exception with testtools.ExpectedException(Exception): - self.backend.create_domain(self.get_context(), self.domain) + self.backend.create_zone(self.get_context(), self.zone) self.assertSessionTransactionCalls( session_mock, begin=1, commit=1, rollback=0) @@ -115,7 +115,7 @@ class PowerDNSBackendTestCase(BackendTestCase): new_callable=mock.Mock) @mock.patch.object(impl_powerdns.PowerDNSBackend, '_get', return_value=None) - def test_delete_domain(self, get_mock, session_mock): + def test_delete_zone(self, get_mock, session_mock): # Configure the Session mocks's execute method to return a fudged # resultproxy. rp_mock = mock.Mock() @@ -124,11 +124,11 @@ class PowerDNSBackendTestCase(BackendTestCase): session_mock.execute.return_value = rp_mock context = self.get_context() - self.backend.delete_domain(context, self.domain) + self.backend.delete_zone(context, self.zone) # Ensure the _get method was called with the correct arguments get_mock.assert_called_once_with( - tables.domains, self.domain.id, exceptions.DomainNotFound, + tables.domains, self.zone.id, exceptions.ZoneNotFound, id_col=tables.domains.c.designate_id) # Ensure we have one query, a DELETE @@ -143,17 +143,17 @@ class PowerDNSBackendTestCase(BackendTestCase): @mock.patch.object(impl_powerdns.PowerDNSBackend, 'session', new_callable=mock.Mock) @mock.patch.object(impl_powerdns.PowerDNSBackend, '_get', - side_effect=exceptions.DomainNotFound) + side_effect=exceptions.ZoneNotFound) @mock.patch.object(impl_powerdns.PowerDNSBackend, '_delete', return_value=None) - def test_delete_domain_domain_not_found(self, delete_mock, get_mock, - session_mock): + def test_delete_zone_zone_not_found(self, delete_mock, get_mock, + session_mock): context = self.get_context() - self.backend.delete_domain(context, self.domain) + self.backend.delete_zone(context, self.zone) # Ensure the _get method was called with the correct arguments get_mock.assert_called_once_with( - tables.domains, self.domain.id, exceptions.DomainNotFound, + tables.domains, self.zone.id, exceptions.ZoneNotFound, id_col=tables.domains.c.designate_id) # Ensure the _delete method was not called diff --git a/designate/tests/test_central/_test_service_ipa.py b/designate/tests/test_central/_test_service_ipa.py index a3f490cb..274d3823 100644 --- a/designate/tests/test_central/_test_service_ipa.py +++ b/designate/tests/test_central/_test_service_ipa.py @@ -52,27 +52,27 @@ class CentralServiceTestIPA(designate.tests.test_central. # go directly through storage api to bypass tenant/policy checks save_all_tenants = self.admin_context.all_tenants self.admin_context.all_tenants = True - self.startdomains = self.central_service.storage.\ - find_domains(self.admin_context) - LOG.debug("%s.setUp: startdomains %d" % (self.__class__, - len(self.startdomains))) + self.startzones = self.central_service.storage.\ + find_zones(self.admin_context) + LOG.debug("%s.setUp: startzones %d" % (self.__class__, + len(self.startzones))) self.admin_context.all_tenants = save_all_tenants def tearDown(self): - # delete domains + # delete zones # go directly through storage api to bypass tenant/policy checks self.admin_context.all_tenants = True - domains = self.central_service.storage.\ - find_domains(self.admin_context) - LOG.debug("%s.tearDown: domains %d" % (self.__class__, - len(self.startdomains))) - for domain in domains: - if domain in self.startdomains: + zones = self.central_service.storage.\ + find_zones(self.admin_context) + LOG.debug("%s.tearDown: zones %d" % (self.__class__, + len(self.startzones))) + for zone in zones: + if zone in self.startzones: continue - # go directly to backend - front end domains will be + # go directly to backend - front end zones will be # removed when the database fixture is reset - self.central_service.backend.delete_domain(self.admin_context, - domain) + self.central_service.backend.delete_zone(self.admin_context, + zone) super(CentralServiceTestIPA, self).tearDown() @@ -82,23 +82,23 @@ class CentralServiceTestIPA(designate.tests.test_central. self.assertEqual(rec1dict, rec2dict) def test_delete_recordset_extra(self): - domain = self.create_domain() + zone = self.create_zone() # Create a recordset - recsetA = self.create_recordset(domain, 'A') - recsetMX = self.create_recordset(domain, 'MX') + recsetA = self.create_recordset(zone, 'A') + recsetMX = self.create_recordset(zone, 'MX') # create two records in recsetA - recA0 = self.create_record(domain, recsetA, fixture=0) - recA1 = self.create_record(domain, recsetA, fixture=1) + recA0 = self.create_record(zone, recsetA, fixture=0) + recA1 = self.create_record(zone, recsetA, fixture=1) # create two records in recsetMX - recMX0 = self.create_record(domain, recsetMX, fixture=0) - recMX1 = self.create_record(domain, recsetMX, fixture=1) + recMX0 = self.create_record(zone, recsetMX, fixture=0) + recMX1 = self.create_record(zone, recsetMX, fixture=1) # verify two records in each recset criterion = { - 'domain_id': domain['id'], + 'zone_id': zone['id'], 'recordset_id': recsetA['id'] } @@ -120,12 +120,12 @@ class CentralServiceTestIPA(designate.tests.test_central. # Delete recsetA self.central_service.delete_recordset( - self.admin_context, domain['id'], recsetA['id']) + self.admin_context, zone['id'], recsetA['id']) # Fetch the recordset again, ensuring an exception is raised with testtools.ExpectedException(exceptions.RecordSetNotFound): self.central_service.get_recordset( - self.admin_context, domain['id'], recsetA['id']) + self.admin_context, zone['id'], recsetA['id']) # should be no records left in recsetA # however, that doesn't appear to be how @@ -150,28 +150,28 @@ class CentralServiceTestIPA(designate.tests.test_central. # Delete recsetMX self.central_service.delete_recordset( - self.admin_context, domain['id'], recsetMX['id']) + self.admin_context, zone['id'], recsetMX['id']) - def test_create_domain_no_min_ttl(self): + def test_create_zone_no_min_ttl(self): """Override - ipa does not allow negative ttl values - instead, check for proper error """ self.policy({'use_low_ttl': '!'}) self.config(min_ttl="None", group='service:central') - values = self.get_domain_fixture(1) + values = self.get_zone_fixture(1) values['ttl'] = -100 # Create a server self.create_nameserver() - # Create domain with negative TTL + # Create zone with negative TTL with testtools.ExpectedException(impl_ipa.IPAInvalidData): - self.central_service.create_domain( + self.central_service.create_zone( self.admin_context, values=values) @unittest.skip("this is currently broken in IPA") - def test_idn_create_domain_over_tld(self): + def test_idn_create_zone_over_tld(self): pass @unittest.skip("not supported in IPA") diff --git a/designate/tests/test_central/test_service.py b/designate/tests/test_central/test_service.py index acb5bf57..32f2238b 100644 --- a/designate/tests/test_central/test_service.py +++ b/designate/tests/test_central/test_service.py @@ -54,24 +54,24 @@ class CentralServiceTest(CentralTestCase): self.central_service.start() self.assertTrue(self.central_service.check_for_tlds) - def test_is_valid_domain_name(self): - self.config(max_domain_name_len=10, + def test_is_valid_zone_name(self): + self.config(max_zone_name_len=10, group='service:central') context = self.get_context() - self.central_service._is_valid_domain_name(context, 'valid.org.') + self.central_service._is_valid_zone_name(context, 'valid.org.') - with testtools.ExpectedException(exceptions.InvalidDomainName): - self.central_service._is_valid_domain_name(context, 'example.org.') + with testtools.ExpectedException(exceptions.InvalidZoneName): + self.central_service._is_valid_zone_name(context, 'example.org.') - with testtools.ExpectedException(exceptions.InvalidDomainName): - self.central_service._is_valid_domain_name(context, 'example.tld.') + with testtools.ExpectedException(exceptions.InvalidZoneName): + self.central_service._is_valid_zone_name(context, 'example.tld.') - with testtools.ExpectedException(exceptions.InvalidDomainName): - self.central_service._is_valid_domain_name(context, 'tld.') + with testtools.ExpectedException(exceptions.InvalidZoneName): + self.central_service._is_valid_zone_name(context, 'tld.') - def test_is_valid_domain_name_with_tlds(self): + def test_is_valid_zone_name_with_tlds(self): # Stop Service self.central_service.stop() list = objects.TldList() @@ -86,8 +86,8 @@ class CentralServiceTest(CentralTestCase): context = self.get_context() with mock.patch.object(self.central_service.storage, 'find_tld', return_value=objects.Tld(name='biz')): - with testtools.ExpectedException(exceptions.InvalidDomainName): - self.central_service._is_valid_domain_name(context, 'biz.') + with testtools.ExpectedException(exceptions.InvalidZoneName): + self.central_service._is_valid_zone_name(context, 'biz.') def test_is_valid_recordset_name(self): self.config(max_recordset_name_len=18, @@ -95,30 +95,30 @@ class CentralServiceTest(CentralTestCase): context = self.get_context() - domain = self.create_domain(name='example.org.') + zone = self.create_zone(name='example.org.') self.central_service._is_valid_recordset_name( - context, domain, 'valid.example.org.') + context, zone, 'valid.example.org.') with testtools.ExpectedException(exceptions.InvalidRecordSetName): self.central_service._is_valid_recordset_name( - context, domain, 'toolong.example.org.') + context, zone, 'toolong.example.org.') with testtools.ExpectedException(ValueError): self.central_service._is_valid_recordset_name( - context, domain, 'invalidtld.example.org') + context, zone, 'invalidtld.example.org') with testtools.ExpectedException(exceptions.InvalidRecordSetLocation): self.central_service._is_valid_recordset_name( - context, domain, 'a.example.COM.') + context, zone, 'a.example.COM.') with testtools.ExpectedException(exceptions.InvalidRecordSetLocation): - # Ensure names ending in the domain name, but + # Ensure names ending in the zone name, but # not contained in it fail self.central_service._is_valid_recordset_name( - context, domain, 'aexample.org.') + context, zone, 'aexample.org.') - def test_is_blacklisted_domain_name(self): + def test_is_blacklisted_zone_name(self): # Create blacklisted zones with specific names self.create_blacklist(pattern='example.org.') self.create_blacklist(pattern='example.net.') @@ -126,38 +126,38 @@ class CentralServiceTest(CentralTestCase): self.create_blacklist(pattern='com.$') # Set the policy to reject the authz - self.policy({'use_blacklisted_domain': '!'}) + self.policy({'use_blacklisted_zone': '!'}) context = self.get_context() - result = self.central_service._is_blacklisted_domain_name( + result = self.central_service._is_blacklisted_zone_name( context, 'org.') self.assertFalse(result) - # Subdomains should not be allowed from a blacklisted domain - result = self.central_service._is_blacklisted_domain_name( + # subzones should not be allowed from a blacklisted zone + result = self.central_service._is_blacklisted_zone_name( context, 'www.example.org.') self.assertTrue(result) - result = self.central_service._is_blacklisted_domain_name( + result = self.central_service._is_blacklisted_zone_name( context, 'example.org.') self.assertTrue(result) - # Check for blacklisted domains containing regexps - result = self.central_service._is_blacklisted_domain_name( + # Check for blacklisted zones containing regexps + result = self.central_service._is_blacklisted_zone_name( context, 'example.net.') self.assertTrue(result) - result = self.central_service._is_blacklisted_domain_name( + result = self.central_service._is_blacklisted_zone_name( context, 'example.com.') self.assertTrue(result) - result = self.central_service._is_blacklisted_domain_name( + result = self.central_service._is_blacklisted_zone_name( context, 'blacklisted.org.') self.assertTrue(result) - def test_is_blacklisted_domain_name_evil(self): + def test_is_blacklisted_zone_name_evil(self): evil_regex = "(([a-z])+.)+[A-Z]([a-z])+$" evil_zone_name = ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaa.com.") @@ -171,76 +171,76 @@ class CentralServiceTest(CentralTestCase): 'find_blacklists', return_value=blacklists): - result = self.central_service._is_blacklisted_domain_name( + result = self.central_service._is_blacklisted_zone_name( context, evil_zone_name) self.assertTrue(result) - def test_is_subdomain(self): + def test_is_subzone(self): context = self.get_context() - # Create a domain (using the specified domain name) - domain = self.create_domain(name='example.org.') + # Create a zone (using the specified zone name) + zone = self.create_zone(name='example.org.') - result = self.central_service._is_subdomain( - context, 'org.', domain.pool_id) + result = self.central_service._is_subzone( + context, 'org.', zone.pool_id) self.assertFalse(result) - result = self.central_service._is_subdomain( - context, 'www.example.net.', domain.pool_id) + result = self.central_service._is_subzone( + context, 'www.example.net.', zone.pool_id) self.assertFalse(result) - result = self.central_service._is_subdomain( - context, 'example.org.', domain.pool_id) + result = self.central_service._is_subzone( + context, 'example.org.', zone.pool_id) self.assertFalse(result) - result = self.central_service._is_subdomain( - context, 'www.example.org.', domain.pool_id) + result = self.central_service._is_subzone( + context, 'www.example.org.', zone.pool_id) self.assertTrue(result) - def test_is_superdomain(self): + def test_is_superzone(self): context = self.get_context() - # Create a domain (using the specified domain name) - domain = self.create_domain(name='example.org.') + # Create a zone (using the specified zone name) + zone = self.create_zone(name='example.org.') LOG.debug("Testing 'org.'") - result = self.central_service._is_superdomain( - context, 'org.', domain.pool_id) + result = self.central_service._is_superzone( + context, 'org.', zone.pool_id) self.assertTrue(result) LOG.debug("Testing 'www.example.net.'") - result = self.central_service._is_superdomain( - context, 'www.example.net.', domain.pool_id) + result = self.central_service._is_superzone( + context, 'www.example.net.', zone.pool_id) self.assertFalse(result) LOG.debug("Testing 'www.example.org.'") - result = self.central_service._is_superdomain( - context, 'www.example.org.', domain.pool_id) + result = self.central_service._is_superzone( + context, 'www.example.org.', zone.pool_id) self.assertFalse(result) - def test_is_valid_recordset_placement_subdomain(self): + def test_is_valid_recordset_placement_subzone(self): context = self.get_context() - # Create a domain (using the specified domain name) - domain = self.create_domain(name='example.org.') - sub_domain = self.create_domain(name='sub.example.org.') + # Create a zone (using the specified zone name) + zone = self.create_zone(name='example.org.') + sub_zone = self.create_zone(name='sub.example.org.') - def _fail(domain_, name): + def _fail(zone_, name): with testtools.ExpectedException( exceptions.InvalidRecordSetLocation): - self.central_service._is_valid_recordset_placement_subdomain( - context, domain_, name) + self.central_service._is_valid_recordset_placement_subzone( + context, zone_, name) - def _ok(domain_, name): - self.central_service._is_valid_recordset_placement_subdomain( - context, domain_, name) + def _ok(zone_, name): + self.central_service._is_valid_recordset_placement_subzone( + context, zone_, name) - _fail(domain, 'record.sub.example.org.') - _fail(domain, 'sub.example.org.') - _ok(domain, 'example.org.') - _ok(domain, 'record.example.org.') + _fail(zone, 'record.sub.example.org.') + _fail(zone, 'sub.example.org.') + _ok(zone, 'example.org.') + _ok(zone, 'record.example.org.') - _ok(sub_domain, 'record.example.org.') + _ok(sub_zone, 'record.example.org.') def test_is_valid_ttl(self): self.policy({'use_low_ttl': '!'}) @@ -248,7 +248,7 @@ class CentralServiceTest(CentralTestCase): group='service:central') context = self.get_context() - values = self.get_domain_fixture(fixture=1) + values = self.get_zone_fixture(fixture=1) values['ttl'] = 0 with testtools.ExpectedException(exceptions.InvalidTTL): @@ -425,8 +425,8 @@ class CentralServiceTest(CentralTestCase): self.assertEqual(0, tenants) # Explicitly set a tenant_id - self.create_domain(fixture=0, context=tenant_one_context) - self.create_domain(fixture=1, context=tenant_two_context) + self.create_zone(fixture=0, context=tenant_one_context) + self.create_zone(fixture=1, context=tenant_two_context) tenants = self.central_service.count_tenants(admin_context) self.assertEqual(2, tenants) @@ -438,31 +438,31 @@ class CentralServiceTest(CentralTestCase): with testtools.ExpectedException(exceptions.Forbidden): self.central_service.count_tenants(self.get_context()) - # Domain Tests + # Zone Tests @mock.patch.object(notifier.Notifier, "info") - def _test_create_domain(self, values, mock_notifier): + def _test_create_zone(self, values, mock_notifier): # Reset the mock to avoid the calls from the create_nameserver() call mock_notifier.reset_mock() - # Create a domain - domain = self.central_service.create_domain( - self.admin_context, domain=objects.Domain.from_dict(values)) + # Create a zone + zone = self.central_service.create_zone( + self.admin_context, zone=objects.Zone.from_dict(values)) # Ensure all values have been set correctly - self.assertIsNotNone(domain['id']) - self.assertEqual(values['name'], domain['name']) - self.assertEqual(values['email'], domain['email']) - self.assertIn('status', domain) + self.assertIsNotNone(zone['id']) + self.assertEqual(values['name'], zone['name']) + self.assertEqual(values['email'], zone['email']) + self.assertIn('status', zone) - self.assertEqual(1, mock_notifier.call_count) + self.assertEqual(2, mock_notifier.call_count) # Ensure the correct NS Records are in place pool = self.central_service.get_pool( - self.admin_context, domain.pool_id) + self.admin_context, zone.pool_id) ns_recordset = self.central_service.find_recordset( self.admin_context, - criterion={'domain_id': domain.id, 'type': "NS"}) + criterion={'zone_id': zone.id, 'type': "NS"}) self.assertIsNotNone(ns_recordset.id) self.assertEqual('NS', ns_recordset.type) @@ -470,31 +470,29 @@ class CentralServiceTest(CentralTestCase): self.assertEqual(set([n.hostname for n in pool.ns_records]), set([n.data for n in ns_recordset.records])) - mock_notifier.assert_called_once_with( - self.admin_context, 'dns.domain.create', domain) - return domain + return zone - def test_create_domain_duplicate_different_pools(self): - fixture = self.get_domain_fixture() + def test_create_zone_duplicate_different_pools(self): + fixture = self.get_zone_fixture() - # Create first domain that's placed in default pool - self.create_domain(**fixture) + # Create first zone that's placed in default pool + self.create_zone(**fixture) # Create a secondary pool second_pool = self.create_pool() fixture["pool_id"] = second_pool.id - self.create_domain(**fixture) + self.create_zone(**fixture) - def test_create_domain_over_tld(self): + def test_create_zone_over_tld(self): values = dict( name='example.com.', email='info@example.com', type='PRIMARY' ) - self._test_create_domain(values) + self._test_create_zone(values) - def test_idn_create_domain_over_tld(self): + def test_idn_create_zone_over_tld(self): values = dict( name='xn--3e0b707e' ) @@ -503,135 +501,135 @@ class CentralServiceTest(CentralTestCase): self.central_service.create_tld( self.admin_context, objects.Tld.from_dict(values)) - # Test creation of a domain in 한국 (kr) + # Test creation of a zone in 한국 (kr) values = dict( name='example.xn--3e0b707e.', email='info@example.xn--3e0b707e', type='PRIMARY' ) - self._test_create_domain(values) + self._test_create_zone(values) - def test_create_domain_over_quota(self): - self.config(quota_domains=1) + def test_create_zone_over_quota(self): + self.config(quota_zones=1) - self.create_domain() + self.create_zone() with testtools.ExpectedException(exceptions.OverQuota): - self.create_domain() + self.create_zone() - def test_create_subdomain(self): - # Create the Parent Domain using fixture 0 - parent_domain = self.create_domain(fixture=0) + def test_create_subzone(self): + # Create the Parent Zone using fixture 0 + parent_zone = self.create_zone(fixture=0) - # Prepare values for the subdomain using fixture 1 as a base - values = self.get_domain_fixture(fixture=1) - values['name'] = 'www.%s' % parent_domain['name'] + # Prepare values for the subzone using fixture 1 as a base + values = self.get_zone_fixture(fixture=1) + values['name'] = 'www.%s' % parent_zone['name'] - # Create the subdomain - domain = self.central_service.create_domain( - self.admin_context, objects.Domain.from_dict(values)) + # Create the subzone + zone = self.central_service.create_zone( + self.admin_context, objects.Zone.from_dict(values)) # Ensure all values have been set correctly - self.assertIsNotNone(domain['id']) - self.assertEqual(parent_domain['id'], domain['parent_domain_id']) + self.assertIsNotNone(zone['id']) + self.assertEqual(parent_zone['id'], zone['parent_zone_id']) - def test_create_subdomain_different_pools(self): - fixture = self.get_domain_fixture() + def test_create_subzone_different_pools(self): + fixture = self.get_zone_fixture() - # Create first domain that's placed in default pool - self.create_domain(**fixture) + # Create first zone that's placed in default pool + self.create_zone(**fixture) # Create a secondary pool second_pool = self.create_pool() fixture["pool_id"] = second_pool.id fixture["name"] = "sub.%s" % fixture["name"] - subdomain = self.create_domain(**fixture) - self.assertIsNone(subdomain.parent_domain_id) + subzone = self.create_zone(**fixture) + self.assertIsNone(subzone.parent_zone_id) - def test_create_superdomain(self): - # Prepare values for the domain and subdomain + def test_create_superzone(self): + # Prepare values for the zone and subzone # using fixture 1 as a base - domain_values = self.get_domain_fixture(fixture=1) + zone_values = self.get_zone_fixture(fixture=1) - subdomain_values = copy.deepcopy(domain_values) - subdomain_values['name'] = 'www.%s' % domain_values['name'] - subdomain_values['context'] = self.admin_context + subzone_values = copy.deepcopy(zone_values) + subzone_values['name'] = 'www.%s' % zone_values['name'] + subzone_values['context'] = self.admin_context - LOG.debug("domain_values: {0}".format(domain_values)) - LOG.debug("subdomain_values: {0}".format(subdomain_values)) + LOG.debug("zone_values: {0}".format(zone_values)) + LOG.debug("subzone_values: {0}".format(subzone_values)) - # Create the subdomain - subdomain = self.create_domain(**subdomain_values) + # Create the subzone + subzone = self.create_zone(**subzone_values) - # Create the Parent Domain using fixture 1 - parent_domain = self.central_service.create_domain( - self.admin_context, objects.Domain.from_dict(domain_values)) + # Create the Parent Zone using fixture 1 + parent_zone = self.central_service.create_zone( + self.admin_context, objects.Zone.from_dict(zone_values)) - # Get updated subdomain values - subdomain = self.central_service.get_domain(self.admin_context, - subdomain.id) + # Get updated subzone values + subzone = self.central_service.get_zone(self.admin_context, + subzone.id) # Ensure all values have been set correctly - self.assertIsNotNone(parent_domain['id']) - self.assertEqual(parent_domain['id'], subdomain['parent_domain_id']) + self.assertIsNotNone(parent_zone['id']) + self.assertEqual(parent_zone['id'], subzone['parent_zone_id']) - def test_create_subdomain_failure(self): + def test_create_subzone_failure(self): context = self.get_admin_context() # Explicitly set a tenant_id context.tenant = '1' - # Create the Parent Domain using fixture 0 - parent_domain = self.create_domain(fixture=0, context=context) + # Create the Parent Zone using fixture 0 + parent_zone = self.create_zone(fixture=0, context=context) context = self.get_admin_context() # Explicitly use a different tenant_id context.tenant = '2' - # Prepare values for the subdomain using fixture 1 as a base - values = self.get_domain_fixture(fixture=1) - values['name'] = 'www.%s' % parent_domain['name'] + # Prepare values for the subzone using fixture 1 as a base + values = self.get_zone_fixture(fixture=1) + values['name'] = 'www.%s' % parent_zone['name'] - # Attempt to create the subdomain - with testtools.ExpectedException(exceptions.IllegalChildDomain): - self.central_service.create_domain( - context, objects.Domain.from_dict(values)) + # Attempt to create the subzone + with testtools.ExpectedException(exceptions.IllegalChildZone): + self.central_service.create_zone( + context, objects.Zone.from_dict(values)) - def test_create_superdomain_failure(self): + def test_create_superzone_failure(self): context = self.get_admin_context() # Explicitly set a tenant_id context.tenant = '1' - # Set up domain and subdomain values - domain_values = self.get_domain_fixture(fixture=1) - domain_name = domain_values['name'] + # Set up zone and subzone values + zone_values = self.get_zone_fixture(fixture=1) + zone_name = zone_values['name'] - subdomain_values = copy.deepcopy(domain_values) - subdomain_values['name'] = 'www.%s' % domain_name - subdomain_values['context'] = context + subzone_values = copy.deepcopy(zone_values) + subzone_values['name'] = 'www.%s' % zone_name + subzone_values['context'] = context - # Create sub domain - self.create_domain(**subdomain_values) + # Create sub zone + self.create_zone(**subzone_values) context = self.get_admin_context() # Explicitly use a different tenant_id context.tenant = '2' - # Attempt to create the domain - with testtools.ExpectedException(exceptions.IllegalParentDomain): - self.central_service.create_domain( - context, objects.Domain.from_dict(domain_values)) + # Attempt to create the zone + with testtools.ExpectedException(exceptions.IllegalParentZone): + self.central_service.create_zone( + context, objects.Zone.from_dict(zone_values)) - def test_create_blacklisted_domain_success(self): + def test_create_blacklisted_zone_success(self): # Create blacklisted zone using default values self.create_blacklist() # Set the policy to accept the authz - self.policy({'use_blacklisted_domain': '@'}) + self.policy({'use_blacklisted_zone': '@'}) values = dict( name='blacklisted.com.', @@ -639,38 +637,38 @@ class CentralServiceTest(CentralTestCase): ) # Create a zone that is blacklisted - domain = self.central_service.create_domain( - self.admin_context, objects.Domain.from_dict(values)) + zone = self.central_service.create_zone( + self.admin_context, objects.Zone.from_dict(values)) # Ensure all values have been set correctly - self.assertIsNotNone(domain['id']) - self.assertEqual(domain['name'], values['name']) - self.assertEqual(domain['email'], values['email']) + self.assertIsNotNone(zone['id']) + self.assertEqual(zone['name'], values['name']) + self.assertEqual(zone['email'], values['email']) - def test_create_blacklisted_domain_fail(self): + def test_create_blacklisted_zone_fail(self): self.create_blacklist() # Set the policy to reject the authz - self.policy({'use_blacklisted_domain': '!'}) + self.policy({'use_blacklisted_zone': '!'}) values = dict( name='blacklisted.com.', email='info@blacklisted.com' ) - with testtools.ExpectedException(exceptions.InvalidDomainName): - # Create a domain - self.central_service.create_domain( - self.admin_context, objects.Domain.from_dict(values)) + with testtools.ExpectedException(exceptions.InvalidZoneName): + # Create a zone + self.central_service.create_zone( + self.admin_context, objects.Zone.from_dict(values)) - def _test_create_domain_fail(self, values, exception): + def _test_create_zone_fail(self, values, exception): with testtools.ExpectedException(exception): - # Create an invalid domain - self.central_service.create_domain( - self.admin_context, objects.Domain.from_dict(values)) + # Create an invalid zone + self.central_service.create_zone( + self.admin_context, objects.Zone.from_dict(values)) - def test_create_domain_invalid_tld_fail(self): + def test_create_zone_invalid_tld_fail(self): # add a tld for com self.create_tld(fixture=0) @@ -679,9 +677,9 @@ class CentralServiceTest(CentralTestCase): email='info@example.com' ) - # Create a valid domain - self.central_service.create_domain( - self.admin_context, objects.Domain.from_dict(values)) + # Create a valid zone + self.central_service.create_zone( + self.admin_context, objects.Zone.from_dict(values)) values = dict( name='example.net.', @@ -689,224 +687,221 @@ class CentralServiceTest(CentralTestCase): ) # There is no TLD for net so it should fail - with testtools.ExpectedException(exceptions.InvalidDomainName): - # Create an invalid domain - self.central_service.create_domain( - self.admin_context, objects.Domain.from_dict(values)) + with testtools.ExpectedException(exceptions.InvalidZoneName): + # Create an invalid zone + self.central_service.create_zone( + self.admin_context, objects.Zone.from_dict(values)) - def test_create_domain_invalid_ttl_fail(self): + def test_create_zone_invalid_ttl_fail(self): self.policy({'use_low_ttl': '!'}) self.config(min_ttl=100, group='service:central') context = self.get_context() - values = self.get_domain_fixture(fixture=1) + values = self.get_zone_fixture(fixture=1) values['ttl'] = 0 with testtools.ExpectedException(exceptions.InvalidTTL): - self.central_service.create_domain( - context, objects.Domain.from_dict(values)) + self.central_service.create_zone( + context, objects.Zone.from_dict(values)) - def test_create_domain_no_min_ttl(self): + def test_create_zone_no_min_ttl(self): self.policy({'use_low_ttl': '!'}) self.config(min_ttl=None, group='service:central') - values = self.get_domain_fixture(fixture=1) + values = self.get_zone_fixture(fixture=1) values['ttl'] = -100 - # Create domain with random TTL - domain = self.central_service.create_domain( - self.admin_context, objects.Domain.from_dict(values)) + # Create zone with random TTL + zone = self.central_service.create_zone( + self.admin_context, objects.Zone.from_dict(values)) # Ensure all values have been set correctly - self.assertEqual(values['ttl'], domain['ttl']) + self.assertEqual(values['ttl'], zone['ttl']) - def test_find_domains(self): - # Ensure we have no domains to start with. - domains = self.central_service.find_domains(self.admin_context) - self.assertEqual(0, len(domains)) + def test_find_zones(self): + # Ensure we have no zones to start with. + zones = self.central_service.find_zones(self.admin_context) + self.assertEqual(0, len(zones)) - # Create a single domain (using default values) - self.create_domain() + # Create a single zone (using default values) + self.create_zone() - # Ensure we can retrieve the newly created domain - domains = self.central_service.find_domains(self.admin_context) - self.assertEqual(1, len(domains)) - self.assertEqual('example.com.', domains[0]['name']) + # Ensure we can retrieve the newly created zone + zones = self.central_service.find_zones(self.admin_context) + self.assertEqual(1, len(zones)) + self.assertEqual('example.com.', zones[0]['name']) - # Create a second domain - self.create_domain(name='example.net.') + # Create a second zone + self.create_zone(name='example.net.') - # Ensure we can retrieve both domain - domains = self.central_service.find_domains(self.admin_context) - self.assertEqual(2, len(domains)) - self.assertEqual('example.com.', domains[0]['name']) - self.assertEqual('example.net.', domains[1]['name']) + # Ensure we can retrieve both zone + zones = self.central_service.find_zones(self.admin_context) + self.assertEqual(2, len(zones)) + self.assertEqual('example.com.', zones[0]['name']) + self.assertEqual('example.net.', zones[1]['name']) - def test_find_domains_criteria(self): - # Create a domain - domain_name = '%d.example.com.' % random.randint(10, 1000) - expected_domain = self.create_domain(name=domain_name) + def test_find_zones_criteria(self): + # Create a zone + zone_name = '%d.example.com.' % random.randint(10, 1000) + expected_zone = self.create_zone(name=zone_name) # Retrieve it, and ensure it's the same - criterion = {'name': domain_name} + criterion = {'name': zone_name} - domains = self.central_service.find_domains( + zones = self.central_service.find_zones( self.admin_context, criterion) - self.assertEqual(expected_domain['id'], domains[0]['id']) - self.assertEqual(expected_domain['name'], domains[0]['name']) - self.assertEqual(expected_domain['email'], domains[0]['email']) + self.assertEqual(expected_zone['id'], zones[0]['id']) + self.assertEqual(expected_zone['name'], zones[0]['name']) + self.assertEqual(expected_zone['email'], zones[0]['email']) - def test_find_domains_tenant_restrictions(self): + def test_find_zones_tenant_restrictions(self): admin_context = self.get_admin_context() admin_context.all_tenants = True tenant_one_context = self.get_context(tenant=1) tenant_two_context = self.get_context(tenant=2) - # Ensure we have no domains to start with. - domains = self.central_service.find_domains(admin_context) - self.assertEqual(0, len(domains)) + # Ensure we have no zones to start with. + zones = self.central_service.find_zones(admin_context) + self.assertEqual(0, len(zones)) - # Create a single domain (using default values) - domain = self.create_domain(context=tenant_one_context) + # Create a single zone (using default values) + zone = self.create_zone(context=tenant_one_context) - # Ensure admins can retrieve the newly created domain - domains = self.central_service.find_domains(admin_context) - self.assertEqual(1, len(domains)) - self.assertEqual(domain['name'], domains[0]['name']) + # Ensure admins can retrieve the newly created zone + zones = self.central_service.find_zones(admin_context) + self.assertEqual(1, len(zones)) + self.assertEqual(zone['name'], zones[0]['name']) - # Ensure tenant=1 can retrieve the newly created domain - domains = self.central_service.find_domains(tenant_one_context) - self.assertEqual(1, len(domains)) - self.assertEqual(domain['name'], domains[0]['name']) + # Ensure tenant=1 can retrieve the newly created zone + zones = self.central_service.find_zones(tenant_one_context) + self.assertEqual(1, len(zones)) + self.assertEqual(zone['name'], zones[0]['name']) - # Ensure tenant=2 can NOT retrieve the newly created domain - domains = self.central_service.find_domains(tenant_two_context) - self.assertEqual(0, len(domains)) + # Ensure tenant=2 can NOT retrieve the newly created zone + zones = self.central_service.find_zones(tenant_two_context) + self.assertEqual(0, len(zones)) - def test_get_domain(self): - # Create a domain - domain_name = '%d.example.com.' % random.randint(10, 1000) - expected_domain = self.create_domain(name=domain_name) + def test_get_zone(self): + # Create a zone + zone_name = '%d.example.com.' % random.randint(10, 1000) + expected_zone = self.create_zone(name=zone_name) # Retrieve it, and ensure it's the same - domain = self.central_service.get_domain( - self.admin_context, expected_domain['id']) + zone = self.central_service.get_zone( + self.admin_context, expected_zone['id']) - self.assertEqual(expected_domain['id'], domain['id']) - self.assertEqual(expected_domain['name'], domain['name']) - self.assertEqual(expected_domain['email'], domain['email']) + self.assertEqual(expected_zone['id'], zone['id']) + self.assertEqual(expected_zone['name'], zone['name']) + self.assertEqual(expected_zone['email'], zone['email']) - def test_get_domain_servers(self): - # Create a domain - domain = self.create_domain() + def test_get_zone_servers(self): + # Create a zone + zone = self.create_zone() # Retrieve the servers list - servers = self.central_service.get_domain_servers( - self.admin_context, domain['id']) + servers = self.central_service.get_zone_ns_records( + self.admin_context, zone['id']) self.assertTrue(len(servers) > 0) - def test_find_domain(self): - # Create a domain - domain_name = '%d.example.com.' % random.randint(10, 1000) - expected_domain = self.create_domain(name=domain_name) + def test_find_zone(self): + # Create a zone + zone_name = '%d.example.com.' % random.randint(10, 1000) + expected_zone = self.create_zone(name=zone_name) # Retrieve it, and ensure it's the same - criterion = {'name': domain_name} + criterion = {'name': zone_name} - domain = self.central_service.find_domain( + zone = self.central_service.find_zone( self.admin_context, criterion) - self.assertEqual(expected_domain['id'], domain['id']) - self.assertEqual(expected_domain['name'], domain['name']) - self.assertEqual(expected_domain['email'], domain['email']) - self.assertIn('status', domain) + self.assertEqual(expected_zone['id'], zone['id']) + self.assertEqual(expected_zone['name'], zone['name']) + self.assertEqual(expected_zone['email'], zone['email']) + self.assertIn('status', zone) @mock.patch.object(notifier.Notifier, "info") - def test_update_domain(self, mock_notifier): - # Create a domain - domain = self.create_domain(email='info@example.org') - original_serial = domain.serial + def test_update_zone(self, mock_notifier): + # Create a zone + zone = self.create_zone(email='info@example.org') + original_serial = zone.serial # Update the object - domain.email = 'info@example.net' + zone.email = 'info@example.net' - # Reset the mock to avoid the calls from the create_domain() call + # Reset the mock to avoid the calls from the create_zone() call mock_notifier.reset_mock() # Perform the update - self.central_service.update_domain(self.admin_context, domain) + self.central_service.update_zone(self.admin_context, zone) - # Fetch the domain again - domain = self.central_service.get_domain( - self.admin_context, domain.id) + # Fetch the zone again + zone = self.central_service.get_zone( + self.admin_context, zone.id) - # Ensure the domain was updated correctly - self.assertTrue(domain.serial > original_serial) - self.assertEqual('info@example.net', domain.email) + # Ensure the zone was updated correctly + self.assertTrue(zone.serial > original_serial) + self.assertEqual('info@example.net', zone.email) - self.assertEqual(1, mock_notifier.call_count) + self.assertEqual(2, mock_notifier.call_count) - # Check that the object used in the notify is a Domain and the id + # Check that the object used in the notify is a Zone and the id # matches up - notified_domain = mock_notifier.call_args[0][-1] - self.assertIsInstance(notified_domain, objects.Domain) - self.assertEqual(domain.id, notified_domain.id) + notified_zone = mock_notifier.call_args[0][-1] + self.assertIsInstance(notified_zone, objects.Zone) + self.assertEqual(zone.id, notified_zone.id) - mock_notifier.assert_called_once_with( - self.admin_context, 'dns.domain.update', mock.ANY) - - def test_update_domain_without_id(self): - # Create a domain - domain = self.create_domain(email='info@example.org') + def test_update_zone_without_id(self): + # Create a zone + zone = self.create_zone(email='info@example.org') # Update the object - domain.email = 'info@example.net' - domain.id = None + zone.email = 'info@example.net' + zone.id = None # Perform the update with testtools.ExpectedException(Exception): - self.central_service.update_domain(self.admin_context, domain) + self.central_service.update_zone(self.admin_context, zone) - def test_update_domain_without_incrementing_serial(self): - # Create a domain - domain = self.create_domain(email='info@example.org') - original_serial = domain.serial + def test_update_zone_without_incrementing_serial(self): + # Create a zone + zone = self.create_zone(email='info@example.org') + original_serial = zone.serial # Update the object - domain.email = 'info@example.net' + zone.email = 'info@example.net' # Perform the update - self.central_service.update_domain( - self.admin_context, domain, increment_serial=False) + self.central_service.update_zone( + self.admin_context, zone, increment_serial=False) - # Fetch the domain again - domain = self.central_service.get_domain(self.admin_context, domain.id) + # Fetch the zone again + zone = self.central_service.get_zone(self.admin_context, zone.id) - # Ensure the domain was updated correctly - self.assertEqual(original_serial, domain.serial) - self.assertEqual('info@example.net', domain.email) + # Ensure the zone was updated correctly + self.assertEqual(original_serial, zone.serial) + self.assertEqual('info@example.net', zone.email) - def test_update_domain_name_fail(self): - # Create a domain - domain = self.create_domain(name='example.org.') + def test_update_zone_name_fail(self): + # Create a zone + zone = self.create_zone(name='example.org.') # Update the Object - domain.name = 'example.net.' + zone.name = 'example.net.' # Perform the update with testtools.ExpectedException(exceptions.BadRequest): - self.central_service.update_domain(self.admin_context, domain) + self.central_service.update_zone(self.admin_context, zone) - def test_update_domain_deadlock_retry(self): - # Create a domain - domain = self.create_domain(name='example.org.') - original_serial = domain.serial + def test_update_zone_deadlock_retry(self): + # Create a zone + zone = self.create_zone(name='example.org.') + original_serial = zone.serial # Update the Object - domain.email = 'info@example.net' + zone.email = 'info@example.net' # Due to Python's scoping of i - we need to make it a mutable type # for the counter to work.. In Py3, we can use the nonlocal keyword. @@ -922,127 +917,124 @@ class CentralServiceTest(CentralTestCase): with mock.patch.object(self.central_service.storage, 'commit', side_effect=fail_once_then_pass): # Perform the update - domain = self.central_service.update_domain( - self.admin_context, domain) + zone = self.central_service.update_zone( + self.admin_context, zone) # Ensure i[0] is True, indicating the side_effect code above was # triggered self.assertTrue(i[0]) - # Ensure the domain was updated correctly - self.assertTrue(domain.serial > original_serial) - self.assertEqual('info@example.net', domain.email) + # Ensure the zone was updated correctly + self.assertTrue(zone.serial > original_serial) + self.assertEqual('info@example.net', zone.email) @mock.patch.object(notifier.Notifier, "info") - def test_delete_domain(self, mock_notifier): - # Create a domain - domain = self.create_domain() + def test_delete_zone(self, mock_notifier): + # Create a zone + zone = self.create_zone() mock_notifier.reset_mock() - # Delete the domain - self.central_service.delete_domain(self.admin_context, domain['id']) + # Delete the zone + self.central_service.delete_zone(self.admin_context, zone['id']) - # Fetch the domain - deleted_domain = self.central_service.get_domain( - self.admin_context, domain['id']) + # Fetch the zone + deleted_zone = self.central_service.get_zone( + self.admin_context, zone['id']) - # Ensure the domain is marked for deletion - self.assertEqual(domain.id, deleted_domain.id) - self.assertEqual(domain.name, deleted_domain.name) - self.assertEqual(domain.email, deleted_domain.email) - self.assertEqual('PENDING', deleted_domain.status) - self.assertEqual(domain.tenant_id, deleted_domain.tenant_id) - self.assertEqual(domain.parent_domain_id, - deleted_domain.parent_domain_id) - self.assertEqual('DELETE', deleted_domain.action) - self.assertEqual(domain.serial, deleted_domain.serial) - self.assertEqual(domain.pool_id, deleted_domain.pool_id) + # Ensure the zone is marked for deletion + self.assertEqual(zone.id, deleted_zone.id) + self.assertEqual(zone.name, deleted_zone.name) + self.assertEqual(zone.email, deleted_zone.email) + self.assertEqual('PENDING', deleted_zone.status) + self.assertEqual(zone.tenant_id, deleted_zone.tenant_id) + self.assertEqual(zone.parent_zone_id, + deleted_zone.parent_zone_id) + self.assertEqual('DELETE', deleted_zone.action) + self.assertEqual(zone.serial, deleted_zone.serial) + self.assertEqual(zone.pool_id, deleted_zone.pool_id) - self.assertEqual(1, mock_notifier.call_count) + self.assertEqual(2, mock_notifier.call_count) - # Check that the object used in the notify is a Domain and the id + # Check that the object used in the notify is a Zone and the id # matches up - notified_domain = mock_notifier.call_args[0][-1] - self.assertIsInstance(notified_domain, objects.Domain) - self.assertEqual(deleted_domain.id, notified_domain.id) + notified_zone = mock_notifier.call_args[0][-1] + self.assertIsInstance(notified_zone, objects.Zone) + self.assertEqual(deleted_zone.id, notified_zone.id) - mock_notifier.assert_called_once_with( - self.admin_context, 'dns.domain.delete', mock.ANY) + def test_delete_parent_zone(self): + # Create the Parent Zone using fixture 0 + parent_zone = self.create_zone(fixture=0) - def test_delete_parent_domain(self): - # Create the Parent Domain using fixture 0 - parent_domain = self.create_domain(fixture=0) + # Create the subzone + self.create_zone(fixture=1, name='www.%s' % parent_zone['name']) - # Create the subdomain - self.create_domain(fixture=1, name='www.%s' % parent_domain['name']) + # Attempt to delete the parent zone + with testtools.ExpectedException(exceptions.ZoneHasSubZone): + self.central_service.delete_zone( + self.admin_context, parent_zone['id']) - # Attempt to delete the parent domain - with testtools.ExpectedException(exceptions.DomainHasSubdomain): - self.central_service.delete_domain( - self.admin_context, parent_domain['id']) - - def test_count_domains(self): + def test_count_zones(self): # in the beginning, there should be nothing - domains = self.central_service.count_domains(self.admin_context) - self.assertEqual(0, domains) + zones = self.central_service.count_zones(self.admin_context) + self.assertEqual(0, zones) - # Create a single domain - self.create_domain() + # Create a single zone + self.create_zone() # count 'em up - domains = self.central_service.count_domains(self.admin_context) + zones = self.central_service.count_zones(self.admin_context) # well, did we get 1? - self.assertEqual(1, domains) + self.assertEqual(1, zones) - def test_count_domains_policy_check(self): + def test_count_zones_policy_check(self): # Set the policy to reject the authz - self.policy({'count_domains': '!'}) + self.policy({'count_zones': '!'}) with testtools.ExpectedException(exceptions.Forbidden): - self.central_service.count_domains(self.get_context()) + self.central_service.count_zones(self.get_context()) - def _fetch_all_domains(self): - """Fetch all domains including deleted ones + def _fetch_all_zones(self): + """Fetch all zones including deleted ones """ - query = tables.domains.select() + query = tables.zones.select() return self.central_service.storage.session.execute(query).fetchall() - def _log_all_domains(self, zones, msg=None): + def _log_all_zones(self, zones, msg=None): """Log out a summary of zones """ if msg: LOG.debug("--- %s ---" % msg) cols = ('name', 'status', 'action', 'deleted', 'deleted_at', - 'parent_domain_id') + 'parent_zone_id') tpl = "%-35s | %-11s | %-11s | %-32s | %-20s | %s" LOG.debug(tpl % cols) for z in zones: LOG.debug(tpl % tuple(z[k] for k in cols)) - def _assert_count_all_domains(self, n): - """Assert count ALL domains including deleted ones + def _assert_count_all_zones(self, n): + """Assert count ALL zones including deleted ones """ - zones = self._fetch_all_domains() + zones = self._fetch_all_zones() if len(zones) == n: return msg = "failed: %d zones expected, %d found" % (n, len(zones)) - self._log_all_domains(zones, msg=msg) + self._log_all_zones(zones, msg=msg) raise Exception("Unexpected number of zones") - def _create_deleted_domain(self, name, mock_deletion_time): - # Create a domain and set it as deleted - domain = self.create_domain(name=name) - self._delete_domain(domain, mock_deletion_time) - return domain + def _create_deleted_zone(self, name, mock_deletion_time): + # Create a zone and set it as deleted + zone = self.create_zone(name=name) + self._delete_zone(zone, mock_deletion_time) + return zone - def _delete_domain(self, domain, mock_deletion_time): - # Set a domain as deleted - zid = domain.id.replace('-', '') - query = tables.domains.update().\ - where(tables.domains.c.id == zid).\ + def _delete_zone(self, zone, mock_deletion_time): + # Set a zone as deleted + zid = zone.id.replace('-', '') + query = tables.zones.update().\ + where(tables.zones.c.id == zid).\ values( action='NONE', deleted=zid, @@ -1052,17 +1044,17 @@ class CentralServiceTest(CentralTestCase): pxy = self.central_service.storage.session.execute(query) self.assertEqual(1, pxy.rowcount) - return domain + return zone @mock.patch.object(notifier.Notifier, "info") - def test_purge_domains_nothing_to_purge(self, mock_notifier): + def test_purge_zones_nothing_to_purge(self, mock_notifier): # Create a zone - self.create_domain() + self.create_zone() mock_notifier.reset_mock() - self._assert_count_all_domains(1) + self._assert_count_all_zones(1) now = datetime.datetime(2015, 7, 31, 0, 0) - self.central_service.purge_domains( + self.central_service.purge_zones( self.admin_context, { 'status': 'DELETED', @@ -1071,18 +1063,18 @@ class CentralServiceTest(CentralTestCase): }, limit=100 ) - self._assert_count_all_domains(1) + self._assert_count_all_zones(1) @mock.patch.object(notifier.Notifier, "info") - def test_purge_domains_one_to_purge(self, mock_notifier): - self.create_domain() + def test_purge_zones_one_to_purge(self, mock_notifier): + self.create_zone() new = datetime.datetime(2015, 7, 30, 0, 0) now = datetime.datetime(2015, 7, 31, 0, 0) - self._create_deleted_domain('example2.org.', new) + self._create_deleted_zone('example2.org.', new) mock_notifier.reset_mock() - self._assert_count_all_domains(2) + self._assert_count_all_zones(2) - self.central_service.purge_domains( + self.central_service.purge_zones( self.admin_context, { 'deleted': '!0', @@ -1090,20 +1082,20 @@ class CentralServiceTest(CentralTestCase): }, limit=100, ) - self._assert_count_all_domains(1) + self._assert_count_all_zones(1) @mock.patch.object(notifier.Notifier, "info") - def test_purge_domains_one_to_purge_out_of_three(self, mock_notifier): - self.create_domain() + def test_purge_zones_one_to_purge_out_of_three(self, mock_notifier): + self.create_zone() old = datetime.datetime(2015, 7, 20, 0, 0) time_threshold = datetime.datetime(2015, 7, 25, 0, 0) new = datetime.datetime(2015, 7, 30, 0, 0) - self._create_deleted_domain('old.org.', old) - self._create_deleted_domain('new.org.', new) + self._create_deleted_zone('old.org.', old) + self._create_deleted_zone('new.org.', new) mock_notifier.reset_mock() - self._assert_count_all_domains(3) + self._assert_count_all_zones(3) - purge_cnt = self.central_service.purge_domains( + purge_cnt = self.central_service.purge_zones( self.admin_context, { 'deleted': '!0', @@ -1111,83 +1103,83 @@ class CentralServiceTest(CentralTestCase): }, limit=100, ) - self._assert_count_all_domains(2) + self._assert_count_all_zones(2) self.assertEqual(1, purge_cnt) @mock.patch.object(notifier.Notifier, "info") - def test_purge_domains_without_time_threshold(self, mock_notifier): - self.create_domain() + def test_purge_zones_without_time_threshold(self, mock_notifier): + self.create_zone() old = datetime.datetime(2015, 7, 20, 0, 0) new = datetime.datetime(2015, 7, 30, 0, 0) - self._create_deleted_domain('old.org.', old) - self._create_deleted_domain('new.org.', new) + self._create_deleted_zone('old.org.', old) + self._create_deleted_zone('new.org.', new) mock_notifier.reset_mock() - self._assert_count_all_domains(3) + self._assert_count_all_zones(3) - purge_cnt = self.central_service.purge_domains( + purge_cnt = self.central_service.purge_zones( self.admin_context, { 'deleted': '!0', }, limit=100, ) - self._assert_count_all_domains(1) + self._assert_count_all_zones(1) self.assertEqual(2, purge_cnt) @mock.patch.object(notifier.Notifier, "info") - def test_purge_domains_without_deleted_criterion(self, mock_notifier): - self.create_domain() + def test_purge_zones_without_deleted_criterion(self, mock_notifier): + self.create_zone() old = datetime.datetime(2015, 7, 20, 0, 0) time_threshold = datetime.datetime(2015, 7, 25, 0, 0) new = datetime.datetime(2015, 7, 30, 0, 0) - self._create_deleted_domain('old.org.', old) - self._create_deleted_domain('new.org.', new) + self._create_deleted_zone('old.org.', old) + self._create_deleted_zone('new.org.', new) mock_notifier.reset_mock() - self._assert_count_all_domains(3) + self._assert_count_all_zones(3) # Nothing should be purged - purge_cnt = self.central_service.purge_domains( + purge_cnt = self.central_service.purge_zones( self.admin_context, { 'deleted_at': "<=%s" % time_threshold }, limit=100, ) - self._assert_count_all_domains(3) + self._assert_count_all_zones(3) self.assertIsNone(purge_cnt) @mock.patch.object(notifier.Notifier, "info") - def test_purge_domains_by_name(self, mock_notifier): - self.create_domain() + def test_purge_zones_by_name(self, mock_notifier): + self.create_zone() - # The domain is purged (even if it was not deleted) - purge_cnt = self.central_service.purge_domains( + # The zone is purged (even if it was not deleted) + purge_cnt = self.central_service.purge_zones( self.admin_context, { 'name': 'example.com.' }, limit=100, ) - self._assert_count_all_domains(0) + self._assert_count_all_zones(0) self.assertEqual(1, purge_cnt) @mock.patch.object(notifier.Notifier, "info") - def test_purge_domains_without_any_criterion(self, mock_notifier): + def test_purge_zones_without_any_criterion(self, mock_notifier): with testtools.ExpectedException(TypeError): - self.central_service.purge_domains( + self.central_service.purge_zones( self.admin_context, limit=100, ) @mock.patch.object(notifier.Notifier, "info") - def test_purge_domains_with_sharding(self, mock_notifier): + def test_purge_zones_with_sharding(self, mock_notifier): old = datetime.datetime(2015, 7, 20, 0, 0) time_threshold = datetime.datetime(2015, 7, 25, 0, 0) - domain = self._create_deleted_domain('old.org.', old) + zone = self._create_deleted_zone('old.org.', old) mock_notifier.reset_mock() - # purge domains in an empty shard - self.central_service.purge_domains( + # purge zones in an empty shard + self.central_service.purge_zones( self.admin_context, { 'deleted': '!0', @@ -1196,70 +1188,70 @@ class CentralServiceTest(CentralTestCase): }, limit=100, ) - n_zones = self.central_service.count_domains(self.admin_context) + n_zones = self.central_service.count_zones(self.admin_context) self.assertEqual(1, n_zones) - # purge domains in a shard that contains the domain created above - self.central_service.purge_domains( + # purge zones in a shard that contains the zone created above + self.central_service.purge_zones( self.admin_context, { 'deleted': '!0', 'deleted_at': "<=%s" % time_threshold, - 'shard': 'BETWEEN 0, %d' % domain.shard, + 'shard': 'BETWEEN 0, %d' % zone.shard, }, limit=100, ) - n_zones = self.central_service.count_domains(self.admin_context) + n_zones = self.central_service.count_zones(self.admin_context) self.assertEqual(0, n_zones) - def test_purge_domains_walk_up_domains(self): - Zone = namedtuple('Zone', 'id parent_domain_id') + def test_purge_zones_walk_up_zones(self): + Zone = namedtuple('Zone', 'id parent_zone_id') zones = [Zone(x + 1, x) for x in range(1234, 1237)] zones_by_id = {z.id: z for z in zones} - sid = self.central_service.storage._walk_up_domains( + sid = self.central_service.storage._walk_up_zones( zones[0], zones_by_id) self.assertEqual(1234, sid) - sid = self.central_service.storage._walk_up_domains( + sid = self.central_service.storage._walk_up_zones( zones[-1], zones_by_id) self.assertEqual(1234, sid) - def test_purge_domains_walk_up_domains_loop(self): - Zone = namedtuple('Zone', 'id parent_domain_id') + def test_purge_zones_walk_up_zones_loop(self): + Zone = namedtuple('Zone', 'id parent_zone_id') zones = [Zone(2, 1), Zone(3, 2), Zone(1, 3)] zones_by_id = {z.id: z for z in zones} - with testtools.ExpectedException(exceptions.IllegalParentDomain): - self.central_service.storage._walk_up_domains( + with testtools.ExpectedException(exceptions.IllegalParentZone): + self.central_service.storage._walk_up_zones( zones[0], zones_by_id) @mock.patch.object(notifier.Notifier, "info") - def test_purge_domains_with_orphans(self, mock_notifier): + def test_purge_zones_with_orphans(self, mock_notifier): old = datetime.datetime(2015, 7, 20, 0, 0) time_threshold = datetime.datetime(2015, 7, 25, 0, 0) - # Create a tree of alive and deleted [sub]domains - z1 = self.create_domain(name='alive.org.') - z2 = self.create_domain(name='deleted.alive.org.') - z3 = self.create_domain(name='del2.deleted.alive.org.') - z4 = self.create_domain(name='del3.del2.deleted.alive.org.') - z5 = self.create_domain(name='alive2.del3.del2.deleted.alive.org.') + # Create a tree of alive and deleted [sub]zones + z1 = self.create_zone(name='alive.org.') + z2 = self.create_zone(name='deleted.alive.org.') + z3 = self.create_zone(name='del2.deleted.alive.org.') + z4 = self.create_zone(name='del3.del2.deleted.alive.org.') + z5 = self.create_zone(name='alive2.del3.del2.deleted.alive.org.') - self._delete_domain(z2, old) - self._delete_domain(z3, old) - self._delete_domain(z4, old) + self._delete_zone(z2, old) + self._delete_zone(z3, old) + self._delete_zone(z4, old) - self.assertEqual(z1.id, z2['parent_domain_id']) - self.assertEqual(z2.id, z3['parent_domain_id']) - self.assertEqual(z3.id, z4['parent_domain_id']) - self.assertEqual(z4.id, z5['parent_domain_id']) + self.assertEqual(z1.id, z2['parent_zone_id']) + self.assertEqual(z2.id, z3['parent_zone_id']) + self.assertEqual(z3.id, z4['parent_zone_id']) + self.assertEqual(z4.id, z5['parent_zone_id']) - self._assert_count_all_domains(5) + self._assert_count_all_zones(5) mock_notifier.reset_mock() - zones = self._fetch_all_domains() - self._log_all_domains(zones) - self.central_service.purge_domains( + zones = self._fetch_all_zones() + self._log_all_zones(zones) + self.central_service.purge_zones( self.admin_context, { 'deleted': '!0', @@ -1267,113 +1259,113 @@ class CentralServiceTest(CentralTestCase): }, limit=100, ) - self._assert_count_all_domains(2) - zones = self._fetch_all_domains() - self._log_all_domains(zones) + self._assert_count_all_zones(2) + zones = self._fetch_all_zones() + self._log_all_zones(zones) for z in zones: if z.name == 'alive.org.': - self.assertIsNone(z.parent_domain_id) + self.assertIsNone(z.parent_zone_id) elif z.name == 'alive2.del3.del2.deleted.alive.org.': # alive2.del2.deleted.alive.org is to be reparented under # alive.org - self.assertEqual(z1.id, z.parent_domain_id) + self.assertEqual(z1.id, z.parent_zone_id) else: raise Exception("Unexpected zone %r" % z) - def test_touch_domain(self): - # Create a domain - expected_domain = self.create_domain() + def test_touch_zone(self): + # Create a zone + expected_zone = self.create_zone() - # Touch the domain - self.central_service.touch_domain( - self.admin_context, expected_domain['id']) + # Touch the zone + self.central_service.touch_zone( + self.admin_context, expected_zone['id']) - # Fetch the domain again - domain = self.central_service.get_domain( - self.admin_context, expected_domain['id']) + # Fetch the zone again + zone = self.central_service.get_zone( + self.admin_context, expected_zone['id']) # Ensure the serial was incremented - self.assertTrue(domain['serial'] > expected_domain['serial']) + self.assertTrue(zone['serial'] > expected_zone['serial']) - def test_xfr_domain(self): - # Create a domain - fixture = self.get_domain_fixture('SECONDARY', 0) + def test_xfr_zone(self): + # Create a zone + fixture = self.get_zone_fixture('SECONDARY', 0) fixture['email'] = cfg.CONF['service:central'].managed_resource_email fixture['attributes'] = [{"key": "master", "value": "10.0.0.10"}] # Create a zone - secondary = self.create_domain(**fixture) + secondary = self.create_zone(**fixture) mdns = mock.Mock() with mock.patch.object(mdns_api.MdnsAPI, 'get_instance') as get_mdns: get_mdns.return_value = mdns mdns.get_serial_number.return_value = ('SUCCESS', 10, 1, ) - self.central_service.xfr_domain(self.admin_context, secondary.id) + self.central_service.xfr_zone(self.admin_context, secondary.id) self.assertTrue(mdns.perform_zone_xfr.called) - def test_xfr_domain_same_serial(self): - # Create a domain - fixture = self.get_domain_fixture('SECONDARY', 0) + def test_xfr_zone_same_serial(self): + # Create a zone + fixture = self.get_zone_fixture('SECONDARY', 0) fixture['email'] = cfg.CONF['service:central'].managed_resource_email fixture['attributes'] = [{"key": "master", "value": "10.0.0.10"}] # Create a zone - secondary = self.create_domain(**fixture) + secondary = self.create_zone(**fixture) mdns = mock.Mock() with mock.patch.object(mdns_api.MdnsAPI, 'get_instance') as get_mdns: get_mdns.return_value = mdns mdns.get_serial_number.return_value = ('SUCCESS', 1, 1, ) - self.central_service.xfr_domain(self.admin_context, secondary.id) + self.central_service.xfr_zone(self.admin_context, secondary.id) self.assertFalse(mdns.perform_zone_xfr.called) - def test_xfr_domain_lower_serial(self): - # Create a domain - fixture = self.get_domain_fixture('SECONDARY', 0) + def test_xfr_zone_lower_serial(self): + # Create a zone + fixture = self.get_zone_fixture('SECONDARY', 0) fixture['email'] = cfg.CONF['service:central'].managed_resource_email fixture['attributes'] = [{"key": "master", "value": "10.0.0.10"}] fixture['serial'] = 10 # Create a zone - secondary = self.create_domain(**fixture) + secondary = self.create_zone(**fixture) secondary.serial mdns = mock.Mock() with mock.patch.object(mdns_api.MdnsAPI, 'get_instance') as get_mdns: get_mdns.return_value = mdns mdns.get_serial_number.return_value = ('SUCCESS', 0, 1, ) - self.central_service.xfr_domain(self.admin_context, secondary.id) + self.central_service.xfr_zone(self.admin_context, secondary.id) self.assertFalse(mdns.perform_zone_xfr.called) - def test_xfr_domain_invalid_type(self): - domain = self.create_domain() + def test_xfr_zone_invalid_type(self): + zone = self.create_zone() with testtools.ExpectedException(exceptions.BadRequest): - self.central_service.xfr_domain(self.admin_context, domain.id) + self.central_service.xfr_zone(self.admin_context, zone.id) # RecordSet Tests def test_create_recordset(self): - domain = self.create_domain() - original_serial = domain.serial + zone = self.create_zone() + original_serial = zone.serial # Create the Object - recordset = objects.RecordSet(name='www.%s' % domain.name, type='A') + recordset = objects.RecordSet(name='www.%s' % zone.name, type='A') # Persist the Object recordset = self.central_service.create_recordset( - self.admin_context, domain.id, recordset=recordset) + self.admin_context, zone.id, recordset=recordset) # Get the zone again to check if serial increased - updated_domain = self.central_service.get_domain(self.admin_context, - domain.id) - new_serial = updated_domain.serial + updated_zone = self.central_service.get_zone(self.admin_context, + zone.id) + new_serial = updated_zone.serial # Ensure all values have been set correctly self.assertIsNotNone(recordset.id) - self.assertEqual('www.%s' % domain.name, recordset.name) + self.assertEqual('www.%s' % zone.name, recordset.name) self.assertEqual('A', recordset.type) self.assertIsNotNone(recordset.records) @@ -1382,12 +1374,12 @@ class CentralServiceTest(CentralTestCase): self.assertEqual(original_serial, new_serial) def test_create_recordset_with_records(self): - domain = self.create_domain() - original_serial = domain.serial + zone = self.create_zone() + original_serial = zone.serial # Create the Object recordset = objects.RecordSet( - name='www.%s' % domain.name, + name='www.%s' % zone.name, type='A', records=objects.RecordList(objects=[ objects.Record(data='192.3.3.15'), @@ -1397,11 +1389,11 @@ class CentralServiceTest(CentralTestCase): # Persist the Object recordset = self.central_service.create_recordset( - self.admin_context, domain.id, recordset=recordset) + self.admin_context, zone.id, recordset=recordset) # Get updated serial number - updated_zone = self.central_service.get_domain(self.admin_context, - domain.id) + updated_zone = self.central_service.get_zone(self.admin_context, + zone.id) new_serial = updated_zone.serial # Ensure all values have been set correctly @@ -1413,20 +1405,20 @@ class CentralServiceTest(CentralTestCase): def test_create_recordset_over_quota(self): # SOA, NS recordsets exist by default. - self.config(quota_domain_recordsets=3) + self.config(quota_zone_recordsets=3) - domain = self.create_domain() + zone = self.create_zone() - self.create_recordset(domain) + self.create_recordset(zone) with testtools.ExpectedException(exceptions.OverQuota): - self.create_recordset(domain) + self.create_recordset(zone) def test_create_invalid_recordset_location_cname_at_apex(self): - domain = self.create_domain() + zone = self.create_zone() values = dict( - name=domain['name'], + name=zone['name'], type='CNAME' ) @@ -1434,12 +1426,12 @@ class CentralServiceTest(CentralTestCase): with testtools.ExpectedException(exceptions.InvalidRecordSetLocation): self.central_service.create_recordset( self.admin_context, - domain['id'], + zone['id'], recordset=objects.RecordSet.from_dict(values)) def test_create_invalid_recordset_location_cname_sharing(self): - domain = self.create_domain() - expected = self.create_recordset(domain) + zone = self.create_zone() + expected = self.create_recordset(zone) values = dict( name=expected['name'], @@ -1450,33 +1442,33 @@ class CentralServiceTest(CentralTestCase): with testtools.ExpectedException(exceptions.InvalidRecordSetLocation): self.central_service.create_recordset( self.admin_context, - domain['id'], + zone['id'], recordset=objects.RecordSet.from_dict(values)) - def test_create_invalid_recordset_location_wrong_domain(self): - domain = self.create_domain() - other_domain = self.create_domain(fixture=1) + def test_create_invalid_recordset_location_wrong_zone(self): + zone = self.create_zone() + other_zone = self.create_zone(fixture=1) values = dict( - name=other_domain['name'], + name=other_zone['name'], type='A' ) - # Attempt to create a record in the incorrect domain + # Attempt to create a record in the incorrect zone with testtools.ExpectedException(exceptions.InvalidRecordSetLocation): self.central_service.create_recordset( self.admin_context, - domain['id'], + zone['id'], recordset=objects.RecordSet.from_dict(values)) def test_create_invalid_recordset_ttl(self): self.policy({'use_low_ttl': '!'}) self.config(min_ttl=100, group='service:central') - domain = self.create_domain() + zone = self.create_zone() values = dict( - name='www.%s' % domain['name'], + name='www.%s' % zone['name'], type='A', ttl=10 ) @@ -1485,73 +1477,73 @@ class CentralServiceTest(CentralTestCase): with testtools.ExpectedException(exceptions.InvalidTTL): self.central_service.create_recordset( self.admin_context, - domain['id'], + zone['id'], recordset=objects.RecordSet.from_dict(values)) def test_create_recordset_no_min_ttl(self): self.policy({'use_low_ttl': '!'}) self.config(min_ttl=None, group='service:central') - domain = self.create_domain() + zone = self.create_zone() values = dict( - name='www.%s' % domain['name'], + name='www.%s' % zone['name'], type='A', ttl=10 ) recordset = self.central_service.create_recordset( self.admin_context, - domain['id'], + zone['id'], recordset=objects.RecordSet.from_dict(values)) self.assertEqual(values['ttl'], recordset['ttl']) def test_get_recordset(self): - domain = self.create_domain() + zone = self.create_zone() # Create a recordset - expected = self.create_recordset(domain) + expected = self.create_recordset(zone) # Retrieve it, and ensure it's the same recordset = self.central_service.get_recordset( - self.admin_context, domain['id'], expected['id']) + self.admin_context, zone['id'], expected['id']) self.assertEqual(expected['id'], recordset['id']) self.assertEqual(expected['name'], recordset['name']) self.assertEqual(expected['type'], recordset['type']) def test_get_recordset_with_records(self): - domain = self.create_domain() + zone = self.create_zone() # Create a recordset and two records - recordset = self.create_recordset(domain) - self.create_record(domain, recordset) - self.create_record(domain, recordset, fixture=1) + recordset = self.create_recordset(zone) + self.create_record(zone, recordset) + self.create_record(zone, recordset, fixture=1) # Retrieve it, and ensure it's the same recordset = self.central_service.get_recordset( - self.admin_context, domain.id, recordset.id) + self.admin_context, zone.id, recordset.id) self.assertEqual(2, len(recordset.records)) self.assertIsNotNone(recordset.records[0].id) self.assertIsNotNone(recordset.records[1].id) - def test_get_recordset_incorrect_domain_id(self): - domain = self.create_domain() - other_domain = self.create_domain(fixture=1) + def test_get_recordset_incorrect_zone_id(self): + zone = self.create_zone() + other_zone = self.create_zone(fixture=1) # Create a recordset - expected = self.create_recordset(domain) + expected = self.create_recordset(zone) - # Ensure we get a 404 if we use the incorrect domain_id + # Ensure we get a 404 if we use the incorrect zone_id with testtools.ExpectedException(exceptions.RecordSetNotFound): self.central_service.get_recordset( - self.admin_context, other_domain['id'], expected['id']) + self.admin_context, other_zone['id'], expected['id']) def test_find_recordsets(self): - domain = self.create_domain() + zone = self.create_zone() - criterion = {'domain_id': domain['id']} + criterion = {'zone_id': zone['id']} # Ensure we have two recordsets to start with as SOA & NS # recordsets are created automatically @@ -1561,34 +1553,34 @@ class CentralServiceTest(CentralTestCase): self.assertEqual(2, len(recordsets)) # Create a single recordset (using default values) - self.create_recordset(domain, name='www.%s' % domain['name']) + self.create_recordset(zone, name='www.%s' % zone['name']) # Ensure we can retrieve the newly created recordset recordsets = self.central_service.find_recordsets( self.admin_context, criterion) self.assertEqual(3, len(recordsets)) - self.assertEqual('www.%s' % domain['name'], recordsets[2]['name']) + self.assertEqual('www.%s' % zone['name'], recordsets[2]['name']) # Create a second recordset - self.create_recordset(domain, name='mail.%s' % domain['name']) + self.create_recordset(zone, name='mail.%s' % zone['name']) # Ensure we can retrieve both recordsets recordsets = self.central_service.find_recordsets( self.admin_context, criterion) self.assertEqual(4, len(recordsets)) - self.assertEqual('www.%s' % domain['name'], recordsets[2]['name']) - self.assertEqual('mail.%s' % domain['name'], recordsets[3]['name']) + self.assertEqual('www.%s' % zone['name'], recordsets[2]['name']) + self.assertEqual('mail.%s' % zone['name'], recordsets[3]['name']) def test_find_recordset(self): - domain = self.create_domain() + zone = self.create_zone() # Create a recordset - expected = self.create_recordset(domain) + expected = self.create_recordset(zone) # Retrieve it, and ensure it's the same - criterion = {'domain_id': domain['id'], 'name': expected['name']} + criterion = {'zone_id': zone['id'], 'name': expected['name']} recordset = self.central_service.find_recordset( self.admin_context, criterion) @@ -1597,15 +1589,15 @@ class CentralServiceTest(CentralTestCase): self.assertEqual(expected['name'], recordset['name']) def test_find_recordset_with_records(self): - domain = self.create_domain() + zone = self.create_zone() # Create a recordset - recordset = self.create_recordset(domain) - self.create_record(domain, recordset) - self.create_record(domain, recordset, fixture=1) + recordset = self.create_recordset(zone) + self.create_record(zone, recordset) + self.create_record(zone, recordset, fixture=1) # Retrieve it, and ensure it's the same - criterion = {'domain_id': domain.id, 'name': recordset.name} + criterion = {'zone_id': zone.id, 'name': recordset.name} recordset = self.central_service.find_recordset( self.admin_context, criterion) @@ -1615,12 +1607,12 @@ class CentralServiceTest(CentralTestCase): self.assertIsNotNone(recordset.records[1].id) def test_update_recordset(self): - # Create a domain - domain = self.create_domain() - original_serial = domain.serial + # Create a zone + zone = self.create_zone() + original_serial = zone.serial # Create a recordset - recordset = self.create_recordset(domain) + recordset = self.create_recordset(zone) # Update the recordset recordset.ttl = 1800 @@ -1628,25 +1620,25 @@ class CentralServiceTest(CentralTestCase): # Perform the update self.central_service.update_recordset(self.admin_context, recordset) - # Get domain again to verify that serial number was updated - updated_domain = self.central_service.get_domain(self.admin_context, - domain.id) - new_serial = updated_domain.serial + # Get zone again to verify that serial number was updated + updated_zone = self.central_service.get_zone(self.admin_context, + zone.id) + new_serial = updated_zone.serial # Fetch the resource again recordset = self.central_service.get_recordset( - self.admin_context, recordset.domain_id, recordset.id) + self.admin_context, recordset.zone_id, recordset.id) # Ensure the new value took self.assertEqual(1800, recordset.ttl) self.assertThat(new_serial, GreaterThan(original_serial)) def test_update_recordset_deadlock_retry(self): - # Create a domain - domain = self.create_domain() + # Create a zone + zone = self.create_zone() # Create a recordset - recordset = self.create_recordset(domain) + recordset = self.create_recordset(zone) # Update the recordset recordset.ttl = 1800 @@ -1676,11 +1668,11 @@ class CentralServiceTest(CentralTestCase): self.assertEqual(1800, recordset.ttl) def test_update_recordset_with_record_create(self): - # Create a domain - domain = self.create_domain() + # Create a zone + zone = self.create_zone() # Create a recordset - recordset = self.create_recordset(domain) + recordset = self.create_recordset(zone) # Append two new Records recordset.records.append(objects.Record(data='192.0.2.1')) @@ -1691,7 +1683,7 @@ class CentralServiceTest(CentralTestCase): # Fetch the RecordSet again recordset = self.central_service.get_recordset( - self.admin_context, domain.id, recordset.id) + self.admin_context, zone.id, recordset.id) # Ensure two Records are attached to the RecordSet correctly self.assertEqual(2, len(recordset.records)) @@ -1699,14 +1691,14 @@ class CentralServiceTest(CentralTestCase): self.assertIsNotNone(recordset.records[1].id) def test_update_recordset_with_record_delete(self): - # Create a domain - domain = self.create_domain() - original_serial = domain.serial + # Create a zone + zone = self.create_zone() + original_serial = zone.serial # Create a recordset and two records - recordset = self.create_recordset(domain) - self.create_record(domain, recordset) - self.create_record(domain, recordset, fixture=1) + recordset = self.create_recordset(zone) + self.create_record(zone, recordset) + self.create_record(zone, recordset, fixture=1) # Append two new Records recordset.records.append(objects.Record(data='192.0.2.1')) @@ -1720,12 +1712,12 @@ class CentralServiceTest(CentralTestCase): # Fetch the RecordSet again recordset = self.central_service.get_recordset( - self.admin_context, domain.id, recordset.id) + self.admin_context, zone.id, recordset.id) - # Fetch the Domain again - updated_domain = self.central_service.get_domain(self.admin_context, - domain.id) - new_serial = updated_domain.serial + # Fetch the Zone again + updated_zone = self.central_service.get_zone(self.admin_context, + zone.id) + new_serial = updated_zone.serial # Ensure two Records are attached to the RecordSet correctly self.assertEqual(1, len(recordset.records)) @@ -1733,17 +1725,17 @@ class CentralServiceTest(CentralTestCase): self.assertThat(new_serial, GreaterThan(original_serial)) def test_update_recordset_with_record_update(self): - # Create a domain - domain = self.create_domain() + # Create a zone + zone = self.create_zone() # Create a recordset and two records - recordset = self.create_recordset(domain, 'A') - self.create_record(domain, recordset) - self.create_record(domain, recordset, fixture=1) + recordset = self.create_recordset(zone, 'A') + self.create_record(zone, recordset) + self.create_record(zone, recordset, fixture=1) # Fetch the RecordSet again recordset = self.central_service.get_recordset( - self.admin_context, domain.id, recordset.id) + self.admin_context, zone.id, recordset.id) # Update one of the Records updated_record_id = recordset.records[0].id @@ -1754,7 +1746,7 @@ class CentralServiceTest(CentralTestCase): # Fetch the RecordSet again recordset = self.central_service.get_recordset( - self.admin_context, domain.id, recordset.id) + self.admin_context, zone.id, recordset.id) # Ensure the Record has been updated for record in recordset.records: @@ -1767,14 +1759,14 @@ class CentralServiceTest(CentralTestCase): raise Exception('Updated record not found') def test_update_recordset_without_incrementing_serial(self): - domain = self.create_domain() + zone = self.create_zone() # Create a recordset - recordset = self.create_recordset(domain) + recordset = self.create_recordset(zone) - # Fetch the domain so we have the latest serial number - domain_before = self.central_service.get_domain( - self.admin_context, domain.id) + # Fetch the zone so we have the latest serial number + zone_before = self.central_service.get_zone( + self.admin_context, zone.id) # Update the recordset recordset.ttl = 1800 @@ -1785,134 +1777,134 @@ class CentralServiceTest(CentralTestCase): # Fetch the resource again recordset = self.central_service.get_recordset( - self.admin_context, recordset.domain_id, recordset.id) + self.admin_context, recordset.zone_id, recordset.id) # Ensure the recordset was updated correctly self.assertEqual(1800, recordset.ttl) - # Ensure the domains serial number was not updated - domain_after = self.central_service.get_domain( - self.admin_context, domain.id) + # Ensure the zones serial number was not updated + zone_after = self.central_service.get_zone( + self.admin_context, zone.id) - self.assertEqual(domain_before.serial, domain_after.serial) + self.assertEqual(zone_before.serial, zone_after.serial) - def test_update_recordset_immutable_domain_id(self): - domain = self.create_domain() - other_domain = self.create_domain(fixture=1) + def test_update_recordset_immutable_zone_id(self): + zone = self.create_zone() + other_zone = self.create_zone(fixture=1) # Create a recordset - recordset = self.create_recordset(domain) + recordset = self.create_recordset(zone) # Update the recordset recordset.ttl = 1800 - recordset.domain_id = other_domain.id + recordset.zone_id = other_zone.id - # Ensure we get a BadRequest if we change the domain_id + # Ensure we get a BadRequest if we change the zone_id with testtools.ExpectedException(exceptions.BadRequest): self.central_service.update_recordset( self.admin_context, recordset) def test_update_recordset_immutable_tenant_id(self): - domain = self.create_domain() + zone = self.create_zone() # Create a recordset - recordset = self.create_recordset(domain) + recordset = self.create_recordset(zone) # Update the recordset recordset.ttl = 1800 recordset.tenant_id = 'other-tenant' - # Ensure we get a BadRequest if we change the domain_id + # Ensure we get a BadRequest if we change the zone_id with testtools.ExpectedException(exceptions.BadRequest): self.central_service.update_recordset( self.admin_context, recordset) def test_update_recordset_immutable_type(self): - domain = self.create_domain() + zone = self.create_zone() # Create a recordset - recordset = self.create_recordset(domain) - cname_recordset = self.create_recordset(domain, type='CNAME') + recordset = self.create_recordset(zone) + cname_recordset = self.create_recordset(zone, type='CNAME') # Update the recordset recordset.ttl = 1800 recordset.type = cname_recordset.type - # Ensure we get a BadRequest if we change the domain_id + # Ensure we get a BadRequest if we change the zone_id with testtools.ExpectedException(exceptions.BadRequest): self.central_service.update_recordset( self.admin_context, recordset) def test_delete_recordset(self): - domain = self.create_domain() - original_serial = domain.serial + zone = self.create_zone() + original_serial = zone.serial # Create a recordset - recordset = self.create_recordset(domain) + recordset = self.create_recordset(zone) # Delete the recordset self.central_service.delete_recordset( - self.admin_context, domain['id'], recordset['id']) + self.admin_context, zone['id'], recordset['id']) # Fetch the recordset again, ensuring an exception is raised with testtools.ExpectedException(exceptions.RecordSetNotFound): self.central_service.get_recordset( - self.admin_context, domain['id'], recordset['id']) + self.admin_context, zone['id'], recordset['id']) - # Fetch the domain again to verify serial number increased - updated_domain = self.central_service.get_domain(self.admin_context, - domain.id) - new_serial = updated_domain.serial + # Fetch the zone again to verify serial number increased + updated_zone = self.central_service.get_zone(self.admin_context, + zone.id) + new_serial = updated_zone.serial self.assertThat(new_serial, GreaterThan(original_serial)) def test_delete_recordset_without_incrementing_serial(self): - domain = self.create_domain() + zone = self.create_zone() # Create a recordset - recordset = self.create_recordset(domain) + recordset = self.create_recordset(zone) - # Fetch the domain so we have the latest serial number - domain_before = self.central_service.get_domain( - self.admin_context, domain['id']) + # Fetch the zone so we have the latest serial number + zone_before = self.central_service.get_zone( + self.admin_context, zone['id']) # Delete the recordset self.central_service.delete_recordset( - self.admin_context, domain['id'], recordset['id'], + self.admin_context, zone['id'], recordset['id'], increment_serial=False) # Fetch the record again, ensuring an exception is raised with testtools.ExpectedException(exceptions.RecordSetNotFound): self.central_service.get_recordset( - self.admin_context, domain['id'], recordset['id']) + self.admin_context, zone['id'], recordset['id']) - # Ensure the domains serial number was not updated - domain_after = self.central_service.get_domain( - self.admin_context, domain['id']) + # Ensure the zones serial number was not updated + zone_after = self.central_service.get_zone( + self.admin_context, zone['id']) - self.assertEqual(domain_before['serial'], domain_after['serial']) + self.assertEqual(zone_before['serial'], zone_after['serial']) - def test_delete_recordset_incorrect_domain_id(self): - domain = self.create_domain() - other_domain = self.create_domain(fixture=1) + def test_delete_recordset_incorrect_zone_id(self): + zone = self.create_zone() + other_zone = self.create_zone(fixture=1) # Create a recordset - recordset = self.create_recordset(domain) + recordset = self.create_recordset(zone) - # Ensure we get a 404 if we use the incorrect domain_id + # Ensure we get a 404 if we use the incorrect zone_id with testtools.ExpectedException(exceptions.RecordSetNotFound): self.central_service.delete_recordset( - self.admin_context, other_domain['id'], recordset['id']) + self.admin_context, other_zone['id'], recordset['id']) def test_count_recordsets(self): # in the beginning, there should be nothing recordsets = self.central_service.count_recordsets(self.admin_context) self.assertEqual(0, recordsets) - # Create a domain to put our recordset in - domain = self.create_domain() + # Create a zone to put our recordset in + zone = self.create_zone() # Create a recordset - self.create_recordset(domain) + self.create_recordset(zone) # We should have 1 recordset now, plus SOA & NS recordsets recordsets = self.central_service.count_recordsets(self.admin_context) @@ -1927,8 +1919,8 @@ class CentralServiceTest(CentralTestCase): # Record Tests def test_create_record(self): - domain = self.create_domain() - recordset = self.create_recordset(domain, type='A') + zone = self.create_zone() + recordset = self.create_recordset(zone, type='A') values = dict( data='127.0.0.1' @@ -1936,7 +1928,7 @@ class CentralServiceTest(CentralTestCase): # Create a record record = self.central_service.create_record( - self.admin_context, domain['id'], recordset['id'], + self.admin_context, zone['id'], recordset['id'], objects.Record.from_dict(values)) # Ensure all values have been set correctly @@ -1944,34 +1936,34 @@ class CentralServiceTest(CentralTestCase): self.assertEqual(values['data'], record['data']) self.assertIn('status', record) - def test_create_record_over_domain_quota(self): + def test_create_record_over_zone_quota(self): # SOA and NS Records exist - self.config(quota_domain_records=3) + self.config(quota_zone_records=3) - # Creating the domain automatically creates SOA & NS records - domain = self.create_domain() - recordset = self.create_recordset(domain) + # Creating the zone automatically creates SOA & NS records + zone = self.create_zone() + recordset = self.create_recordset(zone) - self.create_record(domain, recordset) + self.create_record(zone, recordset) with testtools.ExpectedException(exceptions.OverQuota): - self.create_record(domain, recordset) + self.create_record(zone, recordset) def test_create_record_over_recordset_quota(self): self.config(quota_recordset_records=1) - # Creating the domain automatically creates SOA & NS records - domain = self.create_domain() - recordset = self.create_recordset(domain) + # Creating the zone automatically creates SOA & NS records + zone = self.create_zone() + recordset = self.create_recordset(zone) - self.create_record(domain, recordset) + self.create_record(zone, recordset) with testtools.ExpectedException(exceptions.OverQuota): - self.create_record(domain, recordset) + self.create_record(zone, recordset) def test_create_record_without_incrementing_serial(self): - domain = self.create_domain() - recordset = self.create_recordset(domain, type='A') + zone = self.create_zone() + recordset = self.create_recordset(zone, type='A') values = dict( data='127.0.0.1' @@ -1979,65 +1971,65 @@ class CentralServiceTest(CentralTestCase): # Create a record self.central_service.create_record( - self.admin_context, domain['id'], recordset['id'], + self.admin_context, zone['id'], recordset['id'], objects.Record.from_dict(values), increment_serial=False) - # Ensure the domains serial number was not updated - updated_domain = self.central_service.get_domain( - self.admin_context, domain['id']) + # Ensure the zones serial number was not updated + updated_zone = self.central_service.get_zone( + self.admin_context, zone['id']) - self.assertEqual(domain['serial'], updated_domain['serial']) + self.assertEqual(zone['serial'], updated_zone['serial']) def test_get_record(self): - domain = self.create_domain() - recordset = self.create_recordset(domain) + zone = self.create_zone() + recordset = self.create_recordset(zone) # Create a record - expected = self.create_record(domain, recordset) + expected = self.create_record(zone, recordset) # Retrieve it, and ensure it's the same record = self.central_service.get_record( - self.admin_context, domain['id'], recordset['id'], expected['id']) + self.admin_context, zone['id'], recordset['id'], expected['id']) self.assertEqual(expected['id'], record['id']) self.assertEqual(expected['data'], record['data']) self.assertIn('status', record) - def test_get_record_incorrect_domain_id(self): - domain = self.create_domain() - recordset = self.create_recordset(domain) - other_domain = self.create_domain(fixture=1) + def test_get_record_incorrect_zone_id(self): + zone = self.create_zone() + recordset = self.create_recordset(zone) + other_zone = self.create_zone(fixture=1) # Create a record - expected = self.create_record(domain, recordset) + expected = self.create_record(zone, recordset) - # Ensure we get a 404 if we use the incorrect domain_id + # Ensure we get a 404 if we use the incorrect zone_id with testtools.ExpectedException(exceptions.RecordNotFound): self.central_service.get_record( - self.admin_context, other_domain['id'], recordset['id'], + self.admin_context, other_zone['id'], recordset['id'], expected['id']) def test_get_record_incorrect_recordset_id(self): - domain = self.create_domain() - recordset = self.create_recordset(domain) - other_recordset = self.create_recordset(domain, fixture=1) + zone = self.create_zone() + recordset = self.create_recordset(zone) + other_recordset = self.create_recordset(zone, fixture=1) # Create a record - expected = self.create_record(domain, recordset) + expected = self.create_record(zone, recordset) # Ensure we get a 404 if we use the incorrect recordset_id with testtools.ExpectedException(exceptions.RecordNotFound): self.central_service.get_record( - self.admin_context, domain['id'], other_recordset['id'], + self.admin_context, zone['id'], other_recordset['id'], expected['id']) def test_find_records(self): - domain = self.create_domain() - recordset = self.create_recordset(domain) + zone = self.create_zone() + recordset = self.create_recordset(zone) criterion = { - 'domain_id': domain['id'], + 'zone_id': zone['id'], 'recordset_id': recordset['id'] } @@ -2048,7 +2040,7 @@ class CentralServiceTest(CentralTestCase): self.assertEqual(0, len(records)) # Create a single record (using default values) - expected_one = self.create_record(domain, recordset) + expected_one = self.create_record(zone, recordset) # Ensure we can retrieve the newly created record records = self.central_service.find_records( @@ -2058,7 +2050,7 @@ class CentralServiceTest(CentralTestCase): self.assertEqual(expected_one['data'], records[0]['data']) # Create a second record - expected_two = self.create_record(domain, recordset, fixture=1) + expected_two = self.create_record(zone, recordset, fixture=1) # Ensure we can retrieve both records records = self.central_service.find_records( @@ -2069,15 +2061,15 @@ class CentralServiceTest(CentralTestCase): self.assertEqual(expected_two['data'], records[1]['data']) def test_find_record(self): - domain = self.create_domain() - recordset = self.create_recordset(domain) + zone = self.create_zone() + recordset = self.create_recordset(zone) # Create a record - expected = self.create_record(domain, recordset) + expected = self.create_record(zone, recordset) # Retrieve it, and ensure it's the same criterion = { - 'domain_id': domain['id'], + 'zone_id': zone['id'], 'recordset_id': recordset['id'], 'data': expected['data'] } @@ -2090,11 +2082,11 @@ class CentralServiceTest(CentralTestCase): self.assertIn('status', record) def test_update_record(self): - domain = self.create_domain() - recordset = self.create_recordset(domain, 'A') + zone = self.create_zone() + recordset = self.create_recordset(zone, 'A') # Create a record - record = self.create_record(domain, recordset) + record = self.create_record(zone, recordset) # Update the Object record.data = '192.0.2.255' @@ -2104,22 +2096,22 @@ class CentralServiceTest(CentralTestCase): # Fetch the resource again record = self.central_service.get_record( - self.admin_context, record.domain_id, record.recordset_id, + self.admin_context, record.zone_id, record.recordset_id, record.id) # Ensure the new value took self.assertEqual('192.0.2.255', record.data) def test_update_record_without_incrementing_serial(self): - domain = self.create_domain() - recordset = self.create_recordset(domain, 'A') + zone = self.create_zone() + recordset = self.create_recordset(zone, 'A') # Create a record - record = self.create_record(domain, recordset) + record = self.create_record(zone, recordset) - # Fetch the domain so we have the latest serial number - domain_before = self.central_service.get_domain( - self.admin_context, domain.id) + # Fetch the zone so we have the latest serial number + zone_before = self.central_service.get_zone( + self.admin_context, zone.id) # Update the Object record.data = '192.0.2.255' @@ -2130,40 +2122,40 @@ class CentralServiceTest(CentralTestCase): # Fetch the resource again record = self.central_service.get_record( - self.admin_context, record.domain_id, record.recordset_id, + self.admin_context, record.zone_id, record.recordset_id, record.id) # Ensure the new value took self.assertEqual('192.0.2.255', record.data) - # Ensure the domains serial number was not updated - domain_after = self.central_service.get_domain( - self.admin_context, domain.id) + # Ensure the zones serial number was not updated + zone_after = self.central_service.get_zone( + self.admin_context, zone.id) - self.assertEqual(domain_before.serial, domain_after.serial) + self.assertEqual(zone_before.serial, zone_after.serial) - def test_update_record_immutable_domain_id(self): - domain = self.create_domain() - recordset = self.create_recordset(domain) - other_domain = self.create_domain(fixture=1) + def test_update_record_immutable_zone_id(self): + zone = self.create_zone() + recordset = self.create_recordset(zone) + other_zone = self.create_zone(fixture=1) # Create a record - record = self.create_record(domain, recordset) + record = self.create_record(zone, recordset) # Update the record - record.domain_id = other_domain.id + record.zone_id = other_zone.id - # Ensure we get a BadRequest if we change the domain_id + # Ensure we get a BadRequest if we change the zone_id with testtools.ExpectedException(exceptions.BadRequest): self.central_service.update_record(self.admin_context, record) def test_update_record_immutable_recordset_id(self): - domain = self.create_domain() - recordset = self.create_recordset(domain) - other_recordset = self.create_recordset(domain, fixture=1) + zone = self.create_zone() + recordset = self.create_recordset(zone) + other_recordset = self.create_recordset(zone, fixture=1) # Create a record - record = self.create_record(domain, recordset) + record = self.create_record(zone, recordset) # Update the record record.recordset_id = other_recordset.id @@ -2173,102 +2165,102 @@ class CentralServiceTest(CentralTestCase): self.central_service.update_record(self.admin_context, record) def test_delete_record(self): - domain = self.create_domain() - recordset = self.create_recordset(domain) + zone = self.create_zone() + recordset = self.create_recordset(zone) # Create a record - record = self.create_record(domain, recordset) + record = self.create_record(zone, recordset) - # Fetch the domain serial number - domain_serial = self.central_service.get_domain( - self.admin_context, domain['id']).serial + # Fetch the zone serial number + zone_serial = self.central_service.get_zone( + self.admin_context, zone['id']).serial # Delete the record self.central_service.delete_record( - self.admin_context, domain['id'], recordset['id'], record['id']) + self.admin_context, zone['id'], recordset['id'], record['id']) - # Ensure the domain serial number was updated - new_domain_serial = self.central_service.get_domain( - self.admin_context, domain['id']).serial - self.assertNotEqual(new_domain_serial, domain_serial) + # Ensure the zone serial number was updated + new_zone_serial = self.central_service.get_zone( + self.admin_context, zone['id']).serial + self.assertNotEqual(new_zone_serial, zone_serial) # Fetch the record deleted_record = self.central_service.get_record( - self.admin_context, domain['id'], recordset['id'], + self.admin_context, zone['id'], recordset['id'], record['id']) # Ensure the record is marked for deletion self.assertEqual(record.id, deleted_record.id) self.assertEqual(record.data, deleted_record.data) - self.assertEqual(record.domain_id, deleted_record.domain_id) + self.assertEqual(record.zone_id, deleted_record.zone_id) self.assertEqual('PENDING', deleted_record.status) self.assertEqual(record.tenant_id, deleted_record.tenant_id) self.assertEqual(record.recordset_id, deleted_record.recordset_id) self.assertEqual('DELETE', deleted_record.action) - self.assertEqual(new_domain_serial, deleted_record.serial) + self.assertEqual(new_zone_serial, deleted_record.serial) def test_delete_record_without_incrementing_serial(self): - domain = self.create_domain() - recordset = self.create_recordset(domain) + zone = self.create_zone() + recordset = self.create_recordset(zone) # Create a record - record = self.create_record(domain, recordset) + record = self.create_record(zone, recordset) - # Fetch the domain serial number - domain_serial = self.central_service.get_domain( - self.admin_context, domain['id']).serial + # Fetch the zone serial number + zone_serial = self.central_service.get_zone( + self.admin_context, zone['id']).serial # Delete the record self.central_service.delete_record( - self.admin_context, domain['id'], recordset['id'], record['id'], + self.admin_context, zone['id'], recordset['id'], record['id'], increment_serial=False) - # Ensure the domains serial number was not updated - new_domain_serial = self.central_service.get_domain( - self.admin_context, domain['id'])['serial'] - self.assertEqual(domain_serial, new_domain_serial) + # Ensure the zones serial number was not updated + new_zone_serial = self.central_service.get_zone( + self.admin_context, zone['id'])['serial'] + self.assertEqual(zone_serial, new_zone_serial) # Fetch the record deleted_record = self.central_service.get_record( - self.admin_context, domain['id'], recordset['id'], + self.admin_context, zone['id'], recordset['id'], record['id']) # Ensure the record is marked for deletion self.assertEqual(record.id, deleted_record.id) self.assertEqual(record.data, deleted_record.data) - self.assertEqual(record.domain_id, deleted_record.domain_id) + self.assertEqual(record.zone_id, deleted_record.zone_id) self.assertEqual('PENDING', deleted_record.status) self.assertEqual(record.tenant_id, deleted_record.tenant_id) self.assertEqual(record.recordset_id, deleted_record.recordset_id) self.assertEqual('DELETE', deleted_record.action) - self.assertEqual(new_domain_serial, deleted_record.serial) + self.assertEqual(new_zone_serial, deleted_record.serial) - def test_delete_record_incorrect_domain_id(self): - domain = self.create_domain() - recordset = self.create_recordset(domain) - other_domain = self.create_domain(fixture=1) + def test_delete_record_incorrect_zone_id(self): + zone = self.create_zone() + recordset = self.create_recordset(zone) + other_zone = self.create_zone(fixture=1) # Create a record - record = self.create_record(domain, recordset) + record = self.create_record(zone, recordset) - # Ensure we get a 404 if we use the incorrect domain_id + # Ensure we get a 404 if we use the incorrect zone_id with testtools.ExpectedException(exceptions.RecordNotFound): self.central_service.delete_record( - self.admin_context, other_domain['id'], recordset['id'], + self.admin_context, other_zone['id'], recordset['id'], record['id']) def test_delete_record_incorrect_recordset_id(self): - domain = self.create_domain() - recordset = self.create_recordset(domain) - other_recordset = self.create_recordset(domain, fixture=1) + zone = self.create_zone() + recordset = self.create_recordset(zone) + other_recordset = self.create_recordset(zone, fixture=1) # Create a record - record = self.create_record(domain, recordset) + record = self.create_record(zone, recordset) # Ensure we get a 404 if we use the incorrect recordset_id with testtools.ExpectedException(exceptions.RecordNotFound): self.central_service.delete_record( - self.admin_context, domain['id'], other_recordset['id'], + self.admin_context, zone['id'], other_recordset['id'], record['id']) def test_count_records(self): @@ -2276,12 +2268,12 @@ class CentralServiceTest(CentralTestCase): records = self.central_service.count_records(self.admin_context) self.assertEqual(0, records) - # Create a domain and recordset to put our record in - domain = self.create_domain() - recordset = self.create_recordset(domain) + # Create a zone and recordset to put our record in + zone = self.create_zone() + recordset = self.create_recordset(zone) # Create a record - self.create_record(domain, recordset) + self.create_record(zone, recordset) # we should have 1 record now, plus SOA & NS records records = self.central_service.count_records(self.admin_context) @@ -2351,14 +2343,14 @@ class CentralServiceTest(CentralTestCase): criterion = { 'managed_resource_id': fip['id'], 'managed_tenant_id': context_a.tenant} - domain_id = self.central_service.find_record( - elevated_a, criterion).domain_id + zone_id = self.central_service.find_record( + elevated_a, criterion).zone_id # Simulate the update on the backend - domain_serial = self.central_service.get_domain( - elevated_a, domain_id).serial + zone_serial = self.central_service.get_zone( + elevated_a, zone_id).serial self.central_service.update_status( - elevated_a, domain_id, "SUCCESS", domain_serial) + elevated_a, zone_id, "SUCCESS", zone_serial) self.network_api.fake.deallocate_floatingip(fip['id']) @@ -2379,10 +2371,10 @@ class CentralServiceTest(CentralTestCase): self.assertIsNone(fip_ptr['ptrdname']) # Simulate the invalidation on the backend - domain_serial = self.central_service.get_domain( - elevated_a, domain_id).serial + zone_serial = self.central_service.get_zone( + elevated_a, zone_id).serial self.central_service.update_status( - elevated_a, domain_id, "SUCCESS", domain_serial) + elevated_a, zone_id, "SUCCESS", zone_serial) # Ensure that the old record for tenant a for the fip now owned by # tenant b is gone @@ -2447,14 +2439,14 @@ class CentralServiceTest(CentralTestCase): criterion = { 'managed_resource_id': fip['id'], 'managed_tenant_id': context_a.tenant} - domain_id = self.central_service.find_record( - elevated_a, criterion).domain_id + zone_id = self.central_service.find_record( + elevated_a, criterion).zone_id # Simulate the update on the backend - domain_serial = self.central_service.get_domain( - elevated_a, domain_id).serial + zone_serial = self.central_service.get_zone( + elevated_a, zone_id).serial self.central_service.update_status( - elevated_a, domain_id, "SUCCESS", domain_serial) + elevated_a, zone_id, "SUCCESS", zone_serial) self.network_api.fake.deallocate_floatingip(fip['id']) @@ -2474,10 +2466,10 @@ class CentralServiceTest(CentralTestCase): self.assertIsNone(fips[0]['ptrdname']) # Simulate the invalidation on the backend - domain_serial = self.central_service.get_domain( - elevated_a, domain_id).serial + zone_serial = self.central_service.get_zone( + elevated_a, zone_id).serial self.central_service.update_status( - elevated_a, domain_id, "SUCCESS", domain_serial) + elevated_a, zone_id, "SUCCESS", zone_serial) # Ensure that the old record for tenant a for the fip now owned by # tenant b is gone @@ -2514,11 +2506,11 @@ class CentralServiceTest(CentralTestCase): elevated_context = context.elevated() elevated_context.all_tenants = True - # The domain created should have the default 0's uuid as owner - domain = self.central_service.find_domain( + # The zone created should have the default 0's uuid as owner + zone = self.central_service.find_zone( elevated_context, {"tenant_id": tenant_id}) - self.assertEqual(tenant_id, domain.tenant_id) + self.assertEqual(tenant_id, zone.tenant_id) def test_set_floatingip_removes_old_record(self): context_a = self.get_context(tenant='a') @@ -2539,18 +2531,18 @@ class CentralServiceTest(CentralTestCase): criterion = { 'managed_resource_id': fip['id'], 'managed_tenant_id': context_a.tenant} - domain_id = self.central_service.find_record( - elevated_a, criterion).domain_id + zone_id = self.central_service.find_record( + elevated_a, criterion).zone_id fixture2 = self.get_ptr_fixture(fixture=1) self.central_service.update_floatingip( context_a, fip['region'], fip['id'], fixture2) # Simulate the update on the backend - domain_serial = self.central_service.get_domain( - elevated_a, domain_id).serial + zone_serial = self.central_service.get_zone( + elevated_a, zone_id).serial self.central_service.update_status( - elevated_a, domain_id, "SUCCESS", domain_serial) + elevated_a, zone_id, "SUCCESS", zone_serial) count = self.central_service.count_records( elevated_a, {'managed_resource_id': fip['id']}) @@ -2568,10 +2560,10 @@ class CentralServiceTest(CentralTestCase): context_b, fip['region'], fip['id'], fixture) # Simulate the update on the backend - domain_serial = self.central_service.get_domain( - elevated_a, domain_id).serial + zone_serial = self.central_service.get_zone( + elevated_a, zone_id).serial self.central_service.update_status( - elevated_a, domain_id, "SUCCESS", domain_serial) + elevated_a, zone_id, "SUCCESS", zone_serial) count = self.central_service.count_records( elevated_a, {'managed_resource_id': fip['id']}) @@ -2713,10 +2705,10 @@ class CentralServiceTest(CentralTestCase): # A SOA record should automatically be created each time # a zone is created # Create a zone - zone = self.create_domain(name='example3.org.') + zone = self.create_zone(name='example3.org.') # Retrieve SOA - criterion = {'domain_id': zone['id'], 'type': 'SOA'} + criterion = {'zone_id': zone['id'], 'type': 'SOA'} soa = self.central_service.find_recordset(self.admin_context, criterion) @@ -2741,20 +2733,20 @@ class CentralServiceTest(CentralTestCase): def test_update_soa(self): # Anytime the zone's serial number is incremented # the SOA recordset should automatically be updated - zone = self.create_domain(email='info@example.org') + zone = self.create_zone(email='info@example.org') # Update the object zone.email = 'info@example.net' # Perform the update - self.central_service.update_domain(self.admin_context, zone) + self.central_service.update_zone(self.admin_context, zone) - # Fetch the domain again - updated_zone = self.central_service.get_domain(self.admin_context, - zone.id) + # Fetch the zone again + updated_zone = self.central_service.get_zone(self.admin_context, + zone.id) # Retrieve SOA - criterion = {'domain_id': zone['id'], 'type': 'SOA'} + criterion = {'zone_id': zone['id'], 'type': 'SOA'} soa = self.central_service.find_recordset(self.admin_context, criterion) @@ -2889,9 +2881,9 @@ class CentralServiceTest(CentralTestCase): self.assertEqual("New Comment", pool.description) def test_update_pool_add_ns_record(self): - # Create a server pool and domain + # Create a server pool and zone pool = self.create_pool(fixture=0) - domain = self.create_domain(pool_id=pool.id) + zone = self.create_zone(pool_id=pool.id) ns_record_count = len(pool.ns_records) new_ns_record = objects.PoolNsRecord( @@ -2910,19 +2902,19 @@ class CentralServiceTest(CentralTestCase): self.assertIn(new_ns_record.hostname, [n.hostname for n in pool.ns_records]) - # Fetch the domains NS recordset + # Fetch the zones NS recordset ns_recordset = self.central_service.find_recordset( self.admin_context, - criterion={'domain_id': domain.id, 'type': "NS"}) + criterion={'zone_id': zone.id, 'type': "NS"}) # Verify that the doamins NS records ware updated correctly self.assertEqual(set([n.hostname for n in pool.ns_records]), set([n.data for n in ns_recordset.records])) def test_update_pool_remove_ns_record(self): - # Create a server pool and domain + # Create a server pool and zone pool = self.create_pool(fixture=0) - domain = self.create_domain(pool_id=pool.id) + zone = self.create_zone(pool_id=pool.id) ns_record_count = len(pool.ns_records) @@ -2938,10 +2930,10 @@ class CentralServiceTest(CentralTestCase): self.assertNotIn(removed_ns_record.hostname, [n.hostname for n in pool.ns_records]) - # Fetch the domains NS recordset + # Fetch the zones NS recordset ns_recordset = self.central_service.find_recordset( self.admin_context, - criterion={'domain_id': domain.id, 'type': "NS"}) + criterion={'zone_id': zone.id, 'type': "NS"}) # Verify that the doamins NS records ware updated correctly self.assertEqual(set([n.hostname for n in pool.ns_records]), @@ -2958,130 +2950,130 @@ class CentralServiceTest(CentralTestCase): with testtools.ExpectedException(exceptions.PoolNotFound): self.central_service.get_pool(self.admin_context, pool['id']) - def test_update_status_delete_domain(self): - # Create a domain - domain = self.create_domain() + def test_update_status_delete_zone(self): + # Create a zone + zone = self.create_zone() - # Delete the domain - self.central_service.delete_domain(self.admin_context, domain['id']) + # Delete the zone + self.central_service.delete_zone(self.admin_context, zone['id']) - # Simulate the domain having been deleted on the backend - domain_serial = self.central_service.get_domain( - self.admin_context, domain['id']).serial + # Simulate the zone having been deleted on the backend + zone_serial = self.central_service.get_zone( + self.admin_context, zone['id']).serial self.central_service.update_status( - self.admin_context, domain['id'], "SUCCESS", domain_serial) + self.admin_context, zone['id'], "SUCCESS", zone_serial) - # Fetch the domain again, ensuring an exception is raised - with testtools.ExpectedException(exceptions.DomainNotFound): - self.central_service.get_domain(self.admin_context, domain['id']) + # Fetch the zone again, ensuring an exception is raised + with testtools.ExpectedException(exceptions.ZoneNotFound): + self.central_service.get_zone(self.admin_context, zone['id']) def test_update_status_delete_last_record(self): - domain = self.create_domain() - recordset = self.create_recordset(domain) + zone = self.create_zone() + recordset = self.create_recordset(zone) # Create a record - record = self.create_record(domain, recordset) + record = self.create_record(zone, recordset) # Delete the record self.central_service.delete_record( - self.admin_context, domain['id'], recordset['id'], record['id']) + self.admin_context, zone['id'], recordset['id'], record['id']) # Simulate the record having been deleted on the backend - domain_serial = self.central_service.get_domain( - self.admin_context, domain['id']).serial + zone_serial = self.central_service.get_zone( + self.admin_context, zone['id']).serial self.central_service.update_status( - self.admin_context, domain['id'], "SUCCESS", domain_serial) + self.admin_context, zone['id'], "SUCCESS", zone_serial) # Fetch the record again, ensuring an exception is raised with testtools.ExpectedException(exceptions.RecordSetNotFound): self.central_service.get_record( - self.admin_context, domain['id'], recordset['id'], + self.admin_context, zone['id'], recordset['id'], record['id']) def test_update_status_delete_last_record_without_incrementing_serial( self): - domain = self.create_domain() - recordset = self.create_recordset(domain) + zone = self.create_zone() + recordset = self.create_recordset(zone) # Create a record - record = self.create_record(domain, recordset) + record = self.create_record(zone, recordset) - # Fetch the domain serial number - domain_serial = self.central_service.get_domain( - self.admin_context, domain['id']).serial + # Fetch the zone serial number + zone_serial = self.central_service.get_zone( + self.admin_context, zone['id']).serial # Delete the record self.central_service.delete_record( - self.admin_context, domain['id'], recordset['id'], record['id'], + self.admin_context, zone['id'], recordset['id'], record['id'], increment_serial=False) # Simulate the record having been deleted on the backend - domain_serial = self.central_service.get_domain( - self.admin_context, domain['id']).serial + zone_serial = self.central_service.get_zone( + self.admin_context, zone['id']).serial self.central_service.update_status( - self.admin_context, domain['id'], "SUCCESS", domain_serial) + self.admin_context, zone['id'], "SUCCESS", zone_serial) # Fetch the record again, ensuring an exception is raised with testtools.ExpectedException(exceptions.RecordSetNotFound): self.central_service.get_record( - self.admin_context, domain['id'], recordset['id'], + self.admin_context, zone['id'], recordset['id'], record['id']) - # Ensure the domains serial number was not updated - new_domain_serial = self.central_service.get_domain( - self.admin_context, domain['id']).serial + # Ensure the zones serial number was not updated + new_zone_serial = self.central_service.get_zone( + self.admin_context, zone['id']).serial - self.assertEqual(domain_serial, new_domain_serial) + self.assertEqual(zone_serial, new_zone_serial) def test_create_zone_transfer_request(self): - domain = self.create_domain() - zone_transfer_request = self.create_zone_transfer_request(domain) + zone = self.create_zone() + zone_transfer_request = self.create_zone_transfer_request(zone) # Verify all values have been set correctly self.assertIsNotNone(zone_transfer_request.id) self.assertIsNotNone(zone_transfer_request.tenant_id) self.assertIsNotNone(zone_transfer_request.key) - self.assertEqual(domain.id, zone_transfer_request.domain_id) + self.assertEqual(zone.id, zone_transfer_request.zone_id) def test_create_zone_transfer_request_duplicate(self): - domain = self.create_domain() - self.create_zone_transfer_request(domain) + zone = self.create_zone() + self.create_zone_transfer_request(zone) with testtools.ExpectedException( exceptions.DuplicateZoneTransferRequest): - self.create_zone_transfer_request(domain) + self.create_zone_transfer_request(zone) def test_create_scoped_zone_transfer_request(self): - domain = self.create_domain() + zone = self.create_zone() values = self.get_zone_transfer_request_fixture(fixture=1) - zone_transfer_request = self.create_zone_transfer_request(domain, + zone_transfer_request = self.create_zone_transfer_request(zone, fixture=1) # Verify all values have been set correctly self.assertIsNotNone(zone_transfer_request.id) self.assertIsNotNone(zone_transfer_request.tenant_id) - self.assertEqual(domain.id, zone_transfer_request.domain_id) + self.assertEqual(zone.id, zone_transfer_request.zone_id) self.assertIsNotNone(zone_transfer_request.key) self.assertEqual( values['target_tenant_id'], zone_transfer_request.target_tenant_id) def test_get_zone_transfer_request(self): - domain = self.create_domain() - zt_request = self.create_zone_transfer_request(domain, + zone = self.create_zone() + zt_request = self.create_zone_transfer_request(zone, fixture=1) retrived_zt = self.central_service.get_zone_transfer_request( self.admin_context, zt_request.id) - self.assertEqual(zt_request.domain_id, retrived_zt.domain_id) + self.assertEqual(zt_request.zone_id, retrived_zt.zone_id) self.assertEqual(zt_request.key, retrived_zt.key) def test_get_zone_transfer_request_scoped(self): tenant_1_context = self.get_context(tenant=1) tenant_2_context = self.get_context(tenant=2) tenant_3_context = self.get_context(tenant=3) - domain = self.create_domain(context=tenant_1_context) + zone = self.create_zone(context=tenant_1_context) zt_request = self.create_zone_transfer_request( - domain, + zone, context=tenant_1_context, target_tenant_id=2) @@ -3096,8 +3088,8 @@ class CentralServiceTest(CentralTestCase): tenant_3_context, zt_request.id) def test_update_zone_transfer_request(self): - domain = self.create_domain() - zone_transfer_request = self.create_zone_transfer_request(domain) + zone = self.create_zone() + zone_transfer_request = self.create_zone_transfer_request(zone) zone_transfer_request.description = 'TEST' self.central_service.update_zone_transfer_request( @@ -3110,8 +3102,8 @@ class CentralServiceTest(CentralTestCase): self.assertEqual('TEST', zone_transfer_request.description) def test_delete_zone_transfer_request(self): - domain = self.create_domain() - zone_transfer_request = self.create_zone_transfer_request(domain) + zone = self.create_zone() + zone_transfer_request = self.create_zone_transfer_request(zone) self.central_service.delete_zone_transfer_request( self.admin_context, zone_transfer_request.id) @@ -3128,34 +3120,34 @@ class CentralServiceTest(CentralTestCase): admin_context = self.get_admin_context() admin_context.all_tenants = True - domain = self.create_domain(context=tenant_1_context) - recordset = self.create_recordset(domain, context=tenant_1_context) + zone = self.create_zone(context=tenant_1_context) + recordset = self.create_recordset(zone, context=tenant_1_context) record = self.create_record( - domain, recordset, context=tenant_1_context) + zone, recordset, context=tenant_1_context) zone_transfer_request = self.create_zone_transfer_request( - domain, context=tenant_1_context) + zone, context=tenant_1_context) zone_transfer_accept = objects.ZoneTransferAccept() zone_transfer_accept.zone_transfer_request_id =\ zone_transfer_request.id zone_transfer_accept.key = zone_transfer_request.key - zone_transfer_accept.domain_id = domain.id + zone_transfer_accept.zone_id = zone.id zone_transfer_accept = \ self.central_service.create_zone_transfer_accept( tenant_2_context, zone_transfer_accept) result = {} - result['domain'] = self.central_service.get_domain( - admin_context, domain.id) + result['zone'] = self.central_service.get_zone( + admin_context, zone.id) result['recordset'] = self.central_service.get_recordset( - admin_context, domain.id, recordset.id) + admin_context, zone.id, recordset.id) result['record'] = self.central_service.get_record( - admin_context, domain.id, recordset.id, record.id) + admin_context, zone.id, recordset.id, record.id) result['zt_accept'] = self.central_service.get_zone_transfer_accept( admin_context, zone_transfer_accept.id) @@ -3163,7 +3155,7 @@ class CentralServiceTest(CentralTestCase): admin_context, zone_transfer_request.id) self.assertEqual( - str(tenant_2_context.tenant), result['domain'].tenant_id) + str(tenant_2_context.tenant), result['zone'].tenant_id) self.assertEqual( str(tenant_2_context.tenant), result['recordset'].tenant_id) self.assertEqual( @@ -3179,13 +3171,13 @@ class CentralServiceTest(CentralTestCase): admin_context = self.get_admin_context() admin_context.all_tenants = True - domain = self.create_domain(context=tenant_1_context) - recordset = self.create_recordset(domain, context=tenant_1_context) + zone = self.create_zone(context=tenant_1_context) + recordset = self.create_recordset(zone, context=tenant_1_context) record = self.create_record( - domain, recordset, context=tenant_1_context) + zone, recordset, context=tenant_1_context) zone_transfer_request = self.create_zone_transfer_request( - domain, + zone, context=tenant_1_context, target_tenant_id='2') @@ -3194,21 +3186,21 @@ class CentralServiceTest(CentralTestCase): zone_transfer_request.id zone_transfer_accept.key = zone_transfer_request.key - zone_transfer_accept.domain_id = domain.id + zone_transfer_accept.zone_id = zone.id zone_transfer_accept = \ self.central_service.create_zone_transfer_accept( tenant_2_context, zone_transfer_accept) result = {} - result['domain'] = self.central_service.get_domain( - admin_context, domain.id) + result['zone'] = self.central_service.get_zone( + admin_context, zone.id) result['recordset'] = self.central_service.get_recordset( - admin_context, domain.id, recordset.id) + admin_context, zone.id, recordset.id) result['record'] = self.central_service.get_record( - admin_context, domain.id, recordset.id, record.id) + admin_context, zone.id, recordset.id, record.id) result['zt_accept'] = self.central_service.get_zone_transfer_accept( admin_context, zone_transfer_accept.id) @@ -3216,7 +3208,7 @@ class CentralServiceTest(CentralTestCase): admin_context, zone_transfer_request.id) self.assertEqual( - str(tenant_2_context.tenant), result['domain'].tenant_id) + str(tenant_2_context.tenant), result['zone'].tenant_id) self.assertEqual( str(tenant_2_context.tenant), result['recordset'].tenant_id) self.assertEqual( @@ -3232,10 +3224,10 @@ class CentralServiceTest(CentralTestCase): admin_context = self.get_admin_context() admin_context.all_tenants = True - domain = self.create_domain(context=tenant_1_context) + zone = self.create_zone(context=tenant_1_context) zone_transfer_request = self.create_zone_transfer_request( - domain, + zone, context=tenant_1_context, target_tenant_id=2) @@ -3244,7 +3236,7 @@ class CentralServiceTest(CentralTestCase): zone_transfer_request.id zone_transfer_accept.key = 'WRONG KEY' - zone_transfer_accept.domain_id = domain.id + zone_transfer_accept.zone_id = zone.id with testtools.ExpectedException(exceptions.IncorrectZoneTransferKey): zone_transfer_accept = \ @@ -3257,10 +3249,10 @@ class CentralServiceTest(CentralTestCase): admin_context = self.get_admin_context() admin_context.all_tenants = True - domain = self.create_domain(context=tenant_1_context) + zone = self.create_zone(context=tenant_1_context) zone_transfer_request = self.create_zone_transfer_request( - domain, + zone, context=tenant_1_context, target_tenant_id=2) @@ -3269,7 +3261,7 @@ class CentralServiceTest(CentralTestCase): zone_transfer_request.id zone_transfer_accept.key = zone_transfer_request.key - zone_transfer_accept.domain_id = domain.id + zone_transfer_accept.zone_id = zone.id with testtools.ExpectedException(exceptions.Forbidden): zone_transfer_accept = \ @@ -3288,7 +3280,7 @@ class CentralServiceTest(CentralTestCase): self.assertIsNotNone(zone_import['id']) self.assertEqual('PENDING', zone_import.status) self.assertIsNone(zone_import.message) - self.assertIsNone(zone_import.domain_id) + self.assertIsNone(zone_import.zone_id) self.wait_for_import(zone_import.id) diff --git a/designate/tests/test_mdns/test_handler.py b/designate/tests/test_mdns/test_handler.py index 860d0512..a64a8675 100644 --- a/designate/tests/test_mdns/test_handler.py +++ b/designate/tests/test_mdns/test_handler.py @@ -121,17 +121,17 @@ class MdnsRequestHandlerTest(MdnsTestCase): self.assertEqual(expected_response, binascii.b2a_hex(response)) - def _get_secondary_domain(self, values=None, attributes=None, - masters=None): + def _get_secondary_zone(self, values=None, attributes=None, + masters=None): attributes = attributes or [] masters = masters or [{"host": "10.0.0.1", "port": 53}] - fixture = self.get_domain_fixture("SECONDARY", values=values) + fixture = self.get_zone_fixture("SECONDARY", values=values) fixture['email'] = cfg.CONF['service:central'].managed_resource_email - domain = objects.Domain(**fixture) - domain.attributes = objects.DomainAttributeList().from_list(attributes) - domain.masters = objects.DomainMasterList().from_list(masters) - return domain + zone = objects.Zone(**fixture) + zone.attributes = objects.ZoneAttributeList().from_list(attributes) + zone.masters = objects.ZoneMasterList().from_list(masters) + return zone def _get_soa_answer(self, serial): text = "\n".join(ANSWER) % {"serial": str(serial)} @@ -147,7 +147,7 @@ class MdnsRequestHandlerTest(MdnsTestCase): payload = "c38021000001000000000000076578616d706c6503636f6d0000060001" master = "10.0.0.1" - domain = self._get_secondary_domain({"serial": 123}) + zone = self._get_secondary_zone({"serial": 123}) # expected response is an error code NOERROR. The other fields are # id 50048 @@ -162,7 +162,7 @@ class MdnsRequestHandlerTest(MdnsTestCase): expected_response = (b"c380a5000001000000000000076578616d706c6503636f" b"6d0000060001") - # The SOA serial should be different from the one in thedomain and + # The SOA serial should be different from the one in thezone and # will trigger a AXFR func.return_value = self._get_soa_answer(123123) @@ -172,13 +172,13 @@ class MdnsRequestHandlerTest(MdnsTestCase): 'context': self.context } - with mock.patch.object(self.handler.storage, 'find_domain', - return_value=domain): + with mock.patch.object(self.handler.storage, 'find_zone', + return_value=zone): response = next(self.handler(request)).to_wire() self.mock_tg.add_thread.assert_called_with( - self.handler.domain_sync, self.context, domain, - [domain.masters[0]]) + self.handler.zone_sync, self.context, zone, + [zone.masters[0]]) self.assertEqual(expected_response, binascii.b2a_hex(response)) @mock.patch.object(dns.resolver.Resolver, 'query') @@ -187,7 +187,7 @@ class MdnsRequestHandlerTest(MdnsTestCase): payload = "c38021000001000000000000076578616d706c6503636f6d0000060001" master = "10.0.0.1" - domain = self._get_secondary_domain({"serial": 123}) + zone = self._get_secondary_zone({"serial": 123}) # expected response is an error code NOERROR. The other fields are # id 50048 @@ -202,9 +202,9 @@ class MdnsRequestHandlerTest(MdnsTestCase): expected_response = (b"c380a5000001000000000000076578616d706c6503636f" b"6d0000060001") - # The SOA serial should be different from the one in thedomain and + # The SOA serial should be different from the one in thezone and # will trigger a AXFR - func.return_value = self._get_soa_answer(domain.serial) + func.return_value = self._get_soa_answer(zone.serial) request = dns.message.from_wire(binascii.a2b_hex(payload)) request.environ = { @@ -212,8 +212,8 @@ class MdnsRequestHandlerTest(MdnsTestCase): 'context': self.context } - with mock.patch.object(self.handler.storage, 'find_domain', - return_value=domain): + with mock.patch.object(self.handler.storage, 'find_zone', + return_value=zone): response = next(self.handler(request)).to_wire() assert not self.mock_tg.add_thread.called @@ -223,11 +223,11 @@ class MdnsRequestHandlerTest(MdnsTestCase): # DNS packet with NOTIFY opcode payload = "c38021000001000000000000076578616d706c6503636f6d0000060001" - # Have a domain with different master then the one where the notify + # Have a zone with different master then the one where the notify # comes from causing it to be "ignored" as in not transferred and # logged - domain = self._get_secondary_domain({"serial": 123}) + zone = self._get_secondary_zone({"serial": 123}) # expected response is an error code REFUSED. The other fields are # id 50048 @@ -248,8 +248,8 @@ class MdnsRequestHandlerTest(MdnsTestCase): 'context': self.context } - with mock.patch.object(self.handler.storage, 'find_domain', - return_value=domain): + with mock.patch.object(self.handler.storage, 'find_zone', + return_value=zone): response = next(self.handler(request)).to_wire() assert not self.mock_tg.add_thread.called @@ -281,7 +281,7 @@ class MdnsRequestHandlerTest(MdnsTestCase): assert not self.mock_tg.add_thread.called self.assertEqual(expected_response, binascii.b2a_hex(response)) - def test_dispatch_opcode_notify_invalid_domain(self): + def test_dispatch_opcode_notify_invalid_zone(self): # DNS packet with NOTIFY opcode payload = "c38021000001000000000000076578616d706c6503636f6d0000060001" @@ -354,7 +354,7 @@ class MdnsRequestHandlerTest(MdnsTestCase): # # strip the id from the response and compare # self.assertEqual(expected_response, binascii.b2a_hex(response)[5:]) - def test_dispatch_opcode_query_non_existent_domain(self): + def test_dispatch_opcode_query_non_existent_zone(self): # DNS packet with QUERY opcode # query is for example.com. IN A payload = ("271501200001000000000001076578616d706c6503636f6d0000010001" @@ -401,9 +401,9 @@ class MdnsRequestHandlerTest(MdnsTestCase): b"c0000201") # This creates an A record for mail.example.com - domain = self.create_domain() - recordset = self.create_recordset(domain, 'A') - self.create_record(domain, recordset) + zone = self.create_zone() + recordset = self.create_recordset(zone, 'A') + self.create_record(zone, recordset) request = dns.message.from_wire(binascii.a2b_hex(payload)) request.environ = {'addr': self.addr, 'context': self.context} @@ -432,9 +432,9 @@ class MdnsRequestHandlerTest(MdnsTestCase): b"0005046d61696c076578616d706c65036f726700") # This creates an MX record for mail.example.com - domain = self.create_domain() - recordset = self.create_recordset(domain, 'MX') - self.create_record(domain, recordset) + zone = self.create_zone() + recordset = self.create_recordset(zone, 'MX') + self.create_record(zone, recordset) request = dns.message.from_wire(binascii.a2b_hex(payload)) request.environ = {'addr': self.addr, 'context': self.context} @@ -479,7 +479,7 @@ class MdnsRequestHandlerTest(MdnsTestCase): b"c0006000100000e100018c029c03a551c063900000e10000002580001518000" b"000e10") - domain = objects.Domain.from_dict({ + zone = objects.Zone.from_dict({ 'name': 'example.com.', 'ttl': 3600, 'serial': 1427899961, @@ -500,8 +500,8 @@ class MdnsRequestHandlerTest(MdnsTestCase): 'ACTION'], ] - with mock.patch.object(self.storage, 'find_domain', - return_value=domain): + with mock.patch.object(self.storage, 'find_zone', + return_value=zone): with mock.patch.object(self.storage, 'find_recordsets_axfr', side_effect=_find_recordsets_axfr): request = dns.message.from_wire(binascii.a2b_hex(payload)) @@ -541,7 +541,7 @@ class MdnsRequestHandlerTest(MdnsTestCase): # Set the max-message-size to 128 self.config(max_message_size=128, group='service:mdns') - domain = objects.Domain.from_dict({ + zone = objects.Zone.from_dict({ 'name': 'example.com.', 'ttl': 3600, 'serial': 1427899961, @@ -562,8 +562,8 @@ class MdnsRequestHandlerTest(MdnsTestCase): 'ACTION'], ] - with mock.patch.object(self.storage, 'find_domain', - return_value=domain): + with mock.patch.object(self.storage, 'find_zone', + return_value=zone): with mock.patch.object(self.storage, 'find_recordsets_axfr', side_effect=_find_recordsets_axfr): request = dns.message.from_wire(binascii.a2b_hex(payload)) @@ -619,7 +619,7 @@ class MdnsRequestHandlerTest(MdnsTestCase): # Set the max-message-size to 128 self.config(max_message_size=128, group='service:mdns') - domain = objects.Domain.from_dict({ + zone = objects.Zone.from_dict({ 'name': 'example.com.', 'ttl': 3600, 'serial': 1427899961, @@ -640,8 +640,8 @@ class MdnsRequestHandlerTest(MdnsTestCase): 'ACTION'], ] - with mock.patch.object(self.storage, 'find_domain', - return_value=domain): + with mock.patch.object(self.storage, 'find_zone', + return_value=zone): with mock.patch.object(self.storage, 'find_recordsets_axfr', side_effect=_find_recordsets_axfr): request = dns.message.from_wire(binascii.a2b_hex(payload)) @@ -697,7 +697,7 @@ class MdnsRequestHandlerTest(MdnsTestCase): # Set the max-message-size to 128 self.config(max_message_size=128, group='service:mdns') - domain = objects.Domain.from_dict({ + zone = objects.Zone.from_dict({ 'name': 'example.com.', 'ttl': 3600, 'serial': 1427899961, @@ -716,8 +716,8 @@ class MdnsRequestHandlerTest(MdnsTestCase): 'a' * 63 + '.' + 'a' * 63 + '.', 'ACTION'], ] - with mock.patch.object(self.storage, 'find_domain', - return_value=domain): + with mock.patch.object(self.storage, 'find_zone', + return_value=zone): with mock.patch.object(self.storage, 'find_recordsets_axfr', side_effect=_find_recordsets_axfr): request = dns.message.from_wire(binascii.a2b_hex(payload)) @@ -759,9 +759,9 @@ class MdnsRequestHandlerTest(MdnsTestCase): # This creates an MX record for mail.example.com # But we query for a CNAME record - domain = self.create_domain() - recordset = self.create_recordset(domain, 'MX') - self.create_record(domain, recordset) + zone = self.create_zone() + recordset = self.create_recordset(zone, 'MX') + self.create_record(zone, recordset) request = dns.message.from_wire(binascii.a2b_hex(payload)) request.environ = {'addr': self.addr, 'context': self.context} @@ -793,12 +793,12 @@ class MdnsRequestHandlerTest(MdnsTestCase): self.assertEqual(expected_response, binascii.b2a_hex(response)) def test_dispatch_opcode_query_tsig_scope_pool(self): - # Create a domain/recordset/record to query - domain = self.create_domain(name='example.com.') + # Create a zone/recordset/record to query + zone = self.create_zone(name='example.com.') recordset = self.create_recordset( - domain, name='example.com.', type='A') + zone, name='example.com.', type='A') self.create_record( - domain, recordset, data='192.0.2.5') + zone, recordset, data='192.0.2.5') # DNS packet with QUERY opcode for A example.com. payload = ("c28901200001000000000001076578616d706c6503636f6d0000010001" @@ -853,18 +853,18 @@ class MdnsRequestHandlerTest(MdnsTestCase): self.assertEqual(expected_response, binascii.b2a_hex(response)) def test_dispatch_opcode_query_tsig_scope_zone(self): - # Create a domain/recordset/record to query - domain = self.create_domain(name='example.com.') + # Create a zone/recordset/record to query + zone = self.create_zone(name='example.com.') recordset = self.create_recordset( - domain, name='example.com.', type='A') + zone, name='example.com.', type='A') self.create_record( - domain, recordset, data='192.0.2.5') + zone, recordset, data='192.0.2.5') # Create a TSIG Key Matching the zone tsigkey_zone_known = self.create_tsigkey( name='known-zone', scope='ZONE', - resource_id=domain.id) + resource_id=zone.id) # DNS packet with QUERY opcode for A example.com. payload = ("c28901200001000000000001076578616d706c6503636f6d0000010001" diff --git a/designate/tests/test_mdns/test_notify.py b/designate/tests/test_mdns/test_notify.py index 3524404e..b8caca10 100644 --- a/designate/tests/test_mdns/test_notify.py +++ b/designate/tests/test_mdns/test_notify.py @@ -28,7 +28,7 @@ from designate import objects class MdnsNotifyTest(MdnsTestCase): - test_domain = { + test_zone = { 'name': 'example.com.', 'email': 'example@example.com', 'serial': 100, @@ -60,7 +60,7 @@ class MdnsNotifyTest(MdnsTestCase): with patch.object(dns.query, 'udp', return_value=dns.message.from_wire( binascii.a2b_hex(expected_notify_response))): response, retry = self.notify.notify_zone_changed( - context, objects.Domain.from_dict(self.test_domain), + context, objects.Zone.from_dict(self.test_zone), self.nameserver.host, self.nameserver.port, 0, 0, 2, 0) self.assertEqual(response, dns.message.from_wire( binascii.a2b_hex(expected_notify_response))) @@ -82,7 +82,7 @@ class MdnsNotifyTest(MdnsTestCase): with patch.object(dns.query, 'udp', return_value=dns.message.from_wire( binascii.a2b_hex(non_auth_notify_response))): response, retry = self.notify.notify_zone_changed( - context, objects.Domain.from_dict(self.test_domain), + context, objects.Zone.from_dict(self.test_zone), self.nameserver.host, self.nameserver.port, 0, 0, 2, 0) self.assertIsNone(response) self.assertEqual(retry, 1) @@ -91,7 +91,7 @@ class MdnsNotifyTest(MdnsTestCase): def test_send_notify_message_timeout(self, _): context = self.get_context() response, retry = self.notify.notify_zone_changed( - context, objects.Domain.from_dict(self.test_domain), + context, objects.Zone.from_dict(self.test_zone), self.nameserver.host, self.nameserver.port, 0, 0, 2, 0) self.assertIsNone(response) self.assertEqual(retry, 2) @@ -100,7 +100,7 @@ class MdnsNotifyTest(MdnsTestCase): def test_send_notify_message_bad_response(self, _): context = self.get_context() response, retry = self.notify.notify_zone_changed( - context, objects.Domain.from_dict(self.test_domain), + context, objects.Zone.from_dict(self.test_zone), self.nameserver.host, self.nameserver.port, 0, 0, 2, 0) self.assertIsNone(response) self.assertEqual(retry, 1) @@ -125,10 +125,10 @@ class MdnsNotifyTest(MdnsTestCase): with patch.object(dns.query, 'udp', return_value=dns.message.from_wire( binascii.a2b_hex(poll_response))): status, serial, retries = self.notify.get_serial_number( - context, objects.Domain.from_dict(self.test_domain), + context, objects.Zone.from_dict(self.test_zone), self.nameserver.host, self.nameserver.port, 0, 0, 2, 0) self.assertEqual(status, 'SUCCESS') - self.assertEqual(serial, self.test_domain['serial']) + self.assertEqual(serial, self.test_zone['serial']) self.assertEqual(retries, 2) def test_poll_for_serial_number_lower_serial(self): @@ -151,7 +151,7 @@ class MdnsNotifyTest(MdnsTestCase): with patch.object(dns.query, 'udp', return_value=dns.message.from_wire( binascii.a2b_hex(poll_response))): status, serial, retries = self.notify.get_serial_number( - context, objects.Domain.from_dict(self.test_domain), + context, objects.Zone.from_dict(self.test_zone), self.nameserver.host, self.nameserver.port, 0, 0, 2, 0) self.assertEqual(status, 'ERROR') self.assertEqual(serial, 99) @@ -177,7 +177,7 @@ class MdnsNotifyTest(MdnsTestCase): with patch.object(dns.query, 'udp', return_value=dns.message.from_wire( binascii.a2b_hex(poll_response))): status, serial, retries = self.notify.get_serial_number( - context, objects.Domain.from_dict(self.test_domain), + context, objects.Zone.from_dict(self.test_zone), self.nameserver.host, self.nameserver.port, 0, 0, 2, 0) self.assertEqual(status, 'SUCCESS') self.assertEqual(serial, 101) @@ -187,7 +187,7 @@ class MdnsNotifyTest(MdnsTestCase): def test_poll_for_serial_number_timeout(self, _): context = self.get_context() status, serial, retries = self.notify.get_serial_number( - context, objects.Domain.from_dict(self.test_domain), + context, objects.Zone.from_dict(self.test_zone), self.nameserver.host, self.nameserver.port, 0, 0, 2, 0) self.assertEqual(status, 'ERROR') self.assertIsNone(serial) @@ -201,12 +201,12 @@ class MdnsNotifyTest(MdnsTestCase): group='service:mdns' ) context = self.get_context() - test_domain = objects.Domain.from_dict(self.test_domain) + test_zone = objects.Zone.from_dict(self.test_zone) status, serial, retries = self.notify.get_serial_number( - context, test_domain, self.nameserver.host, + context, test_zone, self.nameserver.host, self.nameserver.port, 0, 0, 2, 0) response, retry = self.notify.notify_zone_changed( - context, test_domain, self.nameserver.host, + context, test_zone, self.nameserver.host, self.nameserver.port, 0, 0, 2, 0) assert not udp.called assert tcp.called diff --git a/designate/tests/test_notification_handler/test_neutron.py b/designate/tests/test_notification_handler/test_neutron.py index 2f448092..cfcd4ffd 100644 --- a/designate/tests/test_notification_handler/test_neutron.py +++ b/designate/tests/test_notification_handler/test_neutron.py @@ -27,11 +27,11 @@ class NeutronFloatingHandlerTest(TestCase, NotificationHandlerMixin): def setUp(self): super(NeutronFloatingHandlerTest, self).setUp() - domain = self.create_domain() - self.domain_id = domain['id'] - self.config(domain_id=domain['id'], group='handler:neutron_floatingip') - formats = ['%(octet0)s-%(octet1)s-%(octet2)s-%(octet3)s.%(domain)s', - '%(octet0)s-%(octet1)s-%(octet2)s-%(octet3)s.X.%(domain)s'] + zone = self.create_zone() + self.zone_id = zone['id'] + self.config(zone_id=zone['id'], group='handler:neutron_floatingip') + formats = ['%(octet0)s-%(octet1)s-%(octet2)s-%(octet3)s.%(zone)s', + '%(octet0)s-%(octet1)s-%(octet2)s-%(octet3)s.X.%(zone)s'] self.config(format=formats, group='handler:neutron_floatingip') self.plugin = NeutronFloatingHandler() @@ -43,7 +43,7 @@ class NeutronFloatingHandlerTest(TestCase, NotificationHandlerMixin): self.assertIn(event_type, self.plugin.get_event_types()) - criterion = {'domain_id': self.domain_id} + criterion = {'zone_id': self.zone_id} # Ensure we start with only SOA and NS records records = self.central_service.find_records(self.admin_context, @@ -74,7 +74,7 @@ class NeutronFloatingHandlerTest(TestCase, NotificationHandlerMixin): self.assertIn(event_type, self.plugin.get_event_types()) - criterion = {'domain_id': self.domain_id} + criterion = {'zone_id': self.zone_id} # Ensure we start with at least 1 record, plus NS and SOA records = self.central_service.find_records(self.admin_context, @@ -86,10 +86,10 @@ class NeutronFloatingHandlerTest(TestCase, NotificationHandlerMixin): self.admin_context, event_type, fixture['payload']) # Simulate the record having been deleted on the backend - domain_serial = self.central_service.get_domain( - self.admin_context, self.domain_id).serial + zone_serial = self.central_service.get_zone( + self.admin_context, self.zone_id).serial self.central_service.update_status( - self.admin_context, self.domain_id, "SUCCESS", domain_serial) + self.admin_context, self.zone_id, "SUCCESS", zone_serial) # Ensure we now have exactly 0 records, plus NS and SOA records = self.central_service.find_records(self.admin_context, @@ -111,7 +111,7 @@ class NeutronFloatingHandlerTest(TestCase, NotificationHandlerMixin): self.assertIn(event_type, self.plugin.get_event_types()) - criterion = {'domain_id': self.domain_id} + criterion = {'zone_id': self.zone_id} # Ensure we start with at least 1 record, plus NS and SOA records = self.central_service.find_records(self.admin_context, @@ -122,10 +122,10 @@ class NeutronFloatingHandlerTest(TestCase, NotificationHandlerMixin): self.admin_context, event_type, fixture['payload']) # Simulate the record having been deleted on the backend - domain_serial = self.central_service.get_domain( - self.admin_context, self.domain_id).serial + zone_serial = self.central_service.get_zone( + self.admin_context, self.zone_id).serial self.central_service.update_status( - self.admin_context, self.domain_id, "SUCCESS", domain_serial) + self.admin_context, self.zone_id, "SUCCESS", zone_serial) # Ensure we now have exactly 0 records, plus NS and SOA records = self.central_service.find_records(self.admin_context, diff --git a/designate/tests/test_notification_handler/test_nova.py b/designate/tests/test_notification_handler/test_nova.py index 057f74fd..eb2f263d 100644 --- a/designate/tests/test_notification_handler/test_nova.py +++ b/designate/tests/test_notification_handler/test_nova.py @@ -29,11 +29,11 @@ class NovaFixedHandlerTest(TestCase, NotificationHandlerMixin): def setUp(self): super(NovaFixedHandlerTest, self).setUp() - domain = self.create_domain() - self.domain_id = domain['id'] - self.config(domain_id=domain['id'], group='handler:nova_fixed') - self.config(format=['%(host)s.%(domain)s', - '%(host)s.foo.%(domain)s'], + zone = self.create_zone() + self.zone_id = zone['id'] + self.config(zone_id=zone['id'], group='handler:nova_fixed') + self.config(format=['%(host)s.%(zone)s', + '%(host)s.foo.%(zone)s'], group='handler:nova_fixed') self.plugin = NovaFixedHandler() @@ -44,7 +44,7 @@ class NovaFixedHandlerTest(TestCase, NotificationHandlerMixin): self.assertIn(event_type, self.plugin.get_event_types()) - criterion = {'domain_id': self.domain_id} + criterion = {'zone_id': self.zone_id} # Ensure we start with 2 records records = self.central_service.find_records(self.admin_context, @@ -62,7 +62,7 @@ class NovaFixedHandlerTest(TestCase, NotificationHandlerMixin): self.assertEqual(4, len(records)) def test_instance_create_end_utf8(self): - self.config(format=['%(display_name)s.%(domain)s'], + self.config(format=['%(display_name)s.%(zone)s'], group='handler:nova_fixed') event_type = 'compute.instance.create.end' @@ -73,7 +73,7 @@ class NovaFixedHandlerTest(TestCase, NotificationHandlerMixin): self.assertIn(event_type, self.plugin.get_event_types()) - criterion = {'domain_id': self.domain_id} + criterion = {'zone_id': self.zone_id} # Ensure we start with 2 records recordsets = self.central_service.find_recordsets( @@ -114,7 +114,7 @@ class NovaFixedHandlerTest(TestCase, NotificationHandlerMixin): self.assertIn(event_type, self.plugin.get_event_types()) - criterion = {'domain_id': self.domain_id} + criterion = {'zone_id': self.zone_id} # Ensure we start with at least 1 record, plus NS and SOA records = self.central_service.find_records(self.admin_context, @@ -126,10 +126,10 @@ class NovaFixedHandlerTest(TestCase, NotificationHandlerMixin): self.admin_context, event_type, fixture['payload']) # Simulate the record having been deleted on the backend - domain_serial = self.central_service.get_domain( - self.admin_context, self.domain_id).serial + zone_serial = self.central_service.get_zone( + self.admin_context, self.zone_id).serial self.central_service.update_status( - self.admin_context, self.domain_id, "SUCCESS", domain_serial) + self.admin_context, self.zone_id, "SUCCESS", zone_serial) # Ensure we now have exactly 0 records, plus NS and SOA records = self.central_service.find_records(self.admin_context, @@ -150,5 +150,5 @@ class NovaFixedHandlerTest(TestCase, NotificationHandlerMixin): self.plugin.process_notification( self.admin_context, event_type, fixture['payload']) finder.assert_called_once_with( - mock.ANY, type='A', domain_id=self.domain_id, + mock.ANY, type='A', zone_id=self.zone_id, name='private.example.com') diff --git a/designate/tests/test_pool_manager/cache/__init__.py b/designate/tests/test_pool_manager/cache/__init__.py index bbdc05f5..b81626af 100644 --- a/designate/tests/test_pool_manager/cache/__init__.py +++ b/designate/tests/test_pool_manager/cache/__init__.py @@ -24,7 +24,7 @@ class PoolManagerCacheTestCase(object): def create_pool_manager_status(self): values = { 'nameserver_id': '896aa661-198c-4379-bccd-5d8de7007030', - 'domain_id': 'bce45113-4a22-418d-a54d-c9777d056312', + 'zone_id': 'bce45113-4a22-418d-a54d-c9777d056312', 'action': 'CREATE', 'status': 'SUCCESS', 'serial_number': 1 @@ -42,12 +42,12 @@ class PoolManagerCacheTestCase(object): with testtools.ExpectedException(exceptions.PoolManagerStatusNotFound): self.cache.retrieve( - self.admin_context, expected.nameserver_id, expected.domain_id, + self.admin_context, expected.nameserver_id, expected.zone_id, expected.action) def test_retrieve(self): expected = self.create_pool_manager_status() with testtools.ExpectedException(exceptions.PoolManagerStatusNotFound): self.cache.retrieve( - self.admin_context, expected.nameserver_id, expected.domain_id, + self.admin_context, expected.nameserver_id, expected.zone_id, expected.action) diff --git a/designate/tests/test_pool_manager/cache/test_memcache.py b/designate/tests/test_pool_manager/cache/test_memcache.py index 086b281e..e2c92c92 100644 --- a/designate/tests/test_pool_manager/cache/test_memcache.py +++ b/designate/tests/test_pool_manager/cache/test_memcache.py @@ -27,7 +27,7 @@ class MemcachePoolManagerCacheTest(PoolManagerCacheTestCase, TestCase): self.cache = cache.get_pool_manager_cache('memcache') self.mock_status = Mock( nameserver_id='nameserver_id', - domain_id='domain_id', + zone_id='zone_id', action='CREATE', ) @@ -36,11 +36,11 @@ class MemcachePoolManagerCacheTest(PoolManagerCacheTestCase, TestCase): self.cache.store(self.admin_context, expected) actual = self.cache.retrieve( - self.admin_context, expected.nameserver_id, expected.domain_id, + self.admin_context, expected.nameserver_id, expected.zone_id, expected.action) self.assertEqual(expected.nameserver_id, actual.nameserver_id) - self.assertEqual(expected.domain_id, actual.domain_id) + self.assertEqual(expected.zone_id, actual.zone_id) self.assertEqual(expected.status, actual.status) self.assertEqual(expected.serial_number, actual.serial_number) self.assertEqual(expected.action, actual.action) @@ -53,7 +53,7 @@ class MemcachePoolManagerCacheTest(PoolManagerCacheTestCase, TestCase): """ key = self.cache._build_serial_number_key(self.mock_status) self.assertIsInstance(key, str) - self.assertEqual(key, 'nameserver_id-domain_id-CREATE-serial_number') + self.assertEqual(key, 'nameserver_id-zone_id-CREATE-serial_number') def test_status_key_is_a_string(self): """Memcache requires keys be strings. @@ -63,4 +63,4 @@ class MemcachePoolManagerCacheTest(PoolManagerCacheTestCase, TestCase): """ key = self.cache._build_status_key(self.mock_status) self.assertIsInstance(key, str) - self.assertEqual(key, 'nameserver_id-domain_id-CREATE-status') + self.assertEqual(key, 'nameserver_id-zone_id-CREATE-status') diff --git a/designate/tests/test_pool_manager/cache/test_noop.py b/designate/tests/test_pool_manager/cache/test_noop.py index a85b3f5f..93313923 100644 --- a/designate/tests/test_pool_manager/cache/test_noop.py +++ b/designate/tests/test_pool_manager/cache/test_noop.py @@ -33,5 +33,5 @@ class NoopPoolManagerCacheTest(PoolManagerCacheTestCase, TestCase): with testtools.ExpectedException(exceptions.PoolManagerStatusNotFound): self.cache.retrieve( - self.admin_context, expected.nameserver_id, expected.domain_id, + self.admin_context, expected.nameserver_id, expected.zone_id, expected.action) diff --git a/designate/tests/test_pool_manager/cache/test_sqlalchemy.py b/designate/tests/test_pool_manager/cache/test_sqlalchemy.py index 2d6fb7f4..751dd96a 100644 --- a/designate/tests/test_pool_manager/cache/test_sqlalchemy.py +++ b/designate/tests/test_pool_manager/cache/test_sqlalchemy.py @@ -29,11 +29,11 @@ class SqlalchemyPoolManagerCacheTest(PoolManagerCacheTestCase, TestCase): self.cache.store(self.admin_context, expected) actual = self.cache.retrieve( - self.admin_context, expected.nameserver_id, expected.domain_id, + self.admin_context, expected.nameserver_id, expected.zone_id, expected.action) self.assertEqual(expected.nameserver_id, actual.nameserver_id) - self.assertEqual(expected.domain_id, actual.domain_id) + self.assertEqual(expected.zone_id, actual.zone_id) self.assertEqual(expected.status, actual.status) self.assertEqual(expected.serial_number, actual.serial_number) self.assertEqual(expected.action, actual.action) diff --git a/designate/tests/test_pool_manager/test_rpcapi.py b/designate/tests/test_pool_manager/test_rpcapi.py index c0205c1b..ed7d91da 100644 --- a/designate/tests/test_pool_manager/test_rpcapi.py +++ b/designate/tests/test_pool_manager/test_rpcapi.py @@ -25,7 +25,7 @@ from designate.tests.test_pool_manager import PoolManagerTestCase class PoolManagerAPITest(PoolManagerTestCase): @patch.object(messaging.RPCClient, 'prepare') - def test_create_domain(self, mock_prepare): + def test_create_zone(self, mock_prepare): inner_mock = mock.Mock() inner_mock.cast = mock.Mock(return_value=None) mock_prepare.return_value = inner_mock @@ -34,16 +34,16 @@ class PoolManagerAPITest(PoolManagerTestCase): 'name': 'example.org.', 'pool_id': '794ccc2c-d751-44fe-b57f-8894c9f5c842' } - domain = objects.Domain.from_dict(values) - PoolManagerAPI.get_instance().create_domain(self.admin_context, domain) + zone = objects.Zone.from_dict(values) + PoolManagerAPI.get_instance().create_zone(self.admin_context, zone) mock_prepare.assert_called_once_with( - topic='pool_manager.%s' % domain.pool_id) + topic='pool_manager.%s' % zone.pool_id) mock_prepare.return_value.cast.assert_called_once_with( - self.admin_context, 'create_domain', domain=domain) + self.admin_context, 'create_zone', zone=zone) @patch.object(messaging.RPCClient, 'prepare') - def test_delete_domain(self, mock_prepare): + def test_delete_zone(self, mock_prepare): inner_mock = mock.Mock() inner_mock.cast = mock.Mock(return_value=None) mock_prepare.return_value = inner_mock @@ -52,16 +52,16 @@ class PoolManagerAPITest(PoolManagerTestCase): 'name': 'example.org.', 'pool_id': '794ccc2c-d751-44fe-b57f-8894c9f5c842' } - domain = objects.Domain.from_dict(values) - PoolManagerAPI.get_instance().delete_domain(self.admin_context, domain) + zone = objects.Zone.from_dict(values) + PoolManagerAPI.get_instance().delete_zone(self.admin_context, zone) mock_prepare.assert_called_once_with( - topic='pool_manager.%s' % domain.pool_id) + topic='pool_manager.%s' % zone.pool_id) mock_prepare.return_value.cast.assert_called_once_with( - self.admin_context, 'delete_domain', domain=domain) + self.admin_context, 'delete_zone', zone=zone) @patch.object(messaging.RPCClient, 'prepare') - def test_update_domain(self, mock_prepare): + def test_update_zone(self, mock_prepare): inner_mock = mock.Mock() inner_mock.cast = mock.Mock(return_value=None) mock_prepare.return_value = inner_mock @@ -70,13 +70,13 @@ class PoolManagerAPITest(PoolManagerTestCase): 'name': 'example.org.', 'pool_id': '794ccc2c-d751-44fe-b57f-8894c9f5c842' } - domain = objects.Domain.from_dict(values) - PoolManagerAPI.get_instance().update_domain(self.admin_context, domain) + zone = objects.Zone.from_dict(values) + PoolManagerAPI.get_instance().update_zone(self.admin_context, zone) mock_prepare.assert_called_once_with( - topic='pool_manager.%s' % domain.pool_id) + topic='pool_manager.%s' % zone.pool_id) mock_prepare.return_value.cast.assert_called_once_with( - self.admin_context, 'update_domain', domain=domain) + self.admin_context, 'update_zone', zone=zone) @patch.object(messaging.RPCClient, 'prepare') def test_update_status(self, mock_prepare): @@ -88,17 +88,17 @@ class PoolManagerAPITest(PoolManagerTestCase): 'name': 'example.org.', 'pool_id': '794ccc2c-d751-44fe-b57f-8894c9f5c842' } - domain = objects.Domain.from_dict(values) + zone = objects.Zone.from_dict(values) values = { 'host': '127.0.0.1', 'port': '53' } nameserver = objects.PoolNameserver.from_dict(values) PoolManagerAPI.get_instance().update_status( - self.admin_context, domain, nameserver, 'SUCCESS', 1) + self.admin_context, zone, nameserver, 'SUCCESS', 1) mock_prepare.assert_called_once_with( - topic='pool_manager.%s' % domain.pool_id) + topic='pool_manager.%s' % zone.pool_id) mock_prepare.return_value.cast.assert_called_once_with( - self.admin_context, 'update_status', domain=domain, + self.admin_context, 'update_status', zone=zone, nameserver=nameserver, status='SUCCESS', actual_serial=1) diff --git a/designate/tests/test_pool_manager/test_service.py b/designate/tests/test_pool_manager/test_service.py index 9117eb9e..d50ee40f 100644 --- a/designate/tests/test_pool_manager/test_service.py +++ b/designate/tests/test_pool_manager/test_service.py @@ -103,7 +103,7 @@ class PoolManagerServiceNoopTest(PoolManagerTestCase): self.cache = self.service.cache @staticmethod - def _build_domain(name, action, status): + def _build_zone(name, action, status): values = { 'id': '75ea1626-eea7-46b5-acb7-41e5897c2d40', 'name': name, @@ -112,23 +112,23 @@ class PoolManagerServiceNoopTest(PoolManagerTestCase): 'serial': 1422062497, 'status': status } - return objects.Domain.from_dict(values) + return objects.Zone.from_dict(values) @patch.object(mdns_rpcapi.MdnsAPI, 'get_serial_number', side_effect=messaging.MessagingException) @patch.object(mdns_rpcapi.MdnsAPI, 'poll_for_serial_number') @patch.object(mdns_rpcapi.MdnsAPI, 'notify_zone_changed') @patch.object(central_rpcapi.CentralAPI, 'update_status') - def test_create_domain( + def test_create_zone( self, mock_update_status, mock_notify_zone_changed, mock_poll_for_serial_number, _): - domain = self._build_domain('example.org.', 'CREATE', 'PENDING') + zone = self._build_zone('example.org.', 'CREATE', 'PENDING') - self.service.create_domain(self.admin_context, domain) + self.service.create_zone(self.admin_context, zone) create_statuses = self.service._retrieve_statuses( - self.admin_context, domain, 'CREATE') + self.admin_context, zone, 'CREATE') # Even though _retrieve_statuses tries to get from mdns, mdns does # not return any status self.assertEqual(0, len(create_statuses)) @@ -136,9 +136,9 @@ class PoolManagerServiceNoopTest(PoolManagerTestCase): # Ensure poll_for_serial_number was called for each nameserver. self.assertEqual(2, mock_poll_for_serial_number.call_count) self.assertEqual( - [call(self.admin_context, domain, + [call(self.admin_context, zone, self.service.pool.nameservers[0], 30, 0.5, 1, 5), - call(self.admin_context, domain, + call(self.admin_context, zone, self.service.pool.nameservers[1], 30, 0.5, 1, 5)], mock_poll_for_serial_number.call_args_list) @@ -148,22 +148,22 @@ class PoolManagerServiceNoopTest(PoolManagerTestCase): @patch.object(mdns_rpcapi.MdnsAPI, 'get_serial_number', side_effect=messaging.MessagingException) - @patch.object(impl_fake.FakeBackend, 'create_domain') + @patch.object(impl_fake.FakeBackend, 'create_zone') @patch.object(mdns_rpcapi.MdnsAPI, 'poll_for_serial_number') @patch.object(mdns_rpcapi.MdnsAPI, 'notify_zone_changed') @patch.object(central_rpcapi.CentralAPI, 'update_status') - def test_create_domain_target_both_failure( + def test_create_zone_target_both_failure( self, mock_update_status, mock_notify_zone_changed, - mock_poll_for_serial_number, mock_create_domain, _): + mock_poll_for_serial_number, mock_create_zone, _): - domain = self._build_domain('example.org.', 'CREATE', 'PENDING') + zone = self._build_zone('example.org.', 'CREATE', 'PENDING') - mock_create_domain.side_effect = exceptions.Backend + mock_create_zone.side_effect = exceptions.Backend - self.service.create_domain(self.admin_context, domain) + self.service.create_zone(self.admin_context, zone) create_statuses = self.service._retrieve_statuses( - self.admin_context, domain, 'CREATE') + self.admin_context, zone, 'CREATE') self.assertEqual(0, len(create_statuses)) # Ensure notify_zone_changed and poll_for_serial_number @@ -177,22 +177,22 @@ class PoolManagerServiceNoopTest(PoolManagerTestCase): @patch.object(mdns_rpcapi.MdnsAPI, 'get_serial_number', side_effect=messaging.MessagingException) - @patch.object(impl_fake.FakeBackend, 'create_domain') + @patch.object(impl_fake.FakeBackend, 'create_zone') @patch.object(mdns_rpcapi.MdnsAPI, 'poll_for_serial_number') @patch.object(mdns_rpcapi.MdnsAPI, 'notify_zone_changed') @patch.object(central_rpcapi.CentralAPI, 'update_status') - def test_create_domain_target_one_failure( + def test_create_zone_target_one_failure( self, mock_update_status, mock_notify_zone_changed, - mock_poll_for_serial_number, mock_create_domain, _): + mock_poll_for_serial_number, mock_create_zone, _): - domain = self._build_domain('example.org.', 'CREATE', 'PENDING') + zone = self._build_zone('example.org.', 'CREATE', 'PENDING') - mock_create_domain.side_effect = [None, exceptions.Backend] + mock_create_zone.side_effect = [None, exceptions.Backend] - self.service.create_domain(self.admin_context, domain) + self.service.create_zone(self.admin_context, zone) create_statuses = self.service._retrieve_statuses( - self.admin_context, domain, 'CREATE') + self.admin_context, zone, 'CREATE') self.assertEqual(0, len(create_statuses)) # Since consensus is not reached this early, we immediatly call @@ -201,13 +201,13 @@ class PoolManagerServiceNoopTest(PoolManagerTestCase): @patch.object(mdns_rpcapi.MdnsAPI, 'get_serial_number', side_effect=messaging.MessagingException) - @patch.object(impl_fake.FakeBackend, 'create_domain') + @patch.object(impl_fake.FakeBackend, 'create_zone') @patch.object(mdns_rpcapi.MdnsAPI, 'poll_for_serial_number') @patch.object(mdns_rpcapi.MdnsAPI, 'notify_zone_changed') @patch.object(central_rpcapi.CentralAPI, 'update_status') - def test_create_domain_target_one_failure_consensus( + def test_create_zone_target_one_failure_consensus( self, mock_update_status, mock_notify_zone_changed, - mock_poll_for_serial_number, mock_create_domain, _): + mock_poll_for_serial_number, mock_create_zone, _): self.service.stop() self.config( @@ -215,69 +215,69 @@ class PoolManagerServiceNoopTest(PoolManagerTestCase): group='service:pool_manager') self.service = self.start_service('pool_manager') - domain = self._build_domain('example.org.', 'CREATE', 'PENDING') + zone = self._build_zone('example.org.', 'CREATE', 'PENDING') - mock_create_domain.side_effect = [None, exceptions.Backend] + mock_create_zone.side_effect = [None, exceptions.Backend] - self.service.create_domain(self.admin_context, domain) + self.service.create_zone(self.admin_context, zone) create_statuses = self.service._retrieve_statuses( - self.admin_context, domain, 'CREATE') + self.admin_context, zone, 'CREATE') self.assertEqual(0, len(create_statuses)) # Ensure poll_for_serial_number was called for each nameserver. self.assertEqual( - [call(self.admin_context, domain, + [call(self.admin_context, zone, self.service.pool.nameservers[0], 30, 0.5, 1, 5), - call(self.admin_context, domain, + call(self.admin_context, zone, self.service.pool.nameservers[1], 30, 0.5, 1, 5)], mock_poll_for_serial_number.call_args_list) self.assertFalse(mock_update_status.called) - @patch.object(impl_fake.FakeBackend, 'delete_domain', + @patch.object(impl_fake.FakeBackend, 'delete_zone', side_effect=exceptions.Backend) @patch.object(central_rpcapi.CentralAPI, 'update_status') - def test_delete_domain(self, mock_update_status, _): - domain = self._build_domain('example.org.', 'DELETE', 'PENDING') + def test_delete_zone(self, mock_update_status, _): + zone = self._build_zone('example.org.', 'DELETE', 'PENDING') - self.service.delete_domain(self.admin_context, domain) + self.service.delete_zone(self.admin_context, zone) mock_update_status.assert_called_once_with( - self.admin_context, domain.id, 'ERROR', domain.serial) + self.admin_context, zone.id, 'ERROR', zone.serial) - @patch.object(impl_fake.FakeBackend, 'delete_domain') + @patch.object(impl_fake.FakeBackend, 'delete_zone') @patch.object(central_rpcapi.CentralAPI, 'update_status') - def test_delete_domain_target_both_failure( - self, mock_update_status, mock_delete_domain): + def test_delete_zone_target_both_failure( + self, mock_update_status, mock_delete_zone): - domain = self._build_domain('example.org.', 'DELETE', 'PENDING') + zone = self._build_zone('example.org.', 'DELETE', 'PENDING') - mock_delete_domain.side_effect = exceptions.Backend + mock_delete_zone.side_effect = exceptions.Backend - self.service.delete_domain(self.admin_context, domain) + self.service.delete_zone(self.admin_context, zone) mock_update_status.assert_called_once_with( - self.admin_context, domain.id, 'ERROR', domain.serial) + self.admin_context, zone.id, 'ERROR', zone.serial) - @patch.object(impl_fake.FakeBackend, 'delete_domain') + @patch.object(impl_fake.FakeBackend, 'delete_zone') @patch.object(central_rpcapi.CentralAPI, 'update_status') - def test_delete_domain_target_one_failure( - self, mock_update_status, mock_delete_domain): + def test_delete_zone_target_one_failure( + self, mock_update_status, mock_delete_zone): - domain = self._build_domain('example.org.', 'DELETE', 'PENDING') + zone = self._build_zone('example.org.', 'DELETE', 'PENDING') - mock_delete_domain.side_effect = [None, exceptions.Backend] + mock_delete_zone.side_effect = [None, exceptions.Backend] - self.service.delete_domain(self.admin_context, domain) + self.service.delete_zone(self.admin_context, zone) mock_update_status.assert_called_once_with( - self.admin_context, domain.id, 'ERROR', domain.serial) + self.admin_context, zone.id, 'ERROR', zone.serial) - @patch.object(impl_fake.FakeBackend, 'delete_domain') + @patch.object(impl_fake.FakeBackend, 'delete_zone') @patch.object(central_rpcapi.CentralAPI, 'update_status') - def test_delete_domain_target_one_failure_consensus( - self, mock_update_status, mock_delete_domain): + def test_delete_zone_target_one_failure_consensus( + self, mock_update_status, mock_delete_zone): self.service.stop() self.config( @@ -285,39 +285,39 @@ class PoolManagerServiceNoopTest(PoolManagerTestCase): group='service:pool_manager') self.service = self.start_service('pool_manager') - domain = self._build_domain('example.org.', 'DELETE', 'PENDING') + zone = self._build_zone('example.org.', 'DELETE', 'PENDING') - mock_delete_domain.side_effect = [None, exceptions.Backend] + mock_delete_zone.side_effect = [None, exceptions.Backend] - self.service.delete_domain(self.admin_context, domain) + self.service.delete_zone(self.admin_context, zone) mock_update_status.assert_called_once_with( - self.admin_context, domain.id, 'ERROR', domain.serial) + self.admin_context, zone.id, 'ERROR', zone.serial) @patch.object(mdns_rpcapi.MdnsAPI, 'get_serial_number', side_effect=messaging.MessagingException) @patch.object(central_rpcapi.CentralAPI, 'update_status') def test_update_status(self, mock_update_status, _): - domain = self._build_domain('example.org.', 'UPDATE', 'PENDING') + zone = self._build_zone('example.org.', 'UPDATE', 'PENDING') - self.service.update_status(self.admin_context, domain, + self.service.update_status(self.admin_context, zone, self.service.pool.nameservers[0], - 'SUCCESS', domain.serial) + 'SUCCESS', zone.serial) update_statuses = self.service._retrieve_statuses( - self.admin_context, domain, 'UPDATE') + self.admin_context, zone, 'UPDATE') self.assertEqual(0, len(update_statuses)) # Ensure update_status was not called. self.assertFalse(mock_update_status.called) - self.service.update_status(self.admin_context, domain, + self.service.update_status(self.admin_context, zone, self.service.pool.nameservers[1], - 'SUCCESS', domain.serial) + 'SUCCESS', zone.serial) update_statuses = self.service._retrieve_statuses( - self.admin_context, domain, 'UPDATE') + self.admin_context, zone, 'UPDATE') self.assertEqual(0, len(update_statuses)) # Ensure update_status was not called. @@ -327,60 +327,60 @@ class PoolManagerServiceNoopTest(PoolManagerTestCase): side_effect=messaging.MessagingException) @patch.object(central_rpcapi.CentralAPI, 'update_status') def test_update_status_both_failure(self, mock_update_status, _): - domain = self._build_domain('example.org.', 'UPDATE', 'PENDING') + zone = self._build_zone('example.org.', 'UPDATE', 'PENDING') - self.service.update_status(self.admin_context, domain, + self.service.update_status(self.admin_context, zone, self.service.pool.nameservers[0], - 'ERROR', domain.serial) + 'ERROR', zone.serial) update_statuses = self.service._retrieve_statuses( - self.admin_context, domain, 'UPDATE') + self.admin_context, zone, 'UPDATE') self.assertEqual(0, len(update_statuses)) mock_update_status.assert_called_once_with( - self.admin_context, domain.id, 'ERROR', 0) + self.admin_context, zone.id, 'ERROR', 0) # Reset the mock call attributes. mock_update_status.reset_mock() - self.service.update_status(self.admin_context, domain, + self.service.update_status(self.admin_context, zone, self.service.pool.nameservers[1], - 'ERROR', domain.serial) + 'ERROR', zone.serial) update_statuses = self.service._retrieve_statuses( - self.admin_context, domain, 'UPDATE') + self.admin_context, zone, 'UPDATE') self.assertEqual(0, len(update_statuses)) mock_update_status.assert_called_once_with( - self.admin_context, domain.id, 'ERROR', 0) + self.admin_context, zone.id, 'ERROR', 0) @patch.object(mdns_rpcapi.MdnsAPI, 'get_serial_number', side_effect=messaging.MessagingException) @patch.object(central_rpcapi.CentralAPI, 'update_status') def test_update_status_one_failure(self, mock_update_status, _): - domain = self._build_domain('example.org.', 'UPDATE', 'PENDING') + zone = self._build_zone('example.org.', 'UPDATE', 'PENDING') - self.service.update_status(self.admin_context, domain, + self.service.update_status(self.admin_context, zone, self.service.pool.nameservers[0], - 'SUCCESS', domain.serial) + 'SUCCESS', zone.serial) update_statuses = self.service._retrieve_statuses( - self.admin_context, domain, 'UPDATE') + self.admin_context, zone, 'UPDATE') self.assertEqual(0, len(update_statuses)) # Ensure update_status was not called. self.assertFalse(mock_update_status.called) - self.service.update_status(self.admin_context, domain, + self.service.update_status(self.admin_context, zone, self.service.pool.nameservers[1], - 'ERROR', domain.serial) + 'ERROR', zone.serial) update_statuses = self.service._retrieve_statuses( - self.admin_context, domain, 'UPDATE') + self.admin_context, zone, 'UPDATE') self.assertEqual(0, len(update_statuses)) mock_update_status.assert_called_once_with( - self.admin_context, domain.id, 'ERROR', 0) + self.admin_context, zone.id, 'ERROR', 0) @patch.object(mdns_rpcapi.MdnsAPI, 'get_serial_number', side_effect=messaging.MessagingException) @@ -393,14 +393,14 @@ class PoolManagerServiceNoopTest(PoolManagerTestCase): group='service:pool_manager') self.service = self.start_service('pool_manager') - domain = self._build_domain('example.org.', 'UPDATE', 'PENDING') + zone = self._build_zone('example.org.', 'UPDATE', 'PENDING') - self.service.update_status(self.admin_context, domain, + self.service.update_status(self.admin_context, zone, self.service.pool.nameservers[0], - 'SUCCESS', domain.serial) + 'SUCCESS', zone.serial) update_statuses = self.service._retrieve_statuses( - self.admin_context, domain, 'UPDATE') + self.admin_context, zone, 'UPDATE') self.assertEqual(0, len(update_statuses)) # Ensure update_status was not called. @@ -409,13 +409,13 @@ class PoolManagerServiceNoopTest(PoolManagerTestCase): # Reset the mock call attributes. mock_update_status.reset_mock() - self.service.update_status(self.admin_context, domain, + self.service.update_status(self.admin_context, zone, self.service.pool.nameservers[1], - 'ERROR', domain.serial) + 'ERROR', zone.serial) update_statuses = self.service._retrieve_statuses( - self.admin_context, domain, 'UPDATE') + self.admin_context, zone, 'UPDATE') self.assertEqual(0, len(update_statuses)) mock_update_status.assert_called_once_with( - self.admin_context, domain.id, 'ERROR', 0) + self.admin_context, zone.id, 'ERROR', 0) diff --git a/designate/tests/test_quota/test_quota.py b/designate/tests/test_quota/test_quota.py index aac15f7b..a259fe65 100644 --- a/designate/tests/test_quota/test_quota.py +++ b/designate/tests/test_quota/test_quota.py @@ -45,9 +45,9 @@ class QuotaTestCase(tests.TestCase): self.assertIsNotNone(quotas) self.assertEqual({ 'api_export_size': cfg.CONF.quota_api_export_size, - 'domains': cfg.CONF.quota_domains, - 'domain_recordsets': cfg.CONF.quota_domain_recordsets, - 'domain_records': cfg.CONF.quota_domain_records, + 'zones': cfg.CONF.quota_zones, + 'zone_recordsets': cfg.CONF.quota_zone_recordsets, + 'zone_records': cfg.CONF.quota_zone_records, 'recordset_records': cfg.CONF.quota_recordset_records, }, quotas) @@ -58,53 +58,53 @@ class QuotaTestCase(tests.TestCase): self.quota.limit_check(context, 'tenant_id', unknown=0) with testtools.ExpectedException(exceptions.QuotaResourceUnknown): - self.quota.limit_check(context, 'tenant_id', unknown=0, domains=0) + self.quota.limit_check(context, 'tenant_id', unknown=0, zones=0) def test_limit_check_under(self): context = self.get_admin_context() - self.quota.limit_check(context, 'tenant_id', domains=0) - self.quota.limit_check(context, 'tenant_id', domain_records=0) - self.quota.limit_check(context, 'tenant_id', domains=0, - domain_records=0) + self.quota.limit_check(context, 'tenant_id', zones=0) + self.quota.limit_check(context, 'tenant_id', zone_records=0) + self.quota.limit_check(context, 'tenant_id', zones=0, + zone_records=0) self.quota.limit_check(context, 'tenant_id', - domains=(cfg.CONF.quota_domains - 1)) + zones=(cfg.CONF.quota_zones - 1)) self.quota.limit_check( context, 'tenant_id', - domain_records=(cfg.CONF.quota_domain_records - 1)) + zone_records=(cfg.CONF.quota_zone_records - 1)) def test_limit_check_at(self): context = self.get_admin_context() with testtools.ExpectedException(exceptions.OverQuota): self.quota.limit_check(context, 'tenant_id', - domains=cfg.CONF.quota_domains) + zones=cfg.CONF.quota_zones) with testtools.ExpectedException(exceptions.OverQuota): self.quota.limit_check( context, 'tenant_id', - domain_records=cfg.CONF.quota_domain_records) + zone_records=cfg.CONF.quota_zone_records) def test_limit_check_over(self): context = self.get_admin_context() with testtools.ExpectedException(exceptions.OverQuota): - self.quota.limit_check(context, 'tenant_id', domains=99999) + self.quota.limit_check(context, 'tenant_id', zones=99999) with testtools.ExpectedException(exceptions.OverQuota): - self.quota.limit_check(context, 'tenant_id', domain_records=99999) + self.quota.limit_check(context, 'tenant_id', zone_records=99999) with testtools.ExpectedException(exceptions.OverQuota): - self.quota.limit_check(context, 'tenant_id', domains=99999, - domain_records=99999) + self.quota.limit_check(context, 'tenant_id', zones=99999, + zone_records=99999) with testtools.ExpectedException(exceptions.OverQuota): - self.quota.limit_check(context, 'tenant_id', domains=99999, - domain_records=0) + self.quota.limit_check(context, 'tenant_id', zones=99999, + zone_records=0) with testtools.ExpectedException(exceptions.OverQuota): - self.quota.limit_check(context, 'tenant_id', domains=0, - domain_records=99999) + self.quota.limit_check(context, 'tenant_id', zones=0, + zone_records=99999) diff --git a/designate/tests/test_quota/test_storage.py b/designate/tests/test_quota/test_storage.py index 93584143..8d9cd57d 100644 --- a/designate/tests/test_quota/test_storage.py +++ b/designate/tests/test_quota/test_storage.py @@ -31,21 +31,21 @@ class StorageQuotaTest(tests.TestCase): context = self.get_admin_context() context.all_tenants = True - quota = self.quota.set_quota(context, 'tenant_id', 'domains', 1500) + quota = self.quota.set_quota(context, 'tenant_id', 'zones', 1500) - self.assertEqual({'domains': 1500}, quota) + self.assertEqual({'zones': 1500}, quota) # Drop into the storage layer directly to ensure the quota was created # successfully criterion = { 'tenant_id': 'tenant_id', - 'resource': 'domains' + 'resource': 'zones' } quota = self.quota.storage.find_quota(context, criterion) self.assertEqual('tenant_id', quota['tenant_id']) - self.assertEqual('domains', quota['resource']) + self.assertEqual('zones', quota['resource']) self.assertEqual(1500, quota['hard_limit']) def test_set_quota_update(self): @@ -53,33 +53,33 @@ class StorageQuotaTest(tests.TestCase): context.all_tenants = True # First up, Create the quota - self.quota.set_quota(context, 'tenant_id', 'domains', 1500) + self.quota.set_quota(context, 'tenant_id', 'zones', 1500) # Next, update the quota - self.quota.set_quota(context, 'tenant_id', 'domains', 1234) + self.quota.set_quota(context, 'tenant_id', 'zones', 1234) # Drop into the storage layer directly to ensure the quota was updated # successfully criterion = { 'tenant_id': 'tenant_id', - 'resource': 'domains' + 'resource': 'zones' } quota = self.quota.storage.find_quota(context, criterion) self.assertEqual('tenant_id', quota['tenant_id']) - self.assertEqual('domains', quota['resource']) + self.assertEqual('zones', quota['resource']) self.assertEqual(1234, quota['hard_limit']) def test_reset_quotas(self): context = self.get_admin_context() context.all_tenants = True - # First up, Create a domains quota - self.quota.set_quota(context, 'tenant_id', 'domains', 1500) + # First up, Create a zones quota + self.quota.set_quota(context, 'tenant_id', 'zones', 1500) - # Then, Create a domain_records quota - self.quota.set_quota(context, 'tenant_id', 'domain_records', 800) + # Then, Create a zone_records quota + self.quota.set_quota(context, 'tenant_id', 'zone_records', 800) # Now, Reset the tenants quota self.quota.reset_quotas(context, 'tenant_id') diff --git a/designate/tests/test_schema/__init__.py b/designate/tests/test_schema/__init__.py index 09193b71..efd3d63c 100644 --- a/designate/tests/test_schema/__init__.py +++ b/designate/tests/test_schema/__init__.py @@ -19,6 +19,6 @@ from designate import schema class TestSchema(TestCase): def test_constructor(self): - domain = schema.Schema('v1', 'domain') + zone = schema.Schema('v1', 'domain') - self.assertIsInstance(domain, schema.Schema) + self.assertIsInstance(zone, schema.Schema) diff --git a/designate/tests/test_schema/test_format.py b/designate/tests/test_schema/test_format.py index d157ca5c..3c2f8cf8 100644 --- a/designate/tests/test_schema/test_format.py +++ b/designate/tests/test_schema/test_format.py @@ -149,8 +149,8 @@ class SchemaFormatTest(TestCase): for hostname in invalid_hostnames: self.assertFalse(format.is_hostname(hostname)) - def test_is_domainname(self): - valid_domainnames = [ + def test_is_zonename(self): + valid_zonenames = [ 'example.com.', 'www.example.com.', '12345.example.com.', @@ -171,7 +171,7 @@ class SchemaFormatTest(TestCase): 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghi.'), ] - invalid_domainnames = [ + invalid_zonenames = [ '*.example.com.', '**.example.com.', '*.*.example.org.', @@ -215,11 +215,11 @@ class SchemaFormatTest(TestCase): "example.com.\n", ] - for domainname in valid_domainnames: - self.assertTrue(format.is_domainname(domainname), domainname) + for zonename in valid_zonenames: + self.assertTrue(format.is_zonename(zonename), zonename) - for domainname in invalid_domainnames: - self.assertFalse(format.is_domainname(domainname), domainname) + for zonename in invalid_zonenames: + self.assertFalse(format.is_zonename(zonename), zonename) def test_is_srv_hostname(self): valid_hostnames = [ diff --git a/designate/tests/test_storage/__init__.py b/designate/tests/test_storage/__init__.py index c9f5810c..c07046eb 100644 --- a/designate/tests/test_storage/__init__.py +++ b/designate/tests/test_storage/__init__.py @@ -419,14 +419,14 @@ class StorageTestCase(object): two_context.tenant = 'Two' context.all_tenants = True - # create 3 domains in 2 tenants - self.create_domain(fixture=0, context=one_context, tenant_id='One') - domain = self.create_domain(fixture=1, context=one_context, - tenant_id='One') - self.create_domain(fixture=2, context=two_context, tenant_id='Two') + # create 3 zones in 2 tenants + self.create_zone(fixture=0, context=one_context, tenant_id='One') + zone = self.create_zone(fixture=1, context=one_context, + tenant_id='One') + self.create_zone(fixture=2, context=two_context, tenant_id='Two') - # Delete one of the domains. - self.storage.delete_domain(context, domain['id']) + # Delete one of the zones. + self.storage.delete_zone(context, zone['id']) # Ensure we get accurate results result = self.storage.find_tenants(context) @@ -434,10 +434,10 @@ class StorageTestCase(object): expected = [{ 'id': 'One', - 'domain_count': 1, + 'zone_count': 1, }, { 'id': 'Two', - 'domain_count': 1, + 'zone_count': 1, }] self.assertEqual(expected, result_dict) @@ -448,20 +448,20 @@ class StorageTestCase(object): one_context.tenant = 1 context.all_tenants = True - # create 2 domains in a tenant - domain_1 = self.create_domain(fixture=0, context=one_context) - domain_2 = self.create_domain(fixture=1, context=one_context) - domain_3 = self.create_domain(fixture=2, context=one_context) + # create 2 zones in a tenant + zone_1 = self.create_zone(fixture=0, context=one_context) + zone_2 = self.create_zone(fixture=1, context=one_context) + zone_3 = self.create_zone(fixture=2, context=one_context) - # Delete one of the domains. - self.storage.delete_domain(context, domain_3['id']) + # Delete one of the zones. + self.storage.delete_zone(context, zone_3['id']) result = self.storage.get_tenant(context, 1) self.assertEqual(1, result['id']) - self.assertEqual(2, result['domain_count']) - self.assertEqual([domain_1['name'], domain_2['name']], - sorted(result['domains'])) + self.assertEqual(2, result['zone_count']) + self.assertEqual([zone_1['name'], zone_2['name']], + sorted(result['zones'])) def test_count_tenants(self): context = self.get_admin_context() @@ -475,14 +475,14 @@ class StorageTestCase(object): tenants = self.storage.count_tenants(context) self.assertEqual(0, tenants) - # create 2 domains with 2 tenants - self.create_domain(fixture=0, context=one_context, tenant_id=1) - self.create_domain(fixture=1, context=two_context, tenant_id=2) - domain = self.create_domain(fixture=2, - context=two_context, tenant_id=2) + # create 2 zones with 2 tenants + self.create_zone(fixture=0, context=one_context, tenant_id=1) + self.create_zone(fixture=1, context=two_context, tenant_id=2) + zone = self.create_zone(fixture=2, + context=two_context, tenant_id=2) - # Delete one of the domains. - self.storage.delete_domain(context, domain['id']) + # Delete one of the zones. + self.storage.delete_zone(context, zone['id']) tenants = self.storage.count_tenants(context) self.assertEqual(2, tenants) @@ -495,8 +495,8 @@ class StorageTestCase(object): tenants = self.storage.count_tenants(self.admin_context) self.assertEqual(0, tenants) - # Domain Tests - def test_create_domain(self): + # Zone Tests + def test_create_zone(self): pool_id = cfg.CONF['service:central'].default_pool_id values = { 'tenant_id': self.admin_context.tenant, @@ -505,8 +505,8 @@ class StorageTestCase(object): 'pool_id': pool_id } - result = self.storage.create_domain( - self.admin_context, domain=objects.Domain.from_dict(values)) + result = self.storage.create_zone( + self.admin_context, zone=objects.Zone.from_dict(values)) self.assertIsNotNone(result['id']) self.assertIsNotNone(result['created_at']) @@ -518,65 +518,65 @@ class StorageTestCase(object): self.assertEqual(pool_id, result['pool_id']) self.assertIn('status', result) - def test_create_domain_duplicate(self): - # Create the Initial Domain - self.create_domain() + def test_create_zone_duplicate(self): + # Create the Initial Zone + self.create_zone() - with testtools.ExpectedException(exceptions.DuplicateDomain): - self.create_domain() + with testtools.ExpectedException(exceptions.DuplicateZone): + self.create_zone() - def test_find_domains(self): - self.config(quota_domains=20) + def test_find_zones(self): + self.config(quota_zones=20) - actual = self.storage.find_domains(self.admin_context) + actual = self.storage.find_zones(self.admin_context) self.assertEqual(0, len(actual)) - # Create a single domain - domain = self.create_domain() + # Create a single zone + zone = self.create_zone() - actual = self.storage.find_domains(self.admin_context) + actual = self.storage.find_zones(self.admin_context) self.assertEqual(1, len(actual)) - self.assertEqual(domain['name'], actual[0]['name']) - self.assertEqual(domain['email'], actual[0]['email']) + self.assertEqual(zone['name'], actual[0]['name']) + self.assertEqual(zone['email'], actual[0]['email']) - def test_find_domains_paging(self): - # Create 10 Domains - created = [self.create_domain(name='example-%d.org.' % i) + def test_find_zones_paging(self): + # Create 10 zones + created = [self.create_zone(name='example-%d.org.' % i) for i in range(10)] # Ensure we can page through the results. - self._ensure_paging(created, self.storage.find_domains) + self._ensure_paging(created, self.storage.find_zones) - def test_find_domains_criterion(self): - domain_one = self.create_domain() - domain_two = self.create_domain(fixture=1) + def test_find_zones_criterion(self): + zone_one = self.create_zone() + zone_two = self.create_zone(fixture=1) criterion = dict( - name=domain_one['name'] + name=zone_one['name'] ) - results = self.storage.find_domains(self.admin_context, criterion) + results = self.storage.find_zones(self.admin_context, criterion) self.assertEqual(1, len(results)) - self.assertEqual(domain_one['name'], results[0]['name']) - self.assertEqual(domain_one['email'], results[0]['email']) - self.assertIn('status', domain_one) + self.assertEqual(zone_one['name'], results[0]['name']) + self.assertEqual(zone_one['email'], results[0]['email']) + self.assertIn('status', zone_one) criterion = dict( - name=domain_two['name'] + name=zone_two['name'] ) - results = self.storage.find_domains(self.admin_context, criterion) + results = self.storage.find_zones(self.admin_context, criterion) self.assertEqual(len(results), 1) - self.assertEqual(domain_two['name'], results[0]['name']) - self.assertEqual(domain_two['email'], results[0]['email']) - self.assertIn('status', domain_two) + self.assertEqual(zone_two['name'], results[0]['name']) + self.assertEqual(zone_two['email'], results[0]['email']) + self.assertIn('status', zone_two) - def test_find_domains_all_tenants(self): + def test_find_zones_all_tenants(self): # Create two contexts with different tenant_id's one_context = self.get_admin_context() one_context.tenant = 1 @@ -588,206 +588,206 @@ class StorageTestCase(object): at_context = self.get_admin_context() at_context.all_tenants = True - # Create two domains in different tenants - self.create_domain(fixture=0, context=one_context) - self.create_domain(fixture=1, context=two_context) + # Create two zones in different tenants + self.create_zone(fixture=0, context=one_context) + self.create_zone(fixture=1, context=two_context) - # Ensure the all_tenants context see's two domains - results = self.storage.find_domains(at_context) + # Ensure the all_tenants context see's two zones + results = self.storage.find_zones(at_context) self.assertEqual(2, len(results)) - # Ensure the normal context see's no domains - results = self.storage.find_domains(nm_context) + # Ensure the normal context see's no zones + results = self.storage.find_zones(nm_context) self.assertEqual(0, len(results)) - # Ensure the tenant 1 context see's 1 domain - results = self.storage.find_domains(one_context) + # Ensure the tenant 1 context see's 1 zone + results = self.storage.find_zones(one_context) self.assertEqual(1, len(results)) - # Ensure the tenant 2 context see's 1 domain - results = self.storage.find_domains(two_context) + # Ensure the tenant 2 context see's 1 zone + results = self.storage.find_zones(two_context) self.assertEqual(1, len(results)) - def test_get_domain(self): - # Create a domain - expected = self.create_domain() - actual = self.storage.get_domain(self.admin_context, expected['id']) + def test_get_zone(self): + # Create a zone + expected = self.create_zone() + actual = self.storage.get_zone(self.admin_context, expected['id']) self.assertEqual(expected['name'], actual['name']) self.assertEqual(expected['email'], actual['email']) self.assertIn('status', actual) - def test_get_domain_missing(self): - with testtools.ExpectedException(exceptions.DomainNotFound): + def test_get_zone_missing(self): + with testtools.ExpectedException(exceptions.ZoneNotFound): uuid = 'caf771fc-6b05-4891-bee1-c2a48621f57b' - self.storage.get_domain(self.admin_context, uuid) + self.storage.get_zone(self.admin_context, uuid) - def test_get_deleted_domain(self): + def test_get_deleted_zone(self): context = self.get_admin_context() context.show_deleted = True - domain = self.create_domain(context=context) + zone = self.create_zone(context=context) - self.storage.delete_domain(context, domain['id']) - self.storage.get_domain(context, domain['id']) + self.storage.delete_zone(context, zone['id']) + self.storage.get_zone(context, zone['id']) - def test_find_domain_criterion(self): - domain_one = self.create_domain() - domain_two = self.create_domain(fixture=1) + def test_find_zone_criterion(self): + zone_one = self.create_zone() + zone_two = self.create_zone(fixture=1) criterion = dict( - name=domain_one['name'] + name=zone_one['name'] ) - result = self.storage.find_domain(self.admin_context, criterion) + result = self.storage.find_zone(self.admin_context, criterion) - self.assertEqual(domain_one['name'], result['name']) - self.assertEqual(domain_one['email'], result['email']) - self.assertIn('status', domain_one) + self.assertEqual(zone_one['name'], result['name']) + self.assertEqual(zone_one['email'], result['email']) + self.assertIn('status', zone_one) criterion = dict( - name=domain_two['name'] + name=zone_two['name'] ) - result = self.storage.find_domain(self.admin_context, criterion) + result = self.storage.find_zone(self.admin_context, criterion) - self.assertEqual(domain_two['name'], result['name']) - self.assertEqual(domain_two['email'], result['email']) - self.assertIn('status', domain_one) - self.assertIn('status', domain_two) + self.assertEqual(zone_two['name'], result['name']) + self.assertEqual(zone_two['email'], result['email']) + self.assertIn('status', zone_one) + self.assertIn('status', zone_two) - def test_find_domain_criterion_missing(self): - expected = self.create_domain() + def test_find_zone_criterion_missing(self): + expected = self.create_zone() criterion = dict( name=expected['name'] + "NOT FOUND" ) - with testtools.ExpectedException(exceptions.DomainNotFound): - self.storage.find_domain(self.admin_context, criterion) + with testtools.ExpectedException(exceptions.ZoneNotFound): + self.storage.find_zone(self.admin_context, criterion) - def test_find_domain_criterion_lessthan(self): - domain = self.create_domain() + def test_find_zone_criterion_lessthan(self): + zone = self.create_zone() # Test Finding No Results (serial is not < serial) criterion = dict( - name=domain['name'], - serial='<%s' % domain['serial'], + name=zone['name'], + serial='<%s' % zone['serial'], ) - with testtools.ExpectedException(exceptions.DomainNotFound): - self.storage.find_domain(self.admin_context, criterion) + with testtools.ExpectedException(exceptions.ZoneNotFound): + self.storage.find_zone(self.admin_context, criterion) # Test Finding 1 Result (serial is < serial + 1) criterion = dict( - name=domain['name'], - serial='<%s' % (domain['serial'] + 1), + name=zone['name'], + serial='<%s' % (zone['serial'] + 1), ) - result = self.storage.find_domain(self.admin_context, criterion) + result = self.storage.find_zone(self.admin_context, criterion) - self.assertEqual(domain['name'], result['name']) + self.assertEqual(zone['name'], result['name']) - def test_find_domain_criterion_greaterthan(self): - domain = self.create_domain() + def test_find_zone_criterion_greaterthan(self): + zone = self.create_zone() # Test Finding No Results (serial is not > serial) criterion = dict( - name=domain['name'], - serial='>%s' % domain['serial'], + name=zone['name'], + serial='>%s' % zone['serial'], ) - with testtools.ExpectedException(exceptions.DomainNotFound): - self.storage.find_domain(self.admin_context, criterion) + with testtools.ExpectedException(exceptions.ZoneNotFound): + self.storage.find_zone(self.admin_context, criterion) # Test Finding 1 Result (serial is > serial - 1) criterion = dict( - name=domain['name'], - serial='>%s' % (domain['serial'] - 1), + name=zone['name'], + serial='>%s' % (zone['serial'] - 1), ) - result = self.storage.find_domain(self.admin_context, criterion) + result = self.storage.find_zone(self.admin_context, criterion) - self.assertEqual(domain['name'], result['name']) + self.assertEqual(zone['name'], result['name']) - def test_update_domain(self): - # Create a domain - domain = self.create_domain(name='example.org.') + def test_update_zone(self): + # Create a zone + zone = self.create_zone(name='example.org.') # Update the Object - domain.name = 'example.net.' + zone.name = 'example.net.' # Perform the update - domain = self.storage.update_domain(self.admin_context, domain) + zone = self.storage.update_zone(self.admin_context, zone) # Ensure the new valie took - self.assertEqual('example.net.', domain.name) + self.assertEqual('example.net.', zone.name) # Ensure the version column was incremented - self.assertEqual(2, domain.version) + self.assertEqual(2, zone.version) - def test_update_domain_duplicate(self): - # Create two domains - domain_one = self.create_domain(fixture=0) - domain_two = self.create_domain(fixture=1) + def test_update_zone_duplicate(self): + # Create two zones + zone_one = self.create_zone(fixture=0) + zone_two = self.create_zone(fixture=1) # Update the D2 object to be a duplicate of D1 - domain_two.name = domain_one.name + zone_two.name = zone_one.name - with testtools.ExpectedException(exceptions.DuplicateDomain): - self.storage.update_domain(self.admin_context, domain_two) + with testtools.ExpectedException(exceptions.DuplicateZone): + self.storage.update_zone(self.admin_context, zone_two) - def test_update_domain_missing(self): - domain = objects.Domain(id='caf771fc-6b05-4891-bee1-c2a48621f57b') - with testtools.ExpectedException(exceptions.DomainNotFound): - self.storage.update_domain(self.admin_context, domain) + def test_update_zone_missing(self): + zone = objects.Zone(id='caf771fc-6b05-4891-bee1-c2a48621f57b') + with testtools.ExpectedException(exceptions.ZoneNotFound): + self.storage.update_zone(self.admin_context, zone) - def test_delete_domain(self): - domain = self.create_domain() + def test_delete_zone(self): + zone = self.create_zone() - self.storage.delete_domain(self.admin_context, domain['id']) + self.storage.delete_zone(self.admin_context, zone['id']) - with testtools.ExpectedException(exceptions.DomainNotFound): - self.storage.get_domain(self.admin_context, domain['id']) + with testtools.ExpectedException(exceptions.ZoneNotFound): + self.storage.get_zone(self.admin_context, zone['id']) - def test_delete_domain_missing(self): - with testtools.ExpectedException(exceptions.DomainNotFound): + def test_delete_zone_missing(self): + with testtools.ExpectedException(exceptions.ZoneNotFound): uuid = 'caf771fc-6b05-4891-bee1-c2a48621f57b' - self.storage.delete_domain(self.admin_context, uuid) + self.storage.delete_zone(self.admin_context, uuid) - def test_count_domains(self): + def test_count_zones(self): # in the beginning, there should be nothing - domains = self.storage.count_domains(self.admin_context) - self.assertEqual(0, domains) + zones = self.storage.count_zones(self.admin_context) + self.assertEqual(0, zones) - # Create a single domain - self.create_domain() + # Create a single zone + self.create_zone() # count 'em up - domains = self.storage.count_domains(self.admin_context) + zones = self.storage.count_zones(self.admin_context) # well, did we get 1? - self.assertEqual(1, domains) + self.assertEqual(1, zones) - def test_count_domains_none_result(self): + def test_count_zones_none_result(self): rp = mock.Mock() rp.fetchone.return_value = None with mock.patch.object(self.storage.session, 'execute', return_value=rp): - domains = self.storage.count_domains(self.admin_context) - self.assertEqual(0, domains) + zones = self.storage.count_zones(self.admin_context) + self.assertEqual(0, zones) def test_create_recordset(self): - domain = self.create_domain() + zone = self.create_zone() values = { - 'name': 'www.%s' % domain['name'], + 'name': 'www.%s' % zone['name'], 'type': 'A' } result = self.storage.create_recordset( self.admin_context, - domain['id'], + zone['id'], recordset=objects.RecordSet.from_dict(values)) self.assertIsNotNone(result['id']) @@ -798,20 +798,20 @@ class StorageTestCase(object): self.assertEqual(values['type'], result['type']) def test_create_recordset_duplicate(self): - domain = self.create_domain() + zone = self.create_zone() # Create the First RecordSet - self.create_recordset(domain) + self.create_recordset(zone) with testtools.ExpectedException(exceptions.DuplicateRecordSet): # Attempt to create the second/duplicate recordset - self.create_recordset(domain) + self.create_recordset(zone) def test_create_recordset_with_records(self): - domain = self.create_domain() + zone = self.create_zone() recordset = objects.RecordSet( - name='www.%s' % domain['name'], + name='www.%s' % zone['name'], type='A', records=objects.RecordList(objects=[ objects.Record(data='192.0.2.1'), @@ -820,7 +820,7 @@ class StorageTestCase(object): ) recordset = self.storage.create_recordset( - self.admin_context, domain['id'], recordset) + self.admin_context, zone['id'], recordset) # Ensure recordset.records is a RecordList instance self.assertIsInstance(recordset.records, objects.RecordList) @@ -835,15 +835,15 @@ class StorageTestCase(object): self.assertIsNotNone(recordset.records[1].id) def test_find_recordsets(self): - domain = self.create_domain() + zone = self.create_zone() - criterion = {'domain_id': domain['id']} + criterion = {'zone_id': zone['id']} actual = self.storage.find_recordsets(self.admin_context, criterion) self.assertEqual(2, len(actual)) # Create a single recordset - recordset_one = self.create_recordset(domain) + recordset_one = self.create_recordset(zone) actual = self.storage.find_recordsets(self.admin_context, criterion) self.assertEqual(3, len(actual)) @@ -852,18 +852,18 @@ class StorageTestCase(object): self.assertEqual(recordset_one['type'], actual[2]['type']) def test_find_recordsets_paging(self): - domain = self.create_domain(name='example.org.') + zone = self.create_zone(name='example.org.') # Create 10 RecordSets - created = [self.create_recordset(domain, name='r-%d.example.org.' % i) + created = [self.create_recordset(zone, name='r-%d.example.org.' % i) for i in range(10)] # Add in the SOA and NS recordsets that are automatically created soa = self.storage.find_recordset(self.admin_context, - criterion={'domain_id': domain['id'], + criterion={'zone_id': zone['id'], 'type': "SOA"}) ns = self.storage.find_recordset(self.admin_context, - criterion={'domain_id': domain['id'], + criterion={'zone_id': zone['id'], 'type': "NS"}) created.insert(0, ns) created.insert(0, soa) @@ -872,13 +872,13 @@ class StorageTestCase(object): self._ensure_paging(created, self.storage.find_recordsets) def test_find_recordsets_criterion(self): - domain = self.create_domain() + zone = self.create_zone() - recordset_one = self.create_recordset(domain, type='A', fixture=0) - self.create_recordset(domain, fixture=1) + recordset_one = self.create_recordset(zone, type='A', fixture=0) + self.create_recordset(zone, fixture=1) criterion = dict( - domain_id=domain['id'], + zone_id=zone['id'], name=recordset_one['name'], ) @@ -888,7 +888,7 @@ class StorageTestCase(object): self.assertEqual(1, len(results)) criterion = dict( - domain_id=domain['id'], + zone_id=zone['id'], type='A', ) @@ -898,15 +898,15 @@ class StorageTestCase(object): self.assertEqual(2, len(results)) def test_find_recordsets_criterion_wildcard(self): - domain = self.create_domain() + zone = self.create_zone() - values = {'name': 'one.%s' % domain['name']} + values = {'name': 'one.%s' % zone['name']} - self.create_recordset(domain, **values) + self.create_recordset(zone, **values) criterion = dict( - domain_id=domain['id'], - name="%%%(name)s" % {"name": domain['name']}, + zone_id=zone['id'], + name="%%%(name)s" % {"name": zone['name']}, ) results = self.storage.find_recordsets(self.admin_context, criterion) @@ -915,7 +915,7 @@ class StorageTestCase(object): self.assertEqual(3, len(results)) def test_find_recordsets_with_records(self): - domain = self.create_domain() + zone = self.create_zone() records = [ {"data": "10.0.0.1"}, @@ -923,7 +923,7 @@ class StorageTestCase(object): {"data": "10.0.0.3"} ] - recordset = self.create_recordset(domain, records=records) + recordset = self.create_recordset(zone, records=records) criterion = dict( id=recordset.id, @@ -950,8 +950,8 @@ class StorageTestCase(object): records.append(record) def test_get_recordset(self): - domain = self.create_domain() - expected = self.create_recordset(domain) + zone = self.create_zone() + expected = self.create_recordset(zone) actual = self.storage.get_recordset(self.admin_context, expected['id']) @@ -959,12 +959,12 @@ class StorageTestCase(object): self.assertEqual(expected['type'], actual['type']) def test_get_recordset_with_records(self): - domain = self.create_domain() - recordset = self.create_recordset(domain) + zone = self.create_zone() + recordset = self.create_recordset(zone) # Create two Records in the RecordSet - self.create_record(domain, recordset) - self.create_record(domain, recordset, fixture=1) + self.create_record(zone, recordset) + self.create_record(zone, recordset, fixture=1) # Fetch the RecordSet again recordset = self.storage.get_recordset( @@ -984,11 +984,11 @@ class StorageTestCase(object): self.storage.get_recordset(self.admin_context, uuid) def test_find_recordset_criterion(self): - domain = self.create_domain() - expected = self.create_recordset(domain) + zone = self.create_zone() + expected = self.create_recordset(zone) criterion = dict( - domain_id=domain['id'], + zone_id=zone['id'], name=expected['name'], ) @@ -998,8 +998,8 @@ class StorageTestCase(object): self.assertEqual(expected['type'], actual['type']) def test_find_recordset_criterion_missing(self): - domain = self.create_domain() - expected = self.create_recordset(domain) + zone = self.create_zone() + expected = self.create_recordset(zone) criterion = dict( name=expected['name'] + "NOT FOUND" @@ -1009,12 +1009,12 @@ class StorageTestCase(object): self.storage.find_recordset(self.admin_context, criterion) def test_find_recordset_criterion_with_records(self): - domain = self.create_domain() - recordset = self.create_recordset(domain) + zone = self.create_zone() + recordset = self.create_recordset(zone) # Create two Records in the RecordSet - self.create_record(domain, recordset) - self.create_record(domain, recordset, fixture=1) + self.create_record(zone, recordset) + self.create_record(zone, recordset, fixture=1) criterion = dict( id=recordset.id, @@ -1032,10 +1032,10 @@ class StorageTestCase(object): self.assertIsInstance(recordset.records[1], objects.Record) def test_update_recordset(self): - domain = self.create_domain() + zone = self.create_zone() # Create a recordset - recordset = self.create_recordset(domain) + recordset = self.create_recordset(zone) # Update the Object recordset.ttl = 1800 @@ -1054,11 +1054,11 @@ class StorageTestCase(object): self.assertEqual(2, recordset.version) def test_update_recordset_duplicate(self): - domain = self.create_domain() + zone = self.create_zone() # Create two recordsets - recordset_one = self.create_recordset(domain, type='A') - recordset_two = self.create_recordset(domain, type='A', fixture=1) + recordset_one = self.create_recordset(zone, type='A') + recordset_two = self.create_recordset(zone, type='A', fixture=1) # Update the R2 object to be a duplicate of R1 recordset_two.name = recordset_one.name @@ -1074,10 +1074,10 @@ class StorageTestCase(object): self.storage.update_recordset(self.admin_context, recordset) def test_update_recordset_with_record_create(self): - domain = self.create_domain() + zone = self.create_zone() # Create a RecordSet - recordset = self.create_recordset(domain, 'A') + recordset = self.create_recordset(zone, 'A') # Append two new Records recordset.records.append(objects.Record(data='192.0.2.1')) @@ -1100,12 +1100,12 @@ class StorageTestCase(object): self.assertIsNotNone(recordset.records[1].id) def test_update_recordset_with_record_delete(self): - domain = self.create_domain() + zone = self.create_zone() # Create a RecordSet and two Records - recordset = self.create_recordset(domain, 'A') - self.create_record(domain, recordset) - self.create_record(domain, recordset, fixture=1) + recordset = self.create_recordset(zone, 'A') + self.create_record(zone, recordset) + self.create_record(zone, recordset, fixture=1) # Fetch the RecordSet again recordset = self.storage.get_recordset( @@ -1129,12 +1129,12 @@ class StorageTestCase(object): self.assertIsInstance(recordset.records[0], objects.Record) def test_update_recordset_with_record_update(self): - domain = self.create_domain() + zone = self.create_zone() # Create a RecordSet and two Records - recordset = self.create_recordset(domain, 'A') - self.create_record(domain, recordset) - self.create_record(domain, recordset, fixture=1) + recordset = self.create_recordset(zone, 'A') + self.create_record(zone, recordset) + self.create_record(zone, recordset, fixture=1) # Fetch the RecordSet again recordset = self.storage.get_recordset( @@ -1162,10 +1162,10 @@ class StorageTestCase(object): raise Exception('Updated record not found') def test_delete_recordset(self): - domain = self.create_domain() + zone = self.create_zone() # Create a recordset - recordset = self.create_recordset(domain) + recordset = self.create_recordset(zone) self.storage.delete_recordset(self.admin_context, recordset['id']) @@ -1182,16 +1182,16 @@ class StorageTestCase(object): recordsets = self.storage.count_recordsets(self.admin_context) self.assertEqual(0, recordsets) - # Create a single domain & recordset - domain = self.create_domain() - self.create_recordset(domain) + # Create a single zone & recordset + zone = self.create_zone() + self.create_recordset(zone) # we should have 3 recordsets now, including SOA & NS recordsets = self.storage.count_recordsets(self.admin_context) self.assertEqual(3, recordsets) - # Delete the domain, we should be back to 0 recordsets - self.storage.delete_domain(self.admin_context, domain.id) + # Delete the zone, we should be back to 0 recordsets + self.storage.delete_zone(self.admin_context, zone.id) recordsets = self.storage.count_recordsets(self.admin_context) self.assertEqual(0, recordsets) @@ -1204,15 +1204,15 @@ class StorageTestCase(object): self.assertEqual(0, recordsets) def test_create_record(self): - domain = self.create_domain() - recordset = self.create_recordset(domain, type='A') + zone = self.create_zone() + recordset = self.create_recordset(zone, type='A') values = { 'data': '192.0.2.1', } result = self.storage.create_record( - self.admin_context, domain['id'], recordset['id'], + self.admin_context, zone['id'], recordset['id'], objects.Record.from_dict(values)) self.assertIsNotNone(result['id']) @@ -1225,22 +1225,22 @@ class StorageTestCase(object): self.assertIn('status', result) def test_create_record_duplicate(self): - domain = self.create_domain() - recordset = self.create_recordset(domain) + zone = self.create_zone() + recordset = self.create_recordset(zone) # Create the First Record - self.create_record(domain, recordset) + self.create_record(zone, recordset) with testtools.ExpectedException(exceptions.DuplicateRecord): # Attempt to create the second/duplicate record - self.create_record(domain, recordset) + self.create_record(zone, recordset) def test_find_records(self): - domain = self.create_domain() - recordset = self.create_recordset(domain) + zone = self.create_zone() + recordset = self.create_recordset(zone) criterion = { - 'domain_id': domain['id'], + 'zone_id': zone['id'], 'recordset_id': recordset['id'] } @@ -1248,7 +1248,7 @@ class StorageTestCase(object): self.assertEqual(0, len(actual)) # Create a single record - record = self.create_record(domain, recordset) + record = self.create_record(zone, recordset) actual = self.storage.find_records(self.admin_context, criterion) self.assertEqual(1, len(actual)) @@ -1257,19 +1257,19 @@ class StorageTestCase(object): self.assertIn('status', record) def test_find_records_paging(self): - domain = self.create_domain() - recordset = self.create_recordset(domain, type='A') + zone = self.create_zone() + recordset = self.create_recordset(zone, type='A') # Create 10 Records - created = [self.create_record(domain, recordset, data='192.0.2.%d' % i) + created = [self.create_record(zone, recordset, data='192.0.2.%d' % i) for i in range(10)] # Add in the SOA and NS records that are automatically created soa = self.storage.find_recordset(self.admin_context, - criterion={'domain_id': domain['id'], + criterion={'zone_id': zone['id'], 'type': "SOA"}) ns = self.storage.find_recordset(self.admin_context, - criterion={'domain_id': domain['id'], + criterion={'zone_id': zone['id'], 'type': "NS"}) for r in ns['records']: created.insert(0, r) @@ -1279,15 +1279,15 @@ class StorageTestCase(object): self._ensure_paging(created, self.storage.find_records) def test_find_records_criterion(self): - domain = self.create_domain() - recordset = self.create_recordset(domain, type='A') + zone = self.create_zone() + recordset = self.create_recordset(zone, type='A') - record_one = self.create_record(domain, recordset) - self.create_record(domain, recordset, fixture=1) + record_one = self.create_record(zone, recordset) + self.create_record(zone, recordset, fixture=1) criterion = dict( data=record_one['data'], - domain_id=domain['id'], + zone_id=zone['id'], recordset_id=recordset['id'], ) @@ -1295,7 +1295,7 @@ class StorageTestCase(object): self.assertEqual(1, len(results)) criterion = dict( - domain_id=domain['id'], + zone_id=zone['id'], recordset_id=recordset['id'], ) @@ -1304,15 +1304,15 @@ class StorageTestCase(object): self.assertEqual(2, len(results)) def test_find_records_criterion_wildcard(self): - domain = self.create_domain() - recordset = self.create_recordset(domain, type='A') + zone = self.create_zone() + recordset = self.create_recordset(zone, type='A') values = {'data': '127.0.0.1'} - self.create_record(domain, recordset, **values) + self.create_record(zone, recordset, **values) criterion = dict( - domain_id=domain['id'], + zone_id=zone['id'], recordset_id=recordset['id'], data="%.0.0.1", ) @@ -1333,20 +1333,20 @@ class StorageTestCase(object): at_context = self.get_admin_context() at_context.all_tenants = True - # Create two domains in different tenants, and 1 record in each - domain_one = self.create_domain(fixture=0, context=one_context) - recordset_one = self.create_recordset(domain_one, fixture=0, + # Create two zones in different tenants, and 1 record in each + zone_one = self.create_zone(fixture=0, context=one_context) + recordset_one = self.create_recordset(zone_one, fixture=0, context=one_context) - self.create_record(domain_one, recordset_one, context=one_context) + self.create_record(zone_one, recordset_one, context=one_context) - domain_two = self.create_domain(fixture=1, context=two_context) - recordset_one = self.create_recordset(domain_two, fixture=1, + zone_two = self.create_zone(fixture=1, context=two_context) + recordset_one = self.create_recordset(zone_two, fixture=1, context=two_context) - self.create_record(domain_two, recordset_one, context=two_context) + self.create_record(zone_two, recordset_one, context=two_context) # Ensure the all_tenants context see's two records - # Plus the SOA & NS in each of 2 domains = 6 records total + # Plus the SOA & NS in each of 2 zones = 6 records total results = self.storage.find_records(at_context) self.assertEqual(6, len(results)) @@ -1363,10 +1363,10 @@ class StorageTestCase(object): self.assertEqual(3, len(results)) def test_get_record(self): - domain = self.create_domain() - recordset = self.create_recordset(domain) + zone = self.create_zone() + recordset = self.create_recordset(zone) - expected = self.create_record(domain, recordset) + expected = self.create_record(zone, recordset) actual = self.storage.get_record(self.admin_context, expected['id']) @@ -1379,13 +1379,13 @@ class StorageTestCase(object): self.storage.get_record(self.admin_context, uuid) def test_find_record_criterion(self): - domain = self.create_domain() - recordset = self.create_recordset(domain) + zone = self.create_zone() + recordset = self.create_recordset(zone) - expected = self.create_record(domain, recordset) + expected = self.create_record(zone, recordset) criterion = dict( - domain_id=domain['id'], + zone_id=zone['id'], recordset_id=recordset['id'], data=expected['data'], ) @@ -1396,13 +1396,13 @@ class StorageTestCase(object): self.assertIn('status', actual) def test_find_record_criterion_missing(self): - domain = self.create_domain() - recordset = self.create_recordset(domain) + zone = self.create_zone() + recordset = self.create_recordset(zone) - expected = self.create_record(domain, recordset) + expected = self.create_record(zone, recordset) criterion = dict( - domain_id=domain['id'], + zone_id=zone['id'], data=expected['data'] + "NOT FOUND", ) @@ -1410,11 +1410,11 @@ class StorageTestCase(object): self.storage.find_record(self.admin_context, criterion) def test_update_record(self): - domain = self.create_domain() - recordset = self.create_recordset(domain, type='A') + zone = self.create_zone() + recordset = self.create_recordset(zone, type='A') # Create a record - record = self.create_record(domain, recordset) + record = self.create_record(zone, recordset) # Update the Object record.data = '192.0.2.255' @@ -1429,12 +1429,12 @@ class StorageTestCase(object): self.assertEqual(2, record.version) def test_update_record_duplicate(self): - domain = self.create_domain() - recordset = self.create_recordset(domain) + zone = self.create_zone() + recordset = self.create_recordset(zone) # Create two records - record_one = self.create_record(domain, recordset) - record_two = self.create_record(domain, recordset, fixture=1) + record_one = self.create_record(zone, recordset) + record_two = self.create_record(zone, recordset, fixture=1) # Update the R2 object to be a duplicate of R1 record_two.data = record_one.data @@ -1449,11 +1449,11 @@ class StorageTestCase(object): self.storage.update_record(self.admin_context, record) def test_delete_record(self): - domain = self.create_domain() - recordset = self.create_recordset(domain) + zone = self.create_zone() + recordset = self.create_recordset(zone) # Create a record - record = self.create_record(domain, recordset) + record = self.create_record(zone, recordset) self.storage.delete_record(self.admin_context, record['id']) @@ -1470,17 +1470,17 @@ class StorageTestCase(object): records = self.storage.count_records(self.admin_context) self.assertEqual(0, records) - # Create a single domain & record - domain = self.create_domain() - recordset = self.create_recordset(domain) - self.create_record(domain, recordset) + # Create a single zone & record + zone = self.create_zone() + recordset = self.create_recordset(zone) + self.create_record(zone, recordset) # we should have 3 records now, including NS and SOA records = self.storage.count_records(self.admin_context) self.assertEqual(3, records) - # Delete the domain, we should be back to 0 records - self.storage.delete_domain(self.admin_context, domain.id) + # Delete the zone, we should be back to 0 records + self.storage.delete_zone(self.admin_context, zone.id) records = self.storage.count_records(self.admin_context) self.assertEqual(0, records) @@ -1972,11 +1972,11 @@ class StorageTestCase(object): self.storage.delete_pool(self.admin_context, uuid) def test_create_zone_transfer_request(self): - domain = self.create_domain() + zone = self.create_zone() values = { 'tenant_id': self.admin_context.tenant, - 'domain_id': domain.id, + 'zone_id': zone.id, 'key': 'qwertyuiop' } @@ -1987,13 +1987,13 @@ class StorageTestCase(object): self.assertIn('status', result) def test_create_zone_transfer_request_scoped(self): - domain = self.create_domain() + zone = self.create_zone() tenant_2_context = self.get_context(tenant='2') tenant_3_context = self.get_context(tenant='3') values = { 'tenant_id': self.admin_context.tenant, - 'domain_id': domain.id, + 'zone_id': zone.id, 'key': 'qwertyuiop', 'target_tenant_id': tenant_2_context.tenant, } @@ -2021,11 +2021,11 @@ class StorageTestCase(object): tenant_3_context, result.id) def test_find_zone_transfer_requests(self): - domain = self.create_domain() + zone = self.create_zone() values = { 'tenant_id': self.admin_context.tenant, - 'domain_id': domain.id, + 'zone_id': zone.id, 'key': 'qwertyuiop' } @@ -2037,8 +2037,8 @@ class StorageTestCase(object): self.assertEqual(1, len(requests)) def test_delete_zone_transfer_request(self): - domain = self.create_domain() - zt_request = self.create_zone_transfer_request(domain) + zone = self.create_zone() + zt_request = self.create_zone_transfer_request(zone) self.storage.delete_zone_transfer_request( self.admin_context, zt_request.id) @@ -2049,8 +2049,8 @@ class StorageTestCase(object): self.admin_context, zt_request.id) def test_update_zone_transfer_request(self): - domain = self.create_domain() - zt_request = self.create_zone_transfer_request(domain) + zone = self.create_zone() + zt_request = self.create_zone_transfer_request(zone) zt_request.description = 'New description' result = self.storage.update_zone_transfer_request( @@ -2058,21 +2058,21 @@ class StorageTestCase(object): self.assertEqual('New description', result.description) def test_get_zone_transfer_request(self): - domain = self.create_domain() - zt_request = self.create_zone_transfer_request(domain) + zone = self.create_zone() + zt_request = self.create_zone_transfer_request(zone) result = self.storage.get_zone_transfer_request( self.admin_context, zt_request.id) self.assertEqual(zt_request.id, result.id) - self.assertEqual(zt_request.domain_id, result.domain_id) + self.assertEqual(zt_request.zone_id, result.zone_id) def test_create_zone_transfer_accept(self): - domain = self.create_domain() - zt_request = self.create_zone_transfer_request(domain) + zone = self.create_zone() + zt_request = self.create_zone_transfer_request(zone) values = { 'tenant_id': self.admin_context.tenant, 'zone_transfer_request_id': zt_request.id, - 'domain_id': domain.id, + 'zone_id': zone.id, 'key': zt_request.key } @@ -2087,12 +2087,12 @@ class StorageTestCase(object): self.assertIn('status', result) def test_find_zone_transfer_accepts(self): - domain = self.create_domain() - zt_request = self.create_zone_transfer_request(domain) + zone = self.create_zone() + zt_request = self.create_zone_transfer_request(zone) values = { 'tenant_id': self.admin_context.tenant, 'zone_transfer_request_id': zt_request.id, - 'domain_id': domain.id, + 'zone_id': zone.id, 'key': zt_request.key } @@ -2104,12 +2104,12 @@ class StorageTestCase(object): self.assertEqual(1, len(accepts)) def test_find_zone_transfer_accept(self): - domain = self.create_domain() - zt_request = self.create_zone_transfer_request(domain) + zone = self.create_zone() + zt_request = self.create_zone_transfer_request(zone) values = { 'tenant_id': self.admin_context.tenant, 'zone_transfer_request_id': zt_request.id, - 'domain_id': domain.id, + 'zone_id': zone.id, 'key': zt_request.key } @@ -2126,32 +2126,32 @@ class StorageTestCase(object): admin_context = self.get_admin_context() admin_context.all_tenants = True - domain = self.create_domain(context=tenant_1_context) - recordset = self.create_recordset(domain, context=tenant_1_context) + zone = self.create_zone(context=tenant_1_context) + recordset = self.create_recordset(zone, context=tenant_1_context) record = self.create_record( - domain, recordset, context=tenant_1_context) + zone, recordset, context=tenant_1_context) - updated_domain = domain + updated_zone = zone - updated_domain.tenant_id = tenant_2_context.tenant + updated_zone.tenant_id = tenant_2_context.tenant - self.storage.update_domain( - admin_context, updated_domain) + self.storage.update_zone( + admin_context, updated_zone) - saved_domain = self.storage.get_domain( - admin_context, domain.id) + saved_zone = self.storage.get_zone( + admin_context, zone.id) saved_recordset = self.storage.get_recordset( admin_context, recordset.id) saved_record = self.storage.get_record( admin_context, record.id) - self.assertEqual(tenant_2_context.tenant, saved_domain.tenant_id) + self.assertEqual(tenant_2_context.tenant, saved_zone.tenant_id) self.assertEqual(tenant_2_context.tenant, saved_recordset.tenant_id) self.assertEqual(tenant_2_context.tenant, saved_record.tenant_id) def test_delete_zone_transfer_accept(self): - domain = self.create_domain() - zt_request = self.create_zone_transfer_request(domain) + zone = self.create_zone() + zt_request = self.create_zone_transfer_request(zone) zt_accept = self.create_zone_transfer_accept(zt_request) self.storage.delete_zone_transfer_accept( @@ -2163,8 +2163,8 @@ class StorageTestCase(object): self.admin_context, zt_accept.id) def test_update_zone_transfer_accept(self): - domain = self.create_domain() - zt_request = self.create_zone_transfer_request(domain) + zone = self.create_zone() + zt_request = self.create_zone_transfer_request(zone) zt_accept = self.create_zone_transfer_accept(zt_request) zt_accept.status = 'COMPLETE' @@ -2173,14 +2173,14 @@ class StorageTestCase(object): self.assertEqual('COMPLETE', result.status) def test_get_zone_transfer_accept(self): - domain = self.create_domain() - zt_request = self.create_zone_transfer_request(domain) + zone = self.create_zone() + zt_request = self.create_zone_transfer_request(zone) zt_accept = self.create_zone_transfer_accept(zt_request) result = self.storage.get_zone_transfer_accept( self.admin_context, zt_accept.id) self.assertEqual(zt_accept.id, result.id) - self.assertEqual(zt_accept.domain_id, result.domain_id) + self.assertEqual(zt_accept.zone_id, result.zone_id) # PoolAttribute tests def test_create_pool_attribute(self): @@ -2369,7 +2369,7 @@ class StorageTestCase(object): self.assertIsNone(result['updated_at']) self.assertIsNotNone(result['version']) self.assertEqual(values['status'], result['status']) - self.assertIsNone(result['domain_id']) + self.assertIsNone(result['zone_id']) self.assertIsNone(result['message']) def test_find_zone_imports(self): @@ -2385,7 +2385,7 @@ class StorageTestCase(object): self.assertEqual(zone_import['status'], actual[0]['status']) self.assertEqual(zone_import['message'], actual[0]['message']) - self.assertEqual(zone_import['domain_id'], actual[0]['domain_id']) + self.assertEqual(zone_import['zone_id'], actual[0]['zone_id']) def test_find_zone_imports_paging(self): # Create 10 ZoneImports diff --git a/designate/tests/test_zone_manager/test_tasks.py b/designate/tests/test_zone_manager/test_tasks.py index a67e323c..72e96c6e 100644 --- a/designate/tests/test_zone_manager/test_tasks.py +++ b/designate/tests/test_zone_manager/test_tasks.py @@ -37,38 +37,38 @@ class TaskTest(TestCase): group="service:zone_manager") -class DeletedDomainPurgeTest(TaskTest): +class DeletedzonePurgeTest(TaskTest): def setUp(self): - super(DeletedDomainPurgeTest, self).setUp() + super(DeletedzonePurgeTest, self).setUp() self.config( interval=3600, time_threshold=604800, batch_size=100, - group="zone_manager_task:domain_purge" + group="zone_manager_task:zone_purge" ) self.purge_task_fixture = self.useFixture( - fixtures.ZoneManagerTaskFixture(tasks.DeletedDomainPurgeTask) + fixtures.ZoneManagerTaskFixture(tasks.DeletedZonePurgeTask) ) def _create_deleted_zone(self, name, mock_deletion_time): - # Create a domain and set it as deleted - domain = self.create_domain(name=name) - self._delete_domain(domain, mock_deletion_time) - return domain + # Create a zone and set it as deleted + zone = self.create_zone(name=name) + self._delete_zone(zone, mock_deletion_time) + return zone - def _fetch_all_domains(self): - """Fetch all domains including deleted ones + def _fetch_all_zones(self): + """Fetch all zones including deleted ones """ - query = tables.domains.select() + query = tables.zones.select() return self.central_service.storage.session.execute(query).fetchall() - def _delete_domain(self, domain, mock_deletion_time): - # Set a domain as deleted - zid = domain.id.replace('-', '') - query = tables.domains.update().\ - where(tables.domains.c.id == zid).\ + def _delete_zone(self, zone, mock_deletion_time): + # Set a zone as deleted + zid = zone.id.replace('-', '') + query = tables.zones.update().\ + where(tables.zones.c.id == zid).\ values( action='NONE', deleted=zid, @@ -78,7 +78,7 @@ class DeletedDomainPurgeTest(TaskTest): pxy = self.central_service.storage.session.execute(query) self.assertEqual(1, pxy.rowcount) - return domain + return zone def _create_deleted_zones(self): # Create a number of deleted zones in the past days @@ -97,11 +97,11 @@ class DeletedDomainPurgeTest(TaskTest): def test_purge_zones(self): """Create 18 zones, run zone_manager, check if 7 zones are remaining """ - self.config(quota_domains=1000) + self.config(quota_zones=1000) self._create_deleted_zones() self.purge_task_fixture.task() - zones = self._fetch_all_domains() + zones = self._fetch_all_zones() LOG.info("Number of zones: %d", len(zones)) self.assertEqual(7, len(zones)) diff --git a/designate/tests/unit/test_backend/test_designate.py b/designate/tests/unit/test_backend/test_designate.py index 001ef938..3d2a551e 100644 --- a/designate/tests/unit/test_backend/test_designate.py +++ b/designate/tests/unit/test_backend/test_designate.py @@ -32,7 +32,7 @@ LOG = logging.getLogger(__name__) def create_zone(): id_ = str(uuid.uuid4()) - return objects.Domain( + return objects.Zone( id=id_, name='%s-example.com.' % id_, email='root@example.com', @@ -57,8 +57,8 @@ class DesignateBackendTest(oslotest.base.BaseTestCase): username='user', password='secret', project_name='project', - project_domain_name='project_domain', - user_domain_name='user_domain' + project_zone_name='project_zone', + user_zone_name='user_zone' ) self.target = RoObject({ 'id': '4588652b-50e7-46b9-b688-a9bad40a873e', @@ -83,31 +83,31 @@ class DesignateBackendTest(oslotest.base.BaseTestCase): 'create', 'delete']) self.client.configure_mock(zones=zones) - def test_create_domain(self): + def test_create_zone(self): zone = create_zone() masters = ["%(host)s:%(port)s" % self.target.masters[0]] with patch.object( self.backend, '_get_client', return_value=self.client): - self.backend.create_domain(self.admin_context, zone) + self.backend.create_zone(self.admin_context, zone) self.client.zones.create.assert_called_once_with( zone.name, 'SECONDARY', masters=masters) - def test_delete_domain(self): + def test_delete_zone(self): zone = create_zone() with patch.object( self.backend, '_get_client', return_value=self.client): - self.backend.delete_domain(self.admin_context, zone) + self.backend.delete_zone(self.admin_context, zone) self.client.zones.delete.assert_called_once_with(zone.name) - def test_delete_domain_notfound(self): + def test_delete_zone_notfound(self): zone = create_zone() self.client.delete.side_effect = exceptions.NotFound with patch.object( self.backend, '_get_client', return_value=self.client): - self.backend.delete_domain(self.admin_context, zone) + self.backend.delete_zone(self.admin_context, zone) self.client.zones.delete.assert_called_once_with(zone.name) - def test_delete_domain_exc(self): + def test_delete_zone_exc(self): class Exc(Exception): pass @@ -116,5 +116,5 @@ class DesignateBackendTest(oslotest.base.BaseTestCase): with testtools.ExpectedException(Exc): with patch.object( self.backend, '_get_client', return_value=self.client): - self.backend.delete_domain(self.admin_context, zone) + self.backend.delete_zone(self.admin_context, zone) self.client.zones.delete.assert_called_once_with(zone.name) diff --git a/designate/tests/unit/test_central/test_basic.py b/designate/tests/unit/test_central/test_basic.py index 3d847709..9f9322e0 100644 --- a/designate/tests/unit/test_central/test_basic.py +++ b/designate/tests/unit/test_central/test_basic.py @@ -139,7 +139,7 @@ def mock_out(name): return decorator -class MockDomain(object): +class Mockzone(object): id = 1 name = 'example.org' pool_id = 1 @@ -211,9 +211,9 @@ fx_pool_manager = fixtures.MockPatch( 'designate.central.service.pool_manager_rpcapi.Pool' 'ManagerAPI.get_instance', mock.MagicMock(spec_set=[ - 'create_domain', - 'update_domain', - 'delete_domain' + 'create_zone', + 'update_zone', + 'delete_zone' ]) ) @@ -233,34 +233,34 @@ class CentralBasic(base.BaseTestCase): self.CONF = self.useFixture(cfg_fixture.Config(cfg.CONF)).conf mock_storage = mock.NonCallableMagicMock(spec_set=[ - 'count_domains', 'count_records', 'count_recordsets', - 'count_tenants', 'create_blacklist', 'create_domain', + 'count_zones', 'count_records', 'count_recordsets', + 'count_tenants', 'create_blacklist', 'create_zone', 'create_pool', 'create_pool_attribute', 'create_quota', 'create_record', 'create_recordset', 'create_tld', 'create_tsigkey', - 'create_zone_task', 'delete_blacklist', 'delete_domain', + 'create_zone_task', 'delete_blacklist', 'delete_zone', 'delete_pool', 'delete_pool_attribute', 'delete_quota', 'delete_record', 'delete_recordset', 'delete_tld', 'delete_tsigkey', 'delete_zone_task', 'find_blacklist', - 'find_blacklists', 'find_domain', 'find_domains', 'find_pool', + 'find_blacklists', 'find_zone', 'find_zones', 'find_pool', 'find_pool_attribute', 'find_pool_attributes', 'find_pools', 'find_quota', 'find_quotas', 'find_record', 'find_records', 'find_recordset', 'find_recordsets', 'find_recordsets_axfr', 'find_tenants', 'find_tld', 'find_tlds', 'find_tsigkeys', 'find_zone_task', 'find_zone_tasks', 'get_blacklist', - 'get_canonical_name', 'get_cfg_opts', 'get_domain', 'get_driver', + 'get_canonical_name', 'get_cfg_opts', 'get_zone', 'get_driver', 'get_extra_cfg_opts', 'get_plugin_name', 'get_plugin_type', 'get_pool', 'get_pool_attribute', 'get_quota', 'get_record', 'get_recordset', 'get_tenant', 'get_tld', 'get_tsigkey', 'get_zone_task', 'ping', 'register_cfg_opts', - 'register_extra_cfg_opts', 'update_blacklist', 'update_domain', + 'register_extra_cfg_opts', 'update_blacklist', 'update_zone', 'update_pool', 'update_pool_attribute', 'update_quota', 'update_record', 'update_recordset', 'update_tld', 'update_tsigkey', 'update_zone_task', 'commit', 'begin', 'rollback', ]) attrs = { - 'count_domains.return_value': 0, - 'find_domain.return_value': MockDomain(), + 'count_zones.return_value': 0, + 'find_zone.return_value': Mockzone(), 'get_pool.return_value': MockPool(), 'begin.return_value': None, } @@ -346,26 +346,26 @@ class CentralServiceTestCase(CentralBasic): mock_soa = RoObject(records=[MockRecord()]) self.context.elevated = mock.Mock() - self.service._update_domain_in_storage = mock.Mock() + self.service._update_zone_in_storage = mock.Mock() self.service.storage.get_pool = mock.Mock(return_value=MockPool()) self.service.find_recordset = mock.Mock(return_value=mock_soa) self.service._build_soa_record = mock.Mock() self.service._update_recordset_in_storage = mock.Mock() - self.service._update_soa(self.context, MockDomain()) + self.service._update_soa(self.context, Mockzone()) self.assertTrue(self.service._update_recordset_in_storage.called) self.assertTrue(self.context.elevated.called) - def test_count_domains(self): - self.service.count_domains(self.context) - self.service.storage.count_domains.assert_called_once_with( + def test_count_zones(self): + self.service.count_zones(self.context) + self.service.storage.count_zones.assert_called_once_with( self.context, {} ) - def test_count_domains_criterion(self): - self.service.count_domains(self.context, criterion={'a': 1}) - self.service.storage.count_domains.assert_called_once_with( + def test_count_zones_criterion(self): + self.service.count_zones(self.context, criterion={'a': 1}) + self.service.storage.count_zones.assert_called_once_with( self.context, {'a': 1} ) @@ -374,15 +374,15 @@ class CentralServiceTestCase(CentralBasic): self.service._is_valid_ttl = mock.Mock() self.service._is_valid_recordset_name = mock.Mock() self.service._is_valid_recordset_placement = mock.Mock() - self.service._is_valid_recordset_placement_subdomain = mock.Mock() + self.service._is_valid_recordset_placement_subzone = mock.Mock() self.service.storage.create_recordset = mock.Mock(return_value='rs') - self.service._update_domain_in_storage = mock.Mock() + self.service._update_zone_in_storage = mock.Mock() - rs, domain = self.service._create_recordset_in_storage( - self.context, MockDomain(), MockRecordSet() + rs, zone = self.service._create_recordset_in_storage( + self.context, Mockzone(), MockRecordSet() ) self.assertEqual(rs, 'rs') - self.assertFalse(self.service._update_domain_in_storage.called) + self.assertFalse(self.service._update_zone_in_storage.called) def test__create_soa(self): self.service._create_recordset_in_storage = Mock( @@ -391,7 +391,7 @@ class CentralServiceTestCase(CentralBasic): self.service._build_soa_record = Mock( return_value='example.org. foo.bar 1 60 5 999 1' ) - zone = MockDomain() + zone = Mockzone() self.service._create_soa(self.context, zone) ctx, md, rset = self.service._create_recordset_in_storage.call_args[0] @@ -402,54 +402,54 @@ class CentralServiceTestCase(CentralBasic): self.assertEqual(1, len(rset.records.objects)) self.assertTrue(rset.records.objects[0].managed) - def test__create_domain_in_storage(self): + def test__create_zone_in_storage(self): self.service._create_soa = Mock() self.service._create_ns = Mock() - self.service.get_domain_servers = Mock( + self.service.get_zone_ns_records = Mock( return_value=[RoObject(hostname='host_foo')] ) - def cr_dom(ctx, domain): - return domain + def cr_dom(ctx, zone): + return zone - self.service.storage.create_domain = cr_dom + self.service.storage.create_zone = cr_dom - domain = self.service._create_domain_in_storage( - self.context, MockDomain() + zone = self.service._create_zone_in_storage( + self.context, Mockzone() ) - self.assertEqual('PENDING', domain.status) - self.assertEqual('CREATE', domain.action) - ctx, domain, hostnames = self.service._create_ns.call_args[0] + self.assertEqual('PENDING', zone.status) + self.assertEqual('CREATE', zone.action) + ctx, zone, hostnames = self.service._create_ns.call_args[0] self.assertEqual(['host_foo'], hostnames) @unittest.expectedFailure # FIXME - def test_create_domain_forbidden(self): - assert not self.service.storage.count_domains.called + def test_create_zone_forbidden(self): + assert not self.service.storage.count_zones.called designate.central.service.policy.check = mock.Mock(return_value=None) - self.service._enforce_domain_quota = mock.Mock(return_value=None) - self.service._is_valid_domain_name = mock.Mock(return_value=None) + self.service._enforce_zone_quota = mock.Mock(return_value=None) + self.service._is_valid_zone_name = mock.Mock(return_value=None) self.service._is_valid_ttl = mock.Mock(return_value=True) - self.service._is_subdomain = Mock() - self.service._create_domain_in_storage = mock.Mock( - return_value=MockDomain() + self.service._is_subzone = Mock() + self.service._create_zone_in_storage = mock.Mock( + return_value=Mockzone() ) - self.service.storage.find_domain(self.context, {}) + self.service.storage.find_zone(self.context, {}) - parent_domain = self.service._is_subdomain( + parent_zone = self.service._is_subzone( self.context, 'bogusname', 1234) - # self.assertEqual('', parent_domain) + # self.assertEqual('', parent_zone) self.service.check_for_tlds = False with testtools.ExpectedException(exceptions.Forbidden): - self.service.create_domain(self.context, MockDomain()) + self.service.create_zone(self.context, Mockzone()) - # TODO(Federico) add more create_domain tests - assert parent_domain + # TODO(Federico) add more create_zone tests + assert parent_zone -class CentralDomainTestCase(CentralBasic): +class CentralzoneTestCase(CentralBasic): def setUp(self): - super(CentralDomainTestCase, self).setUp() + super(CentralzoneTestCase, self).setUp() def storage_find_tld(c, d): if d['name'] not in ('org',): @@ -457,37 +457,37 @@ class CentralDomainTestCase(CentralBasic): self.service.storage.find_tld = storage_find_tld - def test__is_valid_domain_name_valid(self): - self.service._is_blacklisted_domain_name = Mock() - self.service._is_valid_domain_name(self.context, 'valid.org.') + def test__is_valid_zone_name_valid(self): + self.service._is_blacklisted_zone_name = Mock() + self.service._is_valid_zone_name(self.context, 'valid.org.') - def test__is_valid_domain_name_invalid(self): - self.service._is_blacklisted_domain_name = Mock() - with testtools.ExpectedException(exceptions.InvalidDomainName): - self.service._is_valid_domain_name(self.context, 'example^org.') + def test__is_valid_zone_name_invalid(self): + self.service._is_blacklisted_zone_name = Mock() + with testtools.ExpectedException(exceptions.InvalidZoneName): + self.service._is_valid_zone_name(self.context, 'example^org.') - def test__is_valid_domain_name_invalid_2(self): - self.service._is_blacklisted_domain_name = Mock() - with testtools.ExpectedException(exceptions.InvalidDomainName): - self.service._is_valid_domain_name(self.context, 'example.tld.') + def test__is_valid_zone_name_invalid_2(self): + self.service._is_blacklisted_zone_name = Mock() + with testtools.ExpectedException(exceptions.InvalidZoneName): + self.service._is_valid_zone_name(self.context, 'example.tld.') - def test__is_valid_domain_name_invalid_same_as_tld(self): - self.service._is_blacklisted_domain_name = Mock() - with testtools.ExpectedException(exceptions.InvalidDomainName): - self.service._is_valid_domain_name(self.context, 'com.com.') + def test__is_valid_zone_name_invalid_same_as_tld(self): + self.service._is_blacklisted_zone_name = Mock() + with testtools.ExpectedException(exceptions.InvalidZoneName): + self.service._is_valid_zone_name(self.context, 'com.com.') - def test__is_valid_domain_name_invalid_tld(self): - self.service._is_blacklisted_domain_name = Mock() - with testtools.ExpectedException(exceptions.InvalidDomainName): - self.service._is_valid_domain_name(self.context, 'tld.') + def test__is_valid_zone_name_invalid_tld(self): + self.service._is_blacklisted_zone_name = Mock() + with testtools.ExpectedException(exceptions.InvalidZoneName): + self.service._is_valid_zone_name(self.context, 'tld.') - def test__is_valid_domain_name_blacklisted(self): - self.service._is_blacklisted_domain_name = Mock( - side_effect=exceptions.InvalidDomainName) - with testtools.ExpectedException(exceptions.InvalidDomainName): - self.service._is_valid_domain_name(self.context, 'valid.com.') + def test__is_valid_zone_name_blacklisted(self): + self.service._is_blacklisted_zone_name = Mock( + side_effect=exceptions.InvalidZoneName) + with testtools.ExpectedException(exceptions.InvalidZoneName): + self.service._is_valid_zone_name(self.context, 'valid.com.') - def test__is_blacklisted_domain_name(self): + def test__is_blacklisted_zone_name(self): self.service.storage.find_blacklists.return_value = [ RoObject(pattern='a'), RoObject(pattern='b') ] @@ -497,46 +497,46 @@ class CentralDomainTestCase(CentralBasic): ('hi', False), ('', False) ) - for domain, expected in blacklist_tests: + for zone, expected in blacklist_tests: self.assertEqual( - self.service._is_blacklisted_domain_name(self.context, domain), + self.service._is_blacklisted_zone_name(self.context, zone), expected ) def test__is_valid_recordset_name(self): - domain = RoObject(name='example.org.') - self.service._is_valid_recordset_name(self.context, domain, + zone = RoObject(name='example.org.') + self.service._is_valid_recordset_name(self.context, zone, 'foo..example.org.') def test__is_valid_recordset_name_no_dot(self): - domain = RoObject(name='example.org.') + zone = RoObject(name='example.org.') with testtools.ExpectedException(ValueError): - self.service._is_valid_recordset_name(self.context, domain, + self.service._is_valid_recordset_name(self.context, zone, 'foo.example.org') def test__is_valid_recordset_name_too_long(self): - domain = RoObject(name='example.org.') + zone = RoObject(name='example.org.') designate.central.service.cfg.CONF['service:central'].\ max_recordset_name_len = 255 rs_name = 'a' * 255 + '.org.' with testtools.ExpectedException(exceptions.InvalidRecordSetName) as e: - self.service._is_valid_recordset_name(self.context, domain, + self.service._is_valid_recordset_name(self.context, zone, rs_name) self.assertEqual(e.message, 'Name too long') - def test__is_valid_recordset_name_wrong_domain(self): - domain = RoObject(name='example.org.') + def test__is_valid_recordset_name_wrong_zone(self): + zone = RoObject(name='example.org.') with testtools.ExpectedException(exceptions.InvalidRecordSetLocation): - self.service._is_valid_recordset_name(self.context, domain, + self.service._is_valid_recordset_name(self.context, zone, 'foo.example.com.') def test_is_valid_recordset_placement_cname(self): - domain = RoObject(name='example.org.') + zone = RoObject(name='example.org.') with testtools.ExpectedException(exceptions.InvalidRecordSetLocation) \ as e: self.service._is_valid_recordset_placement( self.context, - domain, + zone, 'example.org.', 'CNAME', ) @@ -546,7 +546,7 @@ class CentralDomainTestCase(CentralBasic): ) def test_is_valid_recordset_placement_failing(self): - domain = RoObject(name='example.org.', id='1') + zone = RoObject(name='example.org.', id='1') self.service.storage.find_recordsets.return_value = [ RoObject(id='2') ] @@ -554,7 +554,7 @@ class CentralDomainTestCase(CentralBasic): as e: self.service._is_valid_recordset_placement( self.context, - domain, + zone, 'example.org.', 'A', ) @@ -564,7 +564,7 @@ class CentralDomainTestCase(CentralBasic): ) def test_is_valid_recordset_placement_failing_2(self): - domain = RoObject(name='example.org.', id='1') + zone = RoObject(name='example.org.', id='1') self.service.storage.find_recordsets.return_value = [ RoObject(), RoObject() @@ -573,7 +573,7 @@ class CentralDomainTestCase(CentralBasic): as e: self.service._is_valid_recordset_placement( self.context, - domain, + zone, 'example.org.', 'A', ) @@ -583,46 +583,46 @@ class CentralDomainTestCase(CentralBasic): ) def test_is_valid_recordset_placement(self): - domain = RoObject(name='example.org.', id='1') + zone = RoObject(name='example.org.', id='1') self.service.storage.find_recordsets.return_value = [] ret = self.service._is_valid_recordset_placement( self.context, - domain, + zone, 'example.org.', 'A', ) self.assertTrue(ret) - def test__is_valid_recordset_placement_subdomain(self): - domain = RoObject(name='example.org.', id='1') - self.service._is_valid_recordset_placement_subdomain( + def test__is_valid_recordset_placement_subzone(self): + zone = RoObject(name='example.org.', id='1') + self.service._is_valid_recordset_placement_subzone( self.context, - domain, + zone, 'example.org.' ) - def test__is_valid_recordset_placement_subdomain_2(self): - domain = RoObject(name='example.org.', id='1') + def test__is_valid_recordset_placement_subzone_2(self): + zone = RoObject(name='example.org.', id='1') self.service._is_valid_recordset_name = Mock(side_effect=Exception) - self.service.storage.find_domains.return_value = [ + self.service.storage.find_zones.return_value = [ RoObject(name='foo.example.org.') ] - self.service._is_valid_recordset_placement_subdomain( + self.service._is_valid_recordset_placement_subzone( self.context, - domain, + zone, 'bar.example.org.' ) - def test__is_valid_recordset_placement_subdomain_failing(self): - domain = RoObject(name='example.org.', id='1') + def test__is_valid_recordset_placement_subzone_failing(self): + zone = RoObject(name='example.org.', id='1') self.service._is_valid_recordset_name = Mock() - self.service.storage.find_domains.return_value = [ + self.service.storage.find_zones.return_value = [ RoObject(name='foo.example.org.') ] with testtools.ExpectedException(exceptions.InvalidRecordSetLocation): - self.service._is_valid_recordset_placement_subdomain( + self.service._is_valid_recordset_placement_subzone( self.context, - domain, + zone, 'bar.example.org.' ) @@ -639,17 +639,17 @@ class CentralDomainTestCase(CentralBasic): recordset ) - def test__is_superdomain(self): - self.service.storage.find_domains = Mock() - self.service._is_superdomain(self.context, 'example.org.', '1') - _class_self_, crit = self.service.storage.find_domains.call_args[0] + def test__is_superzone(self): + self.service.storage.find_zones = Mock() + self.service._is_superzone(self.context, 'example.org.', '1') + _class_self_, crit = self.service.storage.find_zones.call_args[0] self.assertEqual({'name': '%.example.org.', 'pool_id': '1'}, crit) @patch('designate.central.service.utils.increment_serial') - def FIXME_test__increment_domain_serial(self, utils_inc_ser): + def FIXME_test__increment_zone_serial(self, utils_inc_ser): fixtures.MockPatch('designate.central.service.utils.increment_serial') - domain = RoObject(serial=1) - self.service._increment_domain_serial(self.context, domain) + zone = RoObject(serial=1) + self.service._increment_zone_serial(self.context, zone) def test__create_ns(self): self.service._create_recordset_in_storage = Mock(return_value=(0, 0)) @@ -734,14 +734,14 @@ class CentralDomainTestCase(CentralBasic): self.assertTrue(rset.records[0].managed) self.assertEqual('bar', rset.records[0].data.name) - def test_create_domain_no_servers(self): - self.service._enforce_domain_quota = Mock() - self.service._is_valid_domain_name = Mock() + def test_create_zone_no_servers(self): + self.service._enforce_zone_quota = Mock() + self.service._is_valid_zone_name = Mock() self.service._is_valid_ttl = Mock() - self.service._is_subdomain = Mock( + self.service._is_subzone = Mock( return_value=False ) - self.service._is_superdomain = Mock( + self.service._is_superzone = Mock( return_value=[] ) self.service.storage.get_pool.return_value = RoObject( @@ -749,34 +749,34 @@ class CentralDomainTestCase(CentralBasic): ) with testtools.ExpectedException(exceptions.NoServersConfigured): - self.service.create_domain( + self.service.create_zone( self.context, RoObject(tenant_id='1', name='example.com.', ttl=60, pool_id='2') ) - def test_create_domain(self): - self.service._enforce_domain_quota = Mock() - self.service._create_domain_in_storage = Mock( + def test_create_zone(self): + self.service._enforce_zone_quota = Mock() + self.service._create_zone_in_storage = Mock( return_value=RoObject( name='example.com.', type='PRIMARY', ) ) - self.service._is_valid_domain_name = Mock() + self.service._is_valid_zone_name = Mock() self.service._is_valid_ttl = Mock() - self.service._is_subdomain = Mock( + self.service._is_subzone = Mock( return_value=False ) - self.service._is_superdomain = Mock( + self.service._is_superzone = Mock( return_value=[] ) self.service.storage.get_pool.return_value = RoObject( ns_records=[RoObject()] ) - # self.service.create_domain = unwrap(self.service.create_domain) + # self.service.create_zone = unwrap(self.service.create_zone) - out = self.service.create_domain( + out = self.service.create_zone( self.context, RoObject( tenant_id='1', @@ -788,66 +788,66 @@ class CentralDomainTestCase(CentralBasic): ) self.assertEqual('example.com.', out.name) - def test_get_domain(self): - self.service.storage.get_domain.return_value = RoObject( + def test_get_zone(self): + self.service.storage.get_zone.return_value = RoObject( name='foo', tenant_id='2', ) - self.service.get_domain(self.context, '1') + self.service.get_zone(self.context, '1') n, ctx, target = designate.central.service.policy.check.call_args[0] - self.assertEqual('1', target['domain_id']) - self.assertEqual('foo', target['domain_name']) + self.assertEqual('1', target['zone_id']) + self.assertEqual('foo', target['zone_name']) self.assertEqual('2', target['tenant_id']) - def test_get_domain_servers(self): - self.service.storage.get_domain.return_value = RoObject( + def test_get_zone_servers(self): + self.service.storage.get_zone.return_value = RoObject( name='foo', tenant_id='2', pool_id='3', ) - self.service.get_domain_servers( + self.service.get_zone_ns_records( self.context, - domain_id='1' + zone_id='1' ) ctx, pool_id = self.service.storage.get_pool.call_args[0] self.assertEqual('3', pool_id) - def test_find_domains(self): + def test_find_zones(self): self.context = RoObject(tenant='t') - self.service.storage.find_domains = Mock() - self.service.find_domains(self.context) - assert self.service.storage.find_domains.called + self.service.storage.find_zones = Mock() + self.service.find_zones(self.context) + assert self.service.storage.find_zones.called pcheck, ctx, target = \ designate.central.service.policy.check.call_args[0] - self.assertEqual('find_domains', pcheck) + self.assertEqual('find_zones', pcheck) - def test_find_domain(self): + def test_find_zone(self): self.context = RoObject(tenant='t') - self.service.storage.find_domain = Mock() - self.service.find_domain(self.context) - assert self.service.storage.find_domain.called + self.service.storage.find_zone = Mock() + self.service.find_zone(self.context) + assert self.service.storage.find_zone.called pcheck, ctx, target = \ designate.central.service.policy.check.call_args[0] - self.assertEqual('find_domain', pcheck) + self.assertEqual('find_zone', pcheck) - def test_delete_domain_has_subdomain(self): + def test_delete_zone_has_subzone(self): self.context.abandon = False - self.service.storage.get_domain.return_value = RoObject( + self.service.storage.get_zone.return_value = RoObject( name='foo', tenant_id='2', ) - self.service.storage.count_domains.return_value = 2 - with testtools.ExpectedException(exceptions.DomainHasSubdomain): - self.service.delete_domain(self.context, '1') + self.service.storage.count_zones.return_value = 2 + with testtools.ExpectedException(exceptions.ZoneHasSubZone): + self.service.delete_zone(self.context, '1') pcheck, ctx, target = \ designate.central.service.policy.check.call_args[0] - self.assertEqual('delete_domain', pcheck) + self.assertEqual('delete_zone', pcheck) - def test_delete_domain_abandon(self): - self.service.storage.get_domain.return_value = RoObject( + def test_delete_zone_abandon(self): + self.service.storage.get_zone.return_value = RoObject( name='foo', tenant_id='2', id='9' @@ -859,49 +859,49 @@ class CentralDomainTestCase(CentralBasic): 'check', ]) self.context.abandon = True - self.service.storage.count_domains.return_value = 0 - self.service.delete_domain(self.context, '1') - assert self.service.storage.delete_domain.called - assert not self.service.pool_manager_api.delete_domain.called + self.service.storage.count_zones.return_value = 0 + self.service.delete_zone(self.context, '1') + assert self.service.storage.delete_zone.called + assert not self.service.pool_manager_api.delete_zone.called pcheck, ctx, target = \ designate.central.service.policy.check.call_args[0] - self.assertEqual('abandon_domain', pcheck) + self.assertEqual('abandon_zone', pcheck) - def test_delete_domain(self): + def test_delete_zone(self): self.context.abandon = False - self.service.storage.get_domain.return_value = RoObject( + self.service.storage.get_zone.return_value = RoObject( name='foo', tenant_id='2', ) - self.service._delete_domain_in_storage = Mock( + self.service._delete_zone_in_storage = Mock( return_value=RoObject( name='foo' ) ) - self.service.storage.count_domains.return_value = 0 - out = self.service.delete_domain(self.context, '1') - assert not self.service.storage.delete_domain.called - assert self.service.pool_manager_api.delete_domain.called + self.service.storage.count_zones.return_value = 0 + out = self.service.delete_zone(self.context, '1') + assert not self.service.storage.delete_zone.called + assert self.service.pool_manager_api.delete_zone.called assert designate.central.service.policy.check.called ctx, deleted_dom = \ - self.service.pool_manager_api.delete_domain.call_args[0] + self.service.pool_manager_api.delete_zone.call_args[0] self.assertEqual('foo', deleted_dom.name) self.assertEqual('foo', out.name) pcheck, ctx, target = \ designate.central.service.policy.check.call_args[0] - self.assertEqual('delete_domain', pcheck) + self.assertEqual('delete_zone', pcheck) - def test__delete_domain_in_storage(self): - self.service._delete_domain_in_storage( + def test__delete_zone_in_storage(self): + self.service._delete_zone_in_storage( self.context, RwObject(action='', status=''), ) - d = self.service.storage.update_domain.call_args[0][1] + d = self.service.storage.update_zone.call_args[0][1] self.assertEqual('DELETE', d.action) self.assertEqual('PENDING', d.status) - def test__xfr_domain_secondary(self): - self.service.storage.get_domain.return_value = RoObject( + def test__xfr_zone_secondary(self): + self.service.storage.get_zone.return_value = RoObject( name='example.org.', tenant_id='2', type='SECONDARY', @@ -911,26 +911,26 @@ class CentralDomainTestCase(CentralBasic): with fx_mdns_api: self.service.mdns_api.get_serial_number.return_value = \ "SUCCESS", 2, 1 - self.service.xfr_domain(self.context, '1') + self.service.xfr_zone(self.context, '1') assert self.service.mdns_api.perform_zone_xfr.called assert designate.central.service.policy.check.called self.assertEqual( - 'xfr_domain', + 'xfr_zone', designate.central.service.policy.check.call_args[0][0] ) - def test__xfr_domain_not_secondary(self): - self.service.storage.get_domain.return_value = RoObject( + def test__xfr_zone_not_secondary(self): + self.service.storage.get_zone.return_value = RoObject( name='example.org.', tenant_id='2', type='PRIMARY' ) with testtools.ExpectedException(exceptions.BadRequest): - self.service.xfr_domain(self.context, '1') + self.service.xfr_zone(self.context, '1') def test_count_report(self): - self.service.count_domains = Mock(return_value=1) + self.service.count_zones = Mock(return_value=1) self.service.count_records = Mock(return_value=2) self.service.count_tenants = Mock(return_value=3) reports = self.service.count_report( @@ -940,7 +940,7 @@ class CentralDomainTestCase(CentralBasic): self.assertEqual([{'zones': 1, 'records': 2, 'tenants': 3}], reports) def test_count_report_zones(self): - self.service.count_domains = Mock(return_value=1) + self.service.count_zones = Mock(return_value=1) self.service.count_records = Mock(return_value=2) self.service.count_tenants = Mock(return_value=3) reports = self.service.count_report( @@ -950,7 +950,7 @@ class CentralDomainTestCase(CentralBasic): self.assertEqual([{'zones': 1}], reports) def test_count_report_records(self): - self.service.count_domains = Mock(return_value=1) + self.service.count_zones = Mock(return_value=1) self.service.count_records = Mock(return_value=2) self.service.count_tenants = Mock(return_value=3) reports = self.service.count_report( @@ -960,7 +960,7 @@ class CentralDomainTestCase(CentralBasic): self.assertEqual([{'records': 2}], reports) def test_count_report_tenants(self): - self.service.count_domains = Mock(return_value=1) + self.service.count_zones = Mock(return_value=1) self.service.count_records = Mock(return_value=2) self.service.count_tenants = Mock(return_value=3) reports = self.service.count_report( @@ -970,7 +970,7 @@ class CentralDomainTestCase(CentralBasic): self.assertEqual([{'tenants': 3}], reports) def test_count_report_not_found(self): - self.service.count_domains = Mock(return_value=1) + self.service.count_zones = Mock(return_value=1) self.service.count_records = Mock(return_value=2) self.service.count_tenants = Mock(return_value=3) with testtools.ExpectedException(exceptions.ReportNotFound): @@ -979,27 +979,27 @@ class CentralDomainTestCase(CentralBasic): criterion='bogus' ) - def test_touch_domain(self): - self.service._touch_domain_in_storage = Mock() - self.service.storage.get_domain.return_value = RoObject( + def test_touch_zone(self): + self.service._touch_zone_in_storage = Mock() + self.service.storage.get_zone.return_value = RoObject( name='example.org.', tenant_id='2', ) with fx_pool_manager: - self.service.touch_domain(self.context, '1') + self.service.touch_zone(self.context, '1') assert designate.central.service.policy.check.called self.assertEqual( - 'touch_domain', + 'touch_zone', designate.central.service.policy.check.call_args[0][0] ) def test_get_recordset_not_found(self): - self.service.storage.get_domain.return_value = RoObject( + self.service.storage.get_zone.return_value = RoObject( id='2', ) self.service.storage.get_recordset.return_value = RoObject( - domain_id='3' + zone_id='3' ) with testtools.ExpectedException(exceptions.RecordSetNotFound): self.service.get_recordset( @@ -1009,13 +1009,13 @@ class CentralDomainTestCase(CentralBasic): ) def test_get_recordset(self): - self.service.storage.get_domain.return_value = RoObject( + self.service.storage.get_zone.return_value = RoObject( id='2', name='example.org.', tenant_id='2', ) self.service.storage.get_recordset.return_value = RoObject( - domain_id='2', + zone_id='2', id='3' ) self.service.get_recordset( @@ -1030,8 +1030,8 @@ class CentralDomainTestCase(CentralBasic): t, ctx, target = designate.central.service.policy.check.call_args[0] self.assertEqual('get_recordset', t) self.assertEqual({ - 'domain_id': '1', - 'domain_name': 'example.org.', + 'zone_id': '1', + 'zone_name': 'example.org.', 'recordset_id': '3', 'tenant_id': '2'}, target) @@ -1054,7 +1054,7 @@ class CentralDomainTestCase(CentralBasic): self.assertEqual({'tenant_id': 't'}, target) def test_update_recordset_fail_on_changes(self): - self.service.storage.get_domain.return_value = RoObject() + self.service.storage.get_zone.return_value = RoObject() recordset = Mock() recordset.obj_get_original_value.return_value = '1' @@ -1062,7 +1062,7 @@ class CentralDomainTestCase(CentralBasic): with testtools.ExpectedException(exceptions.BadRequest): self.service.update_recordset(self.context, recordset) - recordset.obj_get_changes.return_value = ['domain_id', 'foo'] + recordset.obj_get_changes.return_value = ['zone_id', 'foo'] with testtools.ExpectedException(exceptions.BadRequest): self.service.update_recordset(self.context, recordset) @@ -1071,7 +1071,7 @@ class CentralDomainTestCase(CentralBasic): self.service.update_recordset(self.context, recordset) def test_update_recordset_action_delete(self): - self.service.storage.get_domain.return_value = RoObject( + self.service.storage.get_zone.return_value = RoObject( action='DELETE', ) recordset = Mock() @@ -1080,7 +1080,7 @@ class CentralDomainTestCase(CentralBasic): self.service.update_recordset(self.context, recordset) def test_update_recordset_action_fail_on_managed(self): - self.service.storage.get_domain.return_value = RoObject( + self.service.storage.get_zone.return_value = RoObject( type='foo', name='example.org.', tenant_id='2', @@ -1095,7 +1095,7 @@ class CentralDomainTestCase(CentralBasic): self.service.update_recordset(self.context, recordset) def test_update_recordset(self): - self.service.storage.get_domain.return_value = RoObject( + self.service.storage.get_zone.return_value = RoObject( type='foo', name='example.org.', tenant_id='2', @@ -1116,9 +1116,9 @@ class CentralDomainTestCase(CentralBasic): n, ctx, target = designate.central.service.policy.check.call_args[0] self.assertEqual('update_recordset', n) self.assertEqual({ - 'domain_id': '1', - 'domain_name': 'example.org.', - 'domain_type': 'foo', + 'zone_id': '1', + 'zone_name': 'example.org.', + 'zone_type': 'foo', 'recordset_id': '1', 'tenant_id': '2'}, target) @@ -1131,9 +1131,9 @@ class CentralDomainTestCase(CentralBasic): recordset.records = [] self.service._is_valid_recordset_name = Mock() self.service._is_valid_recordset_placement = Mock() - self.service._is_valid_recordset_placement_subdomain = Mock() + self.service._is_valid_recordset_placement_subzone = Mock() self.service._is_valid_ttl = Mock() - self.service._update_domain_in_storage = Mock() + self.service._update_zone_in_storage = Mock() self.service._update_recordset_in_storage( self.context, @@ -1151,7 +1151,7 @@ class CentralDomainTestCase(CentralBasic): ) self.assertEqual( 'n', - self.service._is_valid_recordset_placement_subdomain. + self.service._is_valid_recordset_placement_subzone. call_args[0][2] ) self.assertEqual( @@ -1159,7 +1159,7 @@ class CentralDomainTestCase(CentralBasic): self.service._is_valid_ttl.call_args[0][1] ) assert self.service.storage.update_recordset.called - assert self.service._update_domain_in_storage.called + assert self.service._update_zone_in_storage.called def test__update_recordset_in_storage_2(self): recordset = Mock() @@ -1174,9 +1174,9 @@ class CentralDomainTestCase(CentralBasic): )] self.service._is_valid_recordset_name = Mock() self.service._is_valid_recordset_placement = Mock() - self.service._is_valid_recordset_placement_subdomain = Mock() + self.service._is_valid_recordset_placement_subzone = Mock() self.service._is_valid_ttl = Mock() - self.service._update_domain_in_storage = Mock() + self.service._update_zone_in_storage = Mock() self.service._update_recordset_in_storage( self.context, @@ -1195,15 +1195,15 @@ class CentralDomainTestCase(CentralBasic): ) self.assertEqual( 'n', - self.service._is_valid_recordset_placement_subdomain. + self.service._is_valid_recordset_placement_subzone. call_args[0][2] ) assert not self.service._is_valid_ttl.called - assert not self.service._update_domain_in_storage.called + assert not self.service._update_zone_in_storage.called assert self.service.storage.update_recordset.called def test_delete_recordset_not_found(self): - self.service.storage.get_domain.return_value = RoObject( + self.service.storage.get_zone.return_value = RoObject( action='bogus', id=4, name='example.org.', @@ -1211,7 +1211,7 @@ class CentralDomainTestCase(CentralBasic): type='foo', ) self.service.storage.get_recordset.return_value = RoObject( - domain_id='d', + zone_id='d', id='i', managed=False, ) @@ -1221,7 +1221,7 @@ class CentralDomainTestCase(CentralBasic): self.service.delete_recordset(self.context, 'd', 'r') def test_delete_recordset_action_delete(self): - self.service.storage.get_domain.return_value = RoObject( + self.service.storage.get_zone.return_value = RoObject( action='DELETE', id=4, name='example.org.', @@ -1229,7 +1229,7 @@ class CentralDomainTestCase(CentralBasic): type='foo', ) self.service.storage.get_recordset.return_value = RoObject( - domain_id=4, + zone_id=4, id='i', managed=False, ) @@ -1239,7 +1239,7 @@ class CentralDomainTestCase(CentralBasic): self.service.delete_recordset(self.context, 'd', 'r') def test_delete_recordset_managed(self): - self.service.storage.get_domain.return_value = RoObject( + self.service.storage.get_zone.return_value = RoObject( action='foo', id=4, name='example.org.', @@ -1247,7 +1247,7 @@ class CentralDomainTestCase(CentralBasic): type='foo', ) self.service.storage.get_recordset.return_value = RoObject( - domain_id=4, + zone_id=4, id='i', managed=True, ) @@ -1257,7 +1257,7 @@ class CentralDomainTestCase(CentralBasic): self.service.delete_recordset(self.context, 'd', 'r') def test_delete_recordset(self): - self.service.storage.get_domain.return_value = RoObject( + self.service.storage.get_zone.return_value = RoObject( action='foo', id=4, name='example.org.', @@ -1265,7 +1265,7 @@ class CentralDomainTestCase(CentralBasic): type='foo', ) self.service.storage.get_recordset.return_value = RoObject( - domain_id=4, + zone_id=4, id='i', managed=False, ) @@ -1276,14 +1276,14 @@ class CentralDomainTestCase(CentralBasic): ) with fx_pool_manager: self.service.delete_recordset(self.context, 'd', 'r') - assert self.service.pool_manager_api.update_domain.called + assert self.service.pool_manager_api.update_zone.called assert self.service._delete_recordset_in_storage.called def test__delete_recordset_in_storage(self): - def mock_uds(c, domain, inc): - return domain - self.service._update_domain_in_storage = mock_uds + def mock_uds(c, zone, inc): + return zone + self.service._update_zone_in_storage = mock_uds self.service._delete_recordset_in_storage( self.context, RoObject(serial=1), @@ -1304,7 +1304,7 @@ class CentralDomainTestCase(CentralBasic): self.assertEqual(1, rs.records[0].serial) def test__delete_recordset_in_storage_no_increment_serial(self): - self.service._update_domain_in_storage = Mock() + self.service._update_zone_in_storage = Mock() self.service._delete_recordset_in_storage( self.context, RoObject(serial=1), @@ -1319,7 +1319,7 @@ class CentralDomainTestCase(CentralBasic): ) assert self.service.storage.update_recordset.called assert self.service.storage.delete_recordset.called - assert not self.service._update_domain_in_storage.called + assert not self.service._update_zone_in_storage.called def test_count_recordset(self): self.service.count_recordsets(self.context) @@ -1332,7 +1332,7 @@ class CentralDomainTestCase(CentralBasic): ) def test_create_record_fail_on_delete(self): - self.service.storage.get_domain.return_value = RoObject( + self.service.storage.get_zone.return_value = RoObject( action='DELETE', id=4, name='example.org.', @@ -1351,7 +1351,7 @@ class CentralDomainTestCase(CentralBasic): self.service._create_record_in_storage = Mock( return_value=(None, None) ) - self.service.storage.get_domain.return_value = RoObject( + self.service.storage.get_zone.return_value = RoObject( action='a', id=4, name='example.org.', @@ -1368,14 +1368,14 @@ class CentralDomainTestCase(CentralBasic): 2, RoObject(), ) - assert self.service.pool_manager_api.update_domain.called + assert self.service.pool_manager_api.update_zone.called n, ctx, target = designate.central.service.policy.check.call_args[0] self.assertEqual('create_record', n) self.assertEqual({ - 'domain_id': 1, - 'domain_name': 'example.org.', - 'domain_type': 'foo', + 'zone_id': 1, + 'zone_name': 'example.org.', + 'zone_type': 'foo', 'recordset_id': 2, 'recordset_name': 'rs', 'tenant_id': '2'}, target) @@ -1401,48 +1401,48 @@ class CentralDomainTestCase(CentralBasic): self.assertEqual(4, record.serial) def test_get_record_not_found(self): - self.service.storage.get_domain.return_value = RoObject( + self.service.storage.get_zone.return_value = RoObject( id=2, ) self.service.storage.get_recordset.return_value = RoObject( - domain_id=3 + zone_id=3 ) with testtools.ExpectedException(exceptions.RecordNotFound): self.service.get_record(self.context, 1, 2, 3) def test_get_record_not_found_2(self): - self.service.storage.get_domain.return_value = RoObject( + self.service.storage.get_zone.return_value = RoObject( id=2, name='example.org.', tenant_id=2, ) self.service.storage.get_recordset.return_value = RoObject( - domain_id=2, + zone_id=2, id=999, # not matching record.recordset_id name='foo' ) self.service.storage.get_record.return_value = RoObject( id=5, - domain_id=2, + zone_id=2, recordset_id=3 ) with testtools.ExpectedException(exceptions.RecordNotFound): self.service.get_record(self.context, 1, 2, 3) def test_get_record(self): - self.service.storage.get_domain.return_value = RoObject( + self.service.storage.get_zone.return_value = RoObject( id=2, name='example.org.', tenant_id=2, ) self.service.storage.get_recordset.return_value = RoObject( - domain_id=2, + zone_id=2, id=3, name='foo' ) self.service.storage.get_record.return_value = RoObject( id=5, - domain_id=2, + zone_id=2, recordset_id=3 ) self.service.get_record(self.context, 1, 2, 3) @@ -1453,15 +1453,15 @@ class CentralDomainTestCase(CentralBasic): t, ctx, target = designate.central.service.policy.check.call_args[0] self.assertEqual('get_record', t) self.assertEqual({ - 'domain_id': 1, - 'domain_name': 'example.org.', + 'zone_id': 1, + 'zone_name': 'example.org.', 'record_id': 5, 'recordset_id': 2, 'recordset_name': 'foo', 'tenant_id': 2}, target) def test_update_record_fail_on_changes(self): - self.service.storage.get_domain.return_value = RoObject( + self.service.storage.get_zone.return_value = RoObject( action='a', name='n', type='t', @@ -1474,7 +1474,7 @@ class CentralDomainTestCase(CentralBasic): with testtools.ExpectedException(exceptions.BadRequest): self.service.update_record(self.context, record) - record.obj_get_changes.return_value = ['domain_id', 'foo'] + record.obj_get_changes.return_value = ['zone_id', 'foo'] with testtools.ExpectedException(exceptions.BadRequest): self.service.update_record(self.context, record) @@ -1483,7 +1483,7 @@ class CentralDomainTestCase(CentralBasic): self.service.update_record(self.context, record) def test_update_record_action_delete(self): - self.service.storage.get_domain.return_value = RoObject( + self.service.storage.get_zone.return_value = RoObject( action='DELETE', ) record = Mock() @@ -1491,7 +1491,7 @@ class CentralDomainTestCase(CentralBasic): self.service.update_record(self.context, record) def test_update_record_action_fail_on_managed(self): - self.service.storage.get_domain.return_value = RoObject( + self.service.storage.get_zone.return_value = RoObject( action='a', name='n', tenant_id='tid', @@ -1509,7 +1509,7 @@ class CentralDomainTestCase(CentralBasic): self.service.update_record(self.context, record) def test_update_record(self): - self.service.storage.get_domain.return_value = RoObject( + self.service.storage.get_zone.return_value = RoObject( action='a', name='n', tenant_id='tid', @@ -1534,16 +1534,16 @@ class CentralDomainTestCase(CentralBasic): n, ctx, target = designate.central.service.policy.check.call_args[0] self.assertEqual('update_record', n) self.assertEqual({ - 'domain_id': '1', - 'domain_name': 'n', - 'domain_type': 't', + 'zone_id': '1', + 'zone_name': 'n', + 'zone_type': 't', 'record_id': '1', 'recordset_id': '1', 'recordset_name': 'rsn', 'tenant_id': 'tid'}, target) def test__update_record_in_storage(self): - self.service._update_domain_in_storage = Mock() + self.service._update_zone_in_storage = Mock() self.service._update_record_in_storage( self.context, RoObject(serial=1), @@ -1560,30 +1560,30 @@ class CentralDomainTestCase(CentralBasic): self.assertEqual(1, record.serial) def test_delete_record_action_delete(self): - self.service.storage.get_domain.return_value = RoObject( + self.service.storage.get_zone.return_value = RoObject( action='DELETE', ) with testtools.ExpectedException(exceptions.BadRequest): self.service.delete_record(self.context, 1, 2, 3) def test_delete_record_not_found(self): - self.service.storage.get_domain.return_value = RoObject( + self.service.storage.get_zone.return_value = RoObject( action='a', id=2 ) self.service.storage.get_record.return_value = RoObject( - domain_id=999, + zone_id=999, ) self.service.storage.get_recordset.return_value = RoObject( id=888, ) - # domain.id != record.domain_id + # zone.id != record.zone_id with testtools.ExpectedException(exceptions.RecordNotFound): self.service.delete_record(self.context, 1, 2, 3) self.service.storage.get_record.return_value = RoObject( id=1, - domain_id=2, + zone_id=2, recordset_id=7777, ) # recordset.id != record.recordset_id @@ -1594,7 +1594,7 @@ class CentralDomainTestCase(CentralBasic): self.service._delete_record_in_storage = Mock( return_value=(None, None) ) - self.service.storage.get_domain.return_value = RoObject( + self.service.storage.get_zone.return_value = RoObject( action='a', id=2, name='dn', @@ -1603,7 +1603,7 @@ class CentralDomainTestCase(CentralBasic): ) self.service.storage.get_record.return_value = RoObject( id=4, - domain_id=2, + zone_id=2, recordset_id=3, ) self.service.storage.get_recordset.return_value = RoObject( @@ -1618,9 +1618,9 @@ class CentralDomainTestCase(CentralBasic): t, ctx, target = designate.central.service.policy.check.call_args[0] self.assertEqual('delete_record', t) self.assertEqual({ - 'domain_id': 1, - 'domain_name': 'dn', - 'domain_type': 't', + 'zone_id': 1, + 'zone_name': 'dn', + 'zone_type': 't', 'record_id': 4, 'recordset_id': 2, 'recordset_name': 'rsn', @@ -1630,7 +1630,7 @@ class CentralDomainTestCase(CentralBasic): self.service._delete_record_in_storage = Mock( return_value=(None, None) ) - self.service.storage.get_domain.return_value = RoObject( + self.service.storage.get_zone.return_value = RoObject( action='a', id=2, name='dn', @@ -1639,7 +1639,7 @@ class CentralDomainTestCase(CentralBasic): ) self.service.storage.get_record.return_value = RoObject( id=4, - domain_id=2, + zone_id=2, recordset_id=3, ) self.service.storage.get_recordset.return_value = RoObject( @@ -1672,35 +1672,35 @@ class CentralDomainTestCase(CentralBasic): self.assertEqual('count_records', t) self.assertEqual({'tenant_id': None}, target) - def test_sync_domains(self): - self.service._sync_domain = Mock() - self.service.storage.find_domains.return_value = [ + def test_sync_zones(self): + self.service._sync_zone = Mock() + self.service.storage.find_zones.return_value = [ RoObject(id=1), RoObject(id=2) ] - res = self.service.sync_domains(self.context) + res = self.service.sync_zones(self.context) t, ctx = designate.central.service.policy.check.call_args[0] - self.assertEqual('diagnostics_sync_domains', t) + self.assertEqual('diagnostics_sync_zones', t) self.assertEqual(2, len(res)) - def test_sync_domain(self): - self.service._sync_domain = Mock() - self.service.storage.get_domain.return_value = RoObject( + def test_sync_zone(self): + self.service._sync_zone = Mock() + self.service.storage.get_zone.return_value = RoObject( id=1, name='n', tenant_id='tid', ) - self.service.sync_domain(self.context, 1) + self.service.sync_zone(self.context, 1) t, ctx, target = designate.central.service.policy.check.call_args[0] - self.assertEqual('diagnostics_sync_domain', t) - self.assertEqual({'tenant_id': 'tid', 'domain_id': 1, - 'domain_name': 'n'}, target) + self.assertEqual('diagnostics_sync_zone', t) + self.assertEqual({'tenant_id': 'tid', 'zone_id': 1, + 'zone_name': 'n'}, target) def test_sync_record(self): - self.service.storage.get_domain.return_value = RoObject( + self.service.storage.get_zone.return_value = RoObject( id=1, name='n', tenant_id='tid', @@ -1714,8 +1714,8 @@ class CentralDomainTestCase(CentralBasic): t, ctx, target = designate.central.service.policy.check.call_args[0] self.assertEqual('diagnostics_sync_record', t) self.assertEqual({ - 'domain_id': 1, - 'domain_name': 'n', + 'zone_id': 1, + 'zone_name': 'n', 'record_id': 3, 'recordset_id': 2, 'recordset_name': 'n', @@ -1765,36 +1765,35 @@ class CentralDomainTestCase(CentralBasic): self.assertEqual(data['k'], ({'address': 1}, None)) -class IsSubdomainTestCase(CentralBasic): +class IsSubzoneTestCase(CentralBasic): def setUp(self): - super(IsSubdomainTestCase, self).setUp() + super(IsSubzoneTestCase, self).setUp() - def find_domain(ctx, criterion): - print("Calling find_domain on %r" % criterion) + def find_zone(ctx, criterion): + print("Calling find_zone on %r" % criterion) if criterion['name'] == 'example.com.': print("Returning %r" % criterion['name']) return criterion['name'] print("Not found") - raise exceptions.DomainNotFound + raise exceptions.ZoneNotFound - self.service.storage.find_domain = find_domain + self.service.storage.find_zone = find_zone - def test__is_subdomain_false(self): - r = self.service._is_subdomain(self.context, 'com', '1') + def test__is_subzone_false(self): + r = self.service._is_subzone(self.context, 'com', '1') self.assertFalse(r) - def FIXME_test__is_subdomain_false2(self): - r = self.service._is_subdomain(self.context, 'com.', '1') + def FIXME_test__is_subzone_false2(self): + r = self.service._is_subzone(self.context, 'com.', '1') self.assertEqual('com.', r) - def FIXME_test__is_subdomain_false3(self): - r = self.service._is_subdomain(self.context, 'example.com.', '1') + def FIXME_test__is_subzone_false3(self): + r = self.service._is_subzone(self.context, 'example.com.', '1') self.assertEqual('example.com.', r) - def test__is_subdomain_false4(self): - r = self.service._is_subdomain(self.context, 'foo.a.b.example.com.', - '1') + def test__is_subzone_false4(self): + r = self.service._is_subzone(self.context, 'foo.a.b.example.com.', '1') self.assertEqual('example.com.', r) @@ -1812,14 +1811,14 @@ class CentralZoneExportTests(CentralBasic): self.context = Mock() self.context.tenant = 't' - self.service.storage.get_domain.return_value = RoObject( + self.service.storage.get_zone.return_value = RoObject( name='example.com.', id='123' ) self.service.storage.create_zone_export = Mock( return_value=RoObject( - domain_id='123', + zone_id='123', task_type='EXPORT', status='PENDING', message=None, @@ -1833,7 +1832,7 @@ class CentralZoneExportTests(CentralBasic): self.context, '123' ) - self.assertEqual('123', out.domain_id) + self.assertEqual('123', out.zone_id) self.assertEqual('PENDING', out.status) self.assertEqual('EXPORT', out.task_type) self.assertIsNone(out.message) @@ -1844,7 +1843,7 @@ class CentralZoneExportTests(CentralBasic): self.context.tenant = 't' self.service.storage.get_zone_export.return_value = RoObject( - domain_id='123', + zone_id='123', task_type='EXPORT', status='PENDING', message=None, @@ -1859,7 +1858,7 @@ class CentralZoneExportTests(CentralBasic): self.assertEqual('t', target['tenant_id']) # Check output - self.assertEqual('123', out.domain_id) + self.assertEqual('123', out.zone_id) self.assertEqual('PENDING', out.status) self.assertEqual('EXPORT', out.task_type) self.assertIsNone(out.message) @@ -1883,7 +1882,7 @@ class CentralZoneExportTests(CentralBasic): self.service.storage.delete_zone_export = Mock( return_value=RoObject( - domain_id='123', + zone_id='123', task_type='EXPORT', status='PENDING', message=None, @@ -1895,7 +1894,7 @@ class CentralZoneExportTests(CentralBasic): assert self.service.storage.delete_zone_export.called - self.assertEqual('123', out.domain_id) + self.assertEqual('123', out.zone_id) self.assertEqual('PENDING', out.status) self.assertEqual('EXPORT', out.task_type) self.assertIsNone(out.message) @@ -1910,14 +1909,14 @@ class CentralZoneExportTests(CentralBasic): class CentralStatusTests(CentralBasic): - def test__update_domain_or_record_status_no_domain(self): - domain = RwObject( + def test__update_zone_or_record_status_no_zone(self): + zone = RwObject( action='UPDATE', status='SUCCESS', serial=0, ) dom, deleted = self.service.\ - _update_domain_or_record_status(domain, 'NO_DOMAIN', 0) + _update_zone_or_record_status(zone, 'NO_zone', 0) self.assertEqual(dom.action, 'CREATE') self.assertEqual(dom.status, 'ERROR') diff --git a/designate/tests/unit/test_objects/test_domain.py b/designate/tests/unit/test_objects/test_domain.py index b3571417..8935e5f4 100644 --- a/designate/tests/unit/test_objects/test_domain.py +++ b/designate/tests/unit/test_objects/test_domain.py @@ -26,131 +26,131 @@ from designate import objects LOG = logging.getLogger(__name__) -def create_test_domain(): - return objects.Domain( +def create_test_zone(): + return objects.Zone( name='www.example.org.', email='foo@example.com', ) -class DomainTest(oslotest.base.BaseTestCase): +class zoneTest(oslotest.base.BaseTestCase): def test_init(self): - domain = create_test_domain() - self.assertEqual('www.example.org.', domain.name) + zone = create_test_zone() + self.assertEqual('www.example.org.', zone.name) def test_masters_none(self): - domain = objects.Domain() + zone = objects.Zone() with testtools.ExpectedException(exceptions.RelationNotLoaded): - self.assertIsNone(domain.masters) + self.assertIsNone(zone.masters) def test_masters(self): - domain = objects.Domain( - masters=objects.DomainMasterList.from_list([ + zone = objects.Zone( + masters=objects.ZoneMasterList.from_list([ {'host': '1.0.0.0', 'port': 53} ]) ) self.assertEqual( - [{'host': '1.0.0.0', 'port': 53}], domain.masters.to_list()) + [{'host': '1.0.0.0', 'port': 53}], zone.masters.to_list()) def test_masters_2(self): - domain = objects.Domain( - masters=objects.DomainMasterList.from_list([ + zone = objects.Zone( + masters=objects.ZoneMasterList.from_list([ {'host': '1.0.0.0'}, {'host': '2.0.0.0'} ]) ) - self.assertEqual(2, len(domain.masters)) + self.assertEqual(2, len(zone.masters)) def test_get_master_by_ip(self): - domain = objects.Domain( - masters=objects.DomainMasterList.from_list([ + zone = objects.Zone( + masters=objects.ZoneMasterList.from_list([ {'host': '1.0.0.0', 'port': 53}, {'host': '2.0.0.0', 'port': 53} ]) ) - m = domain.get_master_by_ip('2.0.0.0').to_data() + m = zone.get_master_by_ip('2.0.0.0').to_data() self.assertEqual('2.0.0.0:53', m) - @unittest.expectedFailure # bug: domain.masters is not iterable + @unittest.expectedFailure # bug: zone.masters is not iterable def test_get_master_by_ip_none(self): - domain = objects.Domain() - m = domain.get_master_by_ip('2.0.0.0') + zone = objects.Zone() + m = zone.get_master_by_ip('2.0.0.0') self.assertFalse(m) def test_validate(self): - domain = create_test_domain() - domain.validate() + zone = create_test_zone() + zone.validate() def test_validate_invalid_secondary(self): - domain = objects.Domain( + zone = objects.Zone( type='SECONDARY', ) with testtools.ExpectedException(exceptions.InvalidObject): - domain.validate() + zone.validate() def test_validate_primary_with_masters(self): - masters = objects.DomainMasterList() - masters.append(objects.DomainMaster.from_data("10.0.0.1:53")) - domain = objects.Domain( + masters = objects.ZoneMasterList() + masters.append(objects.ZoneMaster.from_data("10.0.0.1:53")) + zone = objects.Zone( name='example.com.', type='PRIMARY', email="foo@example.com", masters=masters ) with testtools.ExpectedException(exceptions.InvalidObject): - domain.validate() + zone.validate() def test_validate_primary_no_email(self): - masters = objects.DomainMasterList() - masters.append(objects.DomainMaster.from_data("10.0.0.1:53")) - domain = objects.Domain( + masters = objects.ZoneMasterList() + masters.append(objects.ZoneMaster.from_data("10.0.0.1:53")) + zone = objects.Zone( name='example.com.', type='PRIMARY', ) with testtools.ExpectedException(exceptions.InvalidObject): - domain.validate() + zone.validate() def test_validate_secondary_with_email(self): - masters = objects.DomainMasterList() - masters.append(objects.DomainMaster.from_data("10.0.0.1:53")) - domain = objects.Domain( + masters = objects.ZoneMasterList() + masters.append(objects.ZoneMaster.from_data("10.0.0.1:53")) + zone = objects.Zone( name='example.com.', type='SECONDARY', email="foo@example.com", masters=masters ) with testtools.ExpectedException(exceptions.InvalidObject): - domain.validate() + zone.validate() def test_validate_secondary_with_ttl(self): - masters = objects.DomainMasterList() - masters.append(objects.DomainMaster.from_data("10.0.0.1:53")) - domain = objects.Domain( + masters = objects.ZoneMasterList() + masters.append(objects.ZoneMaster.from_data("10.0.0.1:53")) + zone = objects.Zone( name='example.com.', type='SECONDARY', ttl=600, masters=masters ) with testtools.ExpectedException(exceptions.InvalidObject): - domain.validate() + zone.validate() def test_validate_secondary_with_masters_empty_list(self): - masters = objects.DomainMasterList() - domain = objects.Domain( + masters = objects.ZoneMasterList() + zone = objects.Zone( name='example.com.', type='SECONDARY', masters=masters ) with testtools.ExpectedException(exceptions.InvalidObject): - domain.validate() + zone.validate() def test_validate_secondary_with_masters_none(self): - domain = objects.Domain( + zone = objects.Zone( name='example.com.', type='SECONDARY', masters=None ) with testtools.ExpectedException(exceptions.InvalidObject): - domain.validate() + zone.validate() diff --git a/designate/tests/unit/test_zone_manager/test_tasks.py b/designate/tests/unit/test_zone_manager/test_tasks.py index 5e3c79c7..930925c7 100644 --- a/designate/tests/unit/test_zone_manager/test_tasks.py +++ b/designate/tests/unit/test_zone_manager/test_tasks.py @@ -100,7 +100,7 @@ class PeriodicTest(TaskTest): ctxt = mock.Mock() iterer = self.task._iter_zones(ctxt) - central.find_domains.return_value = [] + central.find_zones.return_value = [] with testtools.ExpectedException(StopIteration): next(iterer) @@ -115,22 +115,22 @@ class PeriodicTest(TaskTest): iterer = self.task._iter_zones(ctxt) items = [RoObject(id=str(uuid.uuid4())) for i in range(0, 5)] - central.find_domains.return_value = items + central.find_zones.return_value = items # Iterate through the items causing the "paging" to be done. map(lambda i: next(iterer), items) - central.find_domains.assert_called_once_with( + central.find_zones.assert_called_once_with( ctxt, {"shard": "BETWEEN 0,9"}, limit=100) - central.find_domains.reset_mock() + central.find_zones.reset_mock() # Call next on the iterator and see it trying to load a new page. # Also this will raise a StopIteration since there are no more items. - central.find_domains.return_value = [] + central.find_zones.return_value = [] with testtools.ExpectedException(StopIteration): next(iterer) - central.find_domains.assert_called_once_with( + central.find_zones.assert_called_once_with( ctxt, {"shard": "BETWEEN 0,9"}, marker=items[-1].id, @@ -181,14 +181,14 @@ class PeriodicExistsTest(TaskTest): self.get_period.return_value = self.period def test_emit_exists(self): - domain = RoObject( + zone = RoObject( id=str(uuid.uuid4())) with mock.patch.object(self.task, '_iter_zones') as iter_: - iter_.return_value = [domain] + iter_.return_value = [zone] self.task() - data = dict(domain) + data = dict(zone) data.update(self.period_data) self.mock_notifier.info.assert_called_with( @@ -247,7 +247,7 @@ class PeriodicSecondaryRefreshTest(TaskTest): _iter.return_value = [] self.task() - self.assertFalse(self.central.xfr_domain.called) + self.assertFalse(self.central.xfr_zone.called) def test_refresh_zone(self): transferred = timeutils.utcnow(True) - datetime.timedelta(minutes=62) @@ -260,7 +260,7 @@ class PeriodicSecondaryRefreshTest(TaskTest): _iter.return_value = [zone] self.task() - self.central.xfr_domain.assert_called_once_with(self.ctxt, zone.id) + self.central.xfr_zone.assert_called_once_with(self.ctxt, zone.id) def test_refresh_zone_not_expired(self): # Dummy zone object @@ -274,4 +274,4 @@ class PeriodicSecondaryRefreshTest(TaskTest): _iter.return_value = [zone] self.task() - self.assertFalse(self.central.xfr_domain.called) + self.assertFalse(self.central.xfr_zone.called) diff --git a/designate/zone_manager/rpcapi.py b/designate/zone_manager/rpcapi.py index e5780bb7..568a18d0 100644 --- a/designate/zone_manager/rpcapi.py +++ b/designate/zone_manager/rpcapi.py @@ -57,11 +57,11 @@ class ZoneManagerAPI(object): return ZONE_MANAGER_API # Zone Export - def start_zone_export(self, context, domain, export): + def start_zone_export(self, context, zone, export): LOG.info(_LI("start_zone_export: " "Calling zone_manager's start_zone_export.")) - return self.client.cast(context, 'start_zone_export', domain=domain, + return self.client.cast(context, 'start_zone_export', zone=zone, export=export) def render_zone(self, context, zone_id): diff --git a/designate/zone_manager/service.py b/designate/zone_manager/service.py index e51385bd..9dffc19f 100644 --- a/designate/zone_manager/service.py +++ b/designate/zone_manager/service.py @@ -87,8 +87,8 @@ class Service(service.RPCService, coordination.CoordinationMixin, # Begin RPC Implementation # Zone Export - def start_zone_export(self, context, domain, export): - criterion = {'domain_id': domain.id} + def start_zone_export(self, context, zone, export): + criterion = {'zone_id': zone.id} count = self.storage.count_recordsets(context, criterion) export = self._determine_export_method(context, export, count) @@ -139,11 +139,11 @@ class Service(service.RPCService, coordination.CoordinationMixin, return export def _export_zone(self, context, zone_id): - domain = self.central_api.get_domain(context, zone_id) + zone = self.central_api.get_zone(context, zone_id) - criterion = {'domain_id': zone_id} + criterion = {'zone_id': zone_id} recordsets = self.storage.find_recordsets_export(context, criterion) return utils.render_template('export-zone.jinja2', - domain=domain, + zone=zone, recordsets=recordsets) diff --git a/designate/zone_manager/tasks.py b/designate/zone_manager/tasks.py index 6d4fc6c8..a4dc5fdf 100644 --- a/designate/zone_manager/tasks.py +++ b/designate/zone_manager/tasks.py @@ -87,20 +87,20 @@ class PeriodicTask(plugin.ExtensionPlugin): def _iter_zones(self, ctxt, criterion=None): criterion = criterion or {} criterion.update(self._filter_between('shard')) - return self._iter(self.central_api.find_domains, ctxt, criterion) + return self._iter(self.central_api.find_zones, ctxt, criterion) -class DeletedDomainPurgeTask(PeriodicTask): - """Purge deleted domains that are exceeding the grace period time interval. - Deleted domains have values in the deleted_at column. +class DeletedZonePurgeTask(PeriodicTask): + """Purge deleted zones that are exceeding the grace period time interval. + Deleted zones have values in the deleted_at column. Purging means removing them from the database entirely. """ - __plugin_name__ = 'domain_purge' + __plugin_name__ = 'zone_purge' __interval__ = 3600 def __init__(self): - super(DeletedDomainPurgeTask, self).__init__() + super(DeletedZonePurgeTask, self).__init__() @classmethod def get_cfg_opts(cls): @@ -109,13 +109,13 @@ class DeletedDomainPurgeTask(PeriodicTask): cfg.IntOpt( 'time_threshold', default=604800, - help="How old deleted domains should be (deleted_at) to be " + help="How old deleted zones should be (deleted_at) to be " "purged, in seconds" ), cfg.IntOpt( 'batch_size', default=100, - help='How many domains to be purged on each run' + help='How many zones to be purged on each run' ), ] return [(group, options)] @@ -125,12 +125,12 @@ class DeletedDomainPurgeTask(PeriodicTask): expiration time and sharding range. """ pstart, pend = self._my_range() - msg = _LI("Performing deleted domain purging for %(start)s to %(end)s") + msg = _LI("Performing deleted zone purging for %(start)s to %(end)s") LOG.info(msg % {"start": pstart, "end": pend}) delta = datetime.timedelta(seconds=self.options.time_threshold) time_threshold = timeutils.utcnow() - delta - LOG.debug("Filtering deleted domains before %s", time_threshold) + LOG.debug("Filtering deleted zones before %s", time_threshold) criterion = self._filter_between('shard') criterion['deleted'] = '!0' @@ -139,7 +139,7 @@ class DeletedDomainPurgeTask(PeriodicTask): ctxt = context.DesignateContext.get_admin_context() ctxt.all_tenants = True - self.central_api.purge_domains( + self.central_api.purge_zones( ctxt, criterion, limit=self.options.batch_size, @@ -225,4 +225,4 @@ class PeriodicSecondaryRefreshTask(PeriodicTask): msg = "Zone %(id)s has %(seconds)d seconds since last transfer, " \ "executing AXFR" LOG.debug(msg % {"id": zone.id, "seconds": seconds}) - self.central_api.xfr_domain(ctxt, zone.id) + self.central_api.xfr_zone(ctxt, zone.id) diff --git a/etc/designate/policy.json b/etc/designate/policy.json index 9f101d57..d4645b2c 100644 --- a/etc/designate/policy.json +++ b/etc/designate/policy.json @@ -1,6 +1,6 @@ { "admin": "role:admin or is_admin:True", - "primary_zone": "target.domain_type:SECONDARY", + "primary_zone": "target.zone_type:SECONDARY", "owner": "tenant:%(tenant_id)s", "admin_or_owner": "rule:admin or rule:owner", @@ -9,7 +9,7 @@ "admin_or_owner_or_target":"rule:owner_or_target or rule:admin", "admin_or_target":"rule:admin or rule:target", - "domain_primary_or_admin": "('PRIMARY':%(domain_type)s and rule:admin_or_owner) OR ('SECONDARY':%(domain_type)s AND is_admin:True)", + "zone_primary_or_admin": "('PRIMARY':%(zone_type)s and rule:admin_or_owner) OR ('SECONDARY':%(zone_type)s AND is_admin:True)", "default": "rule:admin_or_owner", @@ -40,27 +40,27 @@ "get_tenant": "rule:admin", "count_tenants": "rule:admin", - "create_domain": "rule:admin_or_owner", - "get_domains": "rule:admin_or_owner", - "get_domain": "rule:admin_or_owner", - "get_domain_servers": "rule:admin_or_owner", - "find_domains": "rule:admin_or_owner", - "find_domain": "rule:admin_or_owner", - "update_domain": "rule:admin_or_owner", - "delete_domain": "rule:admin_or_owner", - "xfr_domain": "rule:admin_or_owner", - "abandon_domain": "rule:admin", - "count_domains": "rule:admin_or_owner", - "purge_domains": "rule:admin", - "touch_domain": "rule:admin_or_owner", + "create_zone": "rule:admin_or_owner", + "get_zones": "rule:admin_or_owner", + "get_zone": "rule:admin_or_owner", + "get_zone_servers": "rule:admin_or_owner", + "find_zones": "rule:admin_or_owner", + "find_zone": "rule:admin_or_owner", + "update_zone": "rule:admin_or_owner", + "delete_zone": "rule:admin_or_owner", + "xfr_zone": "rule:admin_or_owner", + "abandon_zone": "rule:admin", + "count_zones": "rule:admin_or_owner", + "purge_zones": "rule:admin", + "touch_zone": "rule:admin_or_owner", - "create_recordset": "rule:domain_primary_or_admin", + "create_recordset": "rule:zone_primary_or_admin", "get_recordsets": "rule:admin_or_owner", "get_recordset": "rule:admin_or_owner", "find_recordsets": "rule:admin_or_owner", "find_recordset": "rule:admin_or_owner", - "update_recordset": "rule:domain_primary_or_admin", - "delete_recordset": "rule:domain_primary_or_admin", + "update_recordset": "rule:zone_primary_or_admin", + "delete_recordset": "rule:zone_primary_or_admin", "count_recordset": "rule:admin_or_owner", "create_record": "rule:admin_or_owner", diff --git a/functionaltests/api/v2/test_zone_ownership_transfers.py b/functionaltests/api/v2/test_zone_ownership_transfers.py index b3fa34c8..4e21c7e1 100644 --- a/functionaltests/api/v2/test_zone_ownership_transfers.py +++ b/functionaltests/api/v2/test_zone_ownership_transfers.py @@ -182,7 +182,7 @@ class TransferZoneOwnerShipTest(DesignateV2Test): client = ZoneClient.as_user('default') self._assert_exception( - exceptions.NotFound, 'domain_not_found', 404, + exceptions.NotFound, 'zone_not_found', 404, client.get_zone, self.zone.id) resp, zone = ZoneClient.as_user('alt').get_zone(self.zone.id) diff --git a/setup.cfg b/setup.cfg index c6591329..6558f6bf 100644 --- a/setup.cfg +++ b/setup.cfg @@ -112,7 +112,7 @@ designate.manage = tlds = designate.manage.tlds:TLDCommands designate.zone_manager_tasks = - domain_purge = designate.zone_manager.tasks:DeletedDomainPurgeTask + zone_purge = designate.zone_manager.tasks:DeletedZonePurgeTask periodic_exists = designate.zone_manager.tasks:PeriodicExistsTask periodic_secondary_refresh = designate.zone_manager.tasks:PeriodicSecondaryRefreshTask