jnx_dds_service.proto

Service

DDS

DDS (Distribution Data Service) is a distributed data store which provides all the operational state of the system in the form of objects. DDS RPC service provides a mechanism for clients to view the system's object schema model, get a list of available topics of data and to subscribe to a stream of objects for a given one or more topics.

Method Name Request Type Response Type Description
SchemaModelGet SchemaModelRequest SchemaModelResponse API to get the object hierarchy model
TypeDocumentationGet TypeDocumentationRequest TypeDocumentationResponse API to get the object type documentation
TopicListGet TopicListRequest TopicListResponse API to get the list of subscribe topics
TopicSubscribe TopicSubscribeRequest ObjectStreamResponse API to subscribe for a set of topics
ApplicationDataGet ApplicationDataRequest DataStreamResponse API to fetch application data

RPC(s)

The following APIs are provided by this service:

SchemaModelGet

API to get the object hierarchy model

Input: SchemaModelRequest

Output: SchemaModelResponse

Example(s):

grpc_stub = jnx_dds_service_pb2.DDSStub(grpc_channel)
response = grpc_stub.SchemaModelGet(jnx_dds_types_pb2.SchemaModelRequest())
if response.response_code == jnx_dds_types_pb2.SUCCESS:
   print response.types_descriptors
else:
   print "Received error response, code: " + response.response_code + " response message: " + response.response_message

TypeDocumentationGet

Returns the additional technical information for a given type of object. The information returned will be a high level, human readable description of of the type.

Input: TypeDocumentationRequest

Output: TypeDocumentationResponse

Example(s):

grpc_stub = jnx_dds_service_pb2.DDSStub(grpc_channel)
response = grpc_stub.TypeDocumentationGet(jnx_dds_types_pb2.TypeDocumentationRequest())
if response.response_code == jnx_dds_types_pb2.SUCCESS:
   print response.type_documentation
else:
   print "Received error response, code: " + response.response_code + " response message: " + response.response_message

TopicListGet

Topics are labels which are associated with objects. Clients can subscribe to one more topic(s) to recieve a stream of associated objects.

Input: TopicListRequest

Output: TopicListResponse

Example(s):

grpc_stub = jnx_dds_service_pb2.DDSStub(grpc_channel)
response = grpc_stub.TopicListGet(jnx_dds_types_pb2.TopicListRequest())
if response.response_code == jnx_dds_types_pb2.SUCCESS:
   print response.topics
else:
   print "Received error response, code: " + response.response_code + " response message: " + response.response_message

TopicSubscribe

Returns a stream of objects associated for a given one or more topic(s). Clients can build the system state of interest based on these objects. The stream of objects are continously synced based on the option given in the request.

Input: TopicSubscribeRequest

Output: ObjectStreamResponse

Example(s):

"""
Subsribe to all topics continuously until client channel is closed
"""
grpc_stub = jnx_dds_service_pb2.DDSStub(grpc_channel)
objects = grpc_stub.TopicSubscribe(jnx_dds_types_pb2.TopicSubscribeRequest(continuous_sync=True, subscription_topics=""))
for obj in objects:
if obj.stream_status == jnx_dds_types_pb2.STATUS_STREAMING:
    # more objects to be received, print this object
    print obj
elif obj.stream_status == jnx_dds_types_pb2.STATUS_END_OF_STREAM:
    # all the objects received
    break
else
    # error occured
    print "Received error: " + obj.stream_status


"""
Subscribe to current set of configured objects for set of topics and quit
"""

# Array of topics to subcribe for Routes and Interfaces
topics = [
    "/Root/Type/net::juniper::rtnh::Route",
    "/Root/Type/net::juniper::interfaces::IFDO"
]
grpc_stub = jnx_dds_service_pb2.DDSStub(grpc_channel)
objects = grpc_stub.TopicSubscribe(jnx_dds_types_pb2.TopicSubscribeRequest(continuous_sync=False, subscription_topics=topics))
for obj in objects:
   if obj.stream_status == jnx_dds_types_pb2.STATUS_STREAMING:
       # more objects to be received, print this object
       print obj
   elif obj.stream_status == jnx_dds_types_pb2.STATUS_END_OF_STREAM:
       # all the objects received
       break
   else
       # error occured
       print "Received error: " + obj.stream_status

ApplicationDataGet

API to fetch data from a specific application and a node. This set of data includes certain stats, telemetry and other CLI data.

Input: ApplicationDataRequest

Output: DataStreamResponse

Example(s):

"""
Application data is addressed by Advertisement topics. To get the
list of available advertisement, Execute TopicSubscribeRequest() with
topic name: ["/Root/Type/net::juniper::ddx::Advertisement"] and refer
the topic field in the Advertisement objects. Pass the required topic name
for the data_path argument along with the application and node name to fetch
application specific data.
"""
path_of_interest = "some-data-path-of-interest"
arg = struct.Struct() # Google protobuf struct.proto
arg['app'] = "application-name" # ex: 'ifmand' (which is the interface manager daemon)
arg['node'] = "node-name" # ex: 're0' (which refers to routing engine 0)
grpc_stub = jnx_dds_service_pb2.DDSStub(grpc_channel)
objects = grpc_stub.ApplicationDataGet(jnx_dds_types_pb2.ApplicationDataRequest(data_path=path_of_interest, arguments=args))
for obj in objects:
   if obj.stream_status == jnx_dds_types_pb2.STATUS_STREAMING:
       # more objects to received
       print obj
   elif obj.stream_status == jnx_dds_types_pb2.STATUS_END_OF_STREAM:
       # all the objects Received
       break
   else
       # error occured
       print "Received error: " + obj.stream_status