Skip to content
Snippets Groups Projects
Commit e2bf1b8a authored by Fabian Seidl's avatar Fabian Seidl
Browse files

Merge branch 'develop' into 227-add-an-option-to-send-gnmi-subscribe-requests-via-sbi

parents 0284832d 1825264d
No related branches found
No related tags found
3 merge requests!376Add additional example application hostname-checker,!343Add basic application framework and example application to show interaction between events an NBI,!342Resolve "Add an option to send gNMI Subscribe requests via SBI"
Pipeline #109870 passed
Showing
with 3254 additions and 52 deletions
...@@ -54,7 +54,13 @@ containerlab-destroy: ...@@ -54,7 +54,13 @@ containerlab-destroy:
script: script:
- sudo containerlab destroy --topo ${CLAB_DIR}/${CLAB_NAME}.clab.yml - sudo containerlab destroy --topo ${CLAB_DIR}/${CLAB_NAME}.clab.yml
- docker volume rm -f ${CLAB_NAME}-volume - docker volume rm -f ${CLAB_NAME}-volume
- rm ${CLAB_DIR}/${CLAB_NAME}.clab.yml - echo ${CLAB_NAME}
- ls -la
- rm ${CLAB_DIR}/${CLAB_NAME}.clab.yml || true
- rm ${CLAB_DIR}/.${CLAB_NAME}.clab.yml.bak || true
- sudo rm -r ${CLAB_DIR}/clab-${CLAB_NAME} || true
- ls -la
allow_failure: true allow_failure: true
......
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.27.1
// protoc (unknown)
// source: gosdn/topology/link.proto
package topology
import (
_ "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options"
_ "google.golang.org/genproto/googleapis/api/annotations"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
_ "google.golang.org/protobuf/types/descriptorpb"
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)
)
type Link struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
SourceNode *Node `protobuf:"bytes,3,opt,name=sourceNode,proto3" json:"sourceNode,omitempty"`
TargetNode *Node `protobuf:"bytes,4,opt,name=targetNode,proto3" json:"targetNode,omitempty"`
SourcePort *Port `protobuf:"bytes,5,opt,name=sourcePort,proto3" json:"sourcePort,omitempty"`
TargetPort *Port `protobuf:"bytes,6,opt,name=targetPort,proto3" json:"targetPort,omitempty"`
}
func (x *Link) Reset() {
*x = Link{}
if protoimpl.UnsafeEnabled {
mi := &file_gosdn_topology_link_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Link) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Link) ProtoMessage() {}
func (x *Link) ProtoReflect() protoreflect.Message {
mi := &file_gosdn_topology_link_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 Link.ProtoReflect.Descriptor instead.
func (*Link) Descriptor() ([]byte, []int) {
return file_gosdn_topology_link_proto_rawDescGZIP(), []int{0}
}
func (x *Link) GetId() string {
if x != nil {
return x.Id
}
return ""
}
func (x *Link) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *Link) GetSourceNode() *Node {
if x != nil {
return x.SourceNode
}
return nil
}
func (x *Link) GetTargetNode() *Node {
if x != nil {
return x.TargetNode
}
return nil
}
func (x *Link) GetSourcePort() *Port {
if x != nil {
return x.SourcePort
}
return nil
}
func (x *Link) GetTargetPort() *Port {
if x != nil {
return x.TargetPort
}
return nil
}
var File_gosdn_topology_link_proto protoreflect.FileDescriptor
var file_gosdn_topology_link_proto_rawDesc = []byte{
0x0a, 0x19, 0x67, 0x6f, 0x73, 0x64, 0x6e, 0x2f, 0x74, 0x6f, 0x70, 0x6f, 0x6c, 0x6f, 0x67, 0x79,
0x2f, 0x6c, 0x69, 0x6e, 0x6b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0e, 0x67, 0x6f, 0x73,
0x64, 0x6e, 0x2e, 0x74, 0x6f, 0x70, 0x6f, 0x6c, 0x6f, 0x67, 0x79, 0x1a, 0x1c, 0x67, 0x6f, 0x6f,
0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69,
0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c,
0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72,
0x69, 0x70, 0x74, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x2e, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76,
0x32, 0x2f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61,
0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x67, 0x6f, 0x73,
0x64, 0x6e, 0x2f, 0x74, 0x6f, 0x70, 0x6f, 0x6c, 0x6f, 0x67, 0x79, 0x2f, 0x6e, 0x6f, 0x64, 0x65,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x67, 0x6f, 0x73, 0x64, 0x6e, 0x2f, 0x74, 0x6f,
0x70, 0x6f, 0x6c, 0x6f, 0x67, 0x79, 0x2f, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x22, 0x82, 0x02, 0x0a, 0x04, 0x4c, 0x69, 0x6e, 0x6b, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64,
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61,
0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x34,
0x0a, 0x0a, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01,
0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x73, 0x64, 0x6e, 0x2e, 0x74, 0x6f, 0x70, 0x6f, 0x6c,
0x6f, 0x67, 0x79, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x0a, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65,
0x4e, 0x6f, 0x64, 0x65, 0x12, 0x34, 0x0a, 0x0a, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x4e, 0x6f,
0x64, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x73, 0x64, 0x6e,
0x2e, 0x74, 0x6f, 0x70, 0x6f, 0x6c, 0x6f, 0x67, 0x79, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x0a,
0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x34, 0x0a, 0x0a, 0x73, 0x6f,
0x75, 0x72, 0x63, 0x65, 0x50, 0x6f, 0x72, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14,
0x2e, 0x67, 0x6f, 0x73, 0x64, 0x6e, 0x2e, 0x74, 0x6f, 0x70, 0x6f, 0x6c, 0x6f, 0x67, 0x79, 0x2e,
0x50, 0x6f, 0x72, 0x74, 0x52, 0x0a, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x50, 0x6f, 0x72, 0x74,
0x12, 0x34, 0x0a, 0x0a, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x50, 0x6f, 0x72, 0x74, 0x18, 0x06,
0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x73, 0x64, 0x6e, 0x2e, 0x74, 0x6f, 0x70,
0x6f, 0x6c, 0x6f, 0x67, 0x79, 0x2e, 0x50, 0x6f, 0x72, 0x74, 0x52, 0x0a, 0x74, 0x61, 0x72, 0x67,
0x65, 0x74, 0x50, 0x6f, 0x72, 0x74, 0x42, 0x34, 0x5a, 0x32, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x66,
0x62, 0x69, 0x2e, 0x68, 0x2d, 0x64, 0x61, 0x2e, 0x64, 0x65, 0x2f, 0x64, 0x61, 0x6e, 0x65, 0x74,
0x2f, 0x67, 0x6f, 0x73, 0x64, 0x6e, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x6f, 0x2f, 0x67, 0x6f,
0x73, 0x64, 0x6e, 0x2f, 0x74, 0x6f, 0x70, 0x6f, 0x6c, 0x6f, 0x67, 0x79, 0x62, 0x06, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x33,
}
var (
file_gosdn_topology_link_proto_rawDescOnce sync.Once
file_gosdn_topology_link_proto_rawDescData = file_gosdn_topology_link_proto_rawDesc
)
func file_gosdn_topology_link_proto_rawDescGZIP() []byte {
file_gosdn_topology_link_proto_rawDescOnce.Do(func() {
file_gosdn_topology_link_proto_rawDescData = protoimpl.X.CompressGZIP(file_gosdn_topology_link_proto_rawDescData)
})
return file_gosdn_topology_link_proto_rawDescData
}
var file_gosdn_topology_link_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_gosdn_topology_link_proto_goTypes = []interface{}{
(*Link)(nil), // 0: gosdn.topology.Link
(*Node)(nil), // 1: gosdn.topology.Node
(*Port)(nil), // 2: gosdn.topology.Port
}
var file_gosdn_topology_link_proto_depIdxs = []int32{
1, // 0: gosdn.topology.Link.sourceNode:type_name -> gosdn.topology.Node
1, // 1: gosdn.topology.Link.targetNode:type_name -> gosdn.topology.Node
2, // 2: gosdn.topology.Link.sourcePort:type_name -> gosdn.topology.Port
2, // 3: gosdn.topology.Link.targetPort:type_name -> gosdn.topology.Port
4, // [4:4] is the sub-list for method output_type
4, // [4:4] is the sub-list for method input_type
4, // [4:4] is the sub-list for extension type_name
4, // [4:4] is the sub-list for extension extendee
0, // [0:4] is the sub-list for field type_name
}
func init() { file_gosdn_topology_link_proto_init() }
func file_gosdn_topology_link_proto_init() {
if File_gosdn_topology_link_proto != nil {
return
}
file_gosdn_topology_node_proto_init()
file_gosdn_topology_port_proto_init()
if !protoimpl.UnsafeEnabled {
file_gosdn_topology_link_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Link); 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_gosdn_topology_link_proto_rawDesc,
NumEnums: 0,
NumMessages: 1,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_gosdn_topology_link_proto_goTypes,
DependencyIndexes: file_gosdn_topology_link_proto_depIdxs,
MessageInfos: file_gosdn_topology_link_proto_msgTypes,
}.Build()
File_gosdn_topology_link_proto = out.File
file_gosdn_topology_link_proto_rawDesc = nil
file_gosdn_topology_link_proto_goTypes = nil
file_gosdn_topology_link_proto_depIdxs = nil
}
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.27.1
// protoc (unknown)
// source: gosdn/topology/node.proto
package topology
import (
_ "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options"
_ "google.golang.org/genproto/googleapis/api/annotations"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
_ "google.golang.org/protobuf/types/descriptorpb"
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)
)
type Node struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
}
func (x *Node) Reset() {
*x = Node{}
if protoimpl.UnsafeEnabled {
mi := &file_gosdn_topology_node_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Node) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Node) ProtoMessage() {}
func (x *Node) ProtoReflect() protoreflect.Message {
mi := &file_gosdn_topology_node_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 Node.ProtoReflect.Descriptor instead.
func (*Node) Descriptor() ([]byte, []int) {
return file_gosdn_topology_node_proto_rawDescGZIP(), []int{0}
}
func (x *Node) GetId() string {
if x != nil {
return x.Id
}
return ""
}
func (x *Node) GetName() string {
if x != nil {
return x.Name
}
return ""
}
var File_gosdn_topology_node_proto protoreflect.FileDescriptor
var file_gosdn_topology_node_proto_rawDesc = []byte{
0x0a, 0x19, 0x67, 0x6f, 0x73, 0x64, 0x6e, 0x2f, 0x74, 0x6f, 0x70, 0x6f, 0x6c, 0x6f, 0x67, 0x79,
0x2f, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0e, 0x67, 0x6f, 0x73,
0x64, 0x6e, 0x2e, 0x74, 0x6f, 0x70, 0x6f, 0x6c, 0x6f, 0x67, 0x79, 0x1a, 0x1c, 0x67, 0x6f, 0x6f,
0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69,
0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c,
0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72,
0x69, 0x70, 0x74, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x2e, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76,
0x32, 0x2f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61,
0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x2a, 0x0a, 0x04, 0x4e,
0x6f, 0x64, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28,
0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x42, 0x34, 0x5a, 0x32, 0x63, 0x6f, 0x64, 0x65, 0x2e,
0x66, 0x62, 0x69, 0x2e, 0x68, 0x2d, 0x64, 0x61, 0x2e, 0x64, 0x65, 0x2f, 0x64, 0x61, 0x6e, 0x65,
0x74, 0x2f, 0x67, 0x6f, 0x73, 0x64, 0x6e, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x6f, 0x2f, 0x67,
0x6f, 0x73, 0x64, 0x6e, 0x2f, 0x74, 0x6f, 0x70, 0x6f, 0x6c, 0x6f, 0x67, 0x79, 0x62, 0x06, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_gosdn_topology_node_proto_rawDescOnce sync.Once
file_gosdn_topology_node_proto_rawDescData = file_gosdn_topology_node_proto_rawDesc
)
func file_gosdn_topology_node_proto_rawDescGZIP() []byte {
file_gosdn_topology_node_proto_rawDescOnce.Do(func() {
file_gosdn_topology_node_proto_rawDescData = protoimpl.X.CompressGZIP(file_gosdn_topology_node_proto_rawDescData)
})
return file_gosdn_topology_node_proto_rawDescData
}
var file_gosdn_topology_node_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_gosdn_topology_node_proto_goTypes = []interface{}{
(*Node)(nil), // 0: gosdn.topology.Node
}
var file_gosdn_topology_node_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_gosdn_topology_node_proto_init() }
func file_gosdn_topology_node_proto_init() {
if File_gosdn_topology_node_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_gosdn_topology_node_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Node); 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_gosdn_topology_node_proto_rawDesc,
NumEnums: 0,
NumMessages: 1,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_gosdn_topology_node_proto_goTypes,
DependencyIndexes: file_gosdn_topology_node_proto_depIdxs,
MessageInfos: file_gosdn_topology_node_proto_msgTypes,
}.Build()
File_gosdn_topology_node_proto = out.File
file_gosdn_topology_node_proto_rawDesc = nil
file_gosdn_topology_node_proto_goTypes = nil
file_gosdn_topology_node_proto_depIdxs = nil
}
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.27.1
// protoc (unknown)
// source: gosdn/topology/port.proto
package topology
import (
_ "github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options"
_ "google.golang.org/genproto/googleapis/api/annotations"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
_ "google.golang.org/protobuf/types/descriptorpb"
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)
)
type Configuration struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Ip string `protobuf:"bytes,1,opt,name=ip,proto3" json:"ip,omitempty"`
PrefixLength int64 `protobuf:"varint,2,opt,name=prefixLength,proto3" json:"prefixLength,omitempty"`
}
func (x *Configuration) Reset() {
*x = Configuration{}
if protoimpl.UnsafeEnabled {
mi := &file_gosdn_topology_port_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Configuration) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Configuration) ProtoMessage() {}
func (x *Configuration) ProtoReflect() protoreflect.Message {
mi := &file_gosdn_topology_port_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 Configuration.ProtoReflect.Descriptor instead.
func (*Configuration) Descriptor() ([]byte, []int) {
return file_gosdn_topology_port_proto_rawDescGZIP(), []int{0}
}
func (x *Configuration) GetIp() string {
if x != nil {
return x.Ip
}
return ""
}
func (x *Configuration) GetPrefixLength() int64 {
if x != nil {
return x.PrefixLength
}
return 0
}
type Port struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
Configuration *Configuration `protobuf:"bytes,3,opt,name=configuration,proto3" json:"configuration,omitempty"`
}
func (x *Port) Reset() {
*x = Port{}
if protoimpl.UnsafeEnabled {
mi := &file_gosdn_topology_port_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Port) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Port) ProtoMessage() {}
func (x *Port) ProtoReflect() protoreflect.Message {
mi := &file_gosdn_topology_port_proto_msgTypes[1]
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 Port.ProtoReflect.Descriptor instead.
func (*Port) Descriptor() ([]byte, []int) {
return file_gosdn_topology_port_proto_rawDescGZIP(), []int{1}
}
func (x *Port) GetId() string {
if x != nil {
return x.Id
}
return ""
}
func (x *Port) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *Port) GetConfiguration() *Configuration {
if x != nil {
return x.Configuration
}
return nil
}
var File_gosdn_topology_port_proto protoreflect.FileDescriptor
var file_gosdn_topology_port_proto_rawDesc = []byte{
0x0a, 0x19, 0x67, 0x6f, 0x73, 0x64, 0x6e, 0x2f, 0x74, 0x6f, 0x70, 0x6f, 0x6c, 0x6f, 0x67, 0x79,
0x2f, 0x70, 0x6f, 0x72, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0e, 0x67, 0x6f, 0x73,
0x64, 0x6e, 0x2e, 0x74, 0x6f, 0x70, 0x6f, 0x6c, 0x6f, 0x67, 0x79, 0x1a, 0x1c, 0x67, 0x6f, 0x6f,
0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69,
0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c,
0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72,
0x69, 0x70, 0x74, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x2e, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x6f, 0x70, 0x65, 0x6e, 0x61, 0x70, 0x69, 0x76,
0x32, 0x2f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61,
0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x43, 0x0a, 0x0d, 0x43,
0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x0e, 0x0a, 0x02,
0x69, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x70, 0x12, 0x22, 0x0a, 0x0c,
0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01,
0x28, 0x03, 0x52, 0x0c, 0x70, 0x72, 0x65, 0x66, 0x69, 0x78, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68,
0x22, 0x6f, 0x0a, 0x04, 0x50, 0x6f, 0x72, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01,
0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65,
0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x43, 0x0a, 0x0d,
0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20,
0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x67, 0x6f, 0x73, 0x64, 0x6e, 0x2e, 0x74, 0x6f, 0x70, 0x6f,
0x6c, 0x6f, 0x67, 0x79, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69,
0x6f, 0x6e, 0x52, 0x0d, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f,
0x6e, 0x42, 0x34, 0x5a, 0x32, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x66, 0x62, 0x69, 0x2e, 0x68, 0x2d,
0x64, 0x61, 0x2e, 0x64, 0x65, 0x2f, 0x64, 0x61, 0x6e, 0x65, 0x74, 0x2f, 0x67, 0x6f, 0x73, 0x64,
0x6e, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x67, 0x6f, 0x2f, 0x67, 0x6f, 0x73, 0x64, 0x6e, 0x2f, 0x74,
0x6f, 0x70, 0x6f, 0x6c, 0x6f, 0x67, 0x79, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_gosdn_topology_port_proto_rawDescOnce sync.Once
file_gosdn_topology_port_proto_rawDescData = file_gosdn_topology_port_proto_rawDesc
)
func file_gosdn_topology_port_proto_rawDescGZIP() []byte {
file_gosdn_topology_port_proto_rawDescOnce.Do(func() {
file_gosdn_topology_port_proto_rawDescData = protoimpl.X.CompressGZIP(file_gosdn_topology_port_proto_rawDescData)
})
return file_gosdn_topology_port_proto_rawDescData
}
var file_gosdn_topology_port_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_gosdn_topology_port_proto_goTypes = []interface{}{
(*Configuration)(nil), // 0: gosdn.topology.Configuration
(*Port)(nil), // 1: gosdn.topology.Port
}
var file_gosdn_topology_port_proto_depIdxs = []int32{
0, // 0: gosdn.topology.Port.configuration:type_name -> gosdn.topology.Configuration
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_gosdn_topology_port_proto_init() }
func file_gosdn_topology_port_proto_init() {
if File_gosdn_topology_port_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_gosdn_topology_port_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Configuration); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_gosdn_topology_port_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Port); 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_gosdn_topology_port_proto_rawDesc,
NumEnums: 0,
NumMessages: 2,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_gosdn_topology_port_proto_goTypes,
DependencyIndexes: file_gosdn_topology_port_proto_depIdxs,
MessageInfos: file_gosdn_topology_port_proto_msgTypes,
}.Build()
File_gosdn_topology_port_proto = out.File
file_gosdn_topology_port_proto_rawDesc = nil
file_gosdn_topology_port_proto_goTypes = nil
file_gosdn_topology_port_proto_depIdxs = nil
}
This diff is collapsed.
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
// source: gosdn/topology/topology.proto
/*
Package topology is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
*/
package topology
import (
"context"
"io"
"net/http"
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"github.com/grpc-ecosystem/grpc-gateway/v2/utilities"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/grpclog"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/proto"
)
// Suppress "imported and not used" errors
var _ codes.Code
var _ io.Reader
var _ status.Status
var _ = runtime.String
var _ = utilities.NewDoubleArray
var _ = metadata.Join
func request_TopologyService_AddLink_0(ctx context.Context, marshaler runtime.Marshaler, client TopologyServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq AddLinkRequest
var metadata runtime.ServerMetadata
newReader, berr := utilities.IOReaderFactory(req.Body)
if berr != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
}
if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.AddLink(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_TopologyService_AddLink_0(ctx context.Context, marshaler runtime.Marshaler, server TopologyServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq AddLinkRequest
var metadata runtime.ServerMetadata
newReader, berr := utilities.IOReaderFactory(req.Body)
if berr != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
}
if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.AddLink(ctx, &protoReq)
return msg, metadata, err
}
var (
filter_TopologyService_GetTopology_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
)
func request_TopologyService_GetTopology_0(ctx context.Context, marshaler runtime.Marshaler, client TopologyServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq GetTopologyRequest
var metadata runtime.ServerMetadata
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_TopologyService_GetTopology_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.GetTopology(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_TopologyService_GetTopology_0(ctx context.Context, marshaler runtime.Marshaler, server TopologyServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq GetTopologyRequest
var metadata runtime.ServerMetadata
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_TopologyService_GetTopology_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.GetTopology(ctx, &protoReq)
return msg, metadata, err
}
func request_TopologyService_UpdateLink_0(ctx context.Context, marshaler runtime.Marshaler, client TopologyServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq UpdateLinkRequest
var metadata runtime.ServerMetadata
newReader, berr := utilities.IOReaderFactory(req.Body)
if berr != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
}
if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.UpdateLink(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_TopologyService_UpdateLink_0(ctx context.Context, marshaler runtime.Marshaler, server TopologyServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq UpdateLinkRequest
var metadata runtime.ServerMetadata
newReader, berr := utilities.IOReaderFactory(req.Body)
if berr != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
}
if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.UpdateLink(ctx, &protoReq)
return msg, metadata, err
}
var (
filter_TopologyService_DeleteLink_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
)
func request_TopologyService_DeleteLink_0(ctx context.Context, marshaler runtime.Marshaler, client TopologyServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq DeleteLinkRequest
var metadata runtime.ServerMetadata
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_TopologyService_DeleteLink_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.DeleteLink(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_TopologyService_DeleteLink_0(ctx context.Context, marshaler runtime.Marshaler, server TopologyServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq DeleteLinkRequest
var metadata runtime.ServerMetadata
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_TopologyService_DeleteLink_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.DeleteLink(ctx, &protoReq)
return msg, metadata, err
}
// RegisterTopologyServiceHandlerServer registers the http handlers for service TopologyService to "mux".
// UnaryRPC :call TopologyServiceServer directly.
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterTopologyServiceHandlerFromEndpoint instead.
func RegisterTopologyServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server TopologyServiceServer) error {
mux.Handle("POST", pattern_TopologyService_AddLink_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/gosdn.topology.TopologyService/AddLink", runtime.WithHTTPPathPattern("/topology/create"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_TopologyService_AddLink_0(rctx, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_TopologyService_AddLink_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_TopologyService_GetTopology_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/gosdn.topology.TopologyService/GetTopology", runtime.WithHTTPPathPattern("/topology"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_TopologyService_GetTopology_0(rctx, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_TopologyService_GetTopology_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_TopologyService_UpdateLink_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/gosdn.topology.TopologyService/UpdateLink", runtime.WithHTTPPathPattern("/topology/update"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_TopologyService_UpdateLink_0(rctx, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_TopologyService_UpdateLink_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("DELETE", pattern_TopologyService_DeleteLink_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/gosdn.topology.TopologyService/DeleteLink", runtime.WithHTTPPathPattern("/topology/delete"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_TopologyService_DeleteLink_0(rctx, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_TopologyService_DeleteLink_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
// RegisterTopologyServiceHandlerFromEndpoint is same as RegisterTopologyServiceHandler but
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterTopologyServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
conn, err := grpc.Dial(endpoint, opts...)
if err != nil {
return err
}
defer func() {
if err != nil {
if cerr := conn.Close(); cerr != nil {
grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
}
return
}
go func() {
<-ctx.Done()
if cerr := conn.Close(); cerr != nil {
grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
}
}()
}()
return RegisterTopologyServiceHandler(ctx, mux, conn)
}
// RegisterTopologyServiceHandler registers the http handlers for service TopologyService to "mux".
// The handlers forward requests to the grpc endpoint over "conn".
func RegisterTopologyServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
return RegisterTopologyServiceHandlerClient(ctx, mux, NewTopologyServiceClient(conn))
}
// RegisterTopologyServiceHandlerClient registers the http handlers for service TopologyService
// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "TopologyServiceClient".
// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "TopologyServiceClient"
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
// "TopologyServiceClient" to call the correct interceptors.
func RegisterTopologyServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client TopologyServiceClient) error {
mux.Handle("POST", pattern_TopologyService_AddLink_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req, "/gosdn.topology.TopologyService/AddLink", runtime.WithHTTPPathPattern("/topology/create"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_TopologyService_AddLink_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_TopologyService_AddLink_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_TopologyService_GetTopology_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req, "/gosdn.topology.TopologyService/GetTopology", runtime.WithHTTPPathPattern("/topology"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_TopologyService_GetTopology_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_TopologyService_GetTopology_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_TopologyService_UpdateLink_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req, "/gosdn.topology.TopologyService/UpdateLink", runtime.WithHTTPPathPattern("/topology/update"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_TopologyService_UpdateLink_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_TopologyService_UpdateLink_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("DELETE", pattern_TopologyService_DeleteLink_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req, "/gosdn.topology.TopologyService/DeleteLink", runtime.WithHTTPPathPattern("/topology/delete"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_TopologyService_DeleteLink_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_TopologyService_DeleteLink_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
var (
pattern_TopologyService_AddLink_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"topology", "create"}, ""))
pattern_TopologyService_GetTopology_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0}, []string{"topology"}, ""))
pattern_TopologyService_UpdateLink_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"topology", "update"}, ""))
pattern_TopologyService_DeleteLink_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"topology", "delete"}, ""))
)
var (
forward_TopologyService_AddLink_0 = runtime.ForwardResponseMessage
forward_TopologyService_GetTopology_0 = runtime.ForwardResponseMessage
forward_TopologyService_UpdateLink_0 = runtime.ForwardResponseMessage
forward_TopologyService_DeleteLink_0 = runtime.ForwardResponseMessage
)
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
package topology
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
// TopologyServiceClient is the client API for TopologyService service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type TopologyServiceClient interface {
AddLink(ctx context.Context, in *AddLinkRequest, opts ...grpc.CallOption) (*AddLinkResponse, error)
GetTopology(ctx context.Context, in *GetTopologyRequest, opts ...grpc.CallOption) (*GetTopologyResponse, error)
UpdateLink(ctx context.Context, in *UpdateLinkRequest, opts ...grpc.CallOption) (*UpdateLinkResponse, error)
DeleteLink(ctx context.Context, in *DeleteLinkRequest, opts ...grpc.CallOption) (*DeleteLinkResponse, error)
}
type topologyServiceClient struct {
cc grpc.ClientConnInterface
}
func NewTopologyServiceClient(cc grpc.ClientConnInterface) TopologyServiceClient {
return &topologyServiceClient{cc}
}
func (c *topologyServiceClient) AddLink(ctx context.Context, in *AddLinkRequest, opts ...grpc.CallOption) (*AddLinkResponse, error) {
out := new(AddLinkResponse)
err := c.cc.Invoke(ctx, "/gosdn.topology.TopologyService/AddLink", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *topologyServiceClient) GetTopology(ctx context.Context, in *GetTopologyRequest, opts ...grpc.CallOption) (*GetTopologyResponse, error) {
out := new(GetTopologyResponse)
err := c.cc.Invoke(ctx, "/gosdn.topology.TopologyService/GetTopology", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *topologyServiceClient) UpdateLink(ctx context.Context, in *UpdateLinkRequest, opts ...grpc.CallOption) (*UpdateLinkResponse, error) {
out := new(UpdateLinkResponse)
err := c.cc.Invoke(ctx, "/gosdn.topology.TopologyService/UpdateLink", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *topologyServiceClient) DeleteLink(ctx context.Context, in *DeleteLinkRequest, opts ...grpc.CallOption) (*DeleteLinkResponse, error) {
out := new(DeleteLinkResponse)
err := c.cc.Invoke(ctx, "/gosdn.topology.TopologyService/DeleteLink", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// TopologyServiceServer is the server API for TopologyService service.
// All implementations must embed UnimplementedTopologyServiceServer
// for forward compatibility
type TopologyServiceServer interface {
AddLink(context.Context, *AddLinkRequest) (*AddLinkResponse, error)
GetTopology(context.Context, *GetTopologyRequest) (*GetTopologyResponse, error)
UpdateLink(context.Context, *UpdateLinkRequest) (*UpdateLinkResponse, error)
DeleteLink(context.Context, *DeleteLinkRequest) (*DeleteLinkResponse, error)
mustEmbedUnimplementedTopologyServiceServer()
}
// UnimplementedTopologyServiceServer must be embedded to have forward compatible implementations.
type UnimplementedTopologyServiceServer struct {
}
func (UnimplementedTopologyServiceServer) AddLink(context.Context, *AddLinkRequest) (*AddLinkResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method AddLink not implemented")
}
func (UnimplementedTopologyServiceServer) GetTopology(context.Context, *GetTopologyRequest) (*GetTopologyResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetTopology not implemented")
}
func (UnimplementedTopologyServiceServer) UpdateLink(context.Context, *UpdateLinkRequest) (*UpdateLinkResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method UpdateLink not implemented")
}
func (UnimplementedTopologyServiceServer) DeleteLink(context.Context, *DeleteLinkRequest) (*DeleteLinkResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method DeleteLink not implemented")
}
func (UnimplementedTopologyServiceServer) mustEmbedUnimplementedTopologyServiceServer() {}
// UnsafeTopologyServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to TopologyServiceServer will
// result in compilation errors.
type UnsafeTopologyServiceServer interface {
mustEmbedUnimplementedTopologyServiceServer()
}
func RegisterTopologyServiceServer(s grpc.ServiceRegistrar, srv TopologyServiceServer) {
s.RegisterService(&TopologyService_ServiceDesc, srv)
}
func _TopologyService_AddLink_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(AddLinkRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(TopologyServiceServer).AddLink(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/gosdn.topology.TopologyService/AddLink",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(TopologyServiceServer).AddLink(ctx, req.(*AddLinkRequest))
}
return interceptor(ctx, in, info, handler)
}
func _TopologyService_GetTopology_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetTopologyRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(TopologyServiceServer).GetTopology(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/gosdn.topology.TopologyService/GetTopology",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(TopologyServiceServer).GetTopology(ctx, req.(*GetTopologyRequest))
}
return interceptor(ctx, in, info, handler)
}
func _TopologyService_UpdateLink_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(UpdateLinkRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(TopologyServiceServer).UpdateLink(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/gosdn.topology.TopologyService/UpdateLink",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(TopologyServiceServer).UpdateLink(ctx, req.(*UpdateLinkRequest))
}
return interceptor(ctx, in, info, handler)
}
func _TopologyService_DeleteLink_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(DeleteLinkRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(TopologyServiceServer).DeleteLink(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/gosdn.topology.TopologyService/DeleteLink",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(TopologyServiceServer).DeleteLink(ctx, req.(*DeleteLinkRequest))
}
return interceptor(ctx, in, info, handler)
}
// TopologyService_ServiceDesc is the grpc.ServiceDesc for TopologyService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var TopologyService_ServiceDesc = grpc.ServiceDesc{
ServiceName: "gosdn.topology.TopologyService",
HandlerType: (*TopologyServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "AddLink",
Handler: _TopologyService_AddLink_Handler,
},
{
MethodName: "GetTopology",
Handler: _TopologyService_GetTopology_Handler,
},
{
MethodName: "UpdateLink",
Handler: _TopologyService_UpdateLink_Handler,
},
{
MethodName: "DeleteLink",
Handler: _TopologyService_DeleteLink_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "gosdn/topology/topology.proto",
}
...@@ -43,6 +43,9 @@ ...@@ -43,6 +43,9 @@
}, },
{ {
"name": "UserService" "name": "UserService"
},
{
"name": "TopologyService"
} }
], ],
"consumes": [ "consumes": [
...@@ -1037,6 +1040,138 @@ ...@@ -1037,6 +1040,138 @@
] ]
} }
}, },
"/topology": {
"get": {
"operationId": "TopologyService_GetTopology",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/topologyGetTopologyResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/googlerpcStatus"
}
}
},
"parameters": [
{
"name": "timestamp",
"in": "query",
"required": false,
"type": "string",
"format": "int64"
}
],
"tags": [
"TopologyService"
]
}
},
"/topology/create": {
"post": {
"operationId": "TopologyService_AddLink",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/topologyAddLinkResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/googlerpcStatus"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/topologyAddLinkRequest"
}
}
],
"tags": [
"TopologyService"
]
}
},
"/topology/delete": {
"delete": {
"operationId": "TopologyService_DeleteLink",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/topologyDeleteLinkResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/googlerpcStatus"
}
}
},
"parameters": [
{
"name": "timestamp",
"in": "query",
"required": false,
"type": "string",
"format": "int64"
},
{
"name": "id",
"in": "query",
"required": false,
"type": "string"
}
],
"tags": [
"TopologyService"
]
}
},
"/topology/update": {
"post": {
"operationId": "TopologyService_UpdateLink",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/topologyUpdateLinkResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/googlerpcStatus"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/topologyUpdateLinkRequest"
}
}
],
"tags": [
"TopologyService"
]
}
},
"/users": { "/users": {
"get": { "get": {
"summary": "Requests information about available users, requires login beforehand.\nRequires highest possible permissions.", "summary": "Requests information about available users, requires login beforehand.\nRequires highest possible permissions.",
...@@ -2584,6 +2719,27 @@ ...@@ -2584,6 +2719,27 @@
"default": "TYPE_UNSPECIFIED", "default": "TYPE_UNSPECIFIED",
"title": "Changed according to style guide:\nhttps://docs.buf.build/best-practices/style-guide#enums" "title": "Changed according to style guide:\nhttps://docs.buf.build/best-practices/style-guide#enums"
}, },
"gosdntopologyConfiguration": {
"type": "object",
"properties": {
"ip": {
"type": "string"
},
"prefixLength": {
"type": "string",
"format": "int64"
}
}
},
"gosdntopologyStatus": {
"type": "string",
"enum": [
"STATUS_UNSPECIFIED",
"STATUS_OK",
"STATUS_ERROR"
],
"default": "STATUS_UNSPECIFIED"
},
"pndApiOperation": { "pndApiOperation": {
"type": "string", "type": "string",
"enum": [ "enum": [
...@@ -3262,6 +3418,140 @@ ...@@ -3262,6 +3418,140 @@
} }
} }
}, },
"topologyAddLinkRequest": {
"type": "object",
"properties": {
"timestamp": {
"type": "string",
"format": "int64"
},
"link": {
"$ref": "#/definitions/topologyLink"
}
}
},
"topologyAddLinkResponse": {
"type": "object",
"properties": {
"timestamp": {
"type": "string",
"format": "int64"
},
"status": {
"$ref": "#/definitions/gosdntopologyStatus"
}
}
},
"topologyDeleteLinkResponse": {
"type": "object",
"properties": {
"timestamp": {
"type": "string",
"format": "int64"
},
"status": {
"$ref": "#/definitions/gosdntopologyStatus"
}
}
},
"topologyGetTopologyResponse": {
"type": "object",
"properties": {
"timestamp": {
"type": "string",
"format": "int64"
},
"status": {
"$ref": "#/definitions/gosdntopologyStatus"
},
"toplogy": {
"$ref": "#/definitions/topologyTopology"
}
}
},
"topologyLink": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"sourceNode": {
"$ref": "#/definitions/topologyNode"
},
"targetNode": {
"$ref": "#/definitions/topologyNode"
},
"sourcePort": {
"$ref": "#/definitions/topologyPort"
},
"targetPort": {
"$ref": "#/definitions/topologyPort"
}
}
},
"topologyNode": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
}
}
},
"topologyPort": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"configuration": {
"$ref": "#/definitions/gosdntopologyConfiguration"
}
}
},
"topologyTopology": {
"type": "object",
"properties": {
"links": {
"type": "array",
"items": {
"$ref": "#/definitions/topologyLink"
}
}
}
},
"topologyUpdateLinkRequest": {
"type": "object",
"properties": {
"timestamp": {
"type": "string",
"format": "int64"
},
"link": {
"$ref": "#/definitions/topologyLink"
}
}
},
"topologyUpdateLinkResponse": {
"type": "object",
"properties": {
"timestamp": {
"type": "string",
"format": "int64"
},
"status": {
"$ref": "#/definitions/gosdntopologyStatus"
}
}
},
"transportGnmiTransportOption": { "transportGnmiTransportOption": {
"type": "object", "type": "object",
"properties": { "properties": {
......
...@@ -4,7 +4,7 @@ deps: ...@@ -4,7 +4,7 @@ deps:
- remote: buf.build - remote: buf.build
owner: googleapis owner: googleapis
repository: googleapis repository: googleapis
commit: fdc236b6d1644b29a6161156ce08d8a2 commit: d8957b4333cc4523b3802d0af0e059e3
- remote: buf.build - remote: buf.build
owner: grpc-ecosystem owner: grpc-ecosystem
repository: grpc-gateway repository: grpc-gateway
......
syntax = "proto3";
package gosdn.topology;
import "google/api/annotations.proto";
import "google/protobuf/descriptor.proto";
import "protoc-gen-openapiv2/options/annotations.proto";
import "gosdn/topology/node.proto";
import "gosdn/topology/port.proto";
option go_package = "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/topology";
message Link {
string id = 1;
string name = 2;
Node sourceNode = 3;
Node targetNode = 4;
Port sourcePort = 5;
Port targetPort = 6;
}
syntax = "proto3";
package gosdn.topology;
import "google/api/annotations.proto";
import "google/protobuf/descriptor.proto";
import "protoc-gen-openapiv2/options/annotations.proto";
option go_package = "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/topology";
message Node {
string id = 1;
string name = 2;
}
syntax = "proto3";
package gosdn.topology;
import "google/api/annotations.proto";
import "google/protobuf/descriptor.proto";
import "protoc-gen-openapiv2/options/annotations.proto";
option go_package = "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/topology";
message Configuration {
string ip = 1;
int64 prefixLength = 2;
}
message Port {
string id = 1;
string name = 2;
Configuration configuration = 3;
}
syntax = "proto3";
package gosdn.topology;
import "google/api/annotations.proto";
import "google/protobuf/descriptor.proto";
import "protoc-gen-openapiv2/options/annotations.proto";
import "gosdn/topology/link.proto";
option go_package = "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/topology";
service TopologyService {
rpc AddLink(AddLinkRequest) returns (AddLinkResponse) {
option (google.api.http) = {
post: "/topology/create"
body: "*"
};
}
rpc GetTopology(GetTopologyRequest) returns (GetTopologyResponse) {
option (google.api.http) = {
get: "/topology"
};
}
rpc UpdateLink(UpdateLinkRequest) returns (UpdateLinkResponse) {
option (google.api.http) = {
post: "/topology/update"
body: "*"
};
}
rpc DeleteLink(DeleteLinkRequest) returns (DeleteLinkResponse) {
option (google.api.http) = {
delete: "/topology/delete"
};
}
}
enum Status {
STATUS_UNSPECIFIED = 0;
STATUS_OK = 1;
STATUS_ERROR = 2;
}
message Topology {
repeated Link links = 1;
}
message AddLinkRequest {
int64 timestamp = 1;
Link link = 2;
}
message AddLinkResponse {
int64 timestamp = 1;
Status status = 2;
}
message GetTopologyRequest {
int64 timestamp = 1;
}
message GetTopologyResponse {
int64 timestamp = 1;
Status status = 2;
Topology toplogy = 3;
}
message UpdateLinkRequest {
int64 timestamp = 1;
Link link = 2;
}
message UpdateLinkResponse {
int64 timestamp = 1;
Status status = 2;
}
message DeleteLinkRequest {
int64 timestamp = 1;
string id = 2;
}
message DeleteLinkResponse {
int64 timestamp = 1;
Status status = 2;
}
...@@ -23,6 +23,11 @@ import ( ...@@ -23,6 +23,11 @@ import (
"code.fbi.h-da.de/danet/gosdn/controller/nucleus" "code.fbi.h-da.de/danet/gosdn/controller/nucleus"
"code.fbi.h-da.de/danet/gosdn/controller/nucleus/util/proto" "code.fbi.h-da.de/danet/gosdn/controller/nucleus/util/proto"
rbacImpl "code.fbi.h-da.de/danet/gosdn/controller/rbac" rbacImpl "code.fbi.h-da.de/danet/gosdn/controller/rbac"
"code.fbi.h-da.de/danet/gosdn/controller/topology"
"code.fbi.h-da.de/danet/gosdn/controller/topology/links"
"code.fbi.h-da.de/danet/gosdn/controller/topology/nodes"
"code.fbi.h-da.de/danet/gosdn/controller/topology/ports"
"code.fbi.h-da.de/danet/gosdn/controller/topology/store"
"code.fbi.h-da.de/danet/gosdn/models/generated/openconfig" "code.fbi.h-da.de/danet/gosdn/models/generated/openconfig"
"github.com/google/uuid" "github.com/google/uuid"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
...@@ -145,7 +150,24 @@ func bootstrapUnitTest() { ...@@ -145,7 +150,24 @@ func bootstrapUnitTest() {
jwtManager := rbacImpl.NewJWTManager("", (10000 * time.Hour)) jwtManager := rbacImpl.NewJWTManager("", (10000 * time.Hour))
northbound := nbi.NewNBI(pndStore, userService, roleService, *jwtManager) nodeStore := store.NewGenericStore[nodes.Node]()
nodeService := nodes.NewNodeService(nodeStore, eventService)
portStore := store.NewGenericStore[ports.Port]()
portService := ports.NewPortService(portStore, eventService)
topoloyStore := store.NewGenericStore[links.Link]()
topologyService := topology.NewTopologyService(topoloyStore, nodeService, portService, eventService)
northbound := nbi.NewNBI(
pndStore,
userService,
roleService,
*jwtManager,
topologyService,
nodeService,
portService,
)
cpb.RegisterCoreServiceServer(s, northbound.Core) cpb.RegisterCoreServiceServer(s, northbound.Core)
ppb.RegisterPndServiceServer(s, northbound.Pnd) ppb.RegisterPndServiceServer(s, northbound.Pnd)
......
...@@ -25,6 +25,7 @@ import ( ...@@ -25,6 +25,7 @@ import (
ppb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/pnd" ppb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/pnd"
apb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/rbac" apb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/rbac"
spb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/southbound" spb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/southbound"
tpb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/topology"
"code.fbi.h-da.de/danet/gosdn/controller/config" "code.fbi.h-da.de/danet/gosdn/controller/config"
eventservice "code.fbi.h-da.de/danet/gosdn/controller/eventService" eventservice "code.fbi.h-da.de/danet/gosdn/controller/eventService"
"code.fbi.h-da.de/danet/gosdn/controller/interfaces/device" "code.fbi.h-da.de/danet/gosdn/controller/interfaces/device"
...@@ -34,6 +35,9 @@ import ( ...@@ -34,6 +35,9 @@ import (
nbi "code.fbi.h-da.de/danet/gosdn/controller/northbound/server" nbi "code.fbi.h-da.de/danet/gosdn/controller/northbound/server"
rbacImpl "code.fbi.h-da.de/danet/gosdn/controller/rbac" rbacImpl "code.fbi.h-da.de/danet/gosdn/controller/rbac"
"code.fbi.h-da.de/danet/gosdn/controller/store" "code.fbi.h-da.de/danet/gosdn/controller/store"
"code.fbi.h-da.de/danet/gosdn/controller/topology"
"code.fbi.h-da.de/danet/gosdn/controller/topology/nodes"
"code.fbi.h-da.de/danet/gosdn/controller/topology/ports"
eventInterfaces "code.fbi.h-da.de/danet/gosdn/controller/interfaces/event" eventInterfaces "code.fbi.h-da.de/danet/gosdn/controller/interfaces/event"
...@@ -45,15 +49,18 @@ var coreOnce sync.Once ...@@ -45,15 +49,18 @@ var coreOnce sync.Once
// Core is the representation of the controller's core // Core is the representation of the controller's core
type Core struct { type Core struct {
pndStore networkdomain.PndStore pndStore networkdomain.PndStore
userService rbac.UserService userService rbac.UserService
roleService rbac.RoleService roleService rbac.RoleService
httpServer *http.Server topologyService topology.Service
grpcServer *grpc.Server nodeService nodes.Service
nbi *nbi.NorthboundInterface portService ports.Service
eventService eventInterfaces.Service httpServer *http.Server
stopChan chan os.Signal grpcServer *grpc.Server
deviceWatcher *nucleus.DeviceWatcher nbi *nbi.NorthboundInterface
eventService eventInterfaces.Service
deviceWatcher *nucleus.DeviceWatcher
stopChan chan os.Signal
csbiClient cpb.CsbiServiceClient csbiClient cpb.CsbiServiceClient
} }
...@@ -72,10 +79,21 @@ func initialize() error { ...@@ -72,10 +79,21 @@ func initialize() error {
return err return err
} }
nodeService := nodes.NewNodeService(nodes.NewDatabaseNodeStore(), eventService)
portService := ports.NewPortService(ports.NewDatabasePortStore(), eventService)
c = &Core{ c = &Core{
pndStore: nucleus.NewPndStore(), pndStore: nucleus.NewPndStore(),
userService: rbacImpl.NewUserService(rbacImpl.NewUserStore(), eventService), userService: rbacImpl.NewUserService(rbacImpl.NewUserStore(), eventService),
roleService: rbacImpl.NewRoleService(rbacImpl.NewRoleStore(), eventService), roleService: rbacImpl.NewRoleService(rbacImpl.NewRoleStore(), eventService),
topologyService: topology.NewTopologyService(
topology.NewDatabaseTopologyStore(),
nodeService,
portService,
eventService,
),
nodeService: nodeService,
portService: portService,
eventService: eventService, eventService: eventService,
stopChan: make(chan os.Signal, 1), stopChan: make(chan os.Signal, 1),
} }
...@@ -129,7 +147,15 @@ func startGrpc() error { ...@@ -129,7 +147,15 @@ func startGrpc() error {
jwtManager := rbacImpl.NewJWTManager(config.JWTSecret, config.JWTDuration) jwtManager := rbacImpl.NewJWTManager(config.JWTSecret, config.JWTDuration)
setupGRPCServerWithCorrectSecurityLevel(jwtManager, c.userService, c.roleService) setupGRPCServerWithCorrectSecurityLevel(jwtManager, c.userService, c.roleService)
c.nbi = nbi.NewNBI(c.pndStore, c.userService, c.roleService, *jwtManager) c.nbi = nbi.NewNBI(
c.pndStore,
c.userService,
c.roleService,
*jwtManager,
c.topologyService,
c.nodeService,
c.portService,
)
pb.RegisterCoreServiceServer(c.grpcServer, c.nbi.Core) pb.RegisterCoreServiceServer(c.grpcServer, c.nbi.Core)
ppb.RegisterPndServiceServer(c.grpcServer, c.nbi.Pnd) ppb.RegisterPndServiceServer(c.grpcServer, c.nbi.Pnd)
...@@ -138,6 +164,8 @@ func startGrpc() error { ...@@ -138,6 +164,8 @@ func startGrpc() error {
apb.RegisterAuthServiceServer(c.grpcServer, c.nbi.Auth) apb.RegisterAuthServiceServer(c.grpcServer, c.nbi.Auth)
apb.RegisterUserServiceServer(c.grpcServer, c.nbi.User) apb.RegisterUserServiceServer(c.grpcServer, c.nbi.User)
apb.RegisterRoleServiceServer(c.grpcServer, c.nbi.Role) apb.RegisterRoleServiceServer(c.grpcServer, c.nbi.Role)
tpb.RegisterTopologyServiceServer(c.grpcServer, c.nbi.Topology)
go func() { go func() {
if err := c.grpcServer.Serve(lislisten); err != nil { if err := c.grpcServer.Serve(lislisten); err != nil {
log.Fatal(err) log.Fatal(err)
......
...@@ -18,6 +18,7 @@ import ( ...@@ -18,6 +18,7 @@ import (
cgw "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/core" cgw "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/core"
pgw "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/pnd" pgw "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/pnd"
agw "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/rbac" agw "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/rbac"
tgw "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/topology"
) )
var ( var (
...@@ -75,6 +76,11 @@ func run() error { ...@@ -75,6 +76,11 @@ func run() error {
return err return err
} }
err = tgw.RegisterTopologyServiceHandlerFromEndpoint(ctx, mux, *grpcServerEndpoint, opts)
if err != nil {
return err
}
// Set the HTTP server of core to the new server // Set the HTTP server of core to the new server
c.httpServer = &http.Server{Addr: ":8080", Handler: mux} c.httpServer = &http.Server{Addr: ":8080", Handler: mux}
// Start HTTP server (and proxy calls to gRPC server endpoint) // Start HTTP server (and proxy calls to gRPC server endpoint)
......
...@@ -58,27 +58,6 @@ func (_m *Device) GetModel() ygot.GoStruct { ...@@ -58,27 +58,6 @@ func (_m *Device) GetModel() ygot.GoStruct {
return r0 return r0
} }
// GetModelAsString provides a mock function with given fields:
func (_m *Device) GetModelAsString() (string, error) {
ret := _m.Called()
var r0 string
if rf, ok := ret.Get(0).(func() string); ok {
r0 = rf()
} else {
r0 = ret.Get(0).(string)
}
var r1 error
if rf, ok := ret.Get(1).(func() error); ok {
r1 = rf()
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// ID provides a mock function with given fields: // ID provides a mock function with given fields:
func (_m *Device) ID() uuid.UUID { func (_m *Device) ID() uuid.UUID {
ret := _m.Called() ret := _m.Called()
......
...@@ -4,6 +4,9 @@ import ( ...@@ -4,6 +4,9 @@ import (
"code.fbi.h-da.de/danet/gosdn/controller/interfaces/networkdomain" "code.fbi.h-da.de/danet/gosdn/controller/interfaces/networkdomain"
rbacInterfaces "code.fbi.h-da.de/danet/gosdn/controller/interfaces/rbac" rbacInterfaces "code.fbi.h-da.de/danet/gosdn/controller/interfaces/rbac"
"code.fbi.h-da.de/danet/gosdn/controller/rbac" "code.fbi.h-da.de/danet/gosdn/controller/rbac"
"code.fbi.h-da.de/danet/gosdn/controller/topology"
"code.fbi.h-da.de/danet/gosdn/controller/topology/nodes"
"code.fbi.h-da.de/danet/gosdn/controller/topology/ports"
"code.fbi.h-da.de/danet/gosdn/controller/metrics" "code.fbi.h-da.de/danet/gosdn/controller/metrics"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
...@@ -15,25 +18,36 @@ import ( ...@@ -15,25 +18,36 @@ import (
// NorthboundInterface is the representation of the // NorthboundInterface is the representation of the
// gRPC services used provided. // gRPC services used provided.
type NorthboundInterface struct { type NorthboundInterface struct {
Pnd *PndServer Pnd *PndServer
Core *Core Core *Core
Csbi *Csbi Csbi *Csbi
Sbi *SbiServer Sbi *SbiServer
Auth *Auth Auth *Auth
User *User User *User
Role *Role Role *Role
Topology *Topology
} }
// NewNBI receives a PndStore and returns a new gRPC *NorthboundInterface // NewNBI receives a PndStore and returns a new gRPC *NorthboundInterface
func NewNBI(pnds networkdomain.PndStore, users rbacInterfaces.UserService, roles rbacInterfaces.RoleService, jwt rbac.JWTManager) *NorthboundInterface { func NewNBI(
pnds networkdomain.PndStore,
users rbacInterfaces.UserService,
roles rbacInterfaces.RoleService,
jwt rbac.JWTManager,
topologyService topology.Service,
nodeService nodes.Service,
portService ports.Service,
) *NorthboundInterface {
return &NorthboundInterface{ return &NorthboundInterface{
Pnd: NewPndServer(pnds), Pnd: NewPndServer(pnds),
Core: NewCoreServer(pnds), Core: NewCoreServer(pnds),
Csbi: NewCsbiServer(pnds), Csbi: NewCsbiServer(pnds),
Sbi: NewSbiServer(pnds), Sbi: NewSbiServer(pnds),
Auth: NewAuthServer(&jwt, users), Auth: NewAuthServer(&jwt, users),
User: NewUserServer(&jwt, users), User: NewUserServer(&jwt, users),
Role: NewRoleServer(&jwt, roles), Role: NewRoleServer(&jwt, roles),
Topology: NewTopologyServer(topologyService, nodeService, portService),
} }
} }
......
package server
import (
"context"
"time"
topopb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/topology"
query "code.fbi.h-da.de/danet/gosdn/controller/store"
"code.fbi.h-da.de/danet/gosdn/controller/topology"
"code.fbi.h-da.de/danet/gosdn/controller/topology/links"
"code.fbi.h-da.de/danet/gosdn/controller/topology/nodes"
"code.fbi.h-da.de/danet/gosdn/controller/topology/ports"
"code.fbi.h-da.de/danet/gosdn/controller/topology/ports/configuration"
"github.com/google/uuid"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
// Topology holds a topologyService and represents a TopologyServiceServer.
type Topology struct {
topopb.UnimplementedTopologyServiceServer
topologyService topology.Service
nodeService nodes.Service
portService ports.Service
}
// NewTopologyServer receives a topologyService and returns a new TopologyServer.
func NewTopologyServer(
service topology.Service,
nodeService nodes.Service,
portService ports.Service,
) *Topology {
return &Topology{
topologyService: service,
nodeService: nodeService,
portService: portService,
}
}
// AddLink adds a new link to the topology
func (t *Topology) AddLink(ctx context.Context, request *topopb.AddLinkRequest) (*topopb.AddLinkResponse, error) {
sourceNode, sourcePort, err := t.ensureNodeAndPortExists(request.Link.SourceNode, request.Link.SourcePort)
if err != nil {
return nil, status.Errorf(codes.Aborted, "%v", err)
}
targetNode, targetPort, err := t.ensureNodeAndPortExists(request.Link.TargetNode, request.Link.TargetPort)
if err != nil {
return nil, status.Errorf(codes.Aborted, "%v", err)
}
link := links.Link{
ID: uuid.New(),
Name: request.Link.Name,
SourceNode: sourceNode,
SourcePort: sourcePort,
TargetNode: targetNode,
TargetPort: targetPort,
}
err = t.topologyService.AddLink(link)
if err != nil {
return nil, status.Errorf(codes.Aborted, "%v", err)
}
return &topopb.AddLinkResponse{
Timestamp: time.Now().UnixNano(),
Status: topopb.Status_STATUS_OK,
}, nil
}
// GetTopology returns the current topology in the form of all links
func (t *Topology) GetTopology(ctx context.Context, request *topopb.GetTopologyRequest) (*topopb.GetTopologyResponse, error) {
topo, err := t.topologyService.GetAll()
if err != nil {
return nil, status.Errorf(codes.Aborted, "%v", err)
}
topology := &topopb.Topology{}
for _, link := range topo {
topology.Links = append(topology.Links, &topopb.Link{
Id: link.ID.String(),
Name: link.Name,
SourceNode: &topopb.Node{
Id: link.SourceNode.ID.String(),
Name: link.SourceNode.Name,
},
SourcePort: &topopb.Port{
Id: link.SourcePort.ID.String(),
Name: link.SourcePort.Name,
Configuration: &topopb.Configuration{
Ip: link.SourcePort.Configuration.IP.String(),
PrefixLength: link.SourcePort.Configuration.PrefixLength,
},
},
TargetNode: &topopb.Node{
Id: link.TargetNode.ID.String(),
Name: link.TargetNode.Name,
},
TargetPort: &topopb.Port{
Id: link.TargetPort.ID.String(),
Name: link.TargetPort.Name,
Configuration: &topopb.Configuration{
Ip: link.TargetPort.Configuration.IP.String(),
PrefixLength: link.TargetPort.Configuration.PrefixLength,
},
},
})
}
return &topopb.GetTopologyResponse{
Timestamp: time.Now().UnixNano(),
Status: topopb.Status_STATUS_OK,
Toplogy: topology,
}, nil
}
// DeleteLink deletes a link
func (t *Topology) DeleteLink(ctx context.Context, request *topopb.DeleteLinkRequest) (*topopb.DeleteLinkResponse, error) {
linkID, err := uuid.Parse(request.Id)
if err != nil {
return &topopb.DeleteLinkResponse{
Timestamp: time.Now().UnixNano(),
Status: topopb.Status_STATUS_ERROR,
}, err
}
foundLink, err := t.topologyService.Get(query.Query{ID: linkID})
if err != nil {
return &topopb.DeleteLinkResponse{
Timestamp: time.Now().UnixNano(),
Status: topopb.Status_STATUS_ERROR,
}, err
}
err = t.topologyService.DeleteLink(foundLink)
if err != nil {
return &topopb.DeleteLinkResponse{
Timestamp: time.Now().UnixNano(),
Status: topopb.Status_STATUS_ERROR,
}, err
}
return &topopb.DeleteLinkResponse{
Timestamp: time.Now().UnixNano(),
Status: topopb.Status_STATUS_OK,
}, nil
}
func (t *Topology) ensureNodeAndPortExists(incomingNode *topopb.Node, incomingPort *topopb.Port) (nodes.Node, ports.Port, error) {
node, err := t.nodeService.EnsureExists(
nodes.Node{
ID: getExistingOrCreateNilUUIDFromString(incomingNode.Id),
Name: incomingNode.Name,
},
)
if err != nil {
return node, ports.Port{}, status.Errorf(codes.Aborted, "%v", err)
}
portConf, err := configuration.New(incomingPort.Configuration.Ip, incomingPort.Configuration.PrefixLength)
if err != nil {
return node, ports.Port{}, status.Errorf(codes.Aborted, "%v", err)
}
port, err := t.portService.EnsureExists(
ports.Port{
ID: getExistingOrCreateNilUUIDFromString(incomingPort.Id),
Name: incomingPort.Name,
Configuration: portConf,
},
)
if err != nil {
return nodes.Node{}, port, status.Errorf(codes.Aborted, "%v", err)
}
return node, port, nil
}
func getExistingOrCreateNilUUIDFromString(id string) uuid.UUID {
if len(id) == 0 {
return uuid.Nil
}
parsedID, err := uuid.Parse(id)
if err != nil {
return uuid.Nil
}
return parsedID
}
package server
import (
"context"
"reflect"
"testing"
apb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/topology"
eventservice "code.fbi.h-da.de/danet/gosdn/controller/eventService"
"code.fbi.h-da.de/danet/gosdn/controller/topology"
"code.fbi.h-da.de/danet/gosdn/controller/topology/links"
"code.fbi.h-da.de/danet/gosdn/controller/topology/nodes"
"code.fbi.h-da.de/danet/gosdn/controller/topology/ports"
"code.fbi.h-da.de/danet/gosdn/controller/topology/ports/configuration"
"code.fbi.h-da.de/danet/gosdn/controller/topology/store"
"github.com/google/uuid"
)
func getTestNodeService() nodes.Service {
eventService := eventservice.NewMockEventService()
nodeStore := store.NewGenericStore[nodes.Node]()
nodeService := nodes.NewNodeService(nodeStore, eventService)
return nodeService
}
func getTestPortService() ports.Service {
eventService := eventservice.NewMockEventService()
portStore := store.NewGenericStore[ports.Port]()
portService := ports.NewPortService(portStore, eventService)
return portService
}
func getTestTopologyService() topology.Service {
eventService := eventservice.NewMockEventService()
nodeStore := store.NewGenericStore[nodes.Node]()
nodeService := nodes.NewNodeService(nodeStore, eventService)
portStore := store.NewGenericStore[ports.Port]()
portService := ports.NewPortService(portStore, eventService)
linkStore := store.NewGenericStore[links.Link]()
topologyService := topology.NewTopologyService(linkStore, nodeService, portService, eventService)
return topologyService
}
func getTestTopologyServer(
t *testing.T,
nodesToAdd []nodes.Node,
portsToAdd []ports.Port,
linksToAdd []links.Link,
) *Topology {
eventService := eventservice.NewMockEventService()
nodeStore := getTestStoreWithNodes(t, nodesToAdd)
nodeService := nodes.NewNodeService(nodeStore, eventService)
portStore := getTestStoreWithPorts(t, portsToAdd)
portService := ports.NewPortService(portStore, eventService)
linkStore := getTestStoreWithLinks(t, linksToAdd)
topologyService := topology.NewTopologyService(linkStore, nodeService, portService, eventService)
s := NewTopologyServer(topologyService, nodeService, portService)
return s
}
func getTestSourceNode() nodes.Node {
return nodes.Node{
ID: uuid.MustParse("44fb4aa4-c53c-4cf9-a081-5aabc61c7610"),
Name: "Test-Source-Node",
}
}
func getTestTargetNode() nodes.Node {
return nodes.Node{
ID: uuid.MustParse("44fb4aa4-c53c-4cf9-a081-5aabc61c7612"),
Name: "Test-Target-Node",
}
}
func getTestPortIPConfiguration() configuration.IPConfig {
config, _ := configuration.New("10.13.37.0", 24)
return config
}
func getTestSourcePort() ports.Port {
return ports.Port{
ID: uuid.MustParse("1fa479e7-d393-4d45-822d-485cc1f05fce"),
Name: "Test-Source-Port",
Configuration: getTestPortIPConfiguration(),
}
}
func getTestTargetPort() ports.Port {
return ports.Port{
ID: uuid.MustParse("1fa479e7-d393-4d45-822d-485cc1f05fc2"),
Name: "Test-Target-Port",
Configuration: getTestPortIPConfiguration(),
}
}
func getTestLinkInternal() links.Link {
return links.Link{
ID: uuid.MustParse("5eb474f1-428e-4503-ba68-dcf9bef53467"),
Name: "Test-Link",
SourceNode: getTestSourceNode(),
TargetNode: getTestTargetNode(),
SourcePort: getTestSourcePort(),
TargetPort: getTestTargetPort(),
}
}
func getTestStoreWithLinks(t *testing.T, nodes []links.Link) topology.Store {
store := store.NewGenericStore[links.Link]()
for _, node := range nodes {
err := store.Add(node)
if err != nil {
t.Fatalf("failed to prepare test store while adding node: %v", err)
}
}
return store
}
func getTestStoreWithNodes(t *testing.T, nodesToAdd []nodes.Node) nodes.Store {
store := store.NewGenericStore[nodes.Node]()
for _, node := range nodesToAdd {
err := store.Add(node)
if err != nil {
t.Fatalf("failed to prepare test store while adding node: %v", err)
}
}
return store
}
func getTestStoreWithPorts(t *testing.T, portsToAdd []ports.Port) ports.Store {
store := store.NewGenericStore[ports.Port]()
for _, port := range portsToAdd {
err := store.Add(port)
if err != nil {
t.Fatalf("failed to prepare test store while adding port: %v", err)
}
}
return store
}
func getTestLink() *apb.Link {
return &apb.Link{
Name: "test-link",
SourceNode: &apb.Node{
Name: "test-source-node",
},
SourcePort: &apb.Port{
Name: "test-source-port",
Configuration: &apb.Configuration{
Ip: "10.13.37.0",
PrefixLength: 24,
},
},
TargetNode: &apb.Node{
Name: "test-target-node",
},
TargetPort: &apb.Port{
Name: "test-target-port",
Configuration: &apb.Configuration{
Ip: "10.13.38.0",
PrefixLength: 24,
},
},
}
}
func TestNewTopologyServer(t *testing.T) {
type args struct {
service topology.Service
nodeService nodes.Service
portService ports.Service
}
tests := []struct {
name string
args args
want *Topology
}{
{
name: "should create a new topology service",
args: args{
service: getTestTopologyService(),
nodeService: getTestNodeService(),
portService: getTestPortService(),
},
want: &Topology{
topologyService: getTestTopologyService(),
nodeService: getTestNodeService(),
portService: getTestPortService(),
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := NewTopologyServer(tt.args.service, tt.args.nodeService, tt.args.portService); !reflect.DeepEqual(got, tt.want) {
t.Errorf("NewTopologyServer() = %v, want %v", got, tt.want)
}
})
}
}
func TestTopology_AddLink(t *testing.T) {
type fields struct {
ports []ports.Port
nodes []nodes.Node
links []links.Link
}
type args struct {
ctx context.Context
request *apb.AddLinkRequest
}
tests := []struct {
name string
fields fields
args args
want *apb.AddLinkResponse
wantErr bool
}{
{
name: "should add a new link",
fields: fields{
ports: []ports.Port{},
nodes: []nodes.Node{},
links: []links.Link{},
},
args: args{
ctx: context.TODO(),
request: &apb.AddLinkRequest{
Link: getTestLink(),
},
},
want: &apb.AddLinkResponse{
Status: apb.Status_STATUS_OK,
},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
tr := getTestTopologyServer(t, tt.fields.nodes, tt.fields.ports, tt.fields.links)
got, err := tr.AddLink(tt.args.ctx, tt.args.request)
if (err != nil) != tt.wantErr {
t.Errorf("Topology.AddLink() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got.Status, tt.want.Status) {
t.Errorf("Topology.AddLink() = %v, want %v", got, tt.want)
}
})
}
}
func TestTopology_GetTopology(t *testing.T) {
type fields struct {
ports []ports.Port
nodes []nodes.Node
links []links.Link
}
type args struct {
ctx context.Context
request *apb.GetTopologyRequest
}
tests := []struct {
name string
fields fields
args args
want *apb.GetTopologyResponse
wantErr bool
}{
{
name: "should add a new link",
fields: fields{
ports: []ports.Port{getTestSourcePort(), getTestTargetPort()},
nodes: []nodes.Node{getTestSourceNode(), getTestTargetNode()},
links: []links.Link{getTestLinkInternal()},
},
args: args{
ctx: context.TODO(),
request: &apb.GetTopologyRequest{},
},
want: &apb.GetTopologyResponse{
Status: apb.Status_STATUS_OK,
Toplogy: &apb.Topology{
Links: []*apb.Link{
{
Id: "5eb474f1-428e-4503-ba68-dcf9bef53467",
Name: "Test-Link",
SourceNode: &apb.Node{
Id: "44fb4aa4-c53c-4cf9-a081-5aabc61c7610",
Name: "Test-Source-Node",
},
SourcePort: &apb.Port{
Id: "1fa479e7-d393-4d45-822d-485cc1f05fce",
Name: "Test-Source-Port",
Configuration: &apb.Configuration{
Ip: "10.13.37.0",
PrefixLength: 24,
},
},
TargetNode: &apb.Node{
Id: "44fb4aa4-c53c-4cf9-a081-5aabc61c7612",
Name: "Test-Target-Node",
},
TargetPort: &apb.Port{
Id: "1fa479e7-d393-4d45-822d-485cc1f05fc2",
Name: "Test-Target-Port",
Configuration: &apb.Configuration{
Ip: "10.13.37.0",
PrefixLength: 24,
},
},
},
},
},
},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
tr := getTestTopologyServer(t, tt.fields.nodes, tt.fields.ports, tt.fields.links)
got, err := tr.GetTopology(tt.args.ctx, tt.args.request)
if (err != nil) != tt.wantErr {
t.Errorf("Topology.GetTopology() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got.Toplogy, tt.want.Toplogy) {
t.Errorf("Topology.GetTopology() = %v, want %v", got.Toplogy, tt.want.Toplogy)
}
})
}
}
func TestTopology_DeleteLink(t *testing.T) {
type fields struct {
ports []ports.Port
nodes []nodes.Node
links []links.Link
}
type args struct {
ctx context.Context
request *apb.DeleteLinkRequest
}
tests := []struct {
name string
fields fields
args args
want *apb.DeleteLinkResponse
wantErr bool
}{
{
name: "should add a new link",
fields: fields{
ports: []ports.Port{getTestSourcePort(), getTestTargetPort()},
nodes: []nodes.Node{getTestSourceNode(), getTestTargetNode()},
links: []links.Link{getTestLinkInternal()},
},
args: args{
ctx: context.TODO(),
request: &apb.DeleteLinkRequest{
Id: "5eb474f1-428e-4503-ba68-dcf9bef53467",
},
},
want: &apb.DeleteLinkResponse{
Status: apb.Status_STATUS_OK,
},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
tr := getTestTopologyServer(t, tt.fields.nodes, tt.fields.ports, tt.fields.links)
got, err := tr.DeleteLink(tt.args.ctx, tt.args.request)
if (err != nil) != tt.wantErr {
t.Errorf("Topology.DeleteLink() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got.Status, tt.want.Status) {
t.Errorf("Topology.DeleteLink() = %v, want %v", got, tt.want)
}
gotAfterDelete, err := tr.GetTopology(tt.args.ctx, &apb.GetTopologyRequest{})
if (err != nil) != tt.wantErr {
t.Errorf("Topology.GetTopology() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(gotAfterDelete.Toplogy, &apb.Topology{}) {
t.Errorf("Topology.GetTopology() = %v, want %v", got, tt.want)
}
})
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment