Skip to content
Snippets Groups Projects
Commit 1bfe01d6 authored by Malte Bauch's avatar Malte Bauch
Browse files

updated southbound and nucleus/controller

- southbound to work with gob
- controller load/save pnd functions
parent 5c920a6f
Branches
Tags
3 merge requests!97Resolve "PND handling via CLI and database",!91"Overhaul Architecture",!90Develop
......@@ -156,8 +156,11 @@ func (s *server) TAPIGetLink(ctx context.Context, in *pb.TAPIRequest) (*pb.TAPIR
func (s *server) CreatePND(ctx context.Context, in *pb.PNDRequest) (*pb.PNDReply, error) {
log.Info("Received: ", in.GetName())
path := viper.GetString("pnd.path")
//TODO: change sbi
s.core.principalNetworkDomains[uuid.New()] = NewPND(in.GetName(), in.GetDescription(), s.core.southboundInterfaces["test"])
s.core.savePNDs(path)
return &pb.PNDReply{Message: "Created new PND: " + in.GetName()}, nil
sbi := &OpenConfig{}
id := uuid.New()
s.core.principalNetworkDomains[id] = NewPND(in.GetName(), in.GetDescription(), sbi)
if err := s.core.savePNDs(path); err != nil {
log.Info(err)
}
return &pb.PNDReply{Message: "Created new PND: " + id.String()}, nil
}
......@@ -35,6 +35,7 @@ func (c *Core) Initialize(IsRunningChannel chan bool) {
}
path := viper.GetString("pnd.path")
gob.Register(&pndImplementation{})
gob.Register(&OpenConfig{})
c.AttachDatabase()
if err := c.loadPNDs(path); err != nil {
......@@ -50,7 +51,7 @@ func (c *Core) AttachDatabase() {
}
// TODO: the load and save functions for pnds are just temporary and should be
// moved to the database
// moved to the database
// SavePNDs imports the PNDs from last session
func (c *Core) savePNDs(path string) error {
......
......@@ -10,7 +10,7 @@ type Tapi struct {
}
type OpenConfig struct {
transport Transport
Transport Transport
}
func (oc *OpenConfig) SbiIdentifier() string {
......@@ -18,7 +18,7 @@ func (oc *OpenConfig) SbiIdentifier() string {
}
func (oc *OpenConfig) OpenconfigInterfaces(device Device) {
resp, err := oc.transport.Get(nil, nil...)
resp, err := oc.Transport.Get(nil, nil...)
if err != nil {
}
......
......@@ -16,7 +16,7 @@ func TestOpenConfig_SbiIdentifier(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
oc := &OpenConfig{
transport: tt.fields.transport,
Transport: tt.fields.transport,
}
if got := oc.SbiIdentifier(); got != tt.want {
t.Errorf("SbiIdentifier() = %v, want %v", got, tt.want)
......@@ -42,9 +42,9 @@ func TestOpenConfig_OpenconfigInterfaces(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
oc := &OpenConfig{
transport: tt.fields.transport,
Transport: tt.fields.transport,
}
oc.OpenconfigInterfaces(tt.args.device)
})
}
}
\ No newline at end of file
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment