Douglas Henrique Koerich 84b5114027 Images of ptp-notification containers for Debian
This change reorganizes the source directories of the ptp-notification's
containers: locationservice; notificationservice; notificationclient, to
be reused by both CentOS and Debian Dockerfiles to build the images
having the corresponding OS-specific base, together with the new files
used to build images for Debian.

Tests:
PASS: Build images of the 3 containers for Debian
PASS: Upload and apply changed ptp-notification application to pull
      Debian images from private repository (since final tag is
      not possible yet) in a Debian AIO-SX environment

Regression:
PASS: Build images of the 3 containers for CentOS

Story: 2009831
Task: 45658
Signed-off-by: Douglas Henrique Koerich <douglashenrique.koerich@windriver.com>
Change-Id: I4aa9650dbebe5ba68cd4d104ee0995e79681cfa4
2022-07-19 15:01:27 -03:00

91 lines
2.9 KiB
Python

#
# Copyright (c) 2021 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
import os
import json
import time
import oslo_messaging
from oslo_config import cfg
from locationservicesdk.client.base import BrokerClientBase
import logging
LOG = logging.getLogger(__name__)
from locationservicesdk.common.helpers import log_helper
log_helper.config_logger(LOG)
class LocationProducer(BrokerClientBase):
class ListenerEndpoint(object):
target = oslo_messaging.Target(namespace='notification', version='1.0')
def __init__(self, location_info, handler=None):
self.location_info = location_info
self.handler = handler
pass
def QueryLocation(self, ctx, **rpc_kwargs):
LOG.debug ("LocationProducer QueryLocation called %s" %rpc_kwargs)
return self.location_info
def TriggerAnnouncement(self, ctx, **rpc_kwargs):
LOG.debug ("LocationProducer TriggerAnnouncement called %s" %rpc_kwargs)
if self.handler:
return self.handler.handle(**rpc_kwargs)
else:
return False
def __init__(self, node_name, registrationservice_transport_endpoint):
self.Id = id(self)
self.node_name = node_name
super(LocationProducer, self).__init__(
'locationproducer', registrationservice_transport_endpoint)
return
def __del__(self):
super(LocationProducer, self).__del__()
return
def announce_location(self, LocationInfo):
location_topic_all='LocationListener-*'
location_topic='LocationListener-{0}'.format(self.node_name)
server = None
while True:
try:
self.cast(location_topic_all, 'NotifyLocation', location_info=LocationInfo)
LOG.debug("Broadcast location info:{0}@Topic:{1}".format(LocationInfo, location_topic))
except Exception as ex:
LOG.debug("Failed to publish location due to: {0}".format(str(ex)))
continue
else:
break
def start_location_listener(self, location_info, handler=None):
topic='LocationQuery'
server="LocationService-{0}".format(self.node_name)
endpoints = [LocationProducer.ListenerEndpoint(location_info, handler)]
super(LocationProducer, self).add_listener(
topic, server, endpoints)
return True
def stop_location_listener(self):
topic='LocationQuery'
server="LocationService-{0}".format(self.node_name)
super(LocationProducer, self).remove_listener(
topic, server)
def is_listening(self):
topic='LocationQuery'
server="LocationService-{0}".format(self.node_name)
return super(LocationProducer, self).is_listening(
topic, server)