Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • danet/gosdn
1 result
Select Git revision
Show changes
Commits on Source (3)
Showing
with 26 additions and 7194 deletions
// openconfig.enums is generated by proto_generator as a protobuf
// representation of a YANG schema.
//
// Input schema modules:
// - ../yang-models/models/openconfig/release/models/interfaces/openconfig-interfaces.yang
// Include paths:
// - ../yang-models/models/...
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.25.0-devel
// protoc v3.13.0
// source: openconfig/enums/enums.proto
package gosdn
import (
proto "github.com/golang/protobuf/proto"
_ "github.com/openconfig/ygot/proto/yext"
_ "github.com/openconfig/ygot/proto/ywrapper"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
// IETFInterfacesInterfaceType represents an enumerated type generated for the YANG identity interface-type.
type IETFInterfacesInterfaceType int32
const (
IETFInterfacesInterfaceType_IETFINTERFACESINTERFACETYPE_UNSET IETFInterfacesInterfaceType = 0
)
// Enum value maps for IETFInterfacesInterfaceType.
var (
IETFInterfacesInterfaceType_name = map[int32]string{
0: "IETFINTERFACESINTERFACETYPE_UNSET",
}
IETFInterfacesInterfaceType_value = map[string]int32{
"IETFINTERFACESINTERFACETYPE_UNSET": 0,
}
)
func (x IETFInterfacesInterfaceType) Enum() *IETFInterfacesInterfaceType {
p := new(IETFInterfacesInterfaceType)
*p = x
return p
}
func (x IETFInterfacesInterfaceType) String() string {
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (IETFInterfacesInterfaceType) Descriptor() protoreflect.EnumDescriptor {
return file_openconfig_enums_enums_proto_enumTypes[0].Descriptor()
}
func (IETFInterfacesInterfaceType) Type() protoreflect.EnumType {
return &file_openconfig_enums_enums_proto_enumTypes[0]
}
func (x IETFInterfacesInterfaceType) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use IETFInterfacesInterfaceType.Descriptor instead.
func (IETFInterfacesInterfaceType) EnumDescriptor() ([]byte, []int) {
return file_openconfig_enums_enums_proto_rawDescGZIP(), []int{0}
}
var File_openconfig_enums_enums_proto protoreflect.FileDescriptor
var file_openconfig_enums_enums_proto_rawDesc = []byte{
0x0a, 0x1c, 0x6f, 0x70, 0x65, 0x6e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x65, 0x6e, 0x75,
0x6d, 0x73, 0x2f, 0x65, 0x6e, 0x75, 0x6d, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x10,
0x6f, 0x70, 0x65, 0x6e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x75, 0x6d, 0x73,
0x1a, 0x38, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x70, 0x65,
0x6e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x79, 0x67, 0x6f, 0x74, 0x2f, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x2f, 0x79, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x2f, 0x79, 0x77, 0x72, 0x61,
0x70, 0x70, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x30, 0x67, 0x69, 0x74, 0x68,
0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x70, 0x65, 0x6e, 0x63, 0x6f, 0x6e, 0x66, 0x69,
0x67, 0x2f, 0x79, 0x67, 0x6f, 0x74, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x79, 0x65, 0x78,
0x74, 0x2f, 0x79, 0x65, 0x78, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2a, 0x44, 0x0a, 0x1b,
0x49, 0x45, 0x54, 0x46, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x73, 0x49, 0x6e,
0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x25, 0x0a, 0x21, 0x49,
0x45, 0x54, 0x46, 0x49, 0x4e, 0x54, 0x45, 0x52, 0x46, 0x41, 0x43, 0x45, 0x53, 0x49, 0x4e, 0x54,
0x45, 0x52, 0x46, 0x41, 0x43, 0x45, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x45, 0x54,
0x10, 0x00, 0x42, 0x20, 0x5a, 0x1e, 0x67, 0x69, 0x74, 0x6c, 0x61, 0x62, 0x2e, 0x66, 0x62, 0x69,
0x2e, 0x68, 0x2d, 0x64, 0x61, 0x2e, 0x64, 0x65, 0x2f, 0x63, 0x6f, 0x63, 0x73, 0x6e, 0x2f, 0x67,
0x6f, 0x73, 0x64, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_openconfig_enums_enums_proto_rawDescOnce sync.Once
file_openconfig_enums_enums_proto_rawDescData = file_openconfig_enums_enums_proto_rawDesc
)
func file_openconfig_enums_enums_proto_rawDescGZIP() []byte {
file_openconfig_enums_enums_proto_rawDescOnce.Do(func() {
file_openconfig_enums_enums_proto_rawDescData = protoimpl.X.CompressGZIP(file_openconfig_enums_enums_proto_rawDescData)
})
return file_openconfig_enums_enums_proto_rawDescData
}
var file_openconfig_enums_enums_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_openconfig_enums_enums_proto_goTypes = []interface{}{
(IETFInterfacesInterfaceType)(0), // 0: openconfig.enums.IETFInterfacesInterfaceType
}
var file_openconfig_enums_enums_proto_depIdxs = []int32{
0, // [0:0] is the sub-list for method output_type
0, // [0:0] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
}
func init() { file_openconfig_enums_enums_proto_init() }
func file_openconfig_enums_enums_proto_init() {
if File_openconfig_enums_enums_proto != nil {
return
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_openconfig_enums_enums_proto_rawDesc,
NumEnums: 1,
NumMessages: 0,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_openconfig_enums_enums_proto_goTypes,
DependencyIndexes: file_openconfig_enums_enums_proto_depIdxs,
EnumInfos: file_openconfig_enums_enums_proto_enumTypes,
}.Build()
File_openconfig_enums_enums_proto = out.File
file_openconfig_enums_enums_proto_rawDesc = nil
file_openconfig_enums_enums_proto_goTypes = nil
file_openconfig_enums_enums_proto_depIdxs = nil
}
// openconfig is generated by proto_generator as a protobuf
// representation of a YANG schema.
//
// Input schema modules:
// - ../yang-models/models/openconfig/release/models/interfaces/openconfig-interfaces.yang
// Include paths:
// - ../yang-models/models/...
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.25.0-devel
// protoc v3.13.0
// source: openconfig/openconfig.proto
package gosdn
import (
proto "github.com/golang/protobuf/proto"
_ "github.com/openconfig/ygot/proto/yext"
_ "github.com/openconfig/ygot/proto/ywrapper"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
type Device struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Interfaces *Interfaces `protobuf:"bytes,85031486,opt,name=interfaces,proto3" json:"interfaces,omitempty"`
}
func (x *Device) Reset() {
*x = Device{}
if protoimpl.UnsafeEnabled {
mi := &file_openconfig_openconfig_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Device) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Device) ProtoMessage() {}
func (x *Device) ProtoReflect() protoreflect.Message {
mi := &file_openconfig_openconfig_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Device.ProtoReflect.Descriptor instead.
func (*Device) Descriptor() ([]byte, []int) {
return file_openconfig_openconfig_proto_rawDescGZIP(), []int{0}
}
func (x *Device) GetInterfaces() *Interfaces {
if x != nil {
return x.Interfaces
}
return nil
}
var File_openconfig_openconfig_proto protoreflect.FileDescriptor
var file_openconfig_openconfig_proto_rawDesc = []byte{
0x0a, 0x1b, 0x6f, 0x70, 0x65, 0x6e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x6f, 0x70, 0x65,
0x6e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0a, 0x6f,
0x70, 0x65, 0x6e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x1a, 0x38, 0x67, 0x69, 0x74, 0x68, 0x75,
0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x70, 0x65, 0x6e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67,
0x2f, 0x79, 0x67, 0x6f, 0x74, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x79, 0x77, 0x72, 0x61,
0x70, 0x70, 0x65, 0x72, 0x2f, 0x79, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x1a, 0x30, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f,
0x6f, 0x70, 0x65, 0x6e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x79, 0x67, 0x6f, 0x74, 0x2f,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x79, 0x65, 0x78, 0x74, 0x2f, 0x79, 0x65, 0x78, 0x74, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x3c, 0x6f, 0x70, 0x65, 0x6e, 0x63, 0x6f, 0x6e, 0x66, 0x69,
0x67, 0x2f, 0x6f, 0x70, 0x65, 0x6e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x69, 0x6e, 0x74,
0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x73, 0x2f, 0x6f, 0x70, 0x65, 0x6e, 0x63, 0x6f, 0x6e, 0x66,
0x69, 0x67, 0x5f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x73, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x22, 0x69, 0x0a, 0x06, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x12, 0x5f, 0x0a,
0x0a, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x73, 0x18, 0xbe, 0xf4, 0xc5, 0x28,
0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x63, 0x6f, 0x6e, 0x66, 0x69,
0x67, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x69, 0x6e, 0x74,
0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x73, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63,
0x65, 0x73, 0x42, 0x0e, 0x82, 0x41, 0x0b, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63,
0x65, 0x73, 0x52, 0x0a, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x73, 0x42, 0x20,
0x5a, 0x1e, 0x67, 0x69, 0x74, 0x6c, 0x61, 0x62, 0x2e, 0x66, 0x62, 0x69, 0x2e, 0x68, 0x2d, 0x64,
0x61, 0x2e, 0x64, 0x65, 0x2f, 0x63, 0x6f, 0x63, 0x73, 0x6e, 0x2f, 0x67, 0x6f, 0x73, 0x64, 0x6e,
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_openconfig_openconfig_proto_rawDescOnce sync.Once
file_openconfig_openconfig_proto_rawDescData = file_openconfig_openconfig_proto_rawDesc
)
func file_openconfig_openconfig_proto_rawDescGZIP() []byte {
file_openconfig_openconfig_proto_rawDescOnce.Do(func() {
file_openconfig_openconfig_proto_rawDescData = protoimpl.X.CompressGZIP(file_openconfig_openconfig_proto_rawDescData)
})
return file_openconfig_openconfig_proto_rawDescData
}
var file_openconfig_openconfig_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_openconfig_openconfig_proto_goTypes = []interface{}{
(*Device)(nil), // 0: openconfig.Device
(*Interfaces)(nil), // 1: openconfig.openconfig_interfaces.Interfaces
}
var file_openconfig_openconfig_proto_depIdxs = []int32{
1, // 0: openconfig.Device.interfaces:type_name -> openconfig.openconfig_interfaces.Interfaces
1, // [1:1] is the sub-list for method output_type
1, // [1:1] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name
1, // [1:1] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
}
func init() { file_openconfig_openconfig_proto_init() }
func file_openconfig_openconfig_proto_init() {
if File_openconfig_openconfig_proto != nil {
return
}
file_openconfig_openconfig_interfaces_openconfig_interfaces_proto_init()
if !protoimpl.UnsafeEnabled {
file_openconfig_openconfig_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Device); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_openconfig_openconfig_proto_rawDesc,
NumEnums: 0,
NumMessages: 1,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_openconfig_openconfig_proto_goTypes,
DependencyIndexes: file_openconfig_openconfig_proto_depIdxs,
MessageInfos: file_openconfig_openconfig_proto_msgTypes,
}.Build()
File_openconfig_openconfig_proto = out.File
file_openconfig_openconfig_proto_rawDesc = nil
file_openconfig_openconfig_proto_goTypes = nil
file_openconfig_openconfig_proto_depIdxs = nil
}
// openconfig.enums is generated by proto_generator as a protobuf
// representation of a YANG schema.
//
// Input schema modules:
// - ../yang-models/models/openconfig/release/models/interfaces/openconfig-interfaces.yang
// Include paths:
// - ../yang-models/models/...
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.25.0-devel
// protoc v3.13.0
// source: openconfig/enums/enums.proto
package openconfig_enums
import (
proto "github.com/golang/protobuf/proto"
_ "github.com/openconfig/ygot/proto/yext"
_ "github.com/openconfig/ygot/proto/ywrapper"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
// IETFInterfacesInterfaceType represents an enumerated type generated for the YANG identity interface-type.
type IETFInterfacesInterfaceType int32
const (
IETFInterfacesInterfaceType_IETFINTERFACESINTERFACETYPE_UNSET IETFInterfacesInterfaceType = 0
)
// Enum value maps for IETFInterfacesInterfaceType.
var (
IETFInterfacesInterfaceType_name = map[int32]string{
0: "IETFINTERFACESINTERFACETYPE_UNSET",
}
IETFInterfacesInterfaceType_value = map[string]int32{
"IETFINTERFACESINTERFACETYPE_UNSET": 0,
}
)
func (x IETFInterfacesInterfaceType) Enum() *IETFInterfacesInterfaceType {
p := new(IETFInterfacesInterfaceType)
*p = x
return p
}
func (x IETFInterfacesInterfaceType) String() string {
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (IETFInterfacesInterfaceType) Descriptor() protoreflect.EnumDescriptor {
return file_openconfig_enums_enums_proto_enumTypes[0].Descriptor()
}
func (IETFInterfacesInterfaceType) Type() protoreflect.EnumType {
return &file_openconfig_enums_enums_proto_enumTypes[0]
}
func (x IETFInterfacesInterfaceType) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use IETFInterfacesInterfaceType.Descriptor instead.
func (IETFInterfacesInterfaceType) EnumDescriptor() ([]byte, []int) {
return file_openconfig_enums_enums_proto_rawDescGZIP(), []int{0}
}
var File_openconfig_enums_enums_proto protoreflect.FileDescriptor
var file_openconfig_enums_enums_proto_rawDesc = []byte{
0x0a, 0x1c, 0x6f, 0x70, 0x65, 0x6e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x65, 0x6e, 0x75,
0x6d, 0x73, 0x2f, 0x65, 0x6e, 0x75, 0x6d, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x10,
0x6f, 0x70, 0x65, 0x6e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x65, 0x6e, 0x75, 0x6d, 0x73,
0x1a, 0x38, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x70, 0x65,
0x6e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x79, 0x67, 0x6f, 0x74, 0x2f, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x2f, 0x79, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x2f, 0x79, 0x77, 0x72, 0x61,
0x70, 0x70, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x30, 0x67, 0x69, 0x74, 0x68,
0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x70, 0x65, 0x6e, 0x63, 0x6f, 0x6e, 0x66, 0x69,
0x67, 0x2f, 0x79, 0x67, 0x6f, 0x74, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x79, 0x65, 0x78,
0x74, 0x2f, 0x79, 0x65, 0x78, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2a, 0x44, 0x0a, 0x1b,
0x49, 0x45, 0x54, 0x46, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x73, 0x49, 0x6e,
0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x25, 0x0a, 0x21, 0x49,
0x45, 0x54, 0x46, 0x49, 0x4e, 0x54, 0x45, 0x52, 0x46, 0x41, 0x43, 0x45, 0x53, 0x49, 0x4e, 0x54,
0x45, 0x52, 0x46, 0x41, 0x43, 0x45, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x53, 0x45, 0x54,
0x10, 0x00, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_openconfig_enums_enums_proto_rawDescOnce sync.Once
file_openconfig_enums_enums_proto_rawDescData = file_openconfig_enums_enums_proto_rawDesc
)
func file_openconfig_enums_enums_proto_rawDescGZIP() []byte {
file_openconfig_enums_enums_proto_rawDescOnce.Do(func() {
file_openconfig_enums_enums_proto_rawDescData = protoimpl.X.CompressGZIP(file_openconfig_enums_enums_proto_rawDescData)
})
return file_openconfig_enums_enums_proto_rawDescData
}
var file_openconfig_enums_enums_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_openconfig_enums_enums_proto_goTypes = []interface{}{
(IETFInterfacesInterfaceType)(0), // 0: openconfig.enums.IETFInterfacesInterfaceType
}
var file_openconfig_enums_enums_proto_depIdxs = []int32{
0, // [0:0] is the sub-list for method output_type
0, // [0:0] is the sub-list for method input_type
0, // [0:0] is the sub-list for extension type_name
0, // [0:0] is the sub-list for extension extendee
0, // [0:0] is the sub-list for field type_name
}
func init() { file_openconfig_enums_enums_proto_init() }
func file_openconfig_enums_enums_proto_init() {
if File_openconfig_enums_enums_proto != nil {
return
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_openconfig_enums_enums_proto_rawDesc,
NumEnums: 1,
NumMessages: 0,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_openconfig_enums_enums_proto_goTypes,
DependencyIndexes: file_openconfig_enums_enums_proto_depIdxs,
EnumInfos: file_openconfig_enums_enums_proto_enumTypes,
}.Build()
File_openconfig_enums_enums_proto = out.File
file_openconfig_enums_enums_proto_rawDesc = nil
file_openconfig_enums_enums_proto_goTypes = nil
file_openconfig_enums_enums_proto_depIdxs = nil
}
// openconfig.enums is generated by proto_generator as a protobuf
// representation of a YANG schema.
//
// Input schema modules:
// - ../yang-models/models/openconfig/release/models/interfaces/openconfig-interfaces.yang
// Include paths:
// - ../yang-models/models/...
syntax = "proto3";
package openconfig.enums;
option go_package = "code.fbi.h-da.de/cocsn/gosdn";
import "github.com/openconfig/ygot/proto/ywrapper/ywrapper.proto";
import "github.com/openconfig/ygot/proto/yext/yext.proto";
// IETFInterfacesInterfaceType represents an enumerated type generated for the YANG identity interface-type.
enum IETFInterfacesInterfaceType {
IETFINTERFACESINTERFACETYPE_UNSET = 0;
}
// openconfig is generated by proto_generator as a protobuf
// representation of a YANG schema.
//
// Input schema modules:
// - ../yang-models/models/openconfig/release/models/interfaces/openconfig-interfaces.yang
// Include paths:
// - ../yang-models/models/...
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.25.0-devel
// protoc v3.13.0
// source: openconfig/openconfig.proto
package openconfig
import (
openconfig_interfaces "code.fbi.h-da.de/cocsn/gosdn/api/proto/openconfig/openconfig_interfaces"
proto "github.com/golang/protobuf/proto"
_ "github.com/openconfig/ygot/proto/yext"
_ "github.com/openconfig/ygot/proto/ywrapper"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
type Device struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Interfaces *openconfig_interfaces.Interfaces `protobuf:"bytes,85031486,opt,name=interfaces,proto3" json:"interfaces,omitempty"`
}
func (x *Device) Reset() {
*x = Device{}
if protoimpl.UnsafeEnabled {
mi := &file_openconfig_openconfig_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Device) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Device) ProtoMessage() {}
func (x *Device) ProtoReflect() protoreflect.Message {
mi := &file_openconfig_openconfig_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Device.ProtoReflect.Descriptor instead.
func (*Device) Descriptor() ([]byte, []int) {
return file_openconfig_openconfig_proto_rawDescGZIP(), []int{0}
}
func (x *Device) GetInterfaces() *openconfig_interfaces.Interfaces {
if x != nil {
return x.Interfaces
}
return nil
}
var File_openconfig_openconfig_proto protoreflect.FileDescriptor
var file_openconfig_openconfig_proto_rawDesc = []byte{
0x0a, 0x1b, 0x6f, 0x70, 0x65, 0x6e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x6f, 0x70, 0x65,
0x6e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0a, 0x6f,
0x70, 0x65, 0x6e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x1a, 0x38, 0x67, 0x69, 0x74, 0x68, 0x75,
0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x70, 0x65, 0x6e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67,
0x2f, 0x79, 0x67, 0x6f, 0x74, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x79, 0x77, 0x72, 0x61,
0x70, 0x70, 0x65, 0x72, 0x2f, 0x79, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x1a, 0x30, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f,
0x6f, 0x70, 0x65, 0x6e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x79, 0x67, 0x6f, 0x74, 0x2f,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x79, 0x65, 0x78, 0x74, 0x2f, 0x79, 0x65, 0x78, 0x74, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x3c, 0x6f, 0x70, 0x65, 0x6e, 0x63, 0x6f, 0x6e, 0x66, 0x69,
0x67, 0x2f, 0x6f, 0x70, 0x65, 0x6e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x69, 0x6e, 0x74,
0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x73, 0x2f, 0x6f, 0x70, 0x65, 0x6e, 0x63, 0x6f, 0x6e, 0x66,
0x69, 0x67, 0x5f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x73, 0x2e, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x22, 0x69, 0x0a, 0x06, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x12, 0x5f, 0x0a,
0x0a, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x73, 0x18, 0xbe, 0xf4, 0xc5, 0x28,
0x20, 0x01, 0x28, 0x0b, 0x32, 0x2c, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x63, 0x6f, 0x6e, 0x66, 0x69,
0x67, 0x2e, 0x6f, 0x70, 0x65, 0x6e, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x69, 0x6e, 0x74,
0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x73, 0x2e, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63,
0x65, 0x73, 0x42, 0x0e, 0x82, 0x41, 0x0b, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63,
0x65, 0x73, 0x52, 0x0a, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x73, 0x62, 0x06,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_openconfig_openconfig_proto_rawDescOnce sync.Once
file_openconfig_openconfig_proto_rawDescData = file_openconfig_openconfig_proto_rawDesc
)
func file_openconfig_openconfig_proto_rawDescGZIP() []byte {
file_openconfig_openconfig_proto_rawDescOnce.Do(func() {
file_openconfig_openconfig_proto_rawDescData = protoimpl.X.CompressGZIP(file_openconfig_openconfig_proto_rawDescData)
})
return file_openconfig_openconfig_proto_rawDescData
}
var file_openconfig_openconfig_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_openconfig_openconfig_proto_goTypes = []interface{}{
(*Device)(nil), // 0: openconfig.Device
(*openconfig_interfaces.Interfaces)(nil), // 1: openconfig.openconfig_interfaces.Interfaces
}
var file_openconfig_openconfig_proto_depIdxs = []int32{
1, // 0: openconfig.Device.interfaces:type_name -> openconfig.openconfig_interfaces.Interfaces
1, // [1:1] is the sub-list for method output_type
1, // [1:1] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name
1, // [1:1] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
}
func init() { file_openconfig_openconfig_proto_init() }
func file_openconfig_openconfig_proto_init() {
if File_openconfig_openconfig_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_openconfig_openconfig_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Device); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_openconfig_openconfig_proto_rawDesc,
NumEnums: 0,
NumMessages: 1,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_openconfig_openconfig_proto_goTypes,
DependencyIndexes: file_openconfig_openconfig_proto_depIdxs,
MessageInfos: file_openconfig_openconfig_proto_msgTypes,
}.Build()
File_openconfig_openconfig_proto = out.File
file_openconfig_openconfig_proto_rawDesc = nil
file_openconfig_openconfig_proto_goTypes = nil
file_openconfig_openconfig_proto_depIdxs = nil
}
// openconfig is generated by proto_generator as a protobuf
// representation of a YANG schema.
//
// Input schema modules:
// - ../yang-models/models/openconfig/release/models/interfaces/openconfig-interfaces.yang
// Include paths:
// - ../yang-models/models/...
syntax = "proto3";
package openconfig;
option go_package = "code.fbi.h-da.de/cocsn/gosdn";
import "github.com/openconfig/ygot/proto/ywrapper/ywrapper.proto";
import "github.com/openconfig/ygot/proto/yext/yext.proto";
import "openconfig/openconfig_interfaces/openconfig_interfaces.proto";
message Device {
openconfig_interfaces.Interfaces interfaces = 85031486 [(yext.schemapath) = "/interfaces"];
}
// openconfig.openconfig_interfaces is generated by proto_generator as a protobuf
// representation of a YANG schema.
//
// Input schema modules:
// - ../yang-models/models/openconfig/release/models/interfaces/openconfig-interfaces.yang
// Include paths:
// - ../yang-models/models/...
syntax = "proto3";
package openconfig.openconfig_interfaces;
option go_package = "code.fbi.h-da.de/cocsn/gosdn";
import "github.com/openconfig/ygot/proto/ywrapper/ywrapper.proto";
import "github.com/openconfig/ygot/proto/yext/yext.proto";
import "openconfig/enums/enums.proto";
message Interfaces {
message Interface {
message Config {
ywrapper.StringValue description = 418535860 [(yext.schemapath) = "/interfaces/interface/config/description"];
ywrapper.BoolValue enabled = 37224301 [(yext.schemapath) = "/interfaces/interface/config/enabled"];
ywrapper.BoolValue loopback_mode = 253516347 [(yext.schemapath) = "/interfaces/interface/config/loopback-mode"];
ywrapper.UintValue mtu = 376210342 [(yext.schemapath) = "/interfaces/interface/config/mtu"];
ywrapper.StringValue name = 51804187 [(yext.schemapath) = "/interfaces/interface/config/name"];
openconfig.enums.IETFInterfacesInterfaceType type = 144596894 [(yext.schemapath) = "/interfaces/interface/config/type"];
}
message HoldTime {
message Config {
ywrapper.UintValue down = 171181656 [(yext.schemapath) = "/interfaces/interface/hold-time/config/down"];
ywrapper.UintValue up = 62026235 [(yext.schemapath) = "/interfaces/interface/hold-time/config/up"];
}
message State {
ywrapper.UintValue down = 167887721 [(yext.schemapath) = "/interfaces/interface/hold-time/state/down"];
ywrapper.UintValue up = 223847598 [(yext.schemapath) = "/interfaces/interface/hold-time/state/up"];
}
Config config = 316512729 [(yext.schemapath) = "/interfaces/interface/hold-time/config"];
State state = 483010990 [(yext.schemapath) = "/interfaces/interface/hold-time/state"];
}
message State {
message Counters {
ywrapper.UintValue carrier_transitions = 270803130 [(yext.schemapath) = "/interfaces/interface/state/counters/carrier-transitions"];
ywrapper.UintValue in_broadcast_pkts = 280201989 [(yext.schemapath) = "/interfaces/interface/state/counters/in-broadcast-pkts"];
ywrapper.UintValue in_discards = 11979514 [(yext.schemapath) = "/interfaces/interface/state/counters/in-discards"];
ywrapper.UintValue in_errors = 456697578 [(yext.schemapath) = "/interfaces/interface/state/counters/in-errors"];
ywrapper.UintValue in_fcs_errors = 501559027 [(yext.schemapath) = "/interfaces/interface/state/counters/in-fcs-errors"];
ywrapper.UintValue in_multicast_pkts = 113269128 [(yext.schemapath) = "/interfaces/interface/state/counters/in-multicast-pkts"];
ywrapper.UintValue in_octets = 333138891 [(yext.schemapath) = "/interfaces/interface/state/counters/in-octets"];
ywrapper.UintValue in_pkts = 412843491 [(yext.schemapath) = "/interfaces/interface/state/counters/in-pkts"];
ywrapper.UintValue in_unicast_pkts = 272792307 [(yext.schemapath) = "/interfaces/interface/state/counters/in-unicast-pkts"];
ywrapper.UintValue in_unknown_protos = 241475497 [(yext.schemapath) = "/interfaces/interface/state/counters/in-unknown-protos"];
ywrapper.UintValue last_clear = 186014919 [(yext.schemapath) = "/interfaces/interface/state/counters/last-clear"];
ywrapper.UintValue out_broadcast_pkts = 338589668 [(yext.schemapath) = "/interfaces/interface/state/counters/out-broadcast-pkts"];
ywrapper.UintValue out_discards = 254055111 [(yext.schemapath) = "/interfaces/interface/state/counters/out-discards"];
ywrapper.UintValue out_errors = 471103047 [(yext.schemapath) = "/interfaces/interface/state/counters/out-errors"];
ywrapper.UintValue out_multicast_pkts = 457840757 [(yext.schemapath) = "/interfaces/interface/state/counters/out-multicast-pkts"];
ywrapper.UintValue out_octets = 201005514 [(yext.schemapath) = "/interfaces/interface/state/counters/out-octets"];
ywrapper.UintValue out_pkts = 437582090 [(yext.schemapath) = "/interfaces/interface/state/counters/out-pkts"];
ywrapper.UintValue out_unicast_pkts = 36542246 [(yext.schemapath) = "/interfaces/interface/state/counters/out-unicast-pkts"];
}
enum AdminStatus {
ADMINSTATUS_UNSET = 0;
ADMINSTATUS_UP = 1 [(yext.yang_name) = "UP"];
ADMINSTATUS_DOWN = 2 [(yext.yang_name) = "DOWN"];
ADMINSTATUS_TESTING = 3 [(yext.yang_name) = "TESTING"];
}
enum OperStatus {
OPERSTATUS_UNSET = 0;
OPERSTATUS_UP = 2 [(yext.yang_name) = "UP"];
OPERSTATUS_DOWN = 3 [(yext.yang_name) = "DOWN"];
OPERSTATUS_TESTING = 4 [(yext.yang_name) = "TESTING"];
OPERSTATUS_UNKNOWN = 5 [(yext.yang_name) = "UNKNOWN"];
OPERSTATUS_DORMANT = 6 [(yext.yang_name) = "DORMANT"];
OPERSTATUS_NOT_PRESENT = 7 [(yext.yang_name) = "NOT_PRESENT"];
OPERSTATUS_LOWER_LAYER_DOWN = 8 [(yext.yang_name) = "LOWER_LAYER_DOWN"];
}
AdminStatus admin_status = 474494763 [(yext.schemapath) = "/interfaces/interface/state/admin-status"];
Counters counters = 83645964 [(yext.schemapath) = "/interfaces/interface/state/counters"];
ywrapper.StringValue description = 389435287 [(yext.schemapath) = "/interfaces/interface/state/description"];
ywrapper.BoolValue enabled = 330927518 [(yext.schemapath) = "/interfaces/interface/state/enabled"];
ywrapper.UintValue ifindex = 116108202 [(yext.schemapath) = "/interfaces/interface/state/ifindex"];
ywrapper.UintValue last_change = 127348880 [(yext.schemapath) = "/interfaces/interface/state/last-change"];
ywrapper.BoolValue logical = 440460216 [(yext.schemapath) = "/interfaces/interface/state/logical"];
ywrapper.BoolValue loopback_mode = 372935512 [(yext.schemapath) = "/interfaces/interface/state/loopback-mode"];
ywrapper.UintValue mtu = 96390485 [(yext.schemapath) = "/interfaces/interface/state/mtu"];
ywrapper.StringValue name = 503495278 [(yext.schemapath) = "/interfaces/interface/state/name"];
OperStatus oper_status = 470394226 [(yext.schemapath) = "/interfaces/interface/state/oper-status"];
openconfig.enums.IETFInterfacesInterfaceType type = 358148579 [(yext.schemapath) = "/interfaces/interface/state/type"];
}
message Subinterfaces {
message Subinterface {
message Config {
ywrapper.StringValue description = 280671199 [(yext.schemapath) = "/interfaces/interface/subinterfaces/subinterface/config/description"];
ywrapper.BoolValue enabled = 297236390 [(yext.schemapath) = "/interfaces/interface/subinterfaces/subinterface/config/enabled"];
ywrapper.UintValue index = 279269781 [(yext.schemapath) = "/interfaces/interface/subinterfaces/subinterface/config/index"];
}
message State {
message Counters {
ywrapper.UintValue carrier_transitions = 141120277 [(yext.schemapath) = "/interfaces/interface/subinterfaces/subinterface/state/counters/carrier-transitions"];
ywrapper.UintValue in_broadcast_pkts = 120244022 [(yext.schemapath) = "/interfaces/interface/subinterfaces/subinterface/state/counters/in-broadcast-pkts"];
ywrapper.UintValue in_discards = 307490461 [(yext.schemapath) = "/interfaces/interface/subinterfaces/subinterface/state/counters/in-discards"];
ywrapper.UintValue in_errors = 319720873 [(yext.schemapath) = "/interfaces/interface/subinterfaces/subinterface/state/counters/in-errors"];
ywrapper.UintValue in_fcs_errors = 169858424 [(yext.schemapath) = "/interfaces/interface/subinterfaces/subinterface/state/counters/in-fcs-errors"];
ywrapper.UintValue in_multicast_pkts = 320618859 [(yext.schemapath) = "/interfaces/interface/subinterfaces/subinterface/state/counters/in-multicast-pkts"];
ywrapper.UintValue in_octets = 530205868 [(yext.schemapath) = "/interfaces/interface/subinterfaces/subinterface/state/counters/in-octets"];
ywrapper.UintValue in_pkts = 441153352 [(yext.schemapath) = "/interfaces/interface/subinterfaces/subinterface/state/counters/in-pkts"];
ywrapper.UintValue in_unicast_pkts = 177838880 [(yext.schemapath) = "/interfaces/interface/subinterfaces/subinterface/state/counters/in-unicast-pkts"];
ywrapper.UintValue in_unknown_protos = 146059814 [(yext.schemapath) = "/interfaces/interface/subinterfaces/subinterface/state/counters/in-unknown-protos"];
ywrapper.UintValue last_clear = 518046966 [(yext.schemapath) = "/interfaces/interface/subinterfaces/subinterface/state/counters/last-clear"];
ywrapper.UintValue out_broadcast_pkts = 501221245 [(yext.schemapath) = "/interfaces/interface/subinterfaces/subinterface/state/counters/out-broadcast-pkts"];
ywrapper.UintValue out_discards = 159539762 [(yext.schemapath) = "/interfaces/interface/subinterfaces/subinterface/state/counters/out-discards"];
ywrapper.UintValue out_errors = 466636898 [(yext.schemapath) = "/interfaces/interface/subinterfaces/subinterface/state/counters/out-errors"];
ywrapper.UintValue out_multicast_pkts = 326155776 [(yext.schemapath) = "/interfaces/interface/subinterfaces/subinterface/state/counters/out-multicast-pkts"];
ywrapper.UintValue out_octets = 50579235 [(yext.schemapath) = "/interfaces/interface/subinterfaces/subinterface/state/counters/out-octets"];
ywrapper.UintValue out_pkts = 29497115 [(yext.schemapath) = "/interfaces/interface/subinterfaces/subinterface/state/counters/out-pkts"];
ywrapper.UintValue out_unicast_pkts = 297910971 [(yext.schemapath) = "/interfaces/interface/subinterfaces/subinterface/state/counters/out-unicast-pkts"];
}
enum AdminStatus {
ADMINSTATUS_UNSET = 0;
ADMINSTATUS_UP = 1 [(yext.yang_name) = "UP"];
ADMINSTATUS_DOWN = 2 [(yext.yang_name) = "DOWN"];
ADMINSTATUS_TESTING = 3 [(yext.yang_name) = "TESTING"];
}
enum OperStatus {
OPERSTATUS_UNSET = 0;
OPERSTATUS_UP = 2 [(yext.yang_name) = "UP"];
OPERSTATUS_DOWN = 3 [(yext.yang_name) = "DOWN"];
OPERSTATUS_TESTING = 4 [(yext.yang_name) = "TESTING"];
OPERSTATUS_UNKNOWN = 5 [(yext.yang_name) = "UNKNOWN"];
OPERSTATUS_DORMANT = 6 [(yext.yang_name) = "DORMANT"];
OPERSTATUS_NOT_PRESENT = 7 [(yext.yang_name) = "NOT_PRESENT"];
OPERSTATUS_LOWER_LAYER_DOWN = 8 [(yext.yang_name) = "LOWER_LAYER_DOWN"];
}
AdminStatus admin_status = 250658952 [(yext.schemapath) = "/interfaces/interface/subinterfaces/subinterface/state/admin-status"];
Counters counters = 483442783 [(yext.schemapath) = "/interfaces/interface/subinterfaces/subinterface/state/counters"];
ywrapper.StringValue description = 49943526 [(yext.schemapath) = "/interfaces/interface/subinterfaces/subinterface/state/description"];
ywrapper.BoolValue enabled = 468513843 [(yext.schemapath) = "/interfaces/interface/subinterfaces/subinterface/state/enabled"];
ywrapper.UintValue ifindex = 511987815 [(yext.schemapath) = "/interfaces/interface/subinterfaces/subinterface/state/ifindex"];
ywrapper.UintValue index = 80745756 [(yext.schemapath) = "/interfaces/interface/subinterfaces/subinterface/state/index"];
ywrapper.UintValue last_change = 29904521 [(yext.schemapath) = "/interfaces/interface/subinterfaces/subinterface/state/last-change"];
ywrapper.BoolValue logical = 294124401 [(yext.schemapath) = "/interfaces/interface/subinterfaces/subinterface/state/logical"];
ywrapper.StringValue name = 279346681 [(yext.schemapath) = "/interfaces/interface/subinterfaces/subinterface/state/name"];
OperStatus oper_status = 401969247 [(yext.schemapath) = "/interfaces/interface/subinterfaces/subinterface/state/oper-status"];
}
Config config = 175001476 [(yext.schemapath) = "/interfaces/interface/subinterfaces/subinterface/config"];
State state = 501974173 [(yext.schemapath) = "/interfaces/interface/subinterfaces/subinterface/state"];
}
message SubinterfaceKey {
uint64 index = 1 [(yext.schemapath) = "/interfaces/interface/subinterfaces/subinterface/index"];
Subinterface subinterface = 2;
}
repeated SubinterfaceKey subinterface = 464802819 [(yext.schemapath) = "/interfaces/interface/subinterfaces/subinterface"];
}
Config config = 334174827 [(yext.schemapath) = "/interfaces/interface/config"];
HoldTime hold_time = 175931092 [(yext.schemapath) = "/interfaces/interface/hold-time"];
State state = 387556140 [(yext.schemapath) = "/interfaces/interface/state"];
Subinterfaces subinterfaces = 327798165 [(yext.schemapath) = "/interfaces/interface/subinterfaces"];
}
message InterfaceKey {
string name = 1 [(yext.schemapath) = "/interfaces/interface/name"];
Interface interface = 2;
}
repeated InterfaceKey interface = 422482938 [(yext.schemapath) = "/interfaces/interface"];
}
package main
import (
"code.fbi.h-da.de/cocsn/gosdn/forks/goarista/gnmi"
"code.fbi.h-da.de/cocsn/gosdn/nucleus"
"context"
"fmt"
"github.com/google/uuid"
log "github.com/sirupsen/logrus"
)
func main() {
sbi := &nucleus.OpenConfig{}
device := nucleus.Device{
SBI: sbi,
Config: nucleus.DeviceConfig{
Uuid: uuid.New(),
Address: "141.100.70.170:6030",
Username: "admin",
Password: "arista",
},
}
pnd := nucleus.NewPND("openconfig", sbi)
if err := pnd.AddDevice(device); err != nil {
log.Fatal(err)
}
cfg := &gnmi.Config{
Addr: device.Config.Address,
Password: device.Config.Password,
Username: device.Config.Username,
}
ctx := gnmi.NewContext(context.Background(), cfg)
ctx = context.WithValue(ctx, "config", cfg)
paths := []string{"interfaces/interface"}
req, err := gnmi.NewGetRequest(gnmi.SplitPaths(paths), "")
resp, err := nucleus.GetWithRequest(ctx, req)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%v", resp)
}
......@@ -141,7 +141,7 @@ func goSDNTestDB(conn *grpc.ClientConn) {
}
// TAPIGetEdge triggers the GetEdge function of the Ciena
// flavoured TAPI ciena
// flavoured TAPI client
func TAPIGetEdge(conn *grpc.ClientConn) {
c := pb.NewGrpcCliClient(conn)
......@@ -161,7 +161,7 @@ func TAPIGetEdge(conn *grpc.ClientConn) {
}
// TAPIGetEdgeNode triggers the GetEdgeNode function of the Ciena
// flavoured TAPI ciena
// flavoured TAPI client
func TAPIGetEdgeNode(conn *grpc.ClientConn) {
c := pb.NewGrpcCliClient(conn)
......@@ -180,7 +180,7 @@ func TAPIGetEdgeNode(conn *grpc.ClientConn) {
}
// TAPIGetLink triggers the GetLink function of the Ciena
// flavoured TAPI ciena
// flavoured TAPI client
func TAPIGetLink(conn *grpc.ClientConn) {
c := pb.NewGrpcCliClient(conn)
......
......@@ -169,7 +169,7 @@ func goSDNTestDB(conn *grpc.ClientConn) string {
}
// TAPIGetEdge triggers the GetEdge function of the Ciena
// flavoured TAPI ciena
// flavoured TAPI client
func TAPIGetEdge(conn *grpc.ClientConn) string {
c := pb.NewGrpcCliClient(conn)
......@@ -186,7 +186,7 @@ func TAPIGetEdge(conn *grpc.ClientConn) string {
}
// TAPIGetEdgeNode triggers the GetEdgeNode function of the Ciena
// flavoured TAPI ciena
// flavoured TAPI client
func TAPIGetEdgeNode(conn *grpc.ClientConn) string {
c := pb.NewGrpcCliClient(conn)
......@@ -202,7 +202,7 @@ func TAPIGetEdgeNode(conn *grpc.ClientConn) string {
}
// TAPIGetLink triggers the GetLink function of the Ciena
// flavoured TAPI ciena
// flavoured TAPI client
func TAPIGetLink(conn *grpc.ClientConn) string {
c := pb.NewGrpcCliClient(conn)
......
......@@ -2,15 +2,27 @@ package main
import (
"code.fbi.h-da.de/cocsn/gosdn/nucleus"
"flag"
log "github.com/sirupsen/logrus"
)
func main() {
// register our supported flags
cliListenAddr := flag.String("cli-listen-addr", "", "The IP address of the grpcCLI.")
cliListenPort := flag.String("cli-server-port", "55055", "The port number of the grpcCLI")
configFileName := flag.String("config-file", "", "Path to the config file")
flag.Parse()
cliSocket := *cliListenAddr + ":" + *cliListenPort
log.SetLevel(log.DebugLevel)
// Setup a channel to communicate if goSDN should shutdown.
IsRunningChannel := make(chan bool)
// hand off to cmd for further processing
nucleus.StartAndRun(IsRunningChannel)
nucleus.StartAndRun(cliSocket, *configFileName, IsRunningChannel)
// nothing to see here, please move on!
}
CliSocket = "localhost:55055"
db.socket = "bolt://172.17.0.4:7687"
db.user = ""
db.password = ""
db.crypto = false
DatabaseSocket = "bolt://172.17.0.4:7687"
DatabaseUser = ""
DatabasePassword = ""
DatabaseCrypto = false
ConfigPath = "./configs/gosdn.toml"
......@@ -4,7 +4,6 @@ import (
"errors"
"github.com/neo4j/neo4j-go-driver/neo4j"
log "github.com/sirupsen/logrus"
"github.com/spf13/viper"
)
//Database is a database
......@@ -19,12 +18,8 @@ type PND struct {
interfaces []string
}
//NewDatabaseClient creates a database ciena
func NewDatabaseClient() Database {
uri := viper.GetString("db.socket")
username := viper.GetString("db.user")
password := viper.GetString("db.password")
encrypted := viper.GetBool("db.crypto")
//NewDatabaseClient creates a database client
func NewDatabaseClient(uri, username, password string, encrypted bool) Database {
driver := createDriver(uri, username, password, encrypted)
return Database{
......
// Copyright (c) 2019 Arista Networks, Inc.
// Use of this source code is governed by the Apache License 2.0
// that can be found in the COPYING file.
package gnmi
import (
"fmt"
"strconv"
"strings"
"github.com/openconfig/gnmi/proto/gnmi_ext"
)
// ArbitrationExt takes a string representation of a master arbitration value
// (e.g. "23", "role:42") and return a *gnmi_ext.Extension.
func ArbitrationExt(s string) (*gnmi_ext.Extension, error) {
if s == "" {
return nil, nil
}
roleID, electionID, err := parseArbitrationString(s)
if err != nil {
return nil, err
}
arb := &gnmi_ext.MasterArbitration{
Role: &gnmi_ext.Role{Id: roleID},
ElectionId: &gnmi_ext.Uint128{High: 0, Low: electionID},
}
ext := gnmi_ext.Extension_MasterArbitration{MasterArbitration: arb}
return &gnmi_ext.Extension{Ext: &ext}, nil
}
// parseArbitrationString parses the supplied string and returns the role and election id
// values. Input is of the form [<role>:]<election_id>, where election_id is a uint64.
//
// Examples:
// "1"
// "admin:42"
func parseArbitrationString(s string) (string, uint64, error) {
tokens := strings.Split(s, ":")
switch len(tokens) {
case 1: // just election id
id, err := parseElectionID(tokens[0])
return "", id, err
case 2: // role and election id
id, err := parseElectionID(tokens[1])
return tokens[0], id, err
}
return "", 0, fmt.Errorf("badly formed arbitration id (%s)", s)
}
func parseElectionID(s string) (uint64, error) {
id, err := strconv.ParseUint(s, 0, 64)
if err != nil {
return 0, fmt.Errorf("badly formed arbitration id (%s)", s)
}
return id, nil
}
// Copyright (c) 2019 Arista Networks, Inc.
// Use of this source code is governed by the Apache License 2.0
// that can be found in the COPYING file.
package gnmi
import (
"fmt"
"testing"
"github.com/aristanetworks/goarista/test"
"github.com/openconfig/gnmi/proto/gnmi_ext"
)
func arbitration(role string, id *gnmi_ext.Uint128) *gnmi_ext.Extension {
arb := &gnmi_ext.MasterArbitration{
Role: &gnmi_ext.Role{Id: role},
ElectionId: id,
}
ext := gnmi_ext.Extension_MasterArbitration{MasterArbitration: arb}
return &gnmi_ext.Extension{Ext: &ext}
}
func electionID(high, low uint64) *gnmi_ext.Uint128 {
return &gnmi_ext.Uint128{High: high, Low: low}
}
func TestArbitrationExt(t *testing.T) {
testCases := map[string]struct {
s string
ext *gnmi_ext.Extension
err error
}{
"empty": {},
"no_role": {
s: "1",
ext: arbitration("", electionID(0, 1)),
},
"with_role": {
s: "admin:1",
ext: arbitration("admin", electionID(0, 1)),
},
"large_no_role": {
s: "9223372036854775807",
ext: arbitration("", electionID(0, 9223372036854775807)),
},
"large_with_role": {
s: "admin:18446744073709551615",
ext: arbitration("admin", electionID(0, 18446744073709551615)),
},
"invalid": {
s: "cat",
err: fmt.Errorf("badly formed arbitration id (%s)", "cat"),
},
"invalid_too_many_colons": {
s: "dog:1:2",
err: fmt.Errorf("badly formed arbitration id (%s)", "dog:1:2"),
},
}
for name, tc := range testCases {
t.Run(name, func(t *testing.T) {
ext, err := ArbitrationExt(tc.s)
if !test.DeepEqual(tc.ext, ext) {
t.Errorf("Expected %#v, got %#v", tc.ext, ext)
}
if !test.DeepEqual(tc.err, err) {
t.Errorf("Expected %v, got %v", tc.err, err)
}
})
}
}
// Copyright (c) 2017 Arista Networks, Inc.
// Use of this source code is governed by the Apache License 2.0
// that can be found in the COPYING file.
package gnmi
import (
"context"
"crypto/tls"
"crypto/x509"
"flag"
"fmt"
"math"
"net"
"os"
"io/ioutil"
"strings"
"github.com/golang/protobuf/proto"
pb "github.com/openconfig/gnmi/proto/gnmi"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/encoding/gzip"
"google.golang.org/grpc/metadata"
)
const (
defaultPort = "6030"
// HostnameArg is the value to be replaced by the actual hostname
HostnameArg = "HOSTNAME"
)
// PublishFunc is the method to publish responses
type PublishFunc func(addr string, message proto.Message)
// ParseHostnames parses a comma-separated list of names and replaces HOSTNAME with the current
// hostname in it
func ParseHostnames(list string) ([]string, error) {
items := strings.Split(list, ",")
hostname, err := os.Hostname()
if err != nil {
return nil, err
}
names := make([]string, len(items))
for i, name := range items {
if name == HostnameArg {
name = hostname
}
names[i] = name
}
return names, nil
}
// Config is the gnmi.Client config
type Config struct {
Addr string
CAFile string
CertFile string
KeyFile string
Password string
Username string
TLS bool
Compression string
DialOptions []grpc.DialOption
Token string
}
// SubscribeOptions is the gNMI subscription request options
type SubscribeOptions struct {
UpdatesOnly bool
Prefix string
Mode string
StreamMode string
SampleInterval uint64
SuppressRedundant bool
HeartbeatInterval uint64
Paths [][]string
Origin string
Target string
}
// ParseFlags reads arguments from stdin and returns a populated Config object and a list of
// paths to subscribe to
func ParseFlags() (*Config, []string) {
// flags
var (
addrsFlag = flag.String("addrs", "localhost:6030",
"Comma-separated list of addresses of OpenConfig gRPC servers. The address 'HOSTNAME' "+
"is replaced by the current hostname.")
caFileFlag = flag.String("cafile", "",
"Path to server TLS certificate file")
certFileFlag = flag.String("certfile", "",
"Path to ciena TLS certificate file")
keyFileFlag = flag.String("keyfile", "",
"Path to ciena TLS private key file")
passwordFlag = flag.String("password", "",
"Password to authenticate with")
usernameFlag = flag.String("username", "",
"Username to authenticate with")
tlsFlag = flag.Bool("tls", false,
"Enable TLS")
compressionFlag = flag.String("compression", "",
"Type of compression to use")
subscribeFlag = flag.String("subscribe", "",
"Comma-separated list of paths to subscribe to upon connecting to the server")
token = flag.String("token", "",
"Authentication token")
)
flag.Parse()
cfg := &Config{
Addr: *addrsFlag,
CAFile: *caFileFlag,
CertFile: *certFileFlag,
KeyFile: *keyFileFlag,
Password: *passwordFlag,
Username: *usernameFlag,
TLS: *tlsFlag,
Compression: *compressionFlag,
Token: *token,
}
subscriptions := strings.Split(*subscribeFlag, ",")
return cfg, subscriptions
}
// accessTokenCred implements credentials.PerRPCCredentials, the gRPC
// interface for credentials that need to attach security information
// to every RPC.
type accessTokenCred struct {
bearerToken string
}
// newAccessTokenCredential constructs a new per-RPC credential from a token.
func newAccessTokenCredential(token string) credentials.PerRPCCredentials {
bearerFmt := "Bearer %s"
return &accessTokenCred{bearerToken: fmt.Sprintf(bearerFmt, token)}
}
func (a *accessTokenCred) GetRequestMetadata(ctx context.Context,
uri ...string) (map[string]string, error) {
authHeader := "Authorization"
return map[string]string{
authHeader: a.bearerToken,
}, nil
}
func (a *accessTokenCred) RequireTransportSecurity() bool { return true }
// DialContext connects to a gnmi service and returns a ciena
func DialContext(ctx context.Context, cfg *Config) (pb.GNMIClient, error) {
opts := append([]grpc.DialOption(nil), cfg.DialOptions...)
switch cfg.Compression {
case "":
case "gzip":
opts = append(opts, grpc.WithDefaultCallOptions(grpc.UseCompressor(gzip.Name)))
default:
return nil, fmt.Errorf("unsupported compression option: %q", cfg.Compression)
}
if cfg.TLS || cfg.CAFile != "" || cfg.CertFile != "" || cfg.Token != "" {
tlsConfig := &tls.Config{}
if cfg.CAFile != "" {
b, err := ioutil.ReadFile(cfg.CAFile)
if err != nil {
return nil, err
}
cp := x509.NewCertPool()
if !cp.AppendCertsFromPEM(b) {
return nil, fmt.Errorf("credentials: failed to append certificates")
}
tlsConfig.RootCAs = cp
} else {
tlsConfig.InsecureSkipVerify = true
}
if cfg.CertFile != "" {
if cfg.KeyFile == "" {
return nil, fmt.Errorf("please provide both -certfile and -keyfile")
}
cert, err := tls.LoadX509KeyPair(cfg.CertFile, cfg.KeyFile)
if err != nil {
return nil, err
}
tlsConfig.Certificates = []tls.Certificate{cert}
}
if cfg.Token != "" {
opts = append(opts,
grpc.WithPerRPCCredentials(newAccessTokenCredential(cfg.Token)))
}
opts = append(opts, grpc.WithTransportCredentials(credentials.NewTLS(tlsConfig)))
} else {
opts = append(opts, grpc.WithInsecure())
}
dial := func(ctx context.Context, addrIn string) (conn net.Conn, err error) {
var network, addr string
split := strings.Split(addrIn, "://")
if l := len(split); l == 2 {
network = split[0]
addr = split[1]
} else {
network = "tcp"
addr = split[0]
}
conn, err = (&net.Dialer{}).DialContext(ctx, network, addr)
return
}
opts = append(opts,
grpc.WithContextDialer(dial),
// Allows received protobuf messages to be larger than 4MB
grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(math.MaxInt32)),
)
grpcconn, err := grpc.DialContext(ctx, cfg.Addr, opts...)
if err != nil {
return nil, fmt.Errorf("failed to dial: %s", err)
}
return pb.NewGNMIClient(grpcconn), nil
}
// Dial connects to a gnmi service and returns a ciena
func Dial(cfg *Config) (pb.GNMIClient, error) {
return DialContext(context.Background(), cfg)
}
// NewContext returns a new context with username and password
// metadata if they are set in cfg.
func NewContext(ctx context.Context, cfg *Config) context.Context {
if cfg.Username != "" {
ctx = metadata.NewOutgoingContext(ctx, metadata.Pairs(
"username", cfg.Username,
"password", cfg.Password))
}
return ctx
}
// NewGetRequest returns a GetRequest for the given paths
func NewGetRequest(paths [][]string, origin string) (*pb.GetRequest, error) {
req := &pb.GetRequest{
Path: make([]*pb.Path, len(paths)),
}
for i, p := range paths {
gnmiPath, err := ParseGNMIElements(p)
if err != nil {
return nil, err
}
req.Path[i] = gnmiPath
req.Path[i].Origin = origin
}
return req, nil
}
// NewSubscribeRequest returns a SubscribeRequest for the given paths
func NewSubscribeRequest(subscribeOptions *SubscribeOptions) (*pb.SubscribeRequest, error) {
var mode pb.SubscriptionList_Mode
switch subscribeOptions.Mode {
case "once":
mode = pb.SubscriptionList_ONCE
case "poll":
mode = pb.SubscriptionList_POLL
case "":
fallthrough
case "stream":
mode = pb.SubscriptionList_STREAM
default:
return nil, fmt.Errorf("subscribe mode (%s) invalid", subscribeOptions.Mode)
}
var streamMode pb.SubscriptionMode
switch subscribeOptions.StreamMode {
case "on_change":
streamMode = pb.SubscriptionMode_ON_CHANGE
case "sample":
streamMode = pb.SubscriptionMode_SAMPLE
case "":
fallthrough
case "target_defined":
streamMode = pb.SubscriptionMode_TARGET_DEFINED
default:
return nil, fmt.Errorf("subscribe stream mode (%s) invalid", subscribeOptions.StreamMode)
}
prefixPath, err := ParseGNMIElements(SplitPath(subscribeOptions.Prefix))
if err != nil {
return nil, err
}
subList := &pb.SubscriptionList{
Subscription: make([]*pb.Subscription, len(subscribeOptions.Paths)),
Mode: mode,
UpdatesOnly: subscribeOptions.UpdatesOnly,
Prefix: prefixPath,
}
if subscribeOptions.Target != "" {
if subList.Prefix == nil {
subList.Prefix = &pb.Path{}
}
subList.Prefix.Target = subscribeOptions.Target
}
for i, p := range subscribeOptions.Paths {
gnmiPath, err := ParseGNMIElements(p)
if err != nil {
return nil, err
}
gnmiPath.Origin = subscribeOptions.Origin
subList.Subscription[i] = &pb.Subscription{
Path: gnmiPath,
Mode: streamMode,
SampleInterval: subscribeOptions.SampleInterval,
SuppressRedundant: subscribeOptions.SuppressRedundant,
HeartbeatInterval: subscribeOptions.HeartbeatInterval,
}
}
return &pb.SubscribeRequest{Request: &pb.SubscribeRequest_Subscribe{
Subscribe: subList}}, nil
}
// Copyright (c) 2017 Arista Networks, Inc.
// Use of this source code is governed by the Apache License 2.0
// that can be found in the COPYING file.
package gnmi
import (
"github.com/openconfig/gnmi/proto/gnmi"
)
// NotificationToMap converts a Notification into a map[string]interface{}
func NotificationToMap(notif *gnmi.Notification) (map[string]interface{}, error) {
m := make(map[string]interface{}, 1)
m["timestamp"] = notif.Timestamp
m["path"] = StrPath(notif.Prefix)
if len(notif.Update) != 0 {
updates := make(map[string]interface{}, len(notif.Update))
var err error
for _, update := range notif.Update {
updates[StrPath(update.Path)] = StrUpdateVal(update)
if err != nil {
return nil, err
}
}
m["updates"] = updates
}
if len(notif.Delete) != 0 {
deletes := make([]string, len(notif.Delete))
for i, del := range notif.Delete {
deletes[i] = StrPath(del)
}
m["deletes"] = deletes
}
return m, nil
}
// Copyright (c) 2017 Arista Networks, Inc.
// Use of this source code is governed by the Apache License 2.0
// that can be found in the COPYING file.
package gnmi
import (
"bufio"
"bytes"
"context"
"encoding/base64"
"encoding/json"
"errors"
"fmt"
"io"
"io/ioutil"
"math"
"os"
"path"
"strconv"
"strings"
"time"
pb "github.com/openconfig/gnmi/proto/gnmi"
"github.com/openconfig/gnmi/proto/gnmi_ext"
"google.golang.org/grpc/codes"
)
// GetWithRequest takes a fully formed GetRequest, performs the Get,
// and displays any response.
func GetWithRequest(ctx context.Context, client pb.GNMIClient,
req *pb.GetRequest) error {
resp, err := client.Get(ctx, req)
if err != nil {
return err
}
for _, notif := range resp.Notification {
prefix := StrPath(notif.Prefix)
for _, update := range notif.Update {
fmt.Printf("%s:\n", path.Join(prefix, StrPath(update.Path)))
fmt.Println(StrUpdateVal(update))
}
}
return nil
}
// Get sends a GetRequest to the given ciena.
func Get(ctx context.Context, client pb.GNMIClient, paths [][]string,
origin string) error {
req, err := NewGetRequest(paths, origin)
if err != nil {
return err
}
return GetWithRequest(ctx, client, req)
}
// Capabilities retuns the capabilities of the ciena.
func Capabilities(ctx context.Context, client pb.GNMIClient) error {
resp, err := client.Capabilities(ctx, &pb.CapabilityRequest{})
if err != nil {
return err
}
fmt.Printf("Version: %s\n", resp.GNMIVersion)
for _, mod := range resp.SupportedModels {
fmt.Printf("SupportedModel: %s\n", mod)
}
for _, enc := range resp.SupportedEncodings {
fmt.Printf("SupportedEncoding: %s\n", enc)
}
return nil
}
// val may be a path to a file or it may be json. First see if it is a
// file, if so return its contents, otherwise return val
func extractJSON(val string) []byte {
if jsonBytes, err := ioutil.ReadFile(val); err == nil {
return jsonBytes
}
// Best effort check if the value might a string literal, in which
// case wrap it in quotes. This is to allow a user to do:
// gnmi update ../hostname host1234
// gnmi update ../description 'This is a description'
// instead of forcing them to quote the string:
// gnmi update ../hostname '"host1234"'
// gnmi update ../description '"This is a description"'
maybeUnquotedStringLiteral := func(s string) bool {
if s == "true" || s == "false" || s == "null" || // JSON reserved words
strings.ContainsAny(s, `"'{}[]`) { // Already quoted or is a JSON object or array
return false
} else if _, err := strconv.ParseInt(s, 0, 32); err == nil {
// Integer. Using byte size of 32 because larger integer
// types are supposed to be sent as strings in JSON.
return false
} else if _, err := strconv.ParseFloat(s, 64); err == nil {
// Float
return false
}
return true
}
if maybeUnquotedStringLiteral(val) {
out := make([]byte, len(val)+2)
out[0] = '"'
copy(out[1:], val)
out[len(out)-1] = '"'
return out
}
return []byte(val)
}
// StrUpdateVal will return a string representing the value within the supplied update
func StrUpdateVal(u *pb.Update) string {
if u.Value != nil {
// Backwards compatibility with pre-v0.4 gnmi
switch u.Value.Type {
case pb.Encoding_JSON, pb.Encoding_JSON_IETF:
return strJSON(u.Value.Value)
case pb.Encoding_BYTES, pb.Encoding_PROTO:
return base64.StdEncoding.EncodeToString(u.Value.Value)
case pb.Encoding_ASCII:
return string(u.Value.Value)
default:
return string(u.Value.Value)
}
}
return StrVal(u.Val)
}
// StrVal will return a string representing the supplied value
func StrVal(val *pb.TypedValue) string {
switch v := val.GetValue().(type) {
case *pb.TypedValue_StringVal:
return v.StringVal
case *pb.TypedValue_JsonIetfVal:
return strJSON(v.JsonIetfVal)
case *pb.TypedValue_JsonVal:
return strJSON(v.JsonVal)
case *pb.TypedValue_IntVal:
return strconv.FormatInt(v.IntVal, 10)
case *pb.TypedValue_UintVal:
return strconv.FormatUint(v.UintVal, 10)
case *pb.TypedValue_BoolVal:
return strconv.FormatBool(v.BoolVal)
case *pb.TypedValue_BytesVal:
return base64.StdEncoding.EncodeToString(v.BytesVal)
case *pb.TypedValue_DecimalVal:
return strDecimal64(v.DecimalVal)
case *pb.TypedValue_FloatVal:
return strconv.FormatFloat(float64(v.FloatVal), 'g', -1, 32)
case *pb.TypedValue_LeaflistVal:
return strLeaflist(v.LeaflistVal)
case *pb.TypedValue_AsciiVal:
return v.AsciiVal
case *pb.TypedValue_AnyVal:
return v.AnyVal.String()
case *pb.TypedValue_ProtoBytes:
return base64.StdEncoding.EncodeToString(v.ProtoBytes)
default:
panic(v)
}
}
func strJSON(inJSON []byte) string {
var (
out bytes.Buffer
err error
)
// Check for ',' as simple heuristic on whether to expand JSON
// onto multiple lines, or compact it to a single line.
if bytes.Contains(inJSON, []byte{','}) {
err = json.Indent(&out, inJSON, "", " ")
} else {
err = json.Compact(&out, inJSON)
}
if err != nil {
return fmt.Sprintf("(error unmarshalling json: %s)\n", err) + string(inJSON)
}
return out.String()
}
func strDecimal64(d *pb.Decimal64) string {
var i, frac int64
if d.Precision > 0 {
div := int64(10)
it := d.Precision - 1
for it > 0 {
div *= 10
it--
}
i = d.Digits / div
frac = d.Digits % div
} else {
i = d.Digits
}
if frac < 0 {
frac = -frac
}
return fmt.Sprintf("%d.%d", i, frac)
}
// strLeafList builds a human-readable form of a leaf-list. e.g. [1, 2, 3] or [a, b, c]
func strLeaflist(v *pb.ScalarArray) string {
var b strings.Builder
b.WriteByte('[')
for i, elm := range v.Element {
b.WriteString(StrVal(elm))
if i < len(v.Element)-1 {
b.WriteString(", ")
}
}
b.WriteByte(']')
return b.String()
}
// TypedValue marshals an interface into a gNMI TypedValue value
func TypedValue(val interface{}) *pb.TypedValue {
// TODO: handle more types:
// float64
// maps
// key.Key
// key.Map
// ... etc
switch v := val.(type) {
case string:
return &pb.TypedValue{Value: &pb.TypedValue_StringVal{StringVal: v}}
case int:
return &pb.TypedValue{Value: &pb.TypedValue_IntVal{IntVal: int64(v)}}
case int8:
return &pb.TypedValue{Value: &pb.TypedValue_IntVal{IntVal: int64(v)}}
case int16:
return &pb.TypedValue{Value: &pb.TypedValue_IntVal{IntVal: int64(v)}}
case int32:
return &pb.TypedValue{Value: &pb.TypedValue_IntVal{IntVal: int64(v)}}
case int64:
return &pb.TypedValue{Value: &pb.TypedValue_IntVal{IntVal: v}}
case uint:
return &pb.TypedValue{Value: &pb.TypedValue_UintVal{UintVal: uint64(v)}}
case uint8:
return &pb.TypedValue{Value: &pb.TypedValue_UintVal{UintVal: uint64(v)}}
case uint16:
return &pb.TypedValue{Value: &pb.TypedValue_UintVal{UintVal: uint64(v)}}
case uint32:
return &pb.TypedValue{Value: &pb.TypedValue_UintVal{UintVal: uint64(v)}}
case uint64:
return &pb.TypedValue{Value: &pb.TypedValue_UintVal{UintVal: v}}
case bool:
return &pb.TypedValue{Value: &pb.TypedValue_BoolVal{BoolVal: v}}
case float32:
return &pb.TypedValue{Value: &pb.TypedValue_FloatVal{FloatVal: v}}
case []interface{}:
gnmiElems := make([]*pb.TypedValue, len(v))
for i, elem := range v {
gnmiElems[i] = TypedValue(elem)
}
return &pb.TypedValue{
Value: &pb.TypedValue_LeaflistVal{
LeaflistVal: &pb.ScalarArray{
Element: gnmiElems,
}}}
default:
panic(fmt.Sprintf("unexpected type %T for value %v", val, val))
}
}
// ExtractValue pulls a value out of a gNMI Update, parsing JSON if present.
// Possible return types:
// string
// int64
// uint64
// bool
// []byte
// float32
// *gnmi.Decimal64
// json.Number
// *any.Any
// []interface{}
// map[string]interface{}
func ExtractValue(update *pb.Update) (interface{}, error) {
var i interface{}
var err error
if update == nil {
return nil, fmt.Errorf("empty update")
}
if update.Val != nil {
i, err = extractValueV04(update.Val)
} else if update.Value != nil {
i, err = extractValueV03(update.Value)
}
return i, err
}
func extractValueV04(val *pb.TypedValue) (interface{}, error) {
switch v := val.Value.(type) {
case *pb.TypedValue_StringVal:
return v.StringVal, nil
case *pb.TypedValue_IntVal:
return v.IntVal, nil
case *pb.TypedValue_UintVal:
return v.UintVal, nil
case *pb.TypedValue_BoolVal:
return v.BoolVal, nil
case *pb.TypedValue_BytesVal:
return v.BytesVal, nil
case *pb.TypedValue_FloatVal:
return v.FloatVal, nil
case *pb.TypedValue_DecimalVal:
return v.DecimalVal, nil
case *pb.TypedValue_LeaflistVal:
elementList := v.LeaflistVal.Element
l := make([]interface{}, len(elementList))
for i, element := range elementList {
el, err := extractValueV04(element)
if err != nil {
return nil, err
}
l[i] = el
}
return l, nil
case *pb.TypedValue_AnyVal:
return v.AnyVal, nil
case *pb.TypedValue_JsonVal:
return decode(v.JsonVal)
case *pb.TypedValue_JsonIetfVal:
return decode(v.JsonIetfVal)
case *pb.TypedValue_AsciiVal:
return v.AsciiVal, nil
case *pb.TypedValue_ProtoBytes:
return v.ProtoBytes, nil
}
return nil, fmt.Errorf("unhandled type of value %v", val.GetValue())
}
func extractValueV03(val *pb.Value) (interface{}, error) {
switch val.Type {
case pb.Encoding_JSON, pb.Encoding_JSON_IETF:
return decode(val.Value)
case pb.Encoding_BYTES, pb.Encoding_PROTO:
return val.Value, nil
case pb.Encoding_ASCII:
return string(val.Value), nil
}
return nil, fmt.Errorf("unhandled type of value %v", val.GetValue())
}
func decode(byteArr []byte) (interface{}, error) {
decoder := json.NewDecoder(bytes.NewReader(byteArr))
decoder.UseNumber()
var value interface{}
err := decoder.Decode(&value)
return value, err
}
// DecimalToFloat converts a gNMI Decimal64 to a float64
func DecimalToFloat(dec *pb.Decimal64) float64 {
return float64(dec.Digits) / math.Pow10(int(dec.Precision))
}
func update(p *pb.Path, val string) (*pb.Update, error) {
var v *pb.TypedValue
switch p.Origin {
case "":
v = &pb.TypedValue{
Value: &pb.TypedValue_JsonIetfVal{JsonIetfVal: extractJSON(val)}}
case "eos_native":
v = &pb.TypedValue{
Value: &pb.TypedValue_JsonVal{JsonVal: extractJSON(val)}}
case "cli", "test-regen-cli":
v = &pb.TypedValue{
Value: &pb.TypedValue_AsciiVal{AsciiVal: val}}
case "p4_config":
b, err := ioutil.ReadFile(val)
if err != nil {
return nil, err
}
v = &pb.TypedValue{
Value: &pb.TypedValue_ProtoBytes{ProtoBytes: b}}
default:
return nil, fmt.Errorf("unexpected origin: %q", p.Origin)
}
return &pb.Update{Path: p, Val: v}, nil
}
// Operation describes an gNMI operation.
type Operation struct {
Type string
Origin string
Target string
Path []string
Val string
}
func newSetRequest(setOps []*Operation, exts ...*gnmi_ext.Extension) (*pb.SetRequest, error) {
req := &pb.SetRequest{}
for _, op := range setOps {
p, err := ParseGNMIElements(op.Path)
if err != nil {
return nil, err
}
p.Origin = op.Origin
// Target must apply to the entire SetRequest.
if op.Target != "" {
req.Prefix = &pb.Path{
Target: op.Target,
}
}
switch op.Type {
case "delete":
req.Delete = append(req.Delete, p)
case "update":
u, err := update(p, op.Val)
if err != nil {
return nil, err
}
req.Update = append(req.Update, u)
case "replace":
u, err := update(p, op.Val)
if err != nil {
return nil, err
}
req.Replace = append(req.Replace, u)
}
}
for _, ext := range exts {
req.Extension = append(req.Extension, ext)
}
return req, nil
}
// Set sends a SetRequest to the given ciena.
func Set(ctx context.Context, client pb.GNMIClient, setOps []*Operation,
exts ...*gnmi_ext.Extension) error {
req, err := newSetRequest(setOps, exts...)
if err != nil {
return err
}
resp, err := client.Set(ctx, req)
if err != nil {
return err
}
if resp.Message != nil && codes.Code(resp.Message.Code) != codes.OK {
return errors.New(resp.Message.Message)
}
return nil
}
// Subscribe sends a SubscribeRequest to the given ciena.
// Deprecated: Use SubscribeErr instead.
func Subscribe(ctx context.Context, client pb.GNMIClient, subscribeOptions *SubscribeOptions,
respChan chan<- *pb.SubscribeResponse, errChan chan<- error) {
defer close(errChan)
if err := SubscribeErr(ctx, client, subscribeOptions, respChan); err != nil {
errChan <- err
}
}
// SubscribeErr makes a gNMI.Subscribe call and writes the responses
// to the respChan. Before returning respChan will be closed.
func SubscribeErr(ctx context.Context, client pb.GNMIClient, subscribeOptions *SubscribeOptions,
respChan chan<- *pb.SubscribeResponse) error {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
defer close(respChan)
stream, err := client.Subscribe(ctx)
if err != nil {
return err
}
req, err := NewSubscribeRequest(subscribeOptions)
if err != nil {
return err
}
if err := stream.Send(req); err != nil {
return err
}
for {
resp, err := stream.Recv()
if err != nil {
if err == io.EOF {
return nil
}
return err
}
respChan <- resp
// For POLL subscriptions, initiate a poll request by pressing ENTER
if subscribeOptions.Mode == "poll" {
switch resp.Response.(type) {
case *pb.SubscribeResponse_SyncResponse:
fmt.Print("Press ENTER to send a poll request: ")
reader := bufio.NewReader(os.Stdin)
reader.ReadString('\n')
pollReq := &pb.SubscribeRequest{
Request: &pb.SubscribeRequest_Poll{
Poll: &pb.Poll{},
},
}
if err := stream.Send(pollReq); err != nil {
return err
}
}
}
}
}
// LogSubscribeResponse logs update responses to stderr.
func LogSubscribeResponse(response *pb.SubscribeResponse) error {
switch resp := response.Response.(type) {
case *pb.SubscribeResponse_Error:
return errors.New(resp.Error.Message)
case *pb.SubscribeResponse_SyncResponse:
if !resp.SyncResponse {
return errors.New("initial sync failed")
}
case *pb.SubscribeResponse_Update:
t := time.Unix(0, resp.Update.Timestamp).UTC()
prefix := StrPath(resp.Update.Prefix)
var target string
if t := resp.Update.Prefix.GetTarget(); t != "" {
target = "(" + t + ") "
}
for _, update := range resp.Update.Update {
fmt.Printf("[%s] %s%s = %s\n", t.Format(time.RFC3339Nano),
target,
path.Join(prefix, StrPath(update.Path)),
StrUpdateVal(update))
}
for _, del := range resp.Update.Delete {
fmt.Printf("[%s] %sDeleted %s\n", t.Format(time.RFC3339Nano),
target,
path.Join(prefix, StrPath(del)))
}
}
return nil
}