Removing more unused rpc calls
Removed unused central rpc calls and extended testing on previously untested paths. The following rpc calls were removed. - count_records - count_recordsets - count_zones - count_tenants - delete_zone_transfer_accept - find_blacklist - find_record - find_zone - find_zone_transfer_accept - find_zone_transfer_request - get_record - get_quota - update_zone_transfer_accept Change-Id: I705cfc06f56a1f1285e9c0d29541dc10505ae62f
This commit is contained in:
parent
11b8389389
commit
fc905bf760
@ -66,8 +66,9 @@ class CentralAPI(object):
|
||||
6.2 - Changed 'find_recordsets' method args
|
||||
6.3 - Changed 'update_status' method args
|
||||
6.4 - Removed unused record and diagnostic methods
|
||||
6.5 - Removed additional unused methods
|
||||
"""
|
||||
RPC_API_VERSION = '6.4'
|
||||
RPC_API_VERSION = '6.5'
|
||||
|
||||
# This allows us to mark some methods as not logged.
|
||||
# This can be for a few reasons - some methods my not actually call over
|
||||
@ -80,7 +81,7 @@ class CentralAPI(object):
|
||||
|
||||
target = messaging.Target(topic=self.topic,
|
||||
version=self.RPC_API_VERSION)
|
||||
self.client = rpc.get_client(target, version_cap='6.4')
|
||||
self.client = rpc.get_client(target, version_cap='6.5')
|
||||
|
||||
@classmethod
|
||||
def get_instance(cls):
|
||||
@ -104,10 +105,6 @@ class CentralAPI(object):
|
||||
def get_quotas(self, context, tenant_id):
|
||||
return self.client.call(context, 'get_quotas', tenant_id=tenant_id)
|
||||
|
||||
def get_quota(self, context, tenant_id, resource):
|
||||
return self.client.call(context, 'get_quota', tenant_id=tenant_id,
|
||||
resource=resource)
|
||||
|
||||
def set_quota(self, context, tenant_id, resource, hard_limit):
|
||||
return self.client.call(context, 'set_quota', tenant_id=tenant_id,
|
||||
resource=resource, hard_limit=hard_limit)
|
||||
@ -142,9 +139,6 @@ class CentralAPI(object):
|
||||
def get_tenant(self, context, tenant_id):
|
||||
return self.client.call(context, 'get_tenant', tenant_id=tenant_id)
|
||||
|
||||
def count_tenants(self, context):
|
||||
return self.client.call(context, 'count_tenants')
|
||||
|
||||
# Zone Methods
|
||||
def create_zone(self, context, zone):
|
||||
return self.client.call(context, 'create_zone', zone=zone)
|
||||
@ -162,9 +156,6 @@ class CentralAPI(object):
|
||||
marker=marker, limit=limit, sort_key=sort_key,
|
||||
sort_dir=sort_dir)
|
||||
|
||||
def find_zone(self, context, criterion=None):
|
||||
return self.client.call(context, 'find_zone', criterion=criterion)
|
||||
|
||||
def update_zone(self, context, zone, increment_serial=True):
|
||||
return self.client.call(context, 'update_zone', zone=zone,
|
||||
increment_serial=increment_serial)
|
||||
@ -176,9 +167,6 @@ class CentralAPI(object):
|
||||
return self.client.call(context, 'purge_zones',
|
||||
criterion=criterion, limit=limit)
|
||||
|
||||
def count_zones(self, context, criterion=None):
|
||||
return self.client.call(context, 'count_zones', criterion=criterion)
|
||||
|
||||
# TLD Methods
|
||||
def create_tld(self, context, tld):
|
||||
return self.client.call(context, 'create_tld', tld=tld)
|
||||
@ -232,29 +220,13 @@ class CentralAPI(object):
|
||||
recordset_id=recordset_id,
|
||||
increment_serial=increment_serial)
|
||||
|
||||
def count_recordsets(self, context, criterion=None):
|
||||
return self.client.call(context, 'count_recordsets',
|
||||
criterion=criterion)
|
||||
|
||||
# Record Methods
|
||||
def get_record(self, context, zone_id, recordset_id, record_id):
|
||||
return self.client.call(context, 'get_record',
|
||||
zone_id=zone_id,
|
||||
recordset_id=recordset_id,
|
||||
record_id=record_id)
|
||||
|
||||
def find_records(self, context, criterion=None, marker=None, limit=None,
|
||||
sort_key=None, sort_dir=None):
|
||||
return self.client.call(context, 'find_records', criterion=criterion,
|
||||
marker=marker, limit=limit, sort_key=sort_key,
|
||||
sort_dir=sort_dir)
|
||||
|
||||
def find_record(self, context, criterion=None):
|
||||
return self.client.call(context, 'find_record', criterion=criterion)
|
||||
|
||||
def count_records(self, context, criterion=None):
|
||||
return self.client.call(context, 'count_records', criterion=criterion)
|
||||
|
||||
# Misc. Report combining counts for tenants, zones and records
|
||||
def count_report(self, context, criterion=None):
|
||||
return self.client.call(context, 'count_report', criterion=criterion)
|
||||
@ -285,9 +257,6 @@ class CentralAPI(object):
|
||||
context, 'find_blacklists', criterion=criterion, marker=marker,
|
||||
limit=limit, sort_key=sort_key, sort_dir=sort_dir)
|
||||
|
||||
def find_blacklist(self, context, criterion):
|
||||
return self.client.call(context, 'find_blacklist', criterion=criterion)
|
||||
|
||||
def update_blacklist(self, context, blacklist):
|
||||
return self.client.call(context, 'update_blacklist',
|
||||
blacklist=blacklist)
|
||||
@ -340,11 +309,6 @@ class CentralAPI(object):
|
||||
context, 'find_zone_transfer_requests', criterion=criterion,
|
||||
marker=marker, limit=limit, sort_key=sort_key, sort_dir=sort_dir)
|
||||
|
||||
def find_zone_transfer_request(self, context, zone_transfer_request):
|
||||
return self.client.call(
|
||||
context, 'find_zone_transfer_request',
|
||||
zone_transfer_request=zone_transfer_request)
|
||||
|
||||
def update_zone_transfer_request(self, context, zone_transfer_request):
|
||||
return self.client.call(
|
||||
context, 'update_zone_transfer_request',
|
||||
@ -373,22 +337,6 @@ class CentralAPI(object):
|
||||
context, 'find_zone_transfer_accepts', criterion=criterion,
|
||||
marker=marker, limit=limit, sort_key=sort_key, sort_dir=sort_dir)
|
||||
|
||||
def find_zone_transfer_accept(self, context, zone_transfer_accept):
|
||||
return self.client.call(
|
||||
context, 'find_zone_transfer_accept',
|
||||
zone_transfer_accept=zone_transfer_accept)
|
||||
|
||||
def update_zone_transfer_accept(self, context, zone_transfer_accept):
|
||||
return self.client.call(
|
||||
context, 'update_zone_transfer_accept',
|
||||
zone_transfer_accept=zone_transfer_accept)
|
||||
|
||||
def delete_zone_transfer_accept(self, context, zone_transfer_accept_id):
|
||||
return self.client.call(
|
||||
context,
|
||||
'delete_zone_transfer_accept',
|
||||
zone_transfer_accept_id=zone_transfer_accept_id)
|
||||
|
||||
def xfr_zone(self, context, zone_id):
|
||||
return self.client.call(context, 'xfr_zone', zone_id=zone_id)
|
||||
|
||||
|
@ -184,7 +184,7 @@ def notification(notification_type):
|
||||
|
||||
|
||||
class Service(service.RPCService):
|
||||
RPC_API_VERSION = '6.4'
|
||||
RPC_API_VERSION = '6.5'
|
||||
|
||||
target = messaging.Target(version=RPC_API_VERSION)
|
||||
|
||||
@ -681,19 +681,6 @@ class Service(service.RPCService):
|
||||
|
||||
return self.quota.get_quotas(context, tenant_id)
|
||||
|
||||
@rpc.expected_exceptions()
|
||||
def get_quota(self, context, tenant_id, resource):
|
||||
if policy.enforce_new_defaults():
|
||||
target = {
|
||||
constants.RBAC_PROJECT_ID: tenant_id,
|
||||
'resource': resource
|
||||
}
|
||||
else:
|
||||
target = {'tenant_id': tenant_id, 'resource': resource}
|
||||
policy.check('get_quota', context, target)
|
||||
|
||||
return self.quota.get_quota(context, tenant_id, resource)
|
||||
|
||||
@rpc.expected_exceptions()
|
||||
@transaction
|
||||
def set_quota(self, context, tenant_id, resource, hard_limit):
|
||||
@ -1077,17 +1064,6 @@ class Service(service.RPCService):
|
||||
return self.storage.find_zones(context, criterion, marker, limit,
|
||||
sort_key, sort_dir)
|
||||
|
||||
@rpc.expected_exceptions()
|
||||
def find_zone(self, context, criterion=None):
|
||||
if policy.enforce_new_defaults():
|
||||
target = {constants.RBAC_PROJECT_ID: context.project_id}
|
||||
else:
|
||||
target = {'tenant_id': context.project_id}
|
||||
|
||||
policy.check('find_zone', context, target)
|
||||
|
||||
return self.storage.find_zone(context, criterion)
|
||||
|
||||
@rpc.expected_exceptions()
|
||||
@notification('dns.domain.update')
|
||||
@notification('dns.zone.update')
|
||||
@ -1664,43 +1640,6 @@ class Service(service.RPCService):
|
||||
return self.storage.count_recordsets(context, criterion)
|
||||
|
||||
# Record Methods
|
||||
@rpc.expected_exceptions()
|
||||
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 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
|
||||
if recordset.id != record.recordset_id:
|
||||
raise exceptions.RecordNotFound()
|
||||
|
||||
if policy.enforce_new_defaults():
|
||||
target = {
|
||||
'zone_id': zone_id,
|
||||
'zone_name': zone.name,
|
||||
'recordset_id': recordset_id,
|
||||
'recordset_name': recordset.name,
|
||||
'record_id': record.id,
|
||||
constants.RBAC_PROJECT_ID: zone.tenant_id
|
||||
}
|
||||
else:
|
||||
target = {
|
||||
'zone_id': zone_id,
|
||||
'zone_name': zone.name,
|
||||
'recordset_id': recordset_id,
|
||||
'recordset_name': recordset.name,
|
||||
'record_id': record.id,
|
||||
'tenant_id': zone.tenant_id
|
||||
}
|
||||
|
||||
policy.check('get_record', context, target)
|
||||
|
||||
return record
|
||||
|
||||
@rpc.expected_exceptions()
|
||||
def find_records(self, context, criterion=None, marker=None, limit=None,
|
||||
sort_key=None, sort_dir=None):
|
||||
@ -1714,17 +1653,6 @@ class Service(service.RPCService):
|
||||
return self.storage.find_records(context, criterion, marker, limit,
|
||||
sort_key, sort_dir)
|
||||
|
||||
@rpc.expected_exceptions()
|
||||
def find_record(self, context, criterion=None):
|
||||
|
||||
if policy.enforce_new_defaults():
|
||||
target = {constants.RBAC_PROJECT_ID: context.project_id}
|
||||
else:
|
||||
target = {'tenant_id': context.project_id}
|
||||
policy.check('find_record', context, target)
|
||||
|
||||
return self.storage.find_record(context, criterion)
|
||||
|
||||
@rpc.expected_exceptions()
|
||||
def count_records(self, context, criterion=None):
|
||||
if criterion is None:
|
||||
@ -2154,14 +2082,6 @@ class Service(service.RPCService):
|
||||
|
||||
return blacklists
|
||||
|
||||
@rpc.expected_exceptions()
|
||||
def find_blacklist(self, context, criterion):
|
||||
policy.check('find_blacklist', context)
|
||||
|
||||
blacklist = self.storage.find_blacklist(context, criterion)
|
||||
|
||||
return blacklist
|
||||
|
||||
@rpc.expected_exceptions()
|
||||
@notification('dns.blacklist.update')
|
||||
@transaction
|
||||
@ -2511,20 +2431,6 @@ class Service(service.RPCService):
|
||||
|
||||
return requests
|
||||
|
||||
@rpc.expected_exceptions()
|
||||
def find_zone_transfer_request(self, context, criterion):
|
||||
if policy.enforce_new_defaults():
|
||||
target = {
|
||||
constants.RBAC_PROJECT_ID: context.project_id,
|
||||
}
|
||||
else:
|
||||
target = {
|
||||
'tenant_id': context.project_id,
|
||||
}
|
||||
|
||||
policy.check('find_zone_transfer_request', context, target)
|
||||
return self.storage.find_zone_transfer_requests(context, criterion)
|
||||
|
||||
@rpc.expected_exceptions()
|
||||
@notification('dns.zone_transfer_request.update')
|
||||
@transaction
|
||||
@ -2668,51 +2574,6 @@ class Service(service.RPCService):
|
||||
marker, limit,
|
||||
sort_key, sort_dir)
|
||||
|
||||
@rpc.expected_exceptions()
|
||||
def find_zone_transfer_accept(self, context, criterion):
|
||||
policy.check('find_zone_transfer_accept', context)
|
||||
return self.storage.find_zone_transfer_accept(context, criterion)
|
||||
|
||||
@rpc.expected_exceptions()
|
||||
@notification('dns.zone_transfer_accept.update')
|
||||
@transaction
|
||||
def update_zone_transfer_accept(self, context, zone_transfer_accept):
|
||||
if policy.enforce_new_defaults():
|
||||
target = {
|
||||
constants.RBAC_PROJECT_ID: zone_transfer_accept.tenant_id
|
||||
}
|
||||
else:
|
||||
target = {
|
||||
'tenant_id': zone_transfer_accept.tenant_id
|
||||
}
|
||||
policy.check('update_zone_transfer_accept', context, target)
|
||||
accept = self.storage.update_zone_transfer_accept(
|
||||
context, zone_transfer_accept)
|
||||
|
||||
return accept
|
||||
|
||||
@rpc.expected_exceptions()
|
||||
@notification('dns.zone_transfer_accept.delete')
|
||||
@transaction
|
||||
def delete_zone_transfer_accept(self, context, zone_transfer_accept_id):
|
||||
# Get zone transfer accept
|
||||
zt_accept = self.storage.get_zone_transfer_accept(
|
||||
context, zone_transfer_accept_id)
|
||||
|
||||
if policy.enforce_new_defaults():
|
||||
target = {
|
||||
constants.RBAC_PROJECT_ID: zt_accept.tenant_id
|
||||
}
|
||||
else:
|
||||
target = {
|
||||
'tenant_id': zt_accept.tenant_id
|
||||
}
|
||||
|
||||
policy.check('delete_zone_transfer_accept', context, target)
|
||||
return self.storage.delete_zone_transfer_accept(
|
||||
context,
|
||||
zone_transfer_accept_id)
|
||||
|
||||
# Zone Import Methods
|
||||
@rpc.expected_exceptions()
|
||||
@notification('dns.zone_import.create')
|
||||
@ -2810,6 +2671,17 @@ class Service(service.RPCService):
|
||||
|
||||
self.update_zone_import(context, zone_import)
|
||||
|
||||
@rpc.expected_exceptions()
|
||||
@notification('dns.zone_import.update')
|
||||
def update_zone_import(self, context, zone_import):
|
||||
if policy.enforce_new_defaults():
|
||||
target = {constants.RBAC_PROJECT_ID: zone_import.tenant_id}
|
||||
else:
|
||||
target = {'tenant_id': zone_import.tenant_id}
|
||||
policy.check('update_zone_import', context, target)
|
||||
|
||||
return self.storage.update_zone_import(context, zone_import)
|
||||
|
||||
@rpc.expected_exceptions()
|
||||
def find_zone_imports(self, context, criterion=None, marker=None,
|
||||
limit=None, sort_key=None, sort_dir=None):
|
||||
@ -2842,17 +2714,6 @@ class Service(service.RPCService):
|
||||
policy.check('get_zone_import', context, target)
|
||||
return self.storage.get_zone_import(context, zone_import_id)
|
||||
|
||||
@rpc.expected_exceptions()
|
||||
@notification('dns.zone_import.update')
|
||||
def update_zone_import(self, context, zone_import):
|
||||
if policy.enforce_new_defaults():
|
||||
target = {constants.RBAC_PROJECT_ID: zone_import.tenant_id}
|
||||
else:
|
||||
target = {'tenant_id': zone_import.tenant_id}
|
||||
policy.check('update_zone_import', context, target)
|
||||
|
||||
return self.storage.update_zone_import(context, zone_import)
|
||||
|
||||
@rpc.expected_exceptions()
|
||||
@notification('dns.zone_import.delete')
|
||||
@transaction
|
||||
|
@ -28,12 +28,6 @@ deprecated_create_blacklist = policy.DeprecatedRule(
|
||||
deprecated_reason=DEPRECATED_REASON,
|
||||
deprecated_since=versionutils.deprecated.WALLABY
|
||||
)
|
||||
deprecated_find_blacklist = policy.DeprecatedRule(
|
||||
name="find_blacklist",
|
||||
check_str=base.RULE_ADMIN,
|
||||
deprecated_reason=DEPRECATED_REASON,
|
||||
deprecated_since=versionutils.deprecated.WALLABY
|
||||
)
|
||||
deprecated_find_blacklists = policy.DeprecatedRule(
|
||||
name="find_blacklists",
|
||||
check_str=base.RULE_ADMIN,
|
||||
@ -80,19 +74,6 @@ rules = [
|
||||
],
|
||||
deprecated_rule=deprecated_create_blacklist
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
name="find_blacklist",
|
||||
check_str=base.SYSTEM_READER,
|
||||
scope_types=['system'],
|
||||
description='Find blacklist.',
|
||||
operations=[
|
||||
{
|
||||
'path': '/v2/blacklists',
|
||||
'method': 'GET'
|
||||
}
|
||||
],
|
||||
deprecated_rule=deprecated_find_blacklist
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
name="find_blacklists",
|
||||
check_str=base.SYSTEM_READER,
|
||||
|
@ -28,12 +28,6 @@ deprecated_get_quotas = policy.DeprecatedRule(
|
||||
deprecated_reason=DEPRECATED_REASON,
|
||||
deprecated_since=versionutils.deprecated.WALLABY
|
||||
)
|
||||
deprecated_get_quota = policy.DeprecatedRule(
|
||||
name="get_quota",
|
||||
check_str=base.RULE_ADMIN_OR_OWNER,
|
||||
deprecated_reason=DEPRECATED_REASON,
|
||||
deprecated_since=versionutils.deprecated.WALLABY
|
||||
)
|
||||
deprecated_set_quota = policy.DeprecatedRule(
|
||||
name="set_quota",
|
||||
check_str=base.RULE_ADMIN,
|
||||
@ -61,12 +55,6 @@ rules = [
|
||||
],
|
||||
deprecated_rule=deprecated_get_quotas
|
||||
),
|
||||
policy.RuleDefault(
|
||||
name="get_quota",
|
||||
check_str=base.SYSTEM_OR_PROJECT_READER,
|
||||
scope_types=['system', 'project'],
|
||||
deprecated_rule=deprecated_get_quota
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
name="set_quota",
|
||||
check_str=base.SYSTEM_ADMIN,
|
||||
|
@ -40,24 +40,6 @@ deprecated_find_zone_transfer_accepts = policy.DeprecatedRule(
|
||||
deprecated_reason=DEPRECATED_REASON,
|
||||
deprecated_since=versionutils.deprecated.WALLABY
|
||||
)
|
||||
deprecated_find_zone_transfer_accept = policy.DeprecatedRule(
|
||||
name="find_zone_transfer_accept",
|
||||
check_str=base.RULE_ADMIN,
|
||||
deprecated_reason=DEPRECATED_REASON,
|
||||
deprecated_since=versionutils.deprecated.WALLABY
|
||||
)
|
||||
deprecated_update_zone_transfer_accept = policy.DeprecatedRule(
|
||||
name="update_zone_transfer_accept",
|
||||
check_str=base.RULE_ADMIN,
|
||||
deprecated_reason=DEPRECATED_REASON,
|
||||
deprecated_since=versionutils.deprecated.WALLABY
|
||||
)
|
||||
deprecated_delete_zone_transfer_accept = policy.DeprecatedRule(
|
||||
name="delete_zone_transfer_accept",
|
||||
check_str=base.RULE_ADMIN,
|
||||
deprecated_reason=DEPRECATED_REASON,
|
||||
deprecated_since=versionutils.deprecated.WALLABY
|
||||
)
|
||||
|
||||
|
||||
rules = [
|
||||
@ -100,31 +82,6 @@ rules = [
|
||||
],
|
||||
deprecated_rule=deprecated_find_zone_transfer_accepts
|
||||
),
|
||||
policy.RuleDefault(
|
||||
name="find_zone_transfer_accept",
|
||||
check_str=base.SYSTEM_READER,
|
||||
scope_types=['system'],
|
||||
deprecated_rule=deprecated_find_zone_transfer_accept
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
name="update_zone_transfer_accept",
|
||||
check_str=base.SYSTEM_ADMIN,
|
||||
scope_types=['system'],
|
||||
description="Update a Zone Transfer Accept",
|
||||
operations=[
|
||||
{
|
||||
'path': '/v2/zones/tasks/transfer_accepts',
|
||||
'method': 'POST'
|
||||
}
|
||||
],
|
||||
deprecated_rule=deprecated_update_zone_transfer_accept
|
||||
),
|
||||
policy.RuleDefault(
|
||||
name="delete_zone_transfer_accept",
|
||||
check_str=base.SYSTEM_ADMIN,
|
||||
scope_types=['system'],
|
||||
deprecated_rule=deprecated_delete_zone_transfer_accept
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
|
@ -98,10 +98,6 @@ rules = [
|
||||
}
|
||||
],
|
||||
),
|
||||
policy.RuleDefault(
|
||||
name="find_zone_transfer_request",
|
||||
check_str=base.RULE_ANY
|
||||
),
|
||||
policy.DocumentedRuleDefault(
|
||||
name="update_zone_transfer_request",
|
||||
check_str=base.SYSTEM_ADMIN_OR_PROJECT_MEMBER,
|
||||
|
@ -88,8 +88,8 @@ class ApiV2ReverseFloatingIPTest(ApiV2TestCase):
|
||||
'managed_resource_id': fip['id'],
|
||||
'managed_tenant_id': context.project_id
|
||||
}
|
||||
zone_id = self.central_service.find_record(
|
||||
elevated_context, criterion=criterion).zone_id
|
||||
zone_id = self.central_service.find_records(
|
||||
elevated_context, criterion=criterion)[0].zone_id
|
||||
|
||||
# Simulate the unset on the backend
|
||||
zone_serial = self.central_service.get_zone(
|
||||
@ -256,8 +256,8 @@ class ApiV2ReverseFloatingIPTest(ApiV2TestCase):
|
||||
'managed_resource_id': fip['id'],
|
||||
'managed_tenant_id': context.project_id
|
||||
}
|
||||
zone_id = self.central_service.find_record(
|
||||
elevated_context, criterion=criterion).zone_id
|
||||
zone_id = self.central_service.find_records(
|
||||
elevated_context, criterion=criterion)[0].zone_id
|
||||
|
||||
# Simulate the unset on the backend
|
||||
zone_serial = self.central_service.get_zone(
|
||||
|
@ -131,6 +131,24 @@ class APIV2ZoneImportExportTest(ApiV2TestCase):
|
||||
exported.delete_rdataset(exported.origin, 'NS')
|
||||
self.assertEqual(imported, exported)
|
||||
|
||||
def test_delete_import(self):
|
||||
post_response = self.client.post('/zones/tasks/imports',
|
||||
self.get_zonefile_fixture(),
|
||||
headers={'Content-type': 'text/dns'})
|
||||
|
||||
import_id = post_response.json_body['id']
|
||||
|
||||
self.wait_for_import(import_id)
|
||||
|
||||
delete_response = self.client.delete(
|
||||
'/zones/tasks/imports/%s' % import_id,
|
||||
)
|
||||
|
||||
self.assertEqual('', delete_response.text)
|
||||
self._assert_exception(
|
||||
'not_found', 404, self.client.get, '/zones/imports/%s' % import_id
|
||||
)
|
||||
|
||||
# Metadata tests
|
||||
def test_metadata_exists_imports(self):
|
||||
response = self.client.get('/zones/tasks/imports')
|
||||
@ -154,9 +172,9 @@ class APIV2ZoneImportExportTest(ApiV2TestCase):
|
||||
self.assertEqual(0, response.json['metadata']['total_count'])
|
||||
|
||||
# Create a zone import
|
||||
response = self.client.post('/zones/tasks/imports',
|
||||
self.get_zonefile_fixture(),
|
||||
headers={'Content-type': 'text/dns'})
|
||||
self.client.post('/zones/tasks/imports',
|
||||
self.get_zonefile_fixture(),
|
||||
headers={'Content-type': 'text/dns'})
|
||||
|
||||
response = self.client.get('/zones/tasks/imports')
|
||||
|
||||
@ -168,3 +186,59 @@ class APIV2ZoneImportExportTest(ApiV2TestCase):
|
||||
|
||||
# There are no exported zones by default
|
||||
self.assertEqual(0, response.json['metadata']['total_count'])
|
||||
|
||||
def test_create_export(self):
|
||||
zone = self.create_zone()
|
||||
create_response = self.client.post(
|
||||
'/zones/%s/tasks/export' % zone['id']
|
||||
)
|
||||
|
||||
self.assertEqual('PENDING', create_response.json_body['status'])
|
||||
self.assertEqual(zone['id'], create_response.json_body['zone_id'])
|
||||
|
||||
get_response = self.client.get(
|
||||
'/zones/tasks/exports/%s' % create_response.json_body['id']
|
||||
)
|
||||
|
||||
self.assertEqual('PENDING', get_response.json_body['status'])
|
||||
self.assertEqual(zone['id'], get_response.json_body['zone_id'])
|
||||
|
||||
def test_update_export(self):
|
||||
zone = self.create_zone()
|
||||
create_response = self.client.post(
|
||||
'/zones/%s/tasks/export' % zone['id']
|
||||
)
|
||||
|
||||
self.assertEqual('PENDING', create_response.json_body['status'])
|
||||
self.assertEqual(zone['id'], create_response.json_body['zone_id'])
|
||||
|
||||
delete_response = self.client.delete(
|
||||
'/zones/tasks/exports/%s' % create_response.json_body['id']
|
||||
)
|
||||
|
||||
self.assertEqual('', delete_response.text)
|
||||
|
||||
self._assert_exception(
|
||||
'zone_export_not_found', 404, self.client.get,
|
||||
'/zones/tasks/exports/%s' % create_response.json_body['id']
|
||||
)
|
||||
|
||||
def test_delete_export(self):
|
||||
zone = self.create_zone()
|
||||
create_response = self.client.post(
|
||||
'/zones/%s/tasks/export' % zone['id']
|
||||
)
|
||||
|
||||
self.assertEqual('PENDING', create_response.json_body['status'])
|
||||
self.assertEqual(zone['id'], create_response.json_body['zone_id'])
|
||||
|
||||
delete_response = self.client.delete(
|
||||
'/zones/tasks/exports/%s' % create_response.json_body['id']
|
||||
)
|
||||
|
||||
self.assertEqual('', delete_response.text)
|
||||
|
||||
self._assert_exception(
|
||||
'zone_export_not_found', 404, self.client.get,
|
||||
'/zones/tasks/exports/%s' % create_response.json_body['id']
|
||||
)
|
||||
|
@ -843,22 +843,6 @@ class CentralServiceTest(CentralTestCase):
|
||||
|
||||
self.assertGreater(len(servers), 0)
|
||||
|
||||
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': zone_name}
|
||||
|
||||
zone = self.central_service.find_zone(
|
||||
self.admin_context, criterion)
|
||||
|
||||
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_zone(self, mock_notifier):
|
||||
# Create a zone
|
||||
@ -2022,48 +2006,6 @@ class CentralServiceTest(CentralTestCase):
|
||||
|
||||
self.assertEqual(exceptions.OverQuota, exc.exc_info[0])
|
||||
|
||||
def test_get_record(self):
|
||||
zone = self.create_zone()
|
||||
recordset = self.create_recordset(zone)
|
||||
expected = recordset.records[0]
|
||||
|
||||
# Retrieve it, and ensure it's the same
|
||||
record = self.central_service.get_record(
|
||||
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_zone_id(self):
|
||||
zone = self.create_zone()
|
||||
recordset = self.create_recordset(zone)
|
||||
other_zone = self.create_zone(fixture=1)
|
||||
expected = recordset.records[0]
|
||||
|
||||
exc = self.assertRaises(rpc_dispatcher.ExpectedException,
|
||||
self.central_service.get_record,
|
||||
self.admin_context, other_zone['id'],
|
||||
recordset['id'],
|
||||
expected['id'])
|
||||
|
||||
self.assertEqual(exceptions.RecordNotFound, exc.exc_info[0])
|
||||
|
||||
def test_get_record_incorrect_recordset_id(self):
|
||||
zone = self.create_zone()
|
||||
recordset = self.create_recordset(zone)
|
||||
other_recordset = self.create_recordset(zone, fixture=1)
|
||||
expected = recordset.records[0]
|
||||
|
||||
exc = self.assertRaises(rpc_dispatcher.ExpectedException,
|
||||
self.central_service.get_record,
|
||||
self.admin_context, zone['id'],
|
||||
other_recordset['id'],
|
||||
expected['id'])
|
||||
|
||||
# Ensure we get a 404 if we use the incorrect recordset_id
|
||||
self.assertEqual(exceptions.RecordNotFound, exc.exc_info[0])
|
||||
|
||||
def test_find_records(self):
|
||||
zone = self.create_zone()
|
||||
recordset = self.create_recordset(zone, records=[])
|
||||
@ -2105,25 +2047,6 @@ class CentralServiceTest(CentralTestCase):
|
||||
|
||||
self.assertEqual(2, len(records))
|
||||
|
||||
def test_find_record(self):
|
||||
zone = self.create_zone()
|
||||
recordset = self.create_recordset(zone)
|
||||
expected = recordset.records[0]
|
||||
|
||||
# Retrieve it, and ensure it's the same
|
||||
criterion = {
|
||||
'zone_id': zone['id'],
|
||||
'recordset_id': recordset['id'],
|
||||
'data': expected['data']
|
||||
}
|
||||
|
||||
record = self.central_service.find_record(
|
||||
self.admin_context, criterion)
|
||||
|
||||
self.assertEqual(expected['id'], record['id'])
|
||||
self.assertEqual(expected['data'], record['data'])
|
||||
self.assertIn('status', record)
|
||||
|
||||
def test_count_records(self):
|
||||
# in the beginning, there should be nothing
|
||||
records = self.central_service.count_records(self.admin_context)
|
||||
@ -2222,8 +2145,8 @@ class CentralServiceTest(CentralTestCase):
|
||||
criterion = {
|
||||
'managed_resource_id': fip['id'],
|
||||
'managed_tenant_id': context_a.project_id}
|
||||
zone_id = self.central_service.find_record(
|
||||
elevated_a, criterion).zone_id
|
||||
zone_id = self.central_service.find_records(
|
||||
elevated_a, criterion)[0].zone_id
|
||||
|
||||
self.network_api.fake.deallocate_floatingip(fip['id'])
|
||||
|
||||
@ -2234,7 +2157,7 @@ class CentralServiceTest(CentralTestCase):
|
||||
self.assertEqual(exceptions.NotFound, exc.exc_info[0])
|
||||
|
||||
# Ensure that the record is still in DB (No invalidation)
|
||||
self.central_service.find_record(elevated_a, criterion)
|
||||
self.central_service.find_records(elevated_a, criterion)
|
||||
|
||||
# Now give the fip id to tenant 'b' and see that it get's deleted
|
||||
self.network_api.fake.allocate_floatingip(
|
||||
@ -2251,7 +2174,7 @@ class CentralServiceTest(CentralTestCase):
|
||||
self.central_service.update_status(
|
||||
elevated_a, zone_id, 'SUCCESS', zone_serial, 'UPDATE')
|
||||
|
||||
record = self.central_service.find_record(elevated_a, criterion)
|
||||
record = self.central_service.find_records(elevated_a, criterion)[0]
|
||||
self.assertEqual('NONE', record.action)
|
||||
self.assertEqual('DELETED', record.status)
|
||||
|
||||
@ -2313,8 +2236,8 @@ class CentralServiceTest(CentralTestCase):
|
||||
criterion = {
|
||||
'managed_resource_id': fip['id'],
|
||||
'managed_tenant_id': context_a.project_id}
|
||||
zone_id = self.central_service.find_record(
|
||||
elevated_a, criterion).zone_id
|
||||
zone_id = self.central_service.find_records(
|
||||
elevated_a, criterion)[0].zone_id
|
||||
|
||||
# Simulate the update on the backend
|
||||
zone_serial = self.central_service.get_zone(
|
||||
@ -2328,7 +2251,7 @@ class CentralServiceTest(CentralTestCase):
|
||||
self.assertEqual(len(fips), 0)
|
||||
|
||||
# Ensure that the record is still in DB (No invalidation)
|
||||
self.central_service.find_record(elevated_a, criterion)
|
||||
self.central_service.find_records(elevated_a, criterion)
|
||||
|
||||
# Now give the fip id to tenant 'b' and see that it get's deleted
|
||||
self.network_api.fake.allocate_floatingip(
|
||||
@ -2345,7 +2268,7 @@ class CentralServiceTest(CentralTestCase):
|
||||
self.central_service.update_status(
|
||||
elevated_a, zone_id, 'SUCCESS', zone_serial, 'UPDATE')
|
||||
|
||||
record = self.central_service.find_record(elevated_a, criterion)
|
||||
record = self.central_service.find_records(elevated_a, criterion)[0]
|
||||
self.assertEqual('NONE', record.action)
|
||||
self.assertEqual('DELETED', record.status)
|
||||
|
||||
@ -2402,10 +2325,10 @@ class CentralServiceTest(CentralTestCase):
|
||||
elevated_context.all_tenants = True
|
||||
|
||||
# The zone created should have the default 0's uuid as owner
|
||||
zone = self.central_service.find_zone(
|
||||
zones = self.central_service.find_zones(
|
||||
elevated_context,
|
||||
{"tenant_id": tenant_id})
|
||||
self.assertEqual(tenant_id, zone.tenant_id)
|
||||
self.assertEqual(tenant_id, zones[0].tenant_id)
|
||||
|
||||
def test_set_floatingip_removes_old_record(self):
|
||||
context_a = self.get_context(project_id='a')
|
||||
@ -2426,8 +2349,8 @@ class CentralServiceTest(CentralTestCase):
|
||||
criterion = {
|
||||
'managed_resource_id': fip['id'],
|
||||
'managed_tenant_id': context_a.project_id}
|
||||
zone_id = self.central_service.find_record(
|
||||
elevated_a, criterion).zone_id
|
||||
zone_id = self.central_service.find_records(
|
||||
elevated_a, criterion)[0].zone_id
|
||||
|
||||
fixture2 = self.get_ptr_fixture(fixture=1)
|
||||
self.central_service.update_floatingip(
|
||||
@ -2556,17 +2479,6 @@ class CentralServiceTest(CentralTestCase):
|
||||
self.assertEqual(values1['pattern'], blacklists[0]['pattern'])
|
||||
self.assertEqual(values2['pattern'], blacklists[1]['pattern'])
|
||||
|
||||
def test_find_blacklist(self):
|
||||
# Create a blacklisted zone
|
||||
expected = self.create_blacklist(fixture=0)
|
||||
|
||||
# Retrieve the newly created blacklist
|
||||
blacklist = self.central_service.find_blacklist(
|
||||
self.admin_context, {'id': expected['id']})
|
||||
|
||||
self.assertEqual(expected['pattern'], blacklist['pattern'])
|
||||
self.assertEqual(expected['description'], blacklist['description'])
|
||||
|
||||
def test_update_blacklist(self):
|
||||
# Create a blacklisted zone
|
||||
blacklist = self.create_blacklist(fixture=0)
|
||||
@ -2912,30 +2824,6 @@ class CentralServiceTest(CentralTestCase):
|
||||
|
||||
self.assertEqual(exceptions.ZoneNotFound, exc.exc_info[0])
|
||||
|
||||
def test_update_status_delete_last_record(self):
|
||||
zone = self.create_zone()
|
||||
recordset = self.create_recordset(zone)
|
||||
record = recordset.records[0]
|
||||
|
||||
# Delete the record
|
||||
recordset.records = []
|
||||
self.central_service.update_recordset(self.admin_context, recordset)
|
||||
|
||||
# Simulate the record 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', zone_serial, 'UPDATE')
|
||||
|
||||
# Fetch the record again, ensuring an exception is raised
|
||||
exc = self.assertRaises(rpc_dispatcher.ExpectedException,
|
||||
self.central_service.get_record,
|
||||
self.admin_context, zone['id'],
|
||||
recordset['id'],
|
||||
record['id'])
|
||||
|
||||
self.assertEqual(exceptions.RecordNotFound, exc.exc_info[0])
|
||||
|
||||
def test_update_status_create_zone(self):
|
||||
zone = self.create_zone()
|
||||
|
||||
@ -3244,7 +3132,6 @@ class CentralServiceTest(CentralTestCase):
|
||||
|
||||
zone = self.create_zone(context=tenant_1_context)
|
||||
recordset = self.create_recordset(zone, context=tenant_1_context)
|
||||
record = recordset.records[0]
|
||||
|
||||
zone_transfer_request = self.create_zone_transfer_request(
|
||||
zone, context=tenant_1_context)
|
||||
@ -3264,11 +3151,12 @@ class CentralServiceTest(CentralTestCase):
|
||||
result['zone'] = self.central_service.get_zone(
|
||||
admin_context, zone.id)
|
||||
|
||||
result['recordset'] = self.central_service.get_recordset(
|
||||
recordset = self.central_service.get_recordset(
|
||||
admin_context, zone.id, recordset.id)
|
||||
|
||||
result['record'] = self.central_service.get_record(
|
||||
admin_context, zone.id, recordset.id, record.id)
|
||||
result['recordset'] = recordset
|
||||
|
||||
result['record'] = recordset.records[0]
|
||||
|
||||
result['zt_accept'] = self.central_service.get_zone_transfer_accept(
|
||||
admin_context, zone_transfer_accept.id)
|
||||
@ -3294,7 +3182,6 @@ class CentralServiceTest(CentralTestCase):
|
||||
|
||||
zone = self.create_zone(context=tenant_1_context)
|
||||
recordset = self.create_recordset(zone, context=tenant_1_context)
|
||||
record = recordset.records[0]
|
||||
|
||||
zone_transfer_request = self.create_zone_transfer_request(
|
||||
zone,
|
||||
@ -3316,11 +3203,12 @@ class CentralServiceTest(CentralTestCase):
|
||||
result['zone'] = self.central_service.get_zone(
|
||||
admin_context, zone.id)
|
||||
|
||||
result['recordset'] = self.central_service.get_recordset(
|
||||
recordset = self.central_service.get_recordset(
|
||||
admin_context, zone.id, recordset.id)
|
||||
|
||||
result['record'] = self.central_service.get_record(
|
||||
admin_context, zone.id, recordset.id, record.id)
|
||||
result['recordset'] = recordset
|
||||
|
||||
result['record'] = recordset.records[0]
|
||||
|
||||
result['zt_accept'] = self.central_service.get_zone_transfer_accept(
|
||||
admin_context, zone_transfer_accept.id)
|
||||
@ -3612,7 +3500,7 @@ class CentralServiceTest(CentralTestCase):
|
||||
|
||||
# Perform the update
|
||||
zone_import = self.central_service.update_zone_import(
|
||||
self.admin_context_all_tenants, zone_import)
|
||||
self.admin_context_all_tenants, zone_import)
|
||||
|
||||
# Fetch the zone_import again
|
||||
zone_import = self.central_service.get_zone_import(context,
|
||||
|
@ -3179,7 +3179,7 @@ class StorageTestCase(object):
|
||||
|
||||
# Update storage
|
||||
zone_import = self.storage.update_zone_import(self.admin_context,
|
||||
zone_import)
|
||||
zone_import)
|
||||
|
||||
# Verify the new value
|
||||
self.assertEqual('COMPLETE', zone_import.status)
|
||||
|
@ -935,15 +935,6 @@ class CentralZoneTestCase(CentralBasic):
|
||||
designate.central.service.policy.check.call_args[0]
|
||||
self.assertEqual('find_zones', pcheck)
|
||||
|
||||
def test_find_zone(self):
|
||||
self.context = RoObject(project_id='t')
|
||||
self.service.storage.find_zone = mock.Mock()
|
||||
self.service.find_zone(self.context)
|
||||
self.assertTrue(self.service.storage.find_zone.called)
|
||||
pcheck, ctx, target = \
|
||||
designate.central.service.policy.check.call_args[0]
|
||||
self.assertEqual('find_zone', pcheck)
|
||||
|
||||
def test_delete_zone_has_subzone(self):
|
||||
self.context.abandon = False
|
||||
self.service.storage.get_zone.return_value = RoObject(
|
||||
@ -1500,83 +1491,6 @@ class CentralZoneTestCase(CentralBasic):
|
||||
self.service.storage.count_recordsets.call_args[0][1]
|
||||
)
|
||||
|
||||
def test_get_record_not_found(self):
|
||||
self.service.storage.get_zone.return_value = RoObject(
|
||||
id=CentralZoneTestCase.zone__id_2,
|
||||
)
|
||||
self.service.storage.get_recordset.return_value = RoObject(
|
||||
zone_id=CentralZoneTestCase.recordset__id
|
||||
)
|
||||
|
||||
exc = self.assertRaises(rpc_dispatcher.ExpectedException,
|
||||
self.service.get_record,
|
||||
self.context,
|
||||
CentralZoneTestCase.zone__id_2,
|
||||
CentralZoneTestCase.recordset__id,
|
||||
CentralZoneTestCase.record__id)
|
||||
|
||||
self.assertEqual(exceptions.RecordNotFound, exc.exc_info[0])
|
||||
|
||||
def test_get_record_not_found_2(self):
|
||||
self.service.storage.get_zone.return_value = RoObject(
|
||||
id=CentralZoneTestCase.zone__id_2,
|
||||
name='example.org.',
|
||||
tenant_id=2,
|
||||
)
|
||||
self.service.storage.get_recordset.return_value = RoObject(
|
||||
zone_id=CentralZoneTestCase.zone__id_2,
|
||||
id=999, # not matching record.recordset_id
|
||||
name='foo'
|
||||
)
|
||||
self.service.storage.get_record.return_value = RoObject(
|
||||
id=CentralZoneTestCase.record__id,
|
||||
zone_id=CentralZoneTestCase.zone__id_2,
|
||||
recordset_id=CentralZoneTestCase.recordset__id
|
||||
)
|
||||
|
||||
exc = self.assertRaises(rpc_dispatcher.ExpectedException,
|
||||
self.service.get_record,
|
||||
self.context,
|
||||
CentralZoneTestCase.zone__id_2,
|
||||
CentralZoneTestCase.recordset__id,
|
||||
CentralZoneTestCase.record__id)
|
||||
|
||||
self.assertEqual(exceptions.RecordNotFound, exc.exc_info[0])
|
||||
|
||||
def test_get_record(self):
|
||||
self.service.storage.get_zone.return_value = RoObject(
|
||||
id=CentralZoneTestCase.zone__id,
|
||||
name='example.org.',
|
||||
tenant_id=2,
|
||||
)
|
||||
self.service.storage.get_recordset.return_value = RoObject(
|
||||
zone_id=CentralZoneTestCase.zone__id,
|
||||
id=CentralZoneTestCase.recordset__id,
|
||||
name='foo'
|
||||
)
|
||||
self.service.storage.get_record.return_value = RoObject(
|
||||
id=CentralZoneTestCase.record__id,
|
||||
zone_id=CentralZoneTestCase.zone__id,
|
||||
recordset_id=CentralZoneTestCase.recordset__id
|
||||
)
|
||||
self.service.get_record(self.context,
|
||||
CentralZoneTestCase.zone__id_2,
|
||||
CentralZoneTestCase.recordset__id_2,
|
||||
CentralZoneTestCase.record__id_2)
|
||||
self.assertEqual(
|
||||
'get_record',
|
||||
designate.central.service.policy.check.call_args[0][0]
|
||||
)
|
||||
t, ctx, target = designate.central.service.policy.check.call_args[0]
|
||||
self.assertEqual('get_record', t)
|
||||
self.assertEqual({
|
||||
'zone_id': CentralZoneTestCase.zone__id_2,
|
||||
'zone_name': 'example.org.',
|
||||
'record_id': CentralZoneTestCase.record__id,
|
||||
'recordset_id': CentralZoneTestCase.recordset__id_2,
|
||||
'recordset_name': 'foo',
|
||||
'project_id': 2}, target)
|
||||
|
||||
def test_count_records(self):
|
||||
self.service.count_records(self.context)
|
||||
t, ctx, target = designate.central.service.policy.check.call_args[0]
|
||||
|
@ -0,0 +1,21 @@
|
||||
---
|
||||
upgrade:
|
||||
- |
|
||||
Removed the following unused central rpc calls. This should not impact
|
||||
normal installations, but if these are used in any custom written backends
|
||||
or plugins that you are using, you will need to update your code before
|
||||
upgrading.
|
||||
|
||||
- ``count_records``
|
||||
- ``count_recordsets``
|
||||
- ``count_zones``
|
||||
- ``count_tenants``
|
||||
- ``delete_zone_transfer_accept``
|
||||
- ``find_blacklist``
|
||||
- ``find_record``
|
||||
- ``find_zone``
|
||||
- ``find_zone_transfer_accept``
|
||||
- ``find_zone_transfer_request``
|
||||
- ``get_record``
|
||||
- ``get_quota``
|
||||
- ``update_zone_transfer_accept``
|
Loading…
Reference in New Issue
Block a user