-class NsdRefCountDtsHandler(object):
- """ The NSD Ref Count DTS handler """
- XPATH = "D,/nsr:ns-instance-opdata/rw-nsr:nsd-ref-count"
-
- def __init__(self, dts, log, loop, nsm):
- self._dts = dts
- self._log = log
- self._loop = loop
- self._nsm = nsm
-
- self._regh = None
-
- @property
- def regh(self):
- """ Return registration handle """
- return self._regh
-
- @property
- def nsm(self):
- """ Return the NS manager instance """
- return self._nsm
-
- @asyncio.coroutine
- def register(self):
- """ Register for NSD ref count read from dts """
-
- @asyncio.coroutine
- def on_prepare(xact_info, action, ks_path, msg):
- """ prepare callback from dts """
- xpath = ks_path.to_xpath(RwNsrYang.get_schema())
-
- if action == rwdts.QueryAction.READ:
- schema = RwNsrYang.YangData_Nsr_NsInstanceOpdata_NsdRefCount.schema()
- path_entry = schema.keyspec_to_entry(ks_path)
- nsd_list = yield from self._nsm.get_nsd_refcount(path_entry.key00.nsd_id_ref)
- for xpath, msg in nsd_list:
- xact_info.respond_xpath(rsp_code=rwdts.XactRspCode.MORE,
- xpath=xpath,
- msg=msg)
- xact_info.respond_xpath(rwdts.XactRspCode.ACK)
- else:
- raise NetworkServiceRecordError("Not supported operation %s" % action)
-
- hdl = rift.tasklets.DTS.RegistrationHandler(on_prepare=on_prepare,)
- with self._dts.group_create() as group:
- self._regh = group.register(xpath=NsdRefCountDtsHandler.XPATH,
- handler=hdl,
- flags=rwdts.Flag.PUBLISHER,)
-
-