-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better modularization for gnoi_client.go
Better modularization for gnoi_client.go: Untangle gnoi_client.go into separate modules such as config, util, system, file and sonic.
- Loading branch information
Showing
9 changed files
with
383 additions
and
308 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package config | ||
|
||
import ( | ||
"flag" | ||
) | ||
|
||
var ( | ||
Module = flag.String("module", "System", "gNOI Module") | ||
Rpc = flag.String("rpc", "Time", "rpc call in specified module to call") | ||
Target = flag.String("target", "localhost:8080", "Address:port of gNOI Server") | ||
Args = flag.String("jsonin", "", "RPC Arguments in json format") | ||
JwtToken = flag.String("jwt_token", "", "JWT Token if required") | ||
TargetName = flag.String("target_name", "hostname.com", "The target name use to verify the hostname returned by TLS handshake") | ||
) | ||
|
||
func ParseFlag() { | ||
flag.Parse() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package file | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"encoding/json" | ||
pb "github.com/openconfig/gnoi/file" | ||
"github.com/sonic-net/sonic-gnmi/gnoi_client/utils" | ||
"github.com/sonic-net/sonic-gnmi/gnoi_client/config" | ||
"google.golang.org/grpc" | ||
) | ||
|
||
func Stat(conn *grpc.ClientConn, ctx context.Context) { | ||
fmt.Println("File Stat") | ||
ctx = utils.SetUserCreds(ctx) | ||
fc := pb.NewFileClient(conn) | ||
req := &pb.StatRequest{} | ||
err := json.Unmarshal([]byte(*config.Args), req) | ||
if err != nil { | ||
panic(err.Error()) | ||
} | ||
resp, err := fc.Stat(ctx, req) | ||
if err != nil { | ||
panic(err.Error()) | ||
} | ||
respstr, err := json.Marshal(resp) | ||
if err != nil { | ||
panic(err.Error()) | ||
} | ||
fmt.Println(string(respstr)) | ||
} |
Oops, something went wrong.