Add Decorator to log RPCAPI Calls

For each RPCAPI log a message on call of function

Change-Id: I969ce90ae032e04ae1d49f6837a6a74a8f12bf80
Partially-Implements: blueprint bp/standardize-logging
This commit is contained in:
Graham Hayes 2015-03-24 18:24:59 +00:00 committed by Graham Hayes
parent 0fa168520d
commit 801915576f
5 changed files with 62 additions and 157 deletions

View File

@ -13,19 +13,20 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging from oslo_log import log as logging
import oslo_messaging as messaging import oslo_messaging as messaging
from designate.i18n import _LI
from designate import rpc from designate import rpc
from designate.loggingutils import rpc_logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
CENTRAL_API = None CENTRAL_API = None
@rpc_logging(LOG, 'central')
class CentralAPI(object): class CentralAPI(object):
""" """
Client side of the central RPC API. Client side of the central RPC API.
@ -58,6 +59,12 @@ class CentralAPI(object):
""" """
RPC_API_VERSION = '6.1' RPC_API_VERSION = '6.1'
# This allows us to mark some methods as not logged.
# This can be for a few reasons - some methods my not actually call over
# RPC, or may be so noisy that logging them is not useful
# This should be an array of strings that match the function names
LOGGING_BLACKLIST = ['update_service_status']
def __init__(self, topic=None): def __init__(self, topic=None):
topic = topic if topic else cfg.CONF.central_topic topic = topic if topic else cfg.CONF.central_topic
@ -80,196 +87,150 @@ class CentralAPI(object):
# Misc Methods # Misc Methods
def get_absolute_limits(self, context): def get_absolute_limits(self, context):
LOG.info(_LI("get_absolute_limits: "
"Calling central's get_absolute_limits."))
return self.client.call(context, 'get_absolute_limits') return self.client.call(context, 'get_absolute_limits')
# Quota Methods # Quota Methods
def get_quotas(self, context, tenant_id): def get_quotas(self, context, tenant_id):
LOG.info(_LI("get_quotas: Calling central's get_quotas."))
return self.client.call(context, 'get_quotas', tenant_id=tenant_id) return self.client.call(context, 'get_quotas', tenant_id=tenant_id)
def get_quota(self, context, tenant_id, resource): def get_quota(self, context, tenant_id, resource):
LOG.info(_LI("get_quota: Calling central's get_quota."))
return self.client.call(context, 'get_quota', tenant_id=tenant_id, return self.client.call(context, 'get_quota', tenant_id=tenant_id,
resource=resource) resource=resource)
def set_quota(self, context, tenant_id, resource, hard_limit): def set_quota(self, context, tenant_id, resource, hard_limit):
LOG.info(_LI("set_quota: Calling central's set_quota."))
return self.client.call(context, 'set_quota', tenant_id=tenant_id, return self.client.call(context, 'set_quota', tenant_id=tenant_id,
resource=resource, hard_limit=hard_limit) resource=resource, hard_limit=hard_limit)
def reset_quotas(self, context, tenant_id): def reset_quotas(self, context, tenant_id):
LOG.info(_LI("reset_quotas: Calling central's reset_quotas."))
return self.client.call(context, 'reset_quotas', tenant_id=tenant_id) return self.client.call(context, 'reset_quotas', tenant_id=tenant_id)
# TSIG Key Methods # TSIG Key Methods
def create_tsigkey(self, context, tsigkey): def create_tsigkey(self, context, tsigkey):
LOG.info(_LI("create_tsigkey: Calling central's create_tsigkey."))
return self.client.call(context, 'create_tsigkey', tsigkey=tsigkey) return self.client.call(context, 'create_tsigkey', tsigkey=tsigkey)
def find_tsigkeys(self, context, criterion=None, marker=None, limit=None, def find_tsigkeys(self, context, criterion=None, marker=None, limit=None,
sort_key=None, sort_dir=None): sort_key=None, sort_dir=None):
LOG.info(_LI("find_tsigkeys: Calling central's find_tsigkeys."))
return self.client.call(context, 'find_tsigkeys', criterion=criterion, return self.client.call(context, 'find_tsigkeys', criterion=criterion,
marker=marker, limit=limit, sort_key=sort_key, marker=marker, limit=limit, sort_key=sort_key,
sort_dir=sort_dir) sort_dir=sort_dir)
def get_tsigkey(self, context, tsigkey_id): def get_tsigkey(self, context, tsigkey_id):
LOG.info(_LI("get_tsigkey: Calling central's get_tsigkey."))
return self.client.call(context, 'get_tsigkey', tsigkey_id=tsigkey_id) return self.client.call(context, 'get_tsigkey', tsigkey_id=tsigkey_id)
def update_tsigkey(self, context, tsigkey): def update_tsigkey(self, context, tsigkey):
LOG.info(_LI("update_tsigkey: Calling central's update_tsigkey."))
return self.client.call(context, 'update_tsigkey', tsigkey=tsigkey) return self.client.call(context, 'update_tsigkey', tsigkey=tsigkey)
def delete_tsigkey(self, context, tsigkey_id): def delete_tsigkey(self, context, tsigkey_id):
LOG.info(_LI("delete_tsigkey: Calling central's delete_tsigkey."))
return self.client.call(context, 'delete_tsigkey', return self.client.call(context, 'delete_tsigkey',
tsigkey_id=tsigkey_id) tsigkey_id=tsigkey_id)
# Tenant Methods # Tenant Methods
def find_tenants(self, context): def find_tenants(self, context):
LOG.info(_LI("find_tenants: Calling central's find_tenants."))
return self.client.call(context, 'find_tenants') return self.client.call(context, 'find_tenants')
def get_tenant(self, context, tenant_id): def get_tenant(self, context, tenant_id):
LOG.info(_LI("get_tenant: Calling central's get_tenant."))
return self.client.call(context, 'get_tenant', tenant_id=tenant_id) return self.client.call(context, 'get_tenant', tenant_id=tenant_id)
def count_tenants(self, context): def count_tenants(self, context):
LOG.info(_LI("count_tenants: Calling central's count_tenants."))
return self.client.call(context, 'count_tenants') return self.client.call(context, 'count_tenants')
# Zone Methods # Zone Methods
def create_zone(self, context, zone): 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) return self.client.call(context, 'create_zone', zone=zone)
def get_zone(self, context, zone_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) return self.client.call(context, 'get_zone', zone_id=zone_id)
def get_zone_ns_records(self, context, zone_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', return self.client.call(context, 'get_zone_ns_records',
zone_id=zone_id) zone_id=zone_id)
def find_zones(self, context, criterion=None, marker=None, limit=None, def find_zones(self, context, criterion=None, marker=None, limit=None,
sort_key=None, sort_dir=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, return self.client.call(context, 'find_zones', criterion=criterion,
marker=marker, limit=limit, sort_key=sort_key, marker=marker, limit=limit, sort_key=sort_key,
sort_dir=sort_dir) sort_dir=sort_dir)
def find_zone(self, context, criterion=None): 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) return self.client.call(context, 'find_zone', criterion=criterion)
def update_zone(self, context, zone, increment_serial=True): 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, return self.client.call(context, 'update_zone', zone=zone,
increment_serial=increment_serial) increment_serial=increment_serial)
def delete_zone(self, context, zone_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) return self.client.call(context, 'delete_zone', zone_id=zone_id)
def purge_zones(self, context, criterion, limit=None): def purge_zones(self, context, criterion, limit=None):
LOG.info(_LI(
"purge_zones: Calling central's purge_zones."
))
return self.client.call(context, 'purge_zones', return self.client.call(context, 'purge_zones',
criterion=criterion, limit=limit) criterion=criterion, limit=limit)
def count_zones(self, context, criterion=None): 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) return self.client.call(context, 'count_zones', criterion=criterion)
def touch_zone(self, context, zone_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) return self.client.call(context, 'touch_zone', zone_id=zone_id)
# TLD Methods # TLD Methods
def create_tld(self, context, tld): def create_tld(self, context, tld):
LOG.info(_LI("create_tld: Calling central's create_tld."))
return self.client.call(context, 'create_tld', tld=tld) return self.client.call(context, 'create_tld', tld=tld)
def find_tlds(self, context, criterion=None, marker=None, limit=None, def find_tlds(self, context, criterion=None, marker=None, limit=None,
sort_key=None, sort_dir=None): sort_key=None, sort_dir=None):
LOG.info(_LI("find_tlds: Calling central's find_tlds."))
return self.client.call(context, 'find_tlds', criterion=criterion, return self.client.call(context, 'find_tlds', criterion=criterion,
marker=marker, limit=limit, sort_key=sort_key, marker=marker, limit=limit, sort_key=sort_key,
sort_dir=sort_dir) sort_dir=sort_dir)
def get_tld(self, context, tld_id): def get_tld(self, context, tld_id):
LOG.info(_LI("get_tld: Calling central's get_tld."))
return self.client.call(context, 'get_tld', tld_id=tld_id) return self.client.call(context, 'get_tld', tld_id=tld_id)
def update_tld(self, context, tld): def update_tld(self, context, tld):
LOG.info(_LI("update_tld: Calling central's update_tld."))
return self.client.call(context, 'update_tld', tld=tld) return self.client.call(context, 'update_tld', tld=tld)
def delete_tld(self, context, tld_id): def delete_tld(self, context, tld_id):
LOG.info(_LI("delete_tld: Calling central's delete_tld."))
return self.client.call(context, 'delete_tld', tld_id=tld_id) return self.client.call(context, 'delete_tld', tld_id=tld_id)
# RecordSet Methods # RecordSet Methods
def create_recordset(self, context, zone_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', return self.client.call(context, 'create_recordset',
zone_id=zone_id, recordset=recordset) zone_id=zone_id, recordset=recordset)
def get_recordset(self, context, zone_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', zone_id=zone_id, return self.client.call(context, 'get_recordset', zone_id=zone_id,
recordset_id=recordset_id) recordset_id=recordset_id)
def find_recordsets(self, context, criterion=None, marker=None, limit=None, def find_recordsets(self, context, criterion=None, marker=None, limit=None,
sort_key=None, sort_dir=None): sort_key=None, sort_dir=None):
LOG.info(_LI("find_recordsets: Calling central's find_recordsets."))
return self.client.call(context, 'find_recordsets', return self.client.call(context, 'find_recordsets',
criterion=criterion, marker=marker, criterion=criterion, marker=marker,
limit=limit, sort_key=sort_key, limit=limit, sort_key=sort_key,
sort_dir=sort_dir) sort_dir=sort_dir)
def find_recordset(self, context, criterion=None): def find_recordset(self, context, criterion=None):
LOG.info(_LI("find_recordset: Calling central's find_recordset."))
return self.client.call(context, 'find_recordset', criterion=criterion) return self.client.call(context, 'find_recordset', criterion=criterion)
def export_zone(self, context, zone_id): def export_zone(self, context, zone_id):
LOG.info(_LI("export_zone: Calling central's export_zone."))
return self.client.call(context, 'export_zone', zone_id=zone_id) return self.client.call(context, 'export_zone', zone_id=zone_id)
def update_recordset(self, context, recordset, increment_serial=True): def update_recordset(self, context, recordset, increment_serial=True):
LOG.info(_LI("update_recordset: Calling central's update_recordset."))
return self.client.call(context, 'update_recordset', return self.client.call(context, 'update_recordset',
recordset=recordset, recordset=recordset,
increment_serial=increment_serial) increment_serial=increment_serial)
def delete_recordset(self, context, zone_id, recordset_id, def delete_recordset(self, context, zone_id, recordset_id,
increment_serial=True): increment_serial=True):
LOG.info(_LI("delete_recordset: Calling central's delete_recordset."))
return self.client.call(context, 'delete_recordset', return self.client.call(context, 'delete_recordset',
zone_id=zone_id, zone_id=zone_id,
recordset_id=recordset_id, recordset_id=recordset_id,
increment_serial=increment_serial) increment_serial=increment_serial)
def count_recordsets(self, context, criterion=None): def count_recordsets(self, context, criterion=None):
LOG.info(_LI("count_recordsets: Calling central's count_recordsets."))
return self.client.call(context, 'count_recordsets', return self.client.call(context, 'count_recordsets',
criterion=criterion) criterion=criterion)
# Record Methods # Record Methods
def create_record(self, context, zone_id, recordset_id, record, def create_record(self, context, zone_id, recordset_id, record,
increment_serial=True): increment_serial=True):
LOG.info(_LI("create_record: Calling central's create_record."))
return self.client.call(context, 'create_record', return self.client.call(context, 'create_record',
zone_id=zone_id, zone_id=zone_id,
recordset_id=recordset_id, recordset_id=recordset_id,
@ -277,7 +238,6 @@ class CentralAPI(object):
increment_serial=increment_serial) increment_serial=increment_serial)
def get_record(self, context, zone_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', return self.client.call(context, 'get_record',
zone_id=zone_id, zone_id=zone_id,
recordset_id=recordset_id, recordset_id=recordset_id,
@ -285,24 +245,20 @@ class CentralAPI(object):
def find_records(self, context, criterion=None, marker=None, limit=None, def find_records(self, context, criterion=None, marker=None, limit=None,
sort_key=None, sort_dir=None): sort_key=None, sort_dir=None):
LOG.info(_LI("find_records: Calling central's find_records."))
return self.client.call(context, 'find_records', criterion=criterion, return self.client.call(context, 'find_records', criterion=criterion,
marker=marker, limit=limit, sort_key=sort_key, marker=marker, limit=limit, sort_key=sort_key,
sort_dir=sort_dir) sort_dir=sort_dir)
def find_record(self, context, criterion=None): def find_record(self, context, criterion=None):
LOG.info(_LI("find_record: Calling central's find_record."))
return self.client.call(context, 'find_record', criterion=criterion) return self.client.call(context, 'find_record', criterion=criterion)
def update_record(self, context, record, increment_serial=True): def update_record(self, context, record, increment_serial=True):
LOG.info(_LI("update_record: Calling central's update_record."))
return self.client.call(context, 'update_record', return self.client.call(context, 'update_record',
record=record, record=record,
increment_serial=increment_serial) increment_serial=increment_serial)
def delete_record(self, context, zone_id, recordset_id, record_id, def delete_record(self, context, zone_id, recordset_id, record_id,
increment_serial=True): increment_serial=True):
LOG.info(_LI("delete_record: Calling central's delete_record."))
return self.client.call(context, 'delete_record', return self.client.call(context, 'delete_record',
zone_id=zone_id, zone_id=zone_id,
recordset_id=recordset_id, recordset_id=recordset_id,
@ -310,125 +266,96 @@ class CentralAPI(object):
increment_serial=increment_serial) increment_serial=increment_serial)
def count_records(self, context, criterion=None): def count_records(self, context, criterion=None):
LOG.info(_LI("count_records: Calling central's count_records."))
return self.client.call(context, 'count_records', criterion=criterion) return self.client.call(context, 'count_records', criterion=criterion)
# Misc. Report combining counts for tenants, zones and records # Misc. Report combining counts for tenants, zones and records
def count_report(self, context, criterion=None): 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) return self.client.call(context, 'count_report', criterion=criterion)
# Sync Methods # Sync Methods
def sync_zones(self, context): def sync_zones(self, context):
LOG.info(_LI("sync_zones: Calling central's sync_zones."))
return self.client.call(context, 'sync_zones') return self.client.call(context, 'sync_zones')
def sync_zone(self, context, zone_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) return self.client.call(context, 'sync_zone', zone_id=zone_id)
def sync_record(self, context, zone_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', return self.client.call(context, 'sync_record',
zone_id=zone_id, zone_id=zone_id,
recordset_id=recordset_id, recordset_id=recordset_id,
record_id=record_id) record_id=record_id)
def list_floatingips(self, context): def list_floatingips(self, context):
LOG.info(_LI("list_floatingips: Calling central's list_floatingips."))
return self.client.call(context, 'list_floatingips') return self.client.call(context, 'list_floatingips')
def get_floatingip(self, context, region, floatingip_id): def get_floatingip(self, context, region, floatingip_id):
LOG.info(_LI("get_floatingip: Calling central's get_floatingip."))
return self.client.call(context, 'get_floatingip', region=region, return self.client.call(context, 'get_floatingip', region=region,
floatingip_id=floatingip_id) floatingip_id=floatingip_id)
def update_floatingip(self, context, region, floatingip_id, values): def update_floatingip(self, context, region, floatingip_id, values):
LOG.info(_LI("update_floatingip: "
"Calling central's update_floatingip."))
return self.client.call(context, 'update_floatingip', region=region, return self.client.call(context, 'update_floatingip', region=region,
floatingip_id=floatingip_id, values=values) floatingip_id=floatingip_id, values=values)
# Blacklisted Zone Methods # Blacklisted Zone Methods
def create_blacklist(self, context, blacklist): def create_blacklist(self, context, blacklist):
LOG.info(_LI("create_blacklist: Calling central's create_blacklist"))
return self.client.call(context, 'create_blacklist', return self.client.call(context, 'create_blacklist',
blacklist=blacklist) blacklist=blacklist)
def get_blacklist(self, context, blacklist_id): def get_blacklist(self, context, blacklist_id):
LOG.info(_LI("get_blacklist: Calling central's get_blacklist."))
return self.client.call(context, 'get_blacklist', return self.client.call(context, 'get_blacklist',
blacklist_id=blacklist_id) blacklist_id=blacklist_id)
def find_blacklists(self, context, criterion=None, marker=None, limit=None, def find_blacklists(self, context, criterion=None, marker=None, limit=None,
sort_key=None, sort_dir=None): sort_key=None, sort_dir=None):
LOG.info(_LI("find_blacklists: Calling central's find_blacklists."))
return self.client.call( return self.client.call(
context, 'find_blacklists', criterion=criterion, marker=marker, context, 'find_blacklists', criterion=criterion, marker=marker,
limit=limit, sort_key=sort_key, sort_dir=sort_dir) limit=limit, sort_key=sort_key, sort_dir=sort_dir)
def find_blacklist(self, context, criterion): def find_blacklist(self, context, criterion):
LOG.info(_LI("find_blacklist: Calling central's find_blacklist."))
return self.client.call(context, 'find_blacklist', criterion=criterion) return self.client.call(context, 'find_blacklist', criterion=criterion)
def update_blacklist(self, context, blacklist): def update_blacklist(self, context, blacklist):
LOG.info(_LI("update_blacklist: Calling central's update_blacklist."))
return self.client.call(context, 'update_blacklist', return self.client.call(context, 'update_blacklist',
blacklist=blacklist) blacklist=blacklist)
def delete_blacklist(self, context, blacklist_id): def delete_blacklist(self, context, blacklist_id):
LOG.info(_LI("delete_blacklist: Calling central's delete blacklist."))
return self.client.call(context, 'delete_blacklist', return self.client.call(context, 'delete_blacklist',
blacklist_id=blacklist_id) blacklist_id=blacklist_id)
# Pool Server Methods # Pool Server Methods
def create_pool(self, context, pool): def create_pool(self, context, pool):
LOG.info(_LI("create_pool: Calling central's create_pool."))
return self.client.call(context, 'create_pool', pool=pool) return self.client.call(context, 'create_pool', pool=pool)
def find_pools(self, context, criterion=None, marker=None, limit=None, def find_pools(self, context, criterion=None, marker=None, limit=None,
sort_key=None, sort_dir=None): sort_key=None, sort_dir=None):
LOG.info(_LI("find_pools: Calling central's find_pools."))
return self.client.call(context, 'find_pools', criterion=criterion, return self.client.call(context, 'find_pools', criterion=criterion,
marker=marker, limit=limit, sort_key=sort_key, marker=marker, limit=limit, sort_key=sort_key,
sort_dir=sort_dir) sort_dir=sort_dir)
def find_pool(self, context, criterion=None): def find_pool(self, context, criterion=None):
LOG.info(_LI("find_pool: Calling central's find_pool."))
return self.client.call(context, 'find_pool', criterion=criterion) return self.client.call(context, 'find_pool', criterion=criterion)
def get_pool(self, context, pool_id): def get_pool(self, context, pool_id):
LOG.info(_LI("get_pool: Calling central's get_pool."))
return self.client.call(context, 'get_pool', pool_id=pool_id) return self.client.call(context, 'get_pool', pool_id=pool_id)
def update_pool(self, context, pool): def update_pool(self, context, pool):
LOG.info(_LI("update_pool: Calling central's update_pool."))
return self.client.call(context, 'update_pool', pool=pool) return self.client.call(context, 'update_pool', pool=pool)
def delete_pool(self, context, pool_id): def delete_pool(self, context, pool_id):
LOG.info(_LI("delete_pool: Calling central's delete_pool."))
return self.client.call(context, 'delete_pool', pool_id=pool_id) return self.client.call(context, 'delete_pool', pool_id=pool_id)
# Pool Manager Integration Methods # Pool Manager Integration Methods
def update_status(self, context, zone_id, status, serial): def update_status(self, context, zone_id, status, serial):
LOG.info(_LI("update_status: Calling central's update_status "
"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, self.client.cast(context, 'update_status', zone_id=zone_id,
status=status, serial=serial) status=status, serial=serial)
# Zone Ownership Transfers # Zone Ownership Transfers
def create_zone_transfer_request(self, context, zone_transfer_request): def create_zone_transfer_request(self, context, zone_transfer_request):
LOG.info(_LI("create_zone_transfer_request: \
Calling central's create_zone_transfer_request."))
return self.client.call( return self.client.call(
context, 'create_zone_transfer_request', context, 'create_zone_transfer_request',
zone_transfer_request=zone_transfer_request) zone_transfer_request=zone_transfer_request)
def get_zone_transfer_request(self, context, zone_transfer_request_id): def get_zone_transfer_request(self, context, zone_transfer_request_id):
LOG.info(_LI("get_zone_transfer_request: \
Calling central's get_zone_transfer_request."))
return self.client.call( return self.client.call(
context, context,
'get_zone_transfer_request', 'get_zone_transfer_request',
@ -436,45 +363,32 @@ class CentralAPI(object):
def find_zone_transfer_requests(self, context, criterion=None, marker=None, def find_zone_transfer_requests(self, context, criterion=None, marker=None,
limit=None, sort_key=None, sort_dir=None): limit=None, sort_key=None, sort_dir=None):
LOG.info(_LI("find_zone_transfer_requests: \
Calling central's find_zone_transfer_requests."))
return self.client.call( return self.client.call(
context, 'find_zone_transfer_requests', criterion=criterion, context, 'find_zone_transfer_requests', criterion=criterion,
marker=marker, limit=limit, sort_key=sort_key, sort_dir=sort_dir) marker=marker, limit=limit, sort_key=sort_key, sort_dir=sort_dir)
def find_zone_transfer_request(self, context, zone_transfer_request): def find_zone_transfer_request(self, context, zone_transfer_request):
LOG.info(_LI("find_zone_transfer_request: \
Calling central's find_zone_transfer_request."))
return self.client.call( return self.client.call(
context, 'find_zone_transfer_request', context, 'find_zone_transfer_request',
zone_transfer_request=zone_transfer_request) zone_transfer_request=zone_transfer_request)
def update_zone_transfer_request(self, context, zone_transfer_request): def update_zone_transfer_request(self, context, zone_transfer_request):
LOG.info(_LI("update_zone_transfer_request: \
Calling central's update_zone_transfer_request."))
return self.client.call( return self.client.call(
context, 'update_zone_transfer_request', context, 'update_zone_transfer_request',
zone_transfer_request=zone_transfer_request) zone_transfer_request=zone_transfer_request)
def delete_zone_transfer_request(self, context, zone_transfer_request_id): def delete_zone_transfer_request(self, context, zone_transfer_request_id):
LOG.info(_LI("delete_zone_transfer_request: \
Calling central's delete_zone_transfer_request."))
return self.client.call( return self.client.call(
context, context,
'delete_zone_transfer_request', 'delete_zone_transfer_request',
zone_transfer_request_id=zone_transfer_request_id) zone_transfer_request_id=zone_transfer_request_id)
def create_zone_transfer_accept(self, context, zone_transfer_accept): def create_zone_transfer_accept(self, context, zone_transfer_accept):
LOG.info(_LI("create_zone_transfer_accept: \
Calling central's create_zone_transfer_accept."))
return self.client.call( return self.client.call(
context, 'create_zone_transfer_accept', context, 'create_zone_transfer_accept',
zone_transfer_accept=zone_transfer_accept) zone_transfer_accept=zone_transfer_accept)
def get_zone_transfer_accept(self, context, zone_transfer_accept_id): def get_zone_transfer_accept(self, context, zone_transfer_accept_id):
LOG.info(_LI("get_zone_transfer_accept: \
Calling central's get_zone_transfer_accept."))
return self.client.call( return self.client.call(
context, context,
'get_zone_transfer_accept', 'get_zone_transfer_accept',
@ -482,121 +396,88 @@ class CentralAPI(object):
def find_zone_transfer_accepts(self, context, criterion=None, marker=None, def find_zone_transfer_accepts(self, context, criterion=None, marker=None,
limit=None, sort_key=None, sort_dir=None): limit=None, sort_key=None, sort_dir=None):
LOG.info(_LI("find_zone_transfer_accepts: \
Calling central's find_zone_transfer_accepts."))
return self.client.call( return self.client.call(
context, 'find_zone_transfer_accepts', criterion=criterion, context, 'find_zone_transfer_accepts', criterion=criterion,
marker=marker, limit=limit, sort_key=sort_key, sort_dir=sort_dir) marker=marker, limit=limit, sort_key=sort_key, sort_dir=sort_dir)
def find_zone_transfer_accept(self, context, zone_transfer_accept): def find_zone_transfer_accept(self, context, zone_transfer_accept):
LOG.info(_LI("find_zone_transfer_accept: \
Calling central's find_zone_transfer_accept."))
return self.client.call( return self.client.call(
context, 'find_zone_transfer_accept', context, 'find_zone_transfer_accept',
zone_transfer_accept=zone_transfer_accept) zone_transfer_accept=zone_transfer_accept)
def update_zone_transfer_accept(self, context, zone_transfer_accept): def update_zone_transfer_accept(self, context, zone_transfer_accept):
LOG.info(_LI("update_zone_transfer_accept: \
Calling central's update_zone_transfer_accept."))
return self.client.call( return self.client.call(
context, 'update_zone_transfer_accept', context, 'update_zone_transfer_accept',
zone_transfer_accept=zone_transfer_accept) zone_transfer_accept=zone_transfer_accept)
def delete_zone_transfer_accept(self, context, zone_transfer_accept_id): def delete_zone_transfer_accept(self, context, zone_transfer_accept_id):
LOG.info(_LI("delete_zone_transfer_accept: \
Calling central's delete_zone_transfer_accept."))
return self.client.call( return self.client.call(
context, context,
'delete_zone_transfer_accept', 'delete_zone_transfer_accept',
zone_transfer_accept_id=zone_transfer_accept_id) zone_transfer_accept_id=zone_transfer_accept_id)
def xfr_zone(self, context, zone_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) return self.client.call(context, 'xfr_zone', zone_id=zone_id)
# Zone Import Methods # Zone Import Methods
def create_zone_import(self, context, request_body): def create_zone_import(self, context, request_body):
LOG.info(_LI("create_zone_import: Calling central's "
"create_zone_import."))
return self.client.call(context, 'create_zone_import', return self.client.call(context, 'create_zone_import',
request_body=request_body) request_body=request_body)
def find_zone_imports(self, context, criterion=None, marker=None, def find_zone_imports(self, context, criterion=None, marker=None,
limit=None, sort_key=None, sort_dir=None): limit=None, sort_key=None, sort_dir=None):
LOG.info(_LI("find_zone_imports: Calling central's "
"find_zone_imports."))
return self.client.call(context, 'find_zone_imports', return self.client.call(context, 'find_zone_imports',
criterion=criterion, marker=marker, criterion=criterion, marker=marker,
limit=limit, sort_key=sort_key, limit=limit, sort_key=sort_key,
sort_dir=sort_dir) sort_dir=sort_dir)
def get_zone_import(self, context, zone_import_id): def get_zone_import(self, context, zone_import_id):
LOG.info(_LI("get_zone_import: Calling central's get_zone_import."))
return self.client.call(context, 'get_zone_import', return self.client.call(context, 'get_zone_import',
zone_import_id=zone_import_id) zone_import_id=zone_import_id)
def update_zone_import(self, context, zone_import): def update_zone_import(self, context, zone_import):
LOG.info(_LI("update_zone_import: Calling central's "
"update_zone_import."))
return self.client.call(context, 'update_zone_import', return self.client.call(context, 'update_zone_import',
zone_import=zone_import) zone_import=zone_import)
def delete_zone_import(self, context, zone_import_id): def delete_zone_import(self, context, zone_import_id):
LOG.info(_LI("delete_zone_import: Calling central's "
"delete_zone_import."))
return self.client.call(context, 'delete_zone_import', return self.client.call(context, 'delete_zone_import',
zone_import_id=zone_import_id) zone_import_id=zone_import_id)
# Zone Export Methods # Zone Export Methods
def create_zone_export(self, context, zone_id): def create_zone_export(self, context, zone_id):
LOG.info(_LI("create_zone_export: Calling central's "
"create_zone_export."))
return self.client.call(context, 'create_zone_export', return self.client.call(context, 'create_zone_export',
zone_id=zone_id) zone_id=zone_id)
def find_zone_exports(self, context, criterion=None, marker=None, def find_zone_exports(self, context, criterion=None, marker=None,
limit=None, sort_key=None, sort_dir=None): limit=None, sort_key=None, sort_dir=None):
LOG.info(_LI("find_zone_exports: Calling central's "
"find_zone_exports."))
return self.client.call(context, 'find_zone_exports', return self.client.call(context, 'find_zone_exports',
criterion=criterion, marker=marker, criterion=criterion, marker=marker,
limit=limit, sort_key=sort_key, limit=limit, sort_key=sort_key,
sort_dir=sort_dir) sort_dir=sort_dir)
def get_zone_export(self, context, zone_export_id): def get_zone_export(self, context, zone_export_id):
LOG.info(_LI("get_zone_export: Calling central's get_zone_export."))
return self.client.call(context, 'get_zone_export', return self.client.call(context, 'get_zone_export',
zone_export_id=zone_export_id) zone_export_id=zone_export_id)
def update_zone_export(self, context, zone_export): def update_zone_export(self, context, zone_export):
LOG.info(_LI("update_zone_export: Calling central's "
"update_zone_export."))
return self.client.call(context, 'update_zone_export', return self.client.call(context, 'update_zone_export',
zone_export=zone_export) zone_export=zone_export)
def delete_zone_export(self, context, zone_export_id): def delete_zone_export(self, context, zone_export_id):
LOG.info(_LI("delete_zone_export: Calling central's "
"delete_zone_export."))
return self.client.call(context, 'delete_zone_export', return self.client.call(context, 'delete_zone_export',
zone_export_id=zone_export_id) zone_export_id=zone_export_id)
def find_service_status(self, context, criterion=None): def find_service_status(self, context, criterion=None):
LOG.info(_LI("find_service_status: Calling central's "
"find_service_status."))
return self.client.call(context, 'find_service_status', return self.client.call(context, 'find_service_status',
criterion=criterion) criterion=criterion)
def find_service_statuses(self, context, criterion=None, marker=None, def find_service_statuses(self, context, criterion=None, marker=None,
limit=None, sort_key=None, sort_dir=None): limit=None, sort_key=None, sort_dir=None):
LOG.info(_LI("find_service_statuses: Calling central's "
"find_service_statuses."))
return self.client.call(context, 'find_service_statuses', return self.client.call(context, 'find_service_statuses',
criterion=criterion, marker=marker, criterion=criterion, marker=marker,
limit=limit, sort_key=sort_key, limit=limit, sort_key=sort_key,
sort_dir=sort_dir) sort_dir=sort_dir)
def update_service_status(self, context, service_status): def update_service_status(self, context, service_status):
LOG.info(_LI("update_service_status: Calling central's "
"update_service_status."))
self.client.cast(context, 'update_service_status', self.client.cast(context, 'update_service_status',
service_status=service_status) service_status=service_status)

43
designate/loggingutils.py Normal file
View File

@ -0,0 +1,43 @@
# Copyright 2016 Hewlett Packard Enterprise Development Company LP
#
# 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.
import inspect
LOG = {}
def log_rpc_call(func, rpcapi, logger):
def wrapped(*args, **kwargs):
logger.debug("Calling designate.%(rpcapi)s.%(function)s() "
"over RPC", {'function': func.__name__,
'rpcapi': rpcapi})
return func(*args, **kwargs)
return wrapped
LOGGING_BLACKLIST = [
'get_instance',
'__init__'
]
def rpc_logging(logger, rpcapi):
def wrapper(cls):
CLASS_BLACKLIST = getattr(cls, 'LOGGING_BLACKLIST', [])
BLACKLIST = CLASS_BLACKLIST + LOGGING_BLACKLIST
for name, m in inspect.getmembers(cls, inspect.ismethod):
if name not in BLACKLIST:
setattr(cls, name, log_rpc_call(m, rpcapi, logger))
return cls
return wrapper

View File

@ -18,13 +18,14 @@ import oslo_messaging as messaging
from designate.i18n import _LI from designate.i18n import _LI
from designate import rpc from designate import rpc
from designate.loggingutils import rpc_logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
MDNS_API = None MDNS_API = None
@rpc_logging(LOG, 'mdns')
class MdnsAPI(object): class MdnsAPI(object):
""" """

View File

@ -13,12 +13,14 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging from oslo_log import log as logging
import oslo_messaging as messaging import oslo_messaging as messaging
from designate.i18n import _LI from designate.i18n import _LI
from designate import rpc from designate import rpc
from designate.loggingutils import rpc_logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -26,6 +28,7 @@ LOG = logging.getLogger(__name__)
MNGR_API = None MNGR_API = None
@rpc_logging(LOG, 'pool_manager')
class PoolManagerAPI(object): class PoolManagerAPI(object):
""" """
Client side of the Pool Manager RPC API. Client side of the Pool Manager RPC API.
@ -74,10 +77,6 @@ class PoolManagerAPI(object):
timestamp=timestamp) timestamp=timestamp)
def create_zone(self, context, zone): def create_zone(self, context, zone):
LOG.info(_LI("create_zone: Calling pool manager for %(zone)s, "
"serial:%(serial)s"),
{'zone': zone.name, 'serial': zone.serial})
# Modifying the topic so it is pool manager instance specific. # Modifying the topic so it is pool manager instance specific.
topic = '%s.%s' % (self.topic, zone.pool_id) topic = '%s.%s' % (self.topic, zone.pool_id)
cctxt = self.client.prepare(topic=topic) cctxt = self.client.prepare(topic=topic)
@ -85,10 +84,6 @@ class PoolManagerAPI(object):
context, 'create_zone', zone=zone) context, 'create_zone', zone=zone)
def delete_zone(self, context, zone): def delete_zone(self, context, zone):
LOG.info(_LI("delete_zone: Calling pool manager for %(zone)s, "
"serial:%(serial)s"),
{'zone': zone.name, 'serial': zone.serial})
# Modifying the topic so it is pool manager instance specific. # Modifying the topic so it is pool manager instance specific.
topic = '%s.%s' % (self.topic, zone.pool_id) topic = '%s.%s' % (self.topic, zone.pool_id)
cctxt = self.client.prepare(topic=topic) cctxt = self.client.prepare(topic=topic)
@ -96,10 +91,6 @@ class PoolManagerAPI(object):
context, 'delete_zone', zone=zone) context, 'delete_zone', zone=zone)
def update_zone(self, context, zone): def update_zone(self, context, zone):
LOG.info(_LI("update_zone: Calling pool manager for %(zone)s, "
"serial:%(serial)s"),
{'zone': zone.name, 'serial': zone.serial})
# Modifying the topic so it is pool manager instance specific. # Modifying the topic so it is pool manager instance specific.
topic = '%s.%s' % (self.topic, zone.pool_id) topic = '%s.%s' % (self.topic, zone.pool_id)
cctxt = self.client.prepare(topic=topic) cctxt = self.client.prepare(topic=topic)
@ -108,12 +99,6 @@ class PoolManagerAPI(object):
def update_status(self, context, zone, nameserver, status, def update_status(self, context, zone, nameserver, status,
actual_serial): actual_serial):
LOG.info(_LI("update_status: Calling pool manager for %(zone)s : "
"%(action)s : %(status)s : %(serial)s on nameserver "
"'%(host)s:%(port)s'"),
{'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. # Modifying the topic so it is pool manager instance specific.
topic = '%s.%s' % (self.topic, zone.pool_id) topic = '%s.%s' % (self.topic, zone.pool_id)

View File

@ -17,8 +17,8 @@ from oslo_config import cfg
from oslo_log import log as logging from oslo_log import log as logging
import oslo_messaging as messaging import oslo_messaging as messaging
from designate.i18n import _LI
from designate import rpc from designate import rpc
from designate.loggingutils import rpc_logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -26,6 +26,7 @@ LOG = logging.getLogger(__name__)
ZONE_MANAGER_API = None ZONE_MANAGER_API = None
@rpc_logging(LOG, 'zone_manager')
class ZoneManagerAPI(object): class ZoneManagerAPI(object):
""" """
Client side of the zone manager RPC API. Client side of the zone manager RPC API.
@ -58,15 +59,9 @@ class ZoneManagerAPI(object):
# Zone Export # Zone Export
def start_zone_export(self, context, zone, 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', zone=zone, return self.client.cast(context, 'start_zone_export', zone=zone,
export=export) export=export)
def render_zone(self, context, zone_id): def render_zone(self, context, zone_id):
LOG.info(_LI("render_zone: "
"Calling zone_manager's render_zone."))
return self.client.call(context, 'render_zone', return self.client.call(context, 'render_zone',
zone_id=zone_id) zone_id=zone_id)