Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package api
import (
"context"
"errors"
"time"
pb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/core"
nbi "code.fbi.h-da.de/danet/gosdn/controller/northbound/client"
)
// AddPnd takes a name, description and SBI UUID to create a new
// PrincipalNetworkDomain on the controller
func AddPnd(ctx context.Context, addr, name, description, sbi string) (*pb.CreatePndListResponse, error) {
coreClient, err := nbi.CoreClient(addr, dialOptions...)
if err != nil {
return nil, err
}
req := &pb.CreatePndListRequest{
Timestamp: time.Now().UnixNano(),
Pnd: []*pb.PndCreateProperties{
{
Name: name,
Description: description,
Sbi: sbi,
},
},
}
return coreClient.CreatePndList(ctx, req)
}
// GetPnd requests one PrincipalNetworkDomain from the
// controller.
func GetPnd(ctx context.Context, addr string, args ...string) (*pb.GetPndResponse, error) {
coreClient, err := nbi.CoreClient(addr, dialOptions...)
if err != nil {
return nil, err
}
if len(args) <= 0 {
return nil, errors.New("not enough arguments")
}
req := &pb.GetPndRequest{
Timestamp: time.Now().UnixNano(),
Pid: args,
}
return coreClient.GetPnd(ctx, req)
}
// GetPnds requests all PrincipalNetworkDomains from the
// controller.
func GetPnds(ctx context.Context, addr string, args ...string) (*pb.GetPndListResponse, error) {
coreClient, err := nbi.CoreClient(addr, dialOptions...)
if err != nil {
return nil, err
}
if len(args) <= 0 {
return nil, errors.New("not enough arguments")
}
req := &pb.GetPndListRequest{
Timestamp: time.Now().UnixNano(),
}
return coreClient.GetPndList(ctx, req)
}
// DeletePnd requests a deletion of the provided PND.
func DeletePnd(ctx context.Context, addr string, pid string) (*pb.DeletePndResponse, error) {
coreClient, err := nbi.CoreClient(addr, dialOptions...)
if err != nil {
return nil, err
}
req := &pb.DeletePndRequest{
Timestamp: time.Now().UnixNano(),
Pid: pid,
}
return coreClient.DeletePnd(ctx, req)
}