From 8c45a0135988ce823e053556f8bcc13fa3a20998 Mon Sep 17 00:00:00 2001 From: akarneliuk Date: Fri, 22 Jul 2022 13:39:37 +0100 Subject: [PATCH 1/2] 0.7.6-wip --- pygnmi/__init__.py | 2 +- pygnmi/client.py | 10 +- pygnmi/path_generator.py | 2 +- pygnmi/spec/v080/gnmi_ext_pb2.py | 102 ++++++ pygnmi/spec/v080/gnmi_pb2.py | 341 ++++++++++++++++++ pygnmi/spec/v080/gnmi_pb2_grpc.py | 215 ++++++++++++ pygnmi/spec/v080/proto/collector.proto | 32 ++ pygnmi/spec/v080/proto/gnmi.proto | 458 +++++++++++++++++++++++++ pygnmi/spec/v080/proto/gnmi_ext.proto | 91 +++++ pygnmi/spec/v080/proto/target.proto | 78 +++++ requirements-dev.txt | 9 + tests/test_00_xpath.py | 2 +- 12 files changed, 1334 insertions(+), 8 deletions(-) create mode 100644 pygnmi/spec/v080/gnmi_ext_pb2.py create mode 100644 pygnmi/spec/v080/gnmi_pb2.py create mode 100644 pygnmi/spec/v080/gnmi_pb2_grpc.py create mode 100644 pygnmi/spec/v080/proto/collector.proto create mode 100644 pygnmi/spec/v080/proto/gnmi.proto create mode 100644 pygnmi/spec/v080/proto/gnmi_ext.proto create mode 100644 pygnmi/spec/v080/proto/target.proto create mode 100644 requirements-dev.txt diff --git a/pygnmi/__init__.py b/pygnmi/__init__.py index c0d709b..a8af67d 100644 --- a/pygnmi/__init__.py +++ b/pygnmi/__init__.py @@ -2,4 +2,4 @@ pyGNMI module to manage network devices with gNMI (c)2020-2022, Karneliuk """ -__version__ = "0.7.5" +__version__ = "0.7.6" diff --git a/pygnmi/client.py b/pygnmi/client.py index 5890795..250fe95 100644 --- a/pygnmi/client.py +++ b/pygnmi/client.py @@ -11,8 +11,8 @@ import os import cryptography import grpc -from pygnmi.spec.gnmi_pb2_grpc import gNMIStub -from pygnmi.spec.gnmi_pb2 import (CapabilityRequest, Encoding, GetRequest,\ +from pygnmi.spec.v080.gnmi_pb2_grpc import gNMIStub +from pygnmi.spec.v080.gnmi_pb2 import (CapabilityRequest, Encoding, GetRequest,\ SetRequest, Update, TypedValue, SubscribeRequest, Poll, SubscriptionList,\ SubscriptionMode, AliasList, UpdateResult) @@ -375,7 +375,7 @@ def get(self, prefix: str = "", path: list = [], pb_encoding = 4 try: - gnmi_message_request = GetRequest(prefix=protobuf_prefix, path=protobuf_paths, + gnmi_message_request = GetRequest(prefix=protobuf_prefix, path=protobuf_paths, type=pb_datatype, encoding=pb_encoding) debug_gnmi_msg(self.__debug, gnmi_message_request, "gNMI request") @@ -459,8 +459,8 @@ def get(self, prefix: str = "", path: list = [], logger.critical(f"GRPC ERROR Host: {self.__target_path}, Error: {err.details()}") raise gNMIException(f"GRPC ERROR Host: {self.__target_path}, Error: {err.details()}", err) - except: - logger.error(f'Collection of Get information failed is failed.') + # except: + # logger.error(f'Collection of Get information failed is failed.') return None diff --git a/pygnmi/path_generator.py b/pygnmi/path_generator.py index cbf68a3..457b70c 100644 --- a/pygnmi/path_generator.py +++ b/pygnmi/path_generator.py @@ -3,7 +3,7 @@ """ # Modules import re -from pygnmi.spec.gnmi_pb2 import Path +from pygnmi.spec.v080.gnmi_pb2 import Path # User-defined functions diff --git a/pygnmi/spec/v080/gnmi_ext_pb2.py b/pygnmi/spec/v080/gnmi_ext_pb2.py new file mode 100644 index 0000000..2c39107 --- /dev/null +++ b/pygnmi/spec/v080/gnmi_ext_pb2.py @@ -0,0 +1,102 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: gnmi_ext.proto +"""Generated protocol buffer code.""" +from google.protobuf.internal import enum_type_wrapper +from google.protobuf import descriptor as _descriptor +from google.protobuf import descriptor_pool as _descriptor_pool +from google.protobuf import message as _message +from google.protobuf import reflection as _reflection +from google.protobuf import symbol_database as _symbol_database +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + + + +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0egnmi_ext.proto\x12\x08gnmi_ext\"\xac\x01\n\tExtension\x12\x37\n\x0eregistered_ext\x18\x01 \x01(\x0b\x32\x1d.gnmi_ext.RegisteredExtensionH\x00\x12\x39\n\x12master_arbitration\x18\x02 \x01(\x0b\x32\x1b.gnmi_ext.MasterArbitrationH\x00\x12$\n\x07history\x18\x03 \x01(\x0b\x32\x11.gnmi_ext.HistoryH\x00\x42\x05\n\x03\x65xt\"E\n\x13RegisteredExtension\x12!\n\x02id\x18\x01 \x01(\x0e\x32\x15.gnmi_ext.ExtensionID\x12\x0b\n\x03msg\x18\x02 \x01(\x0c\"Y\n\x11MasterArbitration\x12\x1c\n\x04role\x18\x01 \x01(\x0b\x32\x0e.gnmi_ext.Role\x12&\n\x0b\x65lection_id\x18\x02 \x01(\x0b\x32\x11.gnmi_ext.Uint128\"$\n\x07Uint128\x12\x0c\n\x04high\x18\x01 \x01(\x04\x12\x0b\n\x03low\x18\x02 \x01(\x04\"\x12\n\x04Role\x12\n\n\x02id\x18\x01 \x01(\t\"S\n\x07History\x12\x17\n\rsnapshot_time\x18\x01 \x01(\x03H\x00\x12$\n\x05range\x18\x02 \x01(\x0b\x32\x13.gnmi_ext.TimeRangeH\x00\x42\t\n\x07request\"\'\n\tTimeRange\x12\r\n\x05start\x18\x01 \x01(\x03\x12\x0b\n\x03\x65nd\x18\x02 \x01(\x03*3\n\x0b\x45xtensionID\x12\r\n\tEID_UNSET\x10\x00\x12\x15\n\x10\x45ID_EXPERIMENTAL\x10\xe7\x07\x42+Z)github.com/openconfig/gnmi/proto/gnmi_extb\x06proto3') + +_EXTENSIONID = DESCRIPTOR.enum_types_by_name['ExtensionID'] +ExtensionID = enum_type_wrapper.EnumTypeWrapper(_EXTENSIONID) +EID_UNSET = 0 +EID_EXPERIMENTAL = 999 + + +_EXTENSION = DESCRIPTOR.message_types_by_name['Extension'] +_REGISTEREDEXTENSION = DESCRIPTOR.message_types_by_name['RegisteredExtension'] +_MASTERARBITRATION = DESCRIPTOR.message_types_by_name['MasterArbitration'] +_UINT128 = DESCRIPTOR.message_types_by_name['Uint128'] +_ROLE = DESCRIPTOR.message_types_by_name['Role'] +_HISTORY = DESCRIPTOR.message_types_by_name['History'] +_TIMERANGE = DESCRIPTOR.message_types_by_name['TimeRange'] +Extension = _reflection.GeneratedProtocolMessageType('Extension', (_message.Message,), { + 'DESCRIPTOR' : _EXTENSION, + '__module__' : 'gnmi_ext_pb2' + # @@protoc_insertion_point(class_scope:gnmi_ext.Extension) + }) +_sym_db.RegisterMessage(Extension) + +RegisteredExtension = _reflection.GeneratedProtocolMessageType('RegisteredExtension', (_message.Message,), { + 'DESCRIPTOR' : _REGISTEREDEXTENSION, + '__module__' : 'gnmi_ext_pb2' + # @@protoc_insertion_point(class_scope:gnmi_ext.RegisteredExtension) + }) +_sym_db.RegisterMessage(RegisteredExtension) + +MasterArbitration = _reflection.GeneratedProtocolMessageType('MasterArbitration', (_message.Message,), { + 'DESCRIPTOR' : _MASTERARBITRATION, + '__module__' : 'gnmi_ext_pb2' + # @@protoc_insertion_point(class_scope:gnmi_ext.MasterArbitration) + }) +_sym_db.RegisterMessage(MasterArbitration) + +Uint128 = _reflection.GeneratedProtocolMessageType('Uint128', (_message.Message,), { + 'DESCRIPTOR' : _UINT128, + '__module__' : 'gnmi_ext_pb2' + # @@protoc_insertion_point(class_scope:gnmi_ext.Uint128) + }) +_sym_db.RegisterMessage(Uint128) + +Role = _reflection.GeneratedProtocolMessageType('Role', (_message.Message,), { + 'DESCRIPTOR' : _ROLE, + '__module__' : 'gnmi_ext_pb2' + # @@protoc_insertion_point(class_scope:gnmi_ext.Role) + }) +_sym_db.RegisterMessage(Role) + +History = _reflection.GeneratedProtocolMessageType('History', (_message.Message,), { + 'DESCRIPTOR' : _HISTORY, + '__module__' : 'gnmi_ext_pb2' + # @@protoc_insertion_point(class_scope:gnmi_ext.History) + }) +_sym_db.RegisterMessage(History) + +TimeRange = _reflection.GeneratedProtocolMessageType('TimeRange', (_message.Message,), { + 'DESCRIPTOR' : _TIMERANGE, + '__module__' : 'gnmi_ext_pb2' + # @@protoc_insertion_point(class_scope:gnmi_ext.TimeRange) + }) +_sym_db.RegisterMessage(TimeRange) + +if _descriptor._USE_C_DESCRIPTORS == False: + + DESCRIPTOR._options = None + DESCRIPTOR._serialized_options = b'Z)github.com/openconfig/gnmi/proto/gnmi_ext' + _EXTENSIONID._serialized_start=549 + _EXTENSIONID._serialized_end=600 + _EXTENSION._serialized_start=29 + _EXTENSION._serialized_end=201 + _REGISTEREDEXTENSION._serialized_start=203 + _REGISTEREDEXTENSION._serialized_end=272 + _MASTERARBITRATION._serialized_start=274 + _MASTERARBITRATION._serialized_end=363 + _UINT128._serialized_start=365 + _UINT128._serialized_end=401 + _ROLE._serialized_start=403 + _ROLE._serialized_end=421 + _HISTORY._serialized_start=423 + _HISTORY._serialized_end=506 + _TIMERANGE._serialized_start=508 + _TIMERANGE._serialized_end=547 +# @@protoc_insertion_point(module_scope) diff --git a/pygnmi/spec/v080/gnmi_pb2.py b/pygnmi/spec/v080/gnmi_pb2.py new file mode 100644 index 0000000..6843968 --- /dev/null +++ b/pygnmi/spec/v080/gnmi_pb2.py @@ -0,0 +1,341 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: gnmi.proto +"""Generated protocol buffer code.""" +from google.protobuf.internal import enum_type_wrapper +from google.protobuf import descriptor as _descriptor +from google.protobuf import descriptor_pool as _descriptor_pool +from google.protobuf import message as _message +from google.protobuf import reflection as _reflection +from google.protobuf import symbol_database as _symbol_database +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + +from google.protobuf import any_pb2 as google_dot_protobuf_dot_any__pb2 +from google.protobuf import descriptor_pb2 as google_dot_protobuf_dot_descriptor__pb2 +import pygnmi.spec.v080.gnmi_ext_pb2 as gnmi__ext__pb2 + + +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\ngnmi.proto\x12\x04gnmi\x1a\x19google/protobuf/any.proto\x1a google/protobuf/descriptor.proto\x1a\x0egnmi_ext.proto\"\x96\x01\n\x0cNotification\x12\x11\n\ttimestamp\x18\x01 \x01(\x03\x12\x1a\n\x06prefix\x18\x02 \x01(\x0b\x32\n.gnmi.Path\x12\r\n\x05\x61lias\x18\x03 \x01(\t\x12\x1c\n\x06update\x18\x04 \x03(\x0b\x32\x0c.gnmi.Update\x12\x1a\n\x06\x64\x65lete\x18\x05 \x03(\x0b\x32\n.gnmi.Path\x12\x0e\n\x06\x61tomic\x18\x06 \x01(\x08\"u\n\x06Update\x12\x18\n\x04path\x18\x01 \x01(\x0b\x32\n.gnmi.Path\x12\x1e\n\x05value\x18\x02 \x01(\x0b\x32\x0b.gnmi.ValueB\x02\x18\x01\x12\x1d\n\x03val\x18\x03 \x01(\x0b\x32\x10.gnmi.TypedValue\x12\x12\n\nduplicates\x18\x04 \x01(\r\"\x83\x03\n\nTypedValue\x12\x14\n\nstring_val\x18\x01 \x01(\tH\x00\x12\x11\n\x07int_val\x18\x02 \x01(\x03H\x00\x12\x12\n\x08uint_val\x18\x03 \x01(\x04H\x00\x12\x12\n\x08\x62ool_val\x18\x04 \x01(\x08H\x00\x12\x13\n\tbytes_val\x18\x05 \x01(\x0cH\x00\x12\x17\n\tfloat_val\x18\x06 \x01(\x02\x42\x02\x18\x01H\x00\x12\x14\n\ndouble_val\x18\x0e \x01(\x01H\x00\x12*\n\x0b\x64\x65\x63imal_val\x18\x07 \x01(\x0b\x32\x0f.gnmi.Decimal64B\x02\x18\x01H\x00\x12)\n\x0cleaflist_val\x18\x08 \x01(\x0b\x32\x11.gnmi.ScalarArrayH\x00\x12\'\n\x07\x61ny_val\x18\t \x01(\x0b\x32\x14.google.protobuf.AnyH\x00\x12\x12\n\x08json_val\x18\n \x01(\x0cH\x00\x12\x17\n\rjson_ietf_val\x18\x0b \x01(\x0cH\x00\x12\x13\n\tascii_val\x18\x0c \x01(\tH\x00\x12\x15\n\x0bproto_bytes\x18\r \x01(\x0cH\x00\x42\x07\n\x05value\"Y\n\x04Path\x12\x13\n\x07\x65lement\x18\x01 \x03(\tB\x02\x18\x01\x12\x0e\n\x06origin\x18\x02 \x01(\t\x12\x1c\n\x04\x65lem\x18\x03 \x03(\x0b\x32\x0e.gnmi.PathElem\x12\x0e\n\x06target\x18\x04 \x01(\t\"j\n\x08PathElem\x12\x0c\n\x04name\x18\x01 \x01(\t\x12$\n\x03key\x18\x02 \x03(\x0b\x32\x17.gnmi.PathElem.KeyEntry\x1a*\n\x08KeyEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"8\n\x05Value\x12\r\n\x05value\x18\x01 \x01(\x0c\x12\x1c\n\x04type\x18\x02 \x01(\x0e\x32\x0e.gnmi.Encoding:\x02\x18\x01\"N\n\x05\x45rror\x12\x0c\n\x04\x63ode\x18\x01 \x01(\r\x12\x0f\n\x07message\x18\x02 \x01(\t\x12\"\n\x04\x64\x61ta\x18\x03 \x01(\x0b\x32\x14.google.protobuf.Any:\x02\x18\x01\".\n\tDecimal64\x12\x0e\n\x06\x64igits\x18\x01 \x01(\x03\x12\x11\n\tprecision\x18\x02 \x01(\r\"0\n\x0bScalarArray\x12!\n\x07\x65lement\x18\x01 \x03(\x0b\x32\x10.gnmi.TypedValue\"\xb2\x01\n\x10SubscribeRequest\x12+\n\tsubscribe\x18\x01 \x01(\x0b\x32\x16.gnmi.SubscriptionListH\x00\x12\x1a\n\x04poll\x18\x03 \x01(\x0b\x32\n.gnmi.PollH\x00\x12\"\n\x07\x61liases\x18\x04 \x01(\x0b\x32\x0f.gnmi.AliasListH\x00\x12&\n\textension\x18\x05 \x03(\x0b\x32\x13.gnmi_ext.ExtensionB\t\n\x07request\"\x06\n\x04Poll\"\xa8\x01\n\x11SubscribeResponse\x12$\n\x06update\x18\x01 \x01(\x0b\x32\x12.gnmi.NotificationH\x00\x12\x17\n\rsync_response\x18\x03 \x01(\x08H\x00\x12 \n\x05\x65rror\x18\x04 \x01(\x0b\x32\x0b.gnmi.ErrorB\x02\x18\x01H\x00\x12&\n\textension\x18\x05 \x03(\x0b\x32\x13.gnmi_ext.ExtensionB\n\n\x08response\"\xd7\x02\n\x10SubscriptionList\x12\x1a\n\x06prefix\x18\x01 \x01(\x0b\x32\n.gnmi.Path\x12(\n\x0csubscription\x18\x02 \x03(\x0b\x32\x12.gnmi.Subscription\x12\x13\n\x0buse_aliases\x18\x03 \x01(\x08\x12\x1d\n\x03qos\x18\x04 \x01(\x0b\x32\x10.gnmi.QOSMarking\x12)\n\x04mode\x18\x05 \x01(\x0e\x32\x1b.gnmi.SubscriptionList.Mode\x12\x19\n\x11\x61llow_aggregation\x18\x06 \x01(\x08\x12#\n\nuse_models\x18\x07 \x03(\x0b\x32\x0f.gnmi.ModelData\x12 \n\x08\x65ncoding\x18\x08 \x01(\x0e\x32\x0e.gnmi.Encoding\x12\x14\n\x0cupdates_only\x18\t \x01(\x08\"&\n\x04Mode\x12\n\n\x06STREAM\x10\x00\x12\x08\n\x04ONCE\x10\x01\x12\x08\n\x04POLL\x10\x02\"\x9f\x01\n\x0cSubscription\x12\x18\n\x04path\x18\x01 \x01(\x0b\x32\n.gnmi.Path\x12$\n\x04mode\x18\x02 \x01(\x0e\x32\x16.gnmi.SubscriptionMode\x12\x17\n\x0fsample_interval\x18\x03 \x01(\x04\x12\x1a\n\x12suppress_redundant\x18\x04 \x01(\x08\x12\x1a\n\x12heartbeat_interval\x18\x05 \x01(\x04\"\x1d\n\nQOSMarking\x12\x0f\n\x07marking\x18\x01 \x01(\r\"0\n\x05\x41lias\x12\x18\n\x04path\x18\x01 \x01(\x0b\x32\n.gnmi.Path\x12\r\n\x05\x61lias\x18\x02 \x01(\t\"\'\n\tAliasList\x12\x1a\n\x05\x61lias\x18\x01 \x03(\x0b\x32\x0b.gnmi.Alias\"\xa9\x01\n\nSetRequest\x12\x1a\n\x06prefix\x18\x01 \x01(\x0b\x32\n.gnmi.Path\x12\x1a\n\x06\x64\x65lete\x18\x02 \x03(\x0b\x32\n.gnmi.Path\x12\x1d\n\x07replace\x18\x03 \x03(\x0b\x32\x0c.gnmi.Update\x12\x1c\n\x06update\x18\x04 \x03(\x0b\x32\x0c.gnmi.Update\x12&\n\textension\x18\x05 \x03(\x0b\x32\x13.gnmi_ext.Extension\"\xac\x01\n\x0bSetResponse\x12\x1a\n\x06prefix\x18\x01 \x01(\x0b\x32\n.gnmi.Path\x12$\n\x08response\x18\x02 \x03(\x0b\x32\x12.gnmi.UpdateResult\x12 \n\x07message\x18\x03 \x01(\x0b\x32\x0b.gnmi.ErrorB\x02\x18\x01\x12\x11\n\ttimestamp\x18\x04 \x01(\x03\x12&\n\textension\x18\x05 \x03(\x0b\x32\x13.gnmi_ext.Extension\"\xca\x01\n\x0cUpdateResult\x12\x15\n\ttimestamp\x18\x01 \x01(\x03\x42\x02\x18\x01\x12\x18\n\x04path\x18\x02 \x01(\x0b\x32\n.gnmi.Path\x12 \n\x07message\x18\x03 \x01(\x0b\x32\x0b.gnmi.ErrorB\x02\x18\x01\x12(\n\x02op\x18\x04 \x01(\x0e\x32\x1c.gnmi.UpdateResult.Operation\"=\n\tOperation\x12\x0b\n\x07INVALID\x10\x00\x12\n\n\x06\x44\x45LETE\x10\x01\x12\x0b\n\x07REPLACE\x10\x02\x12\n\n\x06UPDATE\x10\x03\"\x97\x02\n\nGetRequest\x12\x1a\n\x06prefix\x18\x01 \x01(\x0b\x32\n.gnmi.Path\x12\x18\n\x04path\x18\x02 \x03(\x0b\x32\n.gnmi.Path\x12\'\n\x04type\x18\x03 \x01(\x0e\x32\x19.gnmi.GetRequest.DataType\x12 \n\x08\x65ncoding\x18\x05 \x01(\x0e\x32\x0e.gnmi.Encoding\x12#\n\nuse_models\x18\x06 \x03(\x0b\x32\x0f.gnmi.ModelData\x12&\n\textension\x18\x07 \x03(\x0b\x32\x13.gnmi_ext.Extension\";\n\x08\x44\x61taType\x12\x07\n\x03\x41LL\x10\x00\x12\n\n\x06\x43ONFIG\x10\x01\x12\t\n\x05STATE\x10\x02\x12\x0f\n\x0bOPERATIONAL\x10\x03\"\x7f\n\x0bGetResponse\x12(\n\x0cnotification\x18\x01 \x03(\x0b\x32\x12.gnmi.Notification\x12\x1e\n\x05\x65rror\x18\x02 \x01(\x0b\x32\x0b.gnmi.ErrorB\x02\x18\x01\x12&\n\textension\x18\x03 \x03(\x0b\x32\x13.gnmi_ext.Extension\";\n\x11\x43\x61pabilityRequest\x12&\n\textension\x18\x01 \x03(\x0b\x32\x13.gnmi_ext.Extension\"\xaa\x01\n\x12\x43\x61pabilityResponse\x12)\n\x10supported_models\x18\x01 \x03(\x0b\x32\x0f.gnmi.ModelData\x12+\n\x13supported_encodings\x18\x02 \x03(\x0e\x32\x0e.gnmi.Encoding\x12\x14\n\x0cgNMI_version\x18\x03 \x01(\t\x12&\n\textension\x18\x04 \x03(\x0b\x32\x13.gnmi_ext.Extension\"@\n\tModelData\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x14\n\x0corganization\x18\x02 \x01(\t\x12\x0f\n\x07version\x18\x03 \x01(\t*D\n\x08\x45ncoding\x12\x08\n\x04JSON\x10\x00\x12\t\n\x05\x42YTES\x10\x01\x12\t\n\x05PROTO\x10\x02\x12\t\n\x05\x41SCII\x10\x03\x12\r\n\tJSON_IETF\x10\x04*A\n\x10SubscriptionMode\x12\x12\n\x0eTARGET_DEFINED\x10\x00\x12\r\n\tON_CHANGE\x10\x01\x12\n\n\x06SAMPLE\x10\x02\x32\xe3\x01\n\x04gNMI\x12\x41\n\x0c\x43\x61pabilities\x12\x17.gnmi.CapabilityRequest\x1a\x18.gnmi.CapabilityResponse\x12*\n\x03Get\x12\x10.gnmi.GetRequest\x1a\x11.gnmi.GetResponse\x12*\n\x03Set\x12\x10.gnmi.SetRequest\x1a\x11.gnmi.SetResponse\x12@\n\tSubscribe\x12\x16.gnmi.SubscribeRequest\x1a\x17.gnmi.SubscribeResponse(\x01\x30\x01\x62\x06proto3') + +_ENCODING = DESCRIPTOR.enum_types_by_name['Encoding'] +Encoding = enum_type_wrapper.EnumTypeWrapper(_ENCODING) +_SUBSCRIPTIONMODE = DESCRIPTOR.enum_types_by_name['SubscriptionMode'] +SubscriptionMode = enum_type_wrapper.EnumTypeWrapper(_SUBSCRIPTIONMODE) +JSON = 0 +BYTES = 1 +PROTO = 2 +ASCII = 3 +JSON_IETF = 4 +TARGET_DEFINED = 0 +ON_CHANGE = 1 +SAMPLE = 2 + + +_NOTIFICATION = DESCRIPTOR.message_types_by_name['Notification'] +_UPDATE = DESCRIPTOR.message_types_by_name['Update'] +_TYPEDVALUE = DESCRIPTOR.message_types_by_name['TypedValue'] +_PATH = DESCRIPTOR.message_types_by_name['Path'] +_PATHELEM = DESCRIPTOR.message_types_by_name['PathElem'] +_PATHELEM_KEYENTRY = _PATHELEM.nested_types_by_name['KeyEntry'] +_VALUE = DESCRIPTOR.message_types_by_name['Value'] +_ERROR = DESCRIPTOR.message_types_by_name['Error'] +_DECIMAL64 = DESCRIPTOR.message_types_by_name['Decimal64'] +_SCALARARRAY = DESCRIPTOR.message_types_by_name['ScalarArray'] +_SUBSCRIBEREQUEST = DESCRIPTOR.message_types_by_name['SubscribeRequest'] +_POLL = DESCRIPTOR.message_types_by_name['Poll'] +_SUBSCRIBERESPONSE = DESCRIPTOR.message_types_by_name['SubscribeResponse'] +_SUBSCRIPTIONLIST = DESCRIPTOR.message_types_by_name['SubscriptionList'] +_SUBSCRIPTION = DESCRIPTOR.message_types_by_name['Subscription'] +_QOSMARKING = DESCRIPTOR.message_types_by_name['QOSMarking'] +_ALIAS = DESCRIPTOR.message_types_by_name['Alias'] +_ALIASLIST = DESCRIPTOR.message_types_by_name['AliasList'] +_SETREQUEST = DESCRIPTOR.message_types_by_name['SetRequest'] +_SETRESPONSE = DESCRIPTOR.message_types_by_name['SetResponse'] +_UPDATERESULT = DESCRIPTOR.message_types_by_name['UpdateResult'] +_GETREQUEST = DESCRIPTOR.message_types_by_name['GetRequest'] +_GETRESPONSE = DESCRIPTOR.message_types_by_name['GetResponse'] +_CAPABILITYREQUEST = DESCRIPTOR.message_types_by_name['CapabilityRequest'] +_CAPABILITYRESPONSE = DESCRIPTOR.message_types_by_name['CapabilityResponse'] +_MODELDATA = DESCRIPTOR.message_types_by_name['ModelData'] +_SUBSCRIPTIONLIST_MODE = _SUBSCRIPTIONLIST.enum_types_by_name['Mode'] +_UPDATERESULT_OPERATION = _UPDATERESULT.enum_types_by_name['Operation'] +_GETREQUEST_DATATYPE = _GETREQUEST.enum_types_by_name['DataType'] +Notification = _reflection.GeneratedProtocolMessageType('Notification', (_message.Message,), { + 'DESCRIPTOR' : _NOTIFICATION, + '__module__' : 'gnmi_pb2' + # @@protoc_insertion_point(class_scope:gnmi.Notification) + }) +_sym_db.RegisterMessage(Notification) + +Update = _reflection.GeneratedProtocolMessageType('Update', (_message.Message,), { + 'DESCRIPTOR' : _UPDATE, + '__module__' : 'gnmi_pb2' + # @@protoc_insertion_point(class_scope:gnmi.Update) + }) +_sym_db.RegisterMessage(Update) + +TypedValue = _reflection.GeneratedProtocolMessageType('TypedValue', (_message.Message,), { + 'DESCRIPTOR' : _TYPEDVALUE, + '__module__' : 'gnmi_pb2' + # @@protoc_insertion_point(class_scope:gnmi.TypedValue) + }) +_sym_db.RegisterMessage(TypedValue) + +Path = _reflection.GeneratedProtocolMessageType('Path', (_message.Message,), { + 'DESCRIPTOR' : _PATH, + '__module__' : 'gnmi_pb2' + # @@protoc_insertion_point(class_scope:gnmi.Path) + }) +_sym_db.RegisterMessage(Path) + +PathElem = _reflection.GeneratedProtocolMessageType('PathElem', (_message.Message,), { + + 'KeyEntry' : _reflection.GeneratedProtocolMessageType('KeyEntry', (_message.Message,), { + 'DESCRIPTOR' : _PATHELEM_KEYENTRY, + '__module__' : 'gnmi_pb2' + # @@protoc_insertion_point(class_scope:gnmi.PathElem.KeyEntry) + }) + , + 'DESCRIPTOR' : _PATHELEM, + '__module__' : 'gnmi_pb2' + # @@protoc_insertion_point(class_scope:gnmi.PathElem) + }) +_sym_db.RegisterMessage(PathElem) +_sym_db.RegisterMessage(PathElem.KeyEntry) + +Value = _reflection.GeneratedProtocolMessageType('Value', (_message.Message,), { + 'DESCRIPTOR' : _VALUE, + '__module__' : 'gnmi_pb2' + # @@protoc_insertion_point(class_scope:gnmi.Value) + }) +_sym_db.RegisterMessage(Value) + +Error = _reflection.GeneratedProtocolMessageType('Error', (_message.Message,), { + 'DESCRIPTOR' : _ERROR, + '__module__' : 'gnmi_pb2' + # @@protoc_insertion_point(class_scope:gnmi.Error) + }) +_sym_db.RegisterMessage(Error) + +Decimal64 = _reflection.GeneratedProtocolMessageType('Decimal64', (_message.Message,), { + 'DESCRIPTOR' : _DECIMAL64, + '__module__' : 'gnmi_pb2' + # @@protoc_insertion_point(class_scope:gnmi.Decimal64) + }) +_sym_db.RegisterMessage(Decimal64) + +ScalarArray = _reflection.GeneratedProtocolMessageType('ScalarArray', (_message.Message,), { + 'DESCRIPTOR' : _SCALARARRAY, + '__module__' : 'gnmi_pb2' + # @@protoc_insertion_point(class_scope:gnmi.ScalarArray) + }) +_sym_db.RegisterMessage(ScalarArray) + +SubscribeRequest = _reflection.GeneratedProtocolMessageType('SubscribeRequest', (_message.Message,), { + 'DESCRIPTOR' : _SUBSCRIBEREQUEST, + '__module__' : 'gnmi_pb2' + # @@protoc_insertion_point(class_scope:gnmi.SubscribeRequest) + }) +_sym_db.RegisterMessage(SubscribeRequest) + +Poll = _reflection.GeneratedProtocolMessageType('Poll', (_message.Message,), { + 'DESCRIPTOR' : _POLL, + '__module__' : 'gnmi_pb2' + # @@protoc_insertion_point(class_scope:gnmi.Poll) + }) +_sym_db.RegisterMessage(Poll) + +SubscribeResponse = _reflection.GeneratedProtocolMessageType('SubscribeResponse', (_message.Message,), { + 'DESCRIPTOR' : _SUBSCRIBERESPONSE, + '__module__' : 'gnmi_pb2' + # @@protoc_insertion_point(class_scope:gnmi.SubscribeResponse) + }) +_sym_db.RegisterMessage(SubscribeResponse) + +SubscriptionList = _reflection.GeneratedProtocolMessageType('SubscriptionList', (_message.Message,), { + 'DESCRIPTOR' : _SUBSCRIPTIONLIST, + '__module__' : 'gnmi_pb2' + # @@protoc_insertion_point(class_scope:gnmi.SubscriptionList) + }) +_sym_db.RegisterMessage(SubscriptionList) + +Subscription = _reflection.GeneratedProtocolMessageType('Subscription', (_message.Message,), { + 'DESCRIPTOR' : _SUBSCRIPTION, + '__module__' : 'gnmi_pb2' + # @@protoc_insertion_point(class_scope:gnmi.Subscription) + }) +_sym_db.RegisterMessage(Subscription) + +QOSMarking = _reflection.GeneratedProtocolMessageType('QOSMarking', (_message.Message,), { + 'DESCRIPTOR' : _QOSMARKING, + '__module__' : 'gnmi_pb2' + # @@protoc_insertion_point(class_scope:gnmi.QOSMarking) + }) +_sym_db.RegisterMessage(QOSMarking) + +Alias = _reflection.GeneratedProtocolMessageType('Alias', (_message.Message,), { + 'DESCRIPTOR' : _ALIAS, + '__module__' : 'gnmi_pb2' + # @@protoc_insertion_point(class_scope:gnmi.Alias) + }) +_sym_db.RegisterMessage(Alias) + +AliasList = _reflection.GeneratedProtocolMessageType('AliasList', (_message.Message,), { + 'DESCRIPTOR' : _ALIASLIST, + '__module__' : 'gnmi_pb2' + # @@protoc_insertion_point(class_scope:gnmi.AliasList) + }) +_sym_db.RegisterMessage(AliasList) + +SetRequest = _reflection.GeneratedProtocolMessageType('SetRequest', (_message.Message,), { + 'DESCRIPTOR' : _SETREQUEST, + '__module__' : 'gnmi_pb2' + # @@protoc_insertion_point(class_scope:gnmi.SetRequest) + }) +_sym_db.RegisterMessage(SetRequest) + +SetResponse = _reflection.GeneratedProtocolMessageType('SetResponse', (_message.Message,), { + 'DESCRIPTOR' : _SETRESPONSE, + '__module__' : 'gnmi_pb2' + # @@protoc_insertion_point(class_scope:gnmi.SetResponse) + }) +_sym_db.RegisterMessage(SetResponse) + +UpdateResult = _reflection.GeneratedProtocolMessageType('UpdateResult', (_message.Message,), { + 'DESCRIPTOR' : _UPDATERESULT, + '__module__' : 'gnmi_pb2' + # @@protoc_insertion_point(class_scope:gnmi.UpdateResult) + }) +_sym_db.RegisterMessage(UpdateResult) + +GetRequest = _reflection.GeneratedProtocolMessageType('GetRequest', (_message.Message,), { + 'DESCRIPTOR' : _GETREQUEST, + '__module__' : 'gnmi_pb2' + # @@protoc_insertion_point(class_scope:gnmi.GetRequest) + }) +_sym_db.RegisterMessage(GetRequest) + +GetResponse = _reflection.GeneratedProtocolMessageType('GetResponse', (_message.Message,), { + 'DESCRIPTOR' : _GETRESPONSE, + '__module__' : 'gnmi_pb2' + # @@protoc_insertion_point(class_scope:gnmi.GetResponse) + }) +_sym_db.RegisterMessage(GetResponse) + +CapabilityRequest = _reflection.GeneratedProtocolMessageType('CapabilityRequest', (_message.Message,), { + 'DESCRIPTOR' : _CAPABILITYREQUEST, + '__module__' : 'gnmi_pb2' + # @@protoc_insertion_point(class_scope:gnmi.CapabilityRequest) + }) +_sym_db.RegisterMessage(CapabilityRequest) + +CapabilityResponse = _reflection.GeneratedProtocolMessageType('CapabilityResponse', (_message.Message,), { + 'DESCRIPTOR' : _CAPABILITYRESPONSE, + '__module__' : 'gnmi_pb2' + # @@protoc_insertion_point(class_scope:gnmi.CapabilityResponse) + }) +_sym_db.RegisterMessage(CapabilityResponse) + +ModelData = _reflection.GeneratedProtocolMessageType('ModelData', (_message.Message,), { + 'DESCRIPTOR' : _MODELDATA, + '__module__' : 'gnmi_pb2' + # @@protoc_insertion_point(class_scope:gnmi.ModelData) + }) +_sym_db.RegisterMessage(ModelData) + +_GNMI = DESCRIPTOR.services_by_name['gNMI'] +if _descriptor._USE_C_DESCRIPTORS == False: + + DESCRIPTOR._options = None + _UPDATE.fields_by_name['value']._options = None + _UPDATE.fields_by_name['value']._serialized_options = b'\030\001' + _TYPEDVALUE.fields_by_name['float_val']._options = None + _TYPEDVALUE.fields_by_name['float_val']._serialized_options = b'\030\001' + _TYPEDVALUE.fields_by_name['decimal_val']._options = None + _TYPEDVALUE.fields_by_name['decimal_val']._serialized_options = b'\030\001' + _PATH.fields_by_name['element']._options = None + _PATH.fields_by_name['element']._serialized_options = b'\030\001' + _PATHELEM_KEYENTRY._options = None + _PATHELEM_KEYENTRY._serialized_options = b'8\001' + _VALUE._options = None + _VALUE._serialized_options = b'\030\001' + _ERROR._options = None + _ERROR._serialized_options = b'\030\001' + _SUBSCRIBERESPONSE.fields_by_name['error']._options = None + _SUBSCRIBERESPONSE.fields_by_name['error']._serialized_options = b'\030\001' + _SETRESPONSE.fields_by_name['message']._options = None + _SETRESPONSE.fields_by_name['message']._serialized_options = b'\030\001' + _UPDATERESULT.fields_by_name['timestamp']._options = None + _UPDATERESULT.fields_by_name['timestamp']._serialized_options = b'\030\001' + _UPDATERESULT.fields_by_name['message']._options = None + _UPDATERESULT.fields_by_name['message']._serialized_options = b'\030\001' + _GETRESPONSE.fields_by_name['error']._options = None + _GETRESPONSE.fields_by_name['error']._serialized_options = b'\030\001' + _ENCODING._serialized_start=3447 + _ENCODING._serialized_end=3515 + _SUBSCRIPTIONMODE._serialized_start=3517 + _SUBSCRIPTIONMODE._serialized_end=3582 + _NOTIFICATION._serialized_start=98 + _NOTIFICATION._serialized_end=248 + _UPDATE._serialized_start=250 + _UPDATE._serialized_end=367 + _TYPEDVALUE._serialized_start=370 + _TYPEDVALUE._serialized_end=757 + _PATH._serialized_start=759 + _PATH._serialized_end=848 + _PATHELEM._serialized_start=850 + _PATHELEM._serialized_end=956 + _PATHELEM_KEYENTRY._serialized_start=914 + _PATHELEM_KEYENTRY._serialized_end=956 + _VALUE._serialized_start=958 + _VALUE._serialized_end=1014 + _ERROR._serialized_start=1016 + _ERROR._serialized_end=1094 + _DECIMAL64._serialized_start=1096 + _DECIMAL64._serialized_end=1142 + _SCALARARRAY._serialized_start=1144 + _SCALARARRAY._serialized_end=1192 + _SUBSCRIBEREQUEST._serialized_start=1195 + _SUBSCRIBEREQUEST._serialized_end=1373 + _POLL._serialized_start=1375 + _POLL._serialized_end=1381 + _SUBSCRIBERESPONSE._serialized_start=1384 + _SUBSCRIBERESPONSE._serialized_end=1552 + _SUBSCRIPTIONLIST._serialized_start=1555 + _SUBSCRIPTIONLIST._serialized_end=1898 + _SUBSCRIPTIONLIST_MODE._serialized_start=1860 + _SUBSCRIPTIONLIST_MODE._serialized_end=1898 + _SUBSCRIPTION._serialized_start=1901 + _SUBSCRIPTION._serialized_end=2060 + _QOSMARKING._serialized_start=2062 + _QOSMARKING._serialized_end=2091 + _ALIAS._serialized_start=2093 + _ALIAS._serialized_end=2141 + _ALIASLIST._serialized_start=2143 + _ALIASLIST._serialized_end=2182 + _SETREQUEST._serialized_start=2185 + _SETREQUEST._serialized_end=2354 + _SETRESPONSE._serialized_start=2357 + _SETRESPONSE._serialized_end=2529 + _UPDATERESULT._serialized_start=2532 + _UPDATERESULT._serialized_end=2734 + _UPDATERESULT_OPERATION._serialized_start=2673 + _UPDATERESULT_OPERATION._serialized_end=2734 + _GETREQUEST._serialized_start=2737 + _GETREQUEST._serialized_end=3016 + _GETREQUEST_DATATYPE._serialized_start=2957 + _GETREQUEST_DATATYPE._serialized_end=3016 + _GETRESPONSE._serialized_start=3018 + _GETRESPONSE._serialized_end=3145 + _CAPABILITYREQUEST._serialized_start=3147 + _CAPABILITYREQUEST._serialized_end=3206 + _CAPABILITYRESPONSE._serialized_start=3209 + _CAPABILITYRESPONSE._serialized_end=3379 + _MODELDATA._serialized_start=3381 + _MODELDATA._serialized_end=3445 + _GNMI._serialized_start=3585 + _GNMI._serialized_end=3812 +# @@protoc_insertion_point(module_scope) diff --git a/pygnmi/spec/v080/gnmi_pb2_grpc.py b/pygnmi/spec/v080/gnmi_pb2_grpc.py new file mode 100644 index 0000000..c4135f0 --- /dev/null +++ b/pygnmi/spec/v080/gnmi_pb2_grpc.py @@ -0,0 +1,215 @@ +# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! +"""Client and server classes corresponding to protobuf-defined services.""" +import grpc + +import pygnmi.spec.v080.gnmi_pb2 as gnmi__pb2 + + +class gNMIStub(object): + """Define a protobuf FileOption that defines the gNMI service version. + extend google.protobuf.FileOptions { + The gNMI service semantic version. + string gnmi_service = 1001; + } + + gNMI_service is the current version of the gNMI service, returned through + the Capabilities RPC. + option (gnmi_service) = "0.8.0"; + + """ + + def __init__(self, channel): + """Constructor. + + Args: + channel: A grpc.Channel. + """ + self.Capabilities = channel.unary_unary( + '/gnmi.gNMI/Capabilities', + request_serializer=gnmi__pb2.CapabilityRequest.SerializeToString, + response_deserializer=gnmi__pb2.CapabilityResponse.FromString, + ) + self.Get = channel.unary_unary( + '/gnmi.gNMI/Get', + request_serializer=gnmi__pb2.GetRequest.SerializeToString, + response_deserializer=gnmi__pb2.GetResponse.FromString, + ) + self.Set = channel.unary_unary( + '/gnmi.gNMI/Set', + request_serializer=gnmi__pb2.SetRequest.SerializeToString, + response_deserializer=gnmi__pb2.SetResponse.FromString, + ) + self.Subscribe = channel.stream_stream( + '/gnmi.gNMI/Subscribe', + request_serializer=gnmi__pb2.SubscribeRequest.SerializeToString, + response_deserializer=gnmi__pb2.SubscribeResponse.FromString, + ) + + +class gNMIServicer(object): + """Define a protobuf FileOption that defines the gNMI service version. + extend google.protobuf.FileOptions { + The gNMI service semantic version. + string gnmi_service = 1001; + } + + gNMI_service is the current version of the gNMI service, returned through + the Capabilities RPC. + option (gnmi_service) = "0.8.0"; + + """ + + def Capabilities(self, request, context): + """Capabilities allows the client to retrieve the set of capabilities that + is supported by the target. This allows the target to validate the + service version that is implemented and retrieve the set of models that + the target supports. The models can then be specified in subsequent RPCs + to restrict the set of data that is utilized. + Reference: gNMI Specification Section 3.2 + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def Get(self, request, context): + """Retrieve a snapshot of data from the target. A Get RPC requests that the + target snapshots a subset of the data tree as specified by the paths + included in the message and serializes this to be returned to the + client using the specified encoding. + Reference: gNMI Specification Section 3.3 + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def Set(self, request, context): + """Set allows the client to modify the state of data on the target. The + paths to modified along with the new values that the client wishes + to set the value to. + Reference: gNMI Specification Section 3.4 + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + def Subscribe(self, request_iterator, context): + """Subscribe allows a client to request the target to send it values + of particular paths within the data tree. These values may be streamed + at a particular cadence (STREAM), sent one off on a long-lived channel + (POLL), or sent as a one-off retrieval (ONCE). + Reference: gNMI Specification Section 3.5 + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') + + +def add_gNMIServicer_to_server(servicer, server): + rpc_method_handlers = { + 'Capabilities': grpc.unary_unary_rpc_method_handler( + servicer.Capabilities, + request_deserializer=gnmi__pb2.CapabilityRequest.FromString, + response_serializer=gnmi__pb2.CapabilityResponse.SerializeToString, + ), + 'Get': grpc.unary_unary_rpc_method_handler( + servicer.Get, + request_deserializer=gnmi__pb2.GetRequest.FromString, + response_serializer=gnmi__pb2.GetResponse.SerializeToString, + ), + 'Set': grpc.unary_unary_rpc_method_handler( + servicer.Set, + request_deserializer=gnmi__pb2.SetRequest.FromString, + response_serializer=gnmi__pb2.SetResponse.SerializeToString, + ), + 'Subscribe': grpc.stream_stream_rpc_method_handler( + servicer.Subscribe, + request_deserializer=gnmi__pb2.SubscribeRequest.FromString, + response_serializer=gnmi__pb2.SubscribeResponse.SerializeToString, + ), + } + generic_handler = grpc.method_handlers_generic_handler( + 'gnmi.gNMI', rpc_method_handlers) + server.add_generic_rpc_handlers((generic_handler,)) + + + # This class is part of an EXPERIMENTAL API. +class gNMI(object): + """Define a protobuf FileOption that defines the gNMI service version. + extend google.protobuf.FileOptions { + The gNMI service semantic version. + string gnmi_service = 1001; + } + + gNMI_service is the current version of the gNMI service, returned through + the Capabilities RPC. + option (gnmi_service) = "0.8.0"; + + """ + + @staticmethod + def Capabilities(request, + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.unary_unary(request, target, '/gnmi.gNMI/Capabilities', + gnmi__pb2.CapabilityRequest.SerializeToString, + gnmi__pb2.CapabilityResponse.FromString, + options, channel_credentials, + insecure, call_credentials, compression, wait_for_ready, timeout, metadata) + + @staticmethod + def Get(request, + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.unary_unary(request, target, '/gnmi.gNMI/Get', + gnmi__pb2.GetRequest.SerializeToString, + gnmi__pb2.GetResponse.FromString, + options, channel_credentials, + insecure, call_credentials, compression, wait_for_ready, timeout, metadata) + + @staticmethod + def Set(request, + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.unary_unary(request, target, '/gnmi.gNMI/Set', + gnmi__pb2.SetRequest.SerializeToString, + gnmi__pb2.SetResponse.FromString, + options, channel_credentials, + insecure, call_credentials, compression, wait_for_ready, timeout, metadata) + + @staticmethod + def Subscribe(request_iterator, + target, + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.stream_stream(request_iterator, target, '/gnmi.gNMI/Subscribe', + gnmi__pb2.SubscribeRequest.SerializeToString, + gnmi__pb2.SubscribeResponse.FromString, + options, channel_credentials, + insecure, call_credentials, compression, wait_for_ready, timeout, metadata) diff --git a/pygnmi/spec/v080/proto/collector.proto b/pygnmi/spec/v080/proto/collector.proto new file mode 100644 index 0000000..db2c195 --- /dev/null +++ b/pygnmi/spec/v080/proto/collector.proto @@ -0,0 +1,32 @@ +// +// Copyright 2020 Google Inc. All Rights Reserved. +// +// 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. +// +syntax = "proto3"; + +package gnmi; + +option go_package = "github.com/openconfig/gnmi/proto/collector;gnmi"; + +service Collector { + // Reconnect requests that the existing connections for one or more specified + // targets will be stopped and new connections established. + rpc Reconnect(ReconnectRequest) returns (Nil) {} +} + +message ReconnectRequest { + repeated string target = 1; // List of targets to reconnect. +} + +message Nil{} diff --git a/pygnmi/spec/v080/proto/gnmi.proto b/pygnmi/spec/v080/proto/gnmi.proto new file mode 100644 index 0000000..b15e85e --- /dev/null +++ b/pygnmi/spec/v080/proto/gnmi.proto @@ -0,0 +1,458 @@ +// +// Copyright 2016 Google Inc. All Rights Reserved. +// +// 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. +// +syntax = "proto3"; + +import "google/protobuf/any.proto"; +import "google/protobuf/descriptor.proto"; +import "gnmi_ext.proto"; + +// Package gNMI defines a service specification for the gRPC Network Management +// Interface. This interface is defined to be a standard interface via which +// a network management system ("client") can subscribe to state values, +// retrieve snapshots of state information, and manipulate the state of a data +// tree supported by a device ("target"). +// +// This document references the gNMI Specification which can be found at +// http://github.com/openconfig/reference/blob/master/rpc/gnmi +package gnmi; + +// Define a protobuf FileOption that defines the gNMI service version. +//extend google.protobuf.FileOptions { + // The gNMI service semantic version. +// string gnmi_service = 1001; +//} + +// gNMI_service is the current version of the gNMI service, returned through +// the Capabilities RPC. +// option (gnmi_service) = "0.8.0"; + + +service gNMI { + // Capabilities allows the client to retrieve the set of capabilities that + // is supported by the target. This allows the target to validate the + // service version that is implemented and retrieve the set of models that + // the target supports. The models can then be specified in subsequent RPCs + // to restrict the set of data that is utilized. + // Reference: gNMI Specification Section 3.2 + rpc Capabilities(CapabilityRequest) returns (CapabilityResponse); + // Retrieve a snapshot of data from the target. A Get RPC requests that the + // target snapshots a subset of the data tree as specified by the paths + // included in the message and serializes this to be returned to the + // client using the specified encoding. + // Reference: gNMI Specification Section 3.3 + rpc Get(GetRequest) returns (GetResponse); + // Set allows the client to modify the state of data on the target. The + // paths to modified along with the new values that the client wishes + // to set the value to. + // Reference: gNMI Specification Section 3.4 + rpc Set(SetRequest) returns (SetResponse); + // Subscribe allows a client to request the target to send it values + // of particular paths within the data tree. These values may be streamed + // at a particular cadence (STREAM), sent one off on a long-lived channel + // (POLL), or sent as a one-off retrieval (ONCE). + // Reference: gNMI Specification Section 3.5 + rpc Subscribe(stream SubscribeRequest) returns (stream SubscribeResponse); +} + +// Notification is a re-usable message that is used to encode data from the +// target to the client. A Notification carries two types of changes to the data +// tree: +// - Deleted values (delete) - a set of paths that have been removed from the +// data tree. +// - Updated values (update) - a set of path-value pairs indicating the path +// whose value has changed in the data tree. +// Reference: gNMI Specification Section 2.1 +message Notification { + int64 timestamp = 1; // Timestamp in nanoseconds since Epoch. + Path prefix = 2; // Prefix used for paths in the message. + // An alias for the path specified in the prefix field. + // Reference: gNMI Specification Section 2.4.2 + string alias = 3; + repeated Update update = 4; // Data elements that have changed values. + repeated Path delete = 5; // Data elements that have been deleted. + // This notification contains a set of paths that are always updated together + // referenced by a globally unique prefix. + bool atomic = 6; +} + +// Update is a re-usable message that is used to store a particular Path, +// Value pair. +// Reference: gNMI Specification Section 2.1 +message Update { + Path path = 1; // The path (key) for the update. + Value value = 2 [deprecated=true]; // The value (value) for the update. + TypedValue val = 3; // The explicitly typed update value. + uint32 duplicates = 4; // Number of coalesced duplicates. +} + +// TypedValue is used to encode a value being sent between the client and +// target (originated by either entity). +message TypedValue { + // One of the fields within the val oneof is populated with the value + // of the update. The type of the value being included in the Update + // determines which field should be populated. In the case that the + // encoding is a particular form of the base protobuf type, a specific + // field is used to store the value (e.g., json_val). + oneof value { + string string_val = 1; // String value. + int64 int_val = 2; // Integer value. + uint64 uint_val = 3; // Unsigned integer value. + bool bool_val = 4; // Bool value. + bytes bytes_val = 5; // Arbitrary byte sequence value. + float float_val = 6 [deprecated=true]; // Deprecated - use double_val. + double double_val = 14; // Floating point value. + Decimal64 decimal_val = 7 [deprecated=true]; // Deprecated - use double_val. + ScalarArray leaflist_val = 8; // Mixed type scalar array value. + google.protobuf.Any any_val = 9; // protobuf.Any encoded bytes. + bytes json_val = 10; // JSON-encoded text. + bytes json_ietf_val = 11; // JSON-encoded text per RFC7951. + string ascii_val = 12; // Arbitrary ASCII text. + // Protobuf binary encoded bytes. The message type is not included. + // See the specification at + // github.com/openconfig/reference/blob/master/rpc/gnmi/protobuf-vals.md + // for a complete specification. [Experimental] + bytes proto_bytes = 13; + } +} + +// Path encodes a data tree path as a series of repeated strings, with +// each element of the path representing a data tree node name and the +// associated attributes. +// Reference: gNMI Specification Section 2.2.2. +message Path { + // Elements of the path are no longer encoded as a string, but rather within + // the elem field as a PathElem message. + repeated string element = 1 [deprecated=true]; + string origin = 2; // Label to disambiguate path. + repeated PathElem elem = 3; // Elements of the path. + string target = 4; // The name of the target + // (Sec. 2.2.2.1) +} + +// PathElem encodes an element of a gNMI path, along with any attributes (keys) +// that may be associated with it. +// Reference: gNMI Specification Section 2.2.2. +message PathElem { + string name = 1; // The name of the element in the path. + map key = 2; // Map of key (attribute) name to value. +} + +// Value encodes a data tree node's value - along with the way in which +// the value is encoded. This message is deprecated by gNMI 0.3.0. +// Reference: gNMI Specification Section 2.2.3. +message Value { + option deprecated = true; + bytes value = 1; // Value of the variable being transmitted. + Encoding type = 2; // Encoding used for the value field. +} + +// Encoding defines the value encoding formats that are supported by the gNMI +// protocol. These encodings are used by both the client (when sending Set +// messages to modify the state of the target) and the target when serializing +// data to be returned to the client (in both Subscribe and Get RPCs). +// Reference: gNMI Specification Section 2.3 +enum Encoding { + JSON = 0; // JSON encoded text. + BYTES = 1; // Arbitrarily encoded bytes. + PROTO = 2; // Encoded according to scalar values of TypedValue. + ASCII = 3; // ASCII text of an out-of-band agreed format. + JSON_IETF = 4; // JSON encoded text as per RFC7951. +} + +// Error message previously utilised to return errors to the client. Deprecated +// in favour of using the google.golang.org/genproto/googleapis/rpc/status +// message in the RPC response. +// Reference: gNMI Specification Section 2.5 +message Error { + option deprecated = true; + uint32 code = 1; // Canonical gRPC error code. + string message = 2; // Human readable error. + google.protobuf.Any data = 3; // Optional additional information. +} + +// Decimal64 is used to encode a fixed precision decimal number. The value +// is expressed as a set of digits with the precision specifying the +// number of digits following the decimal point in the digit set. +message Decimal64 { + int64 digits = 1; // Set of digits. + uint32 precision = 2; // Number of digits following the decimal point. +} + +// ScalarArray is used to encode a mixed-type array of values. +message ScalarArray { + // The set of elements within the array. Each TypedValue message should + // specify only elements that have a field identifier of 1-7 (i.e., the + // values are scalar values). + repeated TypedValue element = 1; +} + +// SubscribeRequest is the message sent by the client to the target when +// initiating a subscription to a set of paths within the data tree. The +// request field must be populated and the initial message must specify a +// SubscriptionList to initiate a subscription. The message is subsequently +// used to define aliases or trigger polled data to be sent by the target. +// Reference: gNMI Specification Section 3.5.1.1 +message SubscribeRequest { + oneof request { + SubscriptionList subscribe = 1; // Specify the paths within a subscription. + Poll poll = 3; // Trigger a polled update. + AliasList aliases = 4; // Aliases to be created. + } + // Extension messages associated with the SubscribeRequest. See the + // gNMI extension specification for further definition. + repeated gnmi_ext.Extension extension = 5; +} + +// Poll is sent within a SubscribeRequest to trigger the device to +// send telemetry updates for the paths that are associated with the +// subscription. +// Reference: gNMI Specification Section Section 3.5.1.4 +message Poll { +} + +// SubscribeResponse is the message used by the target within a Subscribe RPC. +// The target includes a Notification message which is used to transmit values +// of the path(s) that are associated with the subscription. The same message +// is to indicate that the target has sent all data values once (is +// synchronized). +// Reference: gNMI Specification Section 3.5.1.4 +message SubscribeResponse { + oneof response { + Notification update = 1; // Changed or sampled value for a path. + // Indicate target has sent all values associated with the subscription + // at least once. + bool sync_response = 3; + // Deprecated in favour of google.golang.org/genproto/googleapis/rpc/status + Error error = 4 [deprecated=true]; + } + // Extension messages associated with the SubscribeResponse. See the + // gNMI extension specification for further definition. + repeated gnmi_ext.Extension extension = 5; +} + +// SubscriptionList is used within a Subscribe message to specify the list of +// paths that the client wishes to subscribe to. The message consists of a +// list of (possibly prefixed) paths, and options that relate to the +// subscription. +// Reference: gNMI Specification Section 3.5.1.2 +message SubscriptionList { + Path prefix = 1; // Prefix used for paths. + repeated Subscription subscription = 2; // Set of subscriptions to create. + // Whether target defined aliases are allowed within the subscription. + bool use_aliases = 3; + QOSMarking qos = 4; // DSCP marking to be used. + // Mode of the subscription. + enum Mode { + STREAM = 0; // Values streamed by the target (Sec. 3.5.1.5.2). + ONCE = 1; // Values sent once-off by the target (Sec. 3.5.1.5.1). + POLL = 2; // Values sent in response to a poll request (Sec. 3.5.1.5.3). + } + Mode mode = 5; + // Whether elements of the schema that are marked as eligible for aggregation + // should be aggregated or not. + bool allow_aggregation = 6; + // The set of schemas that define the elements of the data tree that should + // be sent by the target. + repeated ModelData use_models = 7; + // The encoding that the target should use within the Notifications generated + // corresponding to the SubscriptionList. + Encoding encoding = 8; + // An optional field to specify that only updates to current state should be + // sent to a client. If set, the initial state is not sent to the client but + // rather only the sync message followed by any subsequent updates to the + // current state. For ONCE and POLL modes, this causes the server to send only + // the sync message (Sec. 3.5.2.3). + bool updates_only = 9; +} + +// Subscription is a single request within a SubscriptionList. The path +// specified is interpreted (along with the prefix) as the elements of the data +// tree that the client is subscribing to. The mode determines how the target +// should trigger updates to be sent. +// Reference: gNMI Specification Section 3.5.1.3 +message Subscription { + Path path = 1; // The data tree path. + SubscriptionMode mode = 2; // Subscription mode to be used. + uint64 sample_interval = 3; // ns between samples in SAMPLE mode. + // Indicates whether values that have not changed should be sent in a SAMPLE + // subscription. + bool suppress_redundant = 4; + // Specifies the maximum allowable silent period in nanoseconds when + // suppress_redundant is in use. The target should send a value at least once + // in the period specified. + uint64 heartbeat_interval = 5; +} + +// SubscriptionMode is the mode of the subscription, specifying how the +// target must return values in a subscription. +// Reference: gNMI Specification Section 3.5.1.3 +enum SubscriptionMode { + TARGET_DEFINED = 0; // The target selects the relevant mode for each element. + ON_CHANGE = 1; // The target sends an update on element value change. + SAMPLE = 2; // The target samples values according to the interval. +} + +// QOSMarking specifies the DSCP value to be set on transmitted telemetry +// updates from the target. +// Reference: gNMI Specification Section 3.5.1.2 +message QOSMarking { + uint32 marking = 1; +} + +// Alias specifies a data tree path, and an associated string which defines an +// alias which is to be used for this path in the context of the RPC. The alias +// is specified as a string which is prefixed with "#" to disambiguate it from +// data tree element paths. +// Reference: gNMI Specification Section 2.4.2 +message Alias { + Path path = 1; // The path to be aliased. + string alias = 2; // The alias value, a string prefixed by "#". +} + +// AliasList specifies a list of aliases. It is used in a SubscribeRequest for +// a client to create a set of aliases that the target is to utilize. +// Reference: gNMI Specification Section 3.5.1.6 +message AliasList { + repeated Alias alias = 1; // The set of aliases to be created. +} + +// SetRequest is sent from a client to the target to update values in the data +// tree. Paths are either deleted by the client, or modified by means of being +// updated, or replaced. Where a replace is used, unspecified values are +// considered to be replaced, whereas when update is used the changes are +// considered to be incremental. The set of changes that are specified within +// a single SetRequest are considered to be a transaction. +// Reference: gNMI Specification Section 3.4.1 +message SetRequest { + Path prefix = 1; // Prefix used for paths in the message. + repeated Path delete = 2; // Paths to be deleted from the data tree. + repeated Update replace = 3; // Updates specifying elements to be replaced. + repeated Update update = 4; // Updates specifying elements to updated. + // Extension messages associated with the SetRequest. See the + // gNMI extension specification for further definition. + repeated gnmi_ext.Extension extension = 5; +} + +// SetResponse is the response to a SetRequest, sent from the target to the +// client. It reports the result of the modifications to the data tree that were +// specified by the client. Errors for this RPC should be reported using the +// https://github.com/googleapis/googleapis/blob/master/google/rpc/status.proto +// message in the RPC return. The gnmi.Error message can be used to add additional +// details where required. +// Reference: gNMI Specification Section 3.4.2 +message SetResponse { + Path prefix = 1; // Prefix used for paths. + // A set of responses specifying the result of the operations specified in + // the SetRequest. + repeated UpdateResult response = 2; + Error message = 3 [deprecated=true]; // The overall status of the transaction. + int64 timestamp = 4; // Timestamp of transaction (ns since epoch). + // Extension messages associated with the SetResponse. See the + // gNMI extension specification for further definition. + repeated gnmi_ext.Extension extension = 5; +} + +// UpdateResult is used within the SetResponse message to communicate the +// result of an operation specified within a SetRequest message. +// Reference: gNMI Specification Section 3.4.2 +message UpdateResult { + // The operation that was associated with the Path specified. + enum Operation { + INVALID = 0; + DELETE = 1; // The result relates to a delete of Path. + REPLACE = 2; // The result relates to a replace of Path. + UPDATE = 3; // The result relates to an update of Path. + } + // Deprecated timestamp for the UpdateResult, this field has been + // replaced by the timestamp within the SetResponse message, since + // all mutations effected by a set should be applied as a single + // transaction. + int64 timestamp = 1 [deprecated=true]; + Path path = 2; // Path associated with the update. + Error message = 3 [deprecated=true]; // Status of the update operation. + Operation op = 4; // Update operation type. +} + +// GetRequest is sent when a client initiates a Get RPC. It is used to specify +// the set of data elements for which the target should return a snapshot of +// data. The use_models field specifies the set of schema modules that are to +// be used by the target - where use_models is not specified then the target +// must use all schema models that it has. +// Reference: gNMI Specification Section 3.3.1 +message GetRequest { + Path prefix = 1; // Prefix used for paths. + repeated Path path = 2; // Paths requested by the client. + // Type of elements within the data tree. + enum DataType { + ALL = 0; // All data elements. + CONFIG = 1; // Config (rw) only elements. + STATE = 2; // State (ro) only elements. + // Data elements marked in the schema as operational. This refers to data + // elements whose value relates to the state of processes or interactions + // running on the device. + OPERATIONAL = 3; + } + DataType type = 3; // The type of data being requested. + Encoding encoding = 5; // Encoding to be used. + repeated ModelData use_models = 6; // The schema models to be used. + // Extension messages associated with the GetRequest. See the + // gNMI extension specification for further definition. + repeated gnmi_ext.Extension extension = 7; +} + +// GetResponse is used by the target to respond to a GetRequest from a client. +// The set of Notifications corresponds to the data values that are requested +// by the client in the GetRequest. +// Reference: gNMI Specification Section 3.3.2 +message GetResponse { + repeated Notification notification = 1; // Data values. + Error error = 2 [deprecated=true]; // Errors that occurred in the Get. + // Extension messages associated with the GetResponse. See the + // gNMI extension specification for further definition. + repeated gnmi_ext.Extension extension = 3; +} + +// CapabilityRequest is sent by the client in the Capabilities RPC to request +// that the target reports its capabilities. +// Reference: gNMI Specification Section 3.2.1 +message CapabilityRequest { + // Extension messages associated with the CapabilityRequest. See the + // gNMI extension specification for further definition. + repeated gnmi_ext.Extension extension = 1; +} + +// CapabilityResponse is used by the target to report its capabilities to the +// client within the Capabilities RPC. +// Reference: gNMI Specification Section 3.2.2 +message CapabilityResponse { + repeated ModelData supported_models = 1; // Supported schema models. + repeated Encoding supported_encodings = 2; // Supported encodings. + string gNMI_version = 3; // Supported gNMI version. + // Extension messages associated with the CapabilityResponse. See the + // gNMI extension specification for further definition. + repeated gnmi_ext.Extension extension = 4; +} + +// ModelData is used to describe a set of schema modules. It can be used in a +// CapabilityResponse where a target reports the set of modules that it +// supports, and within the SubscribeRequest and GetRequest messages to specify +// the set of models from which data tree elements should be reported. +// Reference: gNMI Specification Section 3.2.3 +message ModelData { + string name = 1; // Name of the model. + string organization = 2; // Organization publishing the model. + string version = 3; // Semantic version of the model. +} diff --git a/pygnmi/spec/v080/proto/gnmi_ext.proto b/pygnmi/spec/v080/proto/gnmi_ext.proto new file mode 100644 index 0000000..142fe1d --- /dev/null +++ b/pygnmi/spec/v080/proto/gnmi_ext.proto @@ -0,0 +1,91 @@ +// +// Copyright 2018 Google Inc. All Rights Reserved. +// +// 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. +// +syntax = "proto3"; + +// Package gnmi_ext defines a set of extensions messages which can be optionally +// included with the request and response messages of gNMI RPCs. A set of +// well-known extensions are defined within this file, along with a registry for +// extensions defined outside of this package. +package gnmi_ext; + +option go_package = "github.com/openconfig/gnmi/proto/gnmi_ext"; + +// The Extension message contains a single gNMI extension. +message Extension { + oneof ext { + RegisteredExtension registered_ext = 1; // A registered extension. + // Well known extensions. + MasterArbitration master_arbitration = 2; // Master arbitration extension. + History history = 3; // History extension. + } +} + +// The RegisteredExtension message defines an extension which is defined outside +// of this file. +message RegisteredExtension { + ExtensionID id = 1; // The unique ID assigned to this extension. + bytes msg = 2; // The binary-marshalled protobuf extension payload. +} + +// RegisteredExtension is an enumeration acting as a registry for extensions +// defined by external sources. +enum ExtensionID { + EID_UNSET = 0; + // New extensions are to be defined within this enumeration - their definition + // MUST link to a reference describing their implementation. + + // An experimental extension that may be used during prototyping of a new + // extension. + EID_EXPERIMENTAL = 999; +} + +// MasterArbitration is used to select the master among multiple gNMI clients +// with the same Roles. The client with the largest election_id is honored as +// the master. +// The document about gNMI master arbitration can be found at +// https://github.com/openconfig/reference/blob/master/rpc/gnmi/gnmi-master-arbitration.md +message MasterArbitration { + Role role = 1; + Uint128 election_id = 2; +} + +// Representation of unsigned 128-bit integer. +message Uint128 { + uint64 high = 1; + uint64 low = 2; +} + +// There can be one master for each role. The role is identified by its id. +message Role { + string id = 1; + // More fields can be added if needed, for example, to specify what paths the + // role can read/write. +} + +// The History extension allows clients to request historical data. Its +// spec can be found at +// https://github.com/openconfig/reference/blob/master/rpc/gnmi/gnmi-history.md +message History { + oneof request { + int64 snapshot_time = 1; // Nanoseconds since the epoch + TimeRange range = 2; + } +} + +message TimeRange { + int64 start = 1; // Nanoseconds since the epoch + int64 end = 2; // Nanoseconds since the epoch +} diff --git a/pygnmi/spec/v080/proto/target.proto b/pygnmi/spec/v080/proto/target.proto new file mode 100644 index 0000000..40d1500 --- /dev/null +++ b/pygnmi/spec/v080/proto/target.proto @@ -0,0 +1,78 @@ +// +// Copyright 2018 Google Inc. All Rights Reserved. +// +// 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. +// +syntax = "proto3"; + +// Package target contains messages for defining a configuration of a caching +// collector to connect to multiple gNMI targets. +package target; + +import "gnmi.proto"; + +option go_package = "github.com/openconfig/gnmi/proto/target"; + +// Configuration holds all information necessary for a caching gNMI collector +// to establish subscriptions to a list of gNMI targets. +message Configuration { + // Request is a keyed list of all SubscriptionRequests that can be sent + // to targets in the Configuration. + // The request must have at minimum a SubscriptionList with a prefix + // containing origin and one or more Subscriptions. Only the STREAM mode is + // supported. + map request = 1; + // Target is the full list of targets connected to by a caching gNMI + // collector. The key of the map is a unique name to identify a target and + // is set in the prefix.target of a SubscriptionRequest message when + // connecting to each respective target. + map target = 2; + // Identifier for the caching collector. + string instance_id = 3; + // Additional config metadata. + map meta = 4; + // Revision for this Configuration. Systems that non-atomically write + // configuration should populate and require revision, leveraging canonical + // protobuf serialization of fields in order. Presence of this field makes no + // guarantee. Consumers should account for atomicity constraints of their + // environment and any custom encoding. + int64 revision = 536870911; + +} + +// Target is the information necessary to establish a single gNMI Subscribe RPC +// to be collected and cached. +message Target { + // A list of address and port or name that resolves to an address and port. + repeated string addresses = 1; + // Credentials to use in metadata for authorization of the RPC + Credentials credentials = 2; + // The request to be sent to the target. The string supplied is looked up in + // the request map of the Configuration message. + string request = 3; + // Additional target metadata. + map meta = 4; + // How should the target be dialed. This option allows for a custom + // implementation for how this target is to be reached. If unset the + // collector's default implementation will be used. + string dialer = 5; +} + +// Credentials contains the fields necessary for authentication of the client to +// the target. +message Credentials { + string username = 1; + string password = 2; + // Password lookup ID. + string password_id = 3; +} diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..b1acf22 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,9 @@ +grpcio +twine +pytest +coverage +dictdiffer +pylint +flake8 +pylint +protobuf --no-binary=protobuf \ No newline at end of file diff --git a/tests/test_00_xpath.py b/tests/test_00_xpath.py index 2de5ae9..2bb0b7b 100644 --- a/tests/test_00_xpath.py +++ b/tests/test_00_xpath.py @@ -4,7 +4,7 @@ import pytest from pygnmi.path_generator import gnmi_path_generator -from pygnmi.spec.gnmi_pb2 import Path, PathElem +from pygnmi.spec.v080.gnmi_pb2 import Path, PathElem def compare_paths(actual: Path, expected: Path): From ffa17f45aac95957acbfebbe6ac63935ed5b2455 Mon Sep 17 00:00:00 2001 From: akarneliuk Date: Fri, 22 Jul 2022 15:49:24 +0100 Subject: [PATCH 2/2] 0.8.0 --- .github/workflows/ci.yaml | 2 +- README.rst | 5 + pygnmi/__init__.py | 2 +- pygnmi/spec/gnmi_ext_pb2_grpc.py | 3 - pygnmi/spec/{ => v070}/gnmi_ext_pb2.py | 0 pygnmi/spec/{ => v070}/gnmi_pb2.py | 0 pygnmi/spec/{ => v070}/gnmi_pb2_grpc.py | 0 pygnmi/spec/v080/proto/collector.proto | 32 -- pygnmi/spec/v080/proto/gnmi.proto | 458 ------------------- pygnmi/spec/v080/proto/gnmi_ext.proto | 91 ---- pygnmi/spec/v080/proto/target.proto | 78 ---- requirements-dev.txt => requirements-new.txt | 1 - requirements.txt => requirements-old.txt | 0 setup.py | 6 +- 14 files changed, 10 insertions(+), 668 deletions(-) delete mode 100644 pygnmi/spec/gnmi_ext_pb2_grpc.py rename pygnmi/spec/{ => v070}/gnmi_ext_pb2.py (100%) rename pygnmi/spec/{ => v070}/gnmi_pb2.py (100%) rename pygnmi/spec/{ => v070}/gnmi_pb2_grpc.py (100%) delete mode 100644 pygnmi/spec/v080/proto/collector.proto delete mode 100644 pygnmi/spec/v080/proto/gnmi.proto delete mode 100644 pygnmi/spec/v080/proto/gnmi_ext.proto delete mode 100644 pygnmi/spec/v080/proto/target.proto rename requirements-dev.txt => requirements-new.txt (92%) rename requirements.txt => requirements-old.txt (100%) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 8b51d14..616bfb6 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -31,7 +31,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install -r requirements.txt + pip install -r requirements-new.txt - name: Perform linting validation continue-on-error: true diff --git a/README.rst b/README.rst index 0aabaae..eefcdbe 100644 --- a/README.rst +++ b/README.rst @@ -84,6 +84,11 @@ Contributors Dev Log ======= +Release **0.8.0**: + +- **Important**: potentially breaking change. The dependency is moved from ``grpcio-tools`` to ``protobuf``, which as a standalone package has a much newer serion. +- Spec is rebuilt and updated to support gNMI of version ``0.8.0``. + Release **0.7.5**: - Amended the logic of ``ONCE`` telemetry mode to automatically terminate on receiving ``{"sync_response": True}`` message. diff --git a/pygnmi/__init__.py b/pygnmi/__init__.py index a8af67d..e48f68d 100644 --- a/pygnmi/__init__.py +++ b/pygnmi/__init__.py @@ -2,4 +2,4 @@ pyGNMI module to manage network devices with gNMI (c)2020-2022, Karneliuk """ -__version__ = "0.7.6" +__version__ = "0.8.0" diff --git a/pygnmi/spec/gnmi_ext_pb2_grpc.py b/pygnmi/spec/gnmi_ext_pb2_grpc.py deleted file mode 100644 index a894352..0000000 --- a/pygnmi/spec/gnmi_ext_pb2_grpc.py +++ /dev/null @@ -1,3 +0,0 @@ -# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! -import grpc - diff --git a/pygnmi/spec/gnmi_ext_pb2.py b/pygnmi/spec/v070/gnmi_ext_pb2.py similarity index 100% rename from pygnmi/spec/gnmi_ext_pb2.py rename to pygnmi/spec/v070/gnmi_ext_pb2.py diff --git a/pygnmi/spec/gnmi_pb2.py b/pygnmi/spec/v070/gnmi_pb2.py similarity index 100% rename from pygnmi/spec/gnmi_pb2.py rename to pygnmi/spec/v070/gnmi_pb2.py diff --git a/pygnmi/spec/gnmi_pb2_grpc.py b/pygnmi/spec/v070/gnmi_pb2_grpc.py similarity index 100% rename from pygnmi/spec/gnmi_pb2_grpc.py rename to pygnmi/spec/v070/gnmi_pb2_grpc.py diff --git a/pygnmi/spec/v080/proto/collector.proto b/pygnmi/spec/v080/proto/collector.proto deleted file mode 100644 index db2c195..0000000 --- a/pygnmi/spec/v080/proto/collector.proto +++ /dev/null @@ -1,32 +0,0 @@ -// -// Copyright 2020 Google Inc. All Rights Reserved. -// -// 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. -// -syntax = "proto3"; - -package gnmi; - -option go_package = "github.com/openconfig/gnmi/proto/collector;gnmi"; - -service Collector { - // Reconnect requests that the existing connections for one or more specified - // targets will be stopped and new connections established. - rpc Reconnect(ReconnectRequest) returns (Nil) {} -} - -message ReconnectRequest { - repeated string target = 1; // List of targets to reconnect. -} - -message Nil{} diff --git a/pygnmi/spec/v080/proto/gnmi.proto b/pygnmi/spec/v080/proto/gnmi.proto deleted file mode 100644 index b15e85e..0000000 --- a/pygnmi/spec/v080/proto/gnmi.proto +++ /dev/null @@ -1,458 +0,0 @@ -// -// Copyright 2016 Google Inc. All Rights Reserved. -// -// 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. -// -syntax = "proto3"; - -import "google/protobuf/any.proto"; -import "google/protobuf/descriptor.proto"; -import "gnmi_ext.proto"; - -// Package gNMI defines a service specification for the gRPC Network Management -// Interface. This interface is defined to be a standard interface via which -// a network management system ("client") can subscribe to state values, -// retrieve snapshots of state information, and manipulate the state of a data -// tree supported by a device ("target"). -// -// This document references the gNMI Specification which can be found at -// http://github.com/openconfig/reference/blob/master/rpc/gnmi -package gnmi; - -// Define a protobuf FileOption that defines the gNMI service version. -//extend google.protobuf.FileOptions { - // The gNMI service semantic version. -// string gnmi_service = 1001; -//} - -// gNMI_service is the current version of the gNMI service, returned through -// the Capabilities RPC. -// option (gnmi_service) = "0.8.0"; - - -service gNMI { - // Capabilities allows the client to retrieve the set of capabilities that - // is supported by the target. This allows the target to validate the - // service version that is implemented and retrieve the set of models that - // the target supports. The models can then be specified in subsequent RPCs - // to restrict the set of data that is utilized. - // Reference: gNMI Specification Section 3.2 - rpc Capabilities(CapabilityRequest) returns (CapabilityResponse); - // Retrieve a snapshot of data from the target. A Get RPC requests that the - // target snapshots a subset of the data tree as specified by the paths - // included in the message and serializes this to be returned to the - // client using the specified encoding. - // Reference: gNMI Specification Section 3.3 - rpc Get(GetRequest) returns (GetResponse); - // Set allows the client to modify the state of data on the target. The - // paths to modified along with the new values that the client wishes - // to set the value to. - // Reference: gNMI Specification Section 3.4 - rpc Set(SetRequest) returns (SetResponse); - // Subscribe allows a client to request the target to send it values - // of particular paths within the data tree. These values may be streamed - // at a particular cadence (STREAM), sent one off on a long-lived channel - // (POLL), or sent as a one-off retrieval (ONCE). - // Reference: gNMI Specification Section 3.5 - rpc Subscribe(stream SubscribeRequest) returns (stream SubscribeResponse); -} - -// Notification is a re-usable message that is used to encode data from the -// target to the client. A Notification carries two types of changes to the data -// tree: -// - Deleted values (delete) - a set of paths that have been removed from the -// data tree. -// - Updated values (update) - a set of path-value pairs indicating the path -// whose value has changed in the data tree. -// Reference: gNMI Specification Section 2.1 -message Notification { - int64 timestamp = 1; // Timestamp in nanoseconds since Epoch. - Path prefix = 2; // Prefix used for paths in the message. - // An alias for the path specified in the prefix field. - // Reference: gNMI Specification Section 2.4.2 - string alias = 3; - repeated Update update = 4; // Data elements that have changed values. - repeated Path delete = 5; // Data elements that have been deleted. - // This notification contains a set of paths that are always updated together - // referenced by a globally unique prefix. - bool atomic = 6; -} - -// Update is a re-usable message that is used to store a particular Path, -// Value pair. -// Reference: gNMI Specification Section 2.1 -message Update { - Path path = 1; // The path (key) for the update. - Value value = 2 [deprecated=true]; // The value (value) for the update. - TypedValue val = 3; // The explicitly typed update value. - uint32 duplicates = 4; // Number of coalesced duplicates. -} - -// TypedValue is used to encode a value being sent between the client and -// target (originated by either entity). -message TypedValue { - // One of the fields within the val oneof is populated with the value - // of the update. The type of the value being included in the Update - // determines which field should be populated. In the case that the - // encoding is a particular form of the base protobuf type, a specific - // field is used to store the value (e.g., json_val). - oneof value { - string string_val = 1; // String value. - int64 int_val = 2; // Integer value. - uint64 uint_val = 3; // Unsigned integer value. - bool bool_val = 4; // Bool value. - bytes bytes_val = 5; // Arbitrary byte sequence value. - float float_val = 6 [deprecated=true]; // Deprecated - use double_val. - double double_val = 14; // Floating point value. - Decimal64 decimal_val = 7 [deprecated=true]; // Deprecated - use double_val. - ScalarArray leaflist_val = 8; // Mixed type scalar array value. - google.protobuf.Any any_val = 9; // protobuf.Any encoded bytes. - bytes json_val = 10; // JSON-encoded text. - bytes json_ietf_val = 11; // JSON-encoded text per RFC7951. - string ascii_val = 12; // Arbitrary ASCII text. - // Protobuf binary encoded bytes. The message type is not included. - // See the specification at - // github.com/openconfig/reference/blob/master/rpc/gnmi/protobuf-vals.md - // for a complete specification. [Experimental] - bytes proto_bytes = 13; - } -} - -// Path encodes a data tree path as a series of repeated strings, with -// each element of the path representing a data tree node name and the -// associated attributes. -// Reference: gNMI Specification Section 2.2.2. -message Path { - // Elements of the path are no longer encoded as a string, but rather within - // the elem field as a PathElem message. - repeated string element = 1 [deprecated=true]; - string origin = 2; // Label to disambiguate path. - repeated PathElem elem = 3; // Elements of the path. - string target = 4; // The name of the target - // (Sec. 2.2.2.1) -} - -// PathElem encodes an element of a gNMI path, along with any attributes (keys) -// that may be associated with it. -// Reference: gNMI Specification Section 2.2.2. -message PathElem { - string name = 1; // The name of the element in the path. - map key = 2; // Map of key (attribute) name to value. -} - -// Value encodes a data tree node's value - along with the way in which -// the value is encoded. This message is deprecated by gNMI 0.3.0. -// Reference: gNMI Specification Section 2.2.3. -message Value { - option deprecated = true; - bytes value = 1; // Value of the variable being transmitted. - Encoding type = 2; // Encoding used for the value field. -} - -// Encoding defines the value encoding formats that are supported by the gNMI -// protocol. These encodings are used by both the client (when sending Set -// messages to modify the state of the target) and the target when serializing -// data to be returned to the client (in both Subscribe and Get RPCs). -// Reference: gNMI Specification Section 2.3 -enum Encoding { - JSON = 0; // JSON encoded text. - BYTES = 1; // Arbitrarily encoded bytes. - PROTO = 2; // Encoded according to scalar values of TypedValue. - ASCII = 3; // ASCII text of an out-of-band agreed format. - JSON_IETF = 4; // JSON encoded text as per RFC7951. -} - -// Error message previously utilised to return errors to the client. Deprecated -// in favour of using the google.golang.org/genproto/googleapis/rpc/status -// message in the RPC response. -// Reference: gNMI Specification Section 2.5 -message Error { - option deprecated = true; - uint32 code = 1; // Canonical gRPC error code. - string message = 2; // Human readable error. - google.protobuf.Any data = 3; // Optional additional information. -} - -// Decimal64 is used to encode a fixed precision decimal number. The value -// is expressed as a set of digits with the precision specifying the -// number of digits following the decimal point in the digit set. -message Decimal64 { - int64 digits = 1; // Set of digits. - uint32 precision = 2; // Number of digits following the decimal point. -} - -// ScalarArray is used to encode a mixed-type array of values. -message ScalarArray { - // The set of elements within the array. Each TypedValue message should - // specify only elements that have a field identifier of 1-7 (i.e., the - // values are scalar values). - repeated TypedValue element = 1; -} - -// SubscribeRequest is the message sent by the client to the target when -// initiating a subscription to a set of paths within the data tree. The -// request field must be populated and the initial message must specify a -// SubscriptionList to initiate a subscription. The message is subsequently -// used to define aliases or trigger polled data to be sent by the target. -// Reference: gNMI Specification Section 3.5.1.1 -message SubscribeRequest { - oneof request { - SubscriptionList subscribe = 1; // Specify the paths within a subscription. - Poll poll = 3; // Trigger a polled update. - AliasList aliases = 4; // Aliases to be created. - } - // Extension messages associated with the SubscribeRequest. See the - // gNMI extension specification for further definition. - repeated gnmi_ext.Extension extension = 5; -} - -// Poll is sent within a SubscribeRequest to trigger the device to -// send telemetry updates for the paths that are associated with the -// subscription. -// Reference: gNMI Specification Section Section 3.5.1.4 -message Poll { -} - -// SubscribeResponse is the message used by the target within a Subscribe RPC. -// The target includes a Notification message which is used to transmit values -// of the path(s) that are associated with the subscription. The same message -// is to indicate that the target has sent all data values once (is -// synchronized). -// Reference: gNMI Specification Section 3.5.1.4 -message SubscribeResponse { - oneof response { - Notification update = 1; // Changed or sampled value for a path. - // Indicate target has sent all values associated with the subscription - // at least once. - bool sync_response = 3; - // Deprecated in favour of google.golang.org/genproto/googleapis/rpc/status - Error error = 4 [deprecated=true]; - } - // Extension messages associated with the SubscribeResponse. See the - // gNMI extension specification for further definition. - repeated gnmi_ext.Extension extension = 5; -} - -// SubscriptionList is used within a Subscribe message to specify the list of -// paths that the client wishes to subscribe to. The message consists of a -// list of (possibly prefixed) paths, and options that relate to the -// subscription. -// Reference: gNMI Specification Section 3.5.1.2 -message SubscriptionList { - Path prefix = 1; // Prefix used for paths. - repeated Subscription subscription = 2; // Set of subscriptions to create. - // Whether target defined aliases are allowed within the subscription. - bool use_aliases = 3; - QOSMarking qos = 4; // DSCP marking to be used. - // Mode of the subscription. - enum Mode { - STREAM = 0; // Values streamed by the target (Sec. 3.5.1.5.2). - ONCE = 1; // Values sent once-off by the target (Sec. 3.5.1.5.1). - POLL = 2; // Values sent in response to a poll request (Sec. 3.5.1.5.3). - } - Mode mode = 5; - // Whether elements of the schema that are marked as eligible for aggregation - // should be aggregated or not. - bool allow_aggregation = 6; - // The set of schemas that define the elements of the data tree that should - // be sent by the target. - repeated ModelData use_models = 7; - // The encoding that the target should use within the Notifications generated - // corresponding to the SubscriptionList. - Encoding encoding = 8; - // An optional field to specify that only updates to current state should be - // sent to a client. If set, the initial state is not sent to the client but - // rather only the sync message followed by any subsequent updates to the - // current state. For ONCE and POLL modes, this causes the server to send only - // the sync message (Sec. 3.5.2.3). - bool updates_only = 9; -} - -// Subscription is a single request within a SubscriptionList. The path -// specified is interpreted (along with the prefix) as the elements of the data -// tree that the client is subscribing to. The mode determines how the target -// should trigger updates to be sent. -// Reference: gNMI Specification Section 3.5.1.3 -message Subscription { - Path path = 1; // The data tree path. - SubscriptionMode mode = 2; // Subscription mode to be used. - uint64 sample_interval = 3; // ns between samples in SAMPLE mode. - // Indicates whether values that have not changed should be sent in a SAMPLE - // subscription. - bool suppress_redundant = 4; - // Specifies the maximum allowable silent period in nanoseconds when - // suppress_redundant is in use. The target should send a value at least once - // in the period specified. - uint64 heartbeat_interval = 5; -} - -// SubscriptionMode is the mode of the subscription, specifying how the -// target must return values in a subscription. -// Reference: gNMI Specification Section 3.5.1.3 -enum SubscriptionMode { - TARGET_DEFINED = 0; // The target selects the relevant mode for each element. - ON_CHANGE = 1; // The target sends an update on element value change. - SAMPLE = 2; // The target samples values according to the interval. -} - -// QOSMarking specifies the DSCP value to be set on transmitted telemetry -// updates from the target. -// Reference: gNMI Specification Section 3.5.1.2 -message QOSMarking { - uint32 marking = 1; -} - -// Alias specifies a data tree path, and an associated string which defines an -// alias which is to be used for this path in the context of the RPC. The alias -// is specified as a string which is prefixed with "#" to disambiguate it from -// data tree element paths. -// Reference: gNMI Specification Section 2.4.2 -message Alias { - Path path = 1; // The path to be aliased. - string alias = 2; // The alias value, a string prefixed by "#". -} - -// AliasList specifies a list of aliases. It is used in a SubscribeRequest for -// a client to create a set of aliases that the target is to utilize. -// Reference: gNMI Specification Section 3.5.1.6 -message AliasList { - repeated Alias alias = 1; // The set of aliases to be created. -} - -// SetRequest is sent from a client to the target to update values in the data -// tree. Paths are either deleted by the client, or modified by means of being -// updated, or replaced. Where a replace is used, unspecified values are -// considered to be replaced, whereas when update is used the changes are -// considered to be incremental. The set of changes that are specified within -// a single SetRequest are considered to be a transaction. -// Reference: gNMI Specification Section 3.4.1 -message SetRequest { - Path prefix = 1; // Prefix used for paths in the message. - repeated Path delete = 2; // Paths to be deleted from the data tree. - repeated Update replace = 3; // Updates specifying elements to be replaced. - repeated Update update = 4; // Updates specifying elements to updated. - // Extension messages associated with the SetRequest. See the - // gNMI extension specification for further definition. - repeated gnmi_ext.Extension extension = 5; -} - -// SetResponse is the response to a SetRequest, sent from the target to the -// client. It reports the result of the modifications to the data tree that were -// specified by the client. Errors for this RPC should be reported using the -// https://github.com/googleapis/googleapis/blob/master/google/rpc/status.proto -// message in the RPC return. The gnmi.Error message can be used to add additional -// details where required. -// Reference: gNMI Specification Section 3.4.2 -message SetResponse { - Path prefix = 1; // Prefix used for paths. - // A set of responses specifying the result of the operations specified in - // the SetRequest. - repeated UpdateResult response = 2; - Error message = 3 [deprecated=true]; // The overall status of the transaction. - int64 timestamp = 4; // Timestamp of transaction (ns since epoch). - // Extension messages associated with the SetResponse. See the - // gNMI extension specification for further definition. - repeated gnmi_ext.Extension extension = 5; -} - -// UpdateResult is used within the SetResponse message to communicate the -// result of an operation specified within a SetRequest message. -// Reference: gNMI Specification Section 3.4.2 -message UpdateResult { - // The operation that was associated with the Path specified. - enum Operation { - INVALID = 0; - DELETE = 1; // The result relates to a delete of Path. - REPLACE = 2; // The result relates to a replace of Path. - UPDATE = 3; // The result relates to an update of Path. - } - // Deprecated timestamp for the UpdateResult, this field has been - // replaced by the timestamp within the SetResponse message, since - // all mutations effected by a set should be applied as a single - // transaction. - int64 timestamp = 1 [deprecated=true]; - Path path = 2; // Path associated with the update. - Error message = 3 [deprecated=true]; // Status of the update operation. - Operation op = 4; // Update operation type. -} - -// GetRequest is sent when a client initiates a Get RPC. It is used to specify -// the set of data elements for which the target should return a snapshot of -// data. The use_models field specifies the set of schema modules that are to -// be used by the target - where use_models is not specified then the target -// must use all schema models that it has. -// Reference: gNMI Specification Section 3.3.1 -message GetRequest { - Path prefix = 1; // Prefix used for paths. - repeated Path path = 2; // Paths requested by the client. - // Type of elements within the data tree. - enum DataType { - ALL = 0; // All data elements. - CONFIG = 1; // Config (rw) only elements. - STATE = 2; // State (ro) only elements. - // Data elements marked in the schema as operational. This refers to data - // elements whose value relates to the state of processes or interactions - // running on the device. - OPERATIONAL = 3; - } - DataType type = 3; // The type of data being requested. - Encoding encoding = 5; // Encoding to be used. - repeated ModelData use_models = 6; // The schema models to be used. - // Extension messages associated with the GetRequest. See the - // gNMI extension specification for further definition. - repeated gnmi_ext.Extension extension = 7; -} - -// GetResponse is used by the target to respond to a GetRequest from a client. -// The set of Notifications corresponds to the data values that are requested -// by the client in the GetRequest. -// Reference: gNMI Specification Section 3.3.2 -message GetResponse { - repeated Notification notification = 1; // Data values. - Error error = 2 [deprecated=true]; // Errors that occurred in the Get. - // Extension messages associated with the GetResponse. See the - // gNMI extension specification for further definition. - repeated gnmi_ext.Extension extension = 3; -} - -// CapabilityRequest is sent by the client in the Capabilities RPC to request -// that the target reports its capabilities. -// Reference: gNMI Specification Section 3.2.1 -message CapabilityRequest { - // Extension messages associated with the CapabilityRequest. See the - // gNMI extension specification for further definition. - repeated gnmi_ext.Extension extension = 1; -} - -// CapabilityResponse is used by the target to report its capabilities to the -// client within the Capabilities RPC. -// Reference: gNMI Specification Section 3.2.2 -message CapabilityResponse { - repeated ModelData supported_models = 1; // Supported schema models. - repeated Encoding supported_encodings = 2; // Supported encodings. - string gNMI_version = 3; // Supported gNMI version. - // Extension messages associated with the CapabilityResponse. See the - // gNMI extension specification for further definition. - repeated gnmi_ext.Extension extension = 4; -} - -// ModelData is used to describe a set of schema modules. It can be used in a -// CapabilityResponse where a target reports the set of modules that it -// supports, and within the SubscribeRequest and GetRequest messages to specify -// the set of models from which data tree elements should be reported. -// Reference: gNMI Specification Section 3.2.3 -message ModelData { - string name = 1; // Name of the model. - string organization = 2; // Organization publishing the model. - string version = 3; // Semantic version of the model. -} diff --git a/pygnmi/spec/v080/proto/gnmi_ext.proto b/pygnmi/spec/v080/proto/gnmi_ext.proto deleted file mode 100644 index 142fe1d..0000000 --- a/pygnmi/spec/v080/proto/gnmi_ext.proto +++ /dev/null @@ -1,91 +0,0 @@ -// -// Copyright 2018 Google Inc. All Rights Reserved. -// -// 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. -// -syntax = "proto3"; - -// Package gnmi_ext defines a set of extensions messages which can be optionally -// included with the request and response messages of gNMI RPCs. A set of -// well-known extensions are defined within this file, along with a registry for -// extensions defined outside of this package. -package gnmi_ext; - -option go_package = "github.com/openconfig/gnmi/proto/gnmi_ext"; - -// The Extension message contains a single gNMI extension. -message Extension { - oneof ext { - RegisteredExtension registered_ext = 1; // A registered extension. - // Well known extensions. - MasterArbitration master_arbitration = 2; // Master arbitration extension. - History history = 3; // History extension. - } -} - -// The RegisteredExtension message defines an extension which is defined outside -// of this file. -message RegisteredExtension { - ExtensionID id = 1; // The unique ID assigned to this extension. - bytes msg = 2; // The binary-marshalled protobuf extension payload. -} - -// RegisteredExtension is an enumeration acting as a registry for extensions -// defined by external sources. -enum ExtensionID { - EID_UNSET = 0; - // New extensions are to be defined within this enumeration - their definition - // MUST link to a reference describing their implementation. - - // An experimental extension that may be used during prototyping of a new - // extension. - EID_EXPERIMENTAL = 999; -} - -// MasterArbitration is used to select the master among multiple gNMI clients -// with the same Roles. The client with the largest election_id is honored as -// the master. -// The document about gNMI master arbitration can be found at -// https://github.com/openconfig/reference/blob/master/rpc/gnmi/gnmi-master-arbitration.md -message MasterArbitration { - Role role = 1; - Uint128 election_id = 2; -} - -// Representation of unsigned 128-bit integer. -message Uint128 { - uint64 high = 1; - uint64 low = 2; -} - -// There can be one master for each role. The role is identified by its id. -message Role { - string id = 1; - // More fields can be added if needed, for example, to specify what paths the - // role can read/write. -} - -// The History extension allows clients to request historical data. Its -// spec can be found at -// https://github.com/openconfig/reference/blob/master/rpc/gnmi/gnmi-history.md -message History { - oneof request { - int64 snapshot_time = 1; // Nanoseconds since the epoch - TimeRange range = 2; - } -} - -message TimeRange { - int64 start = 1; // Nanoseconds since the epoch - int64 end = 2; // Nanoseconds since the epoch -} diff --git a/pygnmi/spec/v080/proto/target.proto b/pygnmi/spec/v080/proto/target.proto deleted file mode 100644 index 40d1500..0000000 --- a/pygnmi/spec/v080/proto/target.proto +++ /dev/null @@ -1,78 +0,0 @@ -// -// Copyright 2018 Google Inc. All Rights Reserved. -// -// 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. -// -syntax = "proto3"; - -// Package target contains messages for defining a configuration of a caching -// collector to connect to multiple gNMI targets. -package target; - -import "gnmi.proto"; - -option go_package = "github.com/openconfig/gnmi/proto/target"; - -// Configuration holds all information necessary for a caching gNMI collector -// to establish subscriptions to a list of gNMI targets. -message Configuration { - // Request is a keyed list of all SubscriptionRequests that can be sent - // to targets in the Configuration. - // The request must have at minimum a SubscriptionList with a prefix - // containing origin and one or more Subscriptions. Only the STREAM mode is - // supported. - map request = 1; - // Target is the full list of targets connected to by a caching gNMI - // collector. The key of the map is a unique name to identify a target and - // is set in the prefix.target of a SubscriptionRequest message when - // connecting to each respective target. - map target = 2; - // Identifier for the caching collector. - string instance_id = 3; - // Additional config metadata. - map meta = 4; - // Revision for this Configuration. Systems that non-atomically write - // configuration should populate and require revision, leveraging canonical - // protobuf serialization of fields in order. Presence of this field makes no - // guarantee. Consumers should account for atomicity constraints of their - // environment and any custom encoding. - int64 revision = 536870911; - -} - -// Target is the information necessary to establish a single gNMI Subscribe RPC -// to be collected and cached. -message Target { - // A list of address and port or name that resolves to an address and port. - repeated string addresses = 1; - // Credentials to use in metadata for authorization of the RPC - Credentials credentials = 2; - // The request to be sent to the target. The string supplied is looked up in - // the request map of the Configuration message. - string request = 3; - // Additional target metadata. - map meta = 4; - // How should the target be dialed. This option allows for a custom - // implementation for how this target is to be reached. If unset the - // collector's default implementation will be used. - string dialer = 5; -} - -// Credentials contains the fields necessary for authentication of the client to -// the target. -message Credentials { - string username = 1; - string password = 2; - // Password lookup ID. - string password_id = 3; -} diff --git a/requirements-dev.txt b/requirements-new.txt similarity index 92% rename from requirements-dev.txt rename to requirements-new.txt index b1acf22..3ede7b2 100644 --- a/requirements-dev.txt +++ b/requirements-new.txt @@ -5,5 +5,4 @@ coverage dictdiffer pylint flake8 -pylint protobuf --no-binary=protobuf \ No newline at end of file diff --git a/requirements.txt b/requirements-old.txt similarity index 100% rename from requirements.txt rename to requirements-old.txt diff --git a/setup.py b/setup.py index ad9f6f8..cc8582d 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setup( name='pygnmi', packages=['pygnmi', 'pygnmi.spec', 'pygnmi.artefacts'], - version='0.7.5', + version='0.8.0', license='bsd-3-clause', description='Pure Python gNMI client to manage network functions and collect telemetry.', long_description=long_description, @@ -14,11 +14,11 @@ author='Anton Karneliuk', author_email='anton@karneliuk.com', url='https://github.com/akarneliuk/pygnmi', - download_url='https://github.com/akarneliuk/pygnmi/archive/v0.7.5.tar.gz', + download_url='https://github.com/akarneliuk/pygnmi/archive/v0.8.0.tar.gz', keywords=['gnmi', 'automation', 'grpc', 'network'], install_requires=[ 'grpcio', - 'grpcio-tools', + 'protobuf --no-binary=protobuf', 'cryptography', 'dictdiffer' ],