diff --git a/notificationclient-base/docker/notificationclient-sidecar/notificationclientsdk/common/helpers/subscription_helper.py b/notificationclient-base/docker/notificationclient-sidecar/notificationclientsdk/common/helpers/subscription_helper.py index 21b29f8..133d27d 100644 --- a/notificationclient-base/docker/notificationclient-sidecar/notificationclientsdk/common/helpers/subscription_helper.py +++ b/notificationclient-base/docker/notificationclient-sidecar/notificationclientsdk/common/helpers/subscription_helper.py @@ -40,6 +40,14 @@ def notify(subscriptioninfo, notification, timeout=2, retry=3): response = requests.post(url, data=data, headers=headers, timeout=timeout) response.raise_for_status() + if notification == {}: + if hasattr(subscriptioninfo, 'ResourceType'): + resource = "{'ResourceType':'" + \ + subscriptioninfo.ResourceType + "'}" + elif hasattr(subscriptioninfo, 'ResourceAddress'): + _, _, resource, _, _ = parse_resource_address( + subscriptioninfo.ResourceAddress) + raise client_exception.InvalidResource(resource) result = True return response except client_exception.InvalidResource as ex: diff --git a/notificationclient-base/docker/notificationclient-sidecar/sidecar/controllers/v1/resource/ptp.py b/notificationclient-base/docker/notificationclient-sidecar/sidecar/controllers/v1/resource/ptp.py index 7171cd0..c893cf8 100644 --- a/notificationclient-base/docker/notificationclient-sidecar/sidecar/controllers/v1/resource/ptp.py +++ b/notificationclient-base/docker/notificationclient-sidecar/sidecar/controllers/v1/resource/ptp.py @@ -47,6 +47,9 @@ class CurrentStateController(rest.RestController): LOG.debug('Querying nodename: %s' % nodename) ptpstatus = ptpservice.query(nodename) LOG.debug('Got ptpstatus: %s' % ptpstatus) + if ptpstatus == {}: + raise client_exception.ResourceNotAvailable('PTP', + nodename) # response.status = 200 return ptpstatus except client_exception.NodeNotAvailable as ex: diff --git a/notificationclient-base/docker/notificationclient-sidecar/sidecar/controllers/v1/subscriptions.py b/notificationclient-base/docker/notificationclient-sidecar/sidecar/controllers/v1/subscriptions.py index 962c22f..b7e365e 100644 --- a/notificationclient-base/docker/notificationclient-sidecar/sidecar/controllers/v1/subscriptions.py +++ b/notificationclient-base/docker/notificationclient-sidecar/sidecar/controllers/v1/subscriptions.py @@ -73,6 +73,8 @@ class SubscriptionsControllerV1(rest.RestController): abort(400) except client_exception.InvalidEndpoint: abort(400) + except client_exception.InvalidResource as ex: + abort(400, str(ex)) except client_exception.NodeNotAvailable: abort(404) except client_exception.ResourceNotAvailable: diff --git a/notificationservice-base-v2/docker/ptptrackingfunction/trackingfunctionsdk/services/daemon.py b/notificationservice-base-v2/docker/ptptrackingfunction/trackingfunctionsdk/services/daemon.py index 799f744..b0a2694 100644 --- a/notificationservice-base-v2/docker/ptptrackingfunction/trackingfunctionsdk/services/daemon.py +++ b/notificationservice-base-v2/docker/ptptrackingfunction/trackingfunctionsdk/services/daemon.py @@ -254,31 +254,6 @@ class PtpWatcherDefault: constants.SOURCE_SYNC_SYNC_STATE), sync_state) LOG.debug("query_status: {}".format(lastStatus)) - else: - # Request is for PTP v1 notification - # PTP v1 only supports single instance ptp - instance = self.daemon_context['PTP4L_INSTANCES'][0] - if len(self.daemon_context['PTP4L_INSTANCES']) > 1: - LOG.warning("Multiple ptp4l instances configured, " - "retrieving status for %s" % instance) - self.watcher.ptptracker_context_lock.acquire() - sync_state = self.watcher.ptptracker_context[instance].get( - 'sync_state', PtpState.Freerun) - last_event_time = \ - self.watcher.ptptracker_context[instance].get( - 'last_event_time', time.time()) - lastStatus[constants.PTP_V1_KEY] = { - 'ResourceType': ResourceType.TypePTP, - 'EventData': { - 'State': sync_state - }, - 'ResourceQualifier': { - 'NodeName': self.watcher.node_name - }, - 'EventTimestamp': last_event_time - } - self.watcher.ptptracker_context_lock.release() - LOG.warning("query_status PTP v1: {}".format(lastStatus)) return lastStatus