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
No related branches found
No related tags found
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 ...@@ -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) { func (s *server) CreatePND(ctx context.Context, in *pb.PNDRequest) (*pb.PNDReply, error) {
log.Info("Received: ", in.GetName()) log.Info("Received: ", in.GetName())
path := viper.GetString("pnd.path") path := viper.GetString("pnd.path")
//TODO: change sbi sbi := &OpenConfig{}
s.core.principalNetworkDomains[uuid.New()] = NewPND(in.GetName(), in.GetDescription(), s.core.southboundInterfaces["test"]) id := uuid.New()
s.core.savePNDs(path) s.core.principalNetworkDomains[id] = NewPND(in.GetName(), in.GetDescription(), sbi)
return &pb.PNDReply{Message: "Created new PND: " + in.GetName()}, nil 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) { ...@@ -35,6 +35,7 @@ func (c *Core) Initialize(IsRunningChannel chan bool) {
} }
path := viper.GetString("pnd.path") path := viper.GetString("pnd.path")
gob.Register(&pndImplementation{}) gob.Register(&pndImplementation{})
gob.Register(&OpenConfig{})
c.AttachDatabase() c.AttachDatabase()
if err := c.loadPNDs(path); err != nil { if err := c.loadPNDs(path); err != nil {
...@@ -50,7 +51,7 @@ func (c *Core) AttachDatabase() { ...@@ -50,7 +51,7 @@ func (c *Core) AttachDatabase() {
} }
// TODO: the load and save functions for pnds are just temporary and should be // 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 // SavePNDs imports the PNDs from last session
func (c *Core) savePNDs(path string) error { func (c *Core) savePNDs(path string) error {
......
...@@ -10,7 +10,7 @@ type Tapi struct { ...@@ -10,7 +10,7 @@ type Tapi struct {
} }
type OpenConfig struct { type OpenConfig struct {
transport Transport Transport Transport
} }
func (oc *OpenConfig) SbiIdentifier() string { func (oc *OpenConfig) SbiIdentifier() string {
...@@ -18,7 +18,7 @@ func (oc *OpenConfig) SbiIdentifier() string { ...@@ -18,7 +18,7 @@ func (oc *OpenConfig) SbiIdentifier() string {
} }
func (oc *OpenConfig) OpenconfigInterfaces(device Device) { func (oc *OpenConfig) OpenconfigInterfaces(device Device) {
resp, err := oc.transport.Get(nil, nil...) resp, err := oc.Transport.Get(nil, nil...)
if err != nil { if err != nil {
} }
......
...@@ -16,7 +16,7 @@ func TestOpenConfig_SbiIdentifier(t *testing.T) { ...@@ -16,7 +16,7 @@ func TestOpenConfig_SbiIdentifier(t *testing.T) {
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
oc := &OpenConfig{ oc := &OpenConfig{
transport: tt.fields.transport, Transport: tt.fields.transport,
} }
if got := oc.SbiIdentifier(); got != tt.want { if got := oc.SbiIdentifier(); got != tt.want {
t.Errorf("SbiIdentifier() = %v, want %v", got, tt.want) t.Errorf("SbiIdentifier() = %v, want %v", got, tt.want)
...@@ -42,9 +42,9 @@ func TestOpenConfig_OpenconfigInterfaces(t *testing.T) { ...@@ -42,9 +42,9 @@ func TestOpenConfig_OpenconfigInterfaces(t *testing.T) {
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
oc := &OpenConfig{ oc := &OpenConfig{
transport: tt.fields.transport, Transport: tt.fields.transport,
} }
oc.OpenconfigInterfaces(tt.args.device) 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