diff --git a/nucleus/cli-handling.go b/nucleus/cli-handling.go index 56efaff9f18cd46cc0ae4d2186b4bb13f25df876..e18c610d58d02d854330ff40df12426735312344 100644 --- a/nucleus/cli-handling.go +++ b/nucleus/cli-handling.go @@ -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 } diff --git a/nucleus/controller.go b/nucleus/controller.go index 24dac33249ba5e28fe6cfe907b27466213a51c09..7563da75460f613b1cd66ae4b7583cb6c6b0c751 100644 --- a/nucleus/controller.go +++ b/nucleus/controller.go @@ -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 { diff --git a/nucleus/southbound.go b/nucleus/southbound.go index a3aa5af682a41581b53ce03e69526a5e34454349..743c243263503b3b6ba57b3c9b271180bf54f97e 100644 --- a/nucleus/southbound.go +++ b/nucleus/southbound.go @@ -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 { } diff --git a/nucleus/southbound_test.go b/nucleus/southbound_test.go index 447696fa7cb6350f089bed728ea31b5ea01af477..04b7456fbcfd95fa881967e608da25956572b3c4 100644 --- a/nucleus/southbound_test.go +++ b/nucleus/southbound_test.go @@ -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 +}