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

small cli-handling changes

parent 3b086065
No related branches found
No related tags found
3 merge requests!97Resolve "PND handling via CLI and database",!91"Overhaul Architecture",!90Develop
...@@ -166,6 +166,7 @@ func (s *server) CreatePND(ctx context.Context, in *pb.CreatePNDRequest) (*pb.Cr ...@@ -166,6 +166,7 @@ func (s *server) CreatePND(ctx context.Context, in *pb.CreatePNDRequest) (*pb.Cr
} }
func (s *server) GetAllPNDs(ctx context.Context, in *emptypb.Empty) (*pb.AllPNDsReply, error) { func (s *server) GetAllPNDs(ctx context.Context, in *emptypb.Empty) (*pb.AllPNDsReply, error) {
log.Info("Received: Get all PNDs")
var pnds []*pb.PND var pnds []*pb.PND
for uuidPND, pnd := range s.core.principalNetworkDomains { for uuidPND, pnd := range s.core.principalNetworkDomains {
var devices []*pb.Device var devices []*pb.Device
...@@ -189,6 +190,7 @@ func (s *server) GetAllPNDs(ctx context.Context, in *emptypb.Empty) (*pb.AllPNDs ...@@ -189,6 +190,7 @@ func (s *server) GetAllPNDs(ctx context.Context, in *emptypb.Empty) (*pb.AllPNDs
} }
func (s *server) AddDevice(ctx context.Context, in *pb.AddDeviceRequest) (*pb.AddDeviceReply, error) { func (s *server) AddDevice(ctx context.Context, in *pb.AddDeviceRequest) (*pb.AddDeviceReply, error) {
path := viper.GetString("pnd.path")
uuidPND, err := uuid.Parse(in.UuidPND) uuidPND, err := uuid.Parse(in.UuidPND)
pnd := s.core.principalNetworkDomains[uuidPND] pnd := s.core.principalNetworkDomains[uuidPND]
...@@ -204,5 +206,8 @@ func (s *server) AddDevice(ctx context.Context, in *pb.AddDeviceRequest) (*pb.Ad ...@@ -204,5 +206,8 @@ func (s *server) AddDevice(ctx context.Context, in *pb.AddDeviceRequest) (*pb.Ad
} }
devicesMap := pnd.(*pndImplementation).Devices devicesMap := pnd.(*pndImplementation).Devices
devicesMap[newDevice.Uuid] = newDevice devicesMap[newDevice.Uuid] = newDevice
if err := s.core.savePNDs(path); err != nil {
log.Info(err)
}
return &pb.AddDeviceReply{Message: "Added new Device: " + newDevice.Uuid.String()}, err return &pb.AddDeviceReply{Message: "Added new Device: " + newDevice.Uuid.String()}, err
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment