Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Draft] System.Setpackage implementation. #337

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 28 additions & 17 deletions gnmi_server/gnoi.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,17 @@ func (srv *SystemServer) Ping(req *gnoi_system_pb.PingRequest, rs gnoi_system_pb
log.V(1).Info("gNOI: Ping")
return status.Errorf(codes.Unimplemented, "")
}

func (src *SystemServer) SetPackage(rs gnoi_system_pb.System_SetPackageServer) error {
ctx := rs.Context()
_, err := authenticate(srv.config, ctx)
if err != nil {
return err
}
log.V(1).Info("gNOI: SetPackage")
return status.Errorf(codes.Unimplemented, "")
}

func (srv *SystemServer) Traceroute(req *gnoi_system_pb.TracerouteRequest, rs gnoi_system_pb.System_TracerouteServer) error {
ctx := rs.Context()
_, err := authenticate(srv.config, ctx)
Expand Down Expand Up @@ -286,7 +297,7 @@ func (srv *Server) Authenticate(ctx context.Context, req *spb_jwt.AuthenticateRe
return &spb_jwt.AuthenticateResponse{Token: tokenResp(req.Username, roles)}, nil
}
}

}
return nil, status.Errorf(codes.PermissionDenied, "Invalid Username or Password")

Expand Down Expand Up @@ -314,7 +325,7 @@ func (srv *Server) Refresh(ctx context.Context, req *spb_jwt.RefreshRequest) (*s
if time.Unix(claims.ExpiresAt, 0).Sub(time.Now()) > JwtRefreshInt {
return nil, status.Errorf(codes.InvalidArgument, "Invalid JWT Token")
}

return &spb_jwt.RefreshResponse{Token: tokenResp(claims.Username, claims.Roles)}, nil

}
Expand Down Expand Up @@ -357,13 +368,13 @@ func (srv *Server) CopyConfig(ctx context.Context, req *spb.CopyConfigRequest) (
return nil, err
}
log.V(1).Info("gNOI: Sonic CopyConfig")

resp := &spb.CopyConfigResponse{
Output: &spb.SonicOutput {

},
}

reqstr, err := json.Marshal(req)
if err != nil {
return nil, status.Error(codes.Unknown, err.Error())
Expand All @@ -373,12 +384,12 @@ func (srv *Server) CopyConfig(ctx context.Context, req *spb.CopyConfigRequest) (
if err != nil {
return nil, status.Error(codes.Unknown, err.Error())
}

err = json.Unmarshal(jsresp, resp)
if err != nil {
return nil, status.Error(codes.Unknown, err.Error())
}

return resp, nil
}

Expand All @@ -388,7 +399,7 @@ func (srv *Server) ShowTechsupport(ctx context.Context, req *spb.TechsupportRequ
return nil, err
}
log.V(1).Info("gNOI: Sonic ShowTechsupport")

resp := &spb.TechsupportResponse{
Output: &spb.TechsupportResponse_Output {

Expand All @@ -404,13 +415,13 @@ func (srv *Server) ShowTechsupport(ctx context.Context, req *spb.TechsupportRequ
if err != nil {
return nil, status.Error(codes.Unknown, err.Error())
}

err = json.Unmarshal(jsresp, resp)
if err != nil {
return nil, status.Error(codes.Unknown, err.Error())
}


return resp, nil
}

Expand All @@ -420,7 +431,7 @@ func (srv *Server) ImageInstall(ctx context.Context, req *spb.ImageInstallReques
return nil, err
}
log.V(1).Info("gNOI: Sonic ImageInstall")

resp := &spb.ImageInstallResponse{
Output: &spb.SonicOutput {

Expand All @@ -436,13 +447,13 @@ func (srv *Server) ImageInstall(ctx context.Context, req *spb.ImageInstallReques
if err != nil {
return nil, status.Error(codes.Unknown, err.Error())
}

err = json.Unmarshal(jsresp, resp)
if err != nil {
return nil, status.Error(codes.Unknown, err.Error())
}


return resp, nil
}

Expand All @@ -452,7 +463,7 @@ func (srv *Server) ImageRemove(ctx context.Context, req *spb.ImageRemoveRequest)
return nil, err
}
log.V(1).Info("gNOI: Sonic ImageRemove")

resp := &spb.ImageRemoveResponse{
Output: &spb.SonicOutput {

Expand All @@ -468,7 +479,7 @@ func (srv *Server) ImageRemove(ctx context.Context, req *spb.ImageRemoveRequest)
if err != nil {
return nil, status.Error(codes.Unknown, err.Error())
}

err = json.Unmarshal(jsresp, resp)
if err != nil {
return nil, status.Error(codes.Unknown, err.Error())
Expand All @@ -482,7 +493,7 @@ func (srv *Server) ImageDefault(ctx context.Context, req *spb.ImageDefaultReques
return nil, err
}
log.V(1).Info("gNOI: Sonic ImageDefault")

resp := &spb.ImageDefaultResponse{
Output: &spb.SonicOutput {

Expand All @@ -504,6 +515,6 @@ func (srv *Server) ImageDefault(ctx context.Context, req *spb.ImageDefaultReques
return nil, status.Error(codes.Unknown, err.Error())
}


return resp, nil
}
Loading
Loading