implement rpc get keys
This commit is contained in:
parent
a1bad13490
commit
f75fa492a6
1 changed files with 29 additions and 0 deletions
29
main.go
29
main.go
|
|
@ -306,6 +306,7 @@ var rpcNewNode string
|
|||
var rpcQueryHost string
|
||||
var rpcQueryHostname string
|
||||
var rpcGetRoutes bool
|
||||
var rpcGetKeys bool
|
||||
|
||||
func rpcMain() {
|
||||
var cl rpc.LuxRpcClient
|
||||
|
|
@ -354,6 +355,33 @@ func rpcMain() {
|
|||
}
|
||||
}
|
||||
|
||||
if rpcGetKeys {
|
||||
rpcRes, rpcErr, err := cl.Execute(rpc.LuxRpcRequest{
|
||||
RequestID: counter,
|
||||
Controller: "ks",
|
||||
Command: "get",
|
||||
})
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "failed to send request: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
counter++
|
||||
|
||||
if rpcErr.ErrorCode != 0 {
|
||||
// we got error
|
||||
fmt.Fprintf(os.Stderr, "RPC error %d: %s\n", rpcErr.ErrorCode, rpcErr.Message)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// pretty print keys
|
||||
for _, node := range rpcRes.Keystore.Nodes {
|
||||
fmt.Printf("node %s\n", node.ID)
|
||||
}
|
||||
for _, host := range rpcRes.Keystore.Hosts {
|
||||
fmt.Printf("host %s\n", host.ID)
|
||||
}
|
||||
}
|
||||
|
||||
if rpcNewHost != "" {
|
||||
rpcRes, rpcErr, err := cl.Execute(rpc.LuxRpcRequest{
|
||||
RequestID: counter,
|
||||
|
|
@ -423,6 +451,7 @@ func main() {
|
|||
flag.StringVar(&rpcQueryHost, "rpc-query-host", "", "RPC node query host state by ID")
|
||||
flag.StringVar(&rpcQueryHostname, "rpc-query-hostname", "", "RPC node querty host state by hostname")
|
||||
flag.BoolVar(&rpcGetRoutes, "rpc-get-routes", false, "RPC node list established routes")
|
||||
flag.BoolVar(&rpcGetKeys, "rpc-get-keys", false, "RPC node list keys")
|
||||
flag.Parse()
|
||||
|
||||
if rpcPath != "" {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue